summaryrefslogtreecommitdiff
authorZhi Zhou <zhi.zhou@amlogic.com>2017-03-27 13:53:57 (GMT)
committer Zhi Zhou <zhi.zhou@amlogic.com>2017-04-10 03:06:16 (GMT)
commit4538d5ec07b84af401c3eb3d0d143d8b5aa079a5 (patch)
tree878d3d831a8028579ca16ecb1ae874596a52b51b
parentc600df36c593c850c186aea1eec9873fe83826f2 (diff)
downloadLibAudio-4538d5ec07b84af401c3eb3d0d143d8b5aa079a5.zip
LibAudio-4538d5ec07b84af401c3eb3d0d143d8b5aa079a5.tar.gz
LibAudio-4538d5ec07b84af401c3eb3d0d143d8b5aa079a5.tar.bz2
PD#141694 move audio related code out of libplayer
move from libplayer version: ---38b6d1 commit 38b6d1442acf10b7e302128ba7793cb5dcdbd18d depends version: --0d580fc65b020fc9723e235249635ef22acf44f3 Change-Id: I2deeefb3415409d591eec471bc02820a6bf70661 Signed-off-by: Zhi Zhou <zhi.zhou@amlogic.com>
Diffstat
-rw-r--r--Android.mk1
-rwxr-xr-xamadec/Android.mk282
-rw-r--r--amadec/acodec_lib_50/libstagefright_soft_dcvdec.so80
-rw-r--r--amadec/acodec_lib_50/libstagefright_soft_dtshd.so85
-rw-r--r--amadec/acodec_lib_50/libstagefright_soft_truehddec.so41
-rw-r--r--amadec/acodec_lib_android_n/libstagefright_soft_dcvdec.so109
-rw-r--r--amadec/acodec_lib_android_n/libstagefright_soft_dtshd.so272
-rw-r--r--amadec/acodec_lib_android_n/libstagefright_soft_truehddec.so87
-rwxr-xr-xamadec/acodec_lib_mx/libstagefright_soft_ddpdec.so113
-rwxr-xr-xamadec/acodec_lib_mx/libstagefright_soft_dtshd.so121
-rw-r--r--amadec/adec-armdec-mgt.h57
-rw-r--r--amadec/adec-external-ctrl.c899
-rw-r--r--amadec/adec-ffmpeg-mgt.c1550
-rw-r--r--amadec/adec-internal-mgt.c772
-rw-r--r--amadec/adec-message.c156
-rw-r--r--amadec/adec-message.h61
-rwxr-xr-xamadec/adec-pts-mgt.c1107
-rw-r--r--amadec/adec-pts-mgt.h82
-rw-r--r--amadec/adec-wfd-out.cpp361
-rw-r--r--amadec/adec-wfd.c811
-rw-r--r--amadec/adec_omx_brige.c284
-rw-r--r--amadec/adec_omx_brige.h56
-rw-r--r--amadec/adec_read.c200
-rw-r--r--amadec/adec_reg.h76
-rw-r--r--amadec/adec_write.c189
-rw-r--r--amadec/adec_write.h42
-rw-r--r--amadec/audio-dec.h314
-rw-r--r--amadec/audio_out/alsa-out.c1082
-rw-r--r--amadec/audio_out/aml_resample.c708
-rw-r--r--amadec/audio_out/aml_resample.h86
-rwxr-xr-xamadec/audio_out/android-out.cpp1640
-rw-r--r--amadec/audiodsp_update_format.c188
-rw-r--r--amadec/dsp/audiodsp-ctl.c471
-rw-r--r--amadec/dts_enc.c209
-rw-r--r--amadec/dts_enc.h11
-rw-r--r--amadec/dts_transenc_api.c143
-rw-r--r--amadec/dts_transenc_api.h19
-rw-r--r--amadec/feeder.c231
-rw-r--r--amadec/feeder.h26
-rw-r--r--amadec/include/adec-external-ctrl.h63
-rwxr-xr-xamadec/include/adec-macros.h41
-rw-r--r--amadec/include/adec-types.h53
-rwxr-xr-xamadec/include/alsa-out.h26
-rw-r--r--amadec/include/audio-out.h41
-rw-r--r--amadec/include/audiodsp.h142
-rw-r--r--amadec/include/audiodsp_update_format.h25
-rw-r--r--amadec/include/log-print.h26
-rwxr-xr-xamadec/omx_audio/ALAC_mediasource.cpp205
-rw-r--r--amadec/omx_audio/ALAC_mediasource.h62
-rwxr-xr-xamadec/omx_audio/ASF_mediasource.cpp184
-rw-r--r--amadec/omx_audio/ASF_mediasource.h127
-rwxr-xr-xamadec/omx_audio/Android.mk34
-rwxr-xr-xamadec/omx_audio/DDP_mediasource.cpp528
-rw-r--r--amadec/omx_audio/DDP_mediasource.h141
-rw-r--r--amadec/omx_audio/DTSHD_mediasource.cpp316
-rw-r--r--amadec/omx_audio/DTSHD_mediasource.h74
-rwxr-xr-xamadec/omx_audio/MP3_mediasource.cpp579
-rw-r--r--amadec/omx_audio/MP3_mediasource.h80
-rw-r--r--amadec/omx_audio/THD_mediasource.cpp229
-rw-r--r--amadec/omx_audio/THD_mediasource.h74
-rwxr-xr-xamadec/omx_audio/Vorbis_mediasource.cpp245
-rw-r--r--amadec/omx_audio/Vorbis_mediasource.h58
-rw-r--r--amadec/omx_audio/adec_omx.cpp421
-rw-r--r--amadec/omx_audio/adec_omx.h71
-rwxr-xr-xamadec/omx_audio/audio_mediasource.cpp37
-rw-r--r--amadec/omx_audio/audio_mediasource.h46
-rw-r--r--amadec/omx_audio/audio_medissource.h137
-rw-r--r--amadec/pcmenc_api.c147
-rw-r--r--amadec/pcmenc_api.h25
-rw-r--r--amadec/spdif_api.c306
-rw-r--r--amadec/spdif_api.h26
-rwxr-xr-xaudio_codec/Android.mk1
-rw-r--r--audio_codec/config.mk10
-rwxr-xr-xaudio_codec/libadpcm/Android.mk12
-rw-r--r--audio_codec/libadpcm/adpcm.h346
-rw-r--r--audio_codec/libadpcm/adpcm_decode.c841
-rwxr-xr-xaudio_codec/libamr/Android.mk25
-rwxr-xr-xaudio_codec/libamr/Makefile5
-rw-r--r--audio_codec/libamr/amr_decode.c186
-rw-r--r--audio_codec/libamr/amr_decode.h8
-rwxr-xr-xaudio_codec/libamr/dec.h18
-rw-r--r--audio_codec/libamr/dec_acelp.c620
-rwxr-xr-xaudio_codec/libamr/dec_acelp.h17
-rw-r--r--audio_codec/libamr/dec_dtx.c683
-rw-r--r--audio_codec/libamr/dec_dtx.h49
-rw-r--r--audio_codec/libamr/dec_gain.c853
-rw-r--r--audio_codec/libamr/dec_gain.h28
-rw-r--r--audio_codec/libamr/dec_if.c834
-rwxr-xr-xaudio_codec/libamr/dec_if.h23
-rw-r--r--audio_codec/libamr/dec_lpc.c789
-rw-r--r--audio_codec/libamr/dec_lpc.h25
-rw-r--r--audio_codec/libamr/dec_main.c842
-rw-r--r--audio_codec/libamr/dec_main.h57
-rw-r--r--audio_codec/libamr/dec_rom.c2114
-rw-r--r--audio_codec/libamr/dec_util.c1304
-rw-r--r--audio_codec/libamr/dec_util.h33
-rw-r--r--audio_codec/libamr/if_rom.c1030
-rwxr-xr-xaudio_codec/libamr/if_rom.h70
-rw-r--r--audio_codec/libamr/interf_dec.c906
-rw-r--r--audio_codec/libamr/interf_dec.h56
-rw-r--r--audio_codec/libamr/interf_rom.h1788
-rw-r--r--audio_codec/libamr/rom_dec.h13274
-rw-r--r--audio_codec/libamr/sp_dec.c6078
-rw-r--r--audio_codec/libamr/sp_dec.h83
-rwxr-xr-xaudio_codec/libamr/typedef.h17
-rwxr-xr-xaudio_codec/libape/Android.mk28
-rw-r--r--audio_codec/libape/Ape_decoder.h216
-rw-r--r--audio_codec/libape/amlogic_r30813_audio_ape_lib.c1
-rw-r--r--audio_codec/libape/apedec.c1120
-rw-r--r--audio_codec/libcook/Android.mk28
-rw-r--r--audio_codec/libcook/aac_bitstream.h133
-rw-r--r--audio_codec/libcook/aac_decode.h148
-rw-r--r--audio_codec/libcook/aac_reorder.h53
-rw-r--r--audio_codec/libcook/assembly.h119
-rw-r--r--audio_codec/libcook/challenge.h132
-rw-r--r--audio_codec/libcook/codec_defines.h93
-rw-r--r--audio_codec/libcook/coder.h287
-rw-r--r--audio_codec/libcook/cook_codec.h30
-rw-r--r--audio_codec/libcook/cook_decode.c624
-rw-r--r--audio_codec/libcook/cook_decode.h35
-rw-r--r--audio_codec/libcook/ga_config.h86
-rw-r--r--audio_codec/libcook/gecko2codec.c833
-rw-r--r--audio_codec/libcook/gecko2codec.h60
-rw-r--r--audio_codec/libcook/helix_config.h92
-rw-r--r--audio_codec/libcook/helix_mime_types.h56
-rw-r--r--audio_codec/libcook/helix_result.h107
-rw-r--r--audio_codec/libcook/helix_types.h305
-rw-r--r--audio_codec/libcook/helix_utils.h106
-rw-r--r--audio_codec/libcook/md5.h113
-rw-r--r--audio_codec/libcook/memory_utils.c100
-rw-r--r--audio_codec/libcook/memory_utils.h58
-rw-r--r--audio_codec/libcook/pack_utils.c306
-rw-r--r--audio_codec/libcook/pack_utils.h93
-rw-r--r--audio_codec/libcook/packet_defines.h48
-rw-r--r--audio_codec/libcook/ra8lbr_decode.c378
-rw-r--r--audio_codec/libcook/ra8lbr_decode.h161
-rw-r--r--audio_codec/libcook/ra_backend.h94
-rw-r--r--audio_codec/libcook/ra_bitpack.c197
-rw-r--r--audio_codec/libcook/ra_buffers.c127
-rw-r--r--audio_codec/libcook/ra_category.c298
-rw-r--r--audio_codec/libcook/ra_couple.c224
-rw-r--r--audio_codec/libcook/ra_decode.c321
-rw-r--r--audio_codec/libcook/ra_decode.h183
-rw-r--r--audio_codec/libcook/ra_depack.c230
-rw-r--r--audio_codec/libcook/ra_depack.h177
-rw-r--r--audio_codec/libcook/ra_depack_internal.c1710
-rw-r--r--audio_codec/libcook/ra_depack_internal.h232
-rw-r--r--audio_codec/libcook/ra_envelope.c123
-rw-r--r--audio_codec/libcook/ra_fft.c368
-rw-r--r--audio_codec/libcook/ra_format_info.h60
-rw-r--r--audio_codec/libcook/ra_gainctrl.c584
-rw-r--r--audio_codec/libcook/ra_huffman.c86
-rw-r--r--audio_codec/libcook/ra_hufftabs.c244
-rw-r--r--audio_codec/libcook/ra_mlt.c357
-rw-r--r--audio_codec/libcook/ra_sqvh.c431
-rw-r--r--audio_codec/libcook/ra_trigtabs.c932
-rw-r--r--audio_codec/libcook/rasl.c376
-rw-r--r--audio_codec/libcook/rasl.h71
-rw-r--r--audio_codec/libcook/rdtpck.h153
-rw-r--r--audio_codec/libcook/rm_error.h54
-rw-r--r--audio_codec/libcook/rm_error_default.c58
-rw-r--r--audio_codec/libcook/rm_error_default.h53
-rw-r--r--audio_codec/libcook/rm_io_default.c101
-rw-r--r--audio_codec/libcook/rm_io_default.h49
-rw-r--r--audio_codec/libcook/rm_memory.h54
-rw-r--r--audio_codec/libcook/rm_memory_default.c54
-rw-r--r--audio_codec/libcook/rm_memory_default.h46
-rw-r--r--audio_codec/libcook/rm_packet.c117
-rw-r--r--audio_codec/libcook/rm_packet.h80
-rw-r--r--audio_codec/libcook/rm_parse.h302
-rw-r--r--audio_codec/libcook/rm_parser.c649
-rw-r--r--audio_codec/libcook/rm_parser_internal.c3342
-rw-r--r--audio_codec/libcook/rm_parser_internal.h420
-rw-r--r--audio_codec/libcook/rm_property.c105
-rw-r--r--audio_codec/libcook/rm_property.h107
-rw-r--r--audio_codec/libcook/rm_stream.c356
-rw-r--r--audio_codec/libcook/rm_stream.h115
-rw-r--r--audio_codec/libcook/rm_stream_internal.h77
-rw-r--r--audio_codec/libcook/rv20backend.h69
-rw-r--r--audio_codec/libcook/rv30backend.h68
-rw-r--r--audio_codec/libcook/rv_backend.h84
-rw-r--r--audio_codec/libcook/rv_backend_types.h198
-rw-r--r--audio_codec/libcook/rv_decode.h208
-rw-r--r--audio_codec/libcook/rv_decode_message.h492
-rw-r--r--audio_codec/libcook/rv_depack.c271
-rw-r--r--audio_codec/libcook/rv_depack.h162
-rw-r--r--audio_codec/libcook/rv_depack_internal.c1071
-rw-r--r--audio_codec/libcook/rv_depack_internal.h171
-rw-r--r--audio_codec/libcook/rv_format_info.h91
-rw-r--r--audio_codec/libcook/statname.h118
-rw-r--r--audio_codec/libcook/stream_hdr_structs.h66
-rw-r--r--audio_codec/libcook/stream_hdr_utils.c136
-rw-r--r--audio_codec/libcook/stream_hdr_utils.h77
-rw-r--r--audio_codec/libcook/string_utils.c87
-rw-r--r--audio_codec/libcook/string_utils.h62
-rw-r--r--audio_codec/libcook/tngpkt.h400
-rwxr-xr-xaudio_codec/libfaad/Android.mk101
-rwxr-xr-xaudio_codec/libfaad/Makefile130
-rw-r--r--audio_codec/libfaad/analysis.h52
-rwxr-xr-xaudio_codec/libfaad/audio.d3
-rw-r--r--audio_codec/libfaad/bits.c261
-rwxr-xr-xaudio_codec/libfaad/bits.d18
-rw-r--r--audio_codec/libfaad/bits.h446
-rw-r--r--audio_codec/libfaad/cfft.c988
-rw-r--r--audio_codec/libfaad/cfft.h55
-rw-r--r--audio_codec/libfaad/cfft_tab.h1816
-rw-r--r--audio_codec/libfaad/codebook/hcb.h140
-rw-r--r--audio_codec/libfaad/codebook/hcb_1.h186
-rw-r--r--audio_codec/libfaad/codebook/hcb_10.h312
-rw-r--r--audio_codec/libfaad/codebook/hcb_11.h415
-rw-r--r--audio_codec/libfaad/codebook/hcb_2.h185
-rw-r--r--audio_codec/libfaad/codebook/hcb_3.h196
-rw-r--r--audio_codec/libfaad/codebook/hcb_4.h199
-rw-r--r--audio_codec/libfaad/codebook/hcb_5.h196
-rw-r--r--audio_codec/libfaad/codebook/hcb_6.h182
-rw-r--r--audio_codec/libfaad/codebook/hcb_7.h162
-rw-r--r--audio_codec/libfaad/codebook/hcb_8.h173
-rw-r--r--audio_codec/libfaad/codebook/hcb_9.h372
-rw-r--r--audio_codec/libfaad/codebook/hcb_sf.h276
-rw-r--r--audio_codec/libfaad/common.c558
-rw-r--r--audio_codec/libfaad/common.h453
-rw-r--r--audio_codec/libfaad/decoder.c2266
-rw-r--r--audio_codec/libfaad/drc.c173
-rw-r--r--audio_codec/libfaad/drc.h49
-rw-r--r--audio_codec/libfaad/drm_dec.c912
-rw-r--r--audio_codec/libfaad/drm_dec.h99
-rw-r--r--audio_codec/libfaad/error.c72
-rw-r--r--audio_codec/libfaad/error.h44
-rw-r--r--audio_codec/libfaad/filtbank.c408
-rw-r--r--audio_codec/libfaad/filtbank.h61
-rw-r--r--audio_codec/libfaad/fixed.h287
-rw-r--r--audio_codec/libfaad/hcr.c422
-rw-r--r--audio_codec/libfaad/helixaac/aaccommon.h210
-rw-r--r--audio_codec/libfaad/helixaac/aacdec.c508
-rw-r--r--audio_codec/libfaad/helixaac/aacdec.h206
-rw-r--r--audio_codec/libfaad/helixaac/aactabs.c157
-rw-r--r--audio_codec/libfaad/helixaac/assembly.h631
-rw-r--r--audio_codec/libfaad/helixaac/assembly_mw.h743
-rw-r--r--audio_codec/libfaad/helixaac/bitstream.c261
-rw-r--r--audio_codec/libfaad/helixaac/bitstream.h74
-rw-r--r--audio_codec/libfaad/helixaac/buffers.c140
-rw-r--r--audio_codec/libfaad/helixaac/coder.h369
-rw-r--r--audio_codec/libfaad/helixaac/dct4.c337
-rw-r--r--audio_codec/libfaad/helixaac/decelmnt.c445
-rw-r--r--audio_codec/libfaad/helixaac/dequant.c379
-rw-r--r--audio_codec/libfaad/helixaac/fft.c391
-rw-r--r--audio_codec/libfaad/helixaac/filefmt.c539
-rw-r--r--audio_codec/libfaad/helixaac/huffman_helix.c450
-rw-r--r--audio_codec/libfaad/helixaac/hufftabs.c177
-rw-r--r--audio_codec/libfaad/helixaac/imdct.c596
-rw-r--r--audio_codec/libfaad/helixaac/noiseless.c513
-rw-r--r--audio_codec/libfaad/helixaac/pns_helix.c371
-rw-r--r--audio_codec/libfaad/helixaac/sbr.c433
-rw-r--r--audio_codec/libfaad/helixaac/sbr.h380
-rw-r--r--audio_codec/libfaad/helixaac/sbrfft.c368
-rw-r--r--audio_codec/libfaad/helixaac/sbrfreq.c673
-rw-r--r--audio_codec/libfaad/helixaac/sbrhfadj.c882
-rw-r--r--audio_codec/libfaad/helixaac/sbrhfgen.c655
-rw-r--r--audio_codec/libfaad/helixaac/sbrhuff.c494
-rw-r--r--audio_codec/libfaad/helixaac/sbrimdct.c447
-rw-r--r--audio_codec/libfaad/helixaac/sbrmath.c198
-rw-r--r--audio_codec/libfaad/helixaac/sbrqmf.c648
-rw-r--r--audio_codec/libfaad/helixaac/sbrside.c634
-rw-r--r--audio_codec/libfaad/helixaac/sbrtabs.c400
-rw-r--r--audio_codec/libfaad/helixaac/statname.h115
-rw-r--r--audio_codec/libfaad/helixaac/stproc.c251
-rw-r--r--audio_codec/libfaad/helixaac/tns_helix.c307
-rw-r--r--audio_codec/libfaad/helixaac/trigtabs.c1000
-rw-r--r--audio_codec/libfaad/helixaac/trigtabs_fltgen.c357
-rw-r--r--audio_codec/libfaad/huffman.c582
-rw-r--r--audio_codec/libfaad/huffman.h47
-rw-r--r--audio_codec/libfaad/ic_predict.c258
-rw-r--r--audio_codec/libfaad/ic_predict.h252
-rw-r--r--audio_codec/libfaad/iq_table.h16456
-rw-r--r--audio_codec/libfaad/is.c106
-rw-r--r--audio_codec/libfaad/is.h67
-rw-r--r--audio_codec/libfaad/kbd_win.h2294
-rw-r--r--audio_codec/libfaad/libaacdec.c544
-rw-r--r--audio_codec/libfaad/libaacdec.h64
-rwxr-xr-xaudio_codec/libfaad/libfaad2.def14
-rw-r--r--audio_codec/libfaad/lt_predict.c205
-rw-r--r--audio_codec/libfaad/lt_predict.h66
-rw-r--r--audio_codec/libfaad/mdct.c307
-rw-r--r--audio_codec/libfaad/mdct.h48
-rw-r--r--audio_codec/libfaad/mdct_tab.h3639
-rw-r--r--audio_codec/libfaad/mp4.c307
-rw-r--r--audio_codec/libfaad/mp4.h52
-rw-r--r--audio_codec/libfaad/ms.c71
-rw-r--r--audio_codec/libfaad/ms.h44
-rw-r--r--audio_codec/libfaad/neaacdec.h257
-rw-r--r--audio_codec/libfaad/output.c583
-rw-r--r--audio_codec/libfaad/output.h48
-rw-r--r--audio_codec/libfaad/pns.c273
-rw-r--r--audio_codec/libfaad/pns.h58
-rw-r--r--audio_codec/libfaad/ps_dec.c1905
-rw-r--r--audio_codec/libfaad/ps_dec.h151
-rw-r--r--audio_codec/libfaad/ps_syntax.c532
-rw-r--r--audio_codec/libfaad/ps_tables.h547
-rw-r--r--audio_codec/libfaad/pulse.c59
-rw-r--r--audio_codec/libfaad/pulse.h43
-rw-r--r--audio_codec/libfaad/rvlc.c524
-rw-r--r--audio_codec/libfaad/rvlc.h55
-rw-r--r--audio_codec/libfaad/sbr_dct.c2267
-rw-r--r--audio_codec/libfaad/sbr_dct.h52
-rw-r--r--audio_codec/libfaad/sbr_dec.c679
-rw-r--r--audio_codec/libfaad/sbr_dec.h253
-rw-r--r--audio_codec/libfaad/sbr_e_nf.c475
-rw-r--r--audio_codec/libfaad/sbr_e_nf.h50
-rw-r--r--audio_codec/libfaad/sbr_fbt.c737
-rw-r--r--audio_codec/libfaad/sbr_fbt.h55
-rw-r--r--audio_codec/libfaad/sbr_hfadj.c1644
-rw-r--r--audio_codec/libfaad/sbr_hfadj.h56
-rw-r--r--audio_codec/libfaad/sbr_hfgen.c647
-rw-r--r--audio_codec/libfaad/sbr_hfgen.h49
-rw-r--r--audio_codec/libfaad/sbr_huff.c344
-rw-r--r--audio_codec/libfaad/sbr_huff.h46
-rw-r--r--audio_codec/libfaad/sbr_noise.h564
-rw-r--r--audio_codec/libfaad/sbr_qmf.c614
-rw-r--r--audio_codec/libfaad/sbr_qmf.h55
-rw-r--r--audio_codec/libfaad/sbr_qmf_c.h368
-rw-r--r--audio_codec/libfaad/sbr_syntax.c893
-rw-r--r--audio_codec/libfaad/sbr_syntax.h68
-rw-r--r--audio_codec/libfaad/sbr_tf_grid.c247
-rw-r--r--audio_codec/libfaad/sbr_tf_grid.h47
-rw-r--r--audio_codec/libfaad/sine_win.h4296
-rw-r--r--audio_codec/libfaad/specrec.c1249
-rw-r--r--audio_codec/libfaad/specrec.h49
-rw-r--r--audio_codec/libfaad/ssr.c170
-rw-r--r--audio_codec/libfaad/ssr.h59
-rw-r--r--audio_codec/libfaad/ssr_fb.c191
-rw-r--r--audio_codec/libfaad/ssr_fb.h53
-rw-r--r--audio_codec/libfaad/ssr_ipqf.c171
-rw-r--r--audio_codec/libfaad/ssr_ipqf.h46
-rw-r--r--audio_codec/libfaad/ssr_win.h635
-rw-r--r--audio_codec/libfaad/structs.h513
-rw-r--r--audio_codec/libfaad/syntax.c2539
-rw-r--r--audio_codec/libfaad/syntax.h129
-rw-r--r--audio_codec/libfaad/tns.c304
-rw-r--r--audio_codec/libfaad/tns.h51
-rwxr-xr-xaudio_codec/libflac/Android.mk22
-rw-r--r--audio_codec/libflac/avcodec.h337
-rw-r--r--audio_codec/libflac/bswap.h94
-rw-r--r--audio_codec/libflac/codec.h36
-rw-r--r--audio_codec/libflac/codec_message.h109
-rw-r--r--audio_codec/libflac/common.h356
-rw-r--r--audio_codec/libflac/crc.c146
-rw-r--r--audio_codec/libflac/crc.h46
-rw-r--r--audio_codec/libflac/flac.c43
-rw-r--r--audio_codec/libflac/flac.h124
-rw-r--r--audio_codec/libflac/flac_decode.c943
-rw-r--r--audio_codec/libflac/flacdata.c38
-rw-r--r--audio_codec/libflac/flacdata.h29
-rw-r--r--audio_codec/libflac/get_bits.h564
-rw-r--r--audio_codec/libflac/golomb.h585
-rw-r--r--audio_codec/libflac/internal.h195
-rw-r--r--audio_codec/libflac/intreadwrite.h390
-rw-r--r--audio_codec/libflac/mathops.h78
-rw-r--r--audio_codec/libflac/types.h49
-rwxr-xr-xaudio_codec/liblpcm/Android.mk13
-rw-r--r--audio_codec/liblpcm/lpcm_decode.c437
-rwxr-xr-xaudio_codec/libmad/Android.mk13
-rwxr-xr-xaudio_codec/libmad/D.dat607
-rw-r--r--audio_codec/libmad/bit.c244
-rw-r--r--audio_codec/libmad/bit.h47
-rw-r--r--audio_codec/libmad/config.h133
-rw-r--r--audio_codec/libmad/decoder.c1102
-rw-r--r--audio_codec/libmad/decoder.h91
-rw-r--r--audio_codec/libmad/fixed.c85
-rw-r--r--audio_codec/libmad/fixed.h499
-rw-r--r--audio_codec/libmad/frame.c525
-rw-r--r--audio_codec/libmad/frame.h118
-rw-r--r--audio_codec/libmad/global.h58
-rw-r--r--audio_codec/libmad/huffman.c3109
-rw-r--r--audio_codec/libmad/huffman.h66
-rwxr-xr-xaudio_codec/libmad/imdct_l_arm.S1000
-rwxr-xr-xaudio_codec/libmad/imdct_s.dat62
-rw-r--r--audio_codec/libmad/layer12.c552
-rwxr-xr-xaudio_codec/libmad/layer12.h31
-rw-r--r--audio_codec/libmad/layer3.c2742
-rwxr-xr-xaudio_codec/libmad/layer3.h30
-rw-r--r--audio_codec/libmad/mad.h966
-rwxr-xr-xaudio_codec/libmad/qc_table.dat77
-rwxr-xr-xaudio_codec/libmad/rq_table.dat8747
-rwxr-xr-xaudio_codec/libmad/sf_table.dat106
-rw-r--r--audio_codec/libmad/stream.c185
-rw-r--r--audio_codec/libmad/stream.h111
-rw-r--r--audio_codec/libmad/synth.c921
-rw-r--r--audio_codec/libmad/synth.h69
-rw-r--r--audio_codec/libmad/timer.c493
-rw-r--r--audio_codec/libmad/timer.h100
-rw-r--r--audio_codec/libmad/version.c91
-rw-r--r--audio_codec/libmad/version.h47
-rwxr-xr-xaudio_codec/libpcm/Android.mk11
-rw-r--r--audio_codec/libpcm/intreadwrite.h390
-rw-r--r--audio_codec/libpcm/pcm_decode.c780
-rw-r--r--audio_codec/libraac/Android.mk51
-rw-r--r--audio_codec/libraac/aac_bitstream.c200
-rw-r--r--audio_codec/libraac/aac_bitstream.h133
-rw-r--r--audio_codec/libraac/aac_decode.h148
-rw-r--r--audio_codec/libraac/aac_decode_main.c396
-rw-r--r--audio_codec/libraac/aac_reorder.c85
-rw-r--r--audio_codec/libraac/aac_reorder.h53
-rw-r--r--audio_codec/libraac/aaccommon.h200
-rw-r--r--audio_codec/libraac/aacdec.c607
-rw-r--r--audio_codec/libraac/aacdec.h200
-rw-r--r--audio_codec/libraac/aactabs.c157
-rw-r--r--audio_codec/libraac/assembly.h147
-rw-r--r--audio_codec/libraac/bitstream.c451
-rw-r--r--audio_codec/libraac/bitstream.h76
-rw-r--r--audio_codec/libraac/buffers.c132
-rw-r--r--audio_codec/libraac/coder.h370
-rw-r--r--audio_codec/libraac/dct4.c339
-rw-r--r--audio_codec/libraac/decelmnt.c451
-rw-r--r--audio_codec/libraac/dequant.c382
-rw-r--r--audio_codec/libraac/fft.c393
-rw-r--r--audio_codec/libraac/filefmt.c531
-rw-r--r--audio_codec/libraac/ga_config.c209
-rw-r--r--audio_codec/libraac/ga_config.h86
-rw-r--r--audio_codec/libraac/huffman.c449
-rw-r--r--audio_codec/libraac/hufftabs.c177
-rw-r--r--audio_codec/libraac/imdct.c598
-rw-r--r--audio_codec/libraac/include/challenge.h132
-rw-r--r--audio_codec/libraac/include/codec_defines.h93
-rw-r--r--audio_codec/libraac/include/gecko2codec.h60
-rw-r--r--audio_codec/libraac/include/helix_config.h92
-rw-r--r--audio_codec/libraac/include/helix_mime_types.h56
-rw-r--r--audio_codec/libraac/include/helix_result.h107
-rw-r--r--audio_codec/libraac/include/helix_types.h305
-rw-r--r--audio_codec/libraac/include/helix_utils.h106
-rw-r--r--audio_codec/libraac/include/md5.h113
-rw-r--r--audio_codec/libraac/include/memory_utils.h58
-rw-r--r--audio_codec/libraac/include/pack_utils.h93
-rw-r--r--audio_codec/libraac/include/packet_defines.h48
-rw-r--r--audio_codec/libraac/include/ra8lbr_decode.h161
-rw-r--r--audio_codec/libraac/include/ra_backend.h94
-rw-r--r--audio_codec/libraac/include/ra_decode.h183
-rw-r--r--audio_codec/libraac/include/ra_depack.h177
-rw-r--r--audio_codec/libraac/include/ra_format_info.h60
-rw-r--r--audio_codec/libraac/include/rasl.h71
-rw-r--r--audio_codec/libraac/include/rdtpck.h153
-rw-r--r--audio_codec/libraac/include/rm_error.h54
-rw-r--r--audio_codec/libraac/include/rm_error_default.h53
-rw-r--r--audio_codec/libraac/include/rm_io_default.h49
-rw-r--r--audio_codec/libraac/include/rm_memory.h54
-rw-r--r--audio_codec/libraac/include/rm_memory_default.h46
-rw-r--r--audio_codec/libraac/include/rm_packet.h80
-rw-r--r--audio_codec/libraac/include/rm_parse.h302
-rw-r--r--audio_codec/libraac/include/rm_property.h107
-rw-r--r--audio_codec/libraac/include/rm_stream.h115
-rw-r--r--audio_codec/libraac/include/rm_stream_internal.h77
-rw-r--r--audio_codec/libraac/include/rv20backend.h69
-rw-r--r--audio_codec/libraac/include/rv30backend.h68
-rw-r--r--audio_codec/libraac/include/rv_backend.h84
-rw-r--r--audio_codec/libraac/include/rv_backend_types.h198
-rw-r--r--audio_codec/libraac/include/rv_decode.h208
-rw-r--r--audio_codec/libraac/include/rv_decode_message.h492
-rw-r--r--audio_codec/libraac/include/rv_depack.h162
-rw-r--r--audio_codec/libraac/include/rv_format_info.h91
-rw-r--r--audio_codec/libraac/include/statname.h118
-rw-r--r--audio_codec/libraac/include/stream_hdr_structs.h66
-rw-r--r--audio_codec/libraac/include/stream_hdr_utils.h77
-rw-r--r--audio_codec/libraac/include/string_utils.h62
-rw-r--r--audio_codec/libraac/include/tngpkt.h400
-rw-r--r--audio_codec/libraac/memory_utils.c100
-rw-r--r--audio_codec/libraac/noiseless.c503
-rw-r--r--audio_codec/libraac/pack_utils.c306
-rw-r--r--audio_codec/libraac/pns.c369
-rw-r--r--audio_codec/libraac/ra_depack.c230
-rw-r--r--audio_codec/libraac/ra_depack_internal.c1713
-rw-r--r--audio_codec/libraac/ra_depack_internal.h232
-rw-r--r--audio_codec/libraac/raac_decode.c854
-rw-r--r--audio_codec/libraac/raac_decode.h37
-rw-r--r--audio_codec/libraac/rm_error_default.c60
-rw-r--r--audio_codec/libraac/rm_io_default.c101
-rw-r--r--audio_codec/libraac/rm_memory_default.c54
-rw-r--r--audio_codec/libraac/rm_packet.c117
-rw-r--r--audio_codec/libraac/rm_parser.c649
-rw-r--r--audio_codec/libraac/rm_parser_internal.c3342
-rw-r--r--audio_codec/libraac/rm_parser_internal.h420
-rw-r--r--audio_codec/libraac/rm_property.c105
-rw-r--r--audio_codec/libraac/rm_stream.c356
-rw-r--r--audio_codec/libraac/rv_depack.c271
-rw-r--r--audio_codec/libraac/rv_depack_internal.c1071
-rw-r--r--audio_codec/libraac/rv_depack_internal.h171
-rw-r--r--audio_codec/libraac/sbr.c431
-rw-r--r--audio_codec/libraac/sbr.h381
-rwxr-xr-xaudio_codec/libraac/sbrcov.s164
-rw-r--r--audio_codec/libraac/sbrfft.c368
-rw-r--r--audio_codec/libraac/sbrfreq.c667
-rw-r--r--audio_codec/libraac/sbrhfadj.c877
-rw-r--r--audio_codec/libraac/sbrhfgen.c646
-rw-r--r--audio_codec/libraac/sbrhuff.c492
-rw-r--r--audio_codec/libraac/sbrimdct.c447
-rw-r--r--audio_codec/libraac/sbrmath.c198
-rw-r--r--audio_codec/libraac/sbrqmf.c643
-rwxr-xr-xaudio_codec/libraac/sbrqmfak.s182
-rwxr-xr-xaudio_codec/libraac/sbrqmfsk.s130
-rw-r--r--audio_codec/libraac/sbrside.c615
-rw-r--r--audio_codec/libraac/sbrtabs.c400
-rw-r--r--audio_codec/libraac/statname.h115
-rw-r--r--audio_codec/libraac/stproc.c252
-rw-r--r--audio_codec/libraac/stream_hdr_utils.c136
-rw-r--r--audio_codec/libraac/string_utils.c87
-rw-r--r--audio_codec/libraac/tns.c307
-rw-r--r--audio_codec/libraac/trigtabs.c1000
-rw-r--r--audio_codec/libraac/trigtabs_fltgen.c357
-rwxr-xr-xaudio_codec/wfd_aac_decoder/Android.mk23
-rw-r--r--audio_codec/wfd_aac_decoder/aaccommon.h210
-rw-r--r--audio_codec/wfd_aac_decoder/aacdec.c508
-rw-r--r--audio_codec/wfd_aac_decoder/aacdec.h206
-rw-r--r--audio_codec/wfd_aac_decoder/aactabs.c157
-rw-r--r--audio_codec/wfd_aac_decoder/assembly.h640
-rw-r--r--audio_codec/wfd_aac_decoder/assembly_mw.h743
-rw-r--r--audio_codec/wfd_aac_decoder/bitstream.c261
-rw-r--r--audio_codec/wfd_aac_decoder/bitstream.h74
-rw-r--r--audio_codec/wfd_aac_decoder/buffers.c140
-rw-r--r--audio_codec/wfd_aac_decoder/coder.h369
-rw-r--r--audio_codec/wfd_aac_decoder/dct4.c337
-rw-r--r--audio_codec/wfd_aac_decoder/decelmnt.c445
-rw-r--r--audio_codec/wfd_aac_decoder/dequant.c379
-rw-r--r--audio_codec/wfd_aac_decoder/fft.c391
-rw-r--r--audio_codec/wfd_aac_decoder/filefmt.c539
-rw-r--r--audio_codec/wfd_aac_decoder/helix_aac_decode.c548
-rw-r--r--audio_codec/wfd_aac_decoder/huffman.c450
-rw-r--r--audio_codec/wfd_aac_decoder/hufftabs.c177
-rw-r--r--audio_codec/wfd_aac_decoder/imdct.c596
-rw-r--r--audio_codec/wfd_aac_decoder/noiseless.c513
-rw-r--r--audio_codec/wfd_aac_decoder/pns.c371
-rw-r--r--audio_codec/wfd_aac_decoder/sbr.c434
-rw-r--r--audio_codec/wfd_aac_decoder/sbr.h380
-rw-r--r--audio_codec/wfd_aac_decoder/sbrfft.c368
-rw-r--r--audio_codec/wfd_aac_decoder/sbrfreq.c673
-rw-r--r--audio_codec/wfd_aac_decoder/sbrhfadj.c882
-rw-r--r--audio_codec/wfd_aac_decoder/sbrhfgen.c655
-rw-r--r--audio_codec/wfd_aac_decoder/sbrhuff.c494
-rw-r--r--audio_codec/wfd_aac_decoder/sbrimdct.c447
-rw-r--r--audio_codec/wfd_aac_decoder/sbrmath.c198
-rw-r--r--audio_codec/wfd_aac_decoder/sbrqmf.c648
-rw-r--r--audio_codec/wfd_aac_decoder/sbrside.c634
-rw-r--r--audio_codec/wfd_aac_decoder/sbrtabs.c400
-rw-r--r--audio_codec/wfd_aac_decoder/statname.h115
-rw-r--r--audio_codec/wfd_aac_decoder/stproc.c251
-rw-r--r--audio_codec/wfd_aac_decoder/tns.c307
-rw-r--r--audio_codec/wfd_aac_decoder/trigtabs.c1000
-rw-r--r--audio_codec/wfd_aac_decoder/trigtabs_fltgen.c357
545 files changed, 230976 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..5053e7d
--- a/dev/null
+++ b/Android.mk
@@ -0,0 +1 @@
+include $(call all-subdir-makefiles)
diff --git a/amadec/Android.mk b/amadec/Android.mk
new file mode 100755
index 0000000..51fcaa8
--- a/dev/null
+++ b/amadec/Android.mk
@@ -0,0 +1,282 @@
+LOCAL_PATH:= $(call my-dir)
+include $(TOP)/hardware/amlogic/media/media_base_config.mk
+AMAVUTILS_INCLUDE=$(AMAVUTILS_PATH)/include/
+ifeq ($(BUILD_WITH_BOOT_PLAYER),true)
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS := \
+ -fPIC -D_POSIX_SOURCE
+
+
+
+ifneq (0, $(shell expr $(PLATFORM_VERSION) \>= 5.0))
+ALSA_LIB_DIR=vendor/amlogic/external/alsa-lib/
+else
+ALSA_LIB_DIR=external/alsa-lib/
+endif
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/include \
+ $(AMAVUTILS_INCLUDE) \
+ $(TOP)/$(ALSA_LIB_DIR)/include
+
+
+ifneq (0, $(shell expr $(PLATFORM_VERSION) \> 4.1.0))
+ LOCAL_CFLAGS += -D_VERSION_JB
+else
+ ifneq (0, $(shell expr $(PLATFORM_VERSION) \> 4.0.0))
+ LOCAL_CFLAGS += -D_VERSION_ICS
+ endif
+endif
+
+LOCAL_CFLAGS += -DALSA_OUT
+#ifdef DOLBY_UDC
+LOCAL_CFLAGS+=-DDOLBY_USE_ARMDEC
+#endif
+LOCAL_SHARED_LIBRARIES += libasound
+
+LOCAL_SRC_FILES := \
+ adec-external-ctrl.c adec-internal-mgt.c adec-ffmpeg-mgt.c adec-message.c adec-pts-mgt.c feeder.c adec_write.c adec_read.c\
+ dsp/audiodsp-ctl.c audio_out/alsa-out.c audio_out/aml_resample.c audiodsp_update_format.c spdif_api.c pcmenc_api.c \
+ dts_transenc_api.c dts_enc.c adec_omx_brige.c adec-wfd.c
+
+LOCAL_MODULE := libamadec_alsa
+
+LOCAL_ARM_MODE := arm
+
+include $(BUILD_STATIC_LIBRARY)
+
+endif
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS := \
+ -fPIC -D_POSIX_SOURCE
+#ifdef DOLBY_UDC
+ LOCAL_CFLAGS+=-DDOLBY_USE_ARMDEC
+#endif
+
+ifdef DOLBY_DS1_UDC
+ LOCAL_CFLAGS += -DDOLBY_DS1_UDC
+endif
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/include \
+ $(AMAVUTILS_INCLUDE)
+
+# PLATFORM_SDK_VERSION:
+# 4.4 = 19
+# 4.3 = 18
+# 4.2 = 17
+LOCAL_CFLAGS += -DANDROID_PLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION)
+
+ifneq (0, $(shell expr $(PLATFORM_VERSION) \>= 4.3))
+ LOCAL_CFLAGS += -DANDROID_VERSION_JBMR2_UP=1
+ ifneq ($(TARGET_BOARD_PLATFORM),meson6)
+ LOCAL_CFLAGS += -DUSE_ARM_AUDIO_DEC
+ endif
+endif
+
+ifneq (0, $(shell expr $(PLATFORM_VERSION) \> 4.1.0))
+ LOCAL_CFLAGS += -D_VERSION_JB
+else
+ ifneq (0, $(shell expr $(PLATFORM_VERSION) \> 4.0.0))
+ LOCAL_CFLAGS += -D_VERSION_ICS
+ endif
+endif
+
+LOCAL_SRC_FILES := \
+ adec-external-ctrl.c adec-internal-mgt.c adec-ffmpeg-mgt.c adec-message.c adec-pts-mgt.c feeder.c adec_write.c adec_read.c\
+ dsp/audiodsp-ctl.c audio_out/android-out.cpp audio_out/aml_resample.c audiodsp_update_format.c spdif_api.c pcmenc_api.c \
+ dts_transenc_api.c dts_enc.c adec_omx_brige.c adec-wfd.c
+
+LOCAL_MODULE := libamadec
+
+LOCAL_ARM_MODE := arm
+
+
+include $(BUILD_STATIC_LIBRARY)
+
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS := \
+ -fPIC -D_POSIX_SOURCE
+#ifdef DOLBY_UDC
+ LOCAL_CFLAGS+=-DDOLBY_USE_ARMDEC
+#endif
+
+
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/include \
+ $(AMAVUTILS_INCLUDE)
+
+
+LOCAL_CFLAGS += -DANDROID_PLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION)
+
+ifneq (0, $(shell expr $(PLATFORM_VERSION) \>= 4.3))
+ LOCAL_CFLAGS += -DANDROID_VERSION_JBMR2_UP=1
+endif
+
+ifneq (0, $(shell expr $(PLATFORM_VERSION) \> 4.1.0))
+ LOCAL_CFLAGS += -D_VERSION_JB
+else
+ ifneq (0, $(shell expr $(PLATFORM_VERSION) \> 4.0.0))
+ LOCAL_CFLAGS += -D_VERSION_ICS
+ endif
+endif
+
+LOCAL_SRC_FILES := \
+ adec-external-ctrl.c adec-internal-mgt.c adec-ffmpeg-mgt.c adec-message.c adec-pts-mgt.c feeder.c adec_write.c adec_read.c\
+ dsp/audiodsp-ctl.c audio_out/android-out.cpp audio_out/aml_resample.c audiodsp_update_format.c \
+ spdif_api.c pcmenc_api.c dts_transenc_api.c dts_enc.c adec_omx_brige.c adec-wfd.c
+
+LOCAL_MODULE := libamadec
+
+LOCAL_ARM_MODE := arm
+##################################################
+#$(shell cp $(LOCAL_PATH)/acodec_lib/*.so $(TARGET_OUT)/lib)
+###################################################
+LOCAL_SHARED_LIBRARIES += libutils libmedia libz libbinder libdl libcutils libc libamadec_omx_api libamavutils
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_SHARED_LIBRARY)
+
+
+###################module make file for libamadec_omx_api ######################################
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS := \
+ -fPIC -D_POSIX_SOURCE -DDOLBY_DDPDEC51_MULTICHANNEL_ENDPOINT
+LOCAL_CFLAGS += -DANDROID_PLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION)
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/omx_audio/include \
+ $(LOCAL_PATH)/omx_audio/../ \
+ $(LOCAL_PATH)/omx_audio/../include \
+ $(AMAVUTILS_INCLUDE) \
+ frameworks/native/include/media/openmax \
+ frameworks/av/include/media/stagefright \
+ frameworks/native/include/utils
+
+LOCAL_SRC_FILES := \
+ /omx_audio/adec_omx.cpp \
+ /omx_audio/audio_mediasource.cpp \
+ /omx_audio/DDP_mediasource.cpp \
+ /omx_audio/ALAC_mediasource.cpp \
+ /omx_audio/MP3_mediasource.cpp \
+ /omx_audio/ASF_mediasource.cpp \
+ /omx_audio/DTSHD_mediasource.cpp \
+ /omx_audio/Vorbis_mediasource.cpp \
+ /omx_audio/THD_mediasource.cpp
+
+LOCAL_MODULE := libamadec_omx_api
+LOCAL_MODULE_TAGS := optional
+LOCAL_ARM_MODE := arm
+
+LOCAL_SHARED_LIBRARIES += libutils libmedia libz libbinder libdl libcutils libc libstagefright \
+ libstagefright_omx libstagefright_yuv liblog libamavutils libstagefright_foundation
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
+#########################################################
+
+
+###################module make wfd audioout api ######################################
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS := \
+ -fPIC -D_POSIX_SOURCE -DDOLBY_DDPDEC51_MULTICHANNEL_ENDPOINT
+
+ifneq (0, $(shell expr $(PLATFORM_VERSION) \>= 4.3))
+ LOCAL_CFLAGS += -DANDROID_VERSION_JBMR2_UP=1
+endif
+ifneq (0, $(shell expr $(PLATFORM_VERSION) \> 4.1.0))
+ LOCAL_CFLAGS += -D_VERSION_JB
+else
+ ifneq (0, $(shell expr $(PLATFORM_VERSION) \> 4.0.0))
+ LOCAL_CFLAGS += -D_VERSION_ICS
+ endif
+endif
+LOCAL_CFLAGS += -DANDROID_PLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION)
+LOCAL_C_INCLUDES:= \
+ external/tinyalsa/include
+
+LOCAL_SRC_FILES := \
+ adec-wfd-out.cpp
+
+LOCAL_MODULE := libamadec_wfd_out
+LOCAL_MODULE_TAGS := optional
+LOCAL_ARM_MODE := arm
+
+LOCAL_SHARED_LIBRARIES += libutils libtinyalsa liblog libmedia libcutils libc
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
+#########################################################
+
+
+#
+# audio_firmware module
+# includes all audio firmware files, which are modules themselves.
+#
+ifeq (0, $(shell expr $(PLATFORM_VERSION) \>= 6.0))
+include $(CLEAR_VARS)
+
+ifeq ($(TARGET_BOARD_PLATFORM),meson6)
+ audio_firmware_dir := firmware-m6
+else ifeq ($(TARGET_BOARD_PLATFORM),meson8)
+ audio_firmware_dir := firmware-m8
+else
+ audio_firmware_dir := firmware
+endif
+
+# generate md5 checksum files
+$(shell cd $(LOCAL_PATH)/$(audio_firmware_dir) && { \
+for f in *.bin; do \
+ md5sum "$$f" > "$$f".checksum; \
+done;})
+
+# gather list of relative filenames
+audio_firmware_files := $(wildcard $(LOCAL_PATH)/$(audio_firmware_dir)/*.bin)
+audio_firmware_files += $(wildcard $(LOCAL_PATH)/$(audio_firmware_dir)/*.checksum)
+audio_firmware_files := $(patsubst $(LOCAL_PATH)/%,%,$(audio_firmware_files))
+
+# define function to create a module for each file
+# $(1): filename
+define _add-audio-firmware-module
+ include $$(CLEAR_VARS)
+ LOCAL_MODULE := audio-firmware_$(notdir $(1))
+ LOCAL_MODULE_STEM := $(notdir $(1))
+ _audio_firmware_modules += $$(LOCAL_MODULE)
+ LOCAL_SRC_FILES := $1
+ LOCAL_MODULE_TAGS := optional
+ LOCAL_MODULE_CLASS := ETC
+ LOCAL_MODULE_PATH := $$(TARGET_OUT_ETC)/firmware
+ include $$(BUILD_PREBUILT)
+endef
+
+# create modules, one for each file
+_audio_firmware_modules :=
+_audio_firmware :=
+$(foreach _firmware, $(audio_firmware_files), \
+ $(eval $(call _add-audio-firmware-module,$(_firmware))))
+
+#LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := audio_firmware
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_REQUIRED_MODULES := $(_audio_firmware_modules)
+
+include $(BUILD_PHONY_PACKAGE)
+
+_audio_firmware_modules :=
+_audio_firmware :=
+endif
diff --git a/amadec/acodec_lib_50/libstagefright_soft_dcvdec.so b/amadec/acodec_lib_50/libstagefright_soft_dcvdec.so
new file mode 100644
index 0000000..fdf1cfc
--- a/dev/null
+++ b/amadec/acodec_lib_50/libstagefright_soft_dcvdec.so
@@ -0,0 +1,80 @@
+ELF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+0å3ÿ/áÐKâ
+IÅó@ciyDJ”øƒ0„ø„PzDì²
+J{DµF›Xñ`ÿ÷0ì Fÿ÷2ì Fÿ÷6ì F½
+J{DµF›Xñ`ÿ÷ì Fÿ÷ì Fÿ÷
+ì F½
+Iñt F4FX_X
+€Cø pÿ÷të=Dø @`Tø‰`èѽèð‡þ?
+ñ ÈëEø  ohˆBÐFŽhÿ÷Ôê o†B1F÷Ñ@`ë ¢o’`Üø
+š™Jø0JøPÿ÷àé°g@`°o€`¥o³oªhÓø •B¿+F‘FUFšFÐ ÿ÷ÞéÙø
+ñgJø 0¢oh‚B¿¡FFÐ F¤hÿ÷déÙøx ”B÷ÑLFR`
+ë ¡o‰`Üø
+ïÝøÀ9F0F'Œø@þ÷hï,a/dÛø
+c”øƒ
+GÛ ñ"AFþ÷vî)F*F@Fþ÷vîFPFþ÷<îSJ”ø„0 Íø
+"þ÷‚íF@Fþ÷<í¡l Íaþ÷~íFàd
+— ”Oô€S ”Çö
+`Èø
+(F9Fþ÷¢ì
+'/@ò9µø
+À(Oê.Nê !i@ò,µø °(Oê#Cê '¯@òµø Oð*úñAê
+#ëBtÐÙOêÁ ù±ë@
+Ðÿ0jÐÿ1J ñ ˜ÿp
+REOê!Aê,%øÀCÙ5øpñ
+REOê @ê'%øpÙ5ø0ñŠBOê @ê'%øpÙ5ø°ñrEOê#Cê ,%øÀÙ5ø Oê*Jê!%ø(h¯ihªhÈø
+@ø °¿Kö€4ø
+Ð-¿JöDDtbÐ-¿OôúDtb0z€±(Ð
+0-ÎóÃóÂOê“Ð*%ÐU
+‚EÙ&j
+I
+JyDzDþ÷è8Fuç
+-
+Ý œ%I6hyD´BÑé
+
+
+
+
+
+
+
+
+
+
+
+
+°°¯€
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+A 
+ ",Dlibstagefright_soft_dcvdec.so
diff --git a/amadec/acodec_lib_50/libstagefright_soft_dtshd.so b/amadec/acodec_lib_50/libstagefright_soft_dtshd.so
new file mode 100644
index 0000000..45400c7
--- a/dev/null
+++ b/amadec/acodec_lib_50/libstagefright_soft_dtshd.so
@@ -0,0 +1,85 @@
+ELF
+
+
+
+
+
+
+
+
+
+
+0å3ÿ/áÐKâ
+hi•hQiª)DBø=ƒn F˜G”øP ˆKù!
+¨ « ñ0 “vàii1¹Õé#aeÄé#Êé#Úø +i©h’¢nhiÚøà
+“
+© “ãnBê š «ÍøÀrDÿ÷>ë+i
+™ji
+DjaZ*a€òŠ€cI cJyD“zDÿ÷ÌêXJ›
+hâd"Mh!
+±ÿ÷ ê n±ÿ÷"ê
+” ”” ””ÿ÷¤é–Oô
+” ””• – ””•ÿ÷Œé<g°½èðâ
+°½èðþB
+h}DoK õ€K ñ<
+BÛ¸ñ
+"(Fþ÷xï0`8Fþ÷hï
+í°ð½
+ŒTškYkTœc
+DOöÿt{Dà MDOöÿt}D“B5ÐÏ\Oê< 3Œê†²ð5ø
+ñÿ:qi ñ 2h@ê%K5asa¹ŸÐ
+Ñ0Fµaÿ÷–þ0Fÿ÷vþHð'àKBÐJ•B@ð胵a0FHðÿ÷‚þ#'³`w`Üã4iõ
+ñÿ: ñ Gê!1aškXkUc‡TDò
+ šcòa
+
+ËDkÓø´ MDcÉëÃø´@qiIDqa
+
+ãD`Dpa
+ñÿ:ri ñ Eê 0aUuaÄø´Öâ³h
+L BÑ IàM¨B Ñ IŠBÑ$!
+#)Äø´,â
+D²õ
+( ñÅø¨@Åø°
++}Ù™{Ñ¢ñ #Åø´@qàõ
+DZdsiDÁë
+
+‹DDqaÿ÷ì» $t`%Ãø´Pÿ÷å»õ
+ñÿ:ri ñ Aê%;5aPpaÄø´07ÿ÷λ²i•BÑ°h¹# à(Ñ# à(ôÀ«ãd0FÄø 0ÿ÷¤ú#s`ÿ÷¶»OFÿ÷³»Ðk
+ñP /FÏÄÏÄ—è
+à°H‡BЯIB Ñ$”7ˆAöÿr¹¿! ‘à3h«B¿ #“›¬ ! F“ÿ÷ÿ¨B@ðw F!ÿ÷dÿ! Fñ¼ÿ÷
+ÿ!
+!F F•ÿ÷Fÿ! Fÿ÷îþ!F Fÿ÷éþ!ƒF Fÿ÷8ÿ! Fÿ÷àþºñ ˜¿2©šˆ¿
+
+나¿Søh<»ñCê@Rø@ OêL¹e;eød@ð ñ
+–—/FWE€ð F !ÿ÷¡þ 7°ñZ?ôÑ”è
+­Ýø°…è
+! Fÿ÷’þÆë Àë ¬ñ
+­Oð
+Ò!’ÿ÷#þ›ZA¨@ø#ñçYF©ñ ÿ÷þ
+–¸e•è
+–•è
+ßøT°–—
+­Ýø€…è
+€ çÿ°°¨€Pçÿà
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+A 
+ ",Dlibstagefright_soft_dtshd.so
diff --git a/amadec/acodec_lib_50/libstagefright_soft_truehddec.so b/amadec/acodec_lib_50/libstagefright_soft_truehddec.so
new file mode 100644
index 0000000..a585a90
--- a/dev/null
+++ b/amadec/acodec_lib_50/libstagefright_soft_truehddec.so
@@ -0,0 +1,41 @@
+ELF
+
+
+
+
+
+
+
+0å3ÿ/áÐKâ
+’ÿ÷°ë–OôŠ0–iF N@F•~D••%” ””•
+– ” ” •ÿ÷šë°½èð
+°½èð
+ë(Fÿ÷ ëIJyDzDF@Fÿ÷Vê Fÿ÷ëG¹ HIJxDKyDzD{Dðç
+’~D –[à hn FˆGF
+„øZ ±hsi”ø[ë 2i¹ñ
+ QFXFÿ÷ý˜1F€ø€ Fÿ÷@êÅø€!)dhXFQF»h “ÿ÷öü ž F)F†ø€ÿ÷(ê á›øÀ›ø
+,œEôg¯Oð„ø[€›øJöDC( ’OêKö€1ðð
+¿ F
+üú
+úû ðQFÿ÷êcmšSEàe?ôD¯N J~DÍø
+™ šÿ÷<é
+NøF*iZF(aPF“ÿ÷é+i
+ë [D+a¡lõ42!PhÍøÀ’ÿ÷ˆé™ÝøÀƒF˜h[E<ÓÍø4°Øø
+ à0H)F #2X Fÿ÷éÄøÈŸ,I F#rX)Fÿ÷ é*J F)F
+#²Xà%J F)F³Xñ#ÿ÷üèËç
+»àH)F#2X FàßøTÀ F)F #Vø ÿ÷ÜèÄøÈ¿ßø@à F)F#Vø ÿ÷Òè K F)FòX
+#ÿ÷ÊèëG F)F#ÿ÷Äè7Ëç½èø
+¾Ìë
+û÷Âëú†ùŠ²ë§±²‰EØDÔø´/›™EÝ-Ù
+îJ!FzDF þ÷(ìþ÷îJ!FzDF þ÷ ìþ÷î J!FzDF °½è@
+
+
+
+
+
+
+
+
+
+A 
+ ",Dlibstagefright_soft_truehddec.so
diff --git a/amadec/acodec_lib_android_n/libstagefright_soft_dcvdec.so b/amadec/acodec_lib_android_n/libstagefright_soft_dcvdec.so
new file mode 100644
index 0000000..964a20a
--- a/dev/null
+++ b/amadec/acodec_lib_android_n/libstagefright_soft_dcvdec.so
@@ -0,0 +1,109 @@
+ELF
+
+
+
+
+
+
+
+
+
+
+
+
+ÅR
+
+
+
+0å3ÿ/áÐKâ
+ñl
+ñ\
+ñL
+ÿ÷úì F)Fÿ÷üì-  ñ`ùï
+/ `"ñ`ùï*ñ’"8Hø ø `xDø
+`ø `Gù
+Eù*Íéb1I”ø€ yD
+ `ùï*%HGù
+xDEù*–‘Íé  FÍé aAFÿ÷ºìH™xD
+@ù
+@ù
+(Fÿ÷lì@±5I(FyDÿ÷fì±”ø€
+"ÿ÷PìF(Fÿ÷RìàI JyDzDÿ÷Pì
+.¡ñ
+`ø `Gù
+Eù*Íé`-J”ø€
+FÆöpÍé &AF – Fÿ÷¢ë !`ùï
+ `ùï*!HGù
+xDEù*–‘Íé  FÍé aAFÿ÷ŒëH™xD
+c©ùÍŠxD`
+ñOð Aù
+!Âé 1Âø,Àø‚9±l‰jÑ`€l@jb
+
+‘ ñX‘ ñP‘Øø ‘h‘B
+™
+™Áé
+˜Àé
+šËøpËø@pÚé
+·gÇéwÛøx@¥h¥BиF þ÷xí)hÀé
+00F)F`"þ÷hî™ñ`
+XF)F`"
+/ ÓOöütÇöÿtêÐêWéF4Fah?Ôø
+øÿp èïp`ïòöÿ DùMêÑà
+ø ø
+ ø ø `ø ø ø `ø@øpøpø@ø@øpøpø@ø@øpøpø@$`‹ ´ë‘Ð+ÐC¹Kö€4àOôúDàJöDDDb‡.ÙOðÿ1qç
+2bÎø
+ hRAö
+Ùø
+ hRAö
+Ùø
+J
+ðð ¯)$Ü€)6Ð)OР)@ð
+ð"1Oô€@
+ð
+6±²ø
+ðAð
+ð
+ð
+
+
+­xD
+¨!F
+(FoðBF
+HÝø”xD
+± GpG€µF
+Ñ h)F2Fi F˜Gµñÿ?Ð
+àNòreÏöÿuà h
+Ð-Ð - Ðàñеñÿ?ÑñD
+ïë…
+pà•øJ
+àÿ÷ÔíOöTëÆ
+ Foð¨G °½µ
+±õ¨p
+ ¨‘©bh^hÍé
+B¿&¼ñ
+™xD
+ ßødxDpG¡õ€p($Øßèð
+–HxDpGÄHxDpGÀHxDpG½HxDpG»HxDpG¸HxDpG¶HxDpG³HxDpG±HxDpG®HxDpG¬HxDpG©HxDpG§HxDpG¤HxDpG¢HxDpG®HxDpGžHxDpG›HxDpG™HxDpG–HxDpG”HxDpG‘HxDpGHxDpGŒHxDpGŠHxDpG‡HxDpG…HxDpG‚HxDpG€HxDpG}HxDpG{HxDpGxHxDpGvHxDpGsHxDpGqHxDpGnHxDpGlHxDpGiHxDpGgHxDpGdHxDpGbHxDpG_HxDpG]HxDpGZHxDpGXHxDpGUHxDpGSHxDpGPHxDpGMHxDpGJHxDpGHHxDpGEHxDpGCHxDpG@HxDpG>HxDpG;HxDpG9HxDpG6HxDpG4HxDpG1HxDpG/HxDpG,HxDpG*HxDpG'HxDpG%HxDpG"HxDpG HxDpGHxDpGHxDpGHxDpGHxDpGHxDpGHxDpGHxDpG HxDpG HxDpGHxDpGHxDpGHxDpG
+
+À à
+
+/oáoá
+@-éÆÿÿë@½è’
+€L÷ÿ°°¬€ˆ÷ÿ°°°€Èûÿ
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+A 
+ "&Dlibstagefright_soft_dcvdec.so
diff --git a/amadec/acodec_lib_android_n/libstagefright_soft_dtshd.so b/amadec/acodec_lib_android_n/libstagefright_soft_dtshd.so
new file mode 100644
index 0000000..083cd3a
--- a/dev/null
+++ b/amadec/acodec_lib_android_n/libstagefright_soft_dtshd.so
@@ -0,0 +1,272 @@
+ELF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+“àøü¤YI.ÑðJb„Éè!ËþàŽõL]1›N…•¯Š2¹[0ïËÙŸÙqXÁ€A—f‚Ÿo' ̪uͽš¦D“”(¬Ÿ¬7XMJ8vùPO)§G8_áµE>)Ó¡ôlù"“˜_ß
+¤¼„iÅüµ¥â
+/ÅÈ=cݦþöŽ’@ƒ³ð5?ó8‹Îà¨=K ¡4‹ï
+`Gå?“ jQýÄÊ
+
+
+
+0å3ÿ/áÐKâ
+ FÄéfÿ÷Þë­©ªÍé`(Fÿ÷Üë(Fÿ÷Þ뱨ÿ÷àë Fÿ÷äëHæfxD ™
+°p½ÿ÷Üë I¬yD Fÿ÷Üë© Fÿ÷Þë Fÿ÷âëIFJ
+ñ”
+ñ„
+ñt
+ Åø¨
+H™xD
+%¡ ñaùï* ñxDIFGù*Eù
+ÍéhÍé  Æöp– Fÿ÷Në !`ùï
+ `ùï*&HGù
+xDEù*–‘Íé  FÍéaIFÿ÷8ëH&gxD™
+¡aùï*¡aùïJñAùJñ$Aù
+ñ4Aù* !QdøP!±ÁlÑ`€lbà!Ñ`Kö€1bdÑhÁd
+–ÿ÷ÐéF˜øP
+dx¹‹øpph€hÐé
+°p½þ÷<ïHIJxDKyDzD{Dþ÷JïI¬yD Fþ÷2ï© Fþ÷4ï Fþ÷6ïIFJ
+¦ñ
+`þ÷¦î°õ OØ&HxD
+hhhþ÷†îI
+ì~D
+ôîá Èø
+ôîá Èø
+ÝI@ò1JKyDzDÍí {D¿çÞø
+s
+Î~Dë€ohE§BÐ0((FõÓ((3ØßíbKò$Àò
+
+¸îAî
+î
+þ÷øë
+¼îÀ
+îê¾ñ
+FBùÍ
+`$¿%
+ë @BOöþaD#Ýø8€.
+!p!`p(
+ p Fåpþ÷úê'IF*F8Fþ÷úê²EЪë iFþ÷òêVFÈø
+•þ÷ÀèÀïP
+@ùÏ
+ÍéÍéš’Íé!šÓ
+xŽxÌxCêbNö
+™
+àXF)Fþ÷nè ˜`Ùç
+î F½"›
+Ñ !à@ò !àOô†q€Ñ
+"
+`pGF
+`pGF
+Kñ
+ÆéÆø  ºñÑ!˜
+Cñ
+œÒCñ
+DD@𯀘 ’
+`ñ›`(¿ ) Óð
+Ñ"™ 8Oð` ™` p`šäÆø°Oð•ä@ò€Íø€°Oð
+D™
+`™`!˜Fh0` p`àphOð( ј™
+yOy,‹yÉy2Ñ?GêbBê"C1à p`ÿ÷º˜dFÀø
+ p`ÿ÷ï¹?GêBCBê!Íø\ Áó @ò€18«FÏöiBјña` Æøàp`Bò WBò% ÅödÆòXLÁæ“]FOð
+Fh9D`,™`
+F
+ü÷lî>`(F°ð½€µ)Oð
+© ’1‘ à
+¨Øø
+¨ !
+šë@
+’ ˜ˆBÙ@àiëFD
+’
+­ !(F
+ -¿&)Fü÷hípC
+šë@
+’ ˜ˆBÙ@àiëFD
+’
+® !0F
+“ š¿!ŠBÙPàëI
+‘A¿Fˆ
+¨!
+/ÒßøÔ
+à@ò
+¨@ð™ ñ
+!×í
+œÍí
+”¸`Çí
+œÍí
+”¸`Çí
+œÍí
+”¸`Çí
+¬! F
+FhD0`˜Fh@ð@
+• š¿#šBÙÐàëA
+‘A¿Fˆ
+­ !(F
+(F!
+¨QF
+Íø(  ˜ˆBÙ ë ài
+ëH
+ë
+ë@
+ž¿
+«D«ë
+Fh)D1`™
+FhAê€`Ýí ™˜¸`Çí
+ë@
+Íø(  ˜ˆBÙ ë ài
+ëD
+ë
+H™xD
+Fê%Fh±BèÒrB`Áñ
+FIöŒbxDIöœeIöcIö”g
+Gù
+õ¶g,bõÅeÃø|uÃøŒuõ»gÃø„uõÀgÃøˆuÃøUÃø”uõÊgÃø€uÃø˜uõÏgÃø uõÔgÃøœuÇÑ F(Fü÷Úé(jHòÇöþq
+Ð03 BøÓ6õ¤u.åÓ
+Ñ7/øÓ6.òÓ4à#ø¬0!çœ
+Íø4€à
+àÍøPà¾ñ
+
+9FPFû÷Ìï™PFû÷æïá
+•h˜Äø¬AòøXø
+h+ ÑuFöœö˜à(hÝø4€8(`ÀæÔøL)@ð>uFö˜ö”Ñø
+ŸDòlûEögÏY®F/Û+Ѳø” ð
+ŸDòlEöbû€ƒPEöbƒP”àÔøL=F)$Ѳø)òLQ’ ô€pÔøœ%Oô€s’ š`
+™Dòl
+˜DòlEöb
+Eö´P:EöÜP9F’û÷Øí˜û÷
+˜®FEö bOð
+ñ
+ºñô*­™Iö¸`X(ЙIö¨`X(ÑØø
+H,™xD
+©FFFT¹I
+ p°½
+à@B
+I
+K¾"yD
+F
+I
+Ké"yD
+I
+K@òiyD
+Û’
+ÑI
+ÑI
+ËøDËø<Ëøð Ëø
+8Fú÷0î8F !ú÷ðí0Ëø
+!ú÷´í0Oöÿq«ø
+&
+8ø
+ëÊÍøIBOð
+šëAëÁëˆÁøX›ø
+
+'F ë
+
+àÛøX ñ ë
+‘ø„)Ø_úˆñªë(Ñ4Dø€P³¡ë
+ñ
+‚EºÓ
+ø„(mؘ=F’‘À²oðk “
+ñ
+\EðÑÝø(° ñ žñ ˜€E¶Ó˜6$0˜†B¤Ó/F%3àOð
+8F!ú÷,é
+Ð0F!ú÷"é‹ø\
+àj
+Ëø 
+…BõÓ ©0Fú÷éÛø
+àÛøð ñ ë
+‘ø„) Ø鲪ë("Ñ4D:Fø€¨³¡ë
+ñ
+–øo
+ñ¨
+PFça§f'cú÷pèÚø
+!ù÷ZîOöøqÀòêÀ
+3
+`pG
+î°€½
+à J I KzDyD
+JOð zDÒø
+ˆßø(À üDƒê<ø0ƒê€ê0
+Úªë
+ŠBÈ¿FIJIBzD‹¶²9 úó)ðƒêÖ32ø0ƒêFðÜ/`Û(h@I0yD(`ôpCPø,6¶²?
+ðð ¯)$Ü€)6Ð)OР)@ð
+ð"1Oô€@
+ð
+6±²ø
+ðAð
+ð
+ð
+
+
+­xD
+¨!F
+(FoðBF
+HÝø”xD
+± GpG€µF
+Ñ h)F2Fi F˜Gµñÿ?Ð
+àNòreÏöÿuà h
+Ð-Ð - Ðàñеñÿ?ÑñD
+ïë…
+pà•øJ
+àÿ÷ÔíOöTëÆ
+ Foð¨G °½µ
+éªA
+±õ¨p
+ ¨‘©bh^hÍé
+B¿&¼ñ
+™xD
+ ßødxDpG¡õ€p($Øßèð
+–HxDpGÄHxDpGÀHxDpG½HxDpG»HxDpG¸HxDpG¶HxDpG³HxDpG±HxDpG®HxDpG¬HxDpG©HxDpG§HxDpG¤HxDpG¢HxDpG®HxDpGžHxDpG›HxDpG™HxDpG–HxDpG”HxDpG‘HxDpGHxDpGŒHxDpGŠHxDpG‡HxDpG…HxDpG‚HxDpG€HxDpG}HxDpG{HxDpGxHxDpGvHxDpGsHxDpGqHxDpGnHxDpGlHxDpGiHxDpGgHxDpGdHxDpGbHxDpG_HxDpG]HxDpGZHxDpGXHxDpGUHxDpGSHxDpGPHxDpGMHxDpGJHxDpGHHxDpGEHxDpGCHxDpG@HxDpG>HxDpG;HxDpG9HxDpG6HxDpG4HxDpG1HxDpG/HxDpG,HxDpG*HxDpG'HxDpG%HxDpG"HxDpG HxDpGHxDpGHxDpGHxDpGHxDpGHxDpGHxDpGHxDpG HxDpG HxDpGHxDpGHxDpGHxDpGÚ
+?oá/oá Cà0 ã á2 á
+@-éÑÿÿë@½è’
+€ õÿ°°¬€Üõÿ°°°€úÿ
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+A 
+ "&Dlibstagefright_soft_dtshd.so
diff --git a/amadec/acodec_lib_android_n/libstagefright_soft_truehddec.so b/amadec/acodec_lib_android_n/libstagefright_soft_truehddec.so
new file mode 100644
index 0000000..871f18f
--- a/dev/null
+++ b/amadec/acodec_lib_android_n/libstagefright_soft_truehddec.so
@@ -0,0 +1,87 @@
+ELF
+é
+
+
+
+
+
+
+
+
+
+
+jQ+¯N{F÷û{p °£IÀá)±G5ž9³~ kd곧3HE;a":(¬Ÿ¬/·ºþ¯×›¨yVy‚g¥Xy°zäg—¿Òá15ù×e–/ÿ¶b6g‘íûþų~‰LcÏm¯V5?ó8©âx‘,ÂT“ˆûû{‡8(—ìðPK& ̪ÙqXÙŸÞ=³~»ã’|¾º®–úüšIÅ)ˆóû{ö¥O¦D“”±>~òh†˜r»M8CEÕì+Õø-ê³T`3éw¾G—®QPAʳ~x,¦Q~´¶Ëu–·
+
+0å3ÿ/áÐKâ
+°p½ÿ÷ðì I¬yD Fÿ÷ðì© Fÿ÷òì Fÿ÷ôìIFJ
+)¢ñ
+`ø `Gù
+Dù*Íébh)FÍé  Æöp –@Fÿ÷tì !`ùï
+ `ùï*HGù
+xDDù*–‘Íé @FÍé a)Fÿ÷\ìH™xD
+ñ
+!Âé 1Âø,ÀøYq±mÑ`@mbà€µ I JyDzDÿ÷0ë
+ushÍéuÍé!ßø¼ßøÈ#yD
+ñ
+”@ö›q7h¸ˆBÓAò
+™q ˜@h€h
+°p½þ÷ÔïHIJxDKyDzD{Dþ÷âïI¬yD Fþ÷Êï© Fþ÷Ìï Fþ÷ÎïIFJ
+¦ñ
+#þ÷œîÕøÌ
+#þ÷Zî(F!F:F#þ÷Tî7>ÔÑ°½èð(N
+‚B¤¿Ôø¬‚BLÛ¤ø¼ŸÔø¸/²ñÿ?ÑÔø¤/û òÄø¸/”øÐ?»»´øÂo¡ë úŒóƒB¿½BÑ´øÀ?7 ÿ
+ÐF3ù
+FøшFö»sÏörBêAAðšBÑ!JƒŠzDOê>Âø
+¨ø
+¨ø
+ðð ¯)$Ü€)6Ð)OР)@ð
+ð"1Oô€@
+ð
+6±²ø
+ðAð
+ð
+ð
+
+
+­xD
+¨!F
+(FoðBF
+HÝø”xD
+± GpG€µF
+Ñ h)F2Fi F˜Gµñÿ?Ð
+àNòreÏöÿuà h
+Ð-Ð - Ðàñеñÿ?ÑñD
+ïë…
+pà•øJ
+àÿ÷ÔíOöTëÆ
+ Foð¨G °½µ
+±õ¨p
+ ¨‘©bh^hÍé
+B¿&¼ñ
+™xD
+ ßødxDpG¡õ€p($Øßèð
+–HxDpGÄHxDpGÀHxDpG½HxDpG»HxDpG¸HxDpG¶HxDpG³HxDpG±HxDpG®HxDpG¬HxDpG©HxDpG§HxDpG¤HxDpG¢HxDpG®HxDpGžHxDpG›HxDpG™HxDpG–HxDpG”HxDpG‘HxDpGHxDpGŒHxDpGŠHxDpG‡HxDpG…HxDpG‚HxDpG€HxDpG}HxDpG{HxDpGxHxDpGvHxDpGsHxDpGqHxDpGnHxDpGlHxDpGiHxDpGgHxDpGdHxDpGbHxDpG_HxDpG]HxDpGZHxDpGXHxDpGUHxDpGSHxDpGPHxDpGMHxDpGJHxDpGHHxDpGEHxDpGCHxDpG@HxDpG>HxDpG;HxDpG9HxDpG6HxDpG4HxDpG1HxDpG/HxDpG,HxDpG*HxDpG'HxDpG%HxDpG"HxDpG HxDpGHxDpGHxDpGHxDpGHxDpGHxDpGHxDpGHxDpG HxDpG HxDpGHxDpGHxDpGHxDpGB
+
+?oá/oá Cà0 ã á2 á
+@-éÑÿÿë@½è’
+€8÷ÿ°°¬€t÷ÿ°°°€´ûÿ
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+A 
+ "&Dlibstagefright_soft_truehddec.so
+
+
diff --git a/amadec/acodec_lib_mx/libstagefright_soft_ddpdec.so b/amadec/acodec_lib_mx/libstagefright_soft_ddpdec.so
new file mode 100755
index 0000000..556f9ef
--- a/dev/null
+++ b/amadec/acodec_lib_mx/libstagefright_soft_ddpdec.so
@@ -0,0 +1,113 @@
+ELF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6
+¹IyD"ÿ÷íAòÈò
+ì™ø‰0ÙøŒ@¹d±ßø\ ßø\%
+•zD – ‘ ”’ØøP Øø0
+™
+hÔø
+ZŠšŠJÚŠB‹ŠZ‹‚š‹ÊÚ‹ÂŒ
+‚ZŒ‚šŒJ‚ÚŒB‚Š‚Z‚‚šÊ‚Ú‚Ž
+ƒZŽƒšŽJƒÚŽBƒŠƒZ‚ƒšÊƒ@1Ú@3ƒ@0š:–E³ÛÙøP
+2
+5
+Kñt F
+ €5Kø ³Dÿ÷–é¸ñpDp„pÄprDr„rÄrËø
+ñt ‘
+ÿ÷ðèñ`ñ`
+ë Jø@Jø ÿ÷Ø蛚üë rEr…rÅrpEp…pÅpËø
+8F1FÃëÿ÷èIFñ`
+ë ë rEr…rÅrpEp…pÅpËø
+øgHøÚø0˜hƒBгF†hþ÷ŒïchžB0FøÑ^F[`Úø
+ïHFþ÷ ï›Xô¯ °½èðÖI
+þ÷p˜Áë › ëš ë
+ë rEr…rÅrpEp…pÅpÈø„
+ë™øgØø„0Èø€˜hƒBгF†hþ÷ÚîchžB0FøÑ^F[`Øø„
+"þ÷ØíF8Fþ÷í¡l Íaþ÷ÔíFàd
+“ ’ ” ”þ÷
+í#““(F“iF K%"••{DOô5”• ””’
+“ ” ” ’þ÷ðì°0½î*
+*
+Ÿþ÷ìóiDD+±6z–±+Ñ.DÐ)hA¹ ñ"NøÞø
+QÐÄóA!FrBðVE(¿VFºñ˜¿VF
+‘OêÑ OêË
+ÐëBˆ2
+’EFê
+ø
+Ð*¿JöDAybÐ*¿OôúAyb8z
+@ÃóÄó  *"Ð+,Ð3
+hhŠB@ð“€° õ€]½èðßø0±ßø0¡LJûDLHúDzD’xD+ÖÐ F¦iþ÷Úè#iâh F“B)¿ÃëÃë¡i]þ÷Òèuµõ€_BÝ i¥õ€Uµõ€_¨¿Oô€U
+#
+èÚøpÚø PF—B)¿ÇëÇëÚø0þþ÷
+h€Ã³õ€_Ì¿£õ€P
+îHF°½èð,h"#HFÍø
+ÛíëíûÍí< Íí>¶ÿDaQí€ Qí~ÍíDKÍíF[}”Qí|KQíz[
+QítKQír[Qíx Qív
+öÿdÍí,KÍí.[QídKQíb[Íí Íí~“Qíh Qíf
+[í íÍíHëÍíJûöÿL!ÝíëÝíûÍí`«Ííb»ÍíLkÍíN{Ýí«Ýí»Ýí kÝí{¶ÿ@Aí ííKí
+[í( í*íKí[FöÿjáÍí«Íí»ÍíëÍíûÝí «Ýí"»Ýí0ëÝí2ûí kí"{öÿDaíKí[Íí kÍí{
+ûöÿfáÍí@kÍíB{Ýí\kÝí^{ÍíëÍí
+ûÝí ëÝíû¶ÿfÍí\kÍí^{dïTaíKí[öÿH¡¶ÿJaöÿLaöÿjáÍíH«ÍíJ»Íí ëÍíûÝí«Ýí»¶ÿl!ÍíLËÍíNÛí+í;öÿNAíhëíjûöÿbÍíP+ÍíR;Ýí+Ýí;öÿFíXkíZ{öÿD!íKí[öÿH¡í‹í›í kí"{Ýí<ëÝí>ûÝíDËÝíFÛíT+íV;¶ÿnaí(ëí*ûí0Kí2[í`‹íb›ÍíëÍíûÝí$ëÝí&û¶ÿHAí(‹í*›í4‹í6›ídKíf[í Kí[öÿBÁí +í";í,+í.;öÿNáí$ëí&ûí8ëí:û¶ÿJ!¶ÿNí,ëí.ûíëí
+û¶ÿfÍí<kÍí>{¶ÿDáí0Kí2[íëí
+ûídKíf[íëíûöÿhÍí8‹Íí:›Íí Íí¶ÿdáÍí4KÍí6[íëíûÝí@KÝíB[íHëíJûöÿj!ÍíD«ÍíF»¶ÿlaÍíTËÍíVÛöÿBáí`+íb;¶ÿHAíd‹íf›öÿNAí@ëíBûÝíLËÝíNÛÝíh ÝíjÝíX‹ÝíZ›Ýí\kÝí^{öÿ`ÁÝí«Ýí»í +í";Ííx Íízí(‹í*›ÝíP ÝíRöÿLaí,ëí.ûíËíÛíËí
+ÛöÿhÍíH‹ÍíJ›Ýí‹Ý훶ÿNí ëí"ûí ëíûöÿjÍí«Íí»Ýí«Ýí»öÿB¡í+í;í$+í&;¶ÿJ!í«í»í«í»¶ÿ@áíL íN¶ÿJÁ.ï^í$«í&»íËí
+Ûí4Ëí6ÛöÿF!íPkíR{Íí +Íí;öÿDáíXKíZ[öÿlAÍí\ËÍí^ÛöÿfÍíhkÍíj{Ýí0kÝí2{öÿjÍíl«Íín»¶ÿH!íp‹ír›öÿLaítËívÛÝí8ËÝí:Ûí<«í>»ÝíD+ÝíF;íTëíVûöÿJÁíxKíz[Ýí`«Ýíb»ídkíf{íËíÛí‹í›öÿN!í<«í>»íDëíFûí«í»í ëí"ûöÿF¡íTkíV{í@kíB{¶ÿDaìKíHKíJ[¶ÿLAöÿàAÍí0 Íí2Íí4KÍí6[öÿÂí(+í*;Íí,‹Íí.›öÿìaÍíHËÍíJÛÍí8kÍí:{öÿê!¶ÿÄa¶ÿJí«í»í«í»¶ÿN¡íëíûíx«íz»í ëíûí«í
+»¶ÿîáÍí@ëÍíBûí ëíû¶ÿÀ¡í íí«í
+»Íí`«Ííb»í$ í&Íí +Íí";íkí{ÝíL ÝíNÝíP+ÝíR;¶ÿàÝíXëÝíZûÝí\KÝí^[íhkíj{Ýíl‹Ýín›öÿî!ÝípËÝírÛÝí<«Ýí>»ídKíf[ítKív[í$ í&öÿÆAíD íFíT+íV;íx«íz»ÝíkÝí{ìëöÿì¶ÿêA¶ÿ¶ÿÊíx«íz»í‹í›í$«í&»í‹í›¶ÿÌá¶ÿæÍí<kÍí>{ÝíkÝí
+{öÿÊaí«í»ÍíkÍí
+{í «í»ÝíkÝí{¶ÿâ¡ÍíD+ÍíF;í «í»öÿàaÍí ÍíÍíkÍí{Ýí@kÝíB{öÿîaÍí$ëÍí&ûÝí4 Ýí6í,«í.»Ýí0+Ýí2;Íí@kÍíB{öÿäÍí4 Íí6Ýí8kÝí:{Ýí(ëÝí*ûdïTÍíLKÍíN[¶ÿè¡ÍíT‹ÍíV›Ýí<KÝí>[í,«í.»jïúÝí`«Ýíb»öÿÆ!Íí0+Íí2;Ýí +Ýí";íPkíR{ídkíf{í«í»öÿàaÍí8kÍí:{ÝíHkÝíJ{íxKíz[öÿèaöÿÀ!¶ÿÌaöÿìáÍíXËÍíZÛÝíËÝíÛÍí(ëÍí*ûÝí8ëÝí:ûöÿ¡öÿÎÁ¶ÿäAÍí<KÍí>[ÝíKÝí
+[¶ÿÈ¡öÿîAÍí8ëÍí:ûÍíKÍí
+[ÝíëÝíûÝíKÝí[öÿæáÍíkÍí{öÿàAÍíH ÍíJÍíKÍí[ÍíëÍíûÝí ÝíÝíKÝí[öÿâÍí\+Íí^;Ýí@kÝíB{ÝíDëÝíFûfïV!íPkíR{öÿèAÍí ‹Íí"›ÍíKÍí[Ýí4‹Ýí6›Ýí$KÝí&[Íí ÍíöÿêaÍí@kÍíB{Ýí0kÝí2{Íí`«Ííb»Ýí,«Ýí.»Ýí< Ýí>öÿÂAÍí$KÍí&[ÝíLKÝíN[íd+íf;íX+íZ;öÿìÍí4‹Íí6›ÝíT‹ÝíV›öÿÎAöÿâaöÿÊ¡¶ÿÌaöÿÀáÍíhëÍíjûÝí(ëÝí*ûíD íFí4 í6öÿÄá¶ÿà!Íí( Íí*Ýí Ýí
+öÿÀí, í.Íí Íí
+í íÝí8 Ýí:¶ÿäöÿìÍí0ËÍí2ÛÍí8 Íí:Íí4KÍí6[Ýí ÝíÝíHËÝíJÛöÿæÍí Ííí íí íjïúÝí@«ÝíB»öÿÎÁÍíXËÍíZÛÝí ËÝí"Ûí<ëí>ûí ëíûÝíKÝí[öÿÌÁÍí ËÍí"ÛÍíHkÍíJ{íTËíVÛnïþÁÝíDkÝíF{öÿÈídËífÛ¶ÿâÍíL+ÍíN;Ýí\+Ýí^;í ííh íj¶ÿàáílëínûíëí
+ûöÿÊ!öÿ졶ÿèjïúáÝí`«Ýíb»öÿÆAíPkíR{ÍíKÍí[í$kí&{Ýí(KÝí*[öÿÈaíD‹íF›íl‹ín›¶ÿäÁÍí KÍí[¶ÿÈáí‹í
+›í\ëí^ûí,ëí.û¶ÿàáÍí$ Íí&Ýí8KÝí:[í‹í›öÿâAnï^Íí(+Íí*;í0ëí2ûdïô!¶ÿÊáÝí4KÝí6[í,«í.»¶ÿÀ.ï^¡í ííXëíZûöÿèA(ïXÍí0‹Íí2›íD‹íF›dïôÝí<KÝí>[öÿÈAÍíXKÍíZ[ÝíKÝí[í4‹í6›öÿîAÍíëÍíûöÿÄ¡dïôáÝíHKÝíJ[¶ÿÂa$ïTöÿìAÍí8ËÍí:ÛdïôÁÝíKÝí[öÿêAÍí@«ÍíB»Ýí«Ýí»ÍíKÍí[ÝíLKÝíN[öÿÆ¡íkí{öÿÈA*ïúaÝíP«ÝíR»öÿ¡$ïôAíD+íF;Ýí\KÝí^[*ïú!CùMJÝí «Ýí"»ÝíKÝí
+[öÿÌ¡íHËíJÛÍí «Íí"»íTËíVÛÝí «Ýí»CùOJ}œ¶ÿæá~›KùO
+Ýí$ Ýí&JùO
+IùO*Ýí(+Ýí*;HùO* ùOªí,«í.»ùOªí0«í2»ùO
+í íùO
+NùOŠÝí4‹Ýí6›ùOªœùOꀛDùOjÝíXkÝíZ{œCùOj‚›DùOŠƒœCùOêÝíëÝíû„›DùOê…œCùOÊÝí8ËÝí:ÛDùOÊÝíKÝí[†›Ýí@ ÝíB‡œ¶ÿêÁÝíH+ÝíJ;CùOJˆ›DùO
+‰œùOJíKí[Š›ùOŠ‹œùOjíDkíF{Œ›ùOJœùO*í +í";Ž›ùOjœùO*›DùO*‘œùOÊ’›DùOª“B>öŒ¯—š–œ“˜’ßø Á£•œüD—˜–“ ë„BmÐUBF–š_ÝøPâNU7ø
+ÀÜŠT³øÀ¡ø À\‹”³øÀ¡øÀÜ‹Ô³ø À¡øÀ\Œ‚³ø$À¡øÀÜŒT‚³ø(À¡øÀ\”‚³ø,À¡øÀÜÔ‚³ø0À¡øÀ\Žƒ³ø4À¡øÀÜŽTƒ³ø8À¡øÀ\”ƒ³ø<À¡øÀ@1Ü@3Ôƒ@2†E™Ü”œ$ð?
+€HÙÿ©±€ÈÙÿ°°ª€PÛÿ°°¨€\Ûÿ°¬€dÝÿ°©€øÝÿ°¬€@ßÿ°­€Xàÿ°°°€xàÿ°¯€¼âÿ°®€4äÿ`
+
+
+
+
+
+
+[%s]BuildDate--%s BuildTime--%s
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+A 
+ ",Dlibstagefright_soft_ddpdec.so
diff --git a/amadec/acodec_lib_mx/libstagefright_soft_dtshd.so b/amadec/acodec_lib_mx/libstagefright_soft_dtshd.so
new file mode 100755
index 0000000..67e1409
--- a/dev/null
+++ b/amadec/acodec_lib_mx/libstagefright_soft_dtshd.so
@@ -0,0 +1,121 @@
+ELF
+
+
+
+
+
+
+
+L¡B Ñ
+Iñ
+I
+JyDzDÿ÷äìOð
+¨ “ÿ÷šÿ F1FˆøPÿ÷Šì
+¨ ©ºh
+¨ ’ÿ÷dÿ™ Fq1Fÿ÷fìÛàii1¹Õé«aeÄé«Æé«ÖøÀOð
+Öø°+i¡n ë ji¨h“ «
+ñ@
+’E
+Ú™ë
+˜ë
+ “
+
+RCëás™Äé#ji+iÅø€Ðhaø€
+¨zh“hJø=QFÿ÷²þ F)Fÿ÷¤ë ˜™Æø€0aÆø@€Ôé#Æé#ø€QFÙø0˜h
+¨ÿ÷™þ F1Fÿ÷žë{hšhšBÐÙøˆhˆB
+Ðhh•-h–6h+lÛõ%¯òæ °½èð
+þ Fÿ÷«ÿ F½
+’øPø@ø@ø@””––•” ””• ” ” “ÿ÷¶ê J!Oô
+’ ” ”ÿ÷ ê°ð½
+'
+ê¨ÿ÷ ê
+I JyDzDF(Fÿ÷zé¨ÿ÷ê Fÿ÷øþ F
+°p½
+N F~D àñ`
+L J|DzD!Fÿ÷Nè J!F zDÿ÷HèJ !FzD½è@ðÛ¸
+Fê$"ø@3«BõÛFp½
+høD™F
+ïßK{DhÀ
+h“BÀðIÆHxDh!±ësE€ð@ÃK{Dh"¹ÂHxDhŠDÕÀM }D+h›Õ¾I¿JyDzDà¾I¾JyDzDþ÷ î"h™%Ðl `#hH`šh:±¸I ¸JyDÛhzDþ÷Žîßøز
+
+•Zø-Gø+*F8Fþ÷šî›z˜h
+h"¹YK{DhÕ#h VIWJyD›lzDà°¹“è
+h’Õ#h OIOJ[hyDzDþ÷ŽíMK{DhB`LIyD h#¹KHxDh“ÕII IJyDzDþ÷zíHIyD hX`àFI FJ¨FyDzDþ÷lí ª Bø]h;`{` ™Éø
+"¨þ÷öí(`8Fþ÷Ôí
+I
+J3FyDzDþ÷nìOðÿ0š#hšBÐþ÷Ôí°ð½,<
+h˜F`F
+ ¼õ€_Ý!i¬õ€P¨B¨¿(F)¹ à'J 9FzD àãh#±Ôøà¾ñ
+LUÔ
+3Jk
+ñ
+ri0hDê#Q3aqa¹ŒÐôã(@ðòƒ¡L£BРM«BРJ“BПI‹BÑ0F³aÿ÷’þ0Fÿ÷xþ?â›HƒBКL£B@ð׃³a0Fÿ÷ƒþGð#qà0iõ
+ñ
+Dê
+ñ
+Dê!1aTtaÅø´
+K™BÑ Mà L¡B Ñ MªBÑ$%
+#*â
+ÛzBê dDê…Aê#ÀóTÔÀóG2À
+-Ãø¨@Ãø°PÃø¬@ò‚€
+)Ù‰
+ñ
+;Eê!B1araÄø´0à°iB
+¹# à*Ñ#à*Ñãd0FÄø 0ÿ÷²ú#s`¸ñ
+
+Bê#›²BhŠBÙRúôB`ÁñOöÿpCúó@úñêBê
+ÿ!
+!ƒF Fÿ÷Jÿ! Fÿ÷ïþ!F Fÿ÷êþ!‚F Fÿ÷<ÿ! Fÿ÷áþ /˜¿2ªÝøÀš¿ë‡Sø,
+–—/F6à ! Fÿ÷£þ 7°ñZ?.Ñ”è
+­Ýø°…è
+! Fÿ÷”þÀë Æë
+­à ! Fÿ÷\þ 7XE@ð‰€”è
+à F!“ÿ÷'þ›ª0Bø#
+–
+–•è
+–ßø °—
+­Ýø€…è
+
+Ú2I 2JCFyDOðÿ5zDý÷(éDà"$Ißø´€ý÷¾ê"I"FÙø
+Ø>"ÐÙø
+Û/"hÑ°ëRÒ à°ë’ùç(FàOðÿ0½èüs€Ò#
+
+€ìòÿ°°ª€Äóÿ°°¨€ôÿ°°«€Âôÿ«±€õÿ°¯2€èøÿ¨±€tùÿ©±€`úÿ°¯€Œûÿ«±€Üûÿ­±€äüÿ„
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+A 
+ ",Dlibstagefright_soft_dtshd.so
+
diff --git a/amadec/adec-armdec-mgt.h b/amadec/adec-armdec-mgt.h
new file mode 100644
index 0000000..c7f78a9
--- a/dev/null
+++ b/amadec/adec-armdec-mgt.h
@@ -0,0 +1,57 @@
+#ifndef ADEC_ARMDEC_MGT_H
+#define ADEC_ARMDEC_MGT_H
+
+
+#include <stdlib.h>
+#include<stdio.h>
+#include <string.h>
+
+//#define AUDIO_ARC_DECODER 0
+//#define AUDIO_ARM_DECODER 1
+//#define AUDIO_FFMPEG_DECODER 2
+
+#define DEFAULT_PCM_BUFFER_SIZE 192000*2//default out buffer size
+
+#define AUDIO_EXTRA_DATA_SIZE (4096)
+typedef struct _audio_info {
+ int bitrate;
+ int samplerate;
+ int channels;
+ int file_profile;
+} AudioInfo;
+
+/* audio decoder operation*/
+typedef struct audio_decoder_operations audio_decoder_operations_t;
+struct audio_decoder_operations {
+ const char * name;
+ int nAudioDecoderType;
+ int nInBufSize;
+ int nOutBufSize;
+ int (*init)(audio_decoder_operations_t *);
+ int (*decode)(audio_decoder_operations_t *, char *outbuf, int *outlen, char *inbuf, int inlen);
+ int (*release)(audio_decoder_operations_t *);
+ int (*getinfo)(audio_decoder_operations_t *, AudioInfo *pAudioInfo);
+ void * priv_data;//point to audec
+ void * priv_dec_data;//decoder private data
+ void *pdecoder; // decoder instance
+ int channels;
+ unsigned long pts;
+ int samplerate;
+ int bps;
+ int extradata_size; ///< extra data size
+ char extradata[AUDIO_EXTRA_DATA_SIZE];
+ int NchOriginal;
+ int lfepresent;
+};
+
+enum AVSampleFormat {
+ AV_SAMPLE_FMT_NONE = -1,
+ AV_SAMPLE_FMT_U8, ///< unsigned 8 bits
+ AV_SAMPLE_FMT_S16, ///< signed 16 bits
+ AV_SAMPLE_FMT_S32, ///< signed 32 bits
+ AV_SAMPLE_FMT_FLT, ///< float
+ AV_SAMPLE_FMT_DBL, ///< double
+ AV_SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if linking dynamically
+};
+#define AVCODEC_MAX_AUDIO_FRAME_SIZE 500*1024
+#endif
diff --git a/amadec/adec-external-ctrl.c b/amadec/adec-external-ctrl.c
new file mode 100644
index 0000000..021e6f8
--- a/dev/null
+++ b/amadec/adec-external-ctrl.c
@@ -0,0 +1,899 @@
+/**
+ * \file adec-external-ctrl.c
+ * \brief Audio Dec Lib Functions
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include <math.h>
+#include <unistd.h>
+
+#include <audio-dec.h>
+#include <amthreadpool.h>
+
+
+
+int audio_decode_basic_init(void)
+{
+#ifndef ALSA_OUT
+ android_basic_init();
+#endif
+ amthreadpool_system_init();
+
+ return 0;
+}
+
+/**
+ * \brief init audio dec
+ * \param handle pointer to player private data
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_decode_init(void **handle, arm_audio_info *a_ainfo)
+{
+ int ret;
+ aml_audio_dec_t *audec;
+
+ if (*handle) {
+ adec_print("Existing an audio dec instance!Need not to create it !");
+ return -1;
+ }
+
+ audec = (aml_audio_dec_t *)malloc(sizeof(aml_audio_dec_t));
+ if (audec == NULL) {
+ adec_print("malloc failed! not enough memory !");
+ return -1;
+ }
+ //set param for arm audio decoder
+ memset(audec, 0, sizeof(aml_audio_dec_t));
+ audec->channels = a_ainfo->channels;
+ audec->samplerate = a_ainfo->sample_rate;
+ audec->format = a_ainfo->format;
+ audec->adsp_ops.dsp_file_fd = a_ainfo->handle;
+ audec->adsp_ops.amstream_fd = a_ainfo->handle;
+ audec->extradata_size = a_ainfo->extradata_size;
+ audec->SessionID = a_ainfo->SessionID;
+ audec->dspdec_not_supported = a_ainfo->dspdec_not_supported;
+ audec->droppcm_flag = 0;
+ audec->bitrate = a_ainfo->bitrate;
+ audec->block_align = a_ainfo->block_align;
+ audec->codec_id = a_ainfo->codec_id;
+ audec->auto_mute = a_ainfo->automute;
+ audec->has_video=a_ainfo->has_video;
+ if (a_ainfo->droppcm_flag) {
+ audec->droppcm_flag = a_ainfo->droppcm_flag;
+ a_ainfo->droppcm_flag = 0;
+ }
+ if (a_ainfo->extradata_size > 0 && a_ainfo->extradata_size <= AUDIO_EXTRA_DATA_SIZE) {
+ memcpy((char*)audec->extradata, (char*)a_ainfo->extradata, a_ainfo->extradata_size);
+ }
+ audec->adsp_ops.audec = audec;
+ // adec_print("audio_decode_init pcodec = %d, pcodec->ctxCodec = %d!\n", pcodec, pcodec->ctxCodec);
+ ret = audiodec_init(audec);
+ if (ret) {
+ adec_print("adec init failed!");
+ return -1;
+ }
+
+ *handle = (void *)audec;
+
+ return 0;
+}
+
+/**
+ * \brief start audio dec
+ * \param handle pointer to player private data
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_decode_start(void *handle)
+{
+ int ret;
+ adec_cmd_t *cmd;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ cmd = adec_message_alloc();
+ if (cmd) {
+ cmd->ctrl_cmd = CMD_START;
+ ret = adec_send_message(audec, cmd);
+ } else {
+ adec_print("message alloc failed, no memory!");
+ ret = -1;
+ }
+
+ return ret;
+}
+
+/**
+ * \brief pause audio dec
+ * \param handle pointer to player private data
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_decode_pause(void *handle)
+{
+ int ret;
+ adec_cmd_t *cmd;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ cmd = adec_message_alloc();
+ if (cmd) {
+ cmd->ctrl_cmd = CMD_PAUSE;
+ ret = adec_send_message(audec, cmd);
+ } else {
+ adec_print("message alloc failed, no memory!");
+ ret = -1;
+ }
+
+ return ret;
+}
+
+/**
+ * \brief resume audio dec
+ * \param handle pointer to player private data
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_decode_resume(void *handle)
+{
+ int ret;
+ adec_cmd_t *cmd;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ cmd = adec_message_alloc();
+ if (cmd) {
+ cmd->ctrl_cmd = CMD_RESUME;
+ ret = adec_send_message(audec, cmd);
+ } else {
+ adec_print("message alloc failed, no memory!");
+ ret = -1;
+ }
+
+ return ret;
+}
+
+/**
+ * \brief stop audio dec
+ * \param handle pointer to player private data
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_decode_stop(void *handle)
+{
+ int ret;
+ adec_cmd_t *cmd;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ audec->need_stop = 1;
+
+ cmd = adec_message_alloc();
+ if (cmd) {
+ cmd->ctrl_cmd = CMD_STOP;
+ ret = adec_send_message(audec, cmd);
+ amthreadpool_pool_thread_cancel(audec->thread_pid);
+ } else {
+ adec_print("message alloc failed, no memory!");
+ ret = -1;
+ }
+
+ return ret;
+}
+
+/**
+ * \brief release audio dec
+ * \param handle pointer to player private data
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_decode_release(void **handle)
+{
+ int ret;
+ adec_cmd_t *cmd;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *) * handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ cmd = adec_message_alloc();
+ if (cmd) {
+ cmd->ctrl_cmd = CMD_RELEASE;
+ ret = adec_send_message(audec, cmd);
+ } else {
+ adec_print("message alloc failed, no memory!");
+ ret = -1;
+ }
+
+ ret = amthreadpool_pthread_join(audec->thread_pid, NULL);
+
+ free(*handle);
+ *handle = NULL;
+
+ return ret;
+
+}
+
+/**
+ * \brief set auto-mute state in audio decode
+ * \param handle pointer to player private data
+ * \param stat 1 = enable automute, 0 = disable automute
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_decode_automute(void *handle, int stat)
+{
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+ adec_print("[%s:%d]set automute %d!\n", __FUNCTION__, __LINE__, stat);
+ //audec->auto_mute = 1;
+ audec->auto_mute = stat;
+ return 0;
+}
+
+/**
+ * \brief mute audio output
+ * \param handle pointer to player private data
+ * \param en 1 = mute output, 0 = unmute output
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_decode_set_mute(void *handle, int en)
+{
+ int ret;
+ adec_cmd_t *cmd;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ cmd = adec_message_alloc();
+ if (cmd) {
+ cmd->ctrl_cmd = CMD_MUTE;
+ cmd->value.en = en;
+ cmd->has_arg = 1;
+ ret = adec_send_message(audec, cmd);
+ } else {
+ adec_print("message alloc failed, no memory!");
+ ret = -1;
+ }
+
+ return ret;
+}
+
+/**
+ * \brief set audio volume
+ * \param handle pointer to player private data
+ * \param vol volume value
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_decode_set_volume(void *handle, float vol)
+{
+ int ret;
+ adec_cmd_t *cmd;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ cmd = adec_message_alloc();
+ if (cmd) {
+ cmd->ctrl_cmd = CMD_SET_VOL;
+ cmd->value.volume = vol;
+ audec->volume = vol;
+ cmd->has_arg = 1;
+ ret = adec_send_message(audec, cmd);
+ } else {
+ adec_print("message alloc failed, no memory!");
+ ret = -1;
+ }
+
+ return ret;
+}
+
+/**
+ * \brief set audio pre-gain
+ * \param handle pointer to player private data
+ * \param gain pre-gain value
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_decode_set_pre_gain(void *handle, float gain)
+{
+ int ret = 0;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ ret = -1;
+ } else {
+ audec->pre_gain_enable = 1;
+ //audec->pre_gain = powf(10.0f, gain/20);
+ adec_print("[%s] set pre-gain[%f] \n", __FUNCTION__, audec->pre_gain);
+ }
+ return ret;
+}
+
+/**
+ * \brief set audio decode pre-mute
+ * \param handle pointer to player private data
+ * \param mute pre-mute value
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_decode_set_pre_mute(void *handle, uint mute)
+{
+ int ret = 0;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ ret = -1;
+ } else {
+ audec->pre_mute = mute;
+ adec_print("[%s] set pre-mute[%d] \n", __FUNCTION__, audec->pre_mute);
+ }
+ return ret;
+}
+
+/**
+ * \brief set audio volume
+ * \param handle pointer to player private data
+ * \param vol volume value
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_decode_set_lrvolume(void *handle, float lvol, float rvol)
+{
+ int ret;
+ adec_cmd_t *cmd;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ cmd = adec_message_alloc();
+ if (cmd) {
+ cmd->ctrl_cmd = CMD_SET_LRVOL;
+ cmd->value.volume = lvol;
+ audec->volume = lvol;
+ cmd->has_arg = 1;
+ cmd->value_ext.volume = rvol;
+ audec->volume_ext = rvol;
+ ret = adec_send_message(audec, cmd);
+ } else {
+ adec_print("message alloc failed, no memory!");
+ ret = -1;
+ }
+
+ return ret;
+}
+
+/**
+ * \brief set audio volume
+ * \param handle pointer to player private data
+ * \param vol volume value
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_decode_get_volume(void *handle, float *vol)
+{
+ int ret = 0;
+ adec_cmd_t *cmd;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ *vol = audec->volume;
+
+ return ret;
+}
+
+/**
+ * \brief get audio pre-gain
+ * \param handle pointer to player private data
+ * \param gain pre-gain value
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_decode_get_pre_gain(void *handle, float *gain)
+{
+ int ret = 0;
+ adec_cmd_t *cmd;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ //*gain = 20*log10f((float)audec->pre_gain);
+
+ return ret;
+}
+
+/**
+ * \brief get audio decode pre-mute
+ * \param handle pointer to player private data
+ * \param mute pre-mute value
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_decode_get_pre_mute(void *handle, uint *mute)
+{
+ int ret = 0;
+ adec_cmd_t *cmd;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ *mute = audec->pre_mute;
+
+ return ret;
+}
+
+/**
+ * \brief set audio volume
+ * \param handle pointer to player private data
+ * \param lvol: left volume value,rvol:right volume value
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_decode_get_lrvolume(void *handle, float *lvol, float* rvol)
+{
+ int ret = 0;
+ adec_cmd_t *cmd;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ *lvol = audec->volume;
+ *rvol = audec->volume_ext;
+
+ return ret;
+}
+
+/**
+ * \brief swap audio left and right channels
+ * \param handle pointer to player private data
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_channels_swap(void *handle)
+{
+ int ret;
+ adec_cmd_t *cmd;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ cmd = adec_message_alloc();
+ if (cmd) {
+ audec->soundtrack = HW_CHANNELS_SWAP;
+ cmd->ctrl_cmd = CMD_CHANL_SWAP;
+ ret = adec_send_message(audec, cmd);
+ } else {
+ adec_print("message alloc failed, no memory!");
+ ret = -1;
+ }
+
+ return ret;
+}
+
+/**
+ * \brief output left channel
+ * \param handle pointer to player private data
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_channel_left_mono(void *handle)
+{
+ int ret;
+ adec_cmd_t *cmd;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ cmd = adec_message_alloc();
+ if (cmd) {
+ audec->soundtrack = HW_LEFT_CHANNEL_MONO;
+ cmd->ctrl_cmd = CMD_LEFT_MONO;
+ ret = adec_send_message(audec, cmd);
+ } else {
+ adec_print("message alloc failed, no memory!");
+ ret = -1;
+ }
+
+ return ret;
+}
+
+/**
+ * \brief output right channel
+ * \param handle pointer to player private data
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_channel_right_mono(void *handle)
+{
+ int ret;
+ adec_cmd_t *cmd;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ cmd = adec_message_alloc();
+ if (cmd) {
+ audec->soundtrack = HW_RIGHT_CHANNEL_MONO;
+ cmd->ctrl_cmd = CMD_RIGHT_MONO;
+ ret = adec_send_message(audec, cmd);
+ } else {
+ adec_print("message alloc failed, no memory!");
+ ret = -1;
+ }
+
+ return ret;
+}
+
+/**
+ * \brief output left and right channels
+ * \param handle pointer to player private data
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audio_channel_stereo(void *handle)
+{
+ int ret;
+ adec_cmd_t *cmd;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ cmd = adec_message_alloc();
+ if (cmd) {
+ audec->soundtrack = HW_STEREO_MODE;
+ cmd->ctrl_cmd = CMD_STEREO;
+ ret = adec_send_message(audec, cmd);
+ } else {
+ adec_print("message alloc failed, no memory!");
+ ret = -1;
+ }
+
+ return ret;
+}
+
+int audio_channel_lrmix_flag_set(void *handle, int enable)
+{
+ int ret = 0;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ ret = -1;
+ } else {
+ audec->mix_lr_channel_enable = enable;
+ adec_print("[%s] set audec->mix_lr_channel_enable/%d \n", __FUNCTION__, audec->mix_lr_channel_enable);
+ }
+ return ret;
+}
+
+int audio_decpara_get(void *handle, int *pfs, int *pch ,int *lfepresent)
+{
+ int ret = 0;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ ret = -1;
+ } else if (pfs != NULL && pch != NULL && lfepresent != NULL) {
+ if (audec->adec_ops != NULL) { //armdecoder case
+ *pch = audec->adec_ops->NchOriginal;
+ *lfepresent = audec->adec_ops->lfepresent;
+ } else { //DSP case
+ *pch = audec->channels;
+ }
+ *pfs = audec->samplerate;
+ }
+ return ret;
+}
+/**
+ * \brief check output mute or not
+ * \param handle pointer to player private data
+ * \return 1 = output is mute, 0 = output not mute
+ */
+int audio_output_muted(void *handle)
+{
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ return audec->muted;
+}
+
+/**
+ * \brief check audiodec ready or not
+ * \param handle pointer to player private data
+ * \return 1 = audiodec is ready, 0 = audiodec not ready
+ */
+int audio_dec_ready(void *handle)
+{
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ if (audec->state > INITTED) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+/**
+ * \brief get audio dsp decoded frame number
+ * \param handle pointer to player private data
+ * \return n = audiodec frame number, -1 = error
+ */
+int audio_get_decoded_nb_frames(void *handle)
+{
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ audec->decoded_nb_frames = audiodsp_get_decoded_nb_frames(&audec->adsp_ops);
+ //adec_print("audio_get_decoded_nb_frames: %d!", audec->decoded_nb_frames);
+ if (audec->decoded_nb_frames >= 0) {
+ return audec->decoded_nb_frames;
+ } else {
+ return -2;
+ }
+}
+
+/**
+ * \brief set av sync threshold in ms.
+ * \param handle pointer to player private data
+ * \param threshold av sync time threshold in ms
+ */
+int audio_set_av_sync_threshold(void *handle, int threshold)
+{
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ if ((threshold > 500) || (threshold < 60)) {
+ adec_print("threshold %d id too small or too large.\n", threshold);
+ }
+
+ audec->avsync_threshold = threshold * 90;
+ return 0;
+}
+int audio_get_soundtrack(void *handle, int* strack)
+{
+ int ret = 0;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ *strack = audec->soundtrack;
+
+ return ret;
+}
+
+int audio_get_pcm_level(void* handle)
+{
+ aml_audio_dec_t* audec = (aml_audio_dec_t*)handle;
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+
+ return audiodsp_get_pcm_level(&audec->adsp_ops);
+
+}
+
+int audio_set_skip_bytes(void* handle, unsigned int bytes)
+{
+ aml_audio_dec_t* audec = (aml_audio_dec_t*) handle;
+ if (!handle) {
+ adec_print("audio handle is NULL !!\n");
+ return -1;
+ }
+
+ return audiodsp_set_skip_bytes(&audec->adsp_ops, bytes);
+}
+
+int audio_get_pts(void* handle)
+{
+ aml_audio_dec_t* audec = (aml_audio_dec_t*)handle;
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+ return audiodsp_get_pts(&audec->adsp_ops);
+}
+/*
+ @get the audio decoder enabled status ,special for dts/dolby audio ,
+ @note that :this should be called after audio_decode_start,
+ @because the status was got from decoder.
+ @default set a invalid value -1.so if got value -1,it means have not got the decoder status.try again.
+ @return 0:disable ; 1:enable ;
+
+*/
+int audio_decoder_get_enable_status(void* handle)
+{
+ aml_audio_dec_t* audec = (aml_audio_dec_t*)handle;
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+ return audec->audio_decoder_enabled;
+}
+
+/**
+ * \brief get audio decoder cached latency
+ * \param handle pointer to player private data
+ * \return n = audio decoder cached latency ms, -1 = error
+ */
+int audio_get_decoded_pcm_delay(void *handle)
+{
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+ if (!audec) {
+ adec_print("audec null\n");
+ return -1;
+ }
+ buffer_stream_t *g_bst = audec->g_bst;
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+ if (!g_bst) {
+ return 0;
+ } else if (audec->samplerate && audec->channels) {
+ return g_bst->buf_level * 1000 / (audec->samplerate * audec->channels * 2);
+ } else {
+ return 0;
+ }
+}
+/**
+ * \brief check if the audio format supported by audio decoder
+ * \param handle pointer to player private data
+ * \return 0 = diable,1 = enable, -1 = error
+ */
+int audio_get_format_supported(int format)
+{
+ int enable = 1;
+ if (format == ACODEC_FMT_DRA) {
+ if (access("/system/lib/libdra.so",F_OK)) {
+ enable = 0;
+ }
+ }
+ else if (format < ACODEC_FMT_MPEG || format > ACODEC_FMT_WMAVOI) {
+ adec_print("unsupported format %d\n",format);
+ enable = 0;
+ }
+ return enable;
+}
+int audio_decoder_set_trackrate(void* handle, void *rate)
+{
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+ audio_out_operations_t *aout_ops = NULL;
+ if (!audec) {
+ adec_print("audio handle is NULL !\n");
+ return -1;
+ }
+ aout_ops = &audec->aout_ops;
+ if (aout_ops->set_track_rate)
+ return aout_ops->set_track_rate(audec,rate);
+ return 0;
+}
+
+/**
+ * \brief set audio associate decode en/dis-able
+ * \param handle pointer to player private data
+ * \return 0 =success, -1 = error
+ */
+int audio_set_associate_enable(void* handle, unsigned int enable)
+{
+ int ret = 0;
+ //enable it after dual-decoder code merged to android N
+#if 0
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ ret = -1;
+ } else {
+ audec->associate_audio_enable = enable;
+ adec_print("[%s]-[associate_audio_enable:%d]\n", __FUNCTION__, audec->associate_audio_enable);
+ }
+#endif
+ return ret;
+}
+
+/**
+ * \brief send the audio-associate data to destination buffer
+ * \param handle pointer to player private data
+ * \param buf pointer of the destination buffer address
+ * \param size which means that the length of request size
+ * \return [0, size], the length that have writen to destination buffer.
+ * \return -1, handle or other error
+ */
+int audio_send_associate_data(void* handle, uint8_t *buf, size_t size)
+{
+#if 0
+ int ret = 0;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)handle;
+ if (!handle) {
+ adec_print("audio handle is NULL !\n");
+ ret = -1;
+ } else {
+ if ((audec->associate_dec_supported) && (audec->g_assoc_bst)) {
+ if (audec->associate_audio_enable == 1) {
+ ret = write_es_buffer(buf, audec->g_assoc_bst, size);
+ }
+ else {
+ adec_print("[%s]-[associate_audio_enable:%d]\n", __FUNCTION__, audec->associate_audio_enable);
+ ret = reset_buffer(audec->g_assoc_bst);
+ }
+ }
+ else {
+ adec_print("[%s]-[associate_dec_supported:%d]-[g_assoc_bst:%p]\n",
+ __FUNCTION__, audec->associate_dec_supported, audec->g_assoc_bst);
+ ret = -1;
+ }
+ }
+
+ return ret;
+#else
+ return size;
+#endif
+}
diff --git a/amadec/adec-ffmpeg-mgt.c b/amadec/adec-ffmpeg-mgt.c
new file mode 100644
index 0000000..2a84c45
--- a/dev/null
+++ b/amadec/adec-ffmpeg-mgt.c
@@ -0,0 +1,1550 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <dlfcn.h>
+
+#include "audiodsp_update_format.h"
+#include "adec_omx_brige.h"
+#include "adec_reg.h"
+#include <adec-pts-mgt.h>
+#include <adec_write.h>
+#include "Amsysfsutils.h"
+#include "amconfigutils.h"
+
+#include <audio-dec.h>
+#include <amthreadpool.h>
+#include <cutils/properties.h>
+
+extern int read_buffer(unsigned char *buffer, int size);
+void *audio_decode_loop(void *args);
+void *audio_dtsdecode_loop(void *args);
+void *audio_getpackage_loop(void *args);
+static int set_sysfs_int(const char *path, int val);
+static void stop_decode_thread(aml_audio_dec_t *audec);
+
+/*audio decoder list structure*/
+typedef struct {
+ //enum CodecID codec_id;
+ int codec_id;
+ char name[64];
+} audio_lib_t;
+
+audio_lib_t audio_lib_list[] = {
+ {ACODEC_FMT_AAC, "libfaad.so"},
+ {ACODEC_FMT_AAC_LATM, "libfaad.so"},
+ {ACODEC_FMT_APE, "libape.so"},
+ {ACODEC_FMT_MPEG, "libmad.so"},
+ {ACODEC_FMT_MPEG2, "libmad.so"},
+ {ACODEC_FMT_MPEG1, "libmad.so"},
+ {ACODEC_FMT_FLAC, "libflac.so"},
+ {ACODEC_FMT_COOK, "libcook.so"},
+ {ACODEC_FMT_RAAC, "libraac.so"},
+ {ACODEC_FMT_AMR, "libamr.so"},
+
+ {ACODEC_FMT_PCM_S16BE, "libpcm.so"},
+ {ACODEC_FMT_PCM_S16LE, "libpcm.so"},
+ {ACODEC_FMT_PCM_U8, "libpcm.so"},
+ {ACODEC_FMT_PCM_BLURAY, "libpcm.so"},
+ {ACODEC_FMT_WIFIDISPLAY, "libpcm.so"},
+ {ACODEC_FMT_ALAW, "libpcm.so"},
+ {ACODEC_FMT_MULAW, "libpcm.so"},
+ {ACODEC_FMT_ADPCM, "libadpcm.so"},
+ {ACODEC_FMT_DRA, "libdra.so"},
+ 0
+} ;
+
+int find_audio_lib(aml_audio_dec_t *audec)
+{
+ int i;
+ int num;
+ audio_lib_t *f;
+
+ adec_print("[%s %d]audec->format/%d audec->codec_id/0x%x\n", __FUNCTION__, __LINE__, audec->format, audec->codec_id);
+ num = ARRAY_SIZE(audio_lib_list);
+ audio_decoder_operations_t *adec_ops = audec->adec_ops;
+ //-------------------------
+ if (find_omx_lib(audec)) {
+ return 0;
+ }
+ //-----------------------
+ for (i = 0; i < num; i++) {
+ f = &audio_lib_list[i];
+ if (f->codec_id == audec->format) {
+ void *fd = dlopen(audio_lib_list[i].name, RTLD_NOW);
+ if (fd != 0) {
+ adec_ops->init = dlsym(fd, "audio_dec_init");
+ adec_ops->decode = dlsym(fd, "audio_dec_decode");
+ adec_ops->release = dlsym(fd, "audio_dec_release");
+ adec_ops->getinfo = dlsym(fd, "audio_dec_getinfo");
+ } else {
+ adec_print("cant find decoder lib\n");
+ return -1;
+ }
+ return 0;
+ }
+ }
+ return -1;
+}
+
+
+audio_decoder_operations_t AudioArmDecoder = {
+ "FFmpegDecoder",
+ AUDIO_ARM_DECODER,
+ 0,
+};
+static int FFmpegDecoderInit(audio_decoder_operations_t *adec_ops)
+{
+ return 0;
+}
+static int FFmpegDecode(audio_decoder_operations_t *adec_ops, char *outbuf, int *outlen, char *inbuf, int inlen)
+{
+ int ret;
+ return ret;
+}
+static int FFmpegDecoderRelease(audio_decoder_operations_t *adec_ops)
+{
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)(adec_ops->priv_data);
+ return 0;
+}
+audio_decoder_operations_t AudioFFmpegDecoder = {
+ .name = "FFmpegDecoder",
+ .nAudioDecoderType = AUDIO_FFMPEG_DECODER,
+ .init = FFmpegDecoderInit,
+ .decode = FFmpegDecode,
+ .release = FFmpegDecoderRelease,
+ .getinfo = NULL,
+};
+
+int package_list_free(aml_audio_dec_t * audec)
+{
+ lp_lock(&(audec->pack_list.tslock));
+ while (audec->pack_list.pack_num) {
+ struct package * p = audec->pack_list.first;
+ audec->pack_list.first = audec->pack_list.first->next;
+ free(p->data);
+ free(p);
+ audec->pack_list.pack_num--;
+ }
+ lp_unlock(&(audec->pack_list.tslock));
+ return 0;
+}
+static int64_t gettime_ms(void)
+{
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ return (int64_t)tv.tv_sec * 1000 + tv.tv_usec/1000;
+}
+
+
+int package_list_init(aml_audio_dec_t * audec)
+{
+ audec->pack_list.first = NULL;
+ audec->pack_list.pack_num = 0;
+ audec->pack_list.current = NULL;
+ lp_lock_init(&(audec->pack_list.tslock), NULL);
+ return 0;
+}
+
+int package_add(aml_audio_dec_t * audec, char * data, int size)
+{
+ lp_lock(&(audec->pack_list.tslock));
+ if (audec->pack_list.pack_num == 4) { //enough
+ lp_unlock(&(audec->pack_list.tslock));
+ return -2;
+ }
+ struct package *p = malloc(sizeof(struct package));
+ if (!p) { //malloc failed
+ lp_unlock(&(audec->pack_list.tslock));
+ return -1;
+ }
+ p->data = data;
+ p->size = size;
+ if (audec->pack_list.pack_num == 0) { //first package
+ audec->pack_list.first = p;
+ audec->pack_list.current = p;
+ audec->pack_list.pack_num = 1;
+ } else {
+ audec->pack_list.current->next = p;
+ audec->pack_list.current = p;
+ audec->pack_list.pack_num++;
+ }
+ lp_unlock(&(audec->pack_list.tslock));
+ return 0;
+}
+
+struct package * package_get(aml_audio_dec_t * audec) {
+ lp_lock(&(audec->pack_list.tslock));
+ if (audec->pack_list.pack_num == 0) {
+ lp_unlock(&(audec->pack_list.tslock));
+ return NULL;
+ }
+ struct package *p = audec->pack_list.first;
+ if (audec->pack_list.pack_num == 1) {
+ audec->pack_list.first = NULL;
+ audec->pack_list.pack_num = 0;
+ audec->pack_list.current = NULL;
+ } else if (audec->pack_list.pack_num > 1) {
+ audec->pack_list.first = audec->pack_list.first->next;
+ audec->pack_list.pack_num--;
+ }
+ lp_unlock(&(audec->pack_list.tslock));
+ return p;
+}
+
+
+int armdec_stream_read(dsp_operations_t *dsp_ops, char *buffer, int size)
+{
+ int read_size = 0;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)dsp_ops->audec;
+ read_size = read_pcm_buffer(buffer, audec->g_bst, size);
+ audec->out_len_after_last_valid_pts += read_size;
+ return read_size;
+}
+
+int armdec_stream_read_raw(dsp_operations_t *dsp_ops, char *buffer, int size)
+{
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)dsp_ops->audec;
+ return read_pcm_buffer(buffer, audec->g_bst_raw, size);
+}
+unsigned long armdec_get_pts(dsp_operations_t *dsp_ops)
+{
+ unsigned long val, offset;
+ unsigned long pts;
+ int data_width, channels, samplerate;
+ unsigned long long frame_nums ;
+ unsigned long delay_pts;
+ char value[PROPERTY_VALUE_MAX];
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)dsp_ops->audec;
+ audio_out_operations_t * aout_ops = &audec->aout_ops;
+ float track_speed = 1.0f;
+ if (aout_ops->track_rate != 8.8f)
+ track_speed = aout_ops->track_rate;
+ switch (audec->g_bst->data_width) {
+ case AV_SAMPLE_FMT_U8:
+ data_width = 8;
+ break;
+ case AV_SAMPLE_FMT_S16:
+ data_width = 16;
+ break;
+ case AV_SAMPLE_FMT_S32:
+ data_width = 32;
+ break;
+ default:
+ data_width = 16;
+ }
+
+ int pts_delta = 0;
+ if ( property_get("media.libplayer.pts_delta",value,NULL) > 0)
+ {
+ pts_delta = atoi(value);
+ }
+
+ channels = audec->g_bst->channels;
+ samplerate = audec->g_bst->samplerate;
+ if (!channels || !samplerate) {
+ adec_print("warning ::::zero channels %d, sample rate %d \n", channels, samplerate);
+ if (!samplerate) {
+ samplerate = 48000;
+ }
+ if (!channels) {
+ channels = 2;
+ }
+ }
+ offset = audec->decode_offset;
+ if (dsp_ops->dsp_file_fd >= 0) {
+ if (audec->g_bst->format != ACODEC_FMT_COOK && audec->g_bst->format != ACODEC_FMT_RAAC) {
+ //when first look up apts,set offset 0
+ if (!audec->first_apts_lookup_over) {
+ offset = 0;
+ }
+ ioctl(dsp_ops->dsp_file_fd, AMSTREAM_IOC_APTS_LOOKUP, &offset);
+ }
+ //for cook/raac should wait to get first apts from decoder
+ else {
+ int wait_count = 10;
+ while (offset == 0xffffffff && wait_count-- > 0) {
+ amthreadpool_thread_usleep(10000);
+ }
+ offset = audec->decode_offset;
+ if (offset == 0xffffffff) {
+ adec_print(" cook/raac get apts 100 ms timeout \n");
+ }
+
+ }
+ } else {
+ adec_print("====abuf have not open!\n", val);
+ }
+
+ if (am_getconfig_bool("media.arm.audio.apts_add")) {
+ offset = 0;
+ }
+ pts = offset;
+ if (!audec->first_apts_lookup_over) {
+ audec->last_valid_pts = pts;
+ audec->first_apts_lookup_over = 1;
+ return pts;
+ }
+
+ if (audec->use_get_out_posion && audec->aout_ops.get_out_position) {
+ /*add by zz*/
+ int64_t postion, time_us;
+ struct timespec timenow;
+ int ret;
+ ret = audec->aout_ops.get_out_position(audec, &postion, &time_us);
+ if (!ret) {
+ int decodered_samples;
+ int cache_samples;
+ int delay_us, t_us;
+ decodered_samples = audec->decode_pcm_offset * 8 /(channels * data_width);
+ cache_samples = decodered_samples - postion;
+ if (cache_samples < 0)
+ cache_samples = 0;
+ delay_us = 1000 * (cache_samples * 1000 / samplerate);
+ clock_gettime(CLOCK_MONOTONIC, &timenow);
+ t_us = timenow.tv_sec * 1000000LL + timenow.tv_nsec/1000 - time_us;
+ if (t_us > 0)
+ delay_us -= t_us;
+ if (delay_us < 0)
+ delay_us = 0;
+ delay_pts = delay_us * 90/1000;
+ if (pts == 0) {
+ int outsamples = postion - audec->last_out_postion ;
+ /*delay_us out samples after last refresh pts*/
+ delay_us = 1000 * (outsamples * 1000 / samplerate);
+ delay_us = delay_us * track_speed;
+ if (delay_us < 0)
+ delay_us = 0;
+ pts = audec->last_valid_pts + delay_us * 90 /1000;
+ audec->last_valid_pts = pts;
+ pts += 90000 / 1000 * pts_delta;
+ audec->last_out_postion = postion;
+ audec->last_get_postion_time_us = time_us;
+ return pts;
+ }
+ audec->last_out_postion = postion;
+ audec->last_get_postion_time_us = time_us;
+ } else {
+ delay_pts = 0;/*audio track not ready? used buf_level add for pts*/
+ }
+ } else {
+ delay_pts = 0;
+ }
+ if (delay_pts == 0)
+ {
+ if (pts == 0) {
+ if (audec->last_valid_pts) {
+ pts = audec->last_valid_pts;
+ }
+ frame_nums = (audec->out_len_after_last_valid_pts * 8 / (data_width * channels));
+ pts += (frame_nums * 90000 / samplerate);
+ pts += 90000 / 1000 * pts_delta;
+ if (pts < 0)
+ pts = 0;
+ //adec_print("decode_offset:%d out_pcm:%d pts:%d \n",decode_offset,out_len_after_last_valid_pts,pts);
+ return pts;
+ }
+ {
+ int len = audec->g_bst->buf_level + audec->pcm_cache_size;
+ frame_nums = (len * 8 / (data_width * channels));
+ delay_pts = (frame_nums * 90000 / samplerate);
+ }
+ }
+ delay_pts = delay_pts * track_speed;
+ if (pts > delay_pts) {
+ pts -= delay_pts;
+ } else {
+ pts = 0;
+ }
+ val = pts;
+ audec->last_valid_pts = pts;
+ audec->out_len_after_last_valid_pts = 0;
+ //adec_print("====get pts:%ld offset:%ld frame_num:%lld delay:%ld \n",val,decode_offset,frame_nums,delay_pts);
+
+ val += 90000 / 1000 * pts_delta; // for a/v sync test,some times audio ahead video +28ms.so add +15ms to apts to .....
+ if (val < 0)
+ val = 0;
+ return val;
+}
+
+unsigned long armdec_get_pcrscr(dsp_operations_t *dsp_ops)
+{
+ unsigned int val;
+ if (dsp_ops->dsp_file_fd < 0) {
+ adec_print("read error!! audiodsp have not opened\n");
+ return -1;
+ }
+ ioctl(dsp_ops->dsp_file_fd, AMSTREAM_IOC_PCRSCR, &val);
+ return val;
+}
+unsigned long armdec_set_pts(dsp_operations_t *dsp_ops, unsigned long apts)
+{
+ if (dsp_ops->dsp_file_fd < 0) {
+ adec_print("armdec_set_apts err!\n");
+ return -1;
+ }
+ ioctl(dsp_ops->dsp_file_fd, AMSTREAM_IOC_SET_APTS, &apts);
+ return 0;
+}
+int armdec_set_skip_bytes(dsp_operations_t* dsp_ops, unsigned int bytes)
+{
+ return 0;
+}
+static int set_sysfs_int(const char *path, int val)
+{
+ return amsysfs_set_sysfs_int(path, val);
+}
+int get_decoder_status(void *p, struct adec_status *adec)
+{
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)p;
+ if (audec && audec->g_bst) {
+ adec->channels = audec->g_bst->channels;
+ adec->sample_rate = audec->g_bst->samplerate;
+ adec->resolution = audec->g_bst->data_width;
+ adec->error_count = audec->nDecodeErrCount; //need count
+ adec->status = (audec->state > INITTED) ? 1 : 0;
+ return 0;
+ } else {
+ return -1;
+ }
+}
+
+/**
+ * \brief register audio decoder
+ * \param audec pointer to audec ,codec_type
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int RegisterDecode(aml_audio_dec_t *audec, int type)
+{
+ switch (type) {
+ case AUDIO_ARM_DECODER:
+ memset(&AudioArmDecoder, 0, sizeof(audio_decoder_operations_t));
+ audec->adec_ops = &AudioArmDecoder;
+ find_audio_lib(audec);
+ audec->adec_ops->priv_data = audec;
+ break;
+ case AUDIO_FFMPEG_DECODER:
+ audec->adec_ops = &AudioFFmpegDecoder;
+ audec->adec_ops->priv_data = audec;
+ break;
+ default:
+ audec->adec_ops = &AudioFFmpegDecoder;
+ audec->adec_ops->priv_data = audec;
+ break;
+ }
+ return 0;
+}
+
+static int InBufferInit(aml_audio_dec_t *audec)
+{
+ int ret = uio_init(audec);
+ if (ret < 0) {
+ adec_print("uio init error! \n");
+ return -1;
+ }
+ return 0;
+}
+static int InBufferRelease(aml_audio_dec_t *audec)
+{
+ // close(audec->fd_uio);
+ // audec->fd_uio=-1;
+ uio_deinit(audec);
+ return 0;
+}
+
+
+static int OutBufferInit(aml_audio_dec_t *audec)
+{
+ audec->g_bst = malloc(sizeof(buffer_stream_t));
+ if (!audec->g_bst) {
+ adec_print("[%s %d]g_bst malloc failed! \n", __FUNCTION__, __LINE__);
+ audec->g_bst = NULL;
+ return -1;
+ } else {
+ adec_print("[%s %d] audec->g_bst/%p", __FUNCTION__, __LINE__, audec->g_bst);
+ }
+
+ memset(audec->g_bst, 0, sizeof(buffer_stream_t));
+
+ if (audec->adec_ops->nOutBufSize <= 0) { //set default if not set
+ audec->adec_ops->nOutBufSize = DEFAULT_PCM_BUFFER_SIZE;
+ }
+
+ int ret = init_buff(audec->g_bst, audec->adec_ops->nOutBufSize);
+ if (ret == -1) {
+ adec_print("[%s %d]pcm buffer init failed !\n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ adec_print("[%s %d]pcm buffer init ok buf_size:%d\n", __FUNCTION__, __LINE__, audec->g_bst->buf_length);
+
+ audec->g_bst->data_width = audec->data_width = AV_SAMPLE_FMT_S16;
+
+ if (audec->channels > 0) {
+ audec->g_bst->channels = audec->channels;
+ }
+ if (audec->samplerate > 0) {
+ audec->g_bst->samplerate = audec->samplerate;
+ }
+ audec->g_bst->format = audec->format;
+
+ return 0;
+}
+static int OutBufferInit_raw(aml_audio_dec_t *audec)
+{
+ audec->g_bst_raw = malloc(sizeof(buffer_stream_t));
+ if (!audec->g_bst_raw) {
+ adec_print("[%s %d]g_bst_raw malloc failed!\n", __FUNCTION__, __LINE__);
+ audec->g_bst_raw = NULL;
+ return -1;
+ } else {
+ adec_print("[%s %d] audec->audec->g_bst_raw/%p", __FUNCTION__, __LINE__, audec->g_bst_raw);
+ }
+
+ if (audec->adec_ops->nOutBufSize <= 0) { //set default if not set
+ audec->adec_ops->nOutBufSize = DEFAULT_PCM_BUFFER_SIZE;
+ }
+ if ((audec->format == ACODEC_FMT_DTS || audec->format == ACODEC_FMT_TRUEHD) && amsysfs_get_sysfs_int("/sys/class/audiodsp/digital_raw") == 2) {
+ audec->adec_ops->nOutBufSize *= 2;
+ }
+ int ret = init_buff(audec->g_bst_raw, audec->adec_ops->nOutBufSize);
+ if (ret == -1) {
+ adec_print("[%s %d]raw_buf init failed !\n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ adec_print("[%s %d]raw buffer init ok buf_size/%d\n", __FUNCTION__, __LINE__, audec->g_bst_raw->buf_length);
+
+ audec->g_bst_raw->data_width = audec->data_width = AV_SAMPLE_FMT_S16;
+ if (audec->channels > 0) {
+ audec->g_bst_raw->channels = audec->channels;
+ } else {
+ audec->g_bst_raw->channels = audec->channels = 2;
+ }
+
+ if (audec->samplerate > 0) {
+ audec->g_bst_raw->samplerate = audec->samplerate;
+ } else {
+ audec->g_bst_raw->samplerate = audec->samplerate = 48000;
+ }
+
+ return 0;
+}
+static int OutBufferRelease(aml_audio_dec_t *audec)
+{
+ if (audec->g_bst) {
+ adec_print("[%s %d] audec->g_bst/%p", __FUNCTION__, __LINE__, audec->g_bst);
+ release_buffer(audec->g_bst);
+ audec->g_bst = NULL;
+ }
+ return 0;
+}
+
+static int OutBufferRelease_raw(aml_audio_dec_t *audec)
+{
+ if (audec->g_bst_raw) {
+ adec_print("[%s %d] audec->g_bst_raw/%p", __FUNCTION__, __LINE__, audec->g_bst_raw);
+ release_buffer(audec->g_bst_raw);
+ audec->g_bst_raw = NULL;
+ }
+ return 0;
+}
+
+static int enable_raw_output(aml_audio_dec_t *audec)
+{
+ int enable = 0;
+ enable = amsysfs_get_sysfs_int("/sys/class/audiodsp/digital_raw");
+ if (enable) {
+ if (audec->format == ACODEC_FMT_AC3 || audec->format == ACODEC_FMT_EAC3 || audec->format == ACODEC_FMT_DTS ||
+ audec->format == ACODEC_FMT_TRUEHD) {
+ return 1;
+ }
+ }
+ return 0;
+}
+static int audio_codec_init(aml_audio_dec_t *audec)
+{
+ //reset static&global
+ audec->exit_decode_thread = 0;
+ audec->exit_decode_thread_success = 0;
+ audec->decode_offset = 0;
+ audec->decode_pcm_offset = 0;
+ audec->nDecodeErrCount = 0;
+ audec->g_bst = NULL;
+ audec->g_bst_raw = NULL;
+ audec->fd_uio = -1;
+ audec->last_valid_pts = 0;
+ audec->out_len_after_last_valid_pts = 0;
+ audec->pcm_cache_size = 0;
+ audec->sn_threadid = -1;
+ audec->sn_getpackage_threadid = -1;
+ audec->OmxFirstFrameDecoded = 0;
+ audec->use_get_out_posion = am_getconfig_bool_def("media.audio.pts.use_get_posion", 0);
+ package_list_init(audec);
+ while (0 != set_sysfs_int(DECODE_ERR_PATH, DECODE_NONE_ERR)) {
+ adec_print("[%s %d]set codec fatal failed ! \n", __FUNCTION__, __LINE__);
+ amthreadpool_thread_usleep(100000);
+ }
+
+ adec_print("[%s %d]param:data_width:%d samplerate:%d channel:%d \n",
+ __FUNCTION__, __LINE__, audec->data_width, audec->samplerate, audec->channels);
+
+ audec->data_width = AV_SAMPLE_FMT_S16;
+ if (audec->channels > 0) {
+ int NumChSave = audec->channels;
+ audec->channels = (audec->channels > 2 ? 2 : audec->channels);
+ audec->adec_ops->channels = audec->channels;
+ if (audec->format == ACODEC_FMT_PCM_S16BE || audec->format == ACODEC_FMT_PCM_S16LE ||
+ audec->format == ACODEC_FMT_PCM_U8 || audec->format == ACODEC_FMT_PCM_BLURAY ||
+ audec->format == ACODEC_FMT_WIFIDISPLAY || audec->format == ACODEC_FMT_ALAW ||
+ audec->format == ACODEC_FMT_MULAW || audec->format == ACODEC_FMT_ADPCM) {
+ audec->adec_ops->channels = NumChSave;
+ }
+ }
+ //for raac/cook audio pts are updated from audio decoder,so set a invalid pts default.
+ else if (audec->format == ACODEC_FMT_RAAC || audec->format == ACODEC_FMT_COOK) {
+ audec->decode_offset = 0xffffffff;
+ }
+ if (audec->samplerate > 0) {
+ audec->adec_ops->samplerate = audec->samplerate;
+ } else {
+ // audec->adec_ops->samplerate=audec->samplerate=48000;
+ }
+ switch (audec->data_width) {
+ case AV_SAMPLE_FMT_U8:
+ audec->adec_ops->bps = 8;
+ break;
+ case AV_SAMPLE_FMT_S16:
+ audec->adec_ops->bps = 16;
+ break;
+ case AV_SAMPLE_FMT_S32:
+ audec->adec_ops->bps = 32;
+ break;
+ default:
+ audec->adec_ops->bps = 16;
+ }
+ adec_print("[%s %d]param_applied: bps:%d samplerate:%d channel:%d \n",
+ __FUNCTION__, __LINE__, audec->adec_ops->bps, audec->adec_ops->samplerate, audec->adec_ops->channels);
+
+ audec->adec_ops->extradata_size = audec->extradata_size;
+ if (audec->extradata_size > 0) {
+ memcpy(audec->adec_ops->extradata, audec->extradata, audec->extradata_size);
+ }
+
+ int ret = 0;
+ if (!audec->StageFrightCodecEnableType) { //1-decoder init
+ ret = audec->adec_ops->init(audec->adec_ops);
+ }
+ if (ret == -1) {
+ adec_print("[%s %d]adec_ops init err\n", __FUNCTION__, __LINE__);
+ goto err1;
+ }
+
+ ret = OutBufferInit(audec); //2-pcm_buffer init
+ if (ret == -1) {
+ adec_print("[%s %d]out buffer init err\n", __FUNCTION__, __LINE__);
+ goto err2;
+ }
+ if (enable_raw_output(audec)) {
+ ret = OutBufferInit_raw(audec);
+ if (ret == -1) {
+ adec_print("[%s %d]out_raw buffer init err\n", __FUNCTION__, __LINE__);
+ OutBufferRelease_raw(audec);
+ goto err2;
+ }
+ }
+ ret = InBufferInit(audec); //3-init uio
+ if (ret == -1) {
+ adec_print("====in buffer init err \n");
+ goto err3;
+ }
+
+ //4-other init
+ audec->adsp_ops.dsp_on = 1;
+ audec->adsp_ops.dsp_read = armdec_stream_read;
+ audec->adsp_ops.get_cur_pts = armdec_get_pts;
+ audec->adsp_ops.get_cur_pcrscr = armdec_get_pcrscr;
+ audec->adsp_ops.set_cur_apts = armdec_set_pts;
+ audec->adsp_ops.set_skip_bytes = armdec_set_skip_bytes;
+ audec->adsp_ops.dsp_read_raw = armdec_stream_read_raw;
+ audec->pcm_bytes_readed = 0;
+ audec->raw_bytes_readed = 0;
+ audec->raw_frame_size = 0;
+ audec->pcm_frame_size = 0;
+ audec->i2s_iec958_sync_flag = 1;
+ audec->i2s_iec958_sync_gate = 0;
+ audec->codec_type = 0;
+ return 0;
+
+err1:
+ audec->adec_ops->release(audec->adec_ops);
+ return -1;
+err2:
+ audec->adec_ops->release(audec->adec_ops);
+ OutBufferRelease(audec);
+ return -1;
+err3:
+ audec->adec_ops->release(audec->adec_ops);
+ OutBufferRelease(audec);
+ InBufferRelease(audec);
+ OutBufferRelease_raw(audec);
+ return -1;
+}
+int audio_codec_release(aml_audio_dec_t *audec)
+{
+ //1-decode thread quit
+ if (!audec->StageFrightCodecEnableType) {
+ stop_decode_thread(audec);//1-decode thread quit
+ audec->adec_ops->release(audec->adec_ops);//2-decoder release
+ } else {
+ stop_decode_thread_omx(audec);
+ }
+
+ InBufferRelease(audec);//3-uio uninit
+ OutBufferRelease(audec);//4-outbufferrelease
+ OutBufferRelease_raw(audec);
+ audec->adsp_ops.dsp_on = -1;//5-other release
+ audec->adsp_ops.dsp_read = NULL;
+ audec->adsp_ops.get_cur_pts = NULL;
+ audec->adsp_ops.dsp_file_fd = -1;
+
+ return 0;
+}
+
+
+static int audio_hardware_ctrl(hw_command_t cmd)
+{
+ int fd;
+ fd = open(AUDIO_CTRL_DEVICE, O_RDONLY);
+ if (fd < 0) {
+ adec_print("Open Device %s Failed!", AUDIO_CTRL_DEVICE);
+ return -1;
+ }
+
+ switch (cmd) {
+ case HW_CHANNELS_SWAP:
+ ioctl(fd, AMAUDIO_IOC_SET_CHANNEL_SWAP, 0);
+ break;
+
+ case HW_LEFT_CHANNEL_MONO:
+ ioctl(fd, AMAUDIO_IOC_SET_LEFT_MONO, 0);
+ break;
+
+ case HW_RIGHT_CHANNEL_MONO:
+ ioctl(fd, AMAUDIO_IOC_SET_RIGHT_MONO, 0);
+ break;
+
+ case HW_STEREO_MODE:
+ ioctl(fd, AMAUDIO_IOC_SET_STEREO, 0);
+ break;
+
+ default:
+ adec_print("Unknow Command %d!", cmd);
+ break;
+
+ };
+
+ close(fd);
+ return 0;
+}
+
+static int get_first_apts_flag(dsp_operations_t *dsp_ops)
+{
+ int val;
+ if (dsp_ops->dsp_file_fd < 0) {
+ adec_print("[%s %d]read error!! audiodsp have not opened\n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ ioctl(dsp_ops->dsp_file_fd, GET_FIRST_APTS_FLAG, &val);
+ return val;
+}
+
+
+/**
+ * \brief start audio dec when receive START command.
+ * \param audec pointer to audec
+ */
+static int start_adec(aml_audio_dec_t *audec)
+{
+ int ret;
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ dsp_operations_t *dsp_ops = &audec->adsp_ops;
+ unsigned long vpts, apts;
+ int times = 0;
+ char buf[32];
+ apts = vpts = 0;
+ audec->no_first_apts = 0;
+ audec->apts_start_flag = 0;
+ audec->first_apts = 0;
+
+ char value[PROPERTY_VALUE_MAX] = {0};
+ int wait_count = 100;
+ if (property_get("media.amadec.wait_count", value, NULL) > 0) {
+ wait_count = atoi(value);
+ }
+ adec_print("wait first apts count :%d \n", wait_count);
+
+ if (audec->state == INITTED) {
+ //get info from the audiodsp == can get from amstreamer
+ while ((!get_first_apts_flag(dsp_ops)) && (!audec->need_stop) && (!audec->no_first_apts)) {
+ adec_print("wait first pts checkin complete !");
+ if (amthreadpool_on_requare_exit(pthread_self())) {
+ adec_print("[%s:%d] quick interrupt \n", __FUNCTION__, __LINE__);
+ break;
+ }
+ times++;
+ if (times >= wait_count) {
+ amsysfs_get_sysfs_str(TSYNC_VPTS, buf, sizeof(buf));// read vpts
+ if (sscanf(buf, "0x%lx", &vpts) < 1) {
+ adec_print("unable to get vpts from: %s", buf);
+ return -1;
+ }
+ // save vpts to apts
+ if (vpts == 0) { // vpts invalid too
+ times = 0; // loop again
+ continue;
+ }
+ adec_print("## can't get first apts, save vpts to apts,vpts=%lx, \n", vpts);
+ sprintf(buf, "0x%lx", vpts);
+ amsysfs_set_sysfs_str(TSYNC_APTS, buf);
+ audec->no_first_apts = 1;
+ }
+ amthreadpool_thread_usleep(100000);
+ }
+ adec_print("get first apts ok, times:%d need_stop:%d auto_mute %d\n", times, audec->need_stop, audec->auto_mute);
+ if (audec->need_stop) {
+ return 0;
+ }
+
+ /*start the the pts scr,...*/
+ ret = adec_pts_start(audec);
+ if (audec->auto_mute) {
+ avsync_en(0);
+ adec_pts_pause();
+ while ((!audec->need_stop) && track_switch_pts(audec)) {
+ amthreadpool_thread_usleep(1000);
+ }
+ avsync_en(1);
+ adec_pts_resume();
+ audec->auto_mute = 0;
+ }
+ if (audec->tsync_mode == TSYNC_MODE_PCRMASTER) {
+ adec_print("[wcs-%s]-before audio track start,sleep 200ms\n",__FUNCTION__);
+ amthreadpool_thread_usleep(200 * 1000); //200ms
+ }
+ aout_ops->start(audec);
+ audec->state = ACTIVE;
+ } else {
+ adec_print("amadec status invalid, start adec failed \n");
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+ * \brief pause audio dec when receive PAUSE command.
+ * \param audec pointer to audec
+ */
+static void pause_adec(aml_audio_dec_t *audec)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ if (audec->state == ACTIVE) {
+ audec->state = PAUSED;
+ adec_pts_pause();
+ aout_ops->pause(audec);
+ }
+}
+
+/**
+ * \brief resume audio dec when receive RESUME command.
+ * \param audec pointer to audec
+ */
+static void resume_adec(aml_audio_dec_t *audec)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ if (audec->state == PAUSED) {
+ audec->state = ACTIVE;
+ audec->refresh_pts_readytime_ms = gettime_ms() +
+ am_getconfig_int_def("media.amadec.wait_fresh_ms", 200);
+ aout_ops->resume(audec);
+ adec_pts_resume();
+ }
+}
+
+/**
+ * \brief stop audio dec when receive STOP command.
+ * \param audec pointer to audec
+ */
+static void stop_adec(aml_audio_dec_t *audec)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ adec_print("[%s %d]audec->state/%d\n", __FUNCTION__, __LINE__, audec->state);
+ if (audec->state > INITING) {
+ char buf[64];
+
+ audec->state = STOPPED;
+ aout_ops->mute(audec, 1); //mute output, some repeat sound in audioflinger after stop
+ aout_ops->stop(audec);
+ audio_codec_release(audec);
+
+ sprintf(buf, "0x%lx", 0);
+ amsysfs_set_sysfs_str(TSYNC_FIRSTAPTS, buf);
+ }
+}
+
+/**
+ * \brief release audio dec when receive RELEASE command.
+ * \param audec pointer to audec
+ */
+static void release_adec(aml_audio_dec_t *audec)
+{
+ audec->state = TERMINATED;
+}
+
+/**
+ * \brief mute audio dec when receive MUTE command.
+ * \param audec pointer to audec
+ * \param en 1 = mute, 0 = unmute
+ */
+static void mute_adec(aml_audio_dec_t *audec, int en)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ if (aout_ops->mute) {
+ adec_print("%s the output !\n", (en ? "mute" : "unmute"));
+ aout_ops->mute(audec, en);
+ audec->muted = en;
+ }
+}
+
+/**
+ * \brief set volume to audio dec when receive SET_VOL command.
+ * \param audec pointer to audec
+ * \param vol volume value
+ */
+static void adec_set_volume(aml_audio_dec_t *audec, float vol)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ if (aout_ops->set_volume) {
+ adec_print("set audio volume! vol = %f\n", vol);
+ aout_ops->set_volume(audec, vol);
+ }
+}
+
+/**
+ * \brief set volume to audio dec when receive SET_LRVOL command.
+ * \param audec pointer to audec
+ * \param lvol left channel volume value
+ * \param rvol right channel volume value
+ */
+static void adec_set_lrvolume(aml_audio_dec_t *audec, float lvol, float rvol)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ if (aout_ops->set_lrvolume) {
+ adec_print("set audio volume! left vol = %f,right vol:%f\n", lvol, rvol);
+ aout_ops->set_lrvolume(audec, lvol, rvol);
+ }
+}
+static void adec_flag_check(aml_audio_dec_t *audec)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ if (audec->auto_mute && (audec->state > INITTED)) {
+ aout_ops->pause(audec);
+ amthreadpool_thread_usleep(10000);
+ while ((!audec->need_stop) && track_switch_pts(audec)) {
+ amthreadpool_thread_usleep(1000);
+ }
+ aout_ops->resume(audec);
+ audec->auto_mute = 0;
+ }
+}
+
+
+static void start_decode_thread(aml_audio_dec_t *audec)
+{
+ if (audec->state != INITTED) {
+ adec_print("decode not inited quit \n");
+ return;
+ }
+
+ pthread_t tid;
+ int ret = amthreadpool_pthread_create_name(&tid, NULL, (void *)audio_getpackage_loop, (void *)audec, "getpackagelp");
+ audec->sn_getpackage_threadid = tid;
+ adec_print("[%s]Create get package thread success! tid = %d\n", __FUNCTION__, tid);
+
+ ret = amthreadpool_pthread_create_name(&tid, NULL, (void *)audio_decode_loop, (void *)audec, "decodeloop");
+ if (ret != 0) {
+ adec_print("[%s]Create ffmpeg decode thread failed!\n", __FUNCTION__);
+ return;
+ }
+ audec->sn_threadid = tid;
+ audec->audio_decoder_enabled = 0x1;
+ pthread_setname_np(tid, "AmadecDecodeLP");
+ adec_print("[%s]Create ffmpeg decode thread success! tid = %d\n", __FUNCTION__, tid);
+}
+static void stop_decode_thread(aml_audio_dec_t *audec)
+{
+ audec->exit_decode_thread = 1;
+ int ret = amthreadpool_pthread_join(audec->sn_threadid, NULL);
+ adec_print("[%s]decode thread exit success\n", __FUNCTION__);
+ ret = amthreadpool_pthread_join(audec->sn_getpackage_threadid, NULL);
+ adec_print("[%s]get package thread exit success\n", __FUNCTION__);
+
+ audec->sn_threadid = -1;
+ audec->sn_getpackage_threadid = -1;
+}
+
+/* --------------------------------------------------------------------------*/
+/**
+* @brief getNextFrameSize Get next frame size
+*
+* @param[in] format audio format
+*
+* @return -1: no frame_size use default 0: need get again non_zero: success
+*/
+/* --------------------------------------------------------------------------*/
+
+static int get_frame_size(aml_audio_dec_t *audec)
+{
+ int frame_szie = 0;
+ int ret = 0;
+ int extra_data = 8; //?
+ StartCode *start_code = &audec->start_code;
+
+ if (start_code->status == 0 || start_code->status == 3) {
+ memset(start_code, 0, sizeof(StartCode));
+ }
+ /*ape case*/
+ if (audec->format == ACODEC_FMT_APE) {
+ if (start_code->status == 0) { //have not get the sync data
+ ret = read_buffer(start_code->buff, 4);
+ if (ret <= 0) {
+ return 0;
+ }
+ start_code->size = 4;
+ start_code->status = 1;
+ }
+
+ if (start_code->status == 1) { //start find sync word
+ if (start_code->size < 4) {
+ ret = read_buffer(start_code->buff + start_code->size, 4 - start_code->size);
+ if (ret <= 0) {
+ return 0;
+ }
+ start_code->size = 4;
+ }
+ if (start_code->size == 4) {
+ if ((start_code->buff[0] == 'A') && (start_code->buff[1] == 'P') && (start_code->buff[2] == 'T') && (start_code->buff[3] == 'S')) {
+ start_code->size = 0;
+ start_code->status = 2; //sync word found ,start find frame size
+ } else {
+ start_code->size = 3;
+ start_code->buff[0] = start_code->buff[1];
+ start_code->buff[1] = start_code->buff[2];
+ start_code->buff[2] = start_code->buff[3];
+ return 0;
+ }
+ }
+
+ }
+
+ if (start_code->status == 2) {
+ ret = read_buffer(start_code->buff, 4);
+ if (ret <= 0) {
+ return 0;
+ }
+ start_code->size = 4;
+ frame_szie = start_code->buff[3] << 24 | start_code->buff[2] << 16 | start_code->buff[1] << 8 | start_code->buff[0] + extra_data;
+ frame_szie = (frame_szie + 3) & (~3);
+ start_code->status = 3; //found frame size
+ return frame_szie;
+ }
+ }
+ return -1;
+}
+// check if audio format info changed,if changed, apply new parameters to audio track
+static void check_audio_info_changed(aml_audio_dec_t *audec)
+{
+ buffer_stream_t *g_bst = audec->g_bst;
+ AudioInfo g_AudioInfo = {0};
+ int BufLevelAllowDoFmtChg = 0;
+ audio_decoder_operations_t *adec_ops = audec->adec_ops;
+ adec_ops->getinfo(audec->adec_ops, &g_AudioInfo);
+ if (g_AudioInfo.channels != 0 && g_AudioInfo.samplerate != 0) {
+ if ((g_AudioInfo.channels != g_bst->channels) || (g_AudioInfo.samplerate != g_bst->samplerate)) {
+ // the first time we get sample rate/channel num info,we use that to set audio track.
+ if (audec->channels == 0 || audec->samplerate == 0) {
+ g_bst->channels = audec->channels = g_AudioInfo.channels;
+ g_bst->samplerate = audec->samplerate = g_AudioInfo.samplerate;
+ } else {
+ //experienc value:0.2 Secs
+ BufLevelAllowDoFmtChg = audec->samplerate * audec->channels * (audec->adec_ops->bps >> 3) / 5;
+ while ((audec->format_changed_flag || g_bst->buf_level > BufLevelAllowDoFmtChg) && !audec->exit_decode_thread) {
+ amthreadpool_thread_usleep(20000);
+ }
+ if (!audec->exit_decode_thread) {
+ adec_print("[%s]Info Changed: src:sample:%d channel:%d dest sample:%d channel:%d PCMBufLevel:%d\n",
+ __FUNCTION__, audec->samplerate, audec->channels, g_AudioInfo.samplerate, g_AudioInfo.channels, g_bst->buf_level);
+ g_bst->channels = g_AudioInfo.channels;
+ g_bst->samplerate = g_AudioInfo.samplerate;
+ if (audec->state == ACTIVE)
+ audec->aout_ops.pause(audec);
+ audec->format_changed_flag = 1;
+ }
+ }
+ }
+ }
+}
+void *audio_getpackage_loop(void *args)
+{
+ int ret;
+ aml_audio_dec_t *audec;
+ audio_decoder_operations_t *adec_ops;
+ int nNextFrameSize = 0; //next read frame size
+ int inlen = 0;//real data size in in_buf
+ int nInBufferSize = 0; //full buffer size
+ char *inbuf = NULL;//real buffer
+ int rlen = 0;//read buffer ret size
+ int nAudioFormat;
+ unsigned wfd = 0;
+ if (am_getconfig_bool("media.libplayer.wfd")) {
+ wfd = 1;
+ }
+
+ adec_print("[%s]adec_getpackage_loop start!\n", __FUNCTION__);
+ audec = (aml_audio_dec_t *)args;
+ adec_ops = audec->adec_ops;
+ nAudioFormat = audec->format;
+ inlen = 0;
+ nNextFrameSize = adec_ops->nInBufSize;
+ while (1) {
+exit_decode_loop:
+ if (audec->exit_decode_thread) { /*detect quit condition*/
+ if (inbuf) {
+ free(inbuf);
+ }
+ package_list_free(audec);
+ break;
+ }
+
+ nNextFrameSize = get_frame_size(audec); /*step 2 get read buffer size*/
+ if (nNextFrameSize == -1) {
+ nNextFrameSize = adec_ops->nInBufSize;
+ } else if (nNextFrameSize == 0) {
+ amthreadpool_thread_usleep(1000);
+ continue;
+ }
+
+ nInBufferSize = nNextFrameSize;/*step 3 read buffer*/
+ if (inbuf != NULL) {
+ free(inbuf);
+ inbuf = NULL;
+ }
+ inbuf = malloc(nInBufferSize);
+
+ int nNextReadSize = nInBufferSize;
+ int nRet = 0;
+ int nReadErrCount = 0;
+ int nCurrentReadCount = 0;
+ int nReadSizePerTime = 1 * 1024;
+ rlen = 0;
+ int sleeptime = 0;
+ while (nNextReadSize > 0 && !audec->exit_decode_thread) {
+ if (nNextReadSize <= nReadSizePerTime) {
+ nReadSizePerTime = nNextReadSize;
+ }
+ nRet = read_buffer(inbuf + rlen, nReadSizePerTime); //read 10K per time
+ if (nRet <= 0) {
+ sleeptime++;
+ amthreadpool_thread_usleep(1000);
+ continue;
+ }
+ rlen += nRet;
+ nNextReadSize -= nRet;
+ if (wfd && nAudioFormat == ACODEC_FMT_AAC) {
+ if (rlen > 300) {
+ break;
+ }
+ }
+ }
+ // adec_print(" read data %d,sleep time %d ms \n", rlen,sleeptime);
+
+ sleeptime = 0;
+ nCurrentReadCount = rlen;
+ rlen += inlen;
+ ret = -1;
+ while ((ret = package_add(audec, inbuf, rlen)) && !audec->exit_decode_thread) {
+ amthreadpool_thread_usleep(1000);
+ }
+ if (ret) {
+ free(inbuf);
+ }
+ inbuf = NULL;
+ }
+QUIT:
+ adec_print("[%s]Exit adec_getpackage_loop Thread finished!", __FUNCTION__);
+ pthread_exit(NULL);
+ return NULL;
+}
+
+static char pcm_buf_tmp[AVCODEC_MAX_AUDIO_FRAME_SIZE];//max frame size out buf
+void *audio_decode_loop(void *args)
+{
+ int ret;
+ aml_audio_dec_t *audec;
+ audio_out_operations_t *aout_ops;
+ audio_decoder_operations_t *adec_ops;
+ int nNextFrameSize = 0; //next read frame size
+ int inlen = 0;//real data size in in_buf
+ int nRestLen = 0; //left data after last decode
+ int nInBufferSize = 0; //full buffer size
+ //int nStartDecodePoint=0;//start decode point in in_buf
+ char *inbuf = NULL;//real buffer
+ int rlen = 0;//read buffer ret size
+ char *pRestData = NULL;
+ char *inbuf2;
+
+ int dlen = 0;//decode size one time
+ int declen = 0;//current decoded size
+ int nCurrentReadCount = 0;
+ int needdata = 0;
+ char startcode[5];
+ int extra_data = 8;
+ int nCodecID;
+ int nAudioFormat;
+ char *outbuf = pcm_buf_tmp;
+ int outlen = 0;
+ struct package *p_Package;
+ buffer_stream_t *g_bst;
+ AudioInfo g_AudioInfo;
+ adec_print("[%s]adec_armdec_loop start!\n", __FUNCTION__);
+ audec = (aml_audio_dec_t *)args;
+ aout_ops = &audec->aout_ops;
+ adec_ops = audec->adec_ops;
+ memset(outbuf, 0, AVCODEC_MAX_AUDIO_FRAME_SIZE);
+ g_bst = audec->g_bst;
+
+ nAudioFormat = audec->format;
+ g_bst->format = audec->format;
+ inlen = 0;
+ nNextFrameSize = adec_ops->nInBufSize;
+ adec_ops->nAudioDecoderType = audec->format;
+ while (1) {
+exit_decode_loop:
+
+ if (audec->exit_decode_thread) { //detect quit condition
+ if (inbuf) {
+ free(inbuf);
+ inbuf = NULL;
+ }
+ if (pRestData) {
+ free(pRestData);
+ pRestData = NULL;
+ }
+ audec->exit_decode_thread_success = 1;
+ break;
+ }
+ //step 2 get read buffer size
+ p_Package = package_get(audec);
+ if (!p_Package) {
+ amthreadpool_thread_usleep(1000);
+ continue;
+ }
+ if (inbuf != NULL) {
+ free(inbuf);
+ inbuf = NULL;
+ }
+
+ if (inlen && pRestData) {
+ rlen = p_Package->size + inlen;
+ inbuf = malloc(rlen);
+ memcpy(inbuf, pRestData, inlen);
+ memcpy(inbuf + inlen, p_Package->data, p_Package->size);
+ free(pRestData);
+ free(p_Package->data);
+ pRestData = NULL;
+ p_Package->data = NULL;
+ } else {
+ rlen = p_Package->size;
+ inbuf = p_Package->data;
+ p_Package->data = NULL;
+ }
+ free(p_Package);
+ p_Package = NULL;
+
+ nCurrentReadCount = rlen;
+ inlen = rlen;
+ declen = 0;
+ if (nCurrentReadCount > 0) {
+ while (declen < rlen && !audec->exit_decode_thread) {
+ outlen = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+ if (nAudioFormat == ACODEC_FMT_COOK || nAudioFormat == ACODEC_FMT_RAAC || nAudioFormat == ACODEC_FMT_AMR) {
+ if (needdata > 0) {
+ pRestData = malloc(inlen);
+ if (pRestData) {
+ memcpy(pRestData, (uint8_t *)(inbuf + declen), inlen);
+ }
+ needdata = 0;
+ break;
+ }
+ }
+
+ dlen = adec_ops->decode(audec->adec_ops, outbuf, &outlen, inbuf + declen, inlen);
+ if (outlen > 0) {
+ check_audio_info_changed(audec);
+ }
+ if (outlen > AVCODEC_MAX_AUDIO_FRAME_SIZE) {
+ adec_print("!!!!!fatal error,out buffer overwriten,out len %d,actual %d", outlen, AVCODEC_MAX_AUDIO_FRAME_SIZE);
+ }
+ if (dlen <= 0) {
+
+ if (nAudioFormat == ACODEC_FMT_APE) {
+ inlen = 0;
+ } else if (inlen > 0) {
+ pRestData = malloc(inlen);
+ if (pRestData) {
+ memcpy(pRestData, (uint8_t *)(inbuf + declen), inlen);
+ }
+ }
+ audec->nDecodeErrCount++;//decode failed, add err_count
+ needdata = 0;
+ break;
+ }
+ audec->nDecodeErrCount = 0; //decode success reset to 0
+ declen += dlen;
+ inlen -= dlen;
+
+ /* decoder input buffer not enough,need new data burst */
+ if (nAudioFormat == ACODEC_FMT_COOK || nAudioFormat == ACODEC_FMT_RAAC || nAudioFormat == ACODEC_FMT_AMR) {
+ if (inlen <= declen) {
+ needdata ++;
+ }
+ }
+ // for aac decoder, if decoder cost es data but no pcm output,may need more data ,which is needed by frame resync
+ else if (nAudioFormat == ACODEC_FMT_AAC_LATM || nAudioFormat == ACODEC_FMT_AAC) {
+ if (outlen == 0 && inlen) {
+ pRestData = malloc(inlen);
+ if (pRestData) {
+ memcpy(pRestData, (uint8_t *)(inbuf + declen), inlen);
+ }
+ audec->decode_offset += dlen; //update es offset for apts look up
+ break;
+ }
+ }
+ //write to the pcm buffer
+ if (nAudioFormat == ACODEC_FMT_RAAC || nAudioFormat == ACODEC_FMT_COOK) {
+ audec->decode_offset = audec->adec_ops->pts;
+ } else {
+ audec->decode_offset += dlen;
+ }
+ audec->decode_pcm_offset += outlen;
+ audec->pcm_cache_size = outlen;
+ if (g_bst) {
+ int wlen = 0;
+ while (outlen && !audec->exit_decode_thread) {
+ if (g_bst->buf_length - g_bst->buf_level < outlen) {
+ amthreadpool_thread_usleep(100000);
+ continue;
+ }
+ wlen = write_pcm_buffer(outbuf, g_bst, outlen);
+ outlen -= wlen;
+ audec->pcm_cache_size -= wlen;
+ }
+ }
+ }
+ } else {
+ amthreadpool_thread_usleep(1000);
+ continue;
+ }
+ }
+
+ adec_print("[%s]exit adec_armdec_loop Thread finished!", __FUNCTION__);
+ pthread_exit(NULL);
+error:
+ pthread_exit(NULL);
+ return NULL;
+}
+
+void *adec_armdec_loop(void *args)
+{
+ int ret;
+ aml_audio_dec_t *audec;
+ audio_out_operations_t *aout_ops;
+ adec_cmd_t *msg = NULL;
+
+ audec = (aml_audio_dec_t *)args;
+ aout_ops = &audec->aout_ops;
+
+ // codec init
+ audec->state = INITING;
+ while (1) {
+ if (audec->need_stop) {
+ goto MSG_LOOP;
+ }
+
+ ret = audio_codec_init(audec);
+ if (ret == 0) {
+ break;
+ }
+ usleep(10000);
+ }
+ audec->state = INITTED;
+
+ //start decode thread
+ while (1) {
+ if (audec->need_stop) {
+ //no need to call release, will do it in stop_adec
+ goto MSG_LOOP;
+ }
+ if (audec->StageFrightCodecEnableType) {
+ start_decode_thread_omx(audec);
+ if (audec->OmxFirstFrameDecoded != 1) { // just one case, need_stop == 1
+ //usleep(10000); // no need
+ continue;
+ }
+ } else {
+ start_decode_thread(audec);
+ }
+ //ok
+ break;
+ }
+
+ //aout init
+ while (1) {
+ if (audec->need_stop) {
+ //no need to call release, will do it in stop_adec
+ goto MSG_LOOP;
+ }
+ //wait the audio sr/ch ready to set audio track.
+ adec_print("wait audio sr/channel begin \n");
+ while (((!audec->channels) || (!audec->samplerate)) && !audec->need_stop) {
+ amthreadpool_thread_usleep(10000);
+ }
+ adec_print("wait audio sr/channel done \n");
+ ret = aout_ops->init(audec);
+ if (ret) {
+ adec_print("[%s %d]Audio out device init failed!", __FUNCTION__, __LINE__);
+ amthreadpool_thread_usleep(10000);
+ continue;
+ }
+ //ok
+ break;
+ }
+
+ //wait first pts decoded
+ start_adec(audec);
+
+MSG_LOOP:
+ do {
+
+ adec_reset_track(audec);
+ adec_flag_check(audec);
+ if (audec->state == ACTIVE)
+ adec_refresh_pts(audec);
+ msg = adec_get_message(audec);
+ if (!msg) {
+ amthreadpool_thread_usleep(10 * 1000); //if not wait,need changed to amthread usleep
+ continue;
+ }
+
+ switch (msg->ctrl_cmd) {
+ case CMD_START:
+
+ adec_print("Receive START Command!\n");
+ //------------------------
+ if (!audec->StageFrightCodecEnableType) {
+ start_decode_thread(audec);
+ }
+ //------------------------
+ start_adec(audec);
+ break;
+
+ case CMD_PAUSE:
+
+ adec_print("Receive PAUSE Command!");
+ pause_adec(audec);
+ break;
+
+ case CMD_RESUME:
+
+ adec_print("Receive RESUME Command!");
+ resume_adec(audec);
+ break;
+
+ case CMD_STOP:
+
+ adec_print("Receive STOP Command!");
+ stop_adec(audec);
+ break;
+
+ case CMD_MUTE:
+
+ adec_print("Receive Mute Command!");
+ if (msg->has_arg) {
+ mute_adec(audec, msg->value.en);
+ }
+ break;
+
+ case CMD_SET_VOL:
+
+ adec_print("Receive Set Vol Command!");
+ if (msg->has_arg) {
+ adec_set_volume(audec, msg->value.volume);
+ }
+ break;
+ case CMD_SET_LRVOL:
+
+ adec_print("Receive Set LRVol Command!");
+ if (msg->has_arg) {
+ adec_set_lrvolume(audec, msg->value.volume, msg->value_ext.volume);
+ }
+ break;
+
+ case CMD_CHANL_SWAP:
+
+ adec_print("Receive Channels Swap Command!");
+ audio_hardware_ctrl(HW_CHANNELS_SWAP);
+ break;
+
+ case CMD_LEFT_MONO:
+
+ adec_print("Receive Left Mono Command!");
+ audio_hardware_ctrl(HW_LEFT_CHANNEL_MONO);
+ break;
+
+ case CMD_RIGHT_MONO:
+
+ adec_print("Receive Right Mono Command!");
+ audio_hardware_ctrl(HW_RIGHT_CHANNEL_MONO);
+ break;
+
+ case CMD_STEREO:
+
+ adec_print("Receive Stereo Command!");
+ audio_hardware_ctrl(HW_STEREO_MODE);
+ break;
+
+ case CMD_RELEASE:
+
+ adec_print("Receive RELEASE Command!");
+ release_adec(audec);
+ break;
+
+ default:
+ adec_print("Unknow Command!");
+ break;
+
+ }
+
+ if (msg) {
+ adec_message_free(msg);
+ msg = NULL;
+ }
+ } while (audec->state != TERMINATED);
+
+ adec_print("Exit Message Loop Thread!");
+ pthread_exit(NULL);
+ return NULL;
+}
+
+
diff --git a/amadec/adec-internal-mgt.c b/amadec/adec-internal-mgt.c
new file mode 100644
index 0000000..f51a912
--- a/dev/null
+++ b/amadec/adec-internal-mgt.c
@@ -0,0 +1,772 @@
+/**
+ * \file adec-internal-mgt.c
+ * \brief Audio Dec Message Loop Thread
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+
+#include <audio-dec.h>
+#include <adec-pts-mgt.h>
+#include <cutils/properties.h>
+#include <dts_enc.h>
+#include <Amsysfsutils.h>
+#include <amthreadpool.h>
+#include <amconfigutils.h>
+#include <unistd.h>
+#include "audiodsp_update_format.h"
+
+#define MULTICH_SUPPORT_PROPERTY "media.multich.support.info"
+#define PCM_88_96_SUPPORT "media.libplayer.88_96K"
+
+extern int RegisterDecode(aml_audio_dec_t *audec, int type);
+extern void get_output_func(struct aml_audio_dec* audec);
+
+static int64_t gettime_ms(void)
+{
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ return (int64_t)tv.tv_sec * 1000 + tv.tv_usec/1000;
+}
+
+
+
+static int set_tsync_enable(int enable)
+{
+
+ char *path = "/sys/class/tsync/enable";
+ return amsysfs_set_sysfs_int(path, enable);
+}
+
+typedef struct {
+ // int no;
+ int audio_id;
+ char type[16];
+} audio_type_t;
+
+audio_type_t audio_type[] = {
+ {ACODEC_FMT_AAC, "aac"},
+ {ACODEC_FMT_AC3, "ac3"},
+ {ACODEC_FMT_DTS, "dts"},
+ {ACODEC_FMT_FLAC, "flac"},
+ {ACODEC_FMT_COOK, "cook"},
+ {ACODEC_FMT_AMR, "amr"},
+ {ACODEC_FMT_RAAC, "raac"},
+ {ACODEC_FMT_WMA, "wma"},
+ {ACODEC_FMT_WMAPRO, "wmapro"},
+ {ACODEC_FMT_ALAC, "alac"},
+ {ACODEC_FMT_VORBIS, "vorbis"},
+ {ACODEC_FMT_AAC_LATM, "aac_latm"},
+ {ACODEC_FMT_APE, "ape"},
+ {ACODEC_FMT_MPEG, "mp3"},//mp3
+ {ACODEC_FMT_MPEG2, "mp3"},//mp2
+ {ACODEC_FMT_MPEG1, "mp3"},//mp1
+ {ACODEC_FMT_EAC3, "eac3"},
+ {ACODEC_FMT_TRUEHD, "thd"},
+ {ACODEC_FMT_PCM_S16BE, "pcm"},
+ {ACODEC_FMT_PCM_S16LE, "pcm"},
+ {ACODEC_FMT_PCM_U8, "pcm"},
+ {ACODEC_FMT_PCM_BLURAY, "pcm"},
+ {ACODEC_FMT_WIFIDISPLAY, "pcm"},
+ {ACODEC_FMT_ALAW, "pcm"},
+ {ACODEC_FMT_MULAW, "pcm"},
+
+ {ACODEC_FMT_ADPCM, "adpcm"},
+ {ACODEC_FMT_WMAVOI, "wmavoi"},
+ {ACODEC_FMT_DRA, "dra"},
+ {ACODEC_FMT_NULL, "null"},
+
+};
+
+extern int match_types(const char *filetypestr, const char *typesetting);
+
+static int audio_decoder = AUDIO_ARC_DECODER;
+static int audio_hardware_ctrl(hw_command_t cmd)
+{
+ int fd;
+
+ fd = open(AUDIO_CTRL_DEVICE, O_RDONLY);
+ if (fd < 0) {
+ adec_print("Open Device %s Failed!", AUDIO_CTRL_DEVICE);
+ return -1;
+ }
+
+ switch (cmd) {
+ case HW_CHANNELS_SWAP:
+ ioctl(fd, AMAUDIO_IOC_SET_CHANNEL_SWAP, 0);
+ break;
+
+ case HW_LEFT_CHANNEL_MONO:
+ ioctl(fd, AMAUDIO_IOC_SET_LEFT_MONO, 0);
+ break;
+
+ case HW_RIGHT_CHANNEL_MONO:
+ ioctl(fd, AMAUDIO_IOC_SET_RIGHT_MONO, 0);
+ break;
+
+ case HW_STEREO_MODE:
+ ioctl(fd, AMAUDIO_IOC_SET_STEREO, 0);
+ break;
+
+ default:
+ adec_print("Unknow Command %d!", cmd);
+ break;
+
+ };
+
+ close(fd);
+
+ return 0;
+
+}
+
+/**
+ * \brief start audio dec when receive START command.
+ * \param audec pointer to audec
+ */
+static void start_adec(aml_audio_dec_t *audec)
+{
+ int ret;
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ dsp_operations_t *dsp_ops = &audec->adsp_ops;
+ unsigned long vpts, apts;
+ int times = 0;
+ char buf[32];
+ apts = vpts = 0;
+
+ char value[PROPERTY_VALUE_MAX] = {0};
+ int wait_count = 100;
+ if (property_get("media.amadec.wait_count", value, NULL) > 0) {
+ wait_count = atoi(value);
+ }
+ adec_print("wait first apts count :%d \n", wait_count);
+
+ audec->no_first_apts = 0;
+ if (audec->state == INITTED) {
+
+ while ((!audiodsp_get_first_pts_flag(dsp_ops)) && (!audec->need_stop) && (!audec->no_first_apts)) {
+ adec_print("wait first pts checkin complete times=%d,!\n", times);
+ times++;
+
+ if (times >= wait_count) {
+ // read vpts
+ amsysfs_get_sysfs_str(TSYNC_VPTS, buf, sizeof(buf));
+ if (sscanf(buf, "0x%lx", &vpts) < 1) {
+ adec_print("unable to get vpts from: %s", buf);
+ return;
+ }
+
+ // save vpts to apts
+ adec_print("## can't get first apts, save vpts to apts,vpts=%lx, \n", vpts);
+
+ sprintf(buf, "0x%lx", vpts);
+
+ amsysfs_set_sysfs_str(TSYNC_APTS, buf);
+
+ audec->no_first_apts = 1;
+ }
+ amthreadpool_thread_usleep(100000);
+ }
+ /*Since audio_track->start consumed too much time
+ *for the first time after platform restart,
+ *so execute start cmd before adec_pts_start
+ */
+ aout_ops->start(audec);
+ aout_ops->pause(audec);
+ /*start the the pts scr,...*/
+ ret = adec_pts_start(audec);
+
+ //adec_pts_droppcm(audec);
+
+ if (audec->auto_mute) {
+ avsync_en(0);
+ audiodsp_automute_on(dsp_ops);
+ adec_pts_pause();
+
+ while ((!audec->need_stop) && track_switch_pts(audec)) {
+ amthreadpool_thread_usleep(1000);
+ }
+
+ audiodsp_automute_off(dsp_ops);
+ avsync_en(1);
+ adec_pts_resume();
+
+ audec->auto_mute = 0;
+ }
+
+ aout_ops->resume(audec);
+ audec->state = ACTIVE;
+
+ }
+}
+
+/**
+ * \brief pause audio dec when receive PAUSE command.
+ * \param audec pointer to audec
+ */
+static void pause_adec(aml_audio_dec_t *audec)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+
+ if (audec->state == ACTIVE) {
+ audec->state = PAUSED;
+ adec_pts_pause();
+ aout_ops->pause(audec);
+ }
+}
+
+/**
+ * \brief resume audio dec when receive RESUME command.
+ * \param audec pointer to audec
+ */
+static void resume_adec(aml_audio_dec_t *audec)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+
+ if (audec->state == PAUSED) {
+ audec->state = ACTIVE;
+ audec->refresh_pts_readytime_ms = gettime_ms() +
+ am_getconfig_int_def("media.amadec.wait_fresh_ms", 200);
+ aout_ops->resume(audec);
+ adec_pts_resume();
+ }
+}
+
+/**
+ * \brief stop audio dec when receive STOP command.
+ * \param audec pointer to audec
+ */
+static void stop_adec(aml_audio_dec_t *audec)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+
+ if (audec->state > INITING) {
+ audec->state = STOPPED;
+ aout_ops->mute(audec, 1); //mute output, some repeat sound in audioflinger after stop
+ aout_ops->stop(audec);
+ feeder_release(audec);
+ }
+}
+
+/**
+ * \brief release audio dec when receive RELEASE command.
+ * \param audec pointer to audec
+ */
+static void release_adec(aml_audio_dec_t *audec)
+{
+ audec->state = TERMINATED;
+}
+
+/**
+ * \brief mute audio dec when receive MUTE command.
+ * \param audec pointer to audec
+ * \param en 1 = mute, 0 = unmute
+ */
+static void mute_adec(aml_audio_dec_t *audec, int en)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+
+ if (aout_ops->mute) {
+ adec_print("%s the output !\n", (en ? "mute" : "unmute"));
+ aout_ops->mute(audec, en);
+ audec->muted = en;
+ }
+}
+
+/**
+ * \brief set volume to audio dec when receive SET_VOL command.
+ * \param audec pointer to audec
+ * \param vol volume value
+ */
+static void adec_set_volume(aml_audio_dec_t *audec, float vol)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+
+ if (aout_ops->set_volume) {
+ adec_print("set audio volume! vol = %f\n", vol);
+ aout_ops->set_volume(audec, vol);
+ }
+}
+
+/**
+ * \brief set volume to audio dec when receive SET_LRVOL command.
+ * \param audec pointer to audec
+ * \param lvol left channel volume value
+ * \param rvol right channel volume value
+ */
+static void adec_set_lrvolume(aml_audio_dec_t *audec, float lvol, float rvol)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+
+ if (aout_ops->set_lrvolume) {
+ adec_print("set audio volume! left vol = %f,right vol:%f\n", lvol, rvol);
+ aout_ops->set_lrvolume(audec, lvol, rvol);
+ }
+}
+static void adec_flag_check(aml_audio_dec_t *audec)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+
+ if (audec->auto_mute && (audec->state > INITTED) && (audec->state != PAUSED)) {
+ aout_ops->pause(audec);
+ adec_print("automute, pause audio out!\n");
+ amthreadpool_thread_usleep(10000);
+ while ((!audec->need_stop) && track_switch_pts(audec)) {
+ amthreadpool_thread_usleep(1000);
+ }
+ aout_ops->resume(audec);
+ adec_print("resume audio out, automute invalid\n");
+ audec->auto_mute = 0;
+ }
+}
+
+static int write_buffer(char *outbuf, int outlen)
+{
+ return 0;
+}
+
+
+static void *adec_message_loop(void *args)
+{
+ int ret;
+ aml_audio_dec_t *audec;
+ audio_out_operations_t *aout_ops;
+ adec_cmd_t *msg = NULL;
+
+ audec = (aml_audio_dec_t *)args;
+ aout_ops = &audec->aout_ops;
+
+ while (!audec->need_stop) {
+ audec->state = INITING;
+ ret = feeder_init(audec);
+ if (ret == 0) {
+ ret = aout_ops->init(audec);
+ if (ret) {
+ adec_print("Audio out device init failed!");
+ feeder_release(audec);
+ continue;
+ }
+ audec->state = INITTED;
+ adec_print("Audio out device init ok!");
+ start_adec(audec);
+ if (dtsenc_init() != -1) {
+ dtsenc_start();
+ }
+
+ break;
+ }
+
+ if (!audec->need_stop) {
+ amthreadpool_thread_usleep(100000);
+ }
+ }
+
+ do {
+ //if(message_pool_empty(audec))
+ //{
+ //adec_print("there is no message !\n");
+ // amthreadpool_thread_usleep(100000);
+ // continue;
+ //}
+ adec_reset_track(audec);
+ adec_flag_check(audec);
+
+ msg = adec_get_message(audec);
+ if (!msg) {
+ amthreadpool_thread_usleep(100000);
+ continue;
+ }
+
+ switch (msg->ctrl_cmd) {
+ case CMD_START:
+
+ adec_print("Receive START Command!\n");
+ start_adec(audec);
+ dtsenc_start();
+ break;
+
+ case CMD_PAUSE:
+
+ adec_print("Receive PAUSE Command!");
+ pause_adec(audec);
+ dtsenc_pause();
+ break;
+
+ case CMD_RESUME:
+
+ adec_print("Receive RESUME Command!");
+ resume_adec(audec);
+ dtsenc_resume();
+ break;
+
+ case CMD_STOP:
+
+ adec_print("Receive STOP Command!");
+ adec_print("audec->state=%d (INITING/3) when Rec_STOP_CMD\n", audec->state);
+ stop_adec(audec);
+ dtsenc_stop();
+ break;
+
+ case CMD_MUTE:
+
+ adec_print("Receive Mute Command!");
+ if (msg->has_arg) {
+ mute_adec(audec, msg->value.en);
+ }
+ break;
+
+ case CMD_SET_VOL:
+
+ adec_print("Receive Set Vol Command!");
+ if (msg->has_arg) {
+ adec_set_volume(audec, msg->value.volume);
+ }
+ break;
+ case CMD_SET_LRVOL:
+
+ adec_print("Receive Set LRVol Command!");
+ if (msg->has_arg) {
+ adec_set_lrvolume(audec, msg->value.volume, msg->value_ext.volume);
+ }
+ break;
+
+ case CMD_CHANL_SWAP:
+
+ adec_print("Receive Channels Swap Command!");
+ audio_hardware_ctrl(HW_CHANNELS_SWAP);
+ break;
+
+ case CMD_LEFT_MONO:
+
+ adec_print("Receive Left Mono Command!");
+ audio_hardware_ctrl(HW_LEFT_CHANNEL_MONO);
+ break;
+
+ case CMD_RIGHT_MONO:
+
+ adec_print("Receive Right Mono Command!");
+ audio_hardware_ctrl(HW_RIGHT_CHANNEL_MONO);
+ break;
+
+ case CMD_STEREO:
+
+ adec_print("Receive Stereo Command!");
+ audio_hardware_ctrl(HW_STEREO_MODE);
+ break;
+
+ case CMD_RELEASE:
+
+ adec_print("Receive RELEASE Command!");
+ release_adec(audec);
+ dtsenc_release();
+ break;
+
+ default:
+ adec_print("Unknow Command!");
+ break;
+
+ }
+
+ if (msg) {
+ adec_message_free(msg);
+ msg = NULL;
+ }
+ } while (audec->state != TERMINATED);
+
+ adec_print("Exit Message Loop Thread!");
+ pthread_exit(NULL);
+ return NULL;
+}
+
+/**
+ * \brief start audio dec
+ * \param audec pointer to audec
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int match_types(const char *filetypestr, const char *typesetting)
+{
+ const char * psets = typesetting;
+ const char *psetend;
+ int psetlen = 0;
+ char typestr[64] = "";
+ if (filetypestr == NULL || typesetting == NULL) {
+ return 0;
+ }
+
+ while (psets && psets[0] != '\0') {
+ psetlen = 0;
+ psetend = strchr(psets, ',');
+ if (psetend != NULL && psetend > psets && psetend - psets < 64) {
+ psetlen = psetend - psets;
+ memcpy(typestr, psets, psetlen);
+ typestr[psetlen] = '\0';
+ psets = &psetend[1]; //skip ";"
+ } else {
+ strcpy(typestr, psets);
+ psets = NULL;
+ }
+ if (strlen(typestr) > 0 && (strlen(typestr) == strlen(filetypestr))) {
+ if (strstr(filetypestr, typestr) != NULL) {
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+/*
+digital_raw:
+0 2ch PCM
+1 spdif passthrough ,for DTS,DD
+2 HDMI passthrough for DD,DTSHD,TrueHD
+3 Multi-channel PCM HDMI passthrough
+*/
+static void set_multichs_prop()
+{
+ char * infobuf;
+ int channel = 0;
+ int dgraw = 0;
+ dgraw = amsysfs_get_sysfs_int("/sys/class/audiodsp/digital_raw");
+ infobuf = (char *)malloc(1024 * sizeof(char));
+ property_set(PCM_88_96_SUPPORT, "0");
+ if (infobuf == NULL) {
+ adec_print("%s: malloc infobuf failed.\n", __FUNCTION__);
+ } else {
+ int fd = open("/sys/class/amhdmitx/amhdmitx0/aud_cap", O_RDONLY);
+ if (fd != -1) {
+ int nread = read(fd, infobuf, 1024);
+ int i;
+ nread = nread - 5;
+ for (i = 0; i < nread; i++) {
+ if ((infobuf[i] == 'P') && (infobuf[i + 1] == 'C') && (infobuf[i + 2] == 'M')) {
+ if (dgraw == 3) { // if configured mutli-channel output,check if the HDMI sink support multi-channel PCM output
+ if (infobuf[i + 5] == '8') {
+ property_set(MULTICH_SUPPORT_PROPERTY, "hdmi8");
+ channel = channel < 8 ? 8 : channel;
+ }
+ if (infobuf[i + 5] == '6') {
+ property_set(MULTICH_SUPPORT_PROPERTY, "hdmi6");
+ channel = channel < 6 ? 6 : channel;
+ }
+ if (infobuf[i + 5] == '2') {
+ property_set(MULTICH_SUPPORT_PROPERTY, "hdmi2");
+ channel = channel < 2 ? 2 : channel;
+ }
+ } else {
+ property_set(MULTICH_SUPPORT_PROPERTY, "hdmi2");
+ channel = channel < 2 ? 2 : channel;
+ }
+ } else if (
+ ((infobuf[i] == '8') && (infobuf[i + 1] == '8') && (infobuf[i + 2] == '.') && (infobuf[i + 3] == '2'))
+ || ((infobuf[i] == '9') && (infobuf[i + 1] == '6'))) {
+ property_set(PCM_88_96_SUPPORT, "1");
+ }
+ }
+ if (channel == 0) {
+ property_set(MULTICH_SUPPORT_PROPERTY, "speaker");
+ }
+ adec_print("%s: aud_cap support channel number: %d ch\n", __FUNCTION__, channel);
+ close(fd);
+ free(infobuf);
+ infobuf = NULL;
+ } else {
+ adec_print("%s: open hdmi driver aud_cap node failed \n", __FUNCTION__);
+ free(infobuf);
+ infobuf = NULL;
+ }
+ }
+}
+
+static int set_audio_decoder(aml_audio_dec_t *audec)
+{
+ int audio_id;
+ int i;
+ int num;
+ int ret;
+ audio_type_t *t;
+ char value[PROPERTY_VALUE_MAX];
+
+
+ audio_id = audec->format;
+
+ num = ARRAY_SIZE(audio_type);
+ for (i = 0; i < num; i++) {
+ t = &audio_type[i];
+ if (t->audio_id == audio_id) {
+ break;
+ }
+ }
+
+ if (match_types(t->type, "thd") || match_types(t->type, "wmavoi") || match_types(t->type, "dra") ) {
+ adec_print("audio format is %s, so chose AUDIO_ARM_DECODER", t->type);
+ audio_decoder = AUDIO_ARM_DECODER;
+ goto exit;
+ }
+
+
+ ret = property_get("media.arm.audio.decoder", value, NULL);
+ adec_print("media.amplayer.audiocodec = %s, t->type = %s\n", value, t->type);
+ if (ret > 0 && match_types(t->type, value)) {
+ char type_value[] = "ac3,eac3";
+ set_multichs_prop();
+ if (match_types(t->type, type_value)) {
+#ifdef DOLBY_USE_ARMDEC
+ adec_print("DOLBY_USE_ARMDEC=%d", DOLBY_USE_ARMDEC);
+#ifndef USE_ARM_AUDIO_DEC
+ if (access("/system/etc/firmware/audiodsp_codec_ddp_dcv.bin",0 /*F_OK*/)) {
+#endif
+ audio_decoder = AUDIO_ARM_DECODER;
+#ifndef USE_ARM_AUDIO_DEC
+ }else{
+ audio_decoder = AUDIO_ARC_DECODER;
+ }
+#endif
+#else
+ audio_decoder = AUDIO_ARC_DECODER;
+ adec_print("<DOLBY_USE_ARMDEC> is not DEFINED,use ARC_Decoder\n!");
+#endif
+ }
+#ifndef USE_ARM_AUDIO_DEC
+ else if (match_types(t->type, "dts")) {
+ if (access("/system/etc/firmware/audiodsp_codec_dtshd.bin", 0/*F_OK*/)) {
+ adec_print("using no license dts component");
+ audio_decoder = AUDIO_ARM_DECODER;
+ } else {
+ adec_print("using audiodsp dts decoder");
+ audio_decoder = AUDIO_ARC_DECODER;
+ }
+ }
+#endif
+ else {
+ audio_decoder = AUDIO_ARM_DECODER;
+ }
+ goto exit;
+ }
+
+ ret = property_get("media.arc.audio.decoder", value, NULL);
+ adec_print("media.amplayer.audiocodec = %s, t->type = %s\n", value, t->type);
+ if (ret > 0 && match_types(t->type, value)) {
+ if (audec->dspdec_not_supported == 0) {
+ audio_decoder = AUDIO_ARC_DECODER;
+ } else {
+ audio_decoder = AUDIO_ARM_DECODER;
+ adec_print("[%s:%d]arc decoder not support this audio yet,switch to ARM decoder \n", __FUNCTION__, __LINE__);
+ }
+ goto exit;
+ }
+
+ ret = property_get("media.ffmpeg.audio.decoder", value, NULL);
+ adec_print("media.amplayer.audiocodec = %s, t->type = %s\n", value, t->type);
+ if (ret > 0 && match_types(t->type, value)) {
+ audio_decoder = AUDIO_FFMPEG_DECODER;
+ goto exit;
+ }
+
+ audio_decoder = AUDIO_ARC_DECODER; //set arc decoder as default
+ if (audec->dspdec_not_supported == 1) {
+ audio_decoder = AUDIO_ARM_DECODER;
+ adec_print("[%s:%d]arc decoder not support this audio yet,switch to ARM decoder \n", __FUNCTION__, __LINE__);
+ }
+exit:
+ if (am_getconfig_bool("media.libplayer.wfd") && (audio_id == ACODEC_FMT_WIFIDISPLAY || audio_id == ACODEC_FMT_AAC)) {
+ adec_print("wfd use arm decoder \n");
+ audio_decoder = AUDIO_ARMWFD_DECODER;
+ }
+ return 0;
+}
+
+int get_audio_decoder(void)
+{
+ //adec_print("audio_decoder = %d\n", audio_decoder);
+ return audio_decoder;
+}
+
+int vdec_pts_pause(void)
+{
+ return amsysfs_set_sysfs_str(TSYNC_EVENT, "VIDEO_PAUSE:0x1");
+}
+
+int adec_thread_wait(aml_audio_dec_t *audec, int microseconds)
+{
+ struct timespec pthread_ts;
+ struct timeval now;
+ adec_thread_mgt_t *mgt = &audec->thread_mgt;
+ int ret;
+
+ gettimeofday(&now, NULL);
+ pthread_ts.tv_sec = now.tv_sec + (microseconds + now.tv_usec) / 1000000;
+ pthread_ts.tv_nsec = ((microseconds + now.tv_usec) * 1000) % 1000000000;
+ pthread_mutex_lock(&mgt->pthread_mutex);
+ ret = pthread_cond_timedwait(&mgt->pthread_cond, &mgt->pthread_mutex, &pthread_ts);
+ pthread_mutex_unlock(&mgt->pthread_mutex);
+ return ret;
+}
+int adec_thread_wakeup(aml_audio_dec_t *audec)
+{
+ adec_thread_mgt_t *mgt = &audec->thread_mgt;
+ int ret;
+
+ pthread_mutex_lock(&mgt->pthread_mutex);
+ ret = pthread_cond_signal(&mgt->pthread_cond);
+ pthread_mutex_unlock(&mgt->pthread_mutex);
+
+ return ret;
+}
+
+int audiodec_init(aml_audio_dec_t *audec)
+{
+ int ret = 0;
+ pthread_t tid;
+ char value[PROPERTY_VALUE_MAX] = {0};
+ unsigned wfd = 0;
+ adec_print("audiodec_init!");
+ adec_message_pool_init(audec);
+ get_output_func(audec);
+ int nCodecType = audec->format;
+ set_audio_decoder(audec);
+ audec->format_changed_flag = 0;
+ audec->audio_decoder_enabled = -1;//default set a invalid value
+ audec->mix_lr_channel_enable = -1;
+ audec->pre_gain_enable = -1;
+ audec->pre_gain = 1.0;
+ audec->pre_mute = 0;
+ audec->VersionNum = -1;
+ audec->refresh_pts_readytime_ms = 0;
+ if (am_getconfig_bool("media.libplayer.wfd")) {
+ wfd = 1;
+ }
+ if (get_audio_decoder() == AUDIO_ARC_DECODER) {
+ audec->adsp_ops.dsp_file_fd = -1;
+ ret = amthreadpool_pthread_create(&tid, NULL, (void *)adec_message_loop, (void *)audec);
+ pthread_setname_np(tid, "AmadecMsgloop");
+ } else if (wfd && (nCodecType == ACODEC_FMT_AAC || nCodecType == ACODEC_FMT_WIFIDISPLAY)) {
+ adec_print("using wfd audio decoder \n");
+ ret = amthreadpool_pthread_create(&tid, NULL, (void *)adec_wfddec_msg_loop, (void *)audec);
+ audec->audio_decoder_enabled = 0x1;
+ pthread_setname_np(tid, "AmadecWFDMsgloop");
+ } else {
+ int codec_type = get_audio_decoder();
+ RegisterDecode(audec, codec_type);
+ ret = amthreadpool_pthread_create(&tid, NULL, (void *)adec_armdec_loop, (void *)audec);
+ pthread_mutex_init(&audec->thread_mgt.pthread_mutex, NULL);
+ pthread_cond_init(&audec->thread_mgt.pthread_cond, NULL);
+ audec->thread_mgt.pthread_id = tid;
+ pthread_setname_np(tid, "AmadecArmdecLP");
+ }
+ if (ret != 0) {
+ adec_print("Create adec main thread failed!\n");
+ return ret;
+ }
+ adec_print("Create adec main thread success! tid = %d\n", tid);
+ audec->thread_pid = tid;
+ return ret;
+}
diff --git a/amadec/adec-message.c b/amadec/adec-message.c
new file mode 100644
index 0000000..004adf0
--- a/dev/null
+++ b/amadec/adec-message.c
@@ -0,0 +1,156 @@
+/**
+ * \file adec-message.c
+ * \brief Audio Dec Message Handlers
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <audio-dec.h>
+#include <amthreadpool.h>
+
+/**
+ * \brief message is empty or not
+ * \param pool pointer to message pool
+ * \return TREU when empty, otherwise FALSE
+ */
+adec_bool_t message_pool_empty(aml_audio_dec_t *audec)
+{
+ message_pool_t *pool = &audec->message_pool;
+
+ if (pool->message_num == 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+/**
+ * \brief init the adec message pool
+ * \param audec pointer to audec
+ * \return 0 on success
+ */
+int adec_message_pool_init(aml_audio_dec_t *audec)
+{
+ message_pool_t *pool;
+
+ pool = &audec->message_pool;
+ pool->message_in_index = 0;
+ pool->message_out_index = 0;
+ pool->message_num = 0;
+ memset(pool->message_lise, 0, sizeof(pool->message_lise));
+ pthread_mutex_init(&pool->msg_mutex, NULL);
+
+ return 0;
+}
+
+/**
+ * \brief alloc new message
+ * \return pointer to the new message
+ */
+adec_cmd_t *adec_message_alloc(void)
+{
+ adec_cmd_t *cmd;
+
+ cmd = (adec_cmd_t *)malloc(sizeof(adec_cmd_t));
+ if (cmd) {
+ memset(cmd, 0, sizeof(adec_cmd_t));
+ }
+
+ return cmd;
+}
+
+/**
+ * \brief free the message
+ * \param cmd pointer to message
+ * \return 0 on success
+ */
+int adec_message_free(adec_cmd_t *cmd)
+{
+ if (cmd) {
+ free(cmd);
+ }
+
+ cmd = NULL;
+
+ return 0;
+}
+
+/**
+ * \brief send a message
+ * \param audec pointer to audec
+ * \param cmd pointer to message
+ * \return 0 on success otherwise -1
+ */
+int adec_send_message(aml_audio_dec_t *audec, adec_cmd_t *cmd)
+{
+
+ int ret = -1;
+ message_pool_t *pool;
+
+ pool = &audec->message_pool;
+
+ int retry_count = 0;
+ adec_thread_wakeup(audec);
+ while (pool->message_num > MESSAGE_NUM_MAX / 2) {
+ usleep(1000 * 10);
+ if (retry_count++ > (pool->message_num - MESSAGE_NUM_MAX / 2) * 10) {
+ break;
+ }
+ }
+
+ pthread_mutex_lock(&pool->msg_mutex);
+ if (pool->message_num < MESSAGE_NUM_MAX) {
+ pool->message_lise[pool->message_in_index] = cmd;
+ pool->message_in_index = (pool->message_in_index + 1) % MESSAGE_NUM_MAX;
+ pool->message_num += 1;
+ ret = 0;
+ } else {
+ /* message pool is full */
+ adec_print("message pool is full! delete the oldest message!");
+ adec_cmd_t *oldestcmd;
+ oldestcmd = pool->message_lise[pool->message_in_index];
+ free(oldestcmd);
+ pool->message_out_index = (pool->message_out_index + 1) % MESSAGE_NUM_MAX;
+ pool->message_lise[pool->message_in_index] = cmd;
+ pool->message_in_index = (pool->message_in_index + 1) % MESSAGE_NUM_MAX;
+ ret = 0;
+ }
+ amthreadpool_thread_wake(audec->thread_pid);
+ pthread_mutex_unlock(&pool->msg_mutex);
+
+ return ret;
+}
+
+/**
+ * \brief get a message
+ * \param audec pointer to audec
+ * \return pointer to message otherwise NULL if an error occurred
+ */
+adec_cmd_t *adec_get_message(aml_audio_dec_t *audec)
+{
+
+ message_pool_t *pool;
+ adec_cmd_t *cmd = NULL;
+
+ pool = &audec->message_pool;
+ if (!pool) {
+ adec_print("message pool is null! get message failed!");
+ return NULL;
+ }
+
+ pthread_mutex_lock(&pool->msg_mutex);
+ if (pool->message_num > 0) {
+ cmd = pool->message_lise[pool->message_out_index];
+ pool->message_out_index = (pool->message_out_index + 1) % MESSAGE_NUM_MAX;
+ pool->message_num -= 1;
+ }
+ pthread_mutex_unlock(&pool->msg_mutex);
+
+ return cmd;
+}
diff --git a/amadec/adec-message.h b/amadec/adec-message.h
new file mode 100644
index 0000000..575ba50
--- a/dev/null
+++ b/amadec/adec-message.h
@@ -0,0 +1,61 @@
+/**
+ * \file adec-message.h
+ * \brief Definitiond Of Audio Dec Types And Structures
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#ifndef ADEC_MESSAGE_H
+#define ADEC_MESSAGE_H
+
+#include <pthread.h>
+
+ADEC_BEGIN_DECLS
+
+#define MESSAGE_NUM_MAX 12
+
+typedef enum {
+ CMD_START = 1 << 0,
+ CMD_PAUSE = 1 << 1,
+ CMD_RESUME = 1 << 2,
+ CMD_STOP = 1 << 3,
+ CMD_MUTE = 1 << 4,
+ CMD_SET_VOL = 1 << 5,
+ CMD_GET_VOL = 1 << 6,
+ CMD_CHANL_SWAP = 1 << 7,
+ CMD_LEFT_MONO = 1 << 8,
+ CMD_RIGHT_MONO = 1 << 9,
+ CMD_STEREO = 1 << 10,
+ CMD_SET_LRVOL = 1 << 20,
+ CMD_RELEASE = 1 << 31,
+} ctrl_cmd_t;
+
+
+typedef struct {
+ int type; /* 1 = reply; 0 = no reply */
+ int has_arg; /* 1 = value is valid; 0 = value is unvalid */
+ ctrl_cmd_t ctrl_cmd;
+ union {
+ int en;
+ float volume;
+ } value;
+ union {
+ int en;
+ float volume;
+ } value_ext;
+} adec_cmd_t;
+
+typedef struct {
+ adec_cmd_t * message_lise[MESSAGE_NUM_MAX + 1];
+ int message_in_index;
+ int message_out_index;
+ int message_num;
+ pthread_mutex_t msg_mutex;
+} message_pool_t;
+
+ADEC_END_DECLS
+
+#endif
diff --git a/amadec/adec-pts-mgt.c b/amadec/adec-pts-mgt.c
new file mode 100755
index 0000000..fd627f7
--- a/dev/null
+++ b/amadec/adec-pts-mgt.c
@@ -0,0 +1,1107 @@
+/**
+ * \file adec-pts-mgt.c
+ * \brief Functions Of Pts Manage.
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <adec-pts-mgt.h>
+#include <cutils/properties.h>
+#include <sys/time.h>
+#include <amthreadpool.h>
+#include <sys/ioctl.h>
+
+#include "Amsysfsutils.h"
+#include "amconfigutils.h"
+
+#define DROP_PCM_DURATION_THRESHHOLD 4 //unit:s
+#define DROP_PCM_MAX_TIME 1000 // unit :ms
+#define DROP_PCM_PTS_DIFF_THRESHHOLD 90000*10
+#define DROP_PCM_RESET_PCR_THRESHOLD 90000/2
+
+int adec_pts_droppcm(aml_audio_dec_t *audec);
+int vdec_pts_resume(void);
+static int vdec_pts_pause(void);
+int droppcm_use_size(aml_audio_dec_t *audec, int drop_size);
+void droppcm_prop_ctrl(int *audio_ahead, int *pts_ahead_val);
+int droppcm_get_refpts(aml_audio_dec_t *audec, unsigned long *refpts);
+
+extern int match_types(const char *filetypestr, const char *typesetting);
+
+static int64_t gettime(void)
+{
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
+}
+
+int sysfs_get_int(char *path, unsigned long *val)
+{
+ char buf[64];
+
+ if (amsysfs_get_sysfs_str(path, buf, sizeof(buf)) == -1) {
+ adec_print("unable to open file %s,err: %s", path, strerror(errno));
+ return -1;
+ }
+ if (sscanf(buf, "0x%lx", val) < 1) {
+ adec_print("unable to get pts from: %s", buf);
+ return -1;
+ }
+
+ return 0;
+}
+/*
+get vpts when refresh apts, do not use sys write servie as it is too slow sometimes.
+*/
+static int mysysfs_get_sysfs_int16(const char *path)
+{
+ int fd;
+ char valstr[64];
+ int val;
+ fd = open(path, O_RDONLY);
+ if (fd >= 0) {
+ memset(valstr, 0, 64);
+ read(fd, valstr, 64 - 1);
+ valstr[strlen(valstr)] = '\0';
+ close(fd);
+ } else {
+ adec_print("unable to open file %s\n", path);
+ return -1;
+ }
+ if (sscanf(valstr, "0x%x", &val) < 1) {
+ adec_print("unable to get pts from: %s", valstr);
+ return -1;
+ }
+ return val;
+}
+
+static int mysysfs_get_sysfs_int(const char *path)
+{
+ int fd;
+ int val = 0;
+ char bcmd[16];
+ fd = open(path, O_RDONLY);
+ if (fd >= 0) {
+ read(fd, bcmd, sizeof(bcmd));
+ val = strtol(bcmd, NULL, 10);
+ close(fd);
+ } else {
+ adec_print("unable to open file %s,err: %s", path, strerror(errno));
+ }
+ return val;
+}
+
+static int set_tsync_enable(int enable)
+{
+ char *path = "/sys/class/tsync/enable";
+ return amsysfs_set_sysfs_int(path, enable);
+}
+/**
+ * \brief calc current pts
+ * \param audec pointer to audec
+ * \return aurrent audio pts
+ */
+unsigned long adec_calc_pts(aml_audio_dec_t *audec)
+{
+ unsigned long pts, delay_pts;
+ audio_out_operations_t *out_ops;
+ dsp_operations_t *dsp_ops;
+
+ out_ops = &audec->aout_ops;
+ dsp_ops = &audec->adsp_ops;
+
+ pts = dsp_ops->get_cur_pts(dsp_ops);
+ if (pts == -1) {
+ adec_print("get get_cur_pts failed\n");
+ return -1;
+ }
+ dsp_ops->kernel_audio_pts = pts;
+
+ if (out_ops == NULL || out_ops->latency == NULL) {
+ adec_print("cur_out is NULL!\n ");
+ return -1;
+ }
+ delay_pts = out_ops->latency(audec) * 90;
+
+ if (!audec->apts_start_flag) {
+ return pts;
+ }
+
+ int diff = abs(delay_pts - pts);
+ // in some case, audio latency got from audiotrack is bigger than pts<hw not enabled>, so when delay_pts-pts < 100ms ,so set apts to 0.
+ //because 100ms pcr-apts diff cause apts reset .
+ if (delay_pts/*+audec->first_apts*/ < pts) {
+ pts -= delay_pts;
+ } else if (diff < 9000) {
+ pts = 0;
+ }
+ return pts;
+}
+
+/**
+ * \brief start pts manager
+ * \param audec pointer to audec
+ * \return 0 on success otherwise -1
+ */
+int adec_pts_start(aml_audio_dec_t *audec)
+{
+ unsigned long pts = 0;
+ char *file;
+ char buf[64];
+ dsp_operations_t *dsp_ops;
+ char value[PROPERTY_VALUE_MAX] = {0};
+ int tsync_mode;
+ unsigned long first_apts = 0;
+
+ adec_print("adec_pts_start");
+ dsp_ops = &audec->adsp_ops;
+ memset(buf, 0, sizeof(buf));
+
+ if (audec->avsync_threshold <= 0) {
+ if (am_getconfig_bool("media.libplayer.wfd")) {
+ audec->avsync_threshold = SYSTIME_CORRECTION_THRESHOLD * 2 / 3;
+ adec_print("use 2/3 default av sync threshold!\n");
+ } else {
+ audec->avsync_threshold = SYSTIME_CORRECTION_THRESHOLD;
+ adec_print("use default av sync threshold!\n");
+ }
+ }
+
+ first_apts = adec_calc_pts(audec);
+ if (sysfs_get_int(TSYNC_FIRSTAPTS, &audec->first_apts) == -1) {
+ adec_print("## [%s::%d] unable to get first_apts! \n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+
+ adec_print("av sync threshold is %d , no_first_apts=%d,first_apts = 0x%x, audec->first_apts = 0x%x \n", audec->avsync_threshold, audec->no_first_apts, first_apts, audec->first_apts);
+
+
+ dsp_ops->last_pts_valid = 0;
+
+ //default enable drop pcm
+ int enable_drop_pcm = 1;
+ if (property_get("sys.amplayer.drop_pcm", value, NULL) > 0) {
+ enable_drop_pcm = atoi(value);
+ }
+ adec_print("[%s:%d] enable_drop_pcm :%d \n", __FUNCTION__, __LINE__, enable_drop_pcm);
+ if (enable_drop_pcm) {
+ char *path = "/sys/class/tsync/enable";
+ char buf[32] = "";
+
+ if (amsysfs_get_sysfs_str(path, buf, 32) >= 0) {
+ if (!strncmp(buf, "1: enabled", 10)) {
+ adec_pts_droppcm(audec);
+ }
+ } else {
+ adec_print("## [%s::%d] unable to get tsync enable status! \n", __FUNCTION__, __LINE__);
+ }
+ }
+
+ // before audio start or pts start
+ if (amsysfs_set_sysfs_str(TSYNC_EVENT, "AUDIO_PRE_START") == -1) {
+ return -1;
+ }
+
+ amthreadpool_thread_usleep(1000);
+
+ if (audec->no_first_apts) {
+ if (amsysfs_get_sysfs_str(TSYNC_APTS, buf, sizeof(buf)) == -1) {
+ adec_print("unable to open file %s,err: %s", TSYNC_APTS, strerror(errno));
+ return -1;
+ }
+
+ if (sscanf(buf, "0x%lx", &pts) < 1) {
+ adec_print("unable to get vpts from: %s", buf);
+ return -1;
+ }
+
+ } else {
+ pts = adec_calc_pts(audec);
+
+ if (pts == -1) {
+
+ adec_print("pts==-1");
+
+ if (amsysfs_get_sysfs_str(TSYNC_APTS, buf, sizeof(buf)) == -1) {
+ adec_print("unable to open file %s,err: %s", TSYNC_APTS, strerror(errno));
+ return -1;
+ }
+
+ if (sscanf(buf, "0x%lx", &pts) < 1) {
+ adec_print("unable to get apts from: %s", buf);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+static void enable_slowsync_repeate()
+{
+ const char * slowsync_path = "/sys/class/tsync/slowsync_enable";
+ const char * slowsync_repeate_path = "/sys/class/video/slowsync_repeat_enable";
+ //amsysfs_set_sysfs_int(slowsync_path, 1);
+ amsysfs_set_sysfs_int(slowsync_repeate_path, 1);
+ adec_print("enable slowsync repeate. \n");
+}
+
+int adec_pts_droppcm(aml_audio_dec_t *audec)
+{
+ unsigned long refpts, apts, oldapts;
+ int ret, drop_size, droppts, dropms;
+ char value[PROPERTY_VALUE_MAX] = {0};
+ int64_t starttime, endtime;
+ int audio_ahead = 0;
+ unsigned pts_ahead_val = SYSTIME_CORRECTION_THRESHOLD;
+ int diff;
+ int sync_switch_ms = 200; // ms
+ int count = 0;
+
+ unsigned long cur_pcr;
+ struct am_io_param am_io;
+
+ starttime = gettime();
+
+ int samplerate = 0;
+ int channels = 0;
+ //ARM based decoder,should got from decoder
+ adec_print("adec_pts_droppcm start get audio sr/ch info \n");
+ while (!audec->need_stop) {
+ if (audec->g_bst) {
+ samplerate = audec->g_bst->samplerate;
+ channels = audec->g_bst->channels;
+ }
+ //DSP decoder must have got audio info when feeder_init
+ else {
+ samplerate = audec->samplerate;
+ channels = audec->channels;
+ }
+ if (!samplerate || !channels) {
+ amthreadpool_thread_usleep(10000);
+ continue;
+ }
+ break;
+ }
+ adec_print("adec_pts_droppcm get audio sr/ch info done sr %d, ch %d \n", samplerate, channels);
+
+ // drop pcm according to media.amplayer.dropms
+ memset(value, 0, sizeof(value));
+ if (property_get("media.amplayer.dropms", value, NULL) > 0) {
+ dropms = atoi(value);
+ audec->droppcm_ms = dropms;
+ drop_size = dropms * (audec->samplerate / 1000) * audec->channels * 2;
+ if (drop_size > 0) {
+ if (droppcm_use_size(audec, drop_size) == -1) {
+ adec_print("[%s::%d] data not enough, drop failed! \n", __FUNCTION__, __LINE__);
+ }
+
+ if (am_getconfig_bool("media.amplayer.dropmsquit")) {
+ adec_print("[%s::%d] fast droppcm: %d ms! \n", __FUNCTION__, __LINE__, dropms);
+ return 0;
+ }
+ }
+ }
+
+ // pre drop, according to first check in vpts
+
+ adec_print("[%s::%d] start pre drop ! \n", __FUNCTION__, __LINE__);
+ if (am_getconfig_bool("media.amplayer.pre_droppcm")) {
+ unsigned long checkin_firstvpts = 0;
+ while (!checkin_firstvpts) {
+ if (audec->need_stop) {
+ return 0;
+ }
+ if (sysfs_get_int(TSYNC_CHECKIN_FIRSTVPTS, &checkin_firstvpts) == -1) {
+ adec_print("## [%s::%d] unable to get TSYNC_CHECKIN_FIRSTVPTS! \n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ if (count >= 50) {
+ adec_print("Unable to get checkin_firstvpts, failed to pre_droppcm\n");
+ break;
+ } else if (checkin_firstvpts) {
+ adec_print("get checkin_firstvpts, checkin_firstvpts=0x%x\n",checkin_firstvpts);
+ break;
+ }
+ count++;
+ amthreadpool_thread_usleep(20000); // 20ms
+ }
+ if (checkin_firstvpts) {
+ apts = adec_calc_pts(audec);
+ diff = (apts > checkin_firstvpts) ? (apts - checkin_firstvpts) : (checkin_firstvpts - apts);
+ adec_print("before drop pre --apts 0x%x,checkin_firstvpts 0x%x,apts %s, diff 0x%x\n", apts, checkin_firstvpts, (apts > checkin_firstvpts) ? "big" : "small", diff);
+ if ((apts < checkin_firstvpts) && (diff < DROP_PCM_PTS_DIFF_THRESHHOLD)) {
+ droppts = checkin_firstvpts - apts;
+ audec->droppcm_ms = droppts / 90;
+ drop_size = (droppts / 90) * (audec->samplerate / 1000) * audec->channels * 2;
+ adec_print("[%s::%d]pre audec->samplerated = %d, audec->channels = %d! \n", __FUNCTION__, __LINE__, audec->samplerate, audec->channels);
+ adec_print("[%s::%d]pre droppts:0x%x, drop_size=%d, audio ahead %d,ahead pts value %d \n", __FUNCTION__, __LINE__,
+ droppts, drop_size, audio_ahead, pts_ahead_val);
+ if (droppcm_use_size(audec, drop_size) == -1) {
+ adec_print("[%s::%d] timeout! data not enough! \n", __FUNCTION__, __LINE__);
+ }
+ oldapts = apts;
+ apts = adec_calc_pts(audec);
+ diff = (apts > checkin_firstvpts) ? (apts - checkin_firstvpts) : (checkin_firstvpts - apts);
+ adec_print("after drop pre:--apts 0x%x,droped:0x%x, checkin_firstvpts 0x%x,apts %s, diff 0x%x\n", apts, apts - oldapts, checkin_firstvpts, (apts > checkin_firstvpts) ? "big" : "small", diff);
+ }
+ }
+ }
+
+ if (droppcm_get_refpts(audec, &refpts) == -1) {
+ adec_print("[%s::%d] get refpts failed! \n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+
+ while (!audec->first_apts) {
+ unsigned long first_apts = 0;
+
+ if (audec->need_stop) {
+ return 0;
+ }
+
+ if (count > 10) {
+ break;
+ }
+
+ first_apts = adec_calc_pts(audec);
+
+ if (sysfs_get_int(TSYNC_FIRSTAPTS, &audec->first_apts) == -1) {
+ adec_print("## [%s::%d] unable to get first_apts! \n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ count++;
+ amthreadpool_thread_usleep(50000); // 50ms
+ adec_print("wait audec->first_apts first_apts = 0x%x, audec->first_apts = 0x%x\n", first_apts, audec->first_apts);
+ }
+ diff = (audec->first_apts > refpts) ? (audec->first_apts - refpts) : (refpts - audec->first_apts);
+ adec_print("before drop --audec->first_apts 0x%x,refpts 0x%x,audec->first_apts %s, diff 0x%x\n", audec->first_apts, refpts, (audec->first_apts > refpts) ? "big" : "small", diff);
+ {
+ sysfs_get_int(TSYNC_PCRSCR, &cur_pcr);
+ ioctl(audec->adsp_ops.amstream_fd, AMSTREAM_IOC_AB_STATUS, (unsigned long)&am_io);
+ adec_print("before drop ab_level=%x, cur_pcr=%x", am_io.status.data_len, cur_pcr);
+ }
+ if (property_get("media.amplayer.sync_switch_ms", value, NULL) > 0) {
+ sync_switch_ms = atoi(value);
+ }
+
+ if (am_getconfig_bool("media.libplayer.show_firstframe") &&
+ audec->tsync_mode == TSYNC_MODE_PCRMASTER) {
+ const char * show_first_frame = "/sys/class/video/show_first_frame_nosync";
+ amsysfs_set_sysfs_int(show_first_frame, 1);
+ sync_switch_ms = 10000;//10s
+ }
+ adec_print("sync switch setting: %d ms \n", sync_switch_ms);
+ //auto switch -- if diff not too much, using slow sync
+ if (audec->first_apts >= refpts || diff / 90 < sync_switch_ms) {
+ //enable_slowsync_repeate();
+ adec_print("diff less than %d (ms), use slowsync repeate mode \n", sync_switch_ms);
+ return 0;
+ }
+ //when start to play,may audio discontinue happens, in this case, don't drop pcm operation
+#if 1
+ else if (diff > DROP_PCM_PTS_DIFF_THRESHHOLD) {
+ adec_print("pts diff 0x%x bigger than %d (ms), don't drop pcm \n", diff, DROP_PCM_PTS_DIFF_THRESHHOLD * 1000 / 90000);
+ return 0;
+ }
+#endif
+ // calculate ahead pcm size
+ droppcm_prop_ctrl(&audio_ahead, &pts_ahead_val);
+
+ // drop pcm
+ droppts = refpts - audec->first_apts + pts_ahead_val * audio_ahead;
+ audec->droppcm_ms = droppts / 90;
+ drop_size = (droppts / 90) * (audec->samplerate / 1000) * audec->channels * 2;
+ adec_print("[%s::%d] audec->samplerated = %d, audec->channels = %d! \n", __FUNCTION__, __LINE__, audec->samplerate, audec->channels);
+ adec_print("[%s::%d] droppts:0x%x, drop_size=%d, audio ahead %d,ahead pts value %d \n", __FUNCTION__, __LINE__,
+ droppts, drop_size, audio_ahead, pts_ahead_val);
+ if (droppcm_use_size(audec, drop_size) == -1) {
+ adec_print("[%s::%d] timeout! data not enough! \n", __FUNCTION__, __LINE__);
+ }
+
+ // show apts refpts after droppcm
+ if (sysfs_get_int(TSYNC_VPTS, &refpts) == -1) {
+ adec_print("## [%s::%d] unable to get vpts! \n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+
+ oldapts = audec->first_apts;
+ apts = adec_calc_pts(audec);
+ diff = (apts > refpts) ? (apts - refpts) : (refpts - apts);
+ adec_print("after drop:--apts 0x%x,droped:0x%x, vpts 0x%x,apts %s, diff 0x%x\n", apts, apts - oldapts, refpts, (apts > refpts) ? "big" : "small", diff);
+ if (diff > DROP_PCM_RESET_PCR_THRESHOLD){
+ char buf[64];
+ sprintf(buf, "0x%lx", apts);
+ adec_print("## [%s::%d] reset pcr =0x%x \n", __FUNCTION__, __LINE__);
+ if (amsysfs_set_sysfs_str(TSYNC_PCRSCR, buf)){
+ adec_print("## [%s::%d] reset pcr error \n", __FUNCTION__, __LINE__);
+ }
+ }
+
+ {
+ sysfs_get_int(TSYNC_PCRSCR, &cur_pcr);
+ ioctl(audec->adsp_ops.amstream_fd, AMSTREAM_IOC_AB_STATUS, (unsigned long)&am_io);
+ adec_print("after drop ab_level=%x, cur_pcr=%x", am_io.status.data_len, cur_pcr);
+ }
+
+ endtime = gettime();
+ adec_print("==starttime is :%lld ms endtime is:%lld ms usetime:%lld ms \n", starttime / 1000 , endtime / 1000 , (endtime - starttime) / 1000);
+
+ return 0;
+}
+
+/**
+ * \brief pause pts manager
+ * \return 0 on success otherwise -1
+ */
+int adec_pts_pause(void)
+{
+ adec_print("adec_pts_pause");
+ return amsysfs_set_sysfs_str(TSYNC_EVENT, "AUDIO_PAUSE");
+}
+
+/**
+ * \brief resume pts manager
+ * \return 0 on success otherwise -1
+ */
+int adec_pts_resume(void)
+{
+ adec_print("adec_pts_resume");
+ return amsysfs_set_sysfs_str(TSYNC_EVENT, "AUDIO_RESUME");
+
+}
+
+/**
+ * \brief refresh current audio pts
+ * \param audec pointer to audec
+ * \return 0 on success otherwise -1
+ */
+static int apts_interrupt = 0;
+static int pcrmaster_droppcm_flag = 0;
+static int pre_filltime = -1;
+int adec_refresh_pts(aml_audio_dec_t *audec)
+{
+ unsigned long pts;
+ unsigned long systime;
+ unsigned long last_pts = audec->adsp_ops.last_audio_pts;
+ unsigned long last_kernel_pts = audec->adsp_ops.kernel_audio_pts;
+ int apts_start_flag = 0;//store the last flag
+ int samplerate = 48000;
+ int channels = 2;
+ char buf[64];
+ char ret_val = -1;
+ if (audec->auto_mute == 1) {
+ return 0;
+ }
+ if (pre_filltime == -1) {
+ char value[PROPERTY_VALUE_MAX] = {0};
+ if (property_get("media.amadec.prefilltime", value, NULL) > 0) {
+ pre_filltime = atoi(value);
+ } else {
+ pre_filltime = 170;
+ }
+ adec_print("[%s:%d] amadec- pre_filltime:%d ms. \n", __FUNCTION__, __LINE__, pre_filltime);
+ }
+
+ apts_start_flag = audec->apts_start_flag;
+ //if the audio start has not been triggered to tsync,calculate the audio pcm data which writen to audiotrack
+ if (!audec->apts_start_flag) {
+ int latency;
+ int wait = pre_filltime;
+ if (audec->g_bst) {
+ samplerate = audec->g_bst->samplerate;
+ channels = audec->g_bst->channels;
+ }
+ //DSP decoder must have got audio info when feeder_init
+ else {
+ samplerate = audec->samplerate;
+ channels = audec->channels;
+ }
+ // 170 ms audio hal have triggered the output hw.
+ latency = audec->aout_ops.latency(audec);
+ if (latency > 0 && ((audec->pcm_bytes_readed * 1000 / (samplerate * channels * 2)) >= wait)) {
+ adec_print("unable to getsystime--\n\n [[[%lld,%d,%d,%d,%d]]]\n",
+ audec->pcm_bytes_readed
+ ,samplerate
+ ,channels
+ ,wait,
+ latency);
+ audec->apts_start_flag = 1;
+ if (!am_getconfig_bool("libplayer.slowsync.disable"))
+ enable_slowsync_repeate();
+ }
+ }
+ memset(buf, 0, sizeof(buf));
+
+ systime = audec->adsp_ops.get_cur_pcrscr(&audec->adsp_ops);
+ if (systime == -1) {
+ adec_print("unable to getsystime");
+ audec->pcrscr64 = 0;
+ return -1;
+ }
+
+ /* get audio time stamp */
+ pts = adec_calc_pts(audec);
+ if (pts != -1 && (apts_start_flag != audec->apts_start_flag)) {
+ adec_print("audio pts start from 0x%lx", pts);
+ sprintf(buf, "AUDIO_START:0x%lx", pts);
+ if (amsysfs_set_sysfs_str(TSYNC_EVENT, buf) == -1) {
+ return -1;
+ }
+ }
+ if (pts == -1 || last_pts == pts) {
+ //close(fd);
+ //if (pts == -1) {
+ audec->pcrscr64 = (int64_t)systime;
+ return -1;
+ //}
+ }
+#if 1
+ unsigned int u32_vpts = mysysfs_get_sysfs_int16(TSYNC_VPTS);
+ unsigned int last_checkin_apts = mysysfs_get_sysfs_int16(TSYNC_LAST_CHECKIN_APTS);
+ //int play_mode = mysysfs_get_sysfs_int(TSYNC_PCR_PLAY_MODE);
+
+ if (audec->tsync_mode == TSYNC_MODE_PCRMASTER && audec->pcrtsync_enable
+ && ((((int64_t)pts) - audec->last_apts64 > TIME_UNIT90K / 10) || ((int64_t)pts < audec->last_apts64))) {
+
+ int64_t apts64 = (int64_t)pts;
+ int64_t pcrscr64 = (int64_t)systime;
+ audec->apts64 = apts64;
+ audec->pcrscr64 = pcrscr64;
+
+ if (audec->adis_flag && abs(audec->pcrscr64 - audec->last_apts64) > APTS_DISCONTINUE_THRESHOLD) {
+ audec->adis_flag = 0;
+ adec_print("[%s:%d] pcr discontinue: last_pcr:%llx, pcr:%llx, --\n", __FUNCTION__, __LINE__, audec->last_pcrscr64, audec->pcrscr64);
+ }
+ audec->last_pcrscr64 = pcrscr64;
+ if (apts64 < audec->last_apts64) {
+ audec->last_apts64 = apts64;
+ }
+
+ unsigned int adiff = (unsigned int)((int64_t)last_checkin_apts - apts64);
+ adec_print("## tsync_mode:%d, pcr:%llx,apts:%llx, u32_vpts = 0x%x,lastapts:%llx, flag:%d,%d,---\n",
+ audec->tsync_mode, pcrscr64, apts64, u32_vpts, audec->last_apts64, pcrmaster_droppcm_flag, audec->adis_flag);
+ //adec_print("## tsync_mode:%d,apts:%llx,last_checkin_apts=0x%x,diff=%ld, play_mode=%d\n",
+ // audec->tsync_mode, apts64, last_checkin_apts, adiff, play_mode);
+ // drop pcm
+ if (pcrscr64 - apts64 > audec->pcrmaster_droppcm_thsh && abs(pcrscr64 - apts64) < 3 * 90000 && abs(u32_vpts - apts64) >= 45000) {
+ if (pcrmaster_droppcm_flag++ > 20) {
+ int drop_size, droppts;
+ droppts = pcrscr64 - apts64;
+ audec->droppcm_ms = droppts / 90;
+ drop_size = (droppts / 90) * (audec->samplerate / 1000) * audec->channels * 2;
+ pcrmaster_droppcm_flag = 0;
+ adec_print("## pcrmaster, droppcm pcr:%lx,apts:%lx,lastapts:%lx,---\n", systime, pts, last_pts);
+
+ if (droppcm_use_size(audec, drop_size) == -1) {
+ adec_print("[%s::%d] timeout! data not enough! \n", __FUNCTION__, __LINE__);
+ }
+ }
+ } else {
+ pcrmaster_droppcm_flag = 0;
+ }
+ }
+#endif
+ if ((abs(pts - last_pts) > APTS_DISCONTINUE_THRESHOLD) && (audec->adsp_ops.last_pts_valid)) {
+ /* report audio time interruption */
+ adec_print("pts = %lx, last pts = %lx, u32_vpts=0x%x, pcr=0x%lx\n", pts, last_pts, u32_vpts, systime);
+
+ adec_print("audio time interrupt: 0x%lx->0x%lx, 0x%lx\n", last_pts, pts, abs(pts - last_pts));
+ int tsync_pcr_discontinue = 0;
+ unsigned int adiff = (unsigned int)((unsigned long)last_checkin_apts - pts);
+ if (audec->tsync_mode == TSYNC_MODE_PCRMASTER) {
+ tsync_pcr_discontinue = mysysfs_get_sysfs_int16(TSYNC_PCR_DISCONTINUE);
+ adec_print("%s,tsync_pcr_discontinue=0x%x-\n",__FUNCTION__,tsync_pcr_discontinue);
+ //adec_print("audio interrupt:%d,apts:%llx,last_checkin_apts=0x%x,diff=%ld, play_mode=%d\n",
+ // audec->tsync_mode, pts, last_checkin_apts, adiff,play_mode);
+
+ }
+ if (audec->tsync_mode == TSYNC_MODE_PCRMASTER && audec->pcrtsync_enable && (tsync_pcr_discontinue & VIDEO_DISCONTINUE)) {
+ unsigned long tsync_pcr_dispoint = 0;
+ int count = 50;
+ audec->apts64 = (int64_t)pts;
+ audec->adis_flag = 0;
+
+ do {
+ if (sysfs_get_int(TSYNC_PCR_DISPOINT, &tsync_pcr_dispoint) == -1) {
+ adec_print("## [%s::%d] unable to get TSYNC_PCR_DISPOINT! \n", __FUNCTION__, __LINE__);
+ audec->adis_flag = 100;
+ break;
+ }
+ amthreadpool_thread_usleep(20000);
+ count--;
+ } while (tsync_pcr_dispoint == 0 && count > 0);
+
+ if (tsync_pcr_dispoint != 0) {
+ int64_t apts64 = (int64_t)pts;
+ int64_t pcrscr64 = (int64_t)tsync_pcr_dispoint;
+ audec->pcrscr64 = (int64_t)pcrscr64;
+ audec->tsync_pcr_dispoint = (int64_t)tsync_pcr_dispoint;
+ audec->adis_flag = 100;
+
+ adec_print("## pcrmaster, tsync_pcr_dispoint,pcr:%lx,apts:%lx,lastapts:%lx,---\n", tsync_pcr_dispoint, pts, last_pts);
+ // drop pcm, if larger than 10s, not to drop pcm
+ if (pcrscr64 - apts64 > APTS_DISCONTINUE_THRESHOLD && pcrscr64 - apts64 < 10 * 90000) {
+ int drop_size, droppts;
+ droppts = pcrscr64 - apts64;
+
+ audec->droppcm_ms = droppts / 90;
+
+ drop_size = (droppts / 90) * (audec->samplerate / 1000) * audec->channels * 2;
+ adec_print("## pcrmaster, droppcm pcr:%lx,apts:%lx,lastapts:%lx,---\n", systime, pts, last_pts);
+
+ if (droppcm_use_size(audec, drop_size) == -1) {
+ adec_print("[%s::%d] timeout! data not enough! \n", __FUNCTION__, __LINE__);
+ }
+ }
+ }
+ }
+
+ sprintf(buf, "AUDIO_TSTAMP_DISCONTINUITY:0x%lx", pts);
+
+ if (amsysfs_set_sysfs_str(TSYNC_EVENT, buf) == -1) {
+ adec_print("unable to open file %s,err: %s", TSYNC_EVENT, strerror(errno));
+ return -1;
+ }
+
+ audec->adsp_ops.last_audio_pts = pts;
+ audec->adsp_ops.last_pts_valid = 1;
+ adec_print("[%s:%d]set automute orig %d!\n", __FUNCTION__, __LINE__, audec->auto_mute);
+ audec->auto_mute = 0;
+ apts_interrupt = 5;
+ return 0;
+ }
+
+ if (last_kernel_pts == audec->adsp_ops.kernel_audio_pts) {
+ audec->pcrscr64 = (int64_t)systime;
+ return 0;
+ }
+
+ audec->adsp_ops.last_audio_pts = pts;
+ audec->adsp_ops.last_pts_valid = 1;
+
+ if (abs(pts - systime) < audec->avsync_threshold) {
+ apts_interrupt = 0;
+ return 0;
+ } else if (apts_interrupt > 0) {
+ apts_interrupt --;
+ return 0;
+ }
+
+ /* report apts-system time difference */
+ if (!apts_start_flag) {
+ return 0;
+ }
+
+ {/*add by zz*/
+ /*
+ reget pts to make sure pts is calc has no errors.
+ because we may have accuracy problem on
+ many thread update the pts related infos.
+ */
+ unsigned long re_getpts = adec_calc_pts(audec);
+ if (abs(pts - re_getpts) > 900) { /*100 ms * 10%*/
+ /*ignore this diff.*/
+ adec_print("## [%s::%d] ixet apts: %d ,%d \n",
+ __FUNCTION__, __LINE__,
+ pts, re_getpts);
+ return 0;
+ } else {
+ /*used new pts.*/
+ pts = re_getpts;
+ }
+ }
+ if (audec->refresh_pts_readytime_ms > 0) {
+ /*pts_readytime not reached ,wait and delay reset apts.*/
+ if (audec->refresh_pts_readytime_ms > gettime()/1000)
+ return 0;
+ audec->refresh_pts_readytime_ms = 0;
+ }
+#if 0
+ if (audec->apts_reset_scr_delay_ms > 0) {
+ unsigned long vpts = 0;
+ if ((vpts = mysysfs_get_sysfs_int16(TSYNC_VPTS)) < 0) {
+ adec_print("## [%s::%d] unable to get vpts! \n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ //adec_print("vpts %x,last apts %x \n,diff %x \n",vpts,audec->last_checkout_apts,abs(vpts-audec->last_discontinue_apts));
+ if ((gettime() - audec->last_discontinue_time) < audec->apts_reset_scr_delay_ms * 1000 && (abs(vpts - audec->last_discontinue_apts) > audec->avsync_threshold)) {
+ return 0;
+ } else {
+ adec_print("after %lld ms,apts reset scr delay time out \n", (gettime() - audec->last_discontinue_time) / 1000);
+ audec->apts_reset_scr_delay_ms = 0;
+ }
+ } else if (abs(pts - last_pts) >= 90000 && abs(pts - last_pts) < APTS_DISCONTINUE_THRESHOLD) {
+ audec->last_discontinue_time = gettime();
+ audec->last_discontinue_apts = pts;
+ audec->apts_reset_scr_delay_ms = audio_get_decoded_pcm_delay(audec)/*+audec->aout_ops.latency(audec)+100*/;
+ adec_print("apts reset time delay %d ms,pts diff 0x%x,timestamp %d ms \n", audec->apts_reset_scr_delay_ms, abs(pts - last_pts),
+ abs(pts - last_pts) / 90);
+ return 0;
+ }
+#endif
+
+ if (audec->adsp_ops.set_cur_apts) {
+ ret_val = audec->adsp_ops.set_cur_apts(&audec->adsp_ops, pts);
+ } else {
+ sprintf(buf, "0x%lx", pts);
+ ret_val = amsysfs_set_sysfs_str(TSYNC_APTS, buf);
+ }
+ if (ret_val == -1) {
+ adec_print("unable to open file %s,err: %s", TSYNC_APTS, strerror(errno));
+ return -1;
+ }
+ if (abs(pts - systime) >= 90000 / 10) {
+ //adec_print("report apts as 0x%x,system pts=0x%x, difference= %ld\n", pts, systime, (pts - systime));
+ }
+ return 0;
+}
+
+/**
+ * \brief Disable or Enable av sync
+ * \param e 1 = enable, 0 = disable
+ * \return 0 on success otherwise -1
+ */
+int avsync_en(int e)
+{
+ return amsysfs_set_sysfs_int(TSYNC_ENABLE, e);
+}
+
+/**
+ * \brief calc pts when switch audio track
+ * \param audec pointer to audec
+ * \return 0 on success otherwise -1
+ *
+ * When audio track switch occurred, use this function to judge audio should
+ * be played or not. If system time fall behind audio pts , and their difference
+ * is greater than SYSTIME_CORRECTION_THRESHOLD, auido should wait for
+ * video. Otherwise audio can be played.
+ */
+int track_switch_pts(aml_audio_dec_t *audec)
+{
+ unsigned long vpts;
+ unsigned long apts;
+ unsigned long pcr;
+ char buf[32];
+
+ memset(buf, 0, sizeof(buf));
+
+ pcr = audec->adsp_ops.get_cur_pcrscr(&audec->adsp_ops);
+ if (pcr == -1) {
+ adec_print("unable to get pcr");
+ return 1;
+ }
+
+ apts = adec_calc_pts(audec);
+ if (apts == -1) {
+ adec_print("unable to get apts");
+ return 1;
+ }
+
+ if ((apts > pcr) && (apts - pcr > 0x100000)) {
+ return 0;
+ }
+
+ if (abs(apts - pcr) < audec->avsync_threshold || (apts <= pcr)) {
+ return 0;
+ } else {
+ return 1;
+ }
+
+}
+static int vdec_pts_pause(void)
+{
+ char *path = "/sys/class/video_pause";
+ return amsysfs_set_sysfs_int(path, 1);
+
+}
+int vdec_pts_resume(void)
+{
+ adec_print("vdec_pts_resume\n");
+ return amsysfs_set_sysfs_str(TSYNC_EVENT, "VIDEO_PAUSE:0x0");
+}
+
+#define DROPPCM_TMPBUF_SIZE (8*1024)
+int droppcm_use_size(aml_audio_dec_t *audec, int drop_size)
+{
+ char value[PROPERTY_VALUE_MAX] = {0};
+ char buffer[DROPPCM_TMPBUF_SIZE];
+ int drop_duration = drop_size / audec->channels / 2 / audec->samplerate;
+ int nDropCount = 0;
+ int size = drop_size;
+ int ret = 0;
+ int drop_max_time = DROP_PCM_MAX_TIME; // unit:ms
+ int64_t start_time, nDropConsumeTime;
+ char platformtype[20];
+ char *buffer_raw = NULL;
+ int drop_raw = 0;
+ int drop_raw_size = 0;
+ int nDropCount_raw = 0;
+ if (audec->codec_type > 0) {
+ buffer_raw = malloc(DROPPCM_TMPBUF_SIZE * audec->codec_type);
+ if (buffer_raw == NULL) {
+ adec_print("[%s %d]WARNING:malloc memory for buffer_raw failed!\n", __FUNCTION__, __LINE__);
+ } else {
+ drop_raw = 1;
+ }
+ }
+ memset(platformtype, 0, sizeof(platformtype));
+ memset(value, 0, sizeof(value));
+ if (property_get("media.amplayer.dropmaxtime", value, NULL) > 0) {
+ drop_max_time = atoi(value);
+ }
+
+ if (audec->droppcm_ms > 50) {
+ drop_max_time = audec->droppcm_ms - 50;
+ }
+ memset(value, 0, sizeof(value));
+ if (property_get("ro.board.platform", value, NULL) > 0) {
+ if (match_types("meson6", value)) {
+ memcpy(platformtype, "meson6", 6);
+ } else if (match_types("meson8", value)) {
+ memcpy(platformtype, "meson8", 6);
+ }
+ }
+
+ start_time = gettime();
+ adec_print("before droppcm: drop_size=%d, nDropCount:%d, drop_max_time:%d,platform:%s, ---\n", drop_size, nDropCount, drop_max_time, platformtype);
+ while (drop_size > 0 && !audec->need_stop/*&& drop_duration < DROP_PCM_DURATION_THRESHHOLD*/) {
+ ret = audec->adsp_ops.dsp_read(&audec->adsp_ops, buffer, MIN(drop_size, DROPPCM_TMPBUF_SIZE));
+ if (drop_raw > 0 && ret > 0) {
+ drop_raw_size = ret * audec->codec_type;
+ nDropCount_raw = 0;
+ while (drop_raw_size > 0) {
+ drop_raw_size -= audec->adsp_ops.dsp_read_raw(&audec->adsp_ops, buffer_raw, drop_raw_size);
+ nDropCount_raw++;
+ if (nDropCount_raw > 10) {
+ adec_print("[%s %d]WARNING:no enough rawdata/%d to Drop,break!\n", __FUNCTION__, __LINE__, drop_raw_size);
+ break;
+ }
+ }
+ }
+ //apts = adec_calc_pts(audec);
+ //adec_print("==drop_size=%d, ret=%d, nDropCount:%d apts=0x%x,-----------------\n",drop_size, ret, nDropCount,apts);
+ nDropConsumeTime = gettime() - start_time;
+ if (nDropConsumeTime / 1000 > drop_max_time) {
+ adec_print("==ret:%d no pcm nDropCount:%d ,nDropConsumeTime:%lld reached drop_max_time:%d, \n", ret, nDropCount, nDropConsumeTime / 1000, drop_max_time);
+ drop_size -= ret;
+ ret = -1;
+ break;
+ }
+ if (ret == 0) { //no data in pcm buf
+ if (nDropCount >= 40) {
+ ret = -1;
+ break;
+ } else {
+ nDropCount++;
+ }
+ if (!strcmp(platformtype, "messon8")) {
+ amthreadpool_thread_usleep(50000); // 10ms
+ } else {
+ amthreadpool_thread_usleep(50000); // 50ms
+ }
+ adec_print("==ret:0 no pcm nDropCount:%d \n", nDropCount);
+ } else {
+ nDropCount = 0;
+ drop_size -= ret;
+ }
+ }
+ if (buffer_raw != NULL) {
+ free(buffer_raw);
+ }
+ adec_print("after droppcm: drop_size=%d, droped:%d, nDropConsumeTime:%lld us,---\n", drop_size, size - drop_size, nDropConsumeTime);
+
+ return ret;
+}
+
+void droppcm_prop_ctrl(int *audio_ahead, int *pts_ahead_val)
+{
+ char value[PROPERTY_VALUE_MAX] = {0};
+
+ if (am_getconfig_bool("media.libplayer.wfd")) {
+ *pts_ahead_val = *pts_ahead_val * 2 / 3;
+ }
+
+ if (property_get("media.amplayer.apts", value, NULL) > 0) {
+ if (!strcmp(value, "slow")) {
+ *audio_ahead = -1;
+ } else if (!strcmp(value, "fast")) {
+ *audio_ahead = 1;
+ }
+ }
+ memset(value, 0, sizeof(value));
+ if (property_get("media.amplayer.apts_val", value, NULL) > 0) {
+ *pts_ahead_val = atoi(value);
+ }
+}
+
+int droppcm_get_refpts(aml_audio_dec_t *audec, unsigned long *refpts)
+{
+ char value[PROPERTY_VALUE_MAX] = {0};
+ char buf[32];
+ char tsync_mode_str[10];
+ int tsync_mode;
+ int circount = 3000; // default: 3000ms
+ int refmode = TSYNC_MODE_AMASTER;
+ int64_t start_time = gettime();
+ unsigned long firstvpts = 0;
+ unsigned long cur_vpts = 0;
+ audio_out_operations_t * aout_ops = &audec->aout_ops;
+ if (amsysfs_get_sysfs_str(TSYNC_MODE, buf, sizeof(buf)) == -1) {
+ adec_print("unable to get tsync_mode from: %s", buf);
+ return -1;
+ }
+ if (sscanf(buf, "%d: %s", &tsync_mode, tsync_mode_str) < 1) {
+ adec_print("unable to get tsync_mode from: %s", buf);
+ return -1;
+ }
+ if ((tsync_mode == TSYNC_MODE_AMASTER && !strcmp(tsync_mode_str, "amaster"))
+ || (tsync_mode == TSYNC_MODE_VMASTER && !strcmp(tsync_mode_str, "vmaster") && audec->droppcm_flag)/* switch audio flag, firstvpts is unvalid when switch audio*/) {
+ refmode = TSYNC_MODE_AMASTER;
+ } else if (tsync_mode == TSYNC_MODE_VMASTER && !strcmp(tsync_mode_str, "vmaster") && !audec->droppcm_flag) {
+ refmode = TSYNC_MODE_VMASTER;
+ } else if (tsync_mode == TSYNC_MODE_PCRMASTER && !strcmp(tsync_mode_str, "pcrmaster")) {
+ refmode = TSYNC_MODE_PCRMASTER;
+ }
+
+ adec_print("## [%s::%d] refmode:%d, tsync_mode:%d,%s, droppcm_flag:%d, ---\n", __FUNCTION__, __LINE__,
+ refmode, tsync_mode, tsync_mode_str, audec->droppcm_flag);
+ if (refmode == TSYNC_MODE_AMASTER || refmode == TSYNC_MODE_VMASTER) {
+ if (sysfs_get_int(TSYNC_VPTS, refpts) == -1) {
+ adec_print("## [%s::%d] unable to get vpts! \n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ adec_print("## [%s::%d] default vpts:0x%x, ---\n", __FUNCTION__, __LINE__, *refpts);
+ } else if (tsync_mode == TSYNC_MODE_PCRMASTER && !strcmp(tsync_mode_str, "pcrmaster")) {
+ if (sysfs_get_int(TSYNC_PCRSCR, refpts) == -1) {
+ adec_print("## [%s::%d] unable to get pts_pcrscr! \n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ int wait_count = 0;
+ while ((*refpts) == 0) {
+ if (audec->need_stop) {
+ return 0;
+ }
+ sysfs_get_int(TSYNC_PCRSCR, refpts);
+ //amthreadpool_thread_usleep(100000);
+ wait_count++;
+ adec_print("## [%s::%d] wait_count = %d, refpts = 0x%x ---\n", __FUNCTION__, __LINE__, wait_count, *refpts);
+ if (wait_count == 1) { //wait 2s
+ break;
+ }
+ }
+ adec_print("## [%s::%d] pcrmaster, refpts:0x%x, ---\n", __FUNCTION__, __LINE__, *refpts);
+ }
+
+ memset(value, 0, sizeof(value));
+ if (property_get("media.amplayer.dropwaitxms", value, NULL) > 0) {
+ circount = atoi(value);
+ }
+ adec_print("drop wait max ms = %d \n", circount);
+
+ //media.amplayer.refmode : 0 vpts 1 other case
+#if 0
+ int use_vpts = 1;
+ if (property_get("media.amplayer.refmode", value, NULL) > 0) {
+ if (atoi(value) != 0) {
+ use_vpts = 0;
+ }
+ }
+
+ if (use_vpts == 0) {
+ return 0;
+ }
+ adec_print("drop pcm use_vpts = %d \n", use_vpts);
+#endif
+
+ unsigned long checkin_firstvpts = 0;
+ while ((!firstvpts || !checkin_firstvpts)) {
+ if (audec->need_stop) {
+ return 0;
+ }
+ aout_ops = &audec->aout_ops;
+ if (aout_ops) {
+ /*cts if audio track rate is set,skip */
+ if (aout_ops->track_rate != 8.8f)
+ return 0;
+ }
+ if (sysfs_get_int(TSYNC_FIRSTVPTS, &firstvpts) == -1) {
+ adec_print("## [%s::%d] unable to get firstpts! \n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+
+ if (sysfs_get_int(TSYNC_CHECKIN_FIRSTVPTS, &checkin_firstvpts) == -1) {
+ adec_print("## [%s::%d] unable to get TSYNC_CHECKIN_FIRSTVPTS! \n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+
+ if (gettime() - start_time >= (circount * 1000)) {
+ adec_print("## [%s::%d] max time reached! %d ms \n", __FUNCTION__, __LINE__, circount);
+ break;
+ }
+ amthreadpool_thread_usleep(10000); // 10ms
+ }
+ adec_print("## [%s::%d] firstvpts:0x%x, use:%lld us, maxtime:%d ms, ---\n", __FUNCTION__, __LINE__, firstvpts, gettime() - start_time, circount);
+
+ if (sysfs_get_int(TSYNC_VPTS, &cur_vpts) == -1) {
+ adec_print("## [%s::%d] unable to get vpts! \n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+
+ if (audec->tsync_mode == TSYNC_MODE_PCRMASTER) {
+ if (cur_vpts && cur_vpts < firstvpts && cur_vpts != checkin_firstvpts) {
+ *refpts = cur_vpts;
+ } else if (firstvpts) {
+ *refpts = firstvpts;
+ } else {
+ *refpts = checkin_firstvpts;
+ }
+ } else {
+ if (firstvpts) {
+ *refpts = firstvpts;
+ } else {
+ *refpts = cur_vpts;
+ }
+ }
+ adec_print("## [%s::%d] cur_vpts:0x%x,checkin_firstvpts=0x%x,firstvpts:0x%x refpts:0x%x, ---\n",
+ __FUNCTION__, __LINE__, cur_vpts, checkin_firstvpts, firstvpts, *refpts);
+
+
+ return 0;
+}
+
+int adec_get_tsync_info(int *tsync_mode)
+{
+ char value[PROPERTY_VALUE_MAX] = {0};
+ char buf[32];
+ char tsync_mode_str[10];
+
+ if (amsysfs_get_sysfs_str(TSYNC_MODE, buf, sizeof(buf)) == -1) {
+ adec_print("unable to get tsync_mode from: %s", buf);
+ return -1;
+ }
+ if (sscanf(buf, "%d: %s", tsync_mode, tsync_mode_str) < 1) {
+ adec_print("unable to get tsync_mode from: %s", buf);
+ return -1;
+ }
+
+ if (tsync_mode == TSYNC_MODE_AMASTER && !strcmp(tsync_mode_str, "amaster")) {
+ *tsync_mode = TSYNC_MODE_AMASTER;
+ } else if (tsync_mode == TSYNC_MODE_VMASTER && !strcmp(tsync_mode_str, "vmaster")) {
+ *tsync_mode = TSYNC_MODE_VMASTER;
+ } else if (tsync_mode == TSYNC_MODE_PCRMASTER && !strcmp(tsync_mode_str, "pcrmaster")) {
+ *tsync_mode = TSYNC_MODE_PCRMASTER;
+ }
+
+ return *tsync_mode;
+}
diff --git a/amadec/adec-pts-mgt.h b/amadec/adec-pts-mgt.h
new file mode 100644
index 0000000..517b69a
--- a/dev/null
+++ b/amadec/adec-pts-mgt.h
@@ -0,0 +1,82 @@
+/**
+ * \file adec-pts-mgt.h
+ * \brief Function prototypes of Pts manage.
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#ifndef ADEC_PTS_H
+#define ADEC_PTS_H
+
+#include <audio-dec.h>
+#define TIME_UNIT90K 90000
+ADEC_BEGIN_DECLS
+
+typedef enum {
+ TSYNC_MODE_VMASTER,
+ TSYNC_MODE_AMASTER,
+ TSYNC_MODE_PCRMASTER,
+} tsync_mode_t;
+
+#define AMSTREAM_IOC_MAGIC 'S'
+#define AMSTREAM_IOC_GET_LAST_CHECKIN_APTS _IOR(AMSTREAM_IOC_MAGIC, 0xa9, unsigned long)
+#define AMSTREAM_IOC_GET_LAST_CHECKIN_VPTS _IOR(AMSTREAM_IOC_MAGIC, 0xaa, unsigned long)
+#define AMSTREAM_IOC_GET_LAST_CHECKOUT_APTS _IOR(AMSTREAM_IOC_MAGIC, 0xab, unsigned long)
+#define AMSTREAM_IOC_GET_LAST_CHECKOUT_VPTS _IOR(AMSTREAM_IOC_MAGIC, 0xac, unsigned long)
+#define AMSTREAM_IOC_AB_STATUS _IOR(AMSTREAM_IOC_MAGIC, 0x09, int)
+
+#define TSYNC_PCR_DISPOINT "/sys/class/tsync_pcr/tsync_pcr_discontinue_point"
+#define TSYNC_PCRSCR "/sys/class/tsync/pts_pcrscr"
+#define TSYNC_EVENT "/sys/class/tsync/event"
+#define TSYNC_APTS "/sys/class/tsync/pts_audio"
+#define TSYNC_VPTS "/sys/class/tsync/pts_video"
+#define TSYNC_ENABLE "/sys/class/tsync/enable"
+#define TSYNC_LAST_CHECKIN_APTS "/sys/class/tsync/last_checkin_apts"
+#define TSYNC_MODE "/sys/class/tsync/mode"
+#define TSYNC_FIRSTVPTS "/sys/class/tsync/firstvpts"
+#define TSYNC_FIRSTAPTS "/sys/class/tsync/firstapts"
+#define TSYNC_CHECKIN_FIRSTVPTS "/sys/class/tsync/checkin_firstvpts"
+#define TSYNC_PCR_DISCONTINUE "/sys/class/tsync_pcr/tsync_pcr_discontinue"
+#define TSYNC_PCR_PLAY_MODE "/sys/class/tsync_pcr/play_mode"
+
+#define SYSTIME_CORRECTION_THRESHOLD (90000*6/100)//modified for amlogic-pd-91949
+#define APTS_DISCONTINUE_THRESHOLD (90000*3)
+#define REFRESH_PTS_TIME_MS (1000/10)
+#define VIDEO_DISCONTINUE 0x02
+
+//#define abs(x) ({ \
+// long __x = (x); \
+// (__x < 0) ? -__x : __x; \
+// })
+
+
+/**********************************************************************/
+int sysfs_get_int(char *path, unsigned long *val);
+unsigned long adec_calc_pts(aml_audio_dec_t *audec);
+int adec_pts_start(aml_audio_dec_t *audec);
+int adec_pts_pause(void);
+int adec_pts_resume(void);
+int adec_refresh_pts(aml_audio_dec_t *audec);
+int avsync_en(int e);
+int track_switch_pts(aml_audio_dec_t *audec);
+int adec_get_tsync_info(int *tsync_mode);
+
+struct buf_status {
+ int size;
+ int data_len;
+ int free_len;
+ unsigned int read_pointer;
+ unsigned int write_pointer;
+};
+
+struct am_io_param {
+ int data;
+ int len; //buffer size;
+ struct buf_status status;
+};
+ADEC_END_DECLS
+
+#endif
diff --git a/amadec/adec-wfd-out.cpp b/amadec/adec-wfd-out.cpp
new file mode 100644
index 0000000..e184560
--- a/dev/null
+++ b/amadec/adec-wfd-out.cpp
@@ -0,0 +1,361 @@
+#include <errno.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <sys/time.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <android/log.h>
+#include <cutils/properties.h>
+//get android media stream volume
+#define CODE_CALC_VOLUME
+#ifdef CODE_CALC_VOLUME
+#include <media/AudioSystem.h>
+#define EXTERN_TAG extern "C"
+namespace android
+{
+#else
+#define EXTERN_TAG
+#endif
+#define LOG_TAG "wfd-output"
+#define adec_print(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+// default using tinyalsa
+#include <tinyalsa/asoundlib.h>
+
+
+
+//"/sys/class/switch/hdmi/state"
+#define HDMI_SWITCH_STATE_PATH "/sys/class/amhdmitx/amhdmitx0/hpd_state"
+
+// audio PCM output configuration
+#define WFD_PERIOD_SIZE 1024
+#define WFD_PERIOD_NUM 4
+static struct pcm_config wfd_config_out;
+static struct pcm *wfd_pcm;
+static char cache_buffer_bytes[64];
+static int cached_len=0;
+static const char *const SOUND_CARDS_PATH = "/proc/asound/cards";
+static int tv_mode = 0;
+static int getprop_bool(const char * path)
+{
+ char buf[PROPERTY_VALUE_MAX];
+ int ret = -1;
+ ret = property_get(path, buf, NULL);
+ if (ret > 0) {
+ if (strcasecmp(buf,"true") == 0 || strcmp(buf,"1") == 0) {
+ return 1;
+ }
+ }
+ return 0;
+}
+static int get_hdmi_switch_state()
+{
+ return 0;
+#if 0
+ int state = 0;
+ int fd = -1;
+ char bcmd[16] = {0};
+ fd = open(HDMI_SWITCH_STATE_PATH, O_RDONLY);
+ if (fd >= 0) {
+ read(fd, bcmd, sizeof(bcmd));
+ state = strtol(bcmd, NULL, 10);
+ close(fd);
+ }else {
+ adec_print("unable to open file %s,err: %s", HDMI_SWITCH_STATE_PATH, strerror(errno));
+ }
+ return state;
+#endif
+}
+#ifdef CODE_CALC_VOLUME
+// save the last volume in case get vol failure, which cause the volume value large gap
+static float last_vol = 1.0;
+static float get_android_stream_volume()
+{
+ float vol = last_vol;
+#if defined(ANDROID_VERSION_JBMR2_UP)
+ unsigned int sr = 0;
+#else
+ int sr = 0;
+#endif
+#if ANDROID_PLATFORM_SDK_VERSION >= 21
+ audio_stream_type_t media_type = AUDIO_STREAM_SYSTEM;
+#else
+ audio_stream_type_t media_type = AUDIO_STREAM_MUSIC;
+#endif
+
+ AudioSystem::getOutputSamplingRate(&sr,AUDIO_STREAM_MUSIC);
+ if(sr > 0){
+ audio_io_handle_t handle = -1;
+ handle = AudioSystem::getOutput(AUDIO_STREAM_MUSIC,
+ 48000,
+ AUDIO_FORMAT_PCM_16_BIT,
+ AUDIO_CHANNEL_OUT_STEREO,
+#if defined(_VERSION_ICS)
+ AUDIO_POLICY_OUTPUT_FLAG_INDIRECT
+#else //JB...
+ AUDIO_OUTPUT_FLAG_PRIMARY
+#endif
+ );
+ if(handle > 0){
+ if(AudioSystem::getStreamVolume(media_type,&vol,handle) == NO_ERROR){
+ last_vol = vol;
+ // adec_print("stream volume %f \n",vol);
+ }
+ else
+ adec_print("get stream volume failed\n");
+ }
+ else
+ adec_print("get output handle failed\n");
+ }
+ return vol;
+
+}
+static void apply_stream_volume(float vol,char *buf,int size)
+{
+ int i;
+ short *sample = (short*)buf;
+ for(i = 0;i < size/sizeof(short);i++)
+ sample[i] = vol*sample[i];
+}
+#endif
+static int get_aml_card(){
+ int card = -1, err = 0;
+ int fd = -1;
+ unsigned fileSize = 512;
+ char *read_buf = NULL, *pd = NULL;
+ fd = open(SOUND_CARDS_PATH, O_RDONLY);
+ if (fd < 0) {
+ adec_print("ERROR: failed to open config file %s error: %d\n", SOUND_CARDS_PATH, errno);
+ close(fd);
+ return -EINVAL;
+ }
+
+ read_buf = (char *)malloc(fileSize);
+ if (!read_buf) {
+ adec_print("Failed to malloc read_buf");
+ close(fd);
+ return -ENOMEM;
+ }
+ memset(read_buf, 0x0, fileSize);
+ err = read(fd, read_buf, fileSize);
+ if (fd < 0) {
+ adec_print("ERROR: failed to read config file %s error: %d\n", SOUND_CARDS_PATH, errno);
+ free(read_buf);
+ close(fd);
+ return -EINVAL;
+ }
+ pd = strstr(read_buf, "AML");
+ card = *(pd - 3) - '0';
+
+OUT:
+ free(read_buf);
+ close(fd);
+ return card;
+}
+static int get_spdif_port() {
+ return 0;
+#if 0
+ int port = -1, err = 0;
+ int fd = -1;
+ unsigned fileSize = 512;
+ char *read_buf = NULL, *pd = NULL;
+ static const char *const SOUND_PCM_PATH = "/proc/asound/pcm";
+ fd = open(SOUND_PCM_PATH, O_RDONLY);
+ if (fd < 0) {
+ adec_print("ERROR: failed to open config file %s error: %d\n", SOUND_PCM_PATH, errno);
+ close(fd);
+ return -EINVAL;
+ }
+
+ read_buf = (char *)malloc(fileSize);
+ if (!read_buf) {
+ adec_print("Failed to malloc read_buf");
+ close(fd);
+ return -ENOMEM;
+ }
+ memset(read_buf, 0x0, fileSize);
+ err = read(fd, read_buf, fileSize);
+ if (fd < 0) {
+ adec_print("ERROR: failed to read config file %s error: %d\n", SOUND_PCM_PATH, errno);
+ free(read_buf);
+ close(fd);
+ return -EINVAL;
+ }
+ pd = strstr(read_buf, "SPDIF");
+ if(!pd)
+ goto OUT;
+ adec_print("%s \n",pd );
+
+ port = *(pd -3) - '0';
+ adec_print("%s \n",(pd -3) );
+
+OUT:
+ free(read_buf);
+ close(fd);
+ return port;
+#endif
+}
+
+EXTERN_TAG int pcm_output_init(int sr,int ch)
+{
+ int card = 0;
+ int device = 2;
+ cached_len = 0;
+ tv_mode = getprop_bool("ro.platform.has.tvuimode");
+ wfd_config_out.channels = 2;
+ wfd_config_out.rate = 48000;
+ wfd_config_out.period_size = WFD_PERIOD_SIZE;
+ wfd_config_out.period_count = WFD_PERIOD_NUM;
+ wfd_config_out.format = PCM_FORMAT_S16_LE;
+ wfd_config_out.start_threshold = WFD_PERIOD_SIZE;
+ wfd_config_out.avail_min = 0;//SHORT_PERIOD_SIZE;
+ card = get_aml_card();
+ if(card < 0)
+ {
+ card = 0;
+ adec_print("get aml card fail, use default \n");
+ }
+ // if hdmi state on
+ if(get_hdmi_switch_state())
+ device = get_spdif_port();
+ else
+ device = 0; //i2s output for analog output
+ if(device < 0)
+ {
+ device = 0;
+ adec_print("get aml card device fail, use default \n");
+ }
+ device = 0;
+ adec_print("open output device card %d, device %d \n",card,device);
+ if(sr < 32000|| sr > 48000 || ch != 2){
+ adec_print("wfd output: not right parameter sr %d,ch %d \n",sr,ch);
+ return -1;
+ }
+ wfd_config_out.rate = sr;
+ wfd_config_out.channels = ch;
+ if (tv_mode) {
+ wfd_config_out.channels = 8;
+ wfd_config_out.format = PCM_FORMAT_S32_LE;
+ wfd_config_out.period_size = WFD_PERIOD_SIZE;
+ wfd_config_out.period_count = WFD_PERIOD_NUM;
+ wfd_config_out.start_threshold = WFD_PERIOD_SIZE;
+ }
+ wfd_pcm = pcm_open(card, device, PCM_OUT /*| PCM_MMAP | PCM_NOIRQ*/, &wfd_config_out);
+ if (!pcm_is_ready(wfd_pcm)) {
+ adec_print("wfd cannot open pcm_out driver: %s", pcm_get_error(wfd_pcm));
+ pcm_close(wfd_pcm);
+ return -1;
+ }
+ adec_print("pcm_output_init done wfd : %p,\n",wfd_pcm);
+ return 0;
+
+}
+
+EXTERN_TAG int pcm_output_write(char *buf,unsigned size)
+{
+
+ int ret = 0;
+ char *data, *data_dst;
+ char *data_src;
+ char outbuf[8192];
+ int total_len,ouput_len;
+#ifdef CODE_CALC_VOLUME
+ float vol = get_android_stream_volume();
+ apply_stream_volume(vol,buf,size);
+#endif
+ if(size < 64)
+ return 0;
+ if(size > sizeof(outbuf)){
+ adec_print("write size tooo big %d \n",size);
+ }
+ total_len = size + cached_len;
+
+ //adec_print("total_len(%d) = + cached_len111(%d)", size, cached_len);
+
+ data_src = (char *)cache_buffer_bytes;
+ data_dst = (char *)outbuf;
+
+
+
+ /*write_back data from cached_buffer*/
+ if(cached_len){
+ memcpy((void *)data_dst, (void *)data_src, cached_len);
+ data_dst += cached_len;
+ }
+ ouput_len = total_len &(~0x3f);
+ data = (char*)buf;
+
+ memcpy((void *)data_dst, (void *)data, ouput_len-cached_len);
+ data += (ouput_len-cached_len);
+ cached_len = total_len & 0x3f;
+ data_src = (char *)cache_buffer_bytes;
+
+ /*save data to cached_buffer*/
+ if(cached_len){
+ memcpy((void *)data_src, (void *)data, cached_len);
+ }
+ char *write_buf = outbuf;
+ int *tmp_buffer = NULL;
+ if (tv_mode) {
+ tmp_buffer = (int*)malloc(ouput_len*8);
+ if (tmp_buffer == NULL) {
+ ALOGE("malloc tmp_buffer failed\n");
+ return -1;
+ }
+ int i;
+ int out_frames = ouput_len/4;
+ short *in_buffer = (short*)outbuf;
+ for (i = 0; i < out_frames; i ++) {
+ tmp_buffer[8*i] = ((int)(in_buffer[2*i])) << 16;
+ tmp_buffer[8*i + 1] = ((int)(in_buffer[2*i + 1])) << 16;
+ tmp_buffer[8*i + 2] = ((int)(in_buffer[2*i])) << 16;
+ tmp_buffer[8*i + 3] = ((int)(in_buffer[2*i + 1])) << 16;
+ tmp_buffer[8*i + 4] = 0;
+ tmp_buffer[8*i + 5] = 0;
+ tmp_buffer[8*i + 6] = 0;
+ tmp_buffer[8*i + 7] = 0;
+ }
+ write_buf = (char*)tmp_buffer;
+ ouput_len = ouput_len*8;
+ }
+ ret = pcm_write(wfd_pcm,write_buf,ouput_len);
+ if(ret < 0 ){
+ adec_print("pcm_output_write failed ? \n");
+ }
+ if (tmp_buffer) {
+ free(tmp_buffer);
+ }
+ //adec_print("write size %d ,ret %d \n",size,ret);
+ return ret;
+}
+EXTERN_TAG int pcm_output_uninit()
+{
+ if(wfd_pcm)
+ pcm_close(wfd_pcm);
+ wfd_pcm = NULL;
+ adec_print("pcm_output_uninit done \n");
+ return 0;
+}
+EXTERN_TAG int pcm_output_latency()
+{
+#if 1
+ struct timespec tstamp;
+ unsigned int avail = 0;
+ int ret;
+ ret = pcm_get_htimestamp(wfd_pcm,&avail, &tstamp);
+ //adec_print("pcm_get_latency ret %d,latency %d \n",ret,avail*1000/48000);
+ if(ret)
+ return ret;
+ else
+ return avail*1000/wfd_config_out.rate;
+#else
+ return pcm_hw_lantency(wfd_pcm);
+#endif
+}
+#ifdef CODE_CALC_VOLUME
+}
+#endif
diff --git a/amadec/adec-wfd.c b/amadec/adec-wfd.c
new file mode 100644
index 0000000..c1faf4d
--- a/dev/null
+++ b/amadec/adec-wfd.c
@@ -0,0 +1,811 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <dlfcn.h>
+
+#include <adec-pts-mgt.h>
+#include <adec_write.h>
+#include <adec_omx_brige.h>
+#include <Amsysfsutils.h>
+#include <audio-dec.h>
+#include <cutils/properties.h>
+#include <amthreadpool.h>
+#include "audiodsp_update_format.h"
+
+typedef struct {
+ int codec_id;
+ char name[64];
+} audio_lib_t;
+
+typedef int (*fn_pcm_output_init)(int sr, int ch);
+typedef int (*fn_pcm_output_write)(char *buf, unsigned size);
+typedef int (*fn_pcm_output_uninit)();
+typedef int (*fn_pcm_output_latency)();
+
+
+typedef void (*fn_audio_set_exit_flag)();
+
+
+static audio_lib_t wfd_audio_lib_list[] = {
+ {ACODEC_FMT_WIFIDISPLAY, "libpcm_wfd.so"},
+ {ACODEC_FMT_AAC, "libaac_helix.so"},
+ 0
+} ;
+static audio_decoder_operations_t WFDAudioDecoder = {
+ "WFDDecoder",
+ AUDIO_ARM_DECODER,
+ 0,
+};
+
+static fn_pcm_output_init wfd_out_init = NULL;
+static fn_pcm_output_write wfd_out_write = NULL;
+static fn_pcm_output_uninit wfd_out_uninit = NULL;
+static fn_pcm_output_latency wfd_out_latency = NULL;
+
+
+static fn_audio_set_exit_flag wfd_adec_exit = NULL;
+static void *dec_mLibHandle = NULL;
+static void *out_mLibHandle = NULL;
+static void *audio_wfd_decode_loop(void *args);
+static void stop_wfd_decode_thread(aml_audio_dec_t *audec);
+static int wfd_register_audio_lib(aml_audio_dec_t *audec)
+{
+ int i;
+ int num;
+ audio_lib_t *f;
+ adec_print("wfd audec->format %d,audec->codec_id %x", audec->format, audec->codec_id);
+ num = ARRAY_SIZE(wfd_audio_lib_list);
+ audio_decoder_operations_t *adec_ops = audec->adec_ops;
+ for (i = 0; i < num; i++) {
+ f = &wfd_audio_lib_list[i];
+ if (f->codec_id == audec->format) {
+ dec_mLibHandle = dlopen(wfd_audio_lib_list[i].name, RTLD_NOW);
+ if (dec_mLibHandle) {
+ adec_ops->init = dlsym(dec_mLibHandle, "audio_dec_init");
+ adec_ops->decode = dlsym(dec_mLibHandle, "audio_dec_decode");
+ adec_ops->release = dlsym(dec_mLibHandle, "audio_dec_release");
+ adec_ops->getinfo = dlsym(dec_mLibHandle, "audio_dec_getinfo");
+ wfd_adec_exit = dlsym(dec_mLibHandle, "audio_set_exit_flag");
+ if (!adec_ops->init || !adec_ops->decode || !adec_ops->release || !adec_ops->getinfo || !wfd_adec_exit) {
+ adec_print("in %s,decode func not implemented %p %p %p %p \n", wfd_audio_lib_list[i].name, \
+ adec_ops->init, adec_ops->decode, adec_ops->release, adec_ops->getinfo);
+ goto error;
+ }
+ } else {
+ adec_print("wfd cant find decoder lib\n");
+ goto error;
+ }
+ return 0;
+ }
+ }
+error:
+ if (dec_mLibHandle) {
+ dlclose(dec_mLibHandle);
+ }
+ dec_mLibHandle = NULL;
+ return -1;
+}
+static int wfd_register_output_lib(aml_audio_dec_t *audec)
+{
+ out_mLibHandle = dlopen("libamadec_wfd_out.so", RTLD_NOW);
+ if (out_mLibHandle) {
+ wfd_out_init = dlsym(out_mLibHandle, "pcm_output_init");
+ wfd_out_write = dlsym(out_mLibHandle, "pcm_output_write");
+ wfd_out_uninit = dlsym(out_mLibHandle, "pcm_output_uninit");
+ wfd_out_latency = dlsym(out_mLibHandle, "pcm_output_latency");
+
+ if (!wfd_out_init || !wfd_out_write || !wfd_out_uninit || !wfd_out_latency) {
+ adec_print("wfd load output lib api failed\n");
+ goto error;
+ }
+ } else {
+ goto error;
+ }
+ return 0;
+error:
+ if (out_mLibHandle) {
+ dlclose(out_mLibHandle);
+ }
+ out_mLibHandle = NULL;
+ return -1;
+
+
+}
+static void wfd_unregister_lib()
+{
+ if (out_mLibHandle) {
+ dlclose(out_mLibHandle);
+ }
+ out_mLibHandle = NULL;
+ if (dec_mLibHandle) {
+ dlclose(dec_mLibHandle);
+ }
+ dec_mLibHandle = NULL;
+}
+extern int read_buffer(unsigned char *buffer, int size);
+
+
+static int wfd_dec_pcm_read(dsp_operations_t *dsp_ops, char *buffer, int len)
+{
+ return 0;
+}
+static unsigned long wfd_dec_get_pts(dsp_operations_t *dsp_ops)
+{
+ unsigned long val, offset;
+ unsigned long pts;
+ int data_width, channels, samplerate;
+ unsigned long long frame_nums ;
+ unsigned long delay_pts;
+ samplerate = 48000;
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)dsp_ops->audec;
+ offset = audec->decode_offset;
+
+ if (dsp_ops->dsp_file_fd >= 0) {
+ ioctl(dsp_ops->dsp_file_fd, AMSTREAM_IOC_APTS_LOOKUP, &offset);
+ } else {
+ adec_print("====abuf have not open!\n", val);
+ }
+ pts = offset;
+ if (pts == 0) {
+ if (audec->last_valid_pts) {
+ pts = audec->last_valid_pts;
+ }
+ frame_nums = (audec->out_len_after_last_valid_pts * 8 / (16 * 2));
+ adec_print("decode_offset:%d out_pcm:%d pts:%d \n", audec->decode_offset, audec->out_len_after_last_valid_pts, pts);
+ pts += (frame_nums * 90000 / samplerate);
+ return pts;
+ }
+ audec->last_valid_pts = pts;
+ audec->out_len_after_last_valid_pts = 0;
+ return pts;
+}
+
+static unsigned long wfd_dec_get_pcrscr(dsp_operations_t *dsp_ops)
+{
+ unsigned long val;
+ if (dsp_ops->dsp_file_fd < 0) {
+ adec_print("read error!! audiodsp have not opened\n");
+ return -1;
+ }
+ ioctl(dsp_ops->dsp_file_fd, AMSTREAM_IOC_PCRSCR, &val);
+ return val;
+}
+unsigned long wfd_dec_set_pts(dsp_operations_t *dsp_ops, unsigned long apts)
+{
+ if (dsp_ops->dsp_file_fd < 0) {
+ adec_print("armdec_set_apts err!\n");
+ return -1;
+ }
+ ioctl(dsp_ops->dsp_file_fd, AMSTREAM_IOC_SET_APTS, &apts);
+ return 0;
+}
+static int wfd_dec_set_skip_bytes(dsp_operations_t* dsp_ops, unsigned int bytes)
+{
+ return 0;
+}
+static int set_sysfs_int(const char *path, int val)
+{
+ return amsysfs_set_sysfs_int(path, val);
+}
+
+
+static int wfd_audio_codec_release(aml_audio_dec_t *audec)
+{
+ if (wfd_adec_exit) {
+ wfd_adec_exit();
+ }
+ stop_wfd_decode_thread(audec);
+ if (wfd_out_uninit) {
+ wfd_out_uninit();
+ }
+ audec->adec_ops->release(audec->adec_ops);
+ wfd_unregister_lib();
+ adec_print("wfd audio_codec_release done\n");
+ return 0;
+}
+
+
+static int get_first_apts_flag(dsp_operations_t *dsp_ops)
+{
+ int val;
+ if (dsp_ops->dsp_file_fd < 0) {
+ adec_print("[%s %d]read error!! audiodsp have not opened\n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ ioctl(dsp_ops->dsp_file_fd, GET_FIRST_APTS_FLAG, &val);
+ return val;
+}
+
+
+/**
+ * \brief start audio dec when receive START command.
+ * \param audec pointer to audec
+ */
+static void start_adec(aml_audio_dec_t *audec)
+{
+ int ret;
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ dsp_operations_t *dsp_ops = &audec->adsp_ops;
+ unsigned long vpts, apts;
+ int times = 0;
+ char buf[32];
+ apts = vpts = 0;
+ audec->no_first_apts = 0;
+
+ if (audec->state == INITTED) {
+ audec->state = ACTIVE;
+ //get info from the audiodsp == can get from amstreamer
+ while ((!get_first_apts_flag(dsp_ops)) && (!audec->need_stop) && (!audec->no_first_apts)) {
+ adec_print("wait first pts checkin complete !");
+ times++;
+ if (times >= 5) {
+ amsysfs_get_sysfs_str(TSYNC_VPTS, buf, sizeof(buf));// read vpts
+ if (sscanf(buf, "0x%lx", &vpts) < 1) {
+ adec_print("unable to get vpts from: %s", buf);
+ return;
+ }
+ // save vpts to apts
+ adec_print("## can't get first apts, save vpts to apts,vpts=%lx, \n", vpts);
+ sprintf(buf, "0x%lx", vpts);
+ amsysfs_set_sysfs_str(TSYNC_APTS, buf);
+ audec->no_first_apts = 1;
+ }
+ amthreadpool_thread_usleep(100000);
+ }
+
+ /*start the the pts scr,...*/
+ ret = adec_pts_start(audec);
+ if (audec->auto_mute) {
+ avsync_en(0);
+ adec_pts_pause();
+ while ((!audec->need_stop) && track_switch_pts(audec)) {
+ amthreadpool_thread_usleep(1000);
+ }
+ avsync_en(1);
+ adec_pts_resume();
+ audec->auto_mute = 0;
+ }
+#ifdef OUT_USE_AUDIOTRACK
+ aout_ops->start(audec);
+#endif
+ }
+}
+
+/**
+ * \brief pause audio dec when receive PAUSE command.
+ * \param audec pointer to audec
+ */
+static void pause_adec(aml_audio_dec_t *audec)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ if (audec->state == ACTIVE) {
+ audec->state = PAUSED;
+ adec_pts_pause();
+#ifdef OUT_USE_AUDIOTRACK
+ aout_ops->pause(audec);
+#endif
+ }
+}
+
+/**
+ * \brief resume audio dec when receive RESUME command.
+ * \param audec pointer to audec
+ */
+static void resume_adec(aml_audio_dec_t *audec)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ if (audec->state == PAUSED) {
+ audec->state = ACTIVE;
+#ifdef OUT_USE_AUDIOTRACK
+ aout_ops->resume(audec);
+#endif
+ adec_pts_resume();
+ }
+}
+
+/**
+ * \brief stop audio dec when receive STOP command.
+ * \param audec pointer to audec
+ */
+static void stop_adec(aml_audio_dec_t *audec)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ adec_print("[%s %d]audec->state/%d\n", __FUNCTION__, __LINE__, audec->state);
+ if (audec->state > INITING) {
+ audec->state = STOPPED;
+#ifdef OUT_USE_AUDIOTRACK
+ aout_ops->mute(audec, 1); //mute output, some repeat sound in audioflinger after stop
+ aout_ops->stop(audec);
+#endif
+ wfd_audio_codec_release(audec);
+ }
+}
+
+/**
+ * \brief release audio dec when receive RELEASE command.
+ * \param audec pointer to audec
+ */
+static void release_adec(aml_audio_dec_t *audec)
+{
+ audec->state = TERMINATED;
+}
+
+/**
+ * \brief mute audio dec when receive MUTE command.
+ * \param audec pointer to audec
+ * \param en 1 = mute, 0 = unmute
+ */
+static void mute_adec(aml_audio_dec_t *audec, int en)
+{
+#ifdef OUT_USE_AUDIOTRACK
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ if (aout_ops->mute) {
+ adec_print("%s the output !\n", (en ? "mute" : "unmute"));
+ aout_ops->mute(audec, en);
+ audec->muted = en;
+ }
+#endif
+}
+
+/**
+ * \brief set volume to audio dec when receive SET_VOL command.
+ * \param audec pointer to audec
+ * \param vol volume value
+ */
+static void adec_set_volume(aml_audio_dec_t *audec, float vol)
+{
+#ifdef OUT_USE_AUDIOTRACK
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ if (aout_ops->set_volume) {
+ adec_print("set audio volume! vol = %f\n", vol);
+ aout_ops->set_volume(audec, vol);
+ }
+#endif
+}
+
+/**
+ * \brief set volume to audio dec when receive SET_LRVOL command.
+ * \param audec pointer to audec
+ * \param lvol left channel volume value
+ * \param rvol right channel volume value
+ */
+static void adec_set_lrvolume(aml_audio_dec_t *audec, float lvol, float rvol)
+{
+#ifdef OUT_USE_AUDIOTRACK
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ if (aout_ops->set_lrvolume) {
+ adec_print("set audio volume! left vol = %f,right vol:%f\n", lvol, rvol);
+ aout_ops->set_lrvolume(audec, lvol, rvol);
+ }
+#endif
+}
+static void adec_flag_check(aml_audio_dec_t *audec)
+{
+ audio_out_operations_t *aout_ops = &audec->aout_ops;
+ if (audec->auto_mute && (audec->state > INITTED)) {
+ aout_ops->pause(audec);
+ amthreadpool_thread_usleep(10000);
+ while ((!audec->need_stop) && track_switch_pts(audec)) {
+ amthreadpool_thread_usleep(1000);
+ }
+#ifdef OUT_USE_AUDIOTRACK
+ aout_ops->resume(audec);
+#endif
+ audec->auto_mute = 0;
+ }
+}
+
+
+static void start_wfd_decode_thread(aml_audio_dec_t *audec)
+{
+ int ret = -1;
+ if (audec->state != INITTED) {
+ adec_print("decode not inited quit \n");
+ return;
+ }
+ pthread_t tid;
+ ret = amthreadpool_pthread_create(&tid, NULL, (void *)audio_wfd_decode_loop, (void *)audec);
+ if (ret != 0) {
+ adec_print("[%s]Create ffmpeg decode thread failed!\n", __FUNCTION__);
+ return;
+ }
+ audec->sn_threadid = tid;
+ pthread_setname_np(tid, "AmadecDecodeWFD");
+ adec_print("[%s]Create WFD audio decode thread success! tid = %d\n", __FUNCTION__, tid);
+}
+static void stop_wfd_decode_thread(aml_audio_dec_t *audec)
+{
+ adec_print("enter stop_wfd_decode_thread \n");
+ audec->exit_decode_thread = 1;
+ int ret = amthreadpool_pthread_join(audec->sn_threadid, NULL);
+ adec_print("[%s]wfd decode thread exit success\n", __FUNCTION__);
+ audec->exit_decode_thread = 0;
+ audec->sn_threadid = -1;
+
+}
+
+static int wfd_audio_codec_init(aml_audio_dec_t *audec)
+{
+ int ret = 0;
+ audec->exit_decode_thread = 0;
+ audec->fd_uio = -1;
+ audec->sn_threadid = -1;
+ audec->adsp_ops.dsp_on = 1;
+ //TODO : get the actual sample rate /channel num
+ audec->data_width = AV_SAMPLE_FMT_S16;
+ audec->channels = 2;
+ audec->samplerate = 48000;
+
+ audec->adsp_ops.dsp_read = wfd_dec_pcm_read;
+ audec->adsp_ops.get_cur_pts = wfd_dec_get_pts;
+ audec->adsp_ops.get_cur_pcrscr = wfd_dec_get_pcrscr;
+ audec->adsp_ops.set_cur_apts = wfd_dec_set_pts;
+ audec->adsp_ops.set_skip_bytes = wfd_dec_set_skip_bytes;
+ audec->adsp_ops.dsp_read_raw = NULL;
+ while (0 != set_sysfs_int(DECODE_ERR_PATH, DECODE_NONE_ERR)) {
+ adec_print("[%s %d]set codec fatal failed ! \n", __FUNCTION__, __LINE__);
+ amthreadpool_thread_usleep(100000);
+ }
+ /*
+ //enable uio interface
+ ret = uio_init(audec);
+ if (ret < 0) {
+ adec_print("wfd uio init error! \n");
+ return -1;
+ }
+ */
+ // register decoder lib
+ memset(&WFDAudioDecoder, 0, sizeof(audio_decoder_operations_t));
+ audec->adec_ops = &WFDAudioDecoder;
+ audec->adec_ops->priv_data = audec;
+ if (wfd_register_audio_lib(audec)) {
+ adec_print("wfd register decoder failed \n");
+ return -1;
+ }
+ if (wfd_register_output_lib(audec)) {
+ adec_print("wfd register output failed \n");
+ return -1;
+ }
+ // output init,not init here as we should get the sr/ch info when decode one frame
+#if 0
+ if (wfd_out_init()) {
+ adec_print("wfd init pcm output device failed\n");
+ return -1;
+ }
+#endif
+ ret = audec->adec_ops->init(audec->adec_ops);
+ if (ret) {
+ adec_print("wfd audio decoder init failed \n");
+ goto error1;
+ }
+
+
+ adec_print("wfd audio_codec_init ok \n");
+ return 0;
+error1:
+ wfd_out_uninit();
+ return -1;
+
+}
+#define RESAMPLE_FRAMES 128
+static short date_temp[1024 * 4 * 2];
+
+static void audio_resample_api(char* buffer, unsigned int *size, int Chnum, int enable, int delta)
+{
+ short *pbuf;
+ int resample_enable;
+ int resample_type;
+ int resample_delta;
+ int frame_read;
+ int num_sample = 0;
+ int i, j, k, h;
+ int request = *size;
+ int dsp_read = 0;
+ static int last_resample_enable = 0;
+ pbuf = (short*)date_temp;
+ unsigned index = 0;
+ float mPhaseFraction;
+ float phaseIncrement ;
+ float mPhaseFraction1;
+ unsigned in_sr;
+ unsigned out_sr;
+ short *input;
+ short *output;
+ unsigned frames = 0;
+ in_sr = (RESAMPLE_FRAMES - 1);
+ out_sr = (RESAMPLE_FRAMES - delta - 1);
+ phaseIncrement = (float)in_sr / out_sr;
+ resample_enable = enable;
+ resample_delta = delta;
+
+ if (last_resample_enable != resample_enable) {
+ adec_print("resample changed: %s\n", resample_enable ? "Enabled" : "Disabled");
+ last_resample_enable = resample_enable;
+ }
+
+ if (resample_enable && resample_delta && *size >= RESAMPLE_FRAMES * sizeof(short)*Chnum) {
+ //adec_print("resample start ... %d, step=%d\n", *size, resample_delta);
+ if (resample_delta < 0) {
+ // *size = *size*RESAMPLE_FRAMES/(RESAMPLE_FRAMES-resample_delta);
+ }
+ memcpy(pbuf, buffer, *size);
+ frame_read = *size / (sizeof(short) * Chnum); //dsp_pcm_read(audec, pbuf, *size); // return mono sample number
+ dsp_read += frame_read;
+ k = 0;
+ while (frame_read >= RESAMPLE_FRAMES) {
+ mPhaseFraction = 0;
+ mPhaseFraction1 = 0;
+ index = 0;
+ input = (short*)pbuf + frames * Chnum;
+ output = (short*)buffer + k * Chnum;
+ for (j = 0; j < RESAMPLE_FRAMES - resample_delta; j++) {
+ output[2 * j] = input[index * 2] + (short)((input[(index + 1) * 2] - input[index * 2]) * mPhaseFraction1);
+ output[2 * j + 1] = input[index * 2 + 1] + (short)((input[(index + 1) * 2 + 1] - input[index * 2 + 1]) * mPhaseFraction1);
+ mPhaseFraction += phaseIncrement;
+ index = mPhaseFraction;
+ mPhaseFraction1 = mPhaseFraction - index;
+ k++;
+ }
+ frames += RESAMPLE_FRAMES;
+ frame_read -= RESAMPLE_FRAMES;
+ }
+ if (frame_read > 0) {
+ memcpy((short*)buffer + k * Chnum, (short*)pbuf + frames * Chnum, frame_read * sizeof(short)* Chnum);
+ k += frame_read;
+ }
+
+
+ num_sample = k * sizeof(short) * Chnum;
+ *size = k * sizeof(short) * Chnum;
+ }
+ // adec_print("resample size from %d to %d, original %d\n", request, *size, dsp_read);
+}
+
+static int skip_thred = 400;
+static int up_thred = 100;
+static int dn_thred = 200;
+static int dn_resample_delta = 2;
+static int up_resample_delta = -4;
+static void set_wfd_pcm_thredhold()
+{
+
+ char value[PROPERTY_VALUE_MAX];
+ if (property_get("media.wfd.skip", value, NULL) > 0) {
+ skip_thred = atoi(value);
+ }
+ if (property_get("media.wfd.up", value, NULL) > 0) {
+ up_thred = atoi(value);
+ }
+ if (property_get("media.wfd.dn", value, NULL) > 0) {
+ dn_thred = atoi(value);
+ }
+ if (property_get("media.wfd.dn_delta", value, NULL) > 0) {
+ dn_resample_delta = atoi(value);
+ }
+ if (property_get("media.wfd.up_delta", value, NULL) > 0) {
+ up_resample_delta = atoi(value);
+ }
+}
+void *audio_wfd_decode_loop(void *args)
+{
+ int ret;
+ aml_audio_dec_t *audec;
+ audio_out_operations_t *aout_ops;
+ audio_decoder_operations_t *adec_ops;
+ short outbuf[2048];
+ int outlen = 0;
+ int write_size = 0;
+ int in_latency = 0;
+ int out_latency = 0;
+ int total_latency = 0;
+ int out_init_flag = 0;
+ char value[PROPERTY_VALUE_MAX];
+ unsigned char debug_latency = 0;
+ adec_print("audio_wfd_decode_loop start!\n");
+ audec = (aml_audio_dec_t *)args;
+ aout_ops = &audec->aout_ops;
+ adec_ops = audec->adec_ops;
+ if (property_get("media.wfd.debug_latency", value, NULL) > 0) {
+ debug_latency = atoi(value);
+ }
+ while (!audec->exit_decode_thread) {
+ outlen = 0;
+ // adec_refresh_pts(audec);
+ set_wfd_pcm_thredhold();
+ audec->decode_offset = adec_ops->decode(adec_ops, outbuf, &outlen, (char*)&in_latency, 0);
+
+ if (outlen > 0) {
+ if (!out_init_flag) {
+ if (wfd_out_init(adec_ops->samplerate, adec_ops->channels)) {
+ adec_print("wfd init pcm output device failed\n");
+ continue;
+ }
+ out_init_flag = 1;
+ }
+ out_latency = wfd_out_latency();
+ if (out_latency < 0) {
+ out_latency = 0;
+ }
+ total_latency = in_latency + out_latency;
+ audec->out_len_after_last_valid_pts += outlen;
+ if (debug_latency) {
+ adec_print("latency in %d ms,out %d ms.total %d ms\n", in_latency, out_latency, total_latency);
+ if (total_latency < 150) {
+ if (property_get("sys.pkginfo", value, NULL) > 0) {
+ adec_print("latency pkg info %s \n", value);
+ }
+ }
+ }
+ if (total_latency > skip_thred) {
+ if (debug_latency) {
+ adec_print(" total latency %d ms ,skip bytes %d \n", total_latency, outlen);
+ }
+ outlen = 0;
+ } else if (total_latency > dn_thred) {
+ audio_resample_api(outbuf, &outlen, 2, 1, dn_resample_delta);
+ } else if (total_latency < up_thred) {
+ audio_resample_api(outbuf, &outlen, 2, 1, up_resample_delta);
+ }
+ if (debug_latency) {
+ adec_print("wfd dec out %d byts pcm \n", outlen);
+ }
+ write_size = wfd_out_write(outbuf, outlen);
+ }
+ //TODO decode function
+ }
+ adec_print("exit audio_wfd_decode_loop Thread finished!\n");
+ pthread_exit(NULL);
+error:
+ pthread_exit(NULL);
+ return NULL;
+}
+
+
+/*
+ WFD audio decoder control thread
+*/
+void *adec_wfddec_msg_loop(void *args)
+{
+ int ret;
+ aml_audio_dec_t *audec;
+ audio_out_operations_t *aout_ops;
+ adec_cmd_t *msg = NULL;
+ audec = (aml_audio_dec_t *)args;
+ aout_ops = &audec->aout_ops;
+ adec_print("adec_wfddec_loop in \n");
+ while (!audec->need_stop) {
+ audec->state = INITING;
+ ret = wfd_audio_codec_init(audec);
+ if (ret == 0) {
+ {
+#ifdef OUT_USE_AUDIOTRACK
+ ret = aout_ops->init(audec);
+ if (ret) {
+ adec_print("WFD Audio out device init failed!\n");
+ wfd_audio_codec_release(audec);
+ continue;
+ }
+#endif
+ audec->state = INITTED;
+ start_wfd_decode_thread(audec);
+ start_adec(audec);
+ }
+ break;
+ }
+
+ if (!audec->need_stop) {
+ amthreadpool_thread_usleep(100000);
+ }
+ }
+
+ do {
+
+ adec_reset_track(audec);
+ adec_flag_check(audec);
+ msg = adec_get_message(audec);
+ if (!msg) {
+ amthreadpool_thread_usleep(100000);
+ continue;
+ }
+
+ switch (msg->ctrl_cmd) {
+ case CMD_START:
+
+ adec_print("Receive START Command!\n");
+ start_wfd_decode_thread(audec);
+ start_adec(audec);
+ break;
+
+ case CMD_PAUSE:
+
+ adec_print("Receive PAUSE Command!");
+ pause_adec(audec);
+ break;
+
+ case CMD_RESUME:
+
+ adec_print("Receive RESUME Command!");
+ resume_adec(audec);
+ break;
+
+ case CMD_STOP:
+
+ adec_print("Receive STOP Command!");
+ stop_adec(audec);
+ break;
+
+ case CMD_MUTE:
+
+ adec_print("Receive Mute Command!");
+ if (msg->has_arg) {
+ mute_adec(audec, msg->value.en);
+ }
+ break;
+
+ case CMD_SET_VOL:
+
+ adec_print("Receive Set Vol Command!");
+ if (msg->has_arg) {
+ adec_set_volume(audec, msg->value.volume);
+ }
+ break;
+ case CMD_SET_LRVOL:
+
+ adec_print("Receive Set LRVol Command!");
+ if (msg->has_arg) {
+ adec_set_lrvolume(audec, msg->value.volume, msg->value_ext.volume);
+ }
+ break;
+#if 0
+ case CMD_CHANL_SWAP:
+
+ adec_print("Receive Channels Swap Command!");
+ audio_hardware_ctrl(HW_CHANNELS_SWAP);
+ break;
+
+ case CMD_LEFT_MONO:
+
+ adec_print("Receive Left Mono Command!");
+ audio_hardware_ctrl(HW_LEFT_CHANNEL_MONO);
+ break;
+
+ case CMD_RIGHT_MONO:
+
+ adec_print("Receive Right Mono Command!");
+ audio_hardware_ctrl(HW_RIGHT_CHANNEL_MONO);
+ break;
+
+ case CMD_STEREO:
+
+ adec_print("Receive Stereo Command!");
+ audio_hardware_ctrl(HW_STEREO_MODE);
+ break;
+#endif
+ case CMD_RELEASE:
+
+ adec_print("Receive RELEASE Command!");
+ release_adec(audec);
+ break;
+
+ default:
+ adec_print("Unknow Command!");
+ break;
+
+ }
+
+ if (msg) {
+ adec_message_free(msg);
+ msg = NULL;
+ }
+ } while (audec->state != TERMINATED);
+
+ adec_print("Exit adec_wfddec_msg_loop!");
+ pthread_exit(NULL);
+ return NULL;
+}
+
+
+
diff --git a/amadec/adec_omx_brige.c b/amadec/adec_omx_brige.c
new file mode 100644
index 0000000..1ee68c2
--- a/dev/null
+++ b/amadec/adec_omx_brige.c
@@ -0,0 +1,284 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <dlfcn.h>
+
+#include <audio-dec.h>
+#include <adec-pts-mgt.h>
+#include <adec_write.h>
+#include "adec_omx_brige.h"
+#include <amthreadpool.h>
+#include "Amsysfsutils.h"
+#include "amconfigutils.h"
+
+#define LOG_TAG "Adec_omx_bridge"
+#define adec_print(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define SIZE_FOR_MX_BYPASS (48*1024) //about 0.25s for 48K_16bit
+
+int find_omx_lib(aml_audio_dec_t *audec)
+{
+ audio_decoder_operations_t *adec_ops = audec->adec_ops;
+ audec->StageFrightCodecEnableType = 0;
+ audec->parm_omx_codec_init = NULL;
+ audec->parm_omx_codec_read = NULL;
+ audec->parm_omx_codec_close = NULL;
+ audec->parm_omx_codec_start = NULL;
+ audec->parm_omx_codec_pause = NULL;
+ audec->parm_omx_codec_get_declen = NULL;
+ audec->parm_omx_codec_get_FS = NULL;
+ audec->parm_omx_codec_get_Nch = NULL;
+
+ if (audec->format == ACODEC_FMT_AC3) {
+#ifndef USE_ARM_AUDIO_DEC
+ audec->adec_ops->nOutBufSize = SIZE_FOR_MX_BYPASS;
+#endif
+ audec->StageFrightCodecEnableType = OMX_ENABLE_CODEC_AC3;
+ } else if (audec->format == ACODEC_FMT_EAC3) {
+#ifndef USE_ARM_AUDIO_DEC
+ audec->adec_ops->nOutBufSize = SIZE_FOR_MX_BYPASS;
+#endif
+ audec->StageFrightCodecEnableType = OMX_ENABLE_CODEC_EAC3;
+ } else if (audec->format == ACODEC_FMT_ALAC) {
+ audec->StageFrightCodecEnableType = OMX_ENABLE_CODEC_ALAC;
+ } else if (audec->format == ACODEC_FMT_MPEG || audec->format == ACODEC_FMT_MPEG1 || audec->format == ACODEC_FMT_MPEG2) {
+ if (0/*!am_getconfig_bool("media.libplayer.usemad")*/) {
+ audec->StageFrightCodecEnableType = OMX_ENABLE_CODEC_MPEG_LAYER_II; //mpeg1-3, new omx libmpg123
+ }
+ } else if (audec->format == ACODEC_FMT_WMA) {
+ audec->StageFrightCodecEnableType = OMX_ENABLE_CODEC_WMA;
+ } else if (audec->format == ACODEC_FMT_WMAPRO) {
+ audec->StageFrightCodecEnableType = OMX_ENABLE_CODEC_WMAPRO;
+ } else if (audec->format == ACODEC_FMT_DTS) {
+#ifndef USE_ARM_AUDIO_DEC
+ audec->adec_ops->nOutBufSize = SIZE_FOR_MX_BYPASS;
+#endif
+ audec->StageFrightCodecEnableType = OMX_ENABLE_CODEC_DTSHD;
+ } else if (audec->format == ACODEC_FMT_VORBIS) {
+ audec->StageFrightCodecEnableType = OMX_ENABLE_CODEC_VORBIS;
+ } else if (audec->format == ACODEC_FMT_TRUEHD) {
+ audec->StageFrightCodecEnableType = OMX_ENABLE_CODEC_TRUEHD;
+ } else if (audec->format == ACODEC_FMT_WMAVOI) {
+ audec->StageFrightCodecEnableType = OMX_ENABLE_CODEC_WMAVOI;
+ }
+
+ adec_print("%s %d audec->format=%d \n", __FUNCTION__, __LINE__, audec->format);
+
+ if (audec->StageFrightCodecEnableType) {
+ int *fd = NULL;
+ fd = dlopen("libamadec_omx_api.so", RTLD_NOW);
+ if (fd != NULL) {
+ audec->parm_omx_codec_init = dlsym(fd, "arm_omx_codec_init");
+ audec->parm_omx_codec_read = dlsym(fd, "arm_omx_codec_read");
+ audec->parm_omx_codec_close = dlsym(fd, "arm_omx_codec_close");
+ audec->parm_omx_codec_start = dlsym(fd, "arm_omx_codec_start");
+ audec->parm_omx_codec_pause = dlsym(fd, "arm_omx_codec_pause");
+ audec->parm_omx_codec_get_declen = dlsym(fd, "arm_omx_codec_get_declen");
+ audec->parm_omx_codec_get_FS = dlsym(fd, "arm_omx_codec_get_FS");
+ audec->parm_omx_codec_get_Nch = dlsym(fd, "arm_omx_codec_get_Nch");
+ } else {
+ adec_print("[NOTE]cant find libamadec_omx_api.so ,StageFrightCodecEnableType=0\n");
+ audec->StageFrightCodecEnableType = 0;
+ return 0;
+ }
+ }
+
+ if (audec->parm_omx_codec_init == NULL || audec->parm_omx_codec_read == NULL || audec->parm_omx_codec_close == NULL ||
+ audec->parm_omx_codec_start == NULL || audec->parm_omx_codec_pause == NULL || audec->parm_omx_codec_get_declen == NULL ||
+ audec->parm_omx_codec_get_FS == NULL || audec->parm_omx_codec_get_Nch == NULL
+ ) {
+ adec_print("[NOTE]load func_api in libamadec_omx_api.so faided, StageFrightCodecEnableType=0\n");
+ audec->StageFrightCodecEnableType = 0;
+ return 0;
+ }
+ adec_print("%s %d StageFrightCodecEnableType=%d \n", __FUNCTION__, __LINE__, audec->StageFrightCodecEnableType);
+ return audec->StageFrightCodecEnableType;
+}
+
+static char pcm_buf_tmp[AVCODEC_MAX_AUDIO_FRAME_SIZE];//max frame size out buf
+void omx_codec_Release();
+extern int read_buffer(unsigned char *buffer, int size);
+
+void *audio_decode_loop_omx(void *args)
+{
+ int ret;
+ aml_audio_dec_t *audec;
+ audio_out_operations_t *aout_ops;
+ audio_decoder_operations_t *adec_ops;
+
+ int nNextFrameSize = 0; //next read frame size
+ int nAudioFormat;
+ char *inbuf = NULL;//real buffer
+ int dlen = 0;//decode size one time
+ int outlen = 0;
+ char *outbuf = pcm_buf_tmp, *outbuf_raw;
+ int outlen_raw = 0;
+ int rawoutput_enable;
+ buffer_stream_t *g_bst, *g_bst_raw;
+ AudioInfo g_AudioInfo = {0};
+ adec_print("\n\naudio_decode_loop_omx start!\n");
+
+ audec = (aml_audio_dec_t *)args;
+ aout_ops = &audec->aout_ops;
+ adec_ops = audec->adec_ops;
+ memset(outbuf, 0, AVCODEC_MAX_AUDIO_FRAME_SIZE);
+ nAudioFormat = audec->format;
+ nNextFrameSize = adec_ops->nInBufSize;
+ g_bst = audec->g_bst;
+ g_bst_raw = audec->g_bst_raw;
+
+ rawoutput_enable = amsysfs_get_sysfs_int("/sys/class/audiodsp/digital_raw");
+ adec_print("rawoutput_enable/%d", rawoutput_enable);
+ if (rawoutput_enable == 1 && audec->StageFrightCodecEnableType == OMX_ENABLE_CODEC_TRUEHD) {
+ adec_print("truehd passthrough enable only when hdmi passthr\n");
+ rawoutput_enable = 0;
+ }
+ if (audec->parm_omx_codec_init && audec->parm_omx_codec_start) {
+ (*audec->parm_omx_codec_init)(audec, audec->StageFrightCodecEnableType, (void*)read_buffer, &audec->exit_decode_thread);
+ (*audec->parm_omx_codec_start)(audec);
+ } else {
+ audec->exit_decode_thread = 1;
+ adec_print("audio_decode_loop_omx start failed!");
+ }
+ audec->OmxFirstFrameDecoded = 0;
+ while (1) {
+exit_decode_loop:
+ if (audec->exit_decode_thread) { //detect quit condition
+ break;
+ }
+ outbuf = pcm_buf_tmp;
+ outlen = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+ (*audec->parm_omx_codec_read)(audec, outbuf, &outlen, &audec->exit_decode_thread);
+
+ outlen_raw = 0;
+ if (audec->StageFrightCodecEnableType == OMX_ENABLE_CODEC_DTSHD ||
+ audec->StageFrightCodecEnableType == OMX_ENABLE_CODEC_TRUEHD) {
+ int outlen0 = outlen;
+ if (outlen > 8) {
+ memcpy(&outlen, outbuf, 4);
+ outbuf += 4;
+ if (outlen + 8 < outlen0) {
+ memcpy(&outlen_raw, outbuf + outlen, 4);
+ outbuf_raw = outbuf + outlen + 4;
+ }
+ } else {
+ outlen = 0;
+ }
+ } else if ((audec->StageFrightCodecEnableType == OMX_ENABLE_CODEC_AC3) ||
+ (audec->StageFrightCodecEnableType == OMX_ENABLE_CODEC_EAC3)) {
+ if (outlen > 8) {
+ memcpy(&outlen, outbuf, 4);
+ outbuf += 4;
+ memcpy(&outlen_raw, outbuf + outlen, 4);
+ outbuf_raw = outbuf + outlen + 4;
+ memset(outbuf + outlen, 0, 4);
+ } else {
+ outlen = 0;
+ }
+ }
+ if (outlen > 0) {
+ memset(&g_AudioInfo, 0, sizeof(AudioInfo));
+ g_AudioInfo.channels = (*audec->parm_omx_codec_get_Nch)(audec);
+ g_AudioInfo.samplerate = (*audec->parm_omx_codec_get_FS)(audec);
+ if (g_AudioInfo.channels != 0 && g_AudioInfo.samplerate != 0) {
+ if (!audec->OmxFirstFrameDecoded) {
+ g_bst->channels = audec->channels = g_AudioInfo.channels;
+ g_bst->samplerate = audec->samplerate = g_AudioInfo.samplerate;
+ audec->OmxFirstFrameDecoded = 1;
+ } else if (audec->OmxFirstFrameDecoded == 1) {
+ if ((g_AudioInfo.channels != g_bst->channels) || (g_AudioInfo.samplerate != g_bst->samplerate)) {
+ while (audec->format_changed_flag && !audec->exit_decode_thread) {
+ amthreadpool_thread_usleep(20000);
+ }
+ if (!audec->exit_decode_thread) {
+ adec_print("Info Changed: src:sample:%d channel:%d dest sample:%d channel:%d \n",
+ g_bst->samplerate, g_bst->channels, g_AudioInfo.samplerate, g_AudioInfo.channels);
+ g_bst->channels = g_AudioInfo.channels;
+ g_bst->samplerate = g_AudioInfo.samplerate;
+ aout_ops->pause(audec);
+ audec->format_changed_flag = 1;
+ }
+ }
+ }
+ }
+ }
+ if (outlen > 0) {
+ dlen = (*audec->parm_omx_codec_get_declen)(audec);
+ } else {
+ dlen = 0;
+ }
+ //write to the pcm buffer
+ audec->decode_offset += dlen;
+ audec->pcm_cache_size = outlen;
+
+ if (g_bst) {
+ int wlen = 0;
+ while (outlen && !audec->exit_decode_thread) {
+ if ((g_bst->buf_length - g_bst->buf_level) < outlen) {
+ amthreadpool_thread_usleep(20000);
+ continue;
+ }
+ wlen = write_pcm_buffer(outbuf, g_bst, outlen);
+ outlen -= wlen;
+ audec->pcm_cache_size -= wlen;
+ }
+
+ while (rawoutput_enable && !audec->exit_decode_thread && outlen_raw && aout_ops->audio_out_raw_enable) {
+ if (g_bst_raw->buf_length - g_bst_raw->buf_level < outlen_raw) {
+ amthreadpool_thread_usleep(20000);
+ continue;
+ }
+ wlen = write_pcm_buffer(outbuf_raw, g_bst_raw, outlen_raw);
+ outlen_raw -= wlen;
+ }
+ }
+ }
+
+ adec_print("[%s %d] has stepped out decodeloop \n", __FUNCTION__, __LINE__);
+ if (audec->StageFrightCodecEnableType && audec->parm_omx_codec_close) {
+ (*audec->parm_omx_codec_close)(audec);
+ }
+ adec_print("Exit audio_decode_loop_omx Thread finished!");
+ pthread_exit(NULL);
+ return NULL;
+}
+
+
+void start_decode_thread_omx(aml_audio_dec_t *audec)
+{
+ int ret;
+ pthread_t tid;
+ int wait_aout_ops_start_time = 0;
+
+ ret = amthreadpool_pthread_create(&tid, NULL, (void *)audio_decode_loop_omx, (void *)audec);
+ if (ret != 0) {
+ adec_print("Create <audio_decode_loop_omx> thread failed!\n");
+ return;
+ }
+ audec->sn_threadid = tid;
+ pthread_setname_np(tid, "AmadecDecodeLP");
+ adec_print("Create <audio_decode_loop_omx> thread success! tid = %d\n", tid);
+
+ while ((!audec->need_stop) && (!audec->OmxFirstFrameDecoded)) {
+ amthreadpool_thread_usleep(50);
+ wait_aout_ops_start_time++;
+ }
+ adec_print("[%s] start thread finished: <audec->OmxFirstFrameDecoded=%d> used time: %d*50(us)\n", __FUNCTION__, audec->OmxFirstFrameDecoded, wait_aout_ops_start_time);
+
+}
+
+
+void stop_decode_thread_omx(aml_audio_dec_t *audec)
+{
+ audec->exit_decode_thread = 1;
+ int ret = amthreadpool_pthread_join(audec->sn_threadid, NULL);
+ //audec->exit_decode_thread = 0;
+ audec->sn_threadid = -1;
+ audec->sn_getpackage_threadid = -1;
+}
+
+
+
+
diff --git a/amadec/adec_omx_brige.h b/amadec/adec_omx_brige.h
new file mode 100644
index 0000000..d49d3e0
--- a/dev/null
+++ b/amadec/adec_omx_brige.h
@@ -0,0 +1,56 @@
+
+#ifndef __ADEC_OMXDDPDEC_BRIGE_H__
+#define __ADEC_OMXDDPDEC_BRIGE_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <dlfcn.h>
+
+#include <audio-dec.h>
+#include <adec-pts-mgt.h>
+#include <adec_write.h>
+
+
+
+enum OMX_CodecID {
+ OMX_ENABLE_CODEC_NULL = 0,
+ OMX_ENABLE_CODEC_AC3,
+ OMX_ENABLE_CODEC_EAC3,
+ OMX_ENABLE_CODEC_AMR_NB,
+ OMX_ENABLE_CODEC_AMR_WB,
+ OMX_ENABLE_CODEC_MPEG,
+ OMX_ENABLE_CODEC_MPEG_LAYER_I,
+ OMX_ENABLE_CODEC_MPEG_LAYER_II,
+ OMX_ENABLE_CODEC_AAC,
+ OMX_ENABLE_CODEC_QCELP,
+ OMX_ENABLE_CODEC_VORBIS,
+ OMX_ENABLE_CODEC_G711_ALAW,
+ OMX_ENABLE_CODEC_G711_MLAW,
+ OMX_ENABLE_CODEC_RAW,
+ OMX_ENABLE_CODEC_ADPCM_IMA,
+ OMX_ENABLE_CODEC_ADPCM_MS,
+ OMX_ENABLE_CODEC_FLAC,
+ OMX_ENABLE_CODEC_AAC_ADTS,
+ OMX_ENABLE_CODEC_ALAC,
+ OMX_ENABLE_CODEC_AAC_ADIF,
+ OMX_ENABLE_CODEC_AAC_LATM,
+ OMX_ENABLE_CODEC_ADTS_PROFILE,
+ OMX_ENABLE_CODEC_WMA,
+ OMX_ENABLE_CODEC_WMAPRO,
+ OMX_ENABLE_CONTAINER_WAV,
+ OMX_ENABLE_CONTAINER_AIFF,
+ OMX_ENABLE_CODEC_DTSHD,
+ OMX_ENABLE_CODEC_TRUEHD,
+ OMX_ENABLE_CODEC_WMAVOI,
+};
+
+
+void stop_decode_thread_omx(aml_audio_dec_t *audec);
+void start_decode_thread_omx(aml_audio_dec_t *audec);
+int find_omx_lib(aml_audio_dec_t *audec);
+#endif
+
diff --git a/amadec/adec_read.c b/amadec/adec_read.c
new file mode 100644
index 0000000..c1a9b57
--- a/dev/null
+++ b/amadec/adec_read.c
@@ -0,0 +1,200 @@
+#include <stdio.h>
+#include <string.h> // strcmp
+#include <time.h> // clock
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <sys/mman.h>
+#include <audio-dec.h>
+#include <adec-pts-mgt.h>
+#include <amthreadpool.h>
+
+#include "Amsysfsutils.h"
+#include "amconfigutils.h"
+
+
+#define ASTREAM_DEV "/dev/uio0"
+#define ASTREAM_ADDR "/sys/class/astream/astream-dev/uio0/maps/map0/addr"
+#define ASTREAM_SIZE "/sys/class/astream/astream-dev/uio0/maps/map0/size"
+#define ASTREAM_OFFSET "/sys/class/astream/astream-dev/uio0/maps/map0/offset"
+#define ADDR_OFFSET "/sys/class/astream/addr_offset"
+
+
+#define AIU_AIFIFO_CTRL 0x1580
+#define AIU_AIFIFO_STATUS 0x1581
+#define AIU_AIFIFO_GBIT 0x1582
+#define AIU_AIFIFO_CLB 0x1583
+#define AIU_MEM_AIFIFO_START_PTR 0x1584
+#define AIU_MEM_AIFIFO_CURR_PTR 0x1585
+#define AIU_MEM_AIFIFO_END_PTR 0x1586
+#define AIU_MEM_AIFIFO_BYTES_AVAIL 0x1587
+#define AIU_MEM_AIFIFO_CONTROL 0x1588
+#define AIU_MEM_AIFIFO_MAN_WP 0x1589
+#define AIU_MEM_AIFIFO_MAN_RP 0x158a
+#define AIU_MEM_AIFIFO_LEVEL 0x158b
+#define AIU_MEM_AIFIFO_BUF_CNTL 0x158c
+#define AIU_MEM_AIFIFO_BUF_WRAP_COUNT 0x158d
+#define AIU_MEM_AIFIFO2_BUF_WRAP_COUNT 0x158e
+#define AIU_MEM_AIFIFO_MEM_CTL 0x158f
+
+volatile unsigned* reg_base = 0;
+#define READ_MPEG_REG(reg) reg_base[reg-AIU_AIFIFO_CTRL]
+#define WRITE_MPEG_REG(reg, val) reg_base[reg-AIU_AIFIFO_CTRL]=val
+#define AIFIFO_READY (((READ_MPEG_REG(AIU_MEM_AIFIFO_CONTROL)&(1<<9))))
+#define min(x,y) ((x<y)?(x):(y))
+
+static volatile void *memmap = MAP_FAILED;
+static int phys_size = 0;
+
+static unsigned long get_num_infile(char *file)
+{
+ return amsysfs_get_sysfs_ulong(file);
+}
+
+int uio_init(aml_audio_dec_t *audec)
+{
+ // int fd = -1;
+ int pagesize = getpagesize();
+ int phys_start;
+ // int phys_size;
+ int phys_offset;
+ // volatile unsigned memmap;
+ int addr_offset;
+
+
+ audec->fd_uio = open(ASTREAM_DEV, O_RDWR);
+ if (audec->fd_uio < 0) {
+ adec_print("error open UIO 0\n");
+ return -1;
+ }
+ phys_start = get_num_infile(ASTREAM_ADDR);
+ phys_size = get_num_infile(ASTREAM_SIZE);
+ phys_offset = get_num_infile(ASTREAM_OFFSET);
+ addr_offset = get_num_infile(ADDR_OFFSET);
+
+ adec_print("add=%08x, size=%08x, phy_offset=%08x, addr_offset=%d\n",
+ phys_start, phys_size, phys_offset, addr_offset);
+
+ phys_size = (phys_size + pagesize - 1) & (~(pagesize - 1));
+ memmap = mmap(NULL, phys_size, PROT_READ | PROT_WRITE, MAP_SHARED, audec->fd_uio, 0 * pagesize);
+
+ adec_print("memmap = %x , pagesize = %x\n", memmap, pagesize);
+ if (memmap == MAP_FAILED) {
+ adec_print("map /dev/uio0 failed\n");
+ return -1;
+ }
+ if (phys_offset == 0)
+ phys_offset = ((AIU_AIFIFO_CTRL + addr_offset) << 2) & (pagesize - 1);
+ reg_base = memmap + phys_offset;
+ return 0;
+}
+
+int uio_deinit(aml_audio_dec_t *audec)
+{
+ if (audec->fd_uio >= 0) {
+ close(audec->fd_uio);
+ }
+ audec->fd_uio = -1;
+
+ if (memmap != NULL && memmap != MAP_FAILED) {
+ munmap(memmap, phys_size);
+ }
+ adec_print("audio_dec_release done \n");
+ return 0;
+}
+
+
+static inline void waiting_bits(int bits)
+{
+ int bytes;
+ bytes = READ_MPEG_REG(AIU_MEM_AIFIFO_BYTES_AVAIL);
+ while (bytes * 8 < bits) {
+ if (amthreadpool_on_requare_exit(0)) {
+ break;
+ }
+ amthreadpool_thread_usleep(1000);
+ bytes = READ_MPEG_REG(AIU_MEM_AIFIFO_BYTES_AVAIL);
+ }
+}
+
+
+#define EXTRA_DATA_SIZE 128
+int read_buffer(unsigned char *buffer, int size)
+{
+ int bytes;
+ int len;
+ unsigned char *p = buffer;
+ int tmp;
+ int space;
+ int i;
+ int wait_times = 0, fifo_ready_wait = 0;
+
+ int iii;
+
+ iii = READ_MPEG_REG(AIU_MEM_AIFIFO_LEVEL) - EXTRA_DATA_SIZE;
+ // adec_print("read_buffer start iii = %d!!\n", iii);
+
+ static int cc = 0;
+ len = 0;
+#if 0
+ while (size >= iii) {
+ cc++ ;
+ amthreadpool_thread_usleep(1000);
+ iii = READ_MPEG_REG(AIU_MEM_AIFIFO_LEVEL) - EXTRA_DATA_SIZE;
+ if (cc % 2000 == 0) {
+ adec_print("read_buffer start in while iii = %d!!exit_decode_thread:%d \n", iii, exit_decode_thread);
+ }
+ if (exit_decode_thread) {
+ goto out;
+ }
+ }
+#endif
+ if ((size >= iii)) {
+ return 0;
+ }
+
+ // adec_print("read_buffer start while iii= %d!!\n", iii);
+ for (len = 0; len < size;) {
+ space = (size - len);
+ bytes = READ_MPEG_REG(AIU_MEM_AIFIFO_BYTES_AVAIL);
+ //adec_print("read_buffer start AIU_MEM_AIFIFO_BYTES_AVAIL bytes= %d!!\n", bytes);
+ wait_times = 0;
+ while (bytes == 0) {
+ waiting_bits((space > 128) ? 128 * 8 : (space * 8)); /*wait 32 bytes,if the space is less than 32 bytes,wait the space bits*/
+ bytes = READ_MPEG_REG(AIU_MEM_AIFIFO_BYTES_AVAIL);
+
+ adec_print("read_buffer while AIU_MEM_AIFIFO_BYTES_AVAIL = %d!!\n", bytes);
+ wait_times++;
+ if (wait_times > 10 || amthreadpool_on_requare_exit(0)) {
+ adec_print("goto out!!\n");
+ goto out;
+ }
+ }
+ bytes = min(space, bytes);
+
+ //adec_print("read_buffer while bytes = %d!!\n", bytes);
+ for (i = 0; i < bytes; i++) {
+ while (!AIFIFO_READY) {
+ fifo_ready_wait++;
+ amthreadpool_thread_usleep(1000);
+ if (fifo_ready_wait > 100 || amthreadpool_on_requare_exit(0)) {
+ adec_print("FATAL err,AIFIFO is not ready,check!!\n");
+ return 0;
+ }
+ }
+ WRITE_MPEG_REG(AIU_AIFIFO_GBIT, 8);
+ tmp = READ_MPEG_REG(AIU_AIFIFO_GBIT);
+ //adec_print("read_buffer while tmp = %d!!\n", tmp);
+
+ *p++ = tmp & 0xff;
+ fifo_ready_wait = 0;
+
+ }
+ len += bytes;
+ }
+out:
+ //stream_in_offset+=len;
+ return len;
+}
+
+
diff --git a/amadec/adec_reg.h b/amadec/adec_reg.h
new file mode 100644
index 0000000..799c1b3
--- a/dev/null
+++ b/amadec/adec_reg.h
@@ -0,0 +1,76 @@
+//-----------------------------------------------------------------------------
+// add for AIFIFO channel (old $cdrom/rtl/cdr_top/getbit)
+//-----------------------------------------------------------------------------
+// Bit 3 CRC pop aififo enable
+// Bit 2 writing to this bit to 1 causes CRC module reset
+// Bit 1 enable aififo
+// Bit 0 writing to this bit to 1 causes aififo soft reset
+#define AIU_AIFIFO_CTRL 0x1580
+//'h0000
+// AIFIFO status register
+// Bit 13 //aififo request to dcu status
+// Bit 12 //dcu select status
+// Bit 11:5 //aififo word counter number
+// Bit 4:0 //how many bits left in the first pop register
+#define AIU_AIFIFO_STATUS 0x1581
+// Same fucntion as the AIGBIT of AIFIFO in CDROM module
+// write to this register how many bits wanna pop,
+// and reading this register gets the corresponding bits data
+#define AIU_AIFIFO_GBIT 0x1582
+// Same function as the AICLB of AIFIFO in CDROM module
+// return the leading zeros by reading this registers
+#define AIU_AIFIFO_CLB 0x1583
+// --------------------------------------------
+// AIFIFO DDR Interface
+// --------------------------------------------
+// The AIFIFO start pointer into DDR memory is a 32-bit number
+// The Start pointer will automatically be truncated to land on
+// an 8-byte boundary. That is, bits [2:0] = 0;
+#define AIU_MEM_AIFIFO_START_PTR 0x1584
+// The current pointer points so some location between the START and END
+// pointers. The current pointer is a BYTE pointer. That is, you can
+// point to any BYTE address within the START/END range
+#define AIU_MEM_AIFIFO_CURR_PTR 0x1585
+#define AIU_MEM_AIFIFO_END_PTR 0x1586
+#define AIU_MEM_AIFIFO_BYTES_AVAIL 0x1587
+// AIFIFO FIFO Control
+// bit [15:11] unused
+// bit [10] use_level Set this bit to 1 to enable filling of the FIFO controlled by the buffer
+// level control. If this bit is 0, then use bit[1] to control the enabling of filling
+// bit [9] Data Ready. This bit is set when data can be popped
+// bit [8] fill busy This bit will be high when we're fetching data from the DDR memory
+// To reset this module, set cntl_enable = 0, and then wait for busy = 0.
+// After that you can pulse cntl_init to start over
+// bit [7] cntl_endian_jic Just in case endian. last minute byte swap of the data out of
+// the FIFO to getbit
+// bit [6] unused
+// bits [5:3] endian: see $lib/rtl/ddr_endian.v
+// bit [2] cntl_empty_en Set to 1 to enable reading the DDR memory FIFO and filling the pipeline to get-bit
+// Set cntl_empty_en = cntl_fill_en = 0 when pulsing cntl_init
+// bit [1] cntl_fill_en Set to 1 to enable reading data from DDR memory
+// bit [0] cntl_init: After setting the read pointers, sizes, channel masks
+// and read masks, set this bit to 1 and then to 0
+// NOTE: You don't need to pulse cntl_init if only the start address is
+// being changed
+#define AIU_MEM_AIFIFO_CONTROL 0x1588
+// --------------------------------------------
+// AIFIFO Buffer Level Manager
+// --------------------------------------------
+#define AIU_MEM_AIFIFO_MAN_WP 0x1589
+#define AIU_MEM_AIFIFO_MAN_RP 0x158a
+#define AIU_MEM_AIFIFO_LEVEL 0x158b
+//
+// bit [1] manual mode Set to 1 for manual write pointer mode
+// bit [0] Init Set high then low after everything has been initialized
+#define AIU_MEM_AIFIFO_BUF_CNTL 0x158c
+
+#define AIU_MEM_AIFIFO_BUF_WRAP_COUNT 0x158d
+#define AIU_MEM_AIFIFO2_BUF_WRAP_COUNT 0x158e
+// bit 29:24 A_brst_num
+// bit 21:16 A_id
+// bit 15:0 level_hold
+#define AIU_MEM_AIFIFO_MEM_CTL 0x158f
+
+int uio_init(aml_audio_dec_t *audec);
+int uio_deinit(aml_audio_dec_t *audec);
+
diff --git a/amadec/adec_write.c b/amadec/adec_write.c
new file mode 100644
index 0000000..0cad7fe
--- a/dev/null
+++ b/amadec/adec_write.c
@@ -0,0 +1,189 @@
+#include <adec_write.h>
+
+int init_buff(buffer_stream_t *bs, int length)
+{
+ //unsigned char *buffer=malloc(DEFAULT_BUFFER_SIZE);
+ unsigned char *buffer = malloc(length);
+ if (!buffer) {
+ printf("Err:malloc failed \n");
+ bs->data = NULL;
+ return -1;
+ }
+ bs->data = buffer;
+ //bs->buf_length=DEFAULT_BUFFER_SIZE;
+ bs->buf_length = length;
+ bs->buf_level = 0;
+ bs->rd_ptr = bs->wr_ptr = bs->data;
+ bs->bInited = 1;
+ bs->nMutex = 1;
+ pthread_mutex_init(&bs->nMutex1, NULL);
+ return 1;
+}
+
+int reset_buffer(buffer_stream_t *bs)
+{
+ if (bs->bInited == 0) {
+ return -1;
+ }
+ //bs->buf_length=DEFAULT_BUFFER_SIZE;
+ bs->buf_level = 0;
+ bs->rd_ptr = bs->wr_ptr = bs->data;
+ bs->nMutex = 1;
+ return 0;
+}
+
+int release_buffer(buffer_stream_t *bs)
+{
+ if (bs->data) {
+ free(bs->data);
+ }
+ free(bs);
+ bs = NULL;
+ return 1;
+}
+
+//1 empty 0 not empty -1 not inited
+int is_buffer_empty(buffer_stream_t *bs)
+{
+ if (bs->bInited == 0) {
+ return -1;
+ }
+ if (bs->buf_level == 0) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+//1 full 0 not full -1 not inited
+int is_buffer_full(buffer_stream_t *bs)
+{
+ if (bs->bInited == 0) {
+ return -1;
+ }
+ if (bs->buf_level == bs->buf_length) {
+ return 1;
+ } else {
+ return 0;
+ }
+
+}
+
+int get_buffer_length(buffer_stream_t *bs)
+{
+ if (bs->bInited == 0) {
+ return -1;
+ }
+ return bs->buf_level;
+}
+
+static int read_data(char * out, buffer_stream_t *bs, int size)
+{
+ if (bs->bInited == 0) {
+ return -1; //read failed
+ }
+ int ret = is_buffer_empty(bs);
+ if (ret == 1) {
+ //printf("=====buffer empty \n");
+ return 0;//buffer empty
+ }
+ int len = MIN(bs->buf_level, size);
+ if (bs->wr_ptr > bs->rd_ptr) {
+ memcpy(out, bs->rd_ptr, len);
+ bs->rd_ptr += len;
+ bs->buf_level -= len;
+ if (bs->rd_ptr == (bs->data + bs->buf_length)) {
+ bs->rd_ptr = bs->data;
+ }
+ //printf("=====read ok: condition 1 read :%d byte \n",len);
+ return len;
+ } else if (len < (bs->data + bs->buf_length - bs->rd_ptr)) {
+ memcpy(out, bs->rd_ptr, len);
+ bs->rd_ptr += len;
+ bs->buf_level -= len;
+ if (bs->rd_ptr == (bs->data + bs->buf_length)) {
+ bs->rd_ptr = bs->data;
+ }
+ //printf("=====read ok: condition 2 read :%d byte \n",len);
+ return len;
+
+ } else {
+ int tail_len = (bs->data + bs->buf_length - bs->rd_ptr);
+ memcpy(out, bs->rd_ptr, tail_len);
+ memcpy(out + tail_len, bs->data, len - tail_len);
+ bs->rd_ptr = bs->data + len - tail_len;
+ bs->buf_level -= len;
+ if (bs->rd_ptr == (bs->data + bs->buf_length)) {
+ bs->rd_ptr = bs->data;
+ }
+ //printf("=====read ok: condition 3 read :%d byte \n",len);
+ return len;
+ }
+
+}
+
+int read_pcm_buffer(char * out, buffer_stream_t *bs, int size)
+{
+ int ret = 0;
+ pthread_mutex_lock(&bs->nMutex1);
+ ret = read_data(out, bs, size);
+ pthread_mutex_unlock(&bs->nMutex1);
+ return ret;
+}
+static int write_data(char *in, buffer_stream_t *bs, int size)
+{
+ if (bs->bInited == 0) {
+ return -1; //not inited
+ }
+ int ret = is_buffer_full(bs);
+ if (ret == 1) {
+
+ //printf("=====buffer full \n");
+ return 0;//buffer full
+ }
+ //start write data
+ int len = MIN(bs->buf_length - bs->buf_level, size);
+ if (bs->wr_ptr < bs->rd_ptr) {
+ memcpy(bs->wr_ptr, in, len);
+ bs->wr_ptr += len;
+ bs->buf_level += len;
+ if (bs->wr_ptr == (bs->data + bs->buf_length)) {
+ bs->wr_ptr = bs->data;
+ }
+ //printf("=====write ok: condition 1 write :%d byte \n",len);
+ return len;
+ } else if (len < (bs->data + bs->buf_length - bs->wr_ptr)) {
+ memcpy(bs->wr_ptr, in, len);
+ bs->wr_ptr += len;
+ bs->buf_level += len;
+ if (bs->wr_ptr == (bs->data + bs->buf_length)) {
+ bs->wr_ptr = bs->data;
+ }
+ //printf("=====write ok: condition 2 write :%d byte \n",len);
+ return len;
+
+ } else {
+ int tail_len = (bs->data + bs->buf_length - bs->wr_ptr);
+ memcpy(bs->wr_ptr, in, tail_len);
+ memcpy(bs->data, in + tail_len, len - tail_len);
+ bs->wr_ptr = bs->data + len - tail_len;
+ bs->buf_level += len;
+ if (bs->wr_ptr == (bs->data + bs->buf_length)) {
+ bs->wr_ptr = bs->data;
+ }
+ //printf("=====write ok: condition 3 write :%d byte \n",len);
+ return len;
+ }
+
+}
+
+int write_pcm_buffer(char * in, buffer_stream_t *bs, int size)
+{
+ int ret = 0;
+ pthread_mutex_lock(&bs->nMutex1);
+ ret = write_data(in, bs, size);
+ pthread_mutex_unlock(&bs->nMutex1);
+ return ret;
+}
+
+
+
diff --git a/amadec/adec_write.h b/amadec/adec_write.h
new file mode 100644
index 0000000..7c7376e
--- a/dev/null
+++ b/amadec/adec_write.h
@@ -0,0 +1,42 @@
+
+#ifndef __ADEC_WRITE_H__
+#define __ADEC_WRITE_H__
+
+#include <pthread.h>
+#include <stdlib.h>
+#include<stdio.h>
+#include <string.h>
+
+#define DEFAULT_BUFFER_SIZE 1024*1024
+#define MIN(a,b) (a>b)?b:a
+
+typedef struct buffer_stream_st {
+ int buf_length;
+ int buf_level;
+ unsigned char * data;
+ unsigned char * rd_ptr;
+ unsigned char * wr_ptr;
+ int bInited;
+ int nMutex;
+ int data_width;
+ int channels;
+ int samplerate;
+ int format;
+ pthread_mutex_t nMutex1;
+
+} buffer_stream_t;
+
+int init_buff(buffer_stream_t *bs, int length);
+int reset_buffer(buffer_stream_t *bs);
+int release_buffer(buffer_stream_t *bs);
+
+int is_buffer_empty(buffer_stream_t *bs);
+
+int is_buffer_full(buffer_stream_t *bs);
+int get_buffer_length(buffer_stream_t *bs);
+int read_pcm_buffer(char * out, buffer_stream_t *bs, int size);
+int write_pcm_buffer(char * in, buffer_stream_t *bs, int size);
+int get_pcmbuf_level();
+
+
+#endif
diff --git a/amadec/audio-dec.h b/amadec/audio-dec.h
new file mode 100644
index 0000000..13c7935
--- a/dev/null
+++ b/amadec/audio-dec.h
@@ -0,0 +1,314 @@
+/**
+ * \file audio-dec.h
+ * \brief Definitiond Of Audio Dec Types And Structures
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#ifndef AUDIO_DEC_H
+#define AUDIO_DEC_H
+
+#include<pthread.h>
+
+#include <audio-out.h>
+#include <audiodsp.h>
+#include <system/audio.h>
+#include <adec-types.h>
+#include <adec-message.h>
+#include <log-print.h>
+#include <adec-armdec-mgt.h>
+#include <adec_write.h>
+ADEC_BEGIN_DECLS
+
+#define AUDIO_CTRL_DEVICE "/dev/amaudio_ctl"
+
+#define AMAUDIO_IOC_MAGIC 'A'
+#define AMAUDIO_IOC_SET_LEFT_MONO _IOW(AMAUDIO_IOC_MAGIC, 0x0e, int)
+#define AMAUDIO_IOC_SET_RIGHT_MONO _IOW(AMAUDIO_IOC_MAGIC, 0x0f, int)
+#define AMAUDIO_IOC_SET_STEREO _IOW(AMAUDIO_IOC_MAGIC, 0x10, int)
+#define AMAUDIO_IOC_SET_CHANNEL_SWAP _IOW(AMAUDIO_IOC_MAGIC, 0x11, int)
+
+//should in accordance with ../amcodec/include/amports/amstream.h
+#define AMAUDIO_IOC_SET_RESAMPLE_DELTA _IOW(AMAUDIO_IOC_MAGIC, 0x1d, unsigned long)
+
+//for ffmpeg audio decode
+#define AMSTREAM_IOC_MAGIC 'S'
+#define AMSTREAM_IOC_APTS_LOOKUP _IOR(AMSTREAM_IOC_MAGIC, 0x81, int)
+#define GET_FIRST_APTS_FLAG _IOR(AMSTREAM_IOC_MAGIC, 0x82, int)
+
+//-----------------------------------------------
+//copy from file: "../amcodec/include/amports/amstream.h"
+#ifndef AMSTREAM_IOC_PCRSCR
+#define AMSTREAM_IOC_PCRSCR _IOR(AMSTREAM_IOC_MAGIC, 0x42, int)
+#endif
+#ifndef AMSTREAM_IOC_SET_APTS
+#define AMSTREAM_IOC_SET_APTS _IOW(AMSTREAM_IOC_MAGIC, 0xa8, int)
+#endif
+
+//-----------------------------------------------
+
+
+/*******************************************************************************************/
+
+typedef struct aml_audio_dec aml_audio_dec_t;
+#define DECODE_ERR_PATH "/sys/class/audiodsp/codec_fatal_err"
+#define DECODE_NONE_ERR 0
+#define DECODE_INIT_ERR 1
+#define DECODE_FATAL_ERR 2
+#define lock_t pthread_mutex_t
+#define lp_lock_init(x,v) pthread_mutex_init(x,v)
+#define lp_lock(x) pthread_mutex_lock(x)
+#define lp_unlock(x) pthread_mutex_unlock(x)
+typedef enum {
+ HW_STEREO_MODE = 0,
+ HW_LEFT_CHANNEL_MONO,
+ HW_RIGHT_CHANNEL_MONO,
+ HW_CHANNELS_SWAP,
+} hw_command_t;
+struct package {
+ char *data;//buf ptr
+ int size; //package size
+ struct package * next;//next ptr
+};
+
+typedef struct {
+ struct package *first;
+ int pack_num;
+ struct package *current;
+ lock_t tslock;
+} Package_List;
+
+typedef struct adec_thread_mgt {
+ pthread_mutex_t pthread_mutex;
+ pthread_cond_t pthread_cond;
+ pthread_t pthread_id;
+} adec_thread_mgt_t;
+
+typedef struct {
+ char buff[10];
+ int size;
+ int status;//0 init 1 finding sync word 2 finding framesize 3 frame size found
+} StartCode;
+typedef void (*fp_arm_omx_codec_init)(aml_audio_dec_t*, int, void*, int*);
+typedef void (*fp_arm_omx_codec_read)(aml_audio_dec_t*, unsigned char *, unsigned *, int *);
+typedef void (*fp_arm_omx_codec_close)(aml_audio_dec_t*);
+typedef void (*fp_arm_omx_codec_start)(aml_audio_dec_t*);
+typedef void (*fp_arm_omx_codec_pause)(aml_audio_dec_t*);
+typedef int (*fp_arm_omx_codec_get_declen)(aml_audio_dec_t*);
+typedef int (*fp_arm_omx_codec_get_FS)(aml_audio_dec_t*);
+typedef int (*fp_arm_omx_codec_get_Nch)(aml_audio_dec_t*);
+typedef int (*fp_arm_omx_codex_read_assoc_data)(aml_audio_dec_t *,unsigned char *, int, int *);
+
+struct aml_audio_dec {
+ adec_state_t state;
+ pthread_t thread_pid;
+ adec_audio_format_t format;
+ int channels;
+ int samplerate;
+ int data_width;
+ int bitrate;
+ int block_align;
+ int codec_id;
+ int need_stop;
+ int auto_mute;
+ int muted;
+ int decoded_nb_frames;
+ int avsync_threshold;
+ float volume; //left or main volume
+ float volume_ext; //right
+ float pre_gain; //gain scope[-12dB,12dB]
+ int pre_gain_enable;
+ uint pre_mute;
+ int64_t refresh_pts_readytime_ms;
+ //codec_para_t *pcodec;
+ hw_command_t soundtrack;
+ audio_out_operations_t aout_ops;
+ dsp_operations_t adsp_ops;
+ message_pool_t message_pool;
+ audio_decoder_operations_t *adec_ops;//non audiodsp decoder operations
+ int extradata_size; ///< extra data size
+ char extradata[AUDIO_EXTRA_DATA_SIZE];
+ audio_session_t SessionID;
+ int format_changed_flag;
+ unsigned dspdec_not_supported;//check some profile that audiodsp decoder can not support,we switch to arm decoder
+ int droppcm_flag; // drop pcm flag, if switch audio (1)
+ int no_first_apts; // if can't get the first apts (1), default (0)
+ int apts_start_flag;
+ uint64_t first_apts;
+ int StageFrightCodecEnableType;
+ int64_t pcm_bytes_readed;
+ int64_t raw_bytes_readed;
+ float codec_type;
+ int raw_frame_size;
+ int pcm_frame_size;
+ int i2s_iec958_sync_flag;
+ int max_bytes_readded_diff;
+ int i2s_iec958_sync_gate;
+
+ buffer_stream_t *g_bst;
+ buffer_stream_t *g_bst_raw;
+ pthread_t sn_threadid;//same as the def: 'pthread_t thread_pid;'
+ pthread_t sn_getpackage_threadid;//same as the def: 'pthread_t thread_pid;'
+ int exit_decode_thread;
+ int exit_decode_thread_success;
+ unsigned long decode_offset;
+ int64_t decode_pcm_offset;
+ int use_get_out_posion;
+ int nDecodeErrCount;
+ int fd_uio;
+ uint64_t last_valid_pts;
+ int out_len_after_last_valid_pts;
+ int64_t last_out_postion;
+ int64_t last_get_postion_time_us;
+ int pcm_cache_size;
+ Package_List pack_list;
+ StartCode start_code;
+
+ void *arm_omx_codec;
+ fp_arm_omx_codec_init parm_omx_codec_init;
+ fp_arm_omx_codec_read parm_omx_codec_read ;
+ fp_arm_omx_codec_close parm_omx_codec_close;
+ fp_arm_omx_codec_start parm_omx_codec_start;
+ fp_arm_omx_codec_pause parm_omx_codec_pause;
+ fp_arm_omx_codec_get_declen parm_omx_codec_get_declen;
+ fp_arm_omx_codec_get_FS parm_omx_codec_get_FS;
+ fp_arm_omx_codec_get_Nch parm_omx_codec_get_Nch;
+ int OmxFirstFrameDecoded;
+ int tsync_mode;
+ adec_thread_mgt_t thread_mgt;
+ int dtshdll_flag;
+ int first_apts_lookup_over;
+ int audio_decoder_enabled; // if the audio decoder is enabled. if not enabled, muted pcm are output
+
+ //dvb pcr master
+ int fill_trackzero_thrsh;
+ int droppcm_ms;
+ int adis_flag;
+ int tsync_pcr_dispoint;
+ int pcrtsync_enable;
+ int pcrmaster_droppcm_thsh;
+ int64_t pcrscr64;
+ int64_t apts64;
+ int64_t last_apts64;
+ int64_t last_pcrscr64;
+ int mix_lr_channel_enable;
+
+ //code to handle small pts discontinue (1s < diff < 3s )
+ int last_discontinue_apts;//the apts when audio has little discontinue
+ int apts_reset_scr_delay_ms;
+ int64_t last_discontinue_time; //the time when littile discontinue happens
+
+ int VersionNum;
+ int DTSHDIEC958_FS;
+ int DTSHDIEC958_PktFrmSize;
+ int DTSHDIEC958_PktType;
+ int DTSHDPCM_SamsInFrmAtMaxSR;
+ unsigned int has_video;
+ int associate_dec_supported;//support associate or not
+ unsigned int associate_audio_enable;//control output associate audio
+ buffer_stream_t *g_assoc_bst;
+ fp_arm_omx_codex_read_assoc_data parm_omx_codec_read_assoc_data;
+ int mixing_level;//def=50, mixing level between main and associate, [0,100]
+};
+
+//from amcodec
+typedef struct {
+ int sample_rate; ///< audio stream sample rate
+ int channels; ///< audio stream channels
+ int format; ///< codec format id
+ int bitrate;
+ int block_align;
+ int codec_id; //original codecid corespingding to ffmepg
+ int handle; ///< codec device handler
+ int extradata_size; ///< extra data size
+ char extradata[AUDIO_EXTRA_DATA_SIZE];
+ int SessionID;
+ int dspdec_not_supported;//check some profile that audiodsp decoder can not support,we switch to arm decoder
+ int droppcm_flag; // drop pcm flag, if switch audio (1)
+ int automute;
+ unsigned int has_video;
+ int associate_dec_supported;//support associate or not
+ int mixing_level;//def=50, mixing level between main and associate, [0,100]
+} arm_audio_info;
+
+typedef struct {
+ int valid; ///< audio extradata valid(1) or invalid(0), set by dsp
+ int sample_rate; ///< audio stream sample rate
+ int channels; ///< audio stream channels
+ int bitrate; ///< audio stream bit rate
+ int codec_id; ///< codec format id
+ int block_align; ///< audio block align from ffmpeg
+ int extradata_size; ///< extra data size
+ char extradata[512];; ///< extra data information for decoder
+} Asf_audio_info_t;
+
+//status check
+struct adec_status {
+ unsigned int channels;
+ unsigned int sample_rate;
+ unsigned int resolution;
+ unsigned int error_count;
+ unsigned int status;
+};
+
+//audio decoder type, default arc
+#define AUDIO_ARC_DECODER 0
+#define AUDIO_ARM_DECODER 1
+#define AUDIO_FFMPEG_DECODER 2
+#define AUDIO_ARMWFD_DECODER 3
+
+//reference from " /amcodec/include/amports/aformat.h"
+#define ACODEC_FMT_NULL -1
+#define ACODEC_FMT_MPEG 0
+#define ACODEC_FMT_PCM_S16LE 1
+#define ACODEC_FMT_AAC 2
+#define ACODEC_FMT_AC3 3
+#define ACODEC_FMT_ALAW 4
+#define ACODEC_FMT_MULAW 5
+#define ACODEC_FMT_DTS 6
+#define ACODEC_FMT_PCM_S16BE 7
+#define ACODEC_FMT_FLAC 8
+#define ACODEC_FMT_COOK 9
+#define ACODEC_FMT_PCM_U8 10
+#define ACODEC_FMT_ADPCM 11
+#define ACODEC_FMT_AMR 12
+#define ACODEC_FMT_RAAC 13
+#define ACODEC_FMT_WMA 14
+#define ACODEC_FMT_WMAPRO 15
+#define ACODEC_FMT_PCM_BLURAY 16
+#define ACODEC_FMT_ALAC 17
+#define ACODEC_FMT_VORBIS 18
+#define ACODEC_FMT_AAC_LATM 19
+#define ACODEC_FMT_APE 20
+#define ACODEC_FMT_EAC3 21
+#define ACODEC_FMT_WIFIDISPLAY 22
+#define ACODEC_FMT_DRA 23
+#define ACODEC_FMT_TRUEHD 25
+#define ACODEC_FMT_MPEG1 26 //AFORMAT_MPEG-->mp3,AFORMAT_MPEG1-->mp1,AFROMAT_MPEG2-->mp2
+#define ACODEC_FMT_MPEG2 27
+#define ACODEC_FMT_WMAVOI 28
+
+
+
+
+
+/***********************************************************************************************/
+extern void android_basic_init(void);
+int audiodec_init(aml_audio_dec_t *aml_audio_dec);
+int adec_message_pool_init(aml_audio_dec_t *);
+adec_cmd_t *adec_message_alloc(void);
+int adec_message_free(adec_cmd_t *);
+int adec_send_message(aml_audio_dec_t *, adec_cmd_t *);
+adec_cmd_t *adec_get_message(aml_audio_dec_t *);
+int feeder_init(aml_audio_dec_t *);
+int feeder_release(aml_audio_dec_t *);
+void *adec_armdec_loop(void *args);
+void *adec_wfddec_msg_loop(void *args);
+int adec_thread_wait(aml_audio_dec_t *audec, int microseconds);
+int adec_thread_wakeup(aml_audio_dec_t *audec);
+
+ADEC_END_DECLS
+#endif
diff --git a/amadec/audio_out/alsa-out.c b/amadec/audio_out/alsa-out.c
new file mode 100644
index 0000000..388e516
--- a/dev/null
+++ b/amadec/audio_out/alsa-out.c
@@ -0,0 +1,1082 @@
+/**
+ * \file alsa-out.c
+ * \brief Functions of Auduo output control for Linux Platform
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <linux/soundcard.h>
+//#include <config.h>
+#include <asoundlib.h>
+
+#include <audio-dec.h>
+#include <adec-pts-mgt.h>
+#include <log-print.h>
+#include <alsa-out.h>
+#include <amthreadpool.h>
+#include <cutils/properties.h>
+
+
+#define USE_INTERPOLATION
+
+static snd_pcm_sframes_t (*readi_func)(snd_pcm_t *handle, void *buffer, snd_pcm_uframes_t size);
+static snd_pcm_sframes_t (*writei_func)(snd_pcm_t *handle, const void *buffer, snd_pcm_uframes_t size);
+static snd_pcm_sframes_t (*readn_func)(snd_pcm_t *handle, void **bufs, snd_pcm_uframes_t size);
+static snd_pcm_sframes_t (*writen_func)(snd_pcm_t *handle, void **bufs, snd_pcm_uframes_t size);
+
+static float alsa_default_vol = 1.0;
+static int hdmi_out = 0;
+static int fragcount = 16;
+static snd_pcm_uframes_t chunk_size = 1024;
+static char output_buffer[64 * 1024];
+static unsigned char decode_buffer[OUTPUT_BUFFER_SIZE + 64];
+#define PERIOD_SIZE 1024
+#define PERIOD_NUM 4
+
+#ifdef USE_INTERPOLATION
+static int pass1_history[8][8];
+#pragma align_to(64,pass1_history)
+static int pass2_history[8][8];
+#pragma align_to(64,pass2_history)
+static short pass1_interpolation_output[0x4000];
+#pragma align_to(64,pass1_interpolation_output)
+static short interpolation_output[0x8000];
+#pragma align_to(64,interpolation_output)
+static int tv_mode = 0;
+static int getprop_bool(const char * path)
+{
+ char buf[PROPERTY_VALUE_MAX];
+ int ret = -1;
+ ret = property_get(path, buf, NULL);
+ if (ret > 0) {
+ if (strcasecmp(buf,"true") == 0 || strcmp(buf,"1") == 0)
+ return 1;
+ }
+ return 0;
+}
+static inline short CLIPTOSHORT(int x)
+{
+ short res;
+#if 0
+ __asm__ __volatile__(
+ "min r0, %1, 0x7fff\r\n"
+ "max r0, r0, -0x8000\r\n"
+ "mov %0, r0\r\n"
+ :"=r"(res)
+ :"r"(x)
+ :"r0"
+ );
+#else
+ if (x > 0x7fff) {
+ res = 0x7fff;
+ } else if (x < -0x8000) {
+ res = -0x8000;
+ } else {
+ res = x;
+ }
+#endif
+ return res;
+}
+
+static int set_sysfs_type(const char *path, const char *type)
+{
+ int ret = -1;
+ int fd = open(path, O_CREAT | O_RDWR | O_TRUNC, 0644);
+ if (fd >= 0) {
+ char set_type[10] = {0};
+ int length = snprintf(set_type, sizeof(set_type), "%s", type);
+ if (length > 0)
+ ret = write(fd, set_type, length);
+ adec_print("%s , %s\n", path, set_type);
+ close(fd);
+ }else{
+ adec_print("open hdmi-tx node:%s failed!\n", path);
+ }
+ return ret;
+}
+
+
+static void pcm_interpolation(int interpolation, unsigned num_channel, unsigned num_sample, short *samples)
+{
+ int i, k, l, ch;
+ int *s;
+ short *d;
+ for (ch = 0; ch < num_channel; ch++) {
+ s = pass1_history[ch];
+ if (interpolation < 2) {
+ d = interpolation_output;
+ } else {
+ d = pass1_interpolation_output;
+ }
+ for (i = 0, k = l = ch; i < num_sample; i++, k += num_channel) {
+ s[0] = s[1];
+ s[1] = s[2];
+ s[2] = s[3];
+ s[3] = s[4];
+ s[4] = s[5];
+ s[5] = samples[k];
+ d[l] = s[2];
+ l += num_channel;
+ d[l] = CLIPTOSHORT((150 * (s[2] + s[3]) - 25 * (s[1] + s[4]) + 3 * (s[0] + s[5]) + 128) >> 8);
+ l += num_channel;
+ }
+ if (interpolation >= 2) {
+ s = pass2_history[ch];
+ d = interpolation_output;
+ for (i = 0, k = l = ch; i < num_sample * 2; i++, k += num_channel) {
+ s[0] = s[1];
+ s[1] = s[2];
+ s[2] = s[3];
+ s[3] = s[4];
+ s[4] = s[5];
+ s[5] = pass1_interpolation_output[k];
+ d[l] = s[2];
+ l += num_channel;
+ d[l] = CLIPTOSHORT((150 * (s[2] + s[3]) - 25 * (s[1] + s[4]) + 3 * (s[0] + s[5]) + 128) >> 8);
+ l += num_channel;
+ }
+ }
+ }
+}
+#endif
+
+
+static int set_params(alsa_param_t *alsa_params)
+{
+ snd_pcm_hw_params_t *hwparams;
+ snd_pcm_sw_params_t *swparams;
+ // snd_pcm_uframes_t buffer_size;
+ // snd_pcm_uframes_t boundary;
+ // unsigned int period_time = 0;
+ // unsigned int buffer_time = 0;
+ snd_pcm_uframes_t bufsize;
+ int err;
+ unsigned int rate;
+ snd_pcm_uframes_t start_threshold, stop_threshold;
+ snd_pcm_hw_params_alloca(&hwparams);
+ snd_pcm_sw_params_alloca(&swparams);
+
+ err = snd_pcm_hw_params_any(alsa_params->handle, hwparams);
+ if (err < 0) {
+ adec_print("Broken configuration for this PCM: no configurations available");
+ return err;
+ }
+
+ err = snd_pcm_hw_params_set_access(alsa_params->handle, hwparams,
+ SND_PCM_ACCESS_RW_INTERLEAVED);
+ if (err < 0) {
+ adec_print("Access type not available");
+ return err;
+ }
+ if (tv_mode) {
+ alsa_params->format = SND_PCM_FORMAT_S32_LE;
+ }
+ err = snd_pcm_hw_params_set_format(alsa_params->handle,hwparams,alsa_params->format);
+ if (err < 0) {
+ adec_print("Sample format non available");
+ return err;
+ }
+ alsa_params->format = SND_PCM_FORMAT_S16_LE;
+ if (tv_mode) {
+ alsa_params->channelcount = 8;
+ }
+ err = snd_pcm_hw_params_set_channels(alsa_params->handle, hwparams, alsa_params->channelcount);
+ alsa_params->channelcount = 2;
+ if (err < 0) {
+ adec_print("Channels count non available");
+ return err;
+ }
+
+ rate = alsa_params->rate;
+ err = snd_pcm_hw_params_set_rate_near(alsa_params->handle, hwparams, &alsa_params->rate, 0);
+ assert(err >= 0);
+#if 0
+ err = snd_pcm_hw_params_get_buffer_time_max(hwparams, &buffer_time, 0);
+ assert(err >= 0);
+ if (buffer_time > 500000) {
+ buffer_time = 500000;
+ }
+
+ period_time = buffer_time / 4;
+
+ err = snd_pcm_hw_params_set_period_time_near(handle, hwparams,
+ &period_time, 0);
+ assert(err >= 0);
+
+ err = snd_pcm_hw_params_set_buffer_time_near(handle, hwparams,
+ &buffer_time, 0);
+ assert(err >= 0);
+
+#endif
+ alsa_params->bits_per_sample = snd_pcm_format_physical_width(alsa_params->format);
+ //bits_per_frame = bits_per_sample * hwparams.realchanl;
+ alsa_params->bits_per_frame = alsa_params->bits_per_sample * alsa_params->channelcount;
+ adec_print("bits_per_sample %d,bits_per_frame %d\n",alsa_params->bits_per_sample,alsa_params->bits_per_frame);
+ bufsize = PERIOD_NUM * PERIOD_SIZE;
+
+ if (tv_mode) {
+ set_sysfs_type("/sys/class/amhdmitx/amhdmitx0/aud_output_chs", "2:1");
+ }
+
+ err = snd_pcm_hw_params_set_buffer_size_near(alsa_params->handle, hwparams, &bufsize);
+ if (err < 0) {
+ adec_print("Unable to set buffer size \n");
+ return err;
+ }
+ err = snd_pcm_hw_params_set_period_size_near(alsa_params->handle, hwparams, &chunk_size, NULL);
+ if (err < 0) {
+ adec_print("Unable to set period size \n");
+ return err;
+ }
+
+ //err = snd_pcm_hw_params_set_periods_near(handle, hwparams, &fragcount, NULL);
+ //if (err < 0) {
+ // adec_print("Unable to set periods \n");
+ // return err;
+ //}
+
+ err = snd_pcm_hw_params(alsa_params->handle, hwparams);
+ if (err < 0) {
+ adec_print("Unable to install hw params:");
+ return err;
+ }
+
+ err = snd_pcm_hw_params_get_buffer_size(hwparams, &bufsize);
+ if (err < 0) {
+ adec_print("Unable to get buffersize \n");
+ return err;
+ }
+ alsa_params->buffer_size = bufsize * alsa_params->bits_per_frame / 8;
+
+#if 1
+ err = snd_pcm_sw_params_current(alsa_params->handle, swparams);
+ if (err < 0) {
+ adec_print("??Unable to get sw-parameters\n");
+ return err;
+ }
+
+ //err = snd_pcm_sw_params_get_boundary(swparams, &boundary);
+ //if (err < 0){
+ // adec_print("Unable to get boundary\n");
+ // return err;
+ //}
+
+ //err = snd_pcm_sw_params_set_start_threshold(handle, swparams, bufsize);
+ //if (err < 0) {
+ // adec_print("Unable to set start threshold \n");
+ // return err;
+ //}
+
+ //err = snd_pcm_sw_params_set_stop_threshold(handle, swparams, buffer_size);
+ //if (err < 0) {
+ // adec_print("Unable to set stop threshold \n");
+ // return err;
+ //}
+
+ // err = snd_pcm_sw_params_set_silence_size(handle, swparams, buffer_size);
+ // if (err < 0) {
+ // adec_print("Unable to set silence size \n");
+ // return err;
+ // }
+
+ err = snd_pcm_sw_params(alsa_params->handle, swparams);
+ if (err < 0) {
+ adec_print("Unable to get sw-parameters\n");
+ return err;
+ }
+
+ //snd_pcm_sw_params_free(swparams);
+#endif
+
+
+ //chunk_bytes = chunk_size * bits_per_frame / 8;
+
+ return 0;
+}
+
+static int alsa_get_hdmi_state()
+{
+ return 0;
+#if 0
+ int fd = -1, err = 0, state = 0;
+ unsigned fileSize = 32;
+ char *read_buf = NULL;
+ static const char *const HDMI_STATE_PATH = "/sys/class/switch/hdmi/state";
+
+ fd = open(HDMI_STATE_PATH, O_RDONLY);
+ if (fd < 0) {
+ adec_print("ERROR: failed to open config file %s error: %d\n", HDMI_STATE_PATH, errno);
+ close(fd);
+ return -EINVAL;
+ }
+
+ read_buf = (char *)malloc(fileSize);
+ if (!read_buf) {
+ adec_print("Failed to malloc read_buf");
+ goto OUT;
+ }
+ memset(read_buf, 0x0, fileSize);
+ err = read(fd, read_buf, fileSize);
+ if (fd < 0) {
+ adec_print("ERROR: failed to read config file %s error: %d\n", HDMI_STATE_PATH, errno);
+ goto OUT;
+ }
+
+ if (*read_buf == '1') {
+ state = 1;
+ }
+
+OUT:
+ free(read_buf);
+ close(fd);
+ return state;
+#endif
+}
+
+static int alsa_get_aml_card()
+{
+ int card = -1, err = 0;
+ int fd = -1;
+ unsigned fileSize = 512;
+ char *read_buf = NULL, *pd = NULL;
+ static const char *const SOUND_CARDS_PATH = "/proc/asound/cards";
+ fd = open(SOUND_CARDS_PATH, O_RDONLY);
+ if (fd < 0) {
+ adec_print("ERROR: failed to open config file %s error: %d\n", SOUND_CARDS_PATH, errno);
+ close(fd);
+ return -EINVAL;
+ }
+
+ read_buf = (char *)malloc(fileSize);
+ if (!read_buf) {
+ adec_print("Failed to malloc read_buf");
+ close(fd);
+ return -ENOMEM;
+ }
+ memset(read_buf, 0x0, fileSize);
+ err = read(fd, read_buf, fileSize);
+ if (fd < 0) {
+ adec_print("ERROR: failed to read config file %s error: %d\n", SOUND_CARDS_PATH, errno);
+ free(read_buf);
+ close(fd);
+ return -EINVAL;
+ }
+ pd = strstr(read_buf, "AML");
+ card = *(pd - 3) - '0';
+
+OUT:
+ free(read_buf);
+ close(fd);
+ return card;
+}
+
+static int alsa_get_spdif_port()
+{
+/* for pcm output,i2s/958 share the same data from i2s,so always use device 0 as i2s output */
+ return 0;
+ int port = -1, err = 0;
+ int fd = -1;
+ unsigned fileSize = 512;
+ char *read_buf = NULL, *pd = NULL;
+ static const char *const SOUND_PCM_PATH = "/proc/asound/pcm";
+ fd = open(SOUND_PCM_PATH, O_RDONLY);
+ if (fd < 0) {
+ adec_print("ERROR: failed to open config file %s error: %d\n", SOUND_PCM_PATH, errno);
+ close(fd);
+ return -EINVAL;
+ }
+
+ read_buf = (char *)malloc(fileSize);
+ if (!read_buf) {
+ adec_print("Failed to malloc read_buf");
+ close(fd);
+ return -ENOMEM;
+ }
+ memset(read_buf, 0x0, fileSize);
+ err = read(fd, read_buf, fileSize);
+ if (fd < 0) {
+ adec_print("ERROR: failed to read config file %s error: %d\n", SOUND_PCM_PATH, errno);
+ free(read_buf);
+ close(fd);
+ return -EINVAL;
+ }
+ pd = strstr(read_buf, "SPDIF");
+ if (!pd) {
+ goto OUT;
+ }
+ adec_print("%s \n", pd);
+
+ port = *(pd - 3) - '0';
+ adec_print("%s \n", (pd - 3));
+
+OUT:
+ free(read_buf);
+ close(fd);
+ return port;
+}
+
+static size_t pcm_write(alsa_param_t * alsa_param, u_char * data, size_t count)
+{
+ snd_pcm_sframes_t r;
+ size_t result = 0;
+ int i;
+ short *sample = (short*)data;
+ /*
+ if (count < chunk_size) {
+ snd_pcm_format_set_silence(hwparams.format, data + count * bits_per_frame / 8, (chunk_size - count) * hwparams.channels);
+ count = chunk_size;
+ }
+ */
+ /* volume control for bootplayer */
+ if (alsa_default_vol != 1.0) {
+ for (i = 0;i < count*2;i++) {
+ sample[i] = (short)(alsa_default_vol*(float)sample[i]);
+ }
+ }
+ // dump pcm data here
+#if 0
+ FILE *fp1=fopen("/data/audio_out.pcm","a+");
+ if (fp1) {
+ int flen=fwrite((char *)data,1,count*2*2,fp1);
+ adec_print("flen = %d---outlen=%d ", flen, count*2*2);
+ fclose(fp1);
+ }else{
+ adec_print("could not open file:audio_out.pcm");
+ }
+#endif
+ int *tmp_buffer = NULL;
+ int bits_per_frame = alsa_param->bits_per_frame;
+ if (tv_mode) {
+ tmp_buffer = (int*)malloc(count*8*4);
+ if (tmp_buffer == NULL) {
+ adec_print("malloc tmp_buffer failed\n");
+ return -1;
+ }
+ int i;
+ int out_frames = count;
+ short *in_buffer = (short*)data;
+ for (i = 0; i < out_frames; i ++) {
+ tmp_buffer[8*i] = ((int)(in_buffer[2*i])) << 16;
+ tmp_buffer[8*i + 1] = ((int)(in_buffer[2*i + 1])) << 16;
+ tmp_buffer[8*i + 2] = ((int)(in_buffer[2*i])) << 16;
+ tmp_buffer[8*i + 3] = ((int)(in_buffer[2*i + 1])) << 16;
+ tmp_buffer[8*i + 4] = 0;
+ tmp_buffer[8*i + 5] = 0;
+ tmp_buffer[8*i + 6] = 0;
+ tmp_buffer[8*i + 7] = 0;
+ }
+ data = (char*)tmp_buffer;
+ bits_per_frame = bits_per_frame*8;//8ch,32bit
+ }
+ while (count > 0) {
+ r = writei_func(alsa_param->handle, data, count);
+
+ if (r == -EINTR) {
+ r = 0;
+ }
+ if (r == -ESTRPIPE) {
+ while ((r = snd_pcm_resume(alsa_param->handle)) == -EAGAIN) {
+ amthreadpool_thread_usleep(1000);
+ }
+ }
+
+ if (r < 0) {
+ printf("xun in\n");
+ if ((r = snd_pcm_prepare(alsa_param->handle)) < 0) {
+ result = 0;
+ goto done;
+ }
+ }
+
+ if (r > 0) {
+ result += r;
+ count -= r;
+ data += r * bits_per_frame / 8;
+ }
+ }
+done:
+ if (tmp_buffer) {
+ free(tmp_buffer);
+ }
+ return result;
+}
+
+static unsigned oversample_play(alsa_param_t * alsa_param, char * src, unsigned count)
+{
+ int frames = 0;
+ int ret, i;
+ unsigned short * to, *from;
+ to = (unsigned short *)output_buffer;
+ from = (unsigned short *)src;
+
+ if (alsa_param->realchanl == 2) {
+ if (alsa_param->oversample == -1) {
+ frames = count * 8 / alsa_param->bits_per_frame;
+ frames = frames & (~(32 - 1));
+ for (i = 0; i < (frames * 2); i += 4) { // i for sample
+ *to++ = *from++;
+ *to ++ = *from++;
+ from += 2;
+ }
+ ret = pcm_write(alsa_param, output_buffer, frames / 2);
+ ret = ret * alsa_param->bits_per_frame / 8;
+ ret = ret * 2;
+ } else if (alsa_param->oversample == 1) {
+ frames = count * 8 / alsa_param->bits_per_frame;
+ frames = frames & (~(16 - 1));
+#ifdef USE_INTERPOLATION
+ pcm_interpolation(1, alsa_param->realchanl, frames, (short*)src);
+ memcpy(output_buffer, interpolation_output, (frames * alsa_param->bits_per_frame / 4));
+#else
+ short l, r;
+ for (i = 0; i < (frames * 2); i += 2) {
+ l = *from++;
+ r = *from++;
+ *to++ = l;
+ *to++ = r;
+ *to++ = l;
+ *to++ = r;
+ }
+#endif
+ ret = pcm_write(alsa_param, output_buffer, frames * 2);
+ ret = ret * alsa_param->bits_per_frame / 8;
+ ret = ret / 2;
+ } else if (alsa_param->oversample == 2) {
+ frames = count * 8 / alsa_param->bits_per_frame;
+ frames = frames & (~(8 - 1));
+#ifdef USE_INTERPOLATION
+ pcm_interpolation(2, alsa_param->realchanl, frames, (short*)src);
+ memcpy(output_buffer, interpolation_output, (frames * alsa_param->bits_per_frame / 2));
+#else
+ short l, r;
+ for (i = 0; i < (frames * 2); i += 2) {
+ l = *from++;
+ r = *from++;
+ *to++ = l;
+ *to++ = r;
+ *to++ = l;
+ *to++ = r;
+ *to++ = l;
+ *to++ = r;
+ *to++ = l;
+ *to++ = r;
+ }
+#endif
+ ret = pcm_write(alsa_param, output_buffer, frames * 4);
+ ret = ret * alsa_param->bits_per_frame / 8;
+ ret = ret / 4;
+ }
+ } else if (alsa_param->realchanl == 1) {
+ if (alsa_param->oversample == -1) {
+ frames = count * 8 / alsa_param->bits_per_frame;
+ frames = frames & (~(32 - 1));
+ for (i = 0; i < (frames * 2); i += 2) {
+ *to++ = *from;
+ *to++ = *from++;
+ from++;
+ }
+ ret = pcm_write(alsa_param, output_buffer, frames);
+ ret = ret * alsa_param->bits_per_frame / 8;
+ } else if (alsa_param->oversample == 0) {
+ frames = count * 8 / (alsa_param->bits_per_frame >> 1);
+ frames = frames & (~(16 - 1));
+ for (i = 0; i < (frames); i++) {
+ *to++ = *from;
+ *to++ = *from++;
+ }
+ ret = pcm_write(alsa_param, output_buffer, frames);
+ ret = ret * (alsa_param->bits_per_frame) / 8;
+ ret = ret / 2;
+ } else if (alsa_param->oversample == 1) {
+ frames = count * 8 / (alsa_param->bits_per_frame >> 1);
+ frames = frames & (~(8 - 1));
+#ifdef USE_INTERPOLATION
+ pcm_interpolation(1, alsa_param->realchanl, frames, (short*)src);
+ from = (unsigned short*)interpolation_output;
+ for (i = 0; i < (frames * 2); i++) {
+ *to++ = *from;
+ *to++ = *from++;
+ }
+#else
+ for (i = 0; i < (frames); i++) {
+ *to++ = *from;
+ *to++ = *from;
+ *to++ = *from;
+ *to++ = *from++;
+ }
+#endif
+ ret = pcm_write(alsa_param, output_buffer, frames * 2);
+ ret = ret * (alsa_param->bits_per_frame) / 8;
+ ret = ret / 4;
+ } else if (alsa_param->oversample == 2) {
+ frames = count * 8 / (alsa_param->bits_per_frame >> 1);
+ frames = frames & (~(8 - 1));
+#ifdef USE_INTERPOLATION
+ pcm_interpolation(2, alsa_param->realchanl, frames, (short*)src);
+ from = (unsigned short*)interpolation_output;
+ for (i = 0; i < (frames * 4); i++) {
+ *to++ = *from;
+ *to++ = *from++;
+ }
+#else
+ for (i = 0; i < (frames); i++) {
+ *to++ = *from;
+ *to++ = *from;
+ *to++ = *from;
+ *to++ = *from;
+ *to++ = *from;
+ *to++ = *from;
+ *to++ = *from;
+ *to++ = *from++;
+ }
+#endif
+ ret = pcm_write(alsa_param, output_buffer, frames * 4);
+ ret = ret * (alsa_param->bits_per_frame) / 8;
+ ret = ret / 8;
+ }
+ }
+
+ return ret;
+}
+
+static int alsa_play(alsa_param_t * alsa_param, char * data, unsigned len)
+{
+ size_t l = 0, r;
+
+ if (!alsa_param->flag) {
+ l = len * 8 / alsa_param->bits_per_frame;
+ l = l & (~(32 - 1)); /*driver only support 32 frames each time */
+ r = pcm_write(alsa_param, data, l);
+ r = r * alsa_param->bits_per_frame / 8;
+ } else {
+ r = oversample_play(alsa_param, data, len);
+ }
+
+ return r ;
+}
+
+static int alsa_swtich_port(alsa_param_t *alsa_params, int card, int port)
+{
+ char dev[10] = {0};
+ adec_print("card = %d, port = %d\n", card, port);
+ sprintf(dev, "hw:%d,%d", (card >= 0) ? card : 0, (port >= 0) ? port : 0);
+ pthread_mutex_lock(&alsa_params->playback_mutex);
+ snd_pcm_drop(alsa_params->handle);
+ snd_pcm_close(alsa_params->handle);
+ alsa_params->handle = NULL;
+ int err = snd_pcm_open(&alsa_params->handle, dev, SND_PCM_STREAM_PLAYBACK, 0);
+
+ if (err < 0) {
+ adec_print("audio open error: %s", snd_strerror(err));
+ pthread_mutex_unlock(&alsa_params->playback_mutex);
+ return -1;
+ }
+
+ set_params(alsa_params);
+ pthread_mutex_unlock(&alsa_params->playback_mutex);
+
+ return 0;
+}
+
+static void *alsa_playback_loop(void *args)
+{
+ int len = 0;
+ int len2 = 0;
+ int offset = 0;
+ aml_audio_dec_t *audec;
+ alsa_param_t *alsa_params;
+ unsigned char *buffer = (unsigned char *)(((unsigned long)decode_buffer + 32) & (~0x1f));
+
+ char value[PROPERTY_VALUE_MAX]={0};
+ audec = (aml_audio_dec_t *)args;
+ alsa_params = (alsa_param_t *)audec->aout_ops.private_data;
+
+ // bootplayer default volume configuration
+ if (property_get("media.amplayer.boot_vol",value,NULL) > 0) {
+ alsa_default_vol = atof(value);
+ if (alsa_default_vol < 0.0 || alsa_default_vol > 1.0 ) {
+ adec_print("wrong alsa default volume %f, set to 1.0 \n",alsa_default_vol);
+ alsa_default_vol = 1.0;
+ }
+ }
+ adec_print("alsa default volume %f \n",alsa_default_vol);
+ /* pthread_mutex_init(&alsa_params->playback_mutex, NULL);
+ pthread_cond_init(&alsa_params->playback_cond, NULL);*/
+
+ while (!alsa_params->wait_flag && alsa_params->stop_flag == 0) {
+ amthreadpool_thread_usleep(10000);
+ }
+
+ adec_print("alsa playback loop start to run !\n");
+
+ while (!alsa_params->stop_flag) {
+#if 0
+ if (hdmi_out == 0) {
+ adec_print("===dynmiac get hdmi plugin state===\n");
+ if (alsa_get_hdmi_state() == 1) {
+ if (alsa_swtich_port(alsa_params, alsa_get_aml_card(), alsa_get_spdif_port()) == -1) {
+ adec_print("switch to hdmi port failed.\n");
+ goto exit;
+ }
+
+ hdmi_out = 1;
+ adec_print("[%s,%d]get hdmi device, use hdmi device \n", __FUNCTION__, __LINE__);
+ }
+ } else if (alsa_get_hdmi_state() == 0) {
+ if (alsa_swtich_port(alsa_params, alsa_get_aml_card(), 0) == -1) {
+ adec_print("switch to default port failed.\n");
+ goto exit;
+ }
+
+ hdmi_out = 0;
+ adec_print("[%s,%d]get default device, use default device \n", __FUNCTION__, __LINE__);
+ }
+#endif
+ while ((len < (128 * 2)) && (!alsa_params->stop_flag)) {
+ if (offset > 0) {
+ memcpy(buffer, buffer + offset, len);
+ }
+ len2 = audec->adsp_ops.dsp_read(&audec->adsp_ops, (buffer + len), (OUTPUT_BUFFER_SIZE - len));
+ len = len + len2;
+ offset = 0;
+ }
+ audec->pcm_bytes_readed += len;
+ while (alsa_params->pause_flag) {
+ amthreadpool_thread_usleep(10000);
+ }
+ if (alsa_params->stop_flag) {
+ goto exit;
+ }
+ adec_refresh_pts(audec);
+
+ len2 = alsa_play(alsa_params, (buffer + offset), len);
+ if (len2 >= 0) {
+ len -= len2;
+ offset += len2;
+ } else {
+ len = 0;
+ offset = 0;
+ }
+ }
+exit:
+ adec_print("Exit alsa playback loop !\n");
+ pthread_exit(NULL);
+ return NULL;
+}
+
+/**
+ * \brief output initialization
+ * \param audec pointer to audec
+ * \return 0 on success otherwise negative error code
+ */
+int alsa_init(struct aml_audio_dec* audec)
+{
+ adec_print("alsa out init");
+ char sound_card_dev[10] = {0};
+ int sound_card_id = 0;
+ int sound_dev_id = 0;
+ int err;
+ pthread_t tid;
+ alsa_param_t *alsa_param;
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+ tv_mode = getprop_bool("ro.platform.has.tvuimode");
+ alsa_param = (alsa_param_t *)malloc(sizeof(alsa_param_t));
+ if (!alsa_param) {
+ adec_print("alloc alsa_param failed, not enough memory!");
+ return -1;
+ }
+ memset(alsa_param, 0, sizeof(alsa_param_t));
+
+ if (audec->samplerate >= (88200 + 96000) / 2) {
+ alsa_param->flag = 1;
+ alsa_param->oversample = -1;
+ alsa_param->rate = 48000;
+ } else if (audec->samplerate >= (64000 + 88200) / 2) {
+ alsa_param->flag = 1;
+ alsa_param->oversample = -1;
+ alsa_param->rate = 44100;
+ } else if (audec->samplerate >= (48000 + 64000) / 2) {
+ alsa_param->flag = 1;
+ alsa_param->oversample = -1;
+ alsa_param->rate = 32000;
+ } else if (audec->samplerate >= (44100 + 48000) / 2) {
+ alsa_param->oversample = 0;
+ alsa_param->rate = 48000;
+ if (audec->channels == 1) {
+ alsa_param->flag = 1;
+ } else if (audec->channels == 2) {
+ alsa_param->flag = 0;
+ }
+ } else if (audec->samplerate >= (32000 + 44100) / 2) {
+ alsa_param->oversample = 0;
+ alsa_param->rate = 44100;
+ if (audec->channels == 1) {
+ alsa_param->flag = 1;
+ } else if (audec->channels == 2) {
+ alsa_param->flag = 0;
+ }
+ } else if (audec->samplerate >= (24000 + 32000) / 2) {
+ alsa_param->oversample = 0;
+ alsa_param->rate = 32000;
+ if (audec->channels == 1) {
+ alsa_param->flag = 1;
+ } else if (audec->channels == 2) {
+ alsa_param->flag = 0;
+ }
+ } else if (audec->samplerate >= (22050 + 24000) / 2) {
+ alsa_param->flag = 1;
+ alsa_param->oversample = 1;
+ alsa_param->rate = 48000;
+ } else if (audec->samplerate >= (16000 + 22050) / 2) {
+ alsa_param->flag = 1;
+ alsa_param->oversample = 1;
+ alsa_param->rate = 44100;
+ } else if (audec->samplerate >= (12000 + 16000) / 2) {
+ alsa_param->flag = 1;
+ alsa_param->oversample = 1;
+ alsa_param->rate = 32000;
+ } else if (audec->samplerate >= (11025 + 12000) / 2) {
+ alsa_param->flag = 1;
+ alsa_param->oversample = 2;
+ alsa_param->rate = 48000;
+ } else if (audec->samplerate >= (8000 + 11025) / 2) {
+ alsa_param->flag = 1;
+ alsa_param->oversample = 2;
+ alsa_param->rate = 44100;
+ } else {
+ alsa_param->flag = 1;
+ alsa_param->oversample = 2;
+ alsa_param->rate = 32000;
+ }
+
+ alsa_param->channelcount = 2;
+ alsa_param->realchanl = audec->channels;
+ //alsa_param->rate = audec->samplerate;
+ alsa_param->format = SND_PCM_FORMAT_S16_LE;
+ alsa_param->wait_flag = 0;
+
+#ifdef USE_INTERPOLATION
+ memset(pass1_history, 0, 64 * sizeof(int));
+ memset(pass2_history, 0, 64 * sizeof(int));
+#endif
+
+ sound_card_id = alsa_get_aml_card();
+ if (sound_card_id < 0) {
+ sound_card_id = 0;
+ adec_print("get aml card fail, use default \n");
+ }
+#if 0
+ if (alsa_get_hdmi_state() == 1) {
+ sound_dev_id = alsa_get_spdif_port();
+ if (sound_dev_id < 0) {
+ sound_dev_id = 0;
+ adec_print("get aml card device fail, use default \n");
+ } else {
+ hdmi_out = 1;
+ }
+ adec_print("get hdmi device, use hdmi device \n");
+ }
+#endif
+ sprintf(sound_card_dev, "hw:%d,%d", sound_card_id, sound_dev_id);
+ err = snd_pcm_open(&alsa_param->handle, sound_card_dev, SND_PCM_STREAM_PLAYBACK, 0);
+ if (err < 0) {
+ adec_print("audio open error: %s", snd_strerror(err));
+ return -1;
+ }
+ readi_func = snd_pcm_readi;
+ writei_func = snd_pcm_writei;
+ readn_func = snd_pcm_readn;
+ writen_func = snd_pcm_writen;
+
+ set_params(alsa_param);
+
+ out_ops->private_data = (void *)alsa_param;
+
+ /*TODO: create play thread */
+ pthread_mutex_init(&alsa_param->playback_mutex, NULL);
+ pthread_cond_init(&alsa_param->playback_cond, NULL);
+ err = amthreadpool_pthread_create(&tid, NULL, (void *)alsa_playback_loop, (void *)audec);
+ if (err != 0) {
+ adec_print("alsa_playback_loop thread create failed!");
+ snd_pcm_close(alsa_param->handle);
+ return -1;
+ }
+ pthread_setname_np(tid, "ALSAOUTLOOP");
+
+ adec_print("Create alsa playback loop thread success ! tid = %d\n", tid);
+
+ alsa_param->playback_tid = tid;
+
+ return 0;
+}
+
+/**
+ * \brief start output
+ * \param audec pointer to audec
+ * \return 0 on success otherwise negative error code
+ *
+ * Call alsa_start(), then the callback will start being called.
+ */
+int alsa_start(struct aml_audio_dec* audec)
+{
+ adec_print("alsa out start!\n");
+
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+ alsa_param_t *alsa_param = (alsa_param_t *)out_ops->private_data;
+
+ pthread_mutex_lock(&alsa_param->playback_mutex);
+ adec_print("yvonne pthread_cond_signalalsa_param->wait_flag=1\n");
+ alsa_param->wait_flag = 1; //yvonneadded
+ pthread_cond_signal(&alsa_param->playback_cond);
+ pthread_mutex_unlock(&alsa_param->playback_mutex);
+ adec_print("exit alsa out start!\n");
+
+ return 0;
+}
+
+/**
+ * \brief pause output
+ * \param audec pointer to audec
+ * \return 0 on success otherwise negative error code
+ */
+int alsa_pause(struct aml_audio_dec* audec)
+{
+ adec_print("alsa out pause\n");
+
+ int res;
+ alsa_param_t *alsa_params;
+
+ alsa_params = (alsa_param_t *)audec->aout_ops.private_data;
+ pthread_mutex_lock(&alsa_params->playback_mutex);
+
+ alsa_params->pause_flag = 1;
+ while ((res = snd_pcm_pause(alsa_params->handle, 1)) == -EAGAIN) {
+ sleep(1);
+ }
+ pthread_mutex_unlock(&alsa_params->playback_mutex);
+ adec_print("exit alsa out pause\n");
+
+ return res;
+}
+
+/**
+ * \brief resume output
+ * \param audec pointer to audec
+ * \return 0 on success otherwise negative error code
+ */
+int alsa_resume(struct aml_audio_dec* audec)
+{
+ adec_print("alsa out rsume\n");
+
+ int res;
+ alsa_param_t *alsa_params;
+
+ alsa_params = (alsa_param_t *)audec->aout_ops.private_data;
+ pthread_mutex_lock(&alsa_params->playback_mutex);
+
+ alsa_params->pause_flag = 0;
+ while ((res = snd_pcm_pause(alsa_params->handle, 0)) == -EAGAIN) {
+ sleep(1);
+ }
+ pthread_mutex_unlock(&alsa_params->playback_mutex);
+
+ return res;
+}
+
+/**
+ * \brief stop output
+ * \param audec pointer to audec
+ * \return 0 on success otherwise negative error code
+ */
+int alsa_stop(struct aml_audio_dec* audec)
+{
+ adec_print("enter alsa out stop\n");
+
+ alsa_param_t *alsa_params;
+
+ alsa_params = (alsa_param_t *)audec->aout_ops.private_data;
+ pthread_mutex_lock(&alsa_params->playback_mutex);
+ alsa_params->pause_flag = 0;
+ alsa_params->stop_flag = 1;
+ //alsa_params->wait_flag = 0;
+ pthread_cond_signal(&alsa_params->playback_cond);
+ amthreadpool_pthread_join(alsa_params->playback_tid, NULL);
+ pthread_cond_destroy(&alsa_params->playback_cond);
+
+
+ snd_pcm_drop(alsa_params->handle);
+ snd_pcm_close(alsa_params->handle);
+ pthread_mutex_unlock(&alsa_params->playback_mutex);
+ pthread_mutex_destroy(&alsa_params->playback_mutex);
+
+ free(alsa_params);
+ audec->aout_ops.private_data = NULL;
+ adec_print("exit alsa out stop\n");
+
+ return 0;
+}
+
+static int alsa_get_space(alsa_param_t * alsa_param)
+{
+ snd_pcm_status_t *status;
+ int ret;
+ int bits_per_sample = alsa_param->bits_per_sample;
+ snd_pcm_status_alloca(&status);
+ if ((ret = snd_pcm_status(alsa_param->handle, status)) < 0) {
+ adec_print("Cannot get pcm status \n");
+ return 0;
+ }
+ ret = snd_pcm_status_get_avail(status) * alsa_param->bits_per_sample / 8;
+ if (ret > alsa_param->buffer_size) {
+ ret = alsa_param->buffer_size;
+ }
+ return ret;
+}
+
+/**
+ * \brief get output latency in ms
+ * \param audec pointer to audec
+ * \return output latency
+ */
+unsigned long alsa_latency(struct aml_audio_dec* audec)
+{
+ int buffered_data;
+ int sample_num;
+ alsa_param_t *alsa_param = (alsa_param_t *)audec->aout_ops.private_data;
+ int bits_per_sample = alsa_param->bits_per_sample;
+ if (tv_mode) {
+ bits_per_sample = bits_per_sample*4;
+ }
+ buffered_data = alsa_param->buffer_size - alsa_get_space(alsa_param);
+ sample_num = buffered_data / (alsa_param->channelcount * (bits_per_sample / 8)); /*16/2*/
+ return ((sample_num * 1000) / alsa_param->rate);
+}
+
+static int alsa_mute(struct aml_audio_dec* audec, adec_bool_t en)
+{
+ return 0;
+}
+/**
+ * \brief get output handle
+ * \param audec pointer to audec
+ */
+void get_output_func(struct aml_audio_dec* audec)
+{
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+
+ out_ops->init = alsa_init;
+ out_ops->start = alsa_start;
+ out_ops->pause = alsa_pause;
+ out_ops->resume = alsa_resume;
+ out_ops->mute = alsa_mute;
+ out_ops->stop = alsa_stop;
+ out_ops->latency = alsa_latency;
+}
diff --git a/amadec/audio_out/aml_resample.c b/amadec/audio_out/aml_resample.c
new file mode 100644
index 0000000..f124ed1
--- a/dev/null
+++ b/amadec/audio_out/aml_resample.c
@@ -0,0 +1,708 @@
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <linux/fb.h>
+#include <sys/system_properties.h>
+#include <log-print.h>
+#include <cutils/properties.h>
+#include "aml_resample.h"
+#include "Amsysfsutils.h"
+#include "amconfigutils.h"
+
+
+af_resampe_ctl_t af_resampler_ctx = {0};
+static int pcmfd = -1;
+static int get_sysfs_int(const char *path)
+{
+ int fd;
+ int val = 0;
+ char bcmd[16] = {0};;
+ fd = open(path, O_RDONLY);
+ if (fd >= 0) {
+ read(fd, bcmd, 16);
+ if (bcmd[0] == 'O' && bcmd[1] == 'N') {
+ val = 1;
+ }
+
+ else if (bcmd[0] == 'O' && bcmd[1] == 'F') {
+ val = 0;
+ }
+
+ else if (bcmd[0] == 'N' && bcmd[1] == 'O') {
+ val = 0;
+ }
+
+ else if (bcmd[0] == 'D' && bcmd[1] == 'W') {
+ val = 1;
+ }
+
+ else if (bcmd[0] == 'U' && bcmd[1] == 'P') {
+ val = 2;
+ }
+
+ //adec_print("value=%s coresponding val=%d\n",bcmd,val);
+
+ close(fd);
+ } else {
+ //adec_print("open %s failed\n",path);
+ }
+ return val;
+}
+
+static int get_sysfs_str(const char *path, char *valstr, int size)
+{
+ return amsysfs_get_sysfs_str(path, valstr, size);
+}
+
+
+int af_get_resample_enable_flag()
+{
+ //return get_sysfs_int("sys/class/amaudio/enable_resample");
+ return af_resampler_ctx.enable_resample;
+}
+
+int af_get_resample_type()
+{
+ //return get_sysfs_int("sys/class/amaudio/resample_type");
+ return af_resampler_ctx.resample_type;
+}
+
+int af_set_resample_type(int val)
+{
+ //return amsysfs_set_sysfs_int("sys/class/amaudio/resample_type", val);
+ af_resampler_ctx.resample_type = val;
+ return 1;
+}
+
+
+void af_resample_linear_init(struct aml_audio_dec *audec)
+{
+ char value[1028] = {0};
+ af_resampe_ctl_t *paf_resampe_ctl;
+ paf_resampe_ctl = &af_resampler_ctx;
+ memset(paf_resampe_ctl, 0, sizeof(af_resampe_ctl_t));
+ adec_print("af_resample_linear_init 140821-1407");
+ audec->pcrtsync_enable = 1;
+ if (property_get("media.libplayer.pcrtsync_enable", value, NULL) > 0) {
+ if (!strcmp(value, "0") || !strcmp(value, "false")) {
+ audec->pcrtsync_enable = 0;
+ }
+ }
+ if (audec->tsync_mode == TSYNC_MODE_PCRMASTER && audec->pcrtsync_enable) {
+ paf_resampe_ctl->enable_resample = 1;
+ if (property_get("media.libplayer.enable_resample", value, NULL) > 0) {
+ paf_resampe_ctl->enable_resample = atoi(value);
+ }
+ amsysfs_set_sysfs_int("sys/class/amaudio/enable_resample", paf_resampe_ctl->enable_resample);
+ //property_set("media.libplayer.resampledelta", "1");
+ audec->fill_trackzero_thrsh = TIME_UNIT90K / 2;
+ if (property_get("media.libplayer.fillzerothrsh", value, NULL) > 0) {
+ audec->fill_trackzero_thrsh = atoi(value);
+ }
+ // add for dolby av sync test
+ if (property_get("media.libplayer.dolby_test", value, NULL) > 0) {
+ audec->fill_trackzero_thrsh = 27000;
+ }
+ audec->pcrmaster_droppcm_thsh = TIME_UNIT90K / 2;
+ if (property_get("media.libplayer.pcrdroppcmthsh", value, NULL) > 0) {
+ audec->pcrmaster_droppcm_thsh = atoi(value);
+ }
+ if (pcmfd == -1) {
+ pcmfd = open("/data/tmp/pcmdump.dat", O_CREAT | O_RDWR, 0666);
+ if (pcmfd < 0) {
+ adec_print("creat pcmdump failed!fd=%d\n", pcmfd);
+ }
+ }
+ adec_print("## pcrmaster enable resample,tsync_enable:%d, fill_trackzero_thrsh:%d, ! --\n", audec->pcrtsync_enable, audec->fill_trackzero_thrsh);
+ }
+}
+
+void af_resample_linear_stop(struct aml_audio_dec *audec)
+{
+ adec_print("[%s:%d]", __FUNCTION__, __LINE__);
+ if (audec->tsync_mode == TSYNC_MODE_PCRMASTER) {
+ amsysfs_set_sysfs_int("sys/class/amaudio/enable_resample", 0);
+ if (pcmfd >= 0) {
+ close(pcmfd);
+ pcmfd = -1;
+ }
+ adec_print("## pcrmaster recovery enable_resample! --\n");
+ }
+}
+
+static int dsp_pcm_read(aml_audio_dec_t*audec, char *data_in, int len)
+{
+ int pcm_ret = 0, pcm_cnt_bytes = 0;
+ int wait_times = 0;
+ while (pcm_cnt_bytes < len) {
+ pcm_ret = audec->adsp_ops.dsp_read(&audec->adsp_ops, data_in + pcm_cnt_bytes, len - pcm_cnt_bytes);
+ if (pcm_ret <= 0) { //indicate there is no data in dsp_buf,still try to read more data:
+#if 0
+ wait_times++;
+ adec_print("wait dsp times: %d\n", wait_times);
+ //usleep(20);
+ if (wait_times > 1) {
+ adec_print("NOTE:dsp no enough data!");
+ break;
+ }
+#else
+ //adec_print("can not read out PCM : %d\n", pcm_ret);
+ break;
+#endif
+ }
+ pcm_cnt_bytes += pcm_ret;
+ }
+ audec->pcm_bytes_readed += pcm_cnt_bytes;
+ return pcm_cnt_bytes / sizeof(short);
+}
+
+static int pcrmaster_dsp_pcm_read(aml_audio_dec_t*audec, char *data_in, int len)
+{
+ int pcm_ret = 0, pcm_cnt_bytes = 0;
+ int wait_times = 0;
+ while (pcm_cnt_bytes < len) {
+ pcm_ret = audec->adsp_ops.dsp_read(&audec->adsp_ops, data_in + pcm_cnt_bytes, len - pcm_cnt_bytes);
+ if (pcm_ret <= 0) { //indicate there is no data in dsp_buf,still try to read more data:
+#if 0
+ wait_times++;
+ adec_print("wait dsp times: %d\n", wait_times);
+ //usleep(20);
+ if (wait_times > 1) {
+ adec_print("NOTE:dsp no enough data!");
+ break;
+ }
+#else
+ //adec_print("can not read out PCM : %d\n", pcm_ret);
+ break;
+#endif
+ }
+ pcm_cnt_bytes += pcm_ret;
+ }
+ audec->pcm_bytes_readed += pcm_cnt_bytes;
+ return pcm_cnt_bytes;
+}
+
+
+void af_resample_api(char* buffer, unsigned int * size, int Chnum, aml_audio_dec_t* audec, int enable, int delta);
+
+void af_pcrmaster_resample_api(char *buffer, unsigned int *size, int Chnum, aml_audio_dec_t *audec/*, int enable, int delta*/)
+{
+ int resample_delta = 0;
+ char value[1028] = {0};
+
+ int resample_enable = af_resampler_ctx.enable_resample;//enable;
+
+ if (af_resampler_ctx.resample_type == RESAMPLE_TYPE_DOWN) {
+ resample_delta = 1;
+ if (property_get("media.libplayer.resampledelta", value, NULL) > 0) {
+ resample_delta = atoi(value);
+ }
+ } else if (af_resampler_ctx.resample_type == RESAMPLE_TYPE_UP) {
+ resample_delta = -1;
+ if (property_get("media.libplayer.resampledelta", value, NULL) > 0) {
+ resample_delta = -atoi(value);
+ }
+ } else if (af_resampler_ctx.resample_type == RESAMPLE_TYPE_NONE) {
+ resample_enable = 0;
+ resample_delta = 0;
+ }
+ //call normal resample api
+ af_resample_api(buffer, size, Chnum, audec, resample_enable, resample_delta);
+}
+
+#if 1
+af_resampe_ctl_t* af_resampler_ctx_get()
+{
+ return &af_resampler_ctx;
+}
+
+static void af_resample_linear_coef_get(af_resampe_ctl_t *paf_resampe_ctl)
+{
+ int SampNumIn = paf_resampe_ctl->SampNumIn;
+ int SampNumOut = paf_resampe_ctl->SampNumOut;
+ int *pCoefArray = paf_resampe_ctl->InterpolateCoefArray;
+ short *pindex = paf_resampe_ctl->InterpolateIndexArray;
+ int i;
+ int step_i = (((SampNumIn - 1)) << 14) / (SampNumOut - 1);
+ int step_forward = 0;
+ int insert_pos_int = 0;
+
+ if (SampNumIn == SampNumOut) {
+ for (i = 0; i < SampNumOut; i++) {
+ pindex[i] = i;
+ pCoefArray[i] = 0;
+ }
+ return;
+ }
+
+ step_forward = 0;
+ for (i = 1; i <= SampNumOut - 2; i++) {
+ step_forward += step_i;
+ insert_pos_int += Q14_INT_GET(step_forward);
+ pindex[i] = insert_pos_int;
+ pCoefArray[i] = Q14_FRA_GET(step_forward);
+ step_forward = Q14_FRA_GET(step_forward);
+ }
+ pindex[0] = 0;
+ pCoefArray[0] = 0;
+ pindex[SampNumOut - 1] = SampNumOut - 1;
+ pCoefArray[SampNumOut - 1] = 0;
+}
+
+
+static int audiodsp_set_pcm_resample_delta(int resample_num_delta)
+{
+ int utils_fd, ret;
+
+ utils_fd = open("/dev/amaudio_utils", O_RDWR);
+ if (utils_fd >= 0) {
+ ret = ioctl(utils_fd, AMAUDIO_IOC_SET_RESAMPLE_DELTA, resample_num_delta);
+ if (ret < 0) {
+ adec_print(" AMAUDIO_IOC_SET_RESAMPLE_DELTA failed\n");
+ close(utils_fd);
+ return -1;
+ }
+ //adec_print("Notify kernel: <resample_num_delta=%d>\n",resample_num_delta);
+ close(utils_fd);
+ return 0;
+ }
+ return -1;
+}
+void af_resample_set_SampsNumRatio(af_resampe_ctl_t *paf_resampe_ctl)
+{
+ char value[1028] = {0};
+ int resample_type = af_get_resample_type();
+ int default_DELTA_NUMSAMPS = RESAMPLE_DELTA_NUMSAMPS;
+ if (property_get("media.libplayer.resampledelta", value, NULL) > 0) {
+ default_DELTA_NUMSAMPS = atoi(value);
+ }
+ if (am_getconfig_bool("media.libplayer.wfd")) {
+ default_DELTA_NUMSAMPS = 2;
+ }
+ audiodsp_set_pcm_resample_delta(default_DELTA_NUMSAMPS);
+ paf_resampe_ctl->LastResamType = resample_type;
+ //adec_print("ReSample Coef Init: type/%d DELTA_NUMSAMPS/%d ",resample_type,default_DELTA_NUMSAMPS);
+ //memset(paf_resampe_ctl,0,sizeof(af_resampe_ctl_t));
+ if (resample_type == RESAMPLE_TYPE_NONE) {
+ paf_resampe_ctl->SampNumIn = DEFALT_NUMSAMPS_PERCH;
+ paf_resampe_ctl->SampNumOut = DEFALT_NUMSAMPS_PERCH;
+ } else if (resample_type == RESAMPLE_TYPE_DOWN) {
+ paf_resampe_ctl->SampNumIn = DEFALT_NUMSAMPS_PERCH + default_DELTA_NUMSAMPS;
+ paf_resampe_ctl->SampNumOut = DEFALT_NUMSAMPS_PERCH ;
+ } else if (resample_type == RESAMPLE_TYPE_UP) {
+ paf_resampe_ctl->SampNumIn = DEFALT_NUMSAMPS_PERCH - default_DELTA_NUMSAMPS;
+ paf_resampe_ctl->SampNumOut = DEFALT_NUMSAMPS_PERCH;
+ }
+ af_resample_linear_coef_get(paf_resampe_ctl);
+ paf_resampe_ctl->ResevedSampsValid = 0;
+ paf_resampe_ctl->OutSampReserveLen = 0;
+ paf_resampe_ctl->InitFlag = 1;
+
+}
+
+
+int af_get_delta_inputsampnum(af_resampe_ctl_t *paf_resampe_ctl, int Nch)
+{
+ return paf_resampe_ctl->SampNumIn * Nch - paf_resampe_ctl->ResevedSampsValid;
+
+}
+
+void af_get_unpro_inputsampnum(af_resampe_ctl_t *paf_resampe_ctl, short *buf, int *num)
+{
+ if (*num >= paf_resampe_ctl->ResevedSampsValid) {
+ memcpy(buf, paf_resampe_ctl->ResevedBuf, paf_resampe_ctl->ResevedSampsValid * sizeof(short));
+ *num = paf_resampe_ctl->ResevedSampsValid;
+ paf_resampe_ctl->ResevedSampsValid = 0;
+
+ } else { //*num < paf_resampe_ctl->ResevedSampsValid
+ memcpy(buf, paf_resampe_ctl->ResevedBuf, (*num)*sizeof(short));
+ memmove(paf_resampe_ctl->ResevedBuf,
+ paf_resampe_ctl->ResevedBuf + (*num),
+ (paf_resampe_ctl->ResevedSampsValid - (*num))*sizeof(short)
+ );
+ paf_resampe_ctl->ResevedSampsValid -= (*num);
+ }
+
+}
+
+
+
+void af_get_pcm_in_resampler(af_resampe_ctl_t *paf_resampe_ctl, short*buf, int *len)
+{
+ int NumSamp_out = *len;
+ int rest_pcm_nums = 0;
+ if ((NumSamp_out >= 0) && (NumSamp_out < paf_resampe_ctl->OutSampReserveLen)) {
+ rest_pcm_nums = paf_resampe_ctl->OutSampReserveLen - NumSamp_out;
+ memcpy(buf, paf_resampe_ctl->OutSampReserveBuf, NumSamp_out * sizeof(short));
+ memmove(paf_resampe_ctl->OutSampReserveBuf,
+ paf_resampe_ctl->OutSampReserveBuf + NumSamp_out,
+ rest_pcm_nums * sizeof(short));
+
+ } else if (NumSamp_out >= paf_resampe_ctl->OutSampReserveLen) {
+ memcpy(buf, paf_resampe_ctl->OutSampReserveBuf,
+ paf_resampe_ctl->OutSampReserveLen * sizeof(short));
+ NumSamp_out = paf_resampe_ctl->OutSampReserveLen;
+ rest_pcm_nums = 0;
+ }
+ *len = NumSamp_out;
+ paf_resampe_ctl->OutSampReserveLen = rest_pcm_nums;
+}
+
+void af_resample_process_linear_inner(af_resampe_ctl_t *paf_resampe_ctl, short *data_in, int *NumSamp_in, short* data_out, int* NumSamp_out, int NumCh)
+{
+
+ int index, ChId;
+ int NumSampsPerCh_in = (*NumSamp_in) / NumCh;
+ int NumSampsPerCh_Pre = paf_resampe_ctl->ResevedSampsValid / NumCh;
+
+ int NumSampsPerCh_out;
+ short buf16_in[MAX_NUMSAMPS_PERCH];
+ short buf16_in_valid;
+ short *pPreSamps = paf_resampe_ctl->ResevedBuf;
+ short *pindex = paf_resampe_ctl->InterpolateIndexArray;
+ int *pcoef = paf_resampe_ctl->InterpolateCoefArray;
+ int input_offset = 0, output_offset = 0;
+ int cur_out_samp_reserve_num = 0;
+
+ if (!paf_resampe_ctl->InitFlag) {
+ af_resample_set_SampsNumRatio(paf_resampe_ctl);
+ }
+ //indecate at the end of pcm stream
+ if (NumSampsPerCh_Pre + NumSampsPerCh_in < paf_resampe_ctl->SampNumIn) {
+ memcpy(pPreSamps + paf_resampe_ctl->ResevedSampsValid, data_in, (*NumSamp_in)*sizeof(short));
+ paf_resampe_ctl->ResevedSampsValid += (*NumSamp_in);
+ //memcpy(data_out,paf_resampe_ctl->ResevedBuf,paf_resampe_ctl->ResevedSampsValid);
+ //*NumSamp_out=paf_resampe_ctl->ResevedSampsValid;
+ *NumSamp_out = 0;
+ } else {
+ int NumSampsPerCh_Rest = NumSampsPerCh_Pre + NumSampsPerCh_in - paf_resampe_ctl->SampNumIn;
+ input_offset += (paf_resampe_ctl->SampNumIn - NumSampsPerCh_Pre) * NumCh;
+ output_offset += paf_resampe_ctl->OutSampReserveLen;
+ memcpy(pPreSamps + paf_resampe_ctl->ResevedSampsValid, data_in, sizeof(short)*input_offset);
+ memcpy(data_out, paf_resampe_ctl->OutSampReserveBuf, sizeof(short)*paf_resampe_ctl->OutSampReserveLen);
+ buf16_in_valid = paf_resampe_ctl->SampNumIn;
+ for (ChId = 0; ChId < NumCh; ChId++) {
+ for (index = 0; index < buf16_in_valid; index++) {
+ buf16_in[index] = pPreSamps[NumCh * index + ChId];
+ }
+ for (index = 0; index < paf_resampe_ctl->SampNumOut - 1; index++) {
+ int pos = pindex[index];
+ short t16;
+ t16 = buf16_in[pos] + Q14_INT_GET((pcoef[index] * (buf16_in[pos + 1] - buf16_in[pos])));
+ data_out[output_offset + NumCh * index + ChId] = t16;
+ }
+ data_out[output_offset + NumCh * (paf_resampe_ctl->SampNumOut - 1) + ChId] = buf16_in[buf16_in_valid - 1];
+ }
+ output_offset += paf_resampe_ctl->SampNumOut * NumCh;
+ paf_resampe_ctl->ResevedSampsValid = 0;
+
+ while (NumSampsPerCh_Rest > paf_resampe_ctl->SampNumIn) {
+ buf16_in_valid = paf_resampe_ctl->SampNumIn;
+ for (ChId = 0; ChId < NumCh; ChId++) {
+ for (index = 0; index < buf16_in_valid; index++) {
+ buf16_in[index] = data_in[input_offset + NumCh * index + ChId];
+ }
+ for (index = 0; index < paf_resampe_ctl->SampNumOut - 1; index++) {
+ int pos = pindex[index];
+ short t16;
+ t16 = buf16_in[pos] + Q14_INT_GET(((int64_t)pcoef[index] * (buf16_in[pos + 1] - buf16_in[pos])));
+ data_out[output_offset + NumCh * index + ChId] = t16;
+ }
+ data_out[output_offset + NumCh * (paf_resampe_ctl->SampNumOut - 1) + ChId] = buf16_in[buf16_in_valid - 1];
+ }
+ NumSampsPerCh_Rest -= paf_resampe_ctl->SampNumIn;
+ input_offset += paf_resampe_ctl->SampNumIn * NumCh;
+ output_offset += paf_resampe_ctl->SampNumOut * NumCh;
+ }
+ cur_out_samp_reserve_num = output_offset % (DEFALT_NUMSAMPS_PERCH * NumCh) ;
+ paf_resampe_ctl->OutSampReserveLen = cur_out_samp_reserve_num;
+
+ memcpy(paf_resampe_ctl->OutSampReserveBuf,
+ data_out + output_offset - cur_out_samp_reserve_num,
+ sizeof(short)*cur_out_samp_reserve_num);
+ *NumSamp_out = output_offset - cur_out_samp_reserve_num;
+
+ if (input_offset < (*NumSamp_in)) {
+ memcpy(pPreSamps, data_in + input_offset, sizeof(short)*NumSampsPerCh_Rest * NumCh);
+ paf_resampe_ctl->ResevedSampsValid = NumSampsPerCh_Rest * NumCh;
+ } else {
+ paf_resampe_ctl->ResevedSampsValid = 0;
+ }
+ }
+}
+
+void af_resample_stop_process(af_resampe_ctl_t *paf_resampe_ctl)
+{
+ //memcpy(pPreservedSamps,paf_resampe_ctl->OutSampReserveBuf,sizeof(short)*paf_resampe_ctl->OutSampReserveLen);
+ //memcpy(pPreservedSamps+paf_resampe_ctl->OutSampReserveLen,paf_resampe_ctl->ResevedBuf,sizeof(short)*paf_resampe_ctl->ResevedSampsValid);
+ //*SampNum=paf_resampe_ctl->OutSampReserveLen + paf_resampe_ctl->ResevedSampsValid;
+ // paf_resampe_ctl->ResevedSampsValid=0;
+ //paf_resampe_ctl->OutSampReserveLen=0;
+ if (paf_resampe_ctl->InitFlag != 0) {
+ audiodsp_set_pcm_resample_delta(0);
+ }
+ paf_resampe_ctl->InitFlag = 0;
+ paf_resampe_ctl->LastResamType = 0;
+ // adec_print("resample stop INIT_FLAG=%d\n",paf_resampe_ctl->InitFlag);
+}
+
+#define MAXCH_NUMBER 8
+#define MAXFRAMESIZE 8192
+short date_temp[MAXCH_NUMBER*MAXFRAMESIZE];
+extern int android_reset_track(struct aml_audio_dec* audec);
+/**
+ * try to read as much data as len from dsp buffer
+ */
+
+static void dump_pcm_bin(char *path, char *buf, int size)
+{
+ FILE *fp = fopen(path, "ab+");
+ if (fp != NULL) {
+ fwrite(buf, 1, size, fp);
+ fclose(fp);
+ }
+}
+
+#define RESAMPLE_FRAMES 128
+void af_resample_api(char* buffer, unsigned int * size, int Chnum, aml_audio_dec_t* audec, int enable, int delta)
+{
+ short data_in[RESAMPLE_FRAMES * 2];
+ short *pbuf;
+ int resample_enable;
+ int resample_type;
+ int resample_delta;
+ int sample_read;
+ int num_sample = 0;
+ int i, j, k, h;
+ int request = *size;
+ int dsp_read = 0;
+ static int last_resample_enable = 0;
+ static int last_delta = 0;
+ pbuf = (short*)date_temp;
+ unsigned index = 0;
+ float mPhaseFraction;
+ float phaseIncrement ;
+ float mPhaseFraction1;
+ unsigned in_sr;
+ unsigned out_sr;
+ short *input;
+ short *output;
+ unsigned frames = 0;
+ in_sr = (RESAMPLE_FRAMES - 1);
+ out_sr = (RESAMPLE_FRAMES - delta - 1);
+ phaseIncrement = (float)in_sr / out_sr;
+ resample_enable = enable;
+ //resample_delta = 0;i
+ resample_delta = delta;
+
+ if (last_resample_enable != resample_enable || last_delta != delta) {
+ adec_print("resample changed: %s,delta %d\n", resample_enable ? "Enabled" : "Disabled", delta);
+ last_resample_enable = resample_enable;
+ last_delta = delta;
+ }
+
+ if (resample_enable && resample_delta && *size >= RESAMPLE_FRAMES * sizeof(short)*Chnum) {
+ //adec_print("resample start ... %d, step=%d\n", *size, resample_delta);
+ if (resample_delta < 0) {
+ *size = *size * RESAMPLE_FRAMES / (RESAMPLE_FRAMES - resample_delta);
+ *size &= ~(2 * Chnum - 1);
+ }
+ sample_read = dsp_pcm_read(audec, pbuf, *size); // return mono sample number
+ dsp_read += sample_read;
+ //adec_print("dsp read %d\n", sample_read);
+ k = 0;
+ while (sample_read >= RESAMPLE_FRAMES * Chnum) {
+ mPhaseFraction = 0;
+ mPhaseFraction1 = 0;
+ index = 0;
+ input = (short*)pbuf + frames * Chnum;
+ output = (short*)buffer + k * Chnum;
+ for (j = 0; j < RESAMPLE_FRAMES - resample_delta; j++) {
+ if (Chnum == 2) {
+ output[2 * j] = input[index * 2] + (short)((input[(index + 1) * 2] - input[index * 2]) * mPhaseFraction1);
+ output[2 * j + 1] = input[index * 2 + 1] + (short)((input[(index + 1) * 2 + 1] - input[index * 2 + 1]) * mPhaseFraction1);
+ } else if (Chnum == 1) {
+ output[j] = input[index] + (short)((input[(index + 1)] - input[index]) * mPhaseFraction1);
+ } else {
+ adec_print("fatal error,only support 1 ch ,2ch audio sample \n");
+ return ;
+ }
+ mPhaseFraction += phaseIncrement;
+ index = mPhaseFraction;
+ mPhaseFraction1 = mPhaseFraction - index;
+ k++;
+ }
+ frames += RESAMPLE_FRAMES;
+ sample_read -= RESAMPLE_FRAMES * Chnum;
+ }
+ if (sample_read > 0) {
+ memcpy((short*)buffer + k * Chnum, (short*)pbuf + frames * Chnum, sample_read * sizeof(short));
+ k += sample_read / Chnum;
+ }
+
+
+ num_sample = k * sizeof(short) * Chnum;
+ if (num_sample < *size) {
+ sample_read = dsp_pcm_read(audec, pbuf, *size - num_sample);
+ dsp_read += sample_read;
+ if (sample_read > 0) {
+ memcpy((short*)buffer + k * Chnum, pbuf, sample_read * sizeof(short));
+ k += sample_read / Chnum;
+ }
+ }
+ *size = k * sizeof(short) * Chnum;
+ //adec_print("resample end ... %d\n", *size);
+ } else {
+ sample_read = dsp_pcm_read(audec, pbuf, *size - num_sample);
+ memcpy(buffer, pbuf, sample_read * sizeof(short));
+ *size = sample_read * sizeof(short);
+ }
+ //adec_print("resample size from %d to %d, original %d\n", request, *size, dsp_read);
+}
+
+void af_resample_api_normal(char *buffer, unsigned int *size, int Chnum, aml_audio_dec_t *audec)
+{
+ int len;
+ int resample_enable;
+ af_resampe_ctl_t *paf_resampe_ctl;
+ short data_in[MAX_NUMSAMPS_PERCH * DEFALT_NUMCH], *data_out;
+ short outbuftmp16[MAX_NUMSAMPS_PERCH * DEFALT_NUMCH];
+ int NumSamp_in, NumSamp_out, NumCh, NumSampRequir = 0;
+ static int print_flag = 0;
+ int outbuf_offset = 0;
+ int dsp_format_changed_flag = 0;
+ static int pcm_left_len = -1;
+ //------------------------------------------
+ NumCh = Chnum; //buffer->channelCount;
+ resample_enable = af_get_resample_enable_flag();
+ paf_resampe_ctl = af_resampler_ctx_get();
+ data_out = date_temp; //buffer->i16
+ NumSamp_out = *size / sizeof(short); //buffer->size/sizeof(short);
+ if (NumSamp_out > MAXCH_NUMBER * MAXFRAMESIZE) {
+ NumSamp_out = MAXCH_NUMBER * MAXFRAMESIZE;
+ }
+ NumSampRequir = NumSamp_out;
+ int resample_type = af_get_resample_type();
+
+ //adec_print("REQURE_NUM-----------------------------%d\n",NumSamp_out);
+
+ //-------------------------------
+ //add this part for support rapid Resample_Type covet:
+ if (resample_enable) {
+ if (paf_resampe_ctl->LastResamType != resample_type) {
+ //adec_print("ReSample Type Changed: FromTYpe/%d ToType/%d \n",
+ // paf_resampe_ctl->LastResamType,resample_type);
+ amsysfs_set_sysfs_int("sys/class/amaudio/resample_type", resample_type);
+ if ((paf_resampe_ctl->OutSampReserveLen == 0) // to ensure phase continue:
+ && (paf_resampe_ctl->ResevedSampsValid == 0)) {
+ //adec_print("ReSample Type Changed: ENABLE");
+ af_resample_stop_process(paf_resampe_ctl);
+ } else {
+ //adec_print("ReSample Type Changed DISABLE:");
+ // adec_print(" OutSampSaved/%d InSampSaved/%d in Resampler!",
+ // paf_resampe_ctl->OutSampReserveLen,paf_resampe_ctl->ResevedSampsValid);
+ resample_enable = 0;
+ }
+
+ }
+ }
+ //-------------------------------
+ if (resample_enable) {
+ int pcm_cnt = 0;
+ if (!paf_resampe_ctl->InitFlag) {
+ af_resample_set_SampsNumRatio(paf_resampe_ctl);
+ }
+ af_get_pcm_in_resampler(paf_resampe_ctl, data_out + outbuf_offset, &NumSampRequir);
+
+ //adec_print("RETURN_SIZE_1:%d OutSampReserve=%d \n",NumSampRequir,paf_resampe_ctl->OutSampReserveLen);
+
+ outbuf_offset += NumSampRequir;
+ NumSamp_out -= NumSampRequir;
+ while (NumSamp_out >= DEFALT_NUMSAMPS_PERCH * NumCh) {
+ int delta_input_sampsnum = af_get_delta_inputsampnum(paf_resampe_ctl, NumCh);
+ NumSamp_in = dsp_pcm_read(audec, (char*)data_in, delta_input_sampsnum * sizeof(short));
+ af_resample_process_linear_inner(paf_resampe_ctl, data_in, &NumSamp_in, data_out + outbuf_offset, &pcm_cnt, NumCh);
+
+ //adec_print("RETURN_SIZE_2:%d OutSampReserve=%d \n",pcm_cnt,paf_resampe_ctl->OutSampReserveLen);
+
+ if (pcm_cnt == 0) {
+ goto resample_out;
+ }
+ outbuf_offset += pcm_cnt;
+ NumSamp_out -= pcm_cnt;
+ }
+
+ if (NumSamp_out > 0) {
+ int delta_input_sampsnum = af_get_delta_inputsampnum(paf_resampe_ctl, NumCh);
+ NumSamp_in = dsp_pcm_read(audec, (char*)data_in, delta_input_sampsnum * sizeof(short));
+ af_resample_process_linear_inner(paf_resampe_ctl, data_in, &NumSamp_in, outbuftmp16, &pcm_cnt, NumCh);
+ if (pcm_cnt == 0) {
+ goto resample_out;
+ }
+
+ //adec_print("RETURN_SIZE_3:%d OutSampReserve=%d \n",NumSamp_out,pcm_cnt-NumSamp_out);
+
+ memcpy(data_out + outbuf_offset, outbuftmp16, NumSamp_out * sizeof(short));
+ outbuf_offset += NumSamp_out;
+ memcpy(paf_resampe_ctl->OutSampReserveBuf, outbuftmp16 + NumSamp_out, (pcm_cnt - NumSamp_out)*sizeof(short));
+ paf_resampe_ctl->OutSampReserveLen = (pcm_cnt - NumSamp_out);
+ }
+
+ } else {
+ if (paf_resampe_ctl->OutSampReserveLen > 0) {
+ af_get_pcm_in_resampler(paf_resampe_ctl, data_out + outbuf_offset, &NumSampRequir);
+ //adec_print("RETURN_SIZE_4:%d OutSampReserve=%d \n",NumSampRequir,paf_resampe_ctl->OutSampReserveLen);
+ outbuf_offset += NumSampRequir;
+ NumSamp_out -= NumSampRequir;
+ NumSampRequir = NumSamp_out;
+ }
+
+ if (paf_resampe_ctl->ResevedSampsValid > 0) {
+ af_get_unpro_inputsampnum(paf_resampe_ctl, data_out + outbuf_offset, &NumSampRequir);
+ //adec_print("RETURN_SIZE_5:%d OutSampReserve=%d \n",NumSampRequir,paf_resampe_ctl->ResevedSampsValid);
+ outbuf_offset += NumSampRequir;
+ NumSamp_out -= NumSampRequir;
+ }
+
+ if ((paf_resampe_ctl->OutSampReserveLen == 0) && (paf_resampe_ctl->ResevedSampsValid == 0)) {
+ af_resample_stop_process(paf_resampe_ctl);
+ }
+
+ if (NumSamp_out > 0) {
+ len = audec->adsp_ops.dsp_read(&audec->adsp_ops, (char*)(data_out + outbuf_offset), NumSamp_out * sizeof(short));
+ outbuf_offset += len / sizeof(short);
+ audec->pcm_bytes_readed += len;
+ }
+ }
+resample_out:
+
+ *size = outbuf_offset * sizeof(short);
+ memcpy(buffer, data_out, *size);
+ if (pcmfd >= 0) {
+ write(pcmfd, buffer, *size);
+ }
+ //------------------------------------
+ dsp_format_changed_flag = audiodsp_format_update(audec);
+ if (dsp_format_changed_flag > 0) {
+ pcm_left_len = audiodsp_get_pcm_left_len();
+ }
+ if (pcm_left_len >= 0) {
+ if (pcm_left_len > (*size)) {
+ pcm_left_len -= (*size);
+ memset((char*)(data_out), 0, *size);
+ } else if (pcm_left_len <= (*size)) {
+ memset((char*)(data_out), 0, pcm_left_len);
+ pcm_left_len = -1;
+
+ }
+ }
+ //dump_pcm_bin("/data/post1.pcm",(char*)(buffer->i16),buffer->size);
+ //---------------------------------------------
+
+}
+#endif
diff --git a/amadec/audio_out/aml_resample.h b/amadec/audio_out/aml_resample.h
new file mode 100644
index 0000000..150cbff
--- a/dev/null
+++ b/amadec/audio_out/aml_resample.h
@@ -0,0 +1,86 @@
+
+#ifndef __AML_RESAMPLE_H__
+#define __AML_RESAMPLE_H__
+
+#include <audio-dec.h>
+#include <adec-pts-mgt.h>
+#include <audiodsp_update_format.h>
+#define Q14(ratio) ((ratio)*(1<<14))
+#define Q14_INT_GET(value) ((value)>>14)
+#define Q14_FRA_GET(value) ((value)&0x3fff)
+
+#define RESAMPLE_DELTA_NUMSAMPS 1
+#define DEFALT_NUMSAMPS_PERCH 128
+#define MAX_NUMSAMPS_PERCH (DEFALT_NUMSAMPS_PERCH + RESAMPLE_DELTA_NUMSAMPS)
+#define DEFALT_NUMCH 2
+
+#define RESAMPLE_TYPE_NONE 0
+#define RESAMPLE_TYPE_DOWN 1
+#define RESAMPLE_TYPE_UP 2
+
+#define RESAMPLE_DOWN_FORCE_PCR_SLOW 3
+
+typedef struct af_resampe_ctl_s {
+ int SampNumIn;
+ int SampNumOut;
+ int InterpolateCoefArray[MAX_NUMSAMPS_PERCH];
+ short InterpolateIndexArray[MAX_NUMSAMPS_PERCH];
+ short ResevedBuf[MAX_NUMSAMPS_PERCH*DEFALT_NUMCH];
+ short ResevedSampsValid;
+ short OutSampReserveBuf[MAX_NUMSAMPS_PERCH*DEFALT_NUMCH];
+ short OutSampReserveLen;
+ short InitFlag;
+ short LastResamType;
+ int resample_type;
+ short enable_resample;
+} af_resampe_ctl_t;
+
+void af_resample_linear_init(struct aml_audio_dec* audec);
+
+void af_resample_linear_stop(struct aml_audio_dec* audec);
+
+int af_get_resample_enable_flag();
+
+af_resampe_ctl_t* af_resampler_ctx_get();
+
+void af_resample_set_SampsNumRatio(af_resampe_ctl_t *paf_resampe_ctl);
+
+void af_get_pcm_in_resampler(af_resampe_ctl_t *paf_resampe_ctl, short*buf, int *len);
+
+
+void af_resample_process_linear_inner(af_resampe_ctl_t *paf_resampe_ctl,
+ short *data_in, int *NumSamp_in,
+ short* data_out, int* NumSamp_out, int NumCh);
+void af_resample_stop_process(af_resampe_ctl_t *paf_resampe_ctl);
+
+
+int af_get_delta_inputsampnum(af_resampe_ctl_t *paf_resampe_ctl, int Nch);
+
+void af_get_unpro_inputsampnum(af_resampe_ctl_t *paf_resampe_ctl, short *buf, int *num);
+
+void af_resample_api_normal(char *buffer, unsigned int *size, int Chnum, aml_audio_dec_t *audec);
+
+void af_resample_api(char* buffer, unsigned int * size, int Chnum, aml_audio_dec_t* audec, int enable, int delta);
+
+int af_set_resample_type(int val);
+
+void af_pcrmaster_resample_api(char *buffer, unsigned int *size, int Chnum, aml_audio_dec_t *audec/*, int enable, int delta*/);
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/amadec/audio_out/android-out.cpp b/amadec/audio_out/android-out.cpp
new file mode 100755
index 0000000..d380ca3
--- a/dev/null
+++ b/amadec/audio_out/android-out.cpp
@@ -0,0 +1,1640 @@
+/**
+ * \file android-out.cpp
+ * \brief Functions of Auduo output control for Android Platform
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#include <utils/RefBase.h>
+#include <utils/KeyedVector.h>
+#include <utils/threads.h>
+#include <media/AudioSystem.h>
+#include <media/AudioTrack.h>
+#include <binder/IPCThreadState.h>
+#include <binder/ProcessState.h>
+#include <media/AudioParameter.h>
+#include <system/audio_policy.h>
+#include <cutils/properties.h>
+
+extern "C" {
+#include <audio-dec.h>
+#include <adec-pts-mgt.h>
+#include <log-print.h>
+#include "aml_resample.h"
+#include <audiodsp_update_format.h>
+#include <Amsysfsutils.h>
+#include <amthreadpool.h>
+}
+#include "adec-external-ctrl.h"
+namespace android
+{
+
+#if ANDROID_PLATFORM_SDK_VERSION >= 21
+//android 5.0 level= 20
+#define AUDIO_FORMAT_EAC3 AUDIO_FORMAT_E_AC3
+#endif
+#if ANDROID_PLATFORM_SDK_VERSION >= 23
+#define AUDIO_FORMAT_DTS_MASTER 0x0E000000UL
+#endif
+#define DOLBY_SYSTEM_CHANNEL "ds1.audio.multichannel.support"
+static Mutex mLock;
+static Mutex mLock_raw;
+//get default output sample rate which maybe changed by raw output
+static int default_sr = 48000;
+static int fill_audiotrack_zero = 0;
+static int buffering_audio_data = 0;
+static int skip_unnormal_discontinue = 0;
+static int unnormal_discontinue = 0;
+static int unnormal_discontinue1 = 0;
+extern "C" int get_audio_decoder(void);
+static int get_digitalraw_mode(void)
+{
+ return amsysfs_get_sysfs_int("/sys/class/audiodsp/digital_raw");
+}
+#define DTSETC_DECODE_VERSION_CORE 350
+#define DTSETC_DECODE_VERSION_M6_M8 380
+#define DTSHD_IEC958_PKTTYPE_CORE 0 //common feature for DTSETC_DECODE_VERSION 350/380,so set it to 0 by default
+#define DTSHD_IEC958_PKTTYPE_SINGLEI2S 1
+#define DTSHD_IEC958_PKTTYPE_FOURI2S 2
+
+void restore_system_samplerate(struct aml_audio_dec* audec)
+{
+#if defined(ANDROID_VERSION_JBMR2_UP)
+ unsigned int sr = 0;
+#else
+ int sr = 0;
+#endif
+ if( audec->format == ACODEC_FMT_TRUEHD ||
+ (audec->format==ACODEC_FMT_DTS && audec->VersionNum==DTSETC_DECODE_VERSION_M6_M8 && audec->DTSHDIEC958_FS>192000 && amsysfs_get_sysfs_int("/sys/class/audiodsp/digital_raw")==2))
+ {
+ ;//do nothing
+ }else if(audec->samplerate == 48000 || (audec->format != ACODEC_FMT_DTS && \
+ audec->format != ACODEC_FMT_AC3 && audec->format != ACODEC_FMT_EAC3 &&
+ audec->format != ACODEC_FMT_TRUEHD))
+ return ;
+ audio_io_handle_t handle = -1;
+//for mx, raw/pcm use the same audio hal
+#ifndef USE_ARM_AUDIO_DEC
+ handle = AudioSystem::getOutput(AUDIO_STREAM_MUSIC,
+ 48000,
+ AUDIO_FORMAT_PCM_16_BIT,
+ AUDIO_CHANNEL_OUT_STEREO,
+#if defined(_VERSION_ICS)
+ AUDIO_POLICY_OUTPUT_FLAG_INDIRECT
+#else //JB...
+ AUDIO_OUTPUT_FLAG_PRIMARY
+#endif
+ );
+ if(handle > 0){
+ char str[64];
+ memset(str,0,sizeof(str));
+ sprintf(str,"sampling_rate=%d",default_sr);
+ AudioSystem::setParameters(handle, String8(str));
+ }
+#else
+//for M8, raw/pcm output use different HAL, so only check the raw output device
+ handle = AudioSystem::getOutput(AUDIO_STREAM_MUSIC,
+ 48000,
+ AUDIO_FORMAT_AC3, //use AC3 as the format tag for all raw output
+ AUDIO_CHANNEL_OUT_STEREO,
+#if defined(_VERSION_ICS)
+ AUDIO_POLICY_OUTPUT_FLAG_INDIRECT
+#else //JB...
+ AUDIO_OUTPUT_FLAG_DIRECT
+#endif
+ );
+
+ if(handle > 0){
+ char str[64];
+ memset(str,0,sizeof(str));
+ sprintf(str,"sampling_rate=%d",default_sr);
+ AudioSystem::setParameters(handle, String8(str));
+#if ANDROID_PLATFORM_SDK_VERSION >= 22
+ AudioSystem::releaseOutput(handle, AUDIO_STREAM_DEFAULT, AUDIO_SESSION_OUTPUT_STAGE);
+#else
+ AudioSystem::releaseOutput(handle);
+#endif
+ }else{
+ adec_print("WARNIN: handle/%d resetore sysFs failed!\n",handle);
+ }
+#endif
+}
+
+#if defined(ANDROID_VERSION_JBMR2_UP)
+static size_t old_frame_count = 0;
+#else
+static int old_frame_count = 0;
+#endif
+
+void restore_system_framesize()
+{
+ if(old_frame_count == 0){
+ adec_print("frame size can't be zero !\n");
+ return;
+ }
+ adec_print("restore system frame size\n");
+ int sr = 0;
+ audio_io_handle_t handle = -1;
+ handle = AudioSystem::getOutput(AUDIO_STREAM_MUSIC,
+ 48000,
+ AUDIO_FORMAT_PCM_16_BIT,
+ AUDIO_CHANNEL_OUT_STEREO,
+#if defined(_VERSION_ICS)
+ AUDIO_POLICY_OUTPUT_FLAG_INDIRECT
+#else //JB...
+ AUDIO_OUTPUT_FLAG_PRIMARY
+#endif
+ );
+ if(handle > 0){
+ char str[64];
+ int ret;
+ memset(str,0,sizeof(str));
+#if defined(ANDROID_VERSION_JBMR2_UP)
+ sprintf(str,"frame_count=%zd",old_frame_count);
+ ret = AudioSystem::setParameters(handle, String8(str));
+ adec_print("restore frame success: %zd\n", old_frame_count);
+#else
+ sprintf(str,"frame_count=%zd",old_frame_count);
+ ret = AudioSystem::setParameters(handle, String8(str));
+ adec_print("restore frame success: %zd\n", old_frame_count);
+#endif
+ }
+}
+
+void reset_system_samplerate(struct aml_audio_dec* audec)
+{
+ unsigned digital_raw = 0;
+ audio_io_handle_t handle = -1;
+ int dtsFS_88_96_Directout=0;
+ digital_raw = get_digitalraw_mode();
+ if(audec->format == ACODEC_FMT_DTS && audec->samplerate>48000 && !digital_raw)
+ {
+ char tmp[128]={0};
+ if(property_get("media.libplayer.88_96K", tmp, "0") > 0 && !strcmp(tmp, "1"))
+ dtsFS_88_96_Directout=1;
+ }
+ if(!audec || (!digital_raw && audec->channels!=8 && !dtsFS_88_96_Directout))
+ return;
+ /*
+ 1)32k,44k dts
+ 2) 32k,44k ac3
+ 3)44.1k eac3 when hdmi passthrough
+ 4)32k,44k eac3 when spdif pasthrough
+ */
+ adec_print("[%s %d]format %d,audec->samplerate%d DTSHDIEC958_FS/%d\n",__FUNCTION__,__LINE__,audec->format ,audec->samplerate,audec->DTSHDIEC958_FS );
+ int Samplerate=audec->samplerate;
+ int dts_raw_reset_sysFS=0;
+ if( (audec->format == ACODEC_FMT_DTS && digital_raw==1)
+ ||(audec->format == ACODEC_FMT_DTS && digital_raw==2 && audec->VersionNum!=DTSETC_DECODE_VERSION_M6_M8)
+ ||(audec->format == ACODEC_FMT_DTS && digital_raw==2 && audec->VersionNum==DTSETC_DECODE_VERSION_M6_M8 && audec->DTSHDIEC958_PktType==DTSHD_IEC958_PKTTYPE_CORE)
+ )
+ { //DTS raw_stream Directoutput
+ if(audec->samplerate%48000!=0)
+ dts_raw_reset_sysFS=1;
+ if(audec->samplerate==32000 || audec->samplerate==44100)
+ Samplerate=audec->samplerate;
+ else if(audec->samplerate==88200 || audec->samplerate==96000)
+ Samplerate=audec->samplerate/2;
+ else if(audec->samplerate==176400 || audec->samplerate==192000)
+ Samplerate=audec->samplerate/4;
+ else{
+ adec_print("[%s %d] Unvalid samplerate/%d for DTSCore Rawoutput\n",__FUNCTION__,__LINE__,audec->samplerate);
+ return;
+ }
+ }else if(audec->format == ACODEC_FMT_DTS && digital_raw==2 && audec->VersionNum==DTSETC_DECODE_VERSION_M6_M8 && audec->DTSHDIEC958_PktType==DTSHD_IEC958_PKTTYPE_SINGLEI2S){
+ //DTSHD SingleI2s raw_stream Directoutput
+ if(audec->DTSHDIEC958_FS==48000||audec->DTSHDIEC958_FS==44100)
+ {
+ Samplerate=audec->DTSHDIEC958_FS;
+ }else if(audec->DTSHDIEC958_FS==192000||audec->DTSHDIEC958_FS==1764000){
+ Samplerate =audec->DTSHDIEC958_FS/4;
+ }else{
+ adec_print("[%s %d] Unvalid DTSHDIEC958_FS/%d for DTSHD RawOutput\n",__FUNCTION__,__LINE__,audec->DTSHDIEC958_FS);
+ return;
+ }
+ if(Samplerate%48000!=0)
+ dts_raw_reset_sysFS=1;
+ }else if(audec->format==ACODEC_FMT_DTS && digital_raw==2&& audec->VersionNum==DTSETC_DECODE_VERSION_M6_M8&& audec->DTSHDIEC958_PktType==DTSHD_IEC958_PKTTYPE_FOURI2S){
+ //DTSLL FourI2s raw_stream Directoutput
+ if(audec->DTSHDIEC958_FS==192000||audec->DTSHDIEC958_FS==384000 || audec->DTSHDIEC958_FS==768000 ||
+ audec->DTSHDIEC958_FS==176400||audec->DTSHDIEC958_FS==352800 || audec->DTSHDIEC958_FS==705600)
+ {
+ Samplerate=audec->DTSHDIEC958_FS/4;
+ }else{
+ adec_print("[%s %d] Unvalid DTSHDIEC958_FS/%d for DTSLL RawOutput\n",__FUNCTION__,__LINE__,audec->DTSHDIEC958_FS);
+ return;
+ }
+ if(Samplerate!=48000)
+ dts_raw_reset_sysFS=1;
+ }else if(audec->format == ACODEC_FMT_DTS&& (audec->samplerate>48000|| (audec->channels==8&&audec->samplerate!=48000))){
+ //DTS HD_PCM(FS>48000) Directoutput/8ch DTS_PCM output
+ dts_raw_reset_sysFS=1;
+ Samplerate=audec->samplerate;
+ }else if(audec->format == ACODEC_FMT_TRUEHD && (digital_raw == 1 || digital_raw == 2)){
+ //Dobly TrueHD RawOutput
+ Samplerate = 192000;
+ }
+ if( (audec->format == ACODEC_FMT_AC3 && (audec->samplerate == 32000 || audec->samplerate == 44100))
+ ||(audec->format == ACODEC_FMT_EAC3 && digital_raw == 2 && audec->samplerate == 44100)
+ ||(audec->format == ACODEC_FMT_EAC3 && digital_raw == 1 && (audec->samplerate == 32000 || audec->samplerate == 44100))
+ || dts_raw_reset_sysFS
+ ||(audec->format == ACODEC_FMT_TRUEHD && (digital_raw == 1 || digital_raw == 2)/* &&
+ (audec->samplerate == 192000 || audec->samplerate == 96000)*/))
+
+ {
+ adec_print("[%s %d]Change AudioSysFS to/%d\n",__FUNCTION__,__LINE__,Samplerate);
+ int sr = 0;
+ if(/*sr*/48000 != Samplerate){
+#ifndef USE_ARM_AUDIO_DEC
+ handle = AudioSystem::getOutput(AUDIO_STREAM_MUSIC,
+ 48000,
+ AUDIO_FORMAT_PCM_16_BIT,
+ AUDIO_CHANNEL_OUT_STEREO,
+#if defined(_VERSION_ICS)
+ AUDIO_POLICY_OUTPUT_FLAG_INDIRECT
+#else //JB...
+ AUDIO_OUTPUT_FLAG_PRIMARY
+#endif
+ );
+ if(handle > 0){
+ char str[64];
+ memset(str,0,sizeof(str));
+ sprintf(str,"sampling_rate=%d",audec->samplerate);
+ AudioSystem::setParameters(handle, String8(str));
+ }
+#else
+ //for M8, raw/pcm output use different HAL, so only check the raw output device
+ handle = AudioSystem::getOutput(AUDIO_STREAM_MUSIC,
+ 48000,
+ AUDIO_FORMAT_AC3, //use AC3 as the format tag for all raw output
+ AUDIO_CHANNEL_OUT_STEREO,
+#if defined(_VERSION_ICS)
+ AUDIO_POLICY_OUTPUT_FLAG_INDIRECT
+#else //JB...
+ AUDIO_OUTPUT_FLAG_DIRECT
+#endif
+ );
+
+ if(handle > 0){
+ char str[64];
+ memset(str,0,sizeof(str));
+ sprintf(str,"sampling_rate=%d",Samplerate);
+ AudioSystem::setParameters(handle, String8(str));
+#if ANDROID_PLATFORM_SDK_VERSION >= 22
+ AudioSystem::releaseOutput(handle, AUDIO_STREAM_DEFAULT, AUDIO_SESSION_OUTPUT_STAGE);
+#else
+ AudioSystem::releaseOutput(handle);
+#endif
+ }else{
+ adec_print("WARNIN:handle/%d reset sysFs failed!\n",handle);
+ }
+#endif
+
+ }
+
+
+ }
+}
+
+/**
+ * \brief callback function invoked by android
+ * \param event type of event notified
+ * \param user pointer to context for use by the callback receiver
+ * \param info pointer to optional parameter according to event type
+ */
+
+#define AMSTREAM_IOC_MAGIC 'S'
+#define AMSTREAM_IOC_GET_LAST_CHECKIN_APTS _IOR(AMSTREAM_IOC_MAGIC, 0xa9, unsigned long)
+#define AMSTREAM_IOC_GET_LAST_CHECKIN_VPTS _IOR(AMSTREAM_IOC_MAGIC, 0xaa, unsigned long)
+#define AMSTREAM_IOC_GET_LAST_CHECKOUT_APTS _IOR(AMSTREAM_IOC_MAGIC, 0xab, unsigned long)
+#define AMSTREAM_IOC_GET_LAST_CHECKOUT_VPTS _IOR(AMSTREAM_IOC_MAGIC, 0xac, unsigned long)
+#define AMSTREAM_IOC_AB_STATUS _IOR(AMSTREAM_IOC_MAGIC, 0x09, int)
+
+static unsigned long long ttt = 0;
+
+static int resample = 0, last_resample = 0, resample_step = 0, last_step=0;
+static int xxx;
+static int diff_record[0x40], diff_wp = 0;
+static int wfd_enable = 0, bytes_skipped = 0x7fffffff;
+static int wfd_ds_thrdhold = 250; //audio pts delay threadhold for down sampling
+static int wfd_us_thrdhold = 150;//audio pts delay threadhold for up sampling
+
+#if ANDROID_PLATFORM_SDK_VERSION >= 19
+static sp<AudioTrack> mpAudioTrack;
+static sp<AudioTrack> mpAudioTrack_raw;
+#endif
+
+struct buf_status {
+ int size;
+ int data_len;
+ int free_len;
+ unsigned int read_pointer;
+ unsigned int write_pointer;
+};
+
+struct am_io_param {
+ int data;
+ int len; //buffer size;
+ struct buf_status status;
+};
+
+static int mix_lr_channel_enable=0;
+static int pre_gain_enable=0;
+static void momo2_mode_mix(short*buf, int nsamps, int channels)
+{
+ int i;
+ int step=4;//assume deffault pcm format: bitwidth/2bytes channels/2
+ short tmpL,tmpR;
+ int tmpSum;
+ short *p16tmp=(short*)buf;
+ if(channels!=2)
+ return;
+ for(i=0;i<nsamps;i+=2)
+ {
+ tmpSum=(p16tmp[i]*3/4)+(p16tmp[i+1]*3/4);
+ tmpSum=tmpSum>32767 ?32767 : tmpSum;
+ tmpSum=tmpSum<-32768?-32768: tmpSum;
+ p16tmp[i]=(tmpSum&0x0000ffff);
+ p16tmp[i+1]=(tmpSum&0x0000ffff);
+ }
+}
+
+static void apply_audio_pregain(void *buf, int size, float gain) {
+ int i;
+ short *sample = (short*)buf;
+ for (i = 0; i < size/sizeof(short); i++)
+ sample[i] = gain*sample[i];
+}
+
+#define RESAMPLE_THRESHOLD (30 * TIME_UNIT90K / 1000)
+void audioCallback(int event, void* user, void *info)
+{
+ int len, i;
+ unsigned last_checkin, last_checkout;
+ unsigned diff, diff_avr;
+ AudioTrack::Buffer *buffer = static_cast<AudioTrack::Buffer *>(info);
+ aml_audio_dec_t *audec = static_cast<aml_audio_dec_t *>(user);
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+ dsp_operations_t *dsp_ops = &audec->adsp_ops;
+ unsigned long apts, pcrscr;
+ struct am_io_param am_io;
+
+ if (event != AudioTrack::EVENT_MORE_DATA) {
+ //adec_refresh_pts(audec);
+ adec_print(" ****************** audioCallback: event = %d g_bst->buf_level/%d g_bst_raw->buf_level/%d [-1:mean unknown] \n", event,audec->g_bst==NULL?-1:audec->g_bst->buf_level,audec->g_bst_raw==NULL?-1:audec->g_bst_raw->buf_level);
+ return;
+ }
+
+ if (buffer == NULL || buffer->size == 0) {
+ adec_print("audioCallback: Wrong buffer\n");
+ return;
+ }
+
+ if(wfd_enable){
+ ioctl(audec->adsp_ops.amstream_fd, AMSTREAM_IOC_GET_LAST_CHECKIN_APTS, &last_checkin);
+ last_checkout = dsp_ops->get_cur_pts(dsp_ops);
+ if(last_checkin < last_checkout){
+ diff = 0;
+ }else{
+ diff = (last_checkin-last_checkout)/90;
+ }
+
+ //ioctl(audec->adsp_ops.amstream_fd, AMSTREAM_IOC_GET_LAST_CHECKOUT_APTS, (int)&last_checkout);
+ }
+ if(wfd_enable){
+ // filtering
+ diff_record[diff_wp++] = diff;
+ diff_wp = diff_wp & 0x3f;
+
+ diff_avr = 0;
+ for (i=0;i<0x40;i++) diff_avr+=diff_record[i];
+ diff_avr = diff_avr / 0x40;
+
+ // if ((xxx++ % 30) == 0)
+ // adec_print("audioCallback start: request %d, in: %d, out: %d, diff: %d, filtered: %d",buffer->size, last_checkin/90, last_checkout/90, diff, diff_avr);
+ if(bytes_skipped == 0 && diff < 200){
+ if(dsp_ops->set_skip_bytes)
+ dsp_ops->set_skip_bytes(&audec->adsp_ops, 0x7fffffff);
+ bytes_skipped = 0x7fffffff;
+ }
+
+ if(diff >1000){ // too much data in audiobuffer,should be skipped
+ if(dsp_ops->set_skip_bytes)
+ dsp_ops->set_skip_bytes(&audec->adsp_ops, 0);
+ bytes_skipped = 0;
+ adec_print("skip more data: last_checkin[%d]-last_checkout[%d]=%d, diff=%d\n", last_checkin/90, last_checkout/90, (last_checkin-last_checkout)/90, diff);
+ }
+
+ if (diff_avr > /*220*/wfd_ds_thrdhold) {
+ resample = 1; resample_step = 2;
+ } else if (diff_avr</*180*/wfd_us_thrdhold) {
+ // once we see a single shot of low boundry we finish down-sampling
+ resample = 1; resample_step = -2;
+ }else if(resample && (diff_avr < 200)){
+ resample = 0;
+ }
+
+ if (last_resample != resample || last_step != resample_step) {
+ last_resample = resample;
+ last_step = resample_step;
+ adec_print("resample changed to %d, step=%d, diff = %d", resample, resample_step,diff_avr);
+ }
+ }
+#if 1
+ if (audec->tsync_mode == TSYNC_MODE_PCRMASTER && audec->pcrtsync_enable) {
+ if (audec->adis_flag <= 0) {
+ unsigned long apts, pcrscr;
+ int64_t apts64, pcrscr64;
+
+ apts64 = audec->apts64;
+ pcrscr64 = audec->pcrscr64;
+
+ if (apts64 && pcrscr64 && (abs(apts64 - pcrscr64) <= 90000*60*10)) {
+ ioctl(audec->adsp_ops.amstream_fd, AMSTREAM_IOC_AB_STATUS, (unsigned long)&am_io);
+ //adec_print("ab_level=%x, ab_rd_ptr=%x", am_io.status.data_len, am_io.status.read_pointer);
+
+ if (abs(apts64 - pcrscr64) >= 90000*30 && unnormal_discontinue < 400) { // avoid replay apts would be pause
+ unnormal_discontinue++;
+ skip_unnormal_discontinue = 0;
+ unnormal_discontinue1 = 0;
+ } else if (abs(apts64 - pcrscr64) < 90000*30 && abs(apts64 - pcrscr64) >= 90000*3 && unnormal_discontinue1 < 200) {
+ unnormal_discontinue1 ++;
+ unnormal_discontinue = 0;
+ skip_unnormal_discontinue = 0;
+ }
+ //if (((apts64 - pcrscr64) > (int64_t)(audec->fill_trackzero_thrsh)) ||((apts64 > pcrscr64) && (am_io.status.data_len < 0x200))) {
+ if ((apts64 - pcrscr64) > (int64_t)(audec->fill_trackzero_thrsh)) {
+ adec_print("[%s:%d] %d, thrsh:%d, apts64:%lld, pcrscr64:%lld, diff:%lld, lastapts:%lx, pcmsize:%d, abuffer_lv:0x%x\n",
+ __FUNCTION__, __LINE__, fill_audiotrack_zero, audec->fill_trackzero_thrsh,apts64, pcrscr64, apts64-pcrscr64,audec->adsp_ops.last_audio_pts,buffer->size, am_io.status.data_len);
+ if (skip_unnormal_discontinue++ > 10) {
+ memset((char*)(buffer->i16), 0, buffer->size);
+ if (!fill_audiotrack_zero) {
+ adec_pts_pause();
+ }
+ fill_audiotrack_zero = audec->fill_trackzero_thrsh/(20*90);
+ adec_print("[%s:%d] %d, thrsh:%d, apts64:%lld, pcrscr64:%lld, diff:%lld, lastapts:%lx, pcmsize:%d, abuffer_lv:0x%x\n",
+ __FUNCTION__, __LINE__, fill_audiotrack_zero, audec->fill_trackzero_thrsh,apts64, pcrscr64, apts64-pcrscr64,audec->adsp_ops.last_audio_pts,buffer->size, am_io.status.data_len);
+ return;
+ }
+ } else {
+ if (skip_unnormal_discontinue>0) {
+ adec_print("[%s:%d], skip_unnormal_discontinue:%d, fill_audiotrack_zero:%d, apts-pcr:%lld, ---------------------------\n",__FUNCTION__, __LINE__, skip_unnormal_discontinue,fill_audiotrack_zero,apts64 - pcrscr64);
+ skip_unnormal_discontinue = 0;
+ }
+ unnormal_discontinue = 0;
+ unnormal_discontinue1 = 0;
+ }
+ if ((fill_audiotrack_zero > 0) && ((apts64 - pcrscr64) > (int64_t)(70*TIME_UNIT90K/1000))) {
+ fill_audiotrack_zero--;
+
+ if (!fill_audiotrack_zero) {
+ adec_pts_resume();
+ skip_unnormal_discontinue = 0;
+ unnormal_discontinue = 0;
+ unnormal_discontinue1 = 0;
+ }
+
+ memset((char*)(buffer->i16), 0, buffer->size);
+ adec_print("## %d, %d, apts bigger than pcr, 2222 apts64:%lld, pcrscr64:%lld, diff:%lld, \n", fill_audiotrack_zero, buffering_audio_data, apts64, pcrscr64, apts64-pcrscr64);
+ return;
+ } else {
+ if (fill_audiotrack_zero > 0 && ((apts64 - pcrscr64) <= (int64_t)(70*TIME_UNIT90K/1000))
+ && ((apts64 - pcrscr64) > 0)) {
+ fill_audiotrack_zero = 0;
+ adec_pts_resume();
+ skip_unnormal_discontinue = 0;
+ unnormal_discontinue = 0;
+ unnormal_discontinue1 = 0;
+ adec_print("[%s:%d], fill enough! ---------------------------\n",__FUNCTION__, __LINE__);
+ }
+ }
+
+ if (audec->apts64 - audec->last_apts64 > RESAMPLE_THRESHOLD) {
+ int64_t diff_discontinue = abs(pcrscr64 - apts64);
+ if (diff_discontinue > (int64_t)(TIME_UNIT90K * 3)) {
+ adec_print("discontinue: #pcrmaster: %lld, %lld, %lld, %d,%d,--------\n", apts64, pcrscr64,
+ apts64 - pcrscr64, RESAMPLE_THRESHOLD, ((pcrscr64 - apts64) > (int64_t)(100 * TIME_UNIT90K / 1000)));
+ af_set_resample_type(RESAMPLE_TYPE_NONE);
+ } else if ((pcrscr64 - apts64) > (int64_t)RESAMPLE_THRESHOLD) {
+ af_set_resample_type(RESAMPLE_TYPE_DOWN);
+ adec_print("down: #pcrmaster enable:%d, %lld, %lld, %lld, --------\n", af_get_resample_enable_flag(),apts64,pcrscr64,pcrscr64-apts64);
+ } else if ((apts64 - pcrscr64) > (int64_t)RESAMPLE_THRESHOLD) {
+ af_set_resample_type(RESAMPLE_TYPE_UP);
+ adec_print("up: #pcrmaster enable:%d, %lld, %lld, %lld, --------\n", af_get_resample_enable_flag(), apts64,pcrscr64,apts64-pcrscr64);
+ } else {
+ adec_print("none: #pcrmaster: %lld, %lld, %lld, %d,%d,--------\n",
+ apts64,pcrscr64,apts64-pcrscr64,RESAMPLE_THRESHOLD,((pcrscr64 - apts64) > (int64_t)(100*TIME_UNIT90K/1000)));
+ af_set_resample_type(RESAMPLE_TYPE_NONE);
+ }
+ audec->last_apts64 = apts64;
+ }
+ }
+ } else {
+ audec->adis_flag--;
+ adec_print("[%s:%d], pcr:%llx, apts:%llx, tsync_pcr_dispoint:%llx, adis_flag:%d,-------------\n",__FUNCTION__, __LINE__,
+ audec->pcrscr64, audec->apts64, audec->tsync_pcr_dispoint,audec->adis_flag);
+ }
+ }
+#endif
+ if (audec->adsp_ops.dsp_on) {
+ int channels;
+ #if ANDROID_PLATFORM_SDK_VERSION >= 19
+ channels = mpAudioTrack->channelCount();
+ #elif defined(ANDROID_VERSION_JBMR2_UP)
+ AudioTrack *track = (AudioTrack *)out_ops->private_data;
+ channels = track->channelCount();
+ #else
+ channels = buffer->channelCount;
+ #endif
+ if (wfd_enable) {
+ af_resample_api((char*)(buffer->i16), (unsigned int*)&buffer->size, channels, audec, resample, resample_step);
+ } else if (audec->tsync_mode == TSYNC_MODE_PCRMASTER) {
+ af_pcrmaster_resample_api((char*)(buffer->i16), (unsigned int*)&buffer->size, channels, audec);
+ } else {
+ af_resample_api_normal((char*)(buffer->i16), (unsigned int*)&buffer->size, channels, audec);
+ }
+ if (!audec->pre_mute) {
+ if (audec->pre_gain_enable >= 0) {
+ pre_gain_enable = audec->pre_gain_enable;
+ }
+ if (pre_gain_enable) {
+ apply_audio_pregain(buffer->i16, buffer->size, audec->pre_gain);
+ }
+ if (audec->mix_lr_channel_enable >= 0)
+ mix_lr_channel_enable = audec->mix_lr_channel_enable;
+ if (mix_lr_channel_enable && channels == 2) {
+ momo2_mode_mix((short*)(buffer->i16), buffer->size/2,channels);
+ }
+ } else {
+ //mute the buffer by pre-mute flag on
+ memset(buffer->i16, 0, buffer->size);
+ }
+ } else {
+ adec_print("audioCallback: dsp not work!\n");
+ }
+
+
+ if(wfd_enable){
+ if (buffer->size==0) {
+ adec_print("no sample from DSP !!! in: %d, out: %d, diff: %d, filtered: %d", last_checkin/90, last_checkout/90, (last_checkin-last_checkout)/90, diff_avr);
+
+ ioctl(audec->adsp_ops.amstream_fd, AMSTREAM_IOC_AB_STATUS, (unsigned long)&am_io);
+ if (am_io.status.size > 0)
+ adec_print("ab_level=%x,ab_size=%x, alevel:%f, ab_rd_ptr=%x",
+ am_io.status.data_len, am_io.status.size, (float)(am_io.status.data_len)/(am_io.status.size), am_io.status.read_pointer);
+ }
+ }
+ return;
+}
+#ifdef USE_ARM_AUDIO_DEC
+//-------------------------------------------------------------------------
+static void i2s_iec958_sync_force(struct aml_audio_dec* audec,int bytes_readed_diff_allowd)
+{
+ int bytes_err= audec->raw_bytes_readed-audec->pcm_bytes_readed*audec->codec_type;
+ int bytes_cnt;
+ int len;
+ int goon_read_data_flag=1;
+ char tmp[2048];
+ int64_t tmp64;
+ #if 0
+ if(-bytes_err>bytes_readed_diff_allowd)
+ {
+ //958 is lower than i2s :so we discard data
+ bytes_err=-bytes_err;
+ int raw_size_discard=bytes_err-bytes_readed_diff_allowd;
+ bytes_cnt=0;
+ while(bytes_cnt<raw_size_discard && !audec->need_stop){
+ len=audec->adsp_ops.dsp_read_raw(&audec->adsp_ops,tmp,(raw_size_discard-bytes_cnt)>2048?2048:(raw_size_discard-bytes_cnt));
+ bytes_cnt+=len;
+ if (len=0)
+ break;
+ }
+ audec->raw_bytes_readed+=bytes_cnt;
+ }else if(bytes_err>bytes_readed_diff_allowd){
+ //958 is faster than i2s
+ int pcm_size_discard=(bytes_err-bytes_readed_diff_allowd)/audec->codec_type;
+ bytes_cnt=0;
+ while(bytes_cnt<pcm_size_discard && !audec->need_stop){
+ len=audec->adsp_ops.dsp_read(&audec->adsp_ops,tmp,(pcm_size_discard-bytes_cnt)>2048?2048:(pcm_size_discard-bytes_cnt));
+ bytes_cnt+=len;
+ if (len=0)
+ break;
+ }
+ audec->pcm_bytes_readed+=bytes_cnt;
+ }
+ #endif
+ tmp64=audec->pcm_bytes_readed>audec->raw_bytes_readed? audec->raw_bytes_readed:audec->pcm_bytes_readed;
+ audec->pcm_bytes_readed -=tmp64;
+ audec->raw_bytes_readed -=tmp64;
+};
+void audioCallback_raw(int event, void* user, void *info)
+{
+ int len;
+ AudioTrack::Buffer *buffer = static_cast<AudioTrack::Buffer *>(info);
+ aml_audio_dec_t *audec = static_cast<aml_audio_dec_t *>(user);
+ if (event != AudioTrack::EVENT_MORE_DATA) {
+ adec_print("[%s %d]audioCallback: event = %d \n",__FUNCTION__,__LINE__, event);
+ return;
+ }
+ if (buffer == NULL || buffer->size == 0) {
+ adec_print("[%s %d]audioCallback: Wrong buffer\n",__FUNCTION__,__LINE__);
+ return;
+ }
+
+ if(audec->i2s_iec958_sync_flag && audec->raw_bytes_readed< audec->i2s_iec958_sync_gate)
+ { char tmp[4096];
+ int readed_bytes=0;
+ int bytes_readed_diff=audec->raw_bytes_readed-audec->pcm_bytes_readed*audec->codec_type;
+ if(bytes_readed_diff==0){
+ //adec_print("NOTE: bytes_readed_diff/0 audec->pcm_bytes_readed/%d\n",audec->pcm_bytes_readed);
+ while(audec->pcm_bytes_readed==0 && !audec->need_stop){
+ amthreadpool_thread_usleep(2000);
+ }
+ adec_print("NOTE:i2s has started read pcm\n");
+ }
+
+ bytes_readed_diff=audec->raw_bytes_readed-audec->pcm_bytes_readed*audec->codec_type;
+ if(bytes_readed_diff>0){//iec958 was faster than i2s:
+ //adec_print("Iec958 faster than I2s: bytes_readed_diff/%d (SyncGate/%d RawBytesReaded/%lld PcmBytesReaded/%lld codec_type/%f)\n",
+ // bytes_readed_diff,audec->i2s_iec958_sync_gate,audec->raw_bytes_readed,audec->pcm_bytes_readed,audec->codec_type);
+ buffer->size /=8;
+ buffer->size-= (buffer->size%audec->raw_frame_size);
+ memset((char*)(buffer->i16),0,buffer->size);
+ return;
+ }else if(bytes_readed_diff<0){//iec958 was slower than i2s:
+ while((audec->raw_bytes_readed-audec->pcm_bytes_readed*audec->codec_type)<0 &&
+ (audec->raw_bytes_readed <audec->i2s_iec958_sync_gate) &&
+ !audec->need_stop
+ )
+ {
+ bytes_readed_diff=audec->pcm_bytes_readed*audec->codec_type-audec->raw_bytes_readed;
+ //adec_print("iec958 was slower than i2s:bytes_readed_diff/%d\n",-bytes_readed_diff);
+ while(bytes_readed_diff && !audec->need_stop){
+ readed_bytes=audec->adsp_ops.dsp_read_raw(&audec->adsp_ops,tmp,bytes_readed_diff>4096?4096: bytes_readed_diff);
+ audec->raw_bytes_readed+=readed_bytes;
+ bytes_readed_diff-=readed_bytes;
+ if(readed_bytes==0)
+ break;
+ }
+ }
+ //audec->i2s_iec958_sync_flag=0;
+ }
+ }
+
+ if (audec->adsp_ops.dsp_on) {
+ int bytes_cnt=0;
+ while(bytes_cnt<buffer->size && !audec->need_stop){
+ len=audec->adsp_ops.dsp_read_raw(&audec->adsp_ops, (char*)(buffer->i16)+bytes_cnt,buffer->size-bytes_cnt);
+ bytes_cnt+=len;
+ if (len == 0)
+ break;
+ }
+ buffer->size=bytes_cnt;
+ audec->raw_bytes_readed+=bytes_cnt;
+ } else {
+ adec_print("[%s %d]audioCallback: dsp not work!\n",__FUNCTION__,__LINE__);
+ }
+// memset raw data when start playback to walkround HDMI audio format changed noise for some kind of TV set
+ if(audec->format != ACODEC_FMT_TRUEHD ){
+ if(audec->raw_bytes_readed < 16*4*1024)
+ memset((char *)(buffer->i16),0,buffer->size);
+ }
+ return;
+}
+
+extern "C" int android_init_raw(struct aml_audio_dec* audec)
+{
+ Mutex::Autolock _l(mLock_raw);
+ adec_print("[%s %d]android raw_out init",__FUNCTION__,__LINE__);
+ status_t status;
+ AudioTrack *track;
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+ int SampleRate=audec->samplerate;
+ out_ops->private_data_raw=NULL;
+ audio_format_t aformat = AUDIO_FORMAT_INVALID;
+ if((audec->format!=ACODEC_FMT_DTS) &&
+ (audec->format != ACODEC_FMT_AC3) &&
+ (audec->format != ACODEC_FMT_EAC3) &&
+ (audec->format != ACODEC_FMT_TRUEHD))
+ {
+ adec_print("[%s %d]NOTE: now just ACODEC_FMT_DTS_rawoutpu was support! ",__FUNCTION__,__LINE__);
+ return 0;
+ }else if(amsysfs_get_sysfs_int("/sys/class/audiodsp/digital_raw")==0){
+ adec_print("[%s %d]DIGITAL_RAW WAS DISABLE !",__FUNCTION__,__LINE__);
+ return 0;
+ }
+
+ if (audec->format == ACODEC_FMT_DTS)
+ aformat = AUDIO_FORMAT_DTS;
+ else if(audec->format == ACODEC_FMT_AC3)
+ aformat = AUDIO_FORMAT_AC3;
+ else if(audec->format == ACODEC_FMT_EAC3)
+ aformat = AUDIO_FORMAT_EAC3;
+ else if(audec->format == ACODEC_FMT_TRUEHD)
+ aformat = AUDIO_FORMAT_TRUEHD;
+
+ if(audec->format == ACODEC_FMT_TRUEHD){
+ audec->codec_type=16;
+ }
+
+ int dgraw = amsysfs_get_sysfs_int("/sys/class/audiodsp/digital_raw");
+ if (dgraw == 1 ) {
+ if((audec->format == ACODEC_FMT_AC3) ||
+ (audec->format == ACODEC_FMT_EAC3)){
+ /*if spdif pass through,force to DD otuput */
+ aformat = AUDIO_FORMAT_AC3;
+ audec->codec_type=1;
+ }else if(audec->format==ACODEC_FMT_DTS){
+ if(audec->samplerate==88200 || audec->samplerate==96000){
+ audec->codec_type=0.50;
+ SampleRate=audec->samplerate/2;
+ }else if(audec->samplerate==176400 || audec->samplerate==192000){
+ audec->codec_type=0.25;
+ SampleRate=audec->samplerate/4;
+ }else if(audec->samplerate==352800 || audec->samplerate==384000){
+ adec_print("[%s %d]NOTE:Current FS/%d was support! ",__FUNCTION__,__LINE__,audec->samplerate);
+ return 0;
+ }else{//audec->samplerate<=48000
+ audec->codec_type=1;
+ }
+ }
+ }else if(dgraw == 2 ){
+ if(audec->format == ACODEC_FMT_AC3){
+ audec->codec_type=1;
+ }else if(audec->format == ACODEC_FMT_EAC3){
+ audec->codec_type=4;
+ }else if(audec->format==ACODEC_FMT_DTS &&(audec->VersionNum!=DTSETC_DECODE_VERSION_M6_M8 ||audec->DTSHDIEC958_PktType==DTSHD_IEC958_PKTTYPE_CORE)){
+ if(audec->samplerate==88200 || audec->samplerate==96000){
+ audec->codec_type=0.50;
+ SampleRate=SampleRate/2;
+ }else if(audec->samplerate==176400 || audec->samplerate==192000){
+ audec->codec_type=0.25;
+ SampleRate=SampleRate/4;
+ }else if(audec->samplerate==352800 || audec->samplerate==384000){
+ adec_print("[%s %d]NOTE:Current FS/%d was support! ",__FUNCTION__,__LINE__,audec->samplerate);
+ return 0;
+ }else{//audec->samplerate<=48000
+ audec->codec_type=1;
+ }
+ }else if(audec->format==ACODEC_FMT_DTS && audec->VersionNum==DTSETC_DECODE_VERSION_M6_M8){
+ int unvalidpara=0;
+ if(audec->DTSHDIEC958_PktType==DTSHD_IEC958_PKTTYPE_SINGLEI2S){
+ if(audec->DTSHDIEC958_FS==48000||audec->DTSHDIEC958_FS==44100)
+ {
+ SampleRate=audec->DTSHDIEC958_FS;
+ }else if(audec->DTSHDIEC958_FS==192000||audec->DTSHDIEC958_FS==176400){// clock need Mutiple 4
+ SampleRate=audec->DTSHDIEC958_FS/4;
+ #if ANDROID_PLATFORM_SDK_VERSION >= 21//android 5.0
+ aformat = (audio_format_t)AUDIO_FORMAT_DTS_HD;
+ SampleRate=audec->DTSHDIEC958_FS;
+ #endif
+ }else{
+ unvalidpara=1;
+ }
+ }else if(audec->DTSHDIEC958_PktType==DTSHD_IEC958_PKTTYPE_FOURI2S){// clock need Mutiple 4
+ if(audec->DTSHDIEC958_FS==192000||audec->DTSHDIEC958_FS==384000 || audec->DTSHDIEC958_FS==768000 ||
+ audec->DTSHDIEC958_FS==176400||audec->DTSHDIEC958_FS==352800 || audec->DTSHDIEC958_FS==705600)
+ {
+ SampleRate=audec->DTSHDIEC958_FS/4;
+ #if ANDROID_PLATFORM_SDK_VERSION >= 21//android 5.0
+ aformat = (audio_format_t)AUDIO_FORMAT_DTS_MASTER;
+ SampleRate=audec->DTSHDIEC958_FS;
+ #endif
+ }else{
+ unvalidpara=2;
+ }
+ }else{
+ unvalidpara=3;
+ }
+ if(unvalidpara){
+ adec_print("[%s %d]NOTE:Unvalid Paras/%d for RawOutput:PCM_FS/%d IEC958_FS/%d PCMSamsInFrm/%d IEC958PktFrmSize/%d ",
+ __FUNCTION__,__LINE__,unvalidpara,audec->samplerate,audec->DTSHDIEC958_FS,audec->DTSHDPCM_SamsInFrmAtMaxSR,audec->DTSHDIEC958_PktFrmSize);
+ return 0;
+ }
+ audec->codec_type=audec->DTSHDIEC958_FS/audec->samplerate;
+ }
+ }
+
+ if(audec->format == ACODEC_FMT_TRUEHD){
+ SampleRate=192000;
+ }
+ adec_print("[%s %d]SampleRate used for init rawoutput:%d\n",__FUNCTION__,__LINE__,SampleRate);
+
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ track = new AudioTrack();
+ if (track == NULL) {
+ adec_print("[%s %d]AudioTrack_raw Create Failed!",__FUNCTION__,__LINE__);
+ return -1;
+ }
+#else
+ mpAudioTrack_raw = new AudioTrack();
+ track = mpAudioTrack_raw.get();
+#endif
+
+ audio_session_t SessionID = AUDIO_SESSION_NONE;//audec->SessionID;
+ adec_print("[%s %d]SessionID = %d audec->codec_type/%f audec->samplerate/%d",__FUNCTION__,__LINE__,SessionID,audec->codec_type,audec->samplerate);
+ int flags = AUDIO_OUTPUT_FLAG_DIRECT;
+//only defined from android M
+#if ANDROID_PLATFORM_SDK_VERSION >= 23
+ flags |= AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO;
+#endif
+ status = track->set(AUDIO_STREAM_MUSIC,
+ SampleRate,
+ aformat,
+ AUDIO_CHANNEL_OUT_STEREO,
+ 0, // frameCount
+ (audio_output_flags_t)flags,
+ audioCallback_raw,
+ audec, // user when callback
+ 0, // notificationFrames
+ 0, // shared buffer
+ false, // threadCanCallJava
+ SessionID); // sessionId
+ if (status != NO_ERROR) {
+ adec_print("[%s %d]track->set returns %d",__FUNCTION__,__LINE__, status);
+ adec_print("[%s %d]audio out samplet %d",__FUNCTION__,__LINE__, audec->samplerate);
+ adec_print("[%s %d]audio out channels %d",__FUNCTION__,__LINE__, audec->channels);
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ delete track;
+ track = NULL;
+#else
+ track = NULL;
+ mpAudioTrack_raw.clear();
+#endif
+ out_ops->audio_out_raw_enable = 0;
+ out_ops->private_data_raw=NULL;
+ return -1;
+ }
+
+ out_ops->private_data_raw= (void *)track;
+
+ //1/10=0.1s=100ms
+ audec->raw_frame_size=audec->channels*(audec->adec_ops->bps>>3);
+ audec->max_bytes_readded_diff=audec->samplerate*audec->raw_frame_size*audec->codec_type/10;
+ audec->i2s_iec958_sync_gate=audec->samplerate*audec->raw_frame_size*audec->codec_type*0.4;//400ms
+ return 0;
+}
+#endif
+//-------------------------------------------------------------------------
+/**
+ * \brief output initialization
+ * \param audec pointer to audec
+ * \return 0 on success otherwise negative error code
+ */
+extern "C" int android_init(struct aml_audio_dec* audec)
+{
+ Mutex::Autolock _l(mLock);
+ status_t status;
+ AudioTrack *track;
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+ char wfd_prop[PROPERTY_VALUE_MAX];
+ fill_audiotrack_zero = 0;
+ buffering_audio_data = 0;
+ skip_unnormal_discontinue = 0;
+ unnormal_discontinue = 0;
+ unnormal_discontinue1 = 0;
+ ttt = 0;
+ resample = 0;
+ last_resample = 0;
+ xxx = 0;
+ memset(&diff_record[0], 0, 0x40*sizeof(diff_record[0]));
+ diff_wp = 0;
+ if (get_audio_decoder() == AUDIO_ARC_DECODER) {
+ wfd_ds_thrdhold = 220;
+ wfd_us_thrdhold = 180;
+
+ }
+ else{
+ wfd_ds_thrdhold = 250;
+ wfd_us_thrdhold = 150;
+ }
+ adec_print("up/down sampling thread %d /%d ms \n",wfd_us_thrdhold,wfd_ds_thrdhold);
+ if(property_get("media.libplayer.wfd", wfd_prop, "0") > 0){
+ wfd_enable = (strcmp(wfd_prop, "1") == 0);
+ if(wfd_enable)
+ {
+ audio_io_handle_t handle = AudioSystem::getOutput(AUDIO_STREAM_MUSIC,
+ 48000,
+ AUDIO_FORMAT_PCM_16_BIT,
+ AUDIO_CHANNEL_OUT_STEREO,
+#if defined(_VERSION_ICS)
+ AUDIO_POLICY_OUTPUT_FLAG_INDIRECT
+#else //JB...
+ AUDIO_OUTPUT_FLAG_PRIMARY
+#endif
+ );
+ if(handle > 0){
+ char str[64];
+ status_t ret;
+ memset(str,0,sizeof(str));
+ // backup old framecount
+#if ANDROID_PLATFORM_SDK_VERSION >= 21 //FIXME on 5.0
+ AudioSystem::getFrameCount(handle,&old_frame_count);
+#else
+ AudioSystem::getFrameCount(handle, AUDIO_STREAM_MUSIC, &old_frame_count);
+#endif
+
+ sprintf(str,"frame_count=%d",256);
+ ret = AudioSystem::setParameters(handle, String8(str));
+ if(ret != 0){
+ adec_print("change frame count failed: ret = %d\n", ret);
+ }
+ adec_print("wfd: %s", str);
+ }
+ }
+ }else{
+ wfd_enable = 0;
+ }
+
+ adec_get_tsync_info(&(audec->tsync_mode));
+ adec_print("wfd_enable = %d, tsync_mode=%d, ", wfd_enable, audec->tsync_mode);
+ //--------------------------------------------
+ //alwas effect in case:
+ //1: rawoutput==1 && format==ACODEC_FMT_AC3 && (FS==32000 ||FS = =44100)
+ //2: rawoutput==1 && format==ACODEC_FMT_EC3 && (FS==32000 ||FS = =44100)
+ //3: rawoutput==1 && format==ACODEC_FMT_DTS && (FS==32000 ||FS = =44100||FS = =88200||FS = =96000|| FS = =176400|| FS = =192000)
+ //4: rawoutput==2 && format==ACODEC_FMT_EC3 && FS==44100
+ //5: rawoutput==2 && format==ACODEC_FMT_DTS && (FS= =32000||FS = =44100||FS = =88200||FS = =96000|| FS = =176400|| FS = =192000)
+ //6: rawoutput==0 && format==ACODEC_FMT_AC3 && CH==8
+ //summary:always effect in case: rawoutput>0 && (format=ACODEC_FMT_DTS or ACODEC_FMT_AC3) or 8chPCM _output
+/*after 6.0,need not this code*/
+#if ANDROID_PLATFORM_SDK_VERSION < 23
+ reset_system_samplerate(audec);
+#endif
+ int user_raw_enable = amsysfs_get_sysfs_int("/sys/class/audiodsp/digital_raw");
+#ifdef USE_ARM_AUDIO_DEC
+ out_ops->audio_out_raw_enable = user_raw_enable && (audec->format == ACODEC_FMT_DTS ||
+ audec->format == ACODEC_FMT_AC3 ||
+ audec->format == ACODEC_FMT_EAC3||
+ (audec->format == ACODEC_FMT_TRUEHD && user_raw_enable == 2));
+ if(out_ops->audio_out_raw_enable)
+ android_init_raw(audec);
+#endif
+ //---------------------------
+ adec_print("[%s %d]android out init",__FUNCTION__,__LINE__);
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ track = new AudioTrack();
+ if (track == NULL) {
+ adec_print("[%s %d]AudioTrack Create Failed!",__FUNCTION__,__LINE__);
+ return -1;
+ }
+#else
+ mpAudioTrack = new AudioTrack();
+ track = mpAudioTrack.get();
+#endif
+
+ audio_session_t SessionID = audec->SessionID;
+ adec_print("[%s %d]SessionID = %d audec->dtshdll_flag/%d audec->channels/%d",__FUNCTION__,__LINE__,SessionID,audec->dtshdll_flag,audec->channels);
+#if defined(_VERSION_JB)
+ char tmp[128]={0};
+ int FS_88_96_enable=0;
+ if (property_get("media.libplayer.88_96K", tmp, "0") > 0 && !strcmp(tmp, "1")) {
+ FS_88_96_enable=1;
+ if (audec->format == ACODEC_FMT_DTS && audec->samplerate>48000 && !user_raw_enable)
+ {
+ adec_print("set digital_codec to AUDIO_FORMAT_DTS_PCM_88K_96K");
+ }
+ }
+ if( audec->channels == 8 ||
+ (audec->format ==ACODEC_FMT_DTS && audec->samplerate>48000 && user_raw_enable==0 && FS_88_96_enable==1 )
+ )
+ { //8ch PCM: use direct output
+ //DTS PCMoutput && FS>48000: use direct output
+ audio_channel_mask_t ChMask;
+ audio_output_flags_t Flag;
+ audio_format_t aformat;
+ memset(tmp,0,sizeof(tmp));
+ if(audec->channels == 8){
+ adec_print("create multi-channel track use DirectOutput\n");
+ property_set(DOLBY_SYSTEM_CHANNEL,"true");
+ property_get(DOLBY_SYSTEM_CHANNEL, tmp, "0");
+ if(!strcmp(tmp, "true"))
+ {
+ adec_print("[%s %d]ds1.audio.multichannel.support set success!\n",__FUNCTION__,__LINE__);
+ }else{
+ adec_print("[%s %d]ds1.audio.multichannel.support set fail!\n",__FUNCTION__,__LINE__);
+ }
+ ChMask=AUDIO_CHANNEL_OUT_7POINT1;
+ Flag=AUDIO_OUTPUT_FLAG_DEEP_BUFFER;
+ aformat=AUDIO_FORMAT_PCM_16_BIT;
+ }else{
+ adec_print("create HD-PCM(Fs/%d>48000)Direct Ouputtrack\n",audec->samplerate);
+ ChMask=AUDIO_CHANNEL_OUT_STEREO;
+ Flag =AUDIO_OUTPUT_FLAG_DIRECT;
+//TODO
+#if ANDROID_PLATFORM_SDK_VERSION < 23
+ aformat = AUDIO_FORMAT_DTS;
+#else
+ aformat = AUDIO_FORMAT_PCM_16_BIT;
+#endif
+ }
+ status = track->set(AUDIO_STREAM_MUSIC,
+ audec->samplerate,
+ aformat,
+ ChMask,
+ 0, // frameCount
+ Flag/*AUDIO_OUTPUT_FLAG_NONE*/, // flags
+ audioCallback,
+ audec, // user when callback
+ 0, // notificationFrames
+ 0, // shared buffer
+ false, // threadCanCallJava
+ SessionID); // sessionId
+ }else{
+//here calculate the min framecount and set the audiotrack
+//refered to android_media_AudioTrack_get_min_buff_size
+//return frameCount * channelCount * bytesPerSample;
+ size_t frameCount = 0;
+ status = AudioTrack::getMinFrameCount(&frameCount, AUDIO_STREAM_DEFAULT,audec->samplerate);
+ if (status == NO_ERROR) {
+ frameCount = audec->channels*2*frameCount;
+ }
+ else
+ frameCount = 0;
+
+ status = track->set(AUDIO_STREAM_MUSIC,
+ audec->samplerate,
+ AUDIO_FORMAT_PCM_16_BIT,
+ (audec->channels == 1) ? AUDIO_CHANNEL_OUT_MONO : AUDIO_CHANNEL_OUT_STEREO,
+ frameCount, // frameCount
+ AUDIO_OUTPUT_FLAG_NONE, // flags
+ audioCallback,
+ audec, // user when callback
+ 0, // notificationFrames
+ 0, // shared buffer
+ false, // threadCanCallJava
+ SessionID); // sessionId
+ }
+
+#elif defined(_VERSION_ICS)
+ status = track->set(AUDIO_STREAM_MUSIC,
+ audec->samplerate,
+ AUDIO_FORMAT_PCM_16_BIT,
+ (audec->channels == 1) ? AUDIO_CHANNEL_OUT_MONO : AUDIO_CHANNEL_OUT_STEREO,
+ 0, // frameCount
+ 0, // flags
+ audioCallback,
+ audec, // user when callback
+ 0, // notificationFrames
+ 0, // shared buffer
+ false, // threadCanCallJava
+ SessionID); // sessionId
+#else // GB or lower:
+ status = track->set(AudioSystem::MUSIC,
+ audec->samplerate,
+ AudioSystem::PCM_16_BIT,
+ (audec->channels == 1) ? AudioSystem::CHANNEL_OUT_MONO : AudioSystem::CHANNEL_OUT_STEREO,
+ 0, // frameCount
+ 0, // flags
+ audioCallback,
+ audec, // user when callback
+ 0, // notificationFrames
+ 0, // shared buffer
+ SessionID);
+#endif
+
+ if (status != NO_ERROR) {
+ adec_print("[%s %d]track->set returns %d", __FUNCTION__,__LINE__,status);
+ adec_print("[%s %d]audio out samplet %d" , __FUNCTION__,__LINE__, audec->samplerate);
+ adec_print("[%s %d]audio out channels %d", __FUNCTION__,__LINE__,audec->channels);
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ delete track;
+ track = NULL;
+#else
+ track = NULL;
+ mpAudioTrack.clear();
+#endif
+ if(audec->channels == 8){
+ property_set(DOLBY_SYSTEM_CHANNEL,"false");
+ }
+ return -1;
+
+ }
+ af_resample_linear_init(audec);
+ out_ops->private_data = (void *)track;
+ return 0;
+}
+#ifdef USE_ARM_AUDIO_DEC
+extern "C" int android_start_raw(struct aml_audio_dec* audec)
+{
+ Mutex::Autolock _l(mLock_raw);
+ adec_print("[%s %d]android raw_out start",__FUNCTION__,__LINE__);
+ status_t status;
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ AudioTrack *track = (AudioTrack *)out_ops->private_data_raw;
+#else
+ AudioTrack *track = mpAudioTrack_raw.get();
+#endif
+ if (track == 0) {
+ adec_print("[%s %d]No track instance!\n",__FUNCTION__,__LINE__);
+ return -1;
+ }
+
+ status = track->initCheck();
+ if (status != NO_ERROR) {
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ delete track;
+#else
+ mpAudioTrack_raw.clear();
+#endif
+ out_ops->private_data_raw= NULL;
+ return -1;
+ }
+
+ track->start();
+ adec_print("[%s %d]AudioTrack_raw initCheck OK and started.",__FUNCTION__,__LINE__);
+ return 0;
+}
+#endif
+/**
+ * \brief start output
+ * \param audec pointer to audec
+ * \return 0 on success otherwise negative error code
+ *
+ * Call android_start(), then the callback will start being called.
+ */
+extern "C" int android_start(struct aml_audio_dec* audec)
+{
+
+ Mutex::Autolock _l(mLock);
+ status_t status;
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ AudioTrack *track = (AudioTrack *)out_ops->private_data;
+#else
+ AudioTrack *track = mpAudioTrack.get();
+#endif
+
+
+#ifdef USE_ARM_AUDIO_DEC
+ i2s_iec958_sync_force(audec,0);
+ if(out_ops->audio_out_raw_enable)
+ android_start_raw(audec);
+#endif
+ adec_print("android out start");
+ ttt = 0;
+ resample = 0;
+ last_resample = 0;
+ xxx = 0;
+ memset(&diff_record[0], 0, 0x40*sizeof(diff_record[0]));
+ diff_wp = 0;
+ if (track == 0) {
+ adec_print("No track instance!\n");
+ return -1;
+ }
+ status = track->initCheck();
+ if (status != NO_ERROR) {
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ delete track;
+#else
+ mpAudioTrack.clear();
+#endif
+ out_ops->private_data = NULL;
+ return -1;
+ }
+ track->start();
+ adec_print("AudioTrack initCheck OK and started.");
+
+ return 0;
+}
+
+extern "C" int android_pause_raw(struct aml_audio_dec* audec)
+{
+ Mutex::Autolock _l(mLock_raw);
+ adec_print("[%s %d]android raw_out pause",__FUNCTION__,__LINE__);
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ AudioTrack *track = (AudioTrack *)out_ops->private_data_raw;
+#else
+ AudioTrack *track = mpAudioTrack_raw.get();
+#endif
+ if (track == 0) {
+ adec_print("[%s %d]No track instance!\n",__FUNCTION__,__LINE__);
+ return -1;
+ }
+ track->pause();
+ return 0;
+}
+
+/**
+ * \brief pause output
+ * \param audec pointer to audec
+ * \return 0 on success otherwise negative error code
+ */
+extern "C" int android_pause(struct aml_audio_dec* audec)
+{
+
+ Mutex::Autolock _l(mLock);
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ AudioTrack *track = (AudioTrack *)out_ops->private_data;
+#else
+ AudioTrack *track = mpAudioTrack.get();
+#endif
+#ifdef USE_ARM_AUDIO_DEC
+ if(out_ops->audio_out_raw_enable)
+ android_pause_raw(audec);
+#endif
+ adec_print("android out pause");
+
+ if (track == 0) {
+ adec_print("No track instance!\n");
+ return -1;
+ }
+
+ track->pause();
+#ifdef USE_ARM_AUDIO_DEC
+ adec_print("[%s %d] PRE_PAUSE:raw_bytes_readed/%lld pcm_bytes_readed/%lld delta/%lld\n",__FUNCTION__,__LINE__,
+ audec->raw_bytes_readed,audec->pcm_bytes_readed,audec->pcm_bytes_readed-audec->raw_bytes_readed);
+ i2s_iec958_sync_force(audec,0);
+ adec_print("[%s %d] POST_PAUSE:raw_bytes_readed/%lld pcm_bytes_readed/%lld delta/%lld\n",__FUNCTION__,__LINE__,
+ audec->raw_bytes_readed,audec->pcm_bytes_readed,audec->pcm_bytes_readed-audec->raw_bytes_readed);
+ audec->i2s_iec958_sync_flag=1;
+#endif
+ return 0;
+}
+
+extern "C" int android_resume_raw(struct aml_audio_dec* audec)
+{
+ Mutex::Autolock _l(mLock_raw);
+ adec_print("[%s %d]android raw_out resume",__FUNCTION__,__LINE__);
+
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ AudioTrack *track = (AudioTrack *)out_ops->private_data_raw;
+#else
+ AudioTrack *track = mpAudioTrack_raw.get();
+#endif
+ if (track == 0) {
+ adec_print("[%s %d]No track instance!\n",__FUNCTION__,__LINE__);
+ return -1;
+ }
+ track->start();
+ return 0;
+}
+/**
+ * \brief resume output
+ * \param audec pointer to audec
+ * \return 0 on success otherwise negative error code
+ */
+extern "C" int android_resume(struct aml_audio_dec* audec)
+{
+
+ Mutex::Autolock _l(mLock);
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ AudioTrack *track = (AudioTrack *)out_ops->private_data;
+#else
+ AudioTrack *track = mpAudioTrack.get();
+#endif
+
+#ifdef USE_ARM_AUDIO_DEC
+ i2s_iec958_sync_force(audec,0);
+ if(out_ops->audio_out_raw_enable)
+ android_resume_raw(audec);
+#endif
+ adec_print("android out resume");
+ ttt = 0;
+ resample = 0;
+ last_resample = 0;
+ xxx = 0;
+ memset(&diff_record[0], 0, 0x40*sizeof(diff_record[0]));
+ diff_wp = 0;
+ if (track == 0) {
+ adec_print("No track instance!\n");
+ return -1;
+ }
+ track->start();
+
+ return 0;
+}
+#ifdef USE_ARM_AUDIO_DEC
+extern "C" int android_stop_raw(struct aml_audio_dec* audec)
+{
+ Mutex::Autolock _l(mLock_raw);
+ adec_print("[%s %d]android raw_out stop",__FUNCTION__,__LINE__);
+
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ AudioTrack *track = (AudioTrack *)out_ops->private_data_raw;
+#else
+ AudioTrack *track = mpAudioTrack_raw.get();
+#endif
+
+ if (track == 0){
+ adec_print("[%s %d]No track instance!\n",__FUNCTION__,__LINE__);
+ return -1;
+ }
+ track->stop();
+ /* release AudioTrack */
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ delete track;
+#else
+ mpAudioTrack_raw.clear();
+#endif
+
+ out_ops->private_data_raw= NULL;
+ return 0;
+}
+#endif
+/**
+ * \brief stop output
+ * \param audec pointer to audec
+ * \return 0 on success otherwise negative error code
+ */
+extern "C" int android_stop(struct aml_audio_dec* audec)
+{
+ Mutex::Autolock _l(mLock);
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ AudioTrack *track = (AudioTrack *)out_ops->private_data;
+#else
+ AudioTrack *track = mpAudioTrack.get();
+#endif
+#ifdef USE_ARM_AUDIO_DEC
+ if(out_ops->audio_out_raw_enable)
+ android_stop_raw(audec);
+#endif
+ adec_print("android out stop");
+ if(audec->channels == 8){
+ property_set(DOLBY_SYSTEM_CHANNEL,"false");
+ }
+ if (track == 0){
+ adec_print("No track instance!\n");
+ return -1;
+ }
+
+ track->stop();
+ /* release AudioTrack */
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ delete track;
+#else
+ mpAudioTrack.clear();
+#endif
+ out_ops->private_data = NULL;
+/*after 6.0,not need this code*/
+#if ANDROID_PLATFORM_SDK_VERSION < 23
+ restore_system_samplerate(audec);
+#endif
+ if(wfd_enable){
+ restore_system_framesize();
+ }
+ return 0;
+}
+
+/**
+ * \brief get output latency in ms
+ * \param audec pointer to audec
+ * \return output latency
+ */
+extern "C" unsigned long android_latency(struct aml_audio_dec* audec)
+{
+ unsigned long latency;
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ AudioTrack *track = (AudioTrack *)out_ops->private_data;
+#else
+ AudioTrack *track = mpAudioTrack.get();
+#endif
+ if (audec->use_get_out_posion && audec->aout_ops.get_out_position)
+ return 0;
+ if (track) {
+ status_t s;
+ int ret = -1;
+ int64_t write_samples;
+ int cache_samples;
+ int delay_us, t_us;
+ AudioTimestamp timestamp;
+ s = track->getTimestamp(timestamp);
+ if (s != NO_ERROR || timestamp.mPosition < 1) {
+ /*
+ timestamp.mPosition <= 0 we think audio not have start.
+ the latency is not accurate
+ */
+ return 0;
+ } else {
+ struct timespec timenow;
+ write_samples = audec->pcm_bytes_readed/(audec->channels * 2);
+ cache_samples = write_samples - timestamp.mPosition;
+ if (cache_samples < 0)
+ cache_samples = 0;
+ delay_us = 1000 * (cache_samples * 1000 / audec->samplerate);
+ clock_gettime(CLOCK_MONOTONIC, &timenow);
+ t_us = (timenow.tv_sec - timestamp.mTime.tv_sec) * 1000000LL +
+ (timenow.tv_nsec- timestamp.mTime.tv_nsec)/1000;
+ delay_us -=t_us;
+ if (delay_us < 0)
+ delay_us =0;
+ return delay_us/1000;
+ }
+ }
+ if (track) {
+ latency = track->latency();
+ return latency;
+ }
+ return 0;
+}
+
+/**
+ * \brief get output latency in ms
+ * \param audec pointer to audec
+ * \return output latency
+ */
+extern "C" int android_get_position(struct aml_audio_dec* audec,
+ int64_t *position,
+ int64_t *timeus)
+{
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+ AudioTimestamp timestamp;
+ status_t s;
+ int ret = -1 ;
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ AudioTrack *track = (AudioTrack *)out_ops->private_data;
+#else
+ AudioTrack *track = mpAudioTrack.get();
+#endif
+
+ if (track) {
+ s = track->getTimestamp(timestamp);
+ if (s == NO_ERROR) {
+ *position = timestamp.mPosition;
+ *timeus = timestamp.mTime.tv_sec * 1000000LL + timestamp.mTime.tv_nsec / 1000;
+ return 0;
+ }
+ }
+ return ret;
+}
+
+
+#ifndef ANDROID_VERSION_JBMR2_UP
+/**
+ * \brief mute output
+ * \param audec pointer to audec
+ * \param en 1 = mute, 0 = unmute
+ * \return 0 on success otherwise negative error code
+ */
+extern "C" int android_mute_raw(struct aml_audio_dec* audec, adec_bool_t en)
+{
+ Mutex::Autolock _l(mLock_raw);
+ adec_print("[%s %d]android raw_out mute",__FUNCTION__,__LINE__);
+
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ AudioTrack *track = (AudioTrack *)out_ops->private_data_raw;
+#else
+ AudioTrack *track = mpAudioTrack_raw.get();
+#endif
+ if (track == 0) {
+ adec_print("No track instance!\n");
+ return -1;
+ }
+
+ track->mute(en);
+ return 0;
+}
+#endif
+extern "C" int android_mute(struct aml_audio_dec* audec, adec_bool_t en)
+{
+ Mutex::Autolock _l(mLock);
+ adec_print("android out mute");
+
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ AudioTrack *track = (AudioTrack *)out_ops->private_data;
+#else
+ AudioTrack *track = mpAudioTrack.get();
+#endif
+ if (!track) {
+ adec_print("No track instance!\n");
+ return -1;
+ }
+
+#ifdef ANDROID_VERSION_JBMR2_UP
+#else
+ #ifdef USE_ARM_AUDIO_DEC
+ if(out_ops->audio_out_raw_enable)
+ android_mute_raw(audec,en);
+ #endif
+ track->mute(en);
+#endif
+
+ return 0;
+}
+
+/**
+ * \brief set output volume
+ * \param audec pointer to audec
+ * \param vol volume value
+ * \return 0 on success otherwise negative error code
+ */
+extern "C" int android_set_volume(struct aml_audio_dec* audec, float vol)
+{
+ Mutex::Autolock _l(mLock);
+ adec_print("android set volume");
+
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ AudioTrack *track = (AudioTrack *)out_ops->private_data;
+#else
+ AudioTrack *track = mpAudioTrack.get();
+#endif
+ if (!track) {
+ adec_print("No track instance!\n");
+ return -1;
+ }
+
+ track->setVolume(vol, vol);
+
+ return 0;
+}
+
+/**
+ * \brief set left/right output volume
+ * \param audec pointer to audec
+ * \param lvol refer to left volume value
+ * \param rvol refer to right volume value
+ * \return 0 on success otherwise negative error code
+ */
+extern "C" int android_set_lrvolume(struct aml_audio_dec* audec, float lvol,float rvol)
+{
+ Mutex::Autolock _l(mLock);
+ adec_print("android set left and right volume separately");
+
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ AudioTrack *track = (AudioTrack *)out_ops->private_data;
+#else
+ AudioTrack *track = mpAudioTrack.get();
+#endif
+ if (!track) {
+ adec_print("No track instance!\n");
+ return -1;
+ }
+
+ track->setVolume(lvol, rvol);
+
+ return 0;
+}
+extern "C" int android_set_track_rate(struct aml_audio_dec* audec,void *rate)
+{
+#if ANDROID_PLATFORM_SDK_VERSION >= 23
+ Mutex::Autolock _l(mLock);
+ adec_print("android_set_track_rate");
+ struct AudioPlaybackRate Rate = *(struct AudioPlaybackRate*)rate;
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+#if ANDROID_PLATFORM_SDK_VERSION < 19
+ AudioTrack *track = (AudioTrack *)out_ops->private_data;
+#else
+ AudioTrack *track = mpAudioTrack.get();
+#endif
+ if (!track) {
+ adec_print("No track instance!\n");
+ return -1;
+ }
+
+ track->setPlaybackRate(Rate);
+ out_ops->track_rate = Rate.mSpeed;
+#endif
+ return 0;
+}
+
+extern "C" void android_basic_init()
+{
+ Mutex::Autolock _l(mLock);
+ adec_print("android basic init!");
+ sp<ProcessState> proc(ProcessState::self());
+}
+
+/**
+ * \brief get output handle
+ * \param audec pointer to audec
+ */
+extern "C" void get_output_func(struct aml_audio_dec* audec)
+{
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+
+ out_ops->init = android_init;
+ out_ops->start = android_start;
+ out_ops->pause = android_pause;
+ out_ops->resume = android_resume;
+ out_ops->stop = android_stop;
+ out_ops->latency = android_latency;
+ out_ops->mute = android_mute;
+ out_ops->set_volume = android_set_volume;
+ out_ops->set_lrvolume = android_set_lrvolume;
+ out_ops->set_track_rate = android_set_track_rate;
+ out_ops->get_out_position = android_get_position;
+ out_ops->audio_out_raw_enable = 1;
+ /* default set a invalid value*/
+ out_ops->track_rate = 8.8f;
+}
+
+}
+
diff --git a/amadec/audiodsp_update_format.c b/amadec/audiodsp_update_format.c
new file mode 100644
index 0000000..abb0e9b
--- a/dev/null
+++ b/amadec/audiodsp_update_format.c
@@ -0,0 +1,188 @@
+/**
+ * \file audiodsp-ctl.c
+ * \brief Functions of Auduodsp control
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <string.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+
+#include <audio-dec.h>
+#include <audiodsp.h>
+#include <log-print.h>
+#include <cutils/properties.h>
+
+#include "adec-external-ctrl.h"
+#include "Amsysfsutils.h"
+#include "amconfigutils.h"
+
+static int reset_track_enable = 0;
+void adec_reset_track_enable(int enable_flag)
+{
+ reset_track_enable = enable_flag;
+ adec_print("reset_track_enable=%d\n", reset_track_enable);
+}
+
+static int get_sysfs_int(const char *path)
+{
+ return amsysfs_get_sysfs_int(path);
+}
+
+static int set_sysfs_int(const char *path, int val)
+{
+ return amsysfs_set_sysfs_int(path, val);
+}
+
+static int audiodsp_get_format_changed_flag()
+{
+ return get_sysfs_int("/sys/class/audiodsp/format_change_flag");
+
+}
+
+void audiodsp_set_format_changed_flag(int val)
+{
+ set_sysfs_int("/sys/class/audiodsp/format_change_flag", val);
+
+}
+
+static int audiodsp_get_pcm_resample_enable()
+{
+ int utils_fd, ret;
+ unsigned long value;
+
+ utils_fd = open("/dev/amaudio_utils", O_RDWR);
+ if (utils_fd >= 0) {
+ ret = ioctl(utils_fd, AMAUDIO_IOC_GET_RESAMPLE_ENA, &value);
+ if (ret < 0) {
+ adec_print("AMAUDIO_IOC_GET_RESAMPLE_ENA failed\n");
+ close(utils_fd);
+ return -1;
+ }
+ close(utils_fd);
+ return value;
+ }
+ return -1;
+}
+
+static int audiodsp_set_pcm_resample_enable(unsigned long enable)
+{
+ int utils_fd, ret;
+
+ utils_fd = open("/dev/amaudio_utils", O_RDWR);
+ if (utils_fd >= 0) {
+ ret = ioctl(utils_fd, AMAUDIO_IOC_SET_RESAMPLE_ENA, enable);
+ if (ret < 0) {
+ adec_print("AMAUDIO_IOC_SET_RESAMPLE_ENA failed\n");
+ close(utils_fd);
+ return -1;
+ }
+ close(utils_fd);
+ return 0;
+ }
+ return -1;
+}
+
+void adec_reset_track(aml_audio_dec_t *audec)
+{
+ if (audec->format_changed_flag && audec->state >= INITTED && !audec->need_stop) {
+ buffer_stream_t *g_bst = audec->g_bst;
+ adec_print("reset audio_track: samplerate=%d channels=%d\n", (g_bst == NULL) ? audec->samplerate : g_bst->samplerate, (g_bst == NULL) ? audec->channels : g_bst->channels);
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+ out_ops->mute(audec, 1);
+ out_ops->pause(audec);
+ out_ops->stop(audec);
+ if (g_bst != NULL) {
+ //4.4 code maybe run on 4.2 hardware platform: g_bst==NULL on 4.2,so add this condition
+ audec->channels = g_bst->channels;
+ audec->samplerate = g_bst->samplerate;
+ }
+ out_ops->init(audec);
+ if (audec->state == ACTIVE) {
+ out_ops->start(audec);
+ }
+ audec->format_changed_flag = 0;
+ }
+}
+
+int audiodsp_format_update(aml_audio_dec_t *audec)
+{
+ int m_fmt;
+ int ret = -1;
+ unsigned long val;
+ dsp_operations_t *dsp_ops = &audec->adsp_ops;
+
+ if (dsp_ops->dsp_file_fd < 0 || get_audio_decoder() != AUDIO_ARC_DECODER) {
+ return ret;
+ }
+
+ ret = 0;
+ if (1/*audiodsp_get_format_changed_flag()*/) {
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_GET_CHANNELS_NUM, &val);
+ if (val != (unsigned long) - 1) {
+ if (audec->channels != val) {
+ //adec_print("dsp_format_update: pre_channels=%d cur_channels=%d\n", audec->channels,val);
+ audec->channels = val;
+ ret = 1;
+ }
+ }
+
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_GET_SAMPLERATE, &val);
+ if (val != (unsigned long) - 1) {
+ if (audec->samplerate != val) {
+ //adec_print("dsp_format_update: pre_samplerate=%d cur_samplerate=%d\n", audec->samplerate,val);
+ audec->samplerate = val;
+ ret = 2;
+ }
+ }
+#if 1
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_GET_BITS_PER_SAMPLE, &val);
+ if (val != (unsigned long) - 1) {
+ if (audec->data_width != val) {
+ //adec_print("dsp_format_update: pre_data_width=%d cur_data_width=%d\n", audec->data_width,val);
+ audec->data_width = val;
+ ret = 3;
+ }
+ }
+#endif
+ //audiodsp_set_format_changed_flag(0);
+
+ if (am_getconfig_bool("media.libplayer.wfd")) {
+ ret = ioctl(dsp_ops->dsp_file_fd, AUDIODSP_GET_PCM_LEVEL, &val);
+ if (ret == 0) {
+ //adec_print("pcm level == 0x%x\n", val);
+ if ((val < 0x1000) && (1 == audiodsp_get_pcm_resample_enable())) {
+ // adec_print("disable pcm down resample");
+ // audiodsp_set_pcm_resample_enable(0);
+ }
+ }
+ }
+ }
+ if (ret > 0) {
+ audec->format_changed_flag = ret;
+ adec_print("dsp_format_update: audec->format_changed_flag = %d \n", audec->format_changed_flag);
+ }
+ return ret;
+}
+
+
+
+int audiodsp_get_pcm_left_len()
+{
+ return get_sysfs_int("/sys/class/audiodsp/pcm_left_len");
+
+}
+
+
+
+
diff --git a/amadec/dsp/audiodsp-ctl.c b/amadec/dsp/audiodsp-ctl.c
new file mode 100644
index 0000000..8d0a05c
--- a/dev/null
+++ b/amadec/dsp/audiodsp-ctl.c
@@ -0,0 +1,471 @@
+/**
+ * \file audiodsp-ctl.c
+ * \brief Functions of Auduodsp control
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <string.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+
+#include <audio-dec.h>
+#include <audiodsp.h>
+#include <log-print.h>
+#include <cutils/properties.h>
+#include <amthreadpool.h>
+#include "Amsysfsutils.h"
+#include "amconfigutils.h"
+
+firmware_s_t firmware_list[] = {
+ {0, MCODEC_FMT_MPEG123, "audiodsp_codec_mad.bin"},
+ {1, MCODEC_FMT_AAC, "audiodsp_codec_aac_helix.bin"},
+ {2, MCODEC_FMT_AC3 | MCODEC_FMT_EAC3, "audiodsp_codec_ddp_dcv.bin"},
+ {3, MCODEC_FMT_DTS, "audiodsp_codec_dtshd.bin"},
+ {4, MCODEC_FMT_FLAC, "audiodsp_codec_flac.bin"},
+ {5, MCODEC_FMT_COOK, "audiodsp_codec_cook.bin"},
+ {6, MCODEC_FMT_AMR, "audiodsp_codec_amr.bin"},
+ {7, MCODEC_FMT_RAAC, "audiodsp_codec_raac.bin"},
+ {8, MCODEC_FMT_ADPCM, "audiodsp_codec_adpcm.bin"},
+ {9, MCODEC_FMT_WMA, "audiodsp_codec_wma.bin"},
+ {10, MCODEC_FMT_PCM, "audiodsp_codec_pcm.bin"},
+ {11, MCODEC_FMT_WMAPRO, "audiodsp_codec_wmapro.bin"},
+ {12, MCODEC_FMT_ALAC, "audiodsp_codec_alac.bin"},
+ {13, MCODEC_FMT_VORBIS, "audiodsp_codec_vorbis.bin"},
+ {14, MCODEC_FMT_AAC_LATM, "audiodsp_codec_aac.bin"},
+ {15, MCODEC_FMT_APE, "audiodsp_codec_ape.bin"},
+
+};
+
+/**
+ * \brief register audio firmware
+ * \param fd dsp handle
+ * \param fmt audio format
+ * \param name audio firmware name
+ * \return 0 on success otherwise negative error code
+ */
+static int register_firmware(int fd, int fmt, char *name)
+{
+ int ret;
+ audiodsp_cmd_t cmd;
+
+ cmd.cmd = AUDIODSP_REGISTER_FIRMWARE;
+ cmd.fmt = fmt;
+ cmd.data = name;
+ cmd.data_len = strlen(name);
+
+ ret = ioctl(fd, AUDIODSP_REGISTER_FIRMWARE, &cmd);
+
+ return ret;
+}
+
+/**
+ * \brief switch audio format
+ * \param fmt audio format
+ * \return new format on success otherwise zero
+ */
+static int switch_audiodsp(adec_audio_format_t fmt)
+{
+ switch (fmt) {
+ case ADEC_AUDIO_FORMAT_MPEG:
+ return MCODEC_FMT_MPEG123;
+
+ case ADEC_AUDIO_FORMAT_AAC_LATM:
+ return MCODEC_FMT_AAC_LATM;
+
+ case ADEC_AUDIO_FORMAT_AAC:
+ return MCODEC_FMT_AAC;
+
+ case ADEC_AUDIO_FORMAT_AC3:
+ return MCODEC_FMT_AC3;
+ case ADEC_AUDIO_FORMAT_EAC3:
+ return MCODEC_FMT_EAC3;
+
+ case ADEC_AUDIO_FORMAT_DTS:
+ return MCODEC_FMT_DTS;
+
+ case ADEC_AUDIO_FORMAT_FLAC:
+ return MCODEC_FMT_FLAC;
+
+ case ADEC_AUDIO_FORMAT_COOK:
+ return MCODEC_FMT_COOK;
+
+ case ADEC_AUDIO_FORMAT_AMR:
+ return MCODEC_FMT_AMR;
+
+ case ADEC_AUDIO_FORMAT_RAAC:
+ return MCODEC_FMT_RAAC;
+
+ case ADEC_AUDIO_FORMAT_ADPCM:
+ return MCODEC_FMT_ADPCM;
+
+ case ADEC_AUDIO_FORMAT_PCM_S16BE:
+ case ADEC_AUDIO_FORMAT_PCM_S16LE:
+ case ADEC_AUDIO_FORMAT_PCM_U8:
+ case ADEC_AUDIO_AFORMAT_PCM_BLURAY:
+ case ADEC_AUDIO_FORMAT_PCM_WIFIDISPLAY:
+ return MCODEC_FMT_PCM;
+
+ case ADEC_AUDIO_FORMAT_WMA:
+ return MCODEC_FMT_WMA;
+
+ case ADEC_AUDIO_FORMAT_WMAPRO:
+ return MCODEC_FMT_WMAPRO;
+ case ADEC_AUDIO_AFORMAT_ALAC:
+ return MCODEC_FMT_ALAC;
+ case ADEC_AUDIO_AFORMAT_VORBIS:
+ return MCODEC_FMT_VORBIS;
+ case ADEC_AUDIO_FORMAT_APE:
+ return MCODEC_FMT_APE;
+ default:
+ return 0;
+ }
+}
+
+/**
+ * \brief find audio firmware through audio format
+ * \param fmt audio format
+ * \return firmware_s struct otherwise null
+ */
+static firmware_s_t * find_firmware_by_fmt(int m_fmt)
+{
+ int i;
+ int num;
+ firmware_s_t *f;
+
+ num = ARRAY_SIZE(firmware_list);
+
+ for (i = 0; i < num; i++) {
+ f = &firmware_list[i];
+ if (f->fmt & m_fmt) {
+ return f;
+ }
+ }
+
+ return NULL;
+}
+
+
+/**
+ * \brief init audiodsp
+ * \param dsp_ops pointer to dsp operation struct
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audiodsp_init(dsp_operations_t *dsp_ops)
+{
+ int i;
+ int fd = -1;
+ int num;
+ int ret;
+ firmware_s_t *f;
+
+ num = ARRAY_SIZE(firmware_list);
+
+ if (dsp_ops->dsp_file_fd < 0) {
+ fd = open(DSP_DEV_NOD, O_RDONLY, 0644);
+ }
+
+ if (fd < 0) {
+ adec_print("unable to open audio dsp %s,err: %s", DSP_DEV_NOD, strerror(errno));
+ return -1;
+ }
+ ioctl(fd, AUDIODSP_UNREGISTER_ALLFIRMWARE, 0);
+ for (i = 0; i < num; i++) {
+ f = &firmware_list[i];
+ ret = register_firmware(fd, f->fmt, f->name);
+ if (ret != 0) {
+ adec_print("register firmware error=%d,fmt:%d,name:%s\n", ret, f->fmt, f->name);
+ }
+ }
+ if (i > 0) {
+ ret = 0; //ignore the some fmt register error,for compatible some old kernel.can't support muti filename,
+ }
+ if (ret != 0) {
+ close(fd);
+
+ }
+
+ dsp_ops->dsp_file_fd = fd;
+
+ return ret;
+}
+
+/**
+ * \brief start audiodsp
+ * \param dsp_ops pointer to dsp operation struct
+ * \return 0 on success otherwise negative code error
+ */
+static err_count = 0;
+
+#define PARSER_WAIT_MAX 100
+int audiodsp_start(aml_audio_dec_t *audec)
+{
+ int m_fmt;
+ int ret = -1;
+ unsigned long val;
+ dsp_operations_t *dsp_ops = &audec->adsp_ops;
+
+ if (dsp_ops->dsp_file_fd < 0) {
+ return -1;
+ }
+
+ if (am_getconfig_bool("media.libplayer.wfd")) {
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_SET_PCM_BUF_SIZE, 8 * 1024);
+ } else {
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_SET_PCM_BUF_SIZE, 32 * 1024);
+ }
+
+ m_fmt = switch_audiodsp(audec->format);
+ adec_print("[%s:%d] audio_fmt=%d\n", __FUNCTION__, __LINE__, m_fmt);
+
+ if (find_firmware_by_fmt(m_fmt) == NULL) {
+ return -2;
+ }
+
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_SET_FMT, m_fmt);
+
+ ret = ioctl(dsp_ops->dsp_file_fd, AUDIODSP_START, 0);
+ if (ret != 0) {
+ return -3;
+ }
+
+ if (audec->need_stop) { //in case stop command comes now
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_STOP, 0);
+ return -5;
+ }
+
+ ret = ioctl(dsp_ops->dsp_file_fd, AUDIODSP_DECODE_START, 0);
+ err_count = 0;
+ if (ret == 0) {
+ do {
+ ret = ioctl(dsp_ops->dsp_file_fd, AUDIODSP_WAIT_FORMAT, 0);
+ if (ret != 0 && !audec->need_stop) {
+ err_count++;
+ amthreadpool_thread_usleep(1000 * 20);
+ if (err_count > PARSER_WAIT_MAX) {
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_STOP, 0);//audiodsp_start failed,should stop audiodsp
+ adec_print("[%s:%d] audio dsp not ready for decode PCM in 2s\n", __FUNCTION__, __LINE__);
+ return -4;
+ }
+ }
+ } while (!audec->need_stop && (ret != 0));
+ }
+
+ if (ret != 0) {
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_STOP, 0);//audiodsp_start failed,should stop audiodsp
+ return -4;
+ }
+
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_GET_CHANNELS_NUM, &val);
+ if (val != (unsigned long) - 1) {
+ audec->channels = val;
+ }
+
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_GET_SAMPLERATE, &val);
+ if (val != (unsigned long) - 1) {
+ audec->samplerate = val;
+ }
+
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_GET_BITS_PER_SAMPLE, &val);
+ if (val != (unsigned long) - 1) {
+ audec->data_width = val;
+ }
+ adec_print("channels == %d, samplerate == %d\n", audec->channels, audec->samplerate);
+ return ret;
+}
+
+/**
+ * \brief stop audiodsp
+ * \param dsp_ops pointer to dsp operation struct
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audiodsp_stop(dsp_operations_t *dsp_ops)
+{
+ int ret;
+
+ if (dsp_ops->dsp_file_fd < 0) {
+ return -1;
+ }
+
+ ret = ioctl(dsp_ops->dsp_file_fd, AUDIODSP_STOP, 0);
+
+ return ret;
+}
+
+/**
+ * \brief release audiodsp
+ * \param dsp_ops pointer to dsp operation struct
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audiodsp_release(dsp_operations_t *dsp_ops)
+{
+ if (dsp_ops->dsp_file_fd < 0) {
+ return -1;
+ }
+
+ close(dsp_ops->dsp_file_fd);
+
+ dsp_ops->dsp_file_fd = -1;
+
+ return 0;
+}
+
+/**
+ * \brief read pcm data from audiodsp
+ * \param dsp_ops pointer to dsp operation struct
+ * \param buffer point to buffer where storing pcm data
+ * \param size read data length
+ * \return the number of bytes read
+ */
+int audiodsp_stream_read(dsp_operations_t *dsp_ops, char *buffer, int size)
+{
+ if (dsp_ops->dsp_file_fd < 0) {
+ adec_print("read error!! audiodsp have not opened\n");
+ return 0;
+ }
+
+ return read(dsp_ops->dsp_file_fd, buffer, size);
+}
+
+/**
+ * \brief get current audio pts
+ * \param dsp_ops pointer to dsp operation struct
+ * \return current audio pts otherwise -1 if an error occurred
+ */
+unsigned long audiodsp_get_pts(dsp_operations_t *dsp_ops)
+{
+ unsigned long val;
+
+ if (dsp_ops->dsp_file_fd < 0) {
+ adec_print("read error!! audiodsp have not opened\n");
+ return -1;
+ }
+
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_GET_PTS, &val);
+
+ return val;
+}
+
+/**
+ * \brief get current audio pcrscr
+ * \param dsp_ops pointer to dsp operation struct
+ * \return current audio pcrscr otherwise -1 if an error occurred
+ */
+unsigned long audiodsp_get_pcrscr(dsp_operations_t *dsp_ops)
+{
+ unsigned long val;
+
+ if (dsp_ops->dsp_file_fd < 0) {
+ adec_print("read error!! audiodsp have not opened\n");
+ return -1;
+ }
+
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_SYNC_GET_PCRSCR, &val);
+
+ return val;
+}
+/**
+ * \brief set current audio pts
+ * \param dsp_ops pointer to dsp operation struct
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int audiodsp_set_apts(dsp_operations_t *dsp_ops, unsigned long apts)
+{
+
+ if (dsp_ops->dsp_file_fd < 0) {
+ adec_print("read error!! audiodsp have not opened\n");
+ return -1;
+ }
+
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_SYNC_SET_APTS, &apts);
+
+ return 0;
+}
+/**
+ * \brief get decoded audio frame number
+ * \param dsp_ops pointer to dsp operation struct
+ * \return audiodsp decoded frame number, -1 if an error occurred
+ */
+int audiodsp_get_decoded_nb_frames(dsp_operations_t *dsp_ops)
+{
+ int val = -1;
+ if (dsp_ops && dsp_ops->dsp_file_fd) {
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_GET_DECODED_NB_FRAMES, &val);
+ }
+ //adec_print("get audio decoded frame number==%d\n",val);
+ return val;
+}
+
+int audiodsp_get_first_pts_flag(dsp_operations_t *dsp_ops)
+{
+ int val;
+
+ if (dsp_ops->dsp_file_fd < 0) {
+ adec_print("read error!! audiodsp have not opened\n");
+ return -1;
+ }
+
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_GET_FIRST_PTS_FLAG, &val);
+
+ return val;
+}
+
+int audiodsp_automute_on(dsp_operations_t *dsp_ops)
+{
+ int ret;
+
+ if (dsp_ops->dsp_file_fd < 0) {
+ adec_print("read error!! audiodsp have not opened\n");
+ return -1;
+ }
+
+ ret = ioctl(dsp_ops->dsp_file_fd, AUDIODSP_AUTOMUTE_ON, 0);
+
+ return ret;
+}
+
+int audiodsp_automute_off(dsp_operations_t *dsp_ops)
+{
+ int ret;
+
+ if (dsp_ops->dsp_file_fd < 0) {
+ adec_print("read error!! audiodsp have not opened\n");
+ return -1;
+ }
+
+ ret = ioctl(dsp_ops->dsp_file_fd, AUDIODSP_AUTOMUTE_OFF, 0);
+
+ return ret;
+}
+
+
+int audiodsp_get_pcm_level(dsp_operations_t* dsp_ops)
+{
+ int val = 0;
+ if (dsp_ops->dsp_file_fd < 0) {
+ adec_print("read error !! audiodsp have not opened\n");
+ return -1;
+ }
+
+ ioctl(dsp_ops->dsp_file_fd, AUDIODSP_GET_PCM_LEVEL, &val);
+ return val;
+}
+
+int audiodsp_set_skip_bytes(dsp_operations_t* dsp_ops, unsigned int bytes)
+{
+ if (dsp_ops->dsp_file_fd < 0) {
+ adec_print("read error !! audiodsp have not opened\n");
+ return -1;
+ }
+
+ return ioctl(dsp_ops->dsp_file_fd, AUDIODSP_SKIP_BYTES, bytes);
+}
diff --git a/amadec/dts_enc.c b/amadec/dts_enc.c
new file mode 100644
index 0000000..f95742e
--- a/dev/null
+++ b/amadec/dts_enc.c
@@ -0,0 +1,209 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <log-print.h>
+#include <pthread.h>
+#include "dts_enc.h"
+#include "dts_transenc_api.h"
+#include <cutils/properties.h>
+#include <amthreadpool.h>
+
+#include "Amsysfsutils.h"
+#include "amconfigutils.h"
+#include "spdif_api.h"
+
+typedef enum {
+ IDLE,
+ TERMINATED,
+ STOPPED,
+ INITTED,
+ ACTIVE,
+ PAUSED,
+} dtsenc_state_t;
+
+typedef struct {
+ dtsenc_state_t state;
+ pthread_t thread_pid;
+ int raw_mode;
+ int dts_flag;
+} dtsenc_info_t;
+
+
+static dtsenc_info_t dtsenc_info;
+static void *dts_enc_loop();
+
+#define DIGITAL_RAW_PATH "sys/class/audiodsp/digital_raw"
+#define FORMAT_PATH "/sys/class/astream/format"
+
+extern int match_types(const char *filetypestr, const char *typesetting);
+
+static int get_dts_mode(void)
+{
+ int val = 0;
+ char bcmd[28];
+ amsysfs_get_sysfs_str(DIGITAL_RAW_PATH, bcmd, 28);
+ val = bcmd[21] & 0xf;
+ return val;
+
+}
+
+static int get_dts_format(void)
+{
+ char format[21];
+ int len;
+
+ format[0] = 0;
+
+ amsysfs_get_sysfs_str(FORMAT_PATH, format, 21);
+ if (strncmp(format, "NA", 2) == 0) {
+ return 0;
+ }
+ adec_print("amadec format: %s", format);
+ if (strncmp(format, "amadec_dts", 10) == 0) {
+ return 1;
+ }
+ return 0;
+}
+
+static int get_cpu_type(void)
+{
+ char value[PROPERTY_VALUE_MAX];
+ int ret = property_get("ro.board.platform", value, NULL);
+ adec_print("ro.board.platform = %s\n", value);
+ if (ret > 0 && match_types("meson6", value)) {
+ return 1;
+ }
+ return 0;
+}
+int dtsenc_init()
+{
+ return 0;
+ int ret;
+ memset(&dtsenc_info, 0, sizeof(dtsenc_info_t));
+ dtsenc_info.dts_flag = get_dts_format();
+ if (!dtsenc_info.dts_flag) {
+ return -1;
+ }
+ dtsenc_info.raw_mode = get_dts_mode();
+ //dtsenc_info.raw_mode=1;//default open
+ if (!dtsenc_info.raw_mode) {
+ return -1;
+ }
+ if (!get_cpu_type()) { //if cpu !=m6 ,skip
+ return -1;
+ }
+
+ //adec_print("====dts_flag:%d raw_mode:%d \n",dtsenc_info.dts_flag,dtsenc_info.raw_mode);
+
+ ret = dts_transenc_init();
+ if (ret != 1) {
+ adec_print("====dts_trancenc init failed \n");
+ return -1;
+ }
+ dtsenc_info.state = INITTED;
+
+ pthread_t tid;
+ ret = amthreadpool_pthread_create(&tid, NULL, (void *)dts_enc_loop, NULL);
+ if (ret != 0) {
+ dtsenc_release();
+ return -1;
+ }
+ pthread_setname_np(tid, "AmadecDtsEncLP");
+ dtsenc_info.thread_pid = tid;
+ adec_print("====dts_enc init success \n");
+ return 0;
+}
+int dtsenc_start()
+{
+ return 0;
+ int ret;
+ if (dtsenc_info.state != INITTED) {
+ return -1;
+ }
+ dtsenc_info.state = ACTIVE;
+ adec_print("====dts_enc thread start success \n");
+ return 0;
+}
+int dtsenc_pause()
+{
+ return 0;
+ if (dtsenc_info.state == ACTIVE) {
+ dtsenc_info.state = PAUSED;
+ }
+ return 0;
+}
+int dtsenc_resume()
+{
+ return 0;
+ if (dtsenc_info.state == PAUSED) {
+ dtsenc_info.state = ACTIVE;
+ }
+ return 0;
+}
+int dtsenc_stop()
+{
+ return 0;
+ if (dtsenc_info.state < INITTED) {
+ return -1;
+ }
+ dtsenc_info.state = STOPPED;
+ //jone the thread
+ if (dtsenc_info.thread_pid <= 0) {
+ return -1;
+ }
+ int ret = amthreadpool_pthread_join(dtsenc_info.thread_pid, NULL);
+ dtsenc_info.thread_pid = 0;
+ if (dtsenc_info.state != STOPPED) {
+ return -1;
+ }
+ dts_transenc_deinit();
+ adec_print("====dts_enc stop ok\n");
+ return 0;
+}
+int dtsenc_release()
+{
+ return 0;
+ memset(&dtsenc_info, 0, sizeof(dtsenc_info_t));
+ // dtsenc_info.state=TERMINATED;
+ adec_print("====dts_enc release ok\n");
+ return 0;
+}
+
+static void *dts_enc_loop()
+{
+ return 0;
+ int ret;
+ while (1) {
+ switch (dtsenc_info.state) {
+ case INITTED:
+ amthreadpool_thread_usleep(10000);
+ continue;
+ case ACTIVE:
+ break;
+ case PAUSED:
+ iec958buf_fill_zero();
+ amthreadpool_thread_usleep(100000);
+ continue;
+ case STOPPED:
+ goto quit_loop;
+ default:
+ goto err;
+ }
+ //shaoshuai --non_block
+ ret = dts_transenc_process_frame();
+ //amthreadpool_thread_usleep(100000);
+ //adec_print("====dts_enc thread is running \n");
+ }
+quit_loop:
+ adec_print("====dts_enc thread exit success \n");
+ pthread_exit(NULL);
+ return NULL;
+err:
+ adec_print("====dts_enc thread exit success err\n");
+ pthread_exit(NULL);
+ return NULL;
+}
+
+
diff --git a/amadec/dts_enc.h b/amadec/dts_enc.h
new file mode 100644
index 0000000..5fcfad3
--- a/dev/null
+++ b/amadec/dts_enc.h
@@ -0,0 +1,11 @@
+#ifndef DTS_ENC_H
+#define DTS_ENC_H
+int dtsenc_init();
+int dtsenc_start();
+int dtsenc_pause();
+int dtsenc_resume();
+int dtsenc_stop();
+int dtsenc_release();
+
+#endif
+
diff --git a/amadec/dts_transenc_api.c b/amadec/dts_transenc_api.c
new file mode 100644
index 0000000..6aba807
--- a/dev/null
+++ b/amadec/dts_transenc_api.c
@@ -0,0 +1,143 @@
+
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <math.h>
+#include <dlfcn.h>
+
+#include "dts_transenc_api.h"
+#include "pcmenc_api.h" //xujian
+#include "spdif_api.h" //xujian
+#include <log-print.h>
+#include <amthreadpool.h>
+
+pcm51_encoded_info_t dts_transenc_info;
+static int dts_init_flag = 0;
+char *stream; //input raw pcm
+char *output;
+static int write_success_flag = 1;
+unsigned int input_size;
+unsigned int output_size;
+static int nNumFrmCoded;
+//sjw added ; param set by shaoshuai
+typedef struct {
+ int (*enc_init)(pcm51_encoded_info_t dts_transenc_info, unsigned int *input_size, unsigned int *output_size);
+ int (*enc_encode)(pcm51_encoded_info_t dts_transenc_info, char *stream, unsigned char *output, unsigned int output_size);
+ int (*enc_release)();
+} ecoder_operations;
+
+static ecoder_operations enc_ops;
+
+int dts_transenc_init()
+{
+ int rv;
+ dts_init_flag = 0;
+ write_success_flag = 1;
+ rv = pcmenc_init();//xujian
+ if (rv == -1) {
+ adec_print("==pcmenc_init failed \n");
+ goto err1;
+ }
+ rv = iec958_init();//xujian
+ if (rv != 0) {
+ adec_print("==iec958_init failed ret:%d\n", rv);
+ goto err2;
+ }
+ rv = pcmenc_get_pcm_info(&dts_transenc_info);//xujian
+ if (dts_transenc_info.LFEFlag > 1) {
+ dts_transenc_info.LFEFlag = 1;
+ }
+ void *fd_dtsenc = dlopen("libdtsenc.so", RTLD_NOW);
+ if (fd_dtsenc != 0) {
+ enc_ops.enc_init = dlsym(fd_dtsenc, "init");
+ enc_ops.enc_encode = dlsym(fd_dtsenc, "encode_frame");
+ enc_ops.enc_release = dlsym(fd_dtsenc, "release");
+ } else {
+ adec_print("==find libdtsenc.so failed \n");
+ goto err3;
+ }
+
+ rv = enc_ops.enc_init(dts_transenc_info, &input_size, &output_size);//encode init
+ if (rv != 0) {
+ goto err4;
+ }
+
+ stream = (char *)malloc(input_size); //malloc input buf
+ output = malloc(output_size); //malloc output buf
+
+ dts_init_flag = 1;
+
+ return dts_init_flag;
+err1:
+ return -1;
+err2:
+ pcmenc_deinit();//xujian
+ return -1;
+err3:
+ pcmenc_deinit();//xujian
+ iec958_deinit();//xujian
+ return -1;
+err4:
+ pcmenc_deinit();//xujian
+ iec958_deinit();//xujian
+ dlclose(fd_dtsenc);
+ return -1;
+}
+
+int dts_transenc_process_frame()
+{
+ int rv;
+ if (write_success_flag) {
+ rv = pcmenc_read_pcm(stream, input_size); //xujian
+ if (rv == 0) { /* no enough pcm data in the buffer */
+ //adec_print("=====read data failed :%d input_size:%d \n",rv,input_size);
+ if (iec958_check_958buf_level() == 0) {
+ adec_print("transenc:insert zero pcm data \n");
+ memset(stream, 0, input_size); //insert zero pcm data when 958 hw buffer underrun
+ } else {
+ amthreadpool_thread_usleep(1000);
+ return -1;
+ }
+ }
+#ifdef DUMP_FILE
+ FILE *fp1 = fopen("/mnt/sda4/a.pcm", "a+");
+ fwrite(stream, 1, input_size, fp1);
+ fclose(fp1);
+#endif
+
+ rv = enc_ops.enc_encode(dts_transenc_info, stream, output, (unsigned int)&output_size);//encode frame
+#ifdef DUMP_FILE
+ FILE *fp2 = fopen("/mnt/sda4/a.dts", "a+");
+ fwrite(output, 1, output_size, fp2);
+ fclose(fp2);
+#endif
+ rv = iec958_pack_frame(output, output_size);
+ }
+ rv = iec958_packed_frame_write_958buf(output, output_size);
+ if (rv == -1) {
+ write_success_flag = 0;
+ amthreadpool_thread_usleep(1000);
+ } else {
+ write_success_flag = 1;
+ }
+
+ //adec_print("===pack frame write 958 ret:%d size:%d \n",rv,output_size);
+ return 1;
+}
+
+int dts_transenc_deinit()
+{
+ iec958_deinit();//xujian
+ pcmenc_deinit();//xujian
+ enc_ops.enc_release();
+ if (stream) {
+ free(stream);
+ }
+ stream = NULL;
+ if (output) {
+ free(output);
+ }
+ output = NULL;
+ return 1;
+}
diff --git a/amadec/dts_transenc_api.h b/amadec/dts_transenc_api.h
new file mode 100644
index 0000000..dba3dbc
--- a/dev/null
+++ b/amadec/dts_transenc_api.h
@@ -0,0 +1,19 @@
+// $Id: DTSTranscode1m5.h,v 1.14 2007-08-09 01:41:03 dyee Exp $
+#ifndef DTSTRANSCODE1M5_H_INCLUDED
+#define DTSTRANSCODE1M5_H_INCLUDED
+
+/*typedef struct pcm51_encoded_info_s
+{
+ unsigned int InfoValidFlag;
+ unsigned int SampFs;
+ unsigned int NumCh;
+ unsigned int AcMode;
+ unsigned int LFEFlag;
+ unsigned int BitsPerSamp;
+}pcm51_encoded_info_t;*/
+
+int dts_transenc_init();
+int dts_transenc_process_frame();
+int dts_transenc_deinit();
+
+#endif // DTSTRANSCODE1M5_H_INCLUDED
diff --git a/amadec/feeder.c b/amadec/feeder.c
new file mode 100644
index 0000000..e8c4234
--- a/dev/null
+++ b/amadec/feeder.c
@@ -0,0 +1,231 @@
+/**
+ * \file feeder.c
+ * \brief Functions of Feeder
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include <feeder.h>
+#include <audiodsp.h>
+
+#include "audiodsp.h"
+#include "Amsysfsutils.h"
+#include "amconfigutils.h"
+
+extern int audiodsp_start(aml_audio_dec_t *audec);
+/**
+ * \brief get audio format
+ * \return audio format on success otherwise ADEC_AUDIO_FORMAT_UNKNOWN
+ */
+static adec_audio_format_t get_audio_format(void)
+{
+ char format[21];
+ int len;
+
+ format[0] = 0;
+
+ amsysfs_get_sysfs_str(FORMAT_PATH, format, 21);
+ if (strncmp(format, "NA", 2) == 0) {
+ return ADEC_AUDIO_FORMAT_UNKNOWN;
+ }
+
+ adec_print("amadec format: %s", format);
+
+ if (strncmp(format, "amadec_mpeg", 11) == 0) {
+ return ADEC_AUDIO_FORMAT_MPEG;
+ }
+
+ if (strncmp(format, "amadec_pcm_s16le", 16) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_PCM_S16LE;
+ }
+
+ if (strncmp(format, "amadec_pcm_s16be", 16) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_PCM_S16BE;
+ }
+
+ if (strncmp(format, "amadec_pcm_u8", 13) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_PCM_U8;
+ }
+
+ if (strncmp(format, "amadec_adpcm", 12) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_ADPCM;
+ }
+
+ if (strncmp(format, "amadec_aac_latm", 15) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_AAC_LATM;
+ }
+
+ if (strncmp(format, "amadec_aac", 10) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_AAC;
+ }
+
+ if (strncmp(format, "amadec_ac3", 10) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_AC3;
+ }
+ if (strncmp(format, "amadec_eac3", 11) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_EAC3;
+ }
+
+ if (strncmp(format, "amadec_alaw", 11) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_ALAW;
+ }
+
+ if (strncmp(format, "amadec_mulaw", 12) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_MULAW;
+ }
+
+ if (strncmp(format, "amadec_dts", 10) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_DTS;
+ }
+
+ if (strncmp(format, "amadec_flac", 11) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_FLAC;
+ }
+
+ if (strncmp(format, "amadec_cook", 11) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_COOK;
+ }
+
+ if (strncmp(format, "amadec_amr", 10) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_AMR;
+ }
+
+ if (strncmp(format, "amadec_raac", 11) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_RAAC;
+ }
+
+ if (strncmp(format, "amadec_wmapro", 13) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_WMAPRO;
+ }
+
+ if (strncmp(format, "amadec_wma", 10) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_WMA;
+ }
+
+ if (strncmp(format, "amadec_pcm_bluray", 10) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_AFORMAT_PCM_BLURAY;
+ }
+ if (strncmp(format, "amadec_alac", 11) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_AFORMAT_ALAC;
+ }
+ if (strncmp(format, "amadec_vorbis", 13) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_AFORMAT_VORBIS;
+ }
+ if (strncmp(format, "amadec_ape", 10) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_APE;
+ }
+ if (strncmp(format, "amadec_pcm_widi", 15) == 0) {
+ /*TODO: get format/channel numer/sample rate etc */
+ return ADEC_AUDIO_FORMAT_PCM_WIFIDISPLAY;
+ }
+
+ adec_print("audio format unknow.");
+
+ return ADEC_AUDIO_FORMAT_UNKNOWN;
+}
+
+/**
+ * \brief init feeder
+ * \param audec pointer to audec
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int feeder_init(aml_audio_dec_t *audec)
+{
+ int ret;
+ dsp_operations_t *dsp_ops;
+
+ dsp_ops = &audec->adsp_ops;
+
+ audec->format = get_audio_format();
+ if (audec->format == ADEC_AUDIO_FORMAT_UNKNOWN) {
+ adec_print("Unknown audio format!");
+ return -1;
+ }
+
+ ret = audiodsp_init(dsp_ops);
+ if (ret) {
+ adec_print("audio dsp init failed!");
+ return -1;
+ }
+
+ ret = audiodsp_start(audec);
+ if (ret == 0) {
+ dsp_ops->dsp_on = 1;
+ dsp_ops->dsp_read = audiodsp_stream_read;
+ dsp_ops->get_cur_pts = audiodsp_get_pts;
+ dsp_ops->get_cur_pcrscr = audiodsp_get_pcrscr;
+ dsp_ops->set_cur_apts = audiodsp_set_apts;
+ dsp_ops->set_skip_bytes = audiodsp_set_skip_bytes;
+ audec->audio_decoder_enabled = 0x1;
+ } else {
+ audiodsp_release(dsp_ops);
+ dsp_ops->dsp_on = 0;
+ dsp_ops->dsp_read = NULL;
+ dsp_ops->get_cur_pts = NULL;
+ dsp_ops->get_cur_pcrscr = NULL;
+ dsp_ops->set_skip_bytes = NULL;
+
+ /* TODO: amport init */
+ }
+
+ return ret;
+}
+
+/**
+ * \brief release feeder
+ * \param audec pointer to audec
+ * \return 0 on success otherwise -1 if an error occurred
+ */
+int feeder_release(aml_audio_dec_t *audec)
+{
+ int ret;
+ dsp_operations_t *dsp_ops;
+
+ dsp_ops = &audec->adsp_ops;
+
+ ret = audiodsp_stop(dsp_ops);
+ if (ret) {
+ adec_print("audiodsp stop failed!");
+ return -1;
+ }
+
+ ret = audiodsp_release(dsp_ops);
+ if (ret) {
+ adec_print("audiodsp release failed!");
+ return -1;
+ }
+
+ dsp_ops->dsp_on = 0;
+ dsp_ops->dsp_read = NULL;
+
+ return ret;
+}
diff --git a/amadec/feeder.h b/amadec/feeder.h
new file mode 100644
index 0000000..18f4eec
--- a/dev/null
+++ b/amadec/feeder.h
@@ -0,0 +1,26 @@
+/**
+ * \file feeder.h
+ * \brief Some Macros for Feeder
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#ifndef FEEDER_H
+#define FEEDER_H
+
+#include <audio-dec.h>
+
+ADEC_BEGIN_DECLS
+
+#define FORMAT_PATH "/sys/class/astream/format"
+#define CHANNUM_PATH "/sys/class/astream/channum"
+#define SAMPLE_RATE_PATH "/sys/class/astream/samplerate"
+#define DATAWIDTH_PATH "/sys/class/astream/datawidth"
+#define AUDIOPTS_PATH "/sys/class/astream/pts"
+
+ADEC_END_DECLS
+
+#endif
diff --git a/amadec/include/adec-external-ctrl.h b/amadec/include/adec-external-ctrl.h
new file mode 100644
index 0000000..2814840
--- a/dev/null
+++ b/amadec/include/adec-external-ctrl.h
@@ -0,0 +1,63 @@
+/**
+ * \file adec-external-ctrl.h
+ * \brief Function prototypes of Audio Dec
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#ifndef ADEC_EXTERNAL_H
+#define ADEC_EXTERNAL_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ int audio_decode_init(void **handle, arm_audio_info *pcodec);
+ int audio_decode_start(void *handle);
+ int audio_decode_pause(void *handle);
+ int audio_decode_resume(void *handle);
+ int audio_decode_stop(void *handle);
+ int audio_decode_release(void **handle);
+ int audio_decode_automute(void *, int);
+ int audio_decode_set_mute(void *handle, int);
+ int audio_decode_set_volume(void *, float);
+ int audio_decode_get_volume(void *, float *);
+ int audio_decode_set_pre_gain(void *, float);
+ int audio_decode_get_pre_gain(void *, float *);
+ int audio_decode_set_pre_mute(void *, uint);
+ int audio_decode_get_pre_mute(void *, uint *);
+ int audio_channels_swap(void *);
+ int audio_channel_left_mono(void *);
+ int audio_channel_right_mono(void *);
+ int audio_channel_stereo(void *);
+ int audio_output_muted(void *handle);
+ int audio_dec_ready(void *handle);
+ int audio_get_decoded_nb_frames(void *handle);
+
+ int audio_decode_set_lrvolume(void *, float lvol, float rvol);
+ int audio_decode_get_lrvolume(void *, float* lvol, float* rvol);
+ int audio_set_av_sync_threshold(void *, int);
+ int audio_get_soundtrack(void *, int*);
+ int get_audio_decoder(void);
+ int get_decoder_status(void *p, struct adec_status *adec);
+ int audio_channel_lrmix_flag_set(void *, int enable);
+ int audio_decpara_get(void *handle, int *pfs, int *pch,int *lfepresent);
+ int audio_get_format_supported(int format);
+ int audio_get_pts(void* handle);
+ int audio_set_skip_bytes(void* handle, unsigned int bytes);
+ int audio_get_pcm_level(void* handle);
+ int audio_get_decoded_pcm_delay(void *handle);
+ int audio_decode_basic_init(void);
+ int audio_decoder_set_trackrate(void* handle, void *rate);
+ int audio_decoder_get_enable_status(void* handle);
+ int audio_set_associate_enable(void *handle, unsigned int enable);
+ int audio_send_associate_data(void *handle, uint8_t *buf, size_t size);
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/amadec/include/adec-macros.h b/amadec/include/adec-macros.h
new file mode 100755
index 0000000..e9a5197
--- a/dev/null
+++ b/amadec/include/adec-macros.h
@@ -0,0 +1,41 @@
+/**
+ * \file adec-macros.h
+ * \brief Some Macros for Audio Dec
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#ifndef ADEC_MACROS_H
+#define ADEC_MACROS_H
+
+
+#ifdef __cplusplus
+#define ADEC_BEGIN_DECLS extern "C" {
+#define ADEC_END_DECLS }
+#else
+#define ADEC_BEGIN_DECLS
+#define ADEC_END_DECLS
+#endif
+
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+typedef unsigned int adec_bool_t;
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#endif
+
+#define MAX(X, Y) ((X) > (Y)) ? (X) : (Y)
+#define MIN(X, Y) ((X) < (Y)) ? (X) : (Y)
+
+#endif
diff --git a/amadec/include/adec-types.h b/amadec/include/adec-types.h
new file mode 100644
index 0000000..d8e3b80
--- a/dev/null
+++ b/amadec/include/adec-types.h
@@ -0,0 +1,53 @@
+/**
+ * \file adec-types.h
+ * \brief Definitiond Of Audio Dec Types
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#ifndef ADEC_TYPES_H
+#define ADEC_TYPES_H
+typedef enum {
+ ADEC_AUDIO_FORMAT_UNKNOWN = -1,
+ ADEC_AUDIO_FORMAT_MPEG = 0,
+ ADEC_AUDIO_FORMAT_PCM_S16LE,
+ ADEC_AUDIO_FORMAT_AAC,
+ ADEC_AUDIO_FORMAT_AC3,
+ ADEC_AUDIO_FORMAT_ALAW,
+ ADEC_AUDIO_FORMAT_MULAW,
+ ADEC_AUDIO_FORMAT_DTS,
+ ADEC_AUDIO_FORMAT_PCM_S16BE,
+ ADEC_AUDIO_FORMAT_FLAC,
+ ADEC_AUDIO_FORMAT_COOK,
+ ADEC_AUDIO_FORMAT_PCM_U8,
+ ADEC_AUDIO_FORMAT_ADPCM,
+ ADEC_AUDIO_FORMAT_AMR,
+ ADEC_AUDIO_FORMAT_RAAC,
+ ADEC_AUDIO_FORMAT_WMA,
+ ADEC_AUDIO_FORMAT_WMAPRO,
+ ADEC_AUDIO_AFORMAT_PCM_BLURAY,
+ ADEC_AUDIO_AFORMAT_ALAC,
+ ADEC_AUDIO_AFORMAT_VORBIS,
+ ADEC_AUDIO_FORMAT_AAC_LATM,
+ ADEC_AUDIO_FORMAT_APE,
+ ADEC_AUDIO_FORMAT_EAC3,
+ ADEC_AUDIO_FORMAT_PCM_WIFIDISPLAY,
+ ADEC_AUDIO_FORMAT_MAX,
+} adec_audio_format_t;
+
+#define VALID_FMT(f) ((f>ADEC_AUDIO_FORMAT_UNKNOWN)&& (f<ADEC_AUDIO_FORMAT_MAX))
+
+typedef enum {
+ IDLE,
+ TERMINATED,
+ STOPPED,
+ INITING,
+ INITTED,
+ ACTIVE,
+ PAUSED,
+} adec_state_t;
+
+#endif
diff --git a/amadec/include/alsa-out.h b/amadec/include/alsa-out.h
new file mode 100755
index 0000000..1be9dd1
--- a/dev/null
+++ b/amadec/include/alsa-out.h
@@ -0,0 +1,26 @@
+#ifndef ALSA_OUT_H
+#define ALSA_OUT_H
+
+#define PCM_DEVICE_DEFAULT "default"
+//#define PCM_DEVICE_DEFAULT "hw:0,2"
+#define OUTPUT_BUFFER_SIZE (8*1024)
+
+typedef struct {
+ pthread_t playback_tid;
+ pthread_mutex_t playback_mutex;
+ pthread_cond_t playback_cond;
+ snd_pcm_t *handle;
+ snd_pcm_format_t format;
+ size_t bits_per_sample;
+ size_t bits_per_frame;
+ int buffer_size;
+ unsigned int channelcount;
+ unsigned int rate;
+ int oversample;
+ int realchanl;
+ int flag;
+ int stop_flag;
+ int pause_flag;
+ int wait_flag;
+} alsa_param_t;
+#endif
diff --git a/amadec/include/audio-out.h b/amadec/include/audio-out.h
new file mode 100644
index 0000000..443732a
--- a/dev/null
+++ b/amadec/include/audio-out.h
@@ -0,0 +1,41 @@
+/**
+ * \file audio-out.h
+ * \brief Definitiond Of Audio Out Structures
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#ifndef AUDIO_OUT_H
+#define AUDIO_OUT_H
+
+#include <adec-macros.h>
+
+ADEC_BEGIN_DECLS
+
+struct aml_audio_dec;
+
+typedef struct {
+ void *private_data;
+ void *private_data_raw;
+ int (*init)(struct aml_audio_dec *);
+ int (*start)(struct aml_audio_dec *);
+ int (*pause)(struct aml_audio_dec *);
+ int (*resume)(struct aml_audio_dec *);
+ int (*stop)(struct aml_audio_dec *);
+ unsigned long(*latency)(struct aml_audio_dec *); /* get latency in ms */
+ int (*mute)(struct aml_audio_dec *, adec_bool_t); /* 1: enable mute ; 0: disable mute */
+ int (*set_volume)(struct aml_audio_dec *, float);
+ int (*set_lrvolume)(struct aml_audio_dec *, float, float);
+ int (*set_track_rate)(struct aml_audio_dec *, void *rate);
+ int (*get_out_position)(struct aml_audio_dec *, int64_t *position,
+ int64_t * time_us);
+ int audio_out_raw_enable;
+ float track_rate;
+} audio_out_operations_t;
+
+ADEC_END_DECLS
+
+#endif
diff --git a/amadec/include/audiodsp.h b/amadec/include/audiodsp.h
new file mode 100644
index 0000000..7c1e15e
--- a/dev/null
+++ b/amadec/include/audiodsp.h
@@ -0,0 +1,142 @@
+/**
+ * \file audiodsp.h
+ * \brief Definitiond Of Audiodsp Types And Structures
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#ifndef AUDIODSP_H
+#define AUDIODSP_H
+
+#include <adec-macros.h>
+#include <adec-types.h>
+#include "../audio-dec.h"
+
+ADEC_BEGIN_DECLS
+
+#define DSP_DEV_NOD "/dev/audiodsp0"
+
+#ifdef ANDROID
+#define AUDIODSP_SET_FMT _IOW('a',1,long)
+#define AUDIODSP_START _IOW('a',2,long)
+#define AUDIODSP_STOP _IOW('a',3,long)
+#define AUDIODSP_DECODE_START _IOW('a',4,long)
+#define AUDIODSP_DECODE_STOP _IOW('a',5,long)
+#define AUDIODSP_REGISTER_FIRMWARE _IOW('a',6,long)
+#define AUDIODSP_UNREGISTER_ALLFIRMWARE _IOW('a',7,long)
+#define AUDIODSP_SYNC_SET_APTS _IOW('a', 10, unsigned long)
+#define AUDIODSP_WAIT_FORMAT _IOW('a',11,long)
+
+#define AUDIODSP_SKIP_BYTES _IOW('a', 13, unsigned long)
+
+#define AUDIODSP_GET_CHANNELS_NUM _IOR('r',1,long)
+#define AUDIODSP_GET_SAMPLERATE _IOR('r',2,long)
+#define AUDIODSP_GET_BITS_PER_SAMPLE _IOR('r',3,long)
+#define AUDIODSP_GET_PTS _IOR('r',4,long)
+#define AUDIODSP_GET_DECODED_NB_FRAMES _IOR('r',5,long)
+#define AUDIODSP_GET_FIRST_PTS_FLAG _IOR('r',6,long)
+#define AUDIODSP_SYNC_GET_APTS _IOR('r',7,unsigned long)
+#define AUDIODSP_SYNC_GET_PCRSCR _IOR('r',8,unsigned long)
+#define AUDIODSP_AUTOMUTE_ON _IOW('r',9,unsigned long)
+#define AUDIODSP_AUTOMUTE_OFF _IOW('r',10,unsigned long)
+#define AUDIODSP_GET_PCM_LEVEL _IOR('r',12,unsigned long)
+#define AUDIODSP_SET_PCM_BUF_SIZE _IOW('r',13,long)
+#define AMAUDIO_IOC_SET_RESAMPLE_ENA _IOW('A', 0x19, unsigned long)
+#define AMAUDIO_IOC_GET_RESAMPLE_ENA _IOR('A', 0x1a, unsigned long)
+#else
+
+#define AUDIODSP_SET_FMT _IOW('a',1,sizeof(long))
+#define AUDIODSP_START _IOW('a',2,sizeof(long))
+#define AUDIODSP_STOP _IOW('a',3,sizeof(long))
+#define AUDIODSP_DECODE_START _IOW('a',4,sizeof(long))
+#define AUDIODSP_DECODE_STOP _IOW('a',5,sizeof(long))
+#define AUDIODSP_REGISTER_FIRMWARE _IOW('a',6,sizeof(long))
+#define AUDIODSP_UNREGISTER_ALLFIRMWARE _IOW('a',7,sizeof(long))
+#define AUDIODSP_WAIT_FORMAT _IOW('a',11,long)
+
+
+#define AUDIODSP_GET_CHANNELS_NUM _IOR('r',1,sizeof(long))
+#define AUDIODSP_GET_SAMPLERATE _IOR('r',2,sizeof(long))
+#define AUDIODSP_GET_BITS_PER_SAMPLE _IOR('r',3,sizeof(long))
+#define AUDIODSP_GET_PTS _IOR('r',4,sizeof(long))
+#define AUDIODSP_GET_DECODED_NB_FRAMES _IOR('r',5,sizeof(long))
+#define AUDIODSP_GET_FIRST_PTS_FLAG _IOR('r',6,sizeof(long))
+#endif
+
+
+#define MCODEC_FMT_MPEG123 (1<<0)
+#define MCODEC_FMT_AAC (1<<1)
+#define MCODEC_FMT_AC3 (1<<2)
+#define MCODEC_FMT_DTS (1<<3)
+#define MCODEC_FMT_FLAC (1<<4)
+#define MCODEC_FMT_COOK (1<<5)
+#define MCODEC_FMT_AMR (1<<6)
+#define MCODEC_FMT_RAAC (1<<7)
+#define MCODEC_FMT_ADPCM (1<<8)
+#define MCODEC_FMT_WMA (1<<9)
+#define MCODEC_FMT_PCM (1<<10)
+#define MCODEC_FMT_WMAPRO (1<<11)
+#define MCODEC_FMT_ALAC (1<<12)
+#define MCODEC_FMT_VORBIS (1<<13)
+#define MCODEC_FMT_AAC_LATM (1<<14)
+#define MCODEC_FMT_APE (1<<15)
+#define MCODEC_FMT_EAC3 (1<<16)
+
+/*********************************************************************************************/
+typedef struct dsp_operations dsp_operations_t;
+
+struct dsp_operations {
+ int dsp_file_fd;
+ int dsp_on;
+ unsigned long kernel_audio_pts;
+ unsigned long last_audio_pts;
+ unsigned long last_pts_valid;
+ int (*dsp_read)(dsp_operations_t *dsp_ops, char *buffer, int len); /* read pcm stream from dsp */
+ int (*dsp_read_raw)(dsp_operations_t *dsp_ops, char *buffer, int len); /* read raw stream from dsp */
+ unsigned long(*get_cur_pts)(dsp_operations_t *);
+ unsigned long(*get_cur_pcrscr)(dsp_operations_t *);
+ int (*set_cur_apts)(dsp_operations_t *dsp_ops, unsigned long apts);
+ int (*set_skip_bytes)(dsp_operations_t *dsp_ops, unsigned int skip_bytes);
+
+ int amstream_fd;
+ void *audec;
+};
+
+typedef struct {
+ int cmd;
+ int fmt;
+ int data_len;
+ char *data;
+} audiodsp_cmd_t;
+
+typedef struct {
+ int id;
+ int fmt;
+ char name[64];
+} firmware_s_t;
+
+
+/************************************************************************************************/
+
+int audiodsp_stream_read(dsp_operations_t *dsp_ops, char *buffer, int size);
+unsigned long audiodsp_get_pts(dsp_operations_t *dsp_ops);
+unsigned long audiodsp_get_pcrscr(dsp_operations_t *dsp_ops);
+int audiodsp_set_apts(dsp_operations_t *dsp_ops, unsigned long apts);
+int audiodsp_get_decoded_nb_frames(dsp_operations_t *dsp_ops);
+int audiodsp_get_first_pts_flag(dsp_operations_t *dsp_ops);
+int audiodsp_automute_on(dsp_operations_t *dsp_ops);
+int audiodsp_automute_off(dsp_operations_t *dsp_ops);
+int audiodsp_set_skip_bytes(dsp_operations_t* dsp_ops, unsigned int bytes);
+int audiodsp_get_pcm_level(dsp_operations_t* dsp_ops);
+
+int audiodsp_init(dsp_operations_t *dsp_ops);
+//int audiodsp_start(aml_audio_dec_t *audec);
+int audiodsp_stop(dsp_operations_t *dsp_ops);
+int audiodsp_release(dsp_operations_t *dsp_ops);
+
+ADEC_END_DECLS
+
+#endif
diff --git a/amadec/include/audiodsp_update_format.h b/amadec/include/audiodsp_update_format.h
new file mode 100644
index 0000000..27180d8
--- a/dev/null
+++ b/amadec/include/audiodsp_update_format.h
@@ -0,0 +1,25 @@
+#ifndef __AUDIODSP_UPDATE_FORMAT_H__
+#define __AUDIODSP_UPDATE_FORMAT_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <string.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+
+#include <audio-dec.h>
+#include <audiodsp.h>
+#include <log-print.h>
+
+void adec_reset_track_enable(int enable_flag);
+void adec_reset_track(aml_audio_dec_t *audec);
+int audiodsp_format_update(aml_audio_dec_t *audec);
+void audiodsp_set_format_changed_flag(int val);
+
+int audiodsp_get_pcm_left_len();
+
+#endif \ No newline at end of file
diff --git a/amadec/include/log-print.h b/amadec/include/log-print.h
new file mode 100644
index 0000000..639f4ba
--- a/dev/null
+++ b/amadec/include/log-print.h
@@ -0,0 +1,26 @@
+/**
+ * \file log-print.h
+ * \brief Definitiond Of Print Functions
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#ifndef LOG_PRINT_H
+#define LOG_PRINT_H
+
+#ifdef ANDROID
+#include <android/log.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#define LOG_TAG "amadec"
+#define adec_print(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#else
+#define adec_print(f,s...) fprintf(stderr,f,##s)
+#endif
+
+
+#endif
diff --git a/amadec/omx_audio/ALAC_mediasource.cpp b/amadec/omx_audio/ALAC_mediasource.cpp
new file mode 100755
index 0000000..c8e6f42
--- a/dev/null
+++ b/amadec/omx_audio/ALAC_mediasource.cpp
@@ -0,0 +1,205 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <android/log.h>
+#include <cutils/properties.h>
+#include "ALAC_mediasource.h"
+
+extern "C" int read_buffer(unsigned char *buffer,int size);
+
+#define LOG_TAG "ALAC_Medissource"
+#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
+
+#define MaxFrameSize 16384
+
+namespace android {
+
+int ALAC_MediaSource::set_ALAC_MetaData(aml_audio_dec_t *audec)
+{
+ mMeta->setInt32(kKeyChannelCount, audec->channels);
+ ChNum = audec->channels;
+ mMeta->setInt32(kKeySampleRate, audec->samplerate);
+ sample_rate = audec->samplerate;
+ mMeta->setInt32(kKeyExtraDataSize, audec->extradata_size);
+ extradata_size = audec->extradata_size;
+ mMeta->setData(kKeyExtraData,0,audec->extradata,audec->extradata_size);
+
+ ALOGI("channel_number = [%d], samplerate = [%d], extradata_size = [%d]\n",ChNum,sample_rate,extradata_size);
+
+ return 0;
+}
+int ALAC_MediaSource::MediaSourceRead_buffer(unsigned char *buffer,int size)
+{
+ int readcnt=0;
+ int readsum=0;
+ if(fpread_buffer!=NULL)
+ { int sleep_time=0;
+ while((readsum<size) && (*pStop_ReadBuf_Flag==0))
+ {
+ readcnt=fpread_buffer(buffer+readsum,size-readsum);
+ if(readcnt<(size-readsum)){
+ sleep_time++;
+ usleep(10000);
+ }
+ readsum+=readcnt;
+ if(sleep_time > 200){ //wait for max 2s to get audio data
+ ALOGE("[%s] Can't get data from audiobuffer,wait for %d ms\n ", __FUNCTION__,sleep_time*10);
+ }
+ }
+ if(*pStop_ReadBuf_Flag==1)
+ {
+ ALOGI("[%s] End of Stream: *pStop_ReadBuf_Flag==1\n ", __FUNCTION__);
+ }
+ return readsum;
+ }else{
+ ALOGE("[%s]ERR: fpread_buffer=NULL\n ", __FUNCTION__);
+ return 0;
+ }
+}
+
+//-------------------------------------------------------------------------
+ALAC_MediaSource::ALAC_MediaSource(void *read_buffer, aml_audio_dec_t *audec)
+{
+ ALOGI("[%s] in line (%d) \n",__FUNCTION__,__LINE__);
+ mStarted=false;
+ mMeta=new MetaData;
+ mDataSource=NULL;
+ mGroup=NULL;
+ mCurrentTimeUs=0;
+ pStop_ReadBuf_Flag=NULL;
+ fpread_buffer=(fp_read_buffer)read_buffer;
+ sample_rate=0;
+ ChNum=0;
+ frame_size=0;
+ bytes_readed_sum=0;
+ bytes_readed_sum_pre=0;
+ set_ALAC_MetaData(audec);
+
+}
+ALAC_MediaSource::~ALAC_MediaSource()
+{
+ ALOGI("[%s] in line (%d) \n",__FUNCTION__,__LINE__);
+ if (mStarted)
+ stop();
+}
+int ALAC_MediaSource::GetSampleRate()
+{
+ return sample_rate;
+}
+
+int ALAC_MediaSource::GetChNum()
+{
+ return ChNum;
+}
+
+int* ALAC_MediaSource::Get_pStop_ReadBuf_Flag()
+{
+ return pStop_ReadBuf_Flag;
+}
+
+int ALAC_MediaSource::Set_pStop_ReadBuf_Flag(int *pStop)
+{
+ pStop_ReadBuf_Flag = pStop;
+ return 0;
+}
+
+int ALAC_MediaSource::GetReadedBytes()
+{ int bytes_used = 0;
+ bytes_used=bytes_readed_sum-bytes_readed_sum_pre;
+ if(bytes_used<0)
+ {
+ ALOGI("[%s]WARING: bytes_readed_sum(%lld) < bytes_readed_sum_pre(%lld) \n",__FUNCTION__,
+ bytes_readed_sum,bytes_readed_sum_pre);
+ bytes_used=0;
+ }
+ bytes_readed_sum_pre=bytes_readed_sum;
+ return bytes_used;
+}
+
+sp<MetaData> ALAC_MediaSource::getFormat() {
+ ALOGI("[%s] in line (%d) \n",__FUNCTION__,__LINE__);
+ return mMeta;
+}
+
+status_t ALAC_MediaSource::start(MetaData *params)
+{
+ ALOGI("[%s] in line (%d) \n",__FUNCTION__,__LINE__);
+ mGroup = new MediaBufferGroup;
+ mGroup->add_buffer(new MediaBuffer(MaxFrameSize));
+ mStarted = true;
+ return OK;
+}
+
+status_t ALAC_MediaSource::stop()
+{
+ ALOGI("[%s] in line (%d) \n",__FUNCTION__,__LINE__);
+ delete mGroup;
+ mGroup = NULL;
+ mStarted = false;
+ return OK;
+}
+
+status_t ALAC_MediaSource::read(MediaBuffer **out, const ReadOptions *options)
+{
+ *out = NULL;
+ unsigned char header_buffer[5];
+ frame_size = 0;
+
+ if (*pStop_ReadBuf_Flag==1){
+ ALOGI("Stop_ReadBuf_Flag==1 stop read_buf [%s %d]",__FUNCTION__,__LINE__);
+ return ERROR_END_OF_STREAM;
+ }
+
+ MediaSourceRead_buffer(header_buffer,4);
+ while(1){
+ if((header_buffer[0] == 0x11)&&(header_buffer[1] == 0x22)&&(header_buffer[2] == 0x33)&&(header_buffer[3] == 0x44)){
+ break;
+ }
+ MediaSourceRead_buffer(&header_buffer[4],1);
+ header_buffer[0] = header_buffer[1];
+ header_buffer[1] = header_buffer[2];
+ header_buffer[2] = header_buffer[3];
+ header_buffer[3] = header_buffer[4];
+
+ if (*pStop_ReadBuf_Flag==1){
+ ALOGI("Stop_ReadBuf_Flag==1 stop read_buf [%s %d]",__FUNCTION__,__LINE__);
+ return ERROR_END_OF_STREAM;
+ }
+ }
+
+ MediaSourceRead_buffer(header_buffer,2);
+ frame_size = header_buffer[0]<<8 | header_buffer[1];
+ //ALOGI("frame_size = %d \n",frame_size);
+
+ if(frame_size<=0)
+ {
+ ALOGV("WARNING: Invalid frame_size %d \n",frame_size);
+ return ERROR_END_OF_STREAM;
+ }
+
+ MediaBuffer *buffer;
+ status_t err = mGroup->acquire_buffer(&buffer);
+ if (err != OK) {
+ return err;
+ }
+
+ if (MediaSourceRead_buffer((unsigned char*)(buffer->data()),frame_size) != frame_size)
+ {
+ buffer->release();
+ buffer = NULL;
+ return ERROR_END_OF_STREAM;
+ }
+ bytes_readed_sum+=frame_size;
+ buffer->set_range(0, frame_size);
+ buffer->meta_data()->setInt64(kKeyTime, mCurrentTimeUs);
+
+ *out = buffer;
+ return OK;
+}
+
+
+
+
+} // namespace android
+
diff --git a/amadec/omx_audio/ALAC_mediasource.h b/amadec/omx_audio/ALAC_mediasource.h
new file mode 100644
index 0000000..a9f0358
--- a/dev/null
+++ b/amadec/omx_audio/ALAC_mediasource.h
@@ -0,0 +1,62 @@
+#ifndef MEDIA_ALACMEDIASOURCE_H_
+#define MEDIA_ALACMEDIASOURCE_H_
+
+#include "MediaSource.h"
+#include "DataSource.h"
+#include "MediaBufferGroup.h"
+#include "MetaData.h"
+#include "audio_mediasource.h"
+#include "../audio-dec.h"
+
+namespace android
+{
+
+typedef int (*fp_read_buffer)(unsigned char *, int);
+
+class ALAC_MediaSource : public AudioMediaSource
+{
+public:
+ ALAC_MediaSource(void *read_buffer, aml_audio_dec_t *audec);
+
+ status_t start(MetaData *params = NULL);
+ status_t stop();
+ sp<MetaData> getFormat();
+ status_t read(MediaBuffer **buffer, const ReadOptions *options = NULL);
+
+ int GetReadedBytes();
+ int GetSampleRate();
+ int GetChNum();
+ int* Get_pStop_ReadBuf_Flag();
+ int Set_pStop_ReadBuf_Flag(int *pStop);
+
+ int set_ALAC_MetaData(aml_audio_dec_t *audec);
+ int MediaSourceRead_buffer(unsigned char *buffer, int size);
+
+ fp_read_buffer fpread_buffer;
+
+ int sample_rate;
+ int ChNum;
+ int frame_size;
+ int *pStop_ReadBuf_Flag;
+ int extradata_size;
+ int64_t bytes_readed_sum_pre;
+ int64_t bytes_readed_sum;
+protected:
+ virtual ~ALAC_MediaSource();
+
+private:
+ bool mStarted;
+ sp<DataSource> mDataSource;
+ sp<MetaData> mMeta;
+ MediaBufferGroup *mGroup;
+ int64_t mCurrentTimeUs;
+ int mBytesReaded;
+
+ ALAC_MediaSource(const ALAC_MediaSource &);
+ ALAC_MediaSource &operator=(const ALAC_MediaSource &);
+};
+
+
+}
+
+#endif
diff --git a/amadec/omx_audio/ASF_mediasource.cpp b/amadec/omx_audio/ASF_mediasource.cpp
new file mode 100755
index 0000000..a78226f
--- a/dev/null
+++ b/amadec/omx_audio/ASF_mediasource.cpp
@@ -0,0 +1,184 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <android/log.h>
+#include <cutils/properties.h>
+#include "ASF_mediasource.h"
+#include "audio-dec.h"
+extern "C" int read_buffer(unsigned char *buffer,int size);
+
+#define LOG_TAG "Asf_Medissource"
+#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
+
+
+namespace android {
+
+int Asf_MediaSource::set_Asf_MetaData(aml_audio_dec_t *audec)
+{
+ Asf_audio_info_t *paudio_info=(Asf_audio_info_t*)audec->extradata;
+
+ sample_rate=audec->samplerate=paudio_info->sample_rate;
+ ChNum =audec->channels =paudio_info->channels>2? 2: paudio_info->channels;
+ block_align=paudio_info->block_align;
+ mMeta->setInt32(kKeySampleRate,paudio_info->sample_rate );
+ mMeta->setInt32(kKeyChannelCount, paudio_info->channels);
+ mMeta->setInt32(kKeyBitRate,paudio_info->bitrate);
+/*
+ if(paudio_info->codec_id==CODEC_ID_WMAV1_FFMPEG)
+ paudio_info->codec_id=CODEC_ID_WMAV1_OMX;
+ else if(paudio_info->codec_id==CODEC_ID_WMAV2_FFMPEG)
+ paudio_info->codec_id=CODEC_ID_WMAV2_OMX;
+*/
+ mMeta->setInt32(kKeyCodecID,paudio_info->codec_id);
+ mMeta->setData(kKeyExtraData,0,paudio_info->extradata,paudio_info->extradata_size);
+ mMeta->setInt32(kKeyExtraDataSize, paudio_info->extradata_size);
+ mMeta->setInt32(kKeyBlockAlign,paudio_info->block_align);
+
+ ALOGI("ASF-->channels/%d samplerate/%d bitrate/%d codec_ID/0x%x extradata_size/%d block_align/%d\n",ChNum,sample_rate,
+ paudio_info->bitrate,paudio_info->codec_id,paudio_info->extradata_size,block_align);
+
+ if(ChNum==1 && paudio_info->codec_id==CODEC_ID_WMAV2){
+ ChNum=2;
+ ALOGI("ASF-->here ChNum:change mono to stero!\n");
+ }
+ return 0;
+}
+int Asf_MediaSource::MediaSourceRead_buffer(unsigned char *buffer,int size)
+{
+ int readcnt=0;
+ int readsum=0;
+ if(fpread_buffer!=NULL)
+ { int sleep_time=0;
+ while((readsum<size) && (*pStop_ReadBuf_Flag==0))
+ {
+ readcnt=fpread_buffer(buffer+readsum,size-readsum);
+ if(readcnt<(size-readsum)){
+ sleep_time++;
+ usleep(10000);
+ }
+ readsum+=readcnt;
+ }
+ bytes_readed_sum +=readsum;
+ if(*pStop_ReadBuf_Flag==1)
+ {
+ ALOGI("[%s] End of Stream: *pStop_ReadBuf_Flag==1\n ", __FUNCTION__);
+ }
+ return readsum;
+ }else{
+ ALOGI("[%s]ERR: fpread_buffer=NULL\n ", __FUNCTION__);
+ return 0;
+ }
+}
+
+//-------------------------------------------------------------------------
+Asf_MediaSource::Asf_MediaSource(void *read_buffer, aml_audio_dec_t *audec)
+{
+ ALOGI("[%s] in line (%d) \n",__FUNCTION__,__LINE__);
+ mStarted=false;
+ mMeta=new MetaData;
+ mDataSource=NULL;
+ mGroup=NULL;
+ mCurrentTimeUs=0;
+ pStop_ReadBuf_Flag=NULL;
+ fpread_buffer=(fp_read_buffer)read_buffer;
+ sample_rate=0;
+ ChNum=0;
+ frame_size=0;
+ block_align=0;
+ bytes_readed_sum_pre=0;
+ bytes_readed_sum=0;
+ set_Asf_MetaData(audec);
+
+}
+Asf_MediaSource::~Asf_MediaSource()
+{
+ ALOGI("[%s] in line (%d) \n",__FUNCTION__,__LINE__);
+ if (mStarted)
+ stop();
+}
+int Asf_MediaSource::GetSampleRate()
+{
+ return sample_rate;
+}
+
+int Asf_MediaSource::GetChNum()
+{
+ return ChNum;
+}
+
+int* Asf_MediaSource::Get_pStop_ReadBuf_Flag()
+{
+ return pStop_ReadBuf_Flag;
+}
+
+int Asf_MediaSource::Set_pStop_ReadBuf_Flag(int *pStop)
+{
+ pStop_ReadBuf_Flag = pStop;
+ return 0;
+}
+
+int Asf_MediaSource::GetReadedBytes()
+{
+ return block_align;
+}
+
+sp<MetaData> Asf_MediaSource::getFormat() {
+ ALOGI("[%s] in line (%d) \n",__FUNCTION__,__LINE__);
+ return mMeta;
+}
+
+status_t Asf_MediaSource::start(MetaData *params)
+{
+ ALOGI("[%s] in line (%d) \n",__FUNCTION__,__LINE__);
+ mGroup = new MediaBufferGroup;
+ mGroup->add_buffer(new MediaBuffer(block_align));
+ mStarted = true;
+ return OK;
+}
+
+status_t Asf_MediaSource::stop()
+{
+ ALOGI("[%s] in line (%d) \n",__FUNCTION__,__LINE__);
+ delete mGroup;
+ mGroup = NULL;
+ mStarted = false;
+ return OK;
+}
+
+status_t Asf_MediaSource::read(MediaBuffer **out, const ReadOptions *options)
+{
+ *out = NULL;
+ int readedbytes = 0;
+ unsigned char header_buffer[5];
+ frame_size = 0;
+
+ if (*pStop_ReadBuf_Flag==1){
+ ALOGI("Stop_ReadBuf_Flag==1 stop read_buf [%s %d]",__FUNCTION__,__LINE__);
+ return ERROR_END_OF_STREAM;
+ }
+
+ MediaBuffer *buffer;
+ status_t err = mGroup->acquire_buffer(&buffer);
+ if (err != OK) {
+ return err;
+ }
+
+ if (MediaSourceRead_buffer((unsigned char*)(buffer->data()),block_align) != block_align)
+ {
+ buffer->release();
+ buffer = NULL;
+ return ERROR_END_OF_STREAM;
+ }
+
+ buffer->set_range(0, block_align);
+ buffer->meta_data()->setInt64(kKeyTime, mCurrentTimeUs);
+
+ *out = buffer;
+ return OK;
+}
+
+
+
+
+} // namespace android
diff --git a/amadec/omx_audio/ASF_mediasource.h b/amadec/omx_audio/ASF_mediasource.h
new file mode 100644
index 0000000..1de9db4
--- a/dev/null
+++ b/amadec/omx_audio/ASF_mediasource.h
@@ -0,0 +1,127 @@
+#ifndef MEDIA_ASF_MEDIASOURCE_H_
+#define MEDIA_ASF_MEDIASOURCE_H_
+
+#include "MediaSource.h"
+#include "DataSource.h"
+#include "MediaBufferGroup.h"
+#include "MetaData.h"
+#include "audio_mediasource.h"
+#include "../audio-dec.h"
+
+namespace android
+{
+
+typedef int (*fp_read_buffer)(unsigned char *, int);
+
+//should corespond to the CodecID defined in <amffmpeg/libavcodec/avcodec.h>
+enum {
+ 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_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,
+ CODEC_ID_AAC_LATM,
+ CODEC_ID_QDMC,
+ CODEC_ID_CELT,
+};
+
+#define CODEC_ID_WMAV1_OMX 0x160
+#define CODEC_ID_WMAV2_OMX 0x161
+#define CODEC_ID_WMAPRO_OMX
+
+
+
+
+class Asf_MediaSource : public AudioMediaSource
+{
+public:
+ Asf_MediaSource(void *read_buffer, aml_audio_dec_t *audec);
+
+ status_t start(MetaData *params = NULL);
+ status_t stop();
+ sp<MetaData> getFormat();
+ status_t read(MediaBuffer **buffer, const ReadOptions *options = NULL);
+
+ int GetReadedBytes();
+ int GetSampleRate();
+ int GetChNum();
+ int* Get_pStop_ReadBuf_Flag();
+ int Set_pStop_ReadBuf_Flag(int *pStop);
+
+ int set_Asf_MetaData(aml_audio_dec_t *audec);
+ int MediaSourceRead_buffer(unsigned char *buffer, int size);
+
+ fp_read_buffer fpread_buffer;
+
+ int sample_rate;
+ int ChNum;
+ int frame_size;
+ int *pStop_ReadBuf_Flag;
+ int extradata_size;
+ int64_t bytes_readed_sum_pre;
+ int64_t bytes_readed_sum;
+protected:
+ virtual ~Asf_MediaSource();
+
+private:
+ bool mStarted;
+ sp<DataSource> mDataSource;
+ sp<MetaData> mMeta;
+ MediaBufferGroup *mGroup;
+ int64_t mCurrentTimeUs;
+ int mBytesReaded;
+ int block_align;
+ Asf_MediaSource(const Asf_MediaSource &);
+ Asf_MediaSource &operator=(const Asf_MediaSource &);
+};
+
+
+}
+
+#endif
+
diff --git a/amadec/omx_audio/Android.mk b/amadec/omx_audio/Android.mk
new file mode 100755
index 0000000..db2ae11
--- a/dev/null
+++ b/amadec/omx_audio/Android.mk
@@ -0,0 +1,34 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS := \
+ -fPIC -D_POSIX_SOURCE -DDOLBY_DDPDEC51_MULTICHANNEL_ENDPOINT
+
+LOCAL_C_INCLUDES:= \
+ $(LOCAL_PATH)/include \
+ $(LOCAL_PATH)/../ \
+ $(LOCAL_PATH)/../include \
+ frameworks/native/include/media/openmax \
+ frameworks/av/include/media/stagefright \
+ frameworks/native/include/utils
+
+LOCAL_SRC_FILES := \
+ adec_omx.cpp audio_mediasource.cpp
+ #../adec_read.c
+
+LOCAL_MODULE := libamadec_omx_api
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_SHARED_LIBRARIES += libutils libmedia libz libbinder libdl libcutils libc libstagefright \
+ libstagefright_omx libstagefright_yuv libmedia_native liblog \
+ libstagefright_foundation
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
+
+
+
diff --git a/amadec/omx_audio/DDP_mediasource.cpp b/amadec/omx_audio/DDP_mediasource.cpp
new file mode 100755
index 0000000..ef2bfd9
--- a/dev/null
+++ b/amadec/omx_audio/DDP_mediasource.cpp
@@ -0,0 +1,528 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <android/log.h>
+#include <cutils/properties.h>
+#include "DDP_mediasource.h"
+
+extern "C" int read_buffer(unsigned char *buffer,int size);
+
+#define LOG_TAG "DDP_Medissource"
+#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
+
+namespace android {
+
+
+DDPerr DDP_MediaSource::ddbs_init(DDPshort * buf, DDPshort bitptr,DDP_BSTRM *p_bstrm)
+{
+ p_bstrm->buf = buf;
+ p_bstrm->bitptr = bitptr;
+ p_bstrm->data = *buf;
+ return 0;
+}
+
+
+DDPerr DDP_MediaSource::ddbs_unprj(DDP_BSTRM *p_bstrm,DDPshort *p_data, DDPshort numbits)
+{
+ DDPushort data;
+ *p_data = (DDPshort)((p_bstrm->data << p_bstrm->bitptr) & msktab[numbits]);
+ p_bstrm->bitptr += numbits;
+ if (p_bstrm->bitptr >= BITSPERWRD)
+ {
+ p_bstrm->buf++;
+ p_bstrm->data = *p_bstrm->buf;
+ p_bstrm->bitptr -= BITSPERWRD;
+ data = (DDPushort)p_bstrm->data;
+ *p_data |= ((data >> (numbits - p_bstrm->bitptr)) & msktab[numbits]);
+ }
+ *p_data = (DDPshort)((DDPushort)(*p_data) >> (BITSPERWRD - numbits));
+ return 0;
+}
+
+
+int DDP_MediaSource::Get_ChNum_DD(void *buf)//at least need:56bit(=7 bytes)
+{
+ int numch=0;
+ DDP_BSTRM bstrm={0};
+ DDP_BSTRM *p_bstrm=&bstrm;
+ short tmp=0,acmod,lfeon,fscod,frmsizecod;
+ ddbs_init((short*)buf,0,p_bstrm);
+
+ ddbs_unprj(p_bstrm, &tmp, 16);
+ if (tmp!= SYNCWRD)
+ {
+ ALOGI("Invalid synchronization word");
+ return 0;
+ }
+ ddbs_unprj(p_bstrm, &tmp, 16);
+ ddbs_unprj(p_bstrm, &fscod, 2);
+ if (fscod == MAXFSCOD)
+ {
+ ALOGI("Invalid sampling rate code");
+ return 0;
+ }
+
+ if (fscod == 0) sample_rate = 48000;
+ else if (fscod == 1) sample_rate = 44100;
+ else if (fscod == 2) sample_rate = 32000;
+
+ ddbs_unprj(p_bstrm, &frmsizecod, 6);
+ if (frmsizecod >= MAXDDDATARATE)
+ {
+ ALOGI("Invalid frame size code");
+ return 0;
+ }
+
+ frame_size=frmsizetab[fscod][frmsizecod];
+
+ ddbs_unprj(p_bstrm, &tmp, 5);
+ if (!ISDD(tmp))
+ {
+ ALOGI("Unsupported bitstream id");
+ return 0;
+ }
+
+ ddbs_unprj(p_bstrm, &tmp, 3);
+ ddbs_unprj(p_bstrm, &acmod, 3);
+
+ if ((acmod!= MODE10) && (acmod& 0x1))
+ {
+ ddbs_unprj(p_bstrm, &tmp, 2);
+ }
+ if (acmod& 0x4)
+ {
+ ddbs_unprj(p_bstrm, &tmp, 2);
+ }
+
+ if (acmod == MODE20)
+ {
+ ddbs_unprj(p_bstrm,&tmp, 2);
+ }
+ ddbs_unprj(p_bstrm, &lfeon, 1);
+
+
+ numch = chanary[acmod];
+ //numch+=lfeon;
+ ChNumOriginal=numch;
+ if (0)
+ {
+ if (numch >= 3)
+ numch = 8;
+ else
+ numch = 2;
+ }else{
+ numch = 2;
+ }
+ ChNum=numch;
+ //ALOGI("DEBUG:numch=%d sample_rate=%d %p [%s %d]",ChNum,sample_rate,this,__FUNCTION__,__LINE__);
+ return numch;
+
+}
+int DDP_MediaSource::Get_ChNum_DDP(void *buf)//at least need:40bit(=5 bytes)
+{
+
+ int numch=0;
+ DDP_BSTRM bstrm={0};
+ DDP_BSTRM *p_bstrm=&bstrm;
+ short tmp=0,acmod,lfeon,strmtyp;
+
+ ddbs_init((short*)buf,0,p_bstrm);
+
+ ddbs_unprj(p_bstrm, &tmp, 16);
+ if (tmp!= SYNCWRD)
+ {
+ ALOGI("Invalid synchronization word");
+ return 0;
+ }
+
+ ddbs_unprj(p_bstrm, &strmtyp, 2);
+ ddbs_unprj(p_bstrm, &tmp, 3);
+ ddbs_unprj(p_bstrm, &tmp, 11);
+ frame_size=tmp+1;
+ //---------------------------
+ if (strmtyp != 0 && strmtyp != 2)
+ {
+ return 0;
+ }
+ //---------------------------
+ ddbs_unprj(p_bstrm, &tmp, 2);
+
+ if (tmp== 0x3)
+ {
+ ALOGI("Half sample rate unsupported");
+ return 0;
+ }else{
+ if (tmp == 0) sample_rate = 48000;
+ else if (tmp == 1) sample_rate = 44100;
+ else if (tmp == 2) sample_rate = 32000;
+
+ ddbs_unprj(p_bstrm, &tmp, 2);
+ }
+
+ ddbs_unprj(p_bstrm, &acmod, 3);
+ ddbs_unprj(p_bstrm, &lfeon, 1);
+
+ numch = chanary[acmod];
+ //numch+=lfeon;
+
+ ChNumOriginal=numch;
+ if (0)
+ {
+ if (numch >= 3)
+ numch = 8;
+ else
+ numch = 2;
+ }else{
+ numch = 2;
+ }
+ ChNum=numch;
+ //ALOGI("DEBUG:numch=%d sample_rate=%d %p [%s %d]",ChNum,sample_rate,this,__FUNCTION__,__LINE__);
+ return numch;
+
+}
+
+
+DDPerr DDP_MediaSource::ddbs_skip( DDP_BSTRM *p_bstrm, DDPshort numbits)
+{
+ p_bstrm->bitptr += numbits;
+ while (p_bstrm->bitptr >= BITSPERWRD)
+ {
+ p_bstrm->buf++;
+ p_bstrm->data = *p_bstrm->buf;
+ p_bstrm->bitptr -= BITSPERWRD;
+ }
+
+ return 0;
+}
+
+
+DDPerr DDP_MediaSource::ddbs_getbsid(DDP_BSTRM *p_inbstrm, DDPshort *p_bsid)
+{
+ DDP_BSTRM bstrm;
+
+ ddbs_init(p_inbstrm->buf, p_inbstrm->bitptr, &bstrm);
+ ddbs_skip(&bstrm, BS_BITOFFSET);
+ ddbs_unprj(&bstrm, p_bsid, 5);
+ if (!ISDDP(*p_bsid) && !ISDD(*p_bsid))
+ {
+ ALOGI("Unsupported bitstream id");
+ }
+
+ return 0;
+}
+
+
+int DDP_MediaSource::Get_ChNum_AC3_Frame(void *buf)
+{
+ DDP_BSTRM bstrm={0};
+ DDP_BSTRM *p_bstrm=&bstrm;
+ DDPshort bsid;
+ int chnum=0;
+ uint8_t ptr8[PTR_HEAD_SIZE];
+
+ memcpy(ptr8,buf,PTR_HEAD_SIZE);
+
+
+ //ALOGI("LZG->ptr_head:0x%x 0x%x 0x%x 0x%x 0x%x 0x%x \n",
+ // ptr8[0],ptr8[1],ptr8[2], ptr8[3],ptr8[4],ptr8[5] );
+ if ((ptr8[0] == 0x0b) && (ptr8[1] == 0x77))
+ {
+ int i;
+ uint8_t tmp;
+ for (i = 0; i < PTR_HEAD_SIZE; i += 2)
+ {
+ tmp=ptr8[i];
+ ptr8[i]=ptr8[i+1];
+ ptr8[i+1]=tmp;
+ }
+ }
+
+
+ ddbs_init((short*)ptr8,0,p_bstrm);
+ ddbs_getbsid(p_bstrm, &bsid);
+ //ALOGI("LZG->bsid=%d \n", bsid );
+ if (ISDDP(bsid))
+ {
+ Get_ChNum_DDP(ptr8);
+ }else if (ISDD(bsid)){
+ Get_ChNum_DD(ptr8);
+ }
+
+ return chnum;
+}
+
+//#####################################################
+
+DDP_MediaSource::DDP_MediaSource(void *read_buffer)
+{
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+ mStarted=false;
+ mMeta=new MetaData;
+ mDataSource=NULL;
+ mGroup=NULL;
+ mBytesReaded=0;
+ mCurrentTimeUs=0;
+ pStop_ReadBuf_Flag=NULL;
+ fpread_buffer=(fp_read_buffer)read_buffer;
+ sample_rate=0;
+ ChNum=0;
+ frame_size=0;
+ bytes_readed_sum_pre=0;
+ bytes_readed_sum=0;
+ extractor_cost_bytes = 0;
+ extractor_cost_bytes_last = 0;
+ mMeta->setInt32(kKeyChannelCount, 2);
+ mMeta->setInt32(kKeySampleRate, /*audec->samplerate*/48000);
+ memset(frame.rawbuf, 0, 6144);
+ memset(frame_length_his,0,sizeof(frame_length_his));
+ frame.len = 0;
+ ChNumOriginal=0;
+}
+
+DDP_MediaSource::~DDP_MediaSource()
+{
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+ if (mStarted) {
+ stop();
+ }
+}
+
+int DDP_MediaSource::GetSampleRate()
+{
+ return sample_rate;
+}
+int DDP_MediaSource::GetChNumOriginal()
+{
+ return ChNumOriginal;
+
+}
+int DDP_MediaSource::GetChNum()
+{
+ return ChNum;
+}
+
+int* DDP_MediaSource::Get_pStop_ReadBuf_Flag()
+{
+ return pStop_ReadBuf_Flag;
+}
+
+int DDP_MediaSource::Set_pStop_ReadBuf_Flag(int *pStop)
+{
+ pStop_ReadBuf_Flag = pStop;
+
+ return 0;
+}
+
+int DDP_MediaSource::SetReadedBytes(int size)
+{
+ mBytesReaded=size;
+ return 0;
+}
+
+int DDP_MediaSource::GetReadedBytes()
+{
+ int bytes_used;
+#if 0
+ bytes_used=bytes_readed_sum-bytes_readed_sum_pre;
+ if (bytes_used < 0)
+ {
+ ALOGI("[%s]bytes_readed_sum(%lld) < bytes_readed_sum_pre(%lld) \n",__FUNCTION__,bytes_readed_sum,bytes_readed_sum_pre);
+ bytes_used=0;
+ }
+ bytes_readed_sum_pre=bytes_readed_sum;
+#endif
+ bytes_used = extractor_cost_bytes;
+ bytes_used -= extractor_cost_bytes_last;
+ extractor_cost_bytes_last += bytes_used;
+ return bytes_used;
+}
+
+sp<MetaData> DDP_MediaSource::getFormat() {
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+ return mMeta;
+}
+
+status_t DDP_MediaSource::start(MetaData *params)
+{
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+ mGroup = new MediaBufferGroup;
+ mGroup->add_buffer(new MediaBuffer(4096));
+ mStarted = true;
+ return OK;
+}
+
+status_t DDP_MediaSource::stop()
+{
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+ delete mGroup;
+ mGroup = NULL;
+ mStarted = false;
+ return OK;
+}
+
+
+static int calc_dd_frame_size(int code)
+{
+ static const int FrameSize32K[] = { 96, 96, 120, 120, 144, 144, 168, 168, 192, 192, 240, 240, 288, 288, 336, 336, 384, 384, 480, 480, 576, 576, 672, 672, 768, 768, 960, 960, 1152, 1152, 1344, 1344, 1536, 1536, 1728, 1728, 1920, 1920 };
+ static const int FrameSize44K[] = { 69, 70, 87, 88, 104, 105, 121, 122, 139, 140, 174, 175, 208, 209, 243, 244, 278, 279, 348, 349, 417, 418, 487, 488, 557, 558, 696, 697, 835, 836, 975, 976, 114, 1115, 1253, 1254, 1393, 1394 };
+ static const int FrameSize48K[] = { 64, 64, 80, 80, 96, 96, 112, 112, 128, 128, 160, 160, 192, 192, 224, 224, 256, 256, 320, 320, 384, 384, 448, 448, 512, 512, 640, 640, 768, 768, 896, 896, 1024, 1024, 1152, 1152, 1280, 1280 };
+
+ int fscod = (code >> 6) & 0x3;
+ int frmsizcod = code & 0x3f;
+
+ if (fscod == 0) return 2 * FrameSize48K[frmsizcod];
+ if (fscod == 1) return 2 * FrameSize44K[frmsizcod];
+ if (fscod == 2) return 2 * FrameSize32K[frmsizcod];
+
+ return 0;
+}
+int DDP_MediaSource::get_frame_size(void)
+{
+ int i;
+ unsigned sum = 0;
+ unsigned valid_his_num = 0;
+ for (i = 0; i < FRAME_RECORD_NUM; i++) {
+ if (frame_length_his[i] > 0) {
+ valid_his_num ++;
+ sum += frame_length_his[i];
+ }
+ }
+
+ if (valid_his_num == 0) {
+ return 768;
+ }
+ return sum / valid_his_num;
+}
+void DDP_MediaSource::store_frame_size(int lastFrameLen)
+{
+ /* record the frame length into the history buffer */
+ int i = 0;
+ for (i = 0; i < FRAME_RECORD_NUM - 1; i++) {
+ frame_length_his[i] = frame_length_his[i + 1];
+ }
+ frame_length_his[FRAME_RECORD_NUM - 1] = lastFrameLen;
+}
+int DDP_MediaSource::MediaSourceRead_buffer(unsigned char *buffer,int size)
+{
+ int readcnt=0;
+ int readsum=0;
+ if(fpread_buffer!=NULL)
+ {
+ int sleep_time=0;
+ while ((readsum < size) && (*pStop_ReadBuf_Flag == 0))
+ {
+ readcnt=fpread_buffer(buffer+readsum,size-readsum);
+ if (readcnt < (size - readsum))
+ {
+ sleep_time++;
+ usleep(10000);
+ }
+ readsum+=readcnt;
+ if ((sleep_time > 0) && (sleep_time % 100 == 0))
+ { //wait for max 10s to get audio data
+ ALOGE("[%s] Can't get data from audiobuffer,wait for %d ms\n ", __FUNCTION__,sleep_time*10);
+ }
+ }
+ bytes_readed_sum +=readsum;
+ if (*pStop_ReadBuf_Flag == 1)
+ {
+ ALOGI("[%s] End of Stream: *pStop_ReadBuf_Flag==1\n ", __FUNCTION__);
+ }
+ return readsum;
+ }else{
+ ALOGE("[%s]ERR: fpread_buffer=NULL\n ", __FUNCTION__);
+ return 0;
+ }
+}
+
+status_t DDP_MediaSource::read(MediaBuffer **out, const ReadOptions *options)
+{
+ *out = NULL;
+ int readdiff = 0;
+ int read_delta = 0;
+ int read_size =0;
+ while(1){
+ frame_size = 0;
+ read_size = get_frame_size()+PTR_HEAD_SIZE+read_delta;
+ if (read_size > frame.len)
+ read_size -= frame.len;
+ /*check if the read_size exceed buffer size*/
+ if ((frame.len+read_size) > 6144) {
+ read_size = 6144 - frame.len;
+ }
+ frame.len += MediaSourceRead_buffer(frame.rawbuf + frame.len, read_size/* - frame.len*/);
+ if(frame.len < PTR_HEAD_SIZE){
+ ALOGI("WARNING: fpread_buffer read failed [%s %d]!\n",__FUNCTION__,__LINE__);
+ return ERROR_END_OF_STREAM;
+ }
+
+ if (*pStop_ReadBuf_Flag==1){
+ ALOGI("Stop_ReadBuf_Flag==1 stop read_buf [%s %d]",__FUNCTION__,__LINE__);
+ return ERROR_END_OF_STREAM;
+ }
+
+ unsigned short head;
+ head = frame.rawbuf[0] << 8 | frame.rawbuf[1];
+
+ if(head == 0x0b77 || head == 0x770b){
+ Get_ChNum_AC3_Frame(frame.rawbuf);
+ frame_size=frame_size*2;
+
+ if ((frame_size == 0) || (frame_size < PTR_HEAD_SIZE) || (frame_size > 4096))
+ {
+ ALOGI("frame_size %d error\n",frame_size);
+ memcpy((char*)(frame.rawbuf),(char *)(frame.rawbuf+1), frame.len-1);
+ frame.len -= 1;
+ readdiff ++;
+ continue;
+ }
+ /* if framesize bigger than current frame size + syncword size.read more */
+ if (frame_size > (frame.len - 2)) {
+ ALOGI("frame size %d exceed cached size %d,read more\n",frame_size,frame.len);
+ read_delta = frame_size - (frame.len -2);
+ continue;
+ }
+ head = (frame.rawbuf[frame_size] << 8) | frame.rawbuf[frame_size + 1];
+
+ if (head == 0x0b77 || head == 0x770b) {
+ ALOGI("next frame is ok,frame size %d\n",frame_size);
+ break;
+ }else{
+ ALOGI("=====next frame sync word error %x,resync\n",head);
+ memmove((char*)(frame.rawbuf),(char *)(frame.rawbuf+1), frame.len-1);
+ frame.len -= 1;
+ readdiff ++;
+ }
+ }else{
+ memmove((char*)(frame.rawbuf),(char *)(frame.rawbuf+1), frame.len-1);
+ frame.len -= 1;
+ readdiff ++;
+ }
+ }
+ read_delta = 0;
+ MediaBuffer *buffer;
+ status_t err = mGroup->acquire_buffer(&buffer);
+
+ if (err != OK) {
+ return err;
+ }
+
+ memcpy((unsigned char*)(buffer->data()), (unsigned char*)frame.rawbuf, frame_size);
+ memmove((unsigned char*)frame.rawbuf, (unsigned char*)(frame.rawbuf+frame_size), frame.len - frame_size);
+ frame.len -= frame_size;
+ buffer->set_range(0, frame_size);
+ buffer->meta_data()->setInt64(kKeyTime, mCurrentTimeUs);
+ buffer->meta_data()->setInt32(kKeyIsSyncFrame, 1);
+
+ *out = buffer;
+ if (readdiff > 0)
+ {
+ extractor_cost_bytes += readdiff;
+ }
+ store_frame_size(frame_size);
+ return OK;
+}
+
+} // namespace android
+
diff --git a/amadec/omx_audio/DDP_mediasource.h b/amadec/omx_audio/DDP_mediasource.h
new file mode 100644
index 0000000..b5d0160
--- a/dev/null
+++ b/amadec/omx_audio/DDP_mediasource.h
@@ -0,0 +1,141 @@
+#ifndef MEDIA_DDPMEDIASOURCE_H_
+#define MEDIA_DDPMEDIASOURCE_H_
+
+#include "MediaSource.h"
+#include "DataSource.h"
+#include "MediaBufferGroup.h"
+#include "MetaData.h"
+#include "audio_mediasource.h"
+
+namespace android {
+
+#define DDPshort short
+#define DDPerr short
+#define DDPushort unsigned short
+#define BYTESPERWRD 2
+#define BITSPERWRD (BYTESPERWRD*8)
+#define SYNCWRD ((DDPshort)0x0b77)
+#define MAXFSCOD 3
+#define MAXDDDATARATE 38
+#define BS_STD 8
+#define ISDD(bsid) ((bsid) <= BS_STD)
+#define MAXCHANCFGS 8
+#define BS_AXE 16
+#define ISDDP(bsid) ((bsid) <= BS_AXE && (bsid) > 10)
+#define BS_BITOFFSET 40
+#define PTR_HEAD_SIZE 7 //20
+#define FRAME_RECORD_NUM 40
+ typedef struct {
+ DDPshort *buf;
+ DDPshort bitptr;
+ DDPshort data;
+ } DDP_BSTRM;
+
+ typedef struct {
+ unsigned char rawbuf[6144];
+ int len;
+ } BUF_T;
+
+ const DDPshort chanary[MAXCHANCFGS] = { 2, 1, 2, 3, 3, 4, 4, 5 };
+ enum { MODE11 = 0, MODE_RSVD = 0, MODE10, MODE20,
+ MODE30, MODE21, MODE31, MODE22, MODE32
+ };
+
+ const DDPushort msktab[] = {
+ 0x0000, 0x8000, 0xc000, 0xe000,
+ 0xf000, 0xf800, 0xfc00, 0xfe00,
+ 0xff00, 0xff80, 0xffc0, 0xffe0,
+ 0xfff0, 0xfff8, 0xfffc, 0xfffe, 0xffff
+ };
+
+ const DDPshort frmsizetab[MAXFSCOD][MAXDDDATARATE] = {
+ /* 48kHz */
+ {
+ 64, 64, 80, 80, 96, 96, 112, 112,
+ 128, 128, 160, 160, 192, 192, 224, 224,
+ 256, 256, 320, 320, 384, 384, 448, 448,
+ 512, 512, 640, 640, 768, 768, 896, 896,
+ 1024, 1024, 1152, 1152, 1280, 1280},
+ /* 44.1kHz */
+ {
+ 69, 70, 87, 88, 104, 105, 121, 122,
+ 139, 140, 174, 175, 208, 209, 243, 244,
+ 278, 279, 348, 349, 417, 418, 487, 488,
+ 557, 558, 696, 697, 835, 836, 975, 976,
+ 1114, 1115, 1253, 1254, 1393, 1394},
+ /* 32kHz */
+ {
+ 96, 96, 120, 120, 144, 144, 168, 168,
+ 192, 192, 240, 240, 288, 288, 336, 336,
+ 384, 384, 480, 480, 576, 576, 672, 672,
+ 768, 768, 960, 960, 1152, 1152, 1344, 1344,
+ 1536, 1536, 1728, 1728, 1920, 1920}
+ };
+
+ typedef int (*fp_read_buffer) (unsigned char *, int);
+
+ class DDP_MediaSource:public AudioMediaSource {
+ public:
+ DDP_MediaSource(void *read_buffer);
+
+ status_t start(MetaData * params = NULL);
+ status_t stop();
+ sp < MetaData > getFormat();
+ status_t read(MediaBuffer ** buffer,
+ const ReadOptions * options = NULL);
+
+ int GetReadedBytes();
+ int GetSampleRate();
+ int GetChNum();
+ virtual int GetChNumOriginal();
+ int *Get_pStop_ReadBuf_Flag();
+ int Set_pStop_ReadBuf_Flag(int *pStop);
+
+ int SetReadedBytes(int size);
+ int MediaSourceRead_buffer(unsigned char *buffer, int size);
+
+ fp_read_buffer fpread_buffer;
+
+ //----------------------------------------
+ DDPerr ddbs_init(DDPshort * buf, DDPshort bitptr,
+ DDP_BSTRM * p_bstrm);
+ DDPerr ddbs_unprj(DDP_BSTRM * p_bstrm, DDPshort * p_data,
+ DDPshort numbits);
+ int Get_ChNum_DD(void *buf);
+ int Get_ChNum_DDP(void *buf);
+ DDPerr ddbs_skip(DDP_BSTRM * p_bstrm, DDPshort numbits);
+ DDPerr ddbs_getbsid(DDP_BSTRM * p_inbstrm, DDPshort * p_bsid);
+ int Get_ChNum_AC3_Frame(void *buf);
+ int get_frame_size(void);
+ void store_frame_size(int lastFrameLen);
+ //---------------------------------------
+
+ int sample_rate;
+ int ChNum;
+ int frame_size;
+ BUF_T frame;
+ int64_t bytes_readed_sum_pre;
+ int64_t bytes_readed_sum;
+ int extractor_cost_bytes;
+ int extractor_cost_bytes_last;
+ int *pStop_ReadBuf_Flag;
+ int ChNumOriginal;
+ int frame_length_his[FRAME_RECORD_NUM];
+protected:
+ virtual ~ DDP_MediaSource();
+
+ private:
+ bool mStarted;
+ sp < DataSource > mDataSource;
+ sp < MetaData > mMeta;
+ MediaBufferGroup *mGroup;
+ int64_t mCurrentTimeUs;
+ int mBytesReaded;
+
+ DDP_MediaSource(const DDP_MediaSource &);
+ DDP_MediaSource & operator=(const DDP_MediaSource &);
+ };
+
+}
+
+#endif
diff --git a/amadec/omx_audio/DTSHD_mediasource.cpp b/amadec/omx_audio/DTSHD_mediasource.cpp
new file mode 100644
index 0000000..84cb1b5
--- a/dev/null
+++ b/amadec/omx_audio/DTSHD_mediasource.cpp
@@ -0,0 +1,316 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <android/log.h>
+#include <cutils/properties.h>
+#include "DTSHD_mediasource.h"
+
+extern "C" int read_buffer(unsigned char *buffer,int size);
+
+#define LOG_TAG "DTSHD_Medissource"
+#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
+
+
+namespace android {
+static int AML_Match_DTS_SyncWord(uint32_t ui32Temp0, uint32_t ui32Temp1)
+{
+ /* 16-bit bit core stream*/
+ if( ui32Temp0 == AML_DCA_SW_CORE_16 || ui32Temp0 == AML_DCA_SW_CORE_14 ||
+ ui32Temp0 == AML_DCA_SW_CORE_16M || ui32Temp0 == AML_DCA_SW_CORE_14M ||
+ ui32Temp0 == AML_DCA_SW_SUBSTREAM|| ui32Temp0 ==AML_DCA_SW_SUBSTREAM_M)
+ {
+ return 1;
+ }
+
+ if ((ui32Temp0 & 0xffffff00) == (AML_DCA_SW_CORE_24 & 0xffffff00) &&
+ ((ui32Temp1 >> 16) & 0xFF)== (AML_DCA_SW_CORE_24 & 0xFF))
+ {
+ return 1;
+ }
+ return 0;
+}
+static int AML_DCA_Estimate_Frame_size( unsigned char *buf,int size,int *syncpos)
+{
+ int i32Index=0;
+ int result=0;
+ unsigned int ui32Sword0=0,ui32Sword1=0;
+ unsigned int ui32Sword0_save=0;
+ int first_sync_Detected=0,first_sync_pos=-1;
+ int frame_size=0;
+ *syncpos=0;
+ for (i32Index=0; i32Index+7<size;i32Index++)
+ {
+ ui32Sword0 = buf[i32Index]; ui32Sword0 <<= 8;
+ ui32Sword0 |= buf[i32Index + 1]; ui32Sword0 <<= 8;
+ ui32Sword0 |= buf[i32Index + 2]; ui32Sword0 <<= 8;
+ ui32Sword0 |= buf[i32Index + 3];
+
+ ui32Sword1 = buf[i32Index + 4]; ui32Sword1 <<= 8;
+ ui32Sword1 |= buf[i32Index + 5]; ui32Sword1 <<= 8;
+ ui32Sword1 |= buf[i32Index + 6]; ui32Sword1 <<= 8;
+ ui32Sword1 |= buf[i32Index + 7];
+
+ result=AML_Match_DTS_SyncWord(ui32Sword0,ui32Sword1);
+
+ if (result) {
+ ALOGI("SyncWord detect: ui32Sync_word/0x%x ui32Sync_word2/0x%x ",ui32Sword0,ui32Sword1);
+ if (first_sync_Detected == 0)
+ {
+ first_sync_Detected=1;
+ first_sync_pos=i32Index;
+ ui32Sword0_save=ui32Sword0;
+ ALOGI("first_sync_pos/%d ",first_sync_pos);
+ }else if(first_sync_Detected == 1){
+ if (ui32Sword0_save == ui32Sword0)
+ {
+ frame_size=i32Index-first_sync_pos;
+ ALOGI("FrameSize detect: %d/bytes",frame_size);
+ break;
+ }
+ }
+ }
+ }
+
+ if (frame_size == 0)
+ {
+ ALOGE("[%s %d ]FrameSize detect Falied,used defualt value/1024\n",__FUNCTION__,__LINE__);
+ frame_size=1024;
+ }else{
+ frame_size += 4;
+ }
+ *syncpos=first_sync_pos;
+ return frame_size;
+}
+
+Dtshd_MediaSource::Dtshd_MediaSource(void *read_buffer)
+{
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+ mStarted=false;
+ mMeta=new MetaData;
+ mDataSource=NULL;
+ mGroup=NULL;
+ mBytesReaded=0;
+ mCurrentTimeUs=0;
+ pStop_ReadBuf_Flag=NULL;
+ fpread_buffer=(fp_read_buffer)read_buffer;
+ sample_rate=0;
+ ChNum=0;
+ frame_size=0;
+ bytes_readed_sum_pre=0;
+ bytes_readed_sum=0;
+ FrameSizeDetectFlag=0;
+ FirFraBuf=NULL;
+ FirFraBuf_Len=0;
+ FirFraBuf_Offset=0;
+ FrameNumReaded=0;
+ mMeta->setInt32(kKeyChannelCount,/* audec->channels > 0?audec->channels:*/2);
+ mMeta->setInt32(kKeySampleRate, /*audec->samplerate> 0?audec->samplerate:*/48000);
+}
+
+
+Dtshd_MediaSource::~Dtshd_MediaSource()
+{
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+ if (FirFraBuf)
+ free(FirFraBuf);
+ if (mStarted) {
+ stop();
+ }
+}
+
+
+int Dtshd_MediaSource::GetSampleRate()
+{
+ return sample_rate;
+}
+
+int Dtshd_MediaSource::GetChNum()
+{
+ return ChNum;
+}
+int Dtshd_MediaSource::SetSampleRate(int samplerate)
+{
+ sample_rate = samplerate;
+ return OK ;
+}
+
+int* Dtshd_MediaSource::Get_pStop_ReadBuf_Flag()
+{
+ return pStop_ReadBuf_Flag;
+}
+
+int Dtshd_MediaSource::Set_pStop_ReadBuf_Flag(int *pStop)
+{
+ pStop_ReadBuf_Flag = pStop;
+ return 0;
+}
+
+int Dtshd_MediaSource::GetReadedBytes()
+{
+ return frame_size;
+}
+
+sp<MetaData> Dtshd_MediaSource::getFormat()
+{
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+ return mMeta;
+}
+
+status_t Dtshd_MediaSource::start(MetaData *params)
+{
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+ mGroup = new MediaBufferGroup;
+ mGroup->add_buffer(new MediaBuffer(AML_DCA_INPUT_DATA_LEN_PTIME));
+ mStarted = true;
+ return OK;
+}
+
+status_t Dtshd_MediaSource::stop()
+{
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+ delete mGroup;
+ mGroup = NULL;
+ mStarted = false;
+ return OK;
+}
+
+
+int Dtshd_MediaSource::MediaSourceRead_buffer(unsigned char *buffer,int size)
+{
+ int readcnt=0;
+ int readsum=0;
+ if (fpread_buffer != NULL)
+ {
+ int sleep_time=0;
+ while ((readsum < size)&& (*pStop_ReadBuf_Flag == 0))
+ {
+ readcnt=fpread_buffer(buffer+readsum,size-readsum);
+ if (readcnt < (size-readsum))
+ {
+ sleep_time++;
+ usleep(10000);
+ }
+ readsum+=readcnt;
+ if ((sleep_time > 0) && (sleep_time%100 == 0) )
+ { //wait for max 10s to get audio data
+ ALOGE("[%s] Can't get data from audiobuffer,wait for %d ms\n ", __FUNCTION__,sleep_time*10);
+ }
+ }
+ bytes_readed_sum +=readsum;
+ if (*pStop_ReadBuf_Flag == 1)
+ {
+ ALOGI("[%s] End of Stream: *pStop_ReadBuf_Flag==1\n ", __FUNCTION__);
+ }
+ return readsum;
+ }else{
+ ALOGE("[%s]ERR: fpread_buffer=NULL\n ", __FUNCTION__);
+ return 0;
+ }
+}
+
+
+status_t Dtshd_MediaSource::read(MediaBuffer **out, const ReadOptions *options)
+{
+ *out = NULL;
+ int read_bytes_per_time;
+ MediaBuffer *buffer;
+ int byte_readed=0;
+ status_t err;
+ if (!FrameSizeDetectFlag)
+ {
+ FirFraBuf=(unsigned char*)malloc(AML_DCA_INPUT_DATA_LEN_PTIME);
+ if (FirFraBuf == NULL)
+ {
+ ALOGE("[%s %d] mallco memory for <FirFraBuf> failed!\n",__FUNCTION__,__LINE__);
+ return ERROR_END_OF_STREAM;
+ }
+ FirFraBuf_Len=AML_DCA_INPUT_DATA_LEN_PTIME;
+ if (MediaSourceRead_buffer(FirFraBuf,FirFraBuf_Len) != FirFraBuf_Len)
+ {
+ ALOGE("[%s %d] Stream Lengh <%d> Err!\n",__FUNCTION__,__LINE__,FirFraBuf_Len);
+ return ERROR_END_OF_STREAM;
+ }
+
+ frame_size= AML_DCA_Estimate_Frame_size(FirFraBuf,FirFraBuf_Len,&FirFraBuf_Offset);
+ if (frame_size == 0)
+ {
+ ALOGE("[%s %d] Detect Frame_size Err!\n",__FUNCTION__,__LINE__);
+ return ERROR_END_OF_STREAM;
+ }
+ FrameSizeDetectFlag=1;
+ }
+
+ err = mGroup->acquire_buffer(&buffer);
+ if (err != OK) {
+ ALOGE("[%s %d] mGroup->acquire_buffer ERR!\n",__FUNCTION__,__LINE__);
+ return err;
+ }
+
+ if (FrameNumReaded == 0 && FirFraBuf_Offset > 0)
+ {
+ int pre_suspend_bytes=0;
+ int redunt=FirFraBuf_Offset%4;
+ if(redunt)
+ pre_suspend_bytes=4-redunt;
+ unsigned char zarray[32]={0};
+ memcpy((unsigned char*)(buffer->data()),FirFraBuf,FirFraBuf_Offset);
+ memcpy((unsigned char*)(buffer->data())+FirFraBuf_Offset, zarray, pre_suspend_bytes);
+ memcpy((unsigned char*)(buffer->data())+FirFraBuf_Offset+pre_suspend_bytes,FirFraBuf+FirFraBuf_Offset, frame_size);
+ memcpy(zarray,FirFraBuf,32);
+ ALOGI("[%s %d] pre_suspend_bytes/%d %s \n",__FUNCTION__,__LINE__,pre_suspend_bytes,zarray);
+
+ buffer->set_range(0, pre_suspend_bytes+FirFraBuf_Offset+frame_size);
+ buffer->meta_data()->setInt64(kKeyTime, mCurrentTimeUs);
+ buffer->meta_data()->setInt32(kKeyIsSyncFrame, 1);
+ *out = buffer;
+ FirFraBuf_Offset+=frame_size;
+ FrameNumReaded++;
+ return OK;
+ }
+
+ if (FirFraBuf_Offset < FirFraBuf_Len)
+ {
+ if (FirFraBuf_Len-FirFraBuf_Offset >= frame_size)
+ {
+ byte_readed=frame_size;
+ }else{
+ byte_readed=(FirFraBuf_Len-FirFraBuf_Offset);
+ }
+ memcpy((unsigned char*)(buffer->data()),FirFraBuf+FirFraBuf_Offset,byte_readed);
+ FirFraBuf_Offset+=byte_readed;
+ if (MediaSourceRead_buffer((unsigned char*)(buffer->data())+byte_readed,frame_size-byte_readed) != (frame_size-byte_readed))
+ {
+ buffer->release();
+ buffer = NULL;
+ return ERROR_END_OF_STREAM;
+ }
+
+ buffer->set_range(0,frame_size);
+ }else{
+ //for dtshd coceless high samplerate stream ,framesize got maybe inaccurate and causes frozen issues
+ //some coceless stream framesize about 100 bytes and need push scores of frames to decoder and paser out
+ //one real dts frame,so change the framesize to 10k.
+ if (sample_rate == 96000)
+ frame_size = AML_DCA_INPUT_DATA_LEN_PTIME;
+ if (MediaSourceRead_buffer((unsigned char*)(buffer->data()), frame_size) != frame_size)
+ {
+ buffer->release();
+ buffer = NULL;
+ return ERROR_END_OF_STREAM;
+ }
+
+ buffer->set_range(0,frame_size);
+ }
+
+ buffer->meta_data()->setInt64(kKeyTime, mCurrentTimeUs);
+ buffer->meta_data()->setInt32(kKeyIsSyncFrame, 1);
+ *out = buffer;
+ FrameNumReaded++;
+ return OK;
+}
+
+
+} // namespace android
+
+
diff --git a/amadec/omx_audio/DTSHD_mediasource.h b/amadec/omx_audio/DTSHD_mediasource.h
new file mode 100644
index 0000000..f9f74f9
--- a/dev/null
+++ b/amadec/omx_audio/DTSHD_mediasource.h
@@ -0,0 +1,74 @@
+#ifndef MEDIA_DTSHD_MEDIASOURCE_H_
+#define MEDIA_DTSHD_MEDIASOURCE_H_
+
+#include "MediaSource.h"
+#include "DataSource.h"
+#include "MediaBufferGroup.h"
+#include "MetaData.h"
+#include "audio_mediasource.h"
+
+namespace android
+{
+//for dtsexpress stream,sometimes vbuf is full and abuf has not 40k and cause block about 5s.
+#define AML_DCA_INPUT_DATA_LEN_PTIME (10*1024)
+#define AML_DCA_OMX_DECODER_NUMBUF 2
+#define AML_DCA_SW_CORE_16M 0x7ffe8001
+#define AML_DCA_SW_CORE_14M 0x1fffe800
+#define AML_DCA_SW_CORE_24M 0xfe80007f
+#define AML_DCA_SW_CORE_16 0xfe7f0180
+#define AML_DCA_SW_CORE_14 0xff1f00e8
+#define AML_DCA_SW_CORE_24 0x80fe7f01
+#define AML_DCA_SW_SUBSTREAM_M 0x64582025
+#define AML_DCA_SW_SUBSTREAM 0x58642520
+
+typedef int (*fp_read_buffer)(unsigned char *, int);
+class Dtshd_MediaSource : public AudioMediaSource
+{
+public:
+ Dtshd_MediaSource(void *read_buffer);
+
+ status_t start(MetaData *params = NULL);
+ status_t stop();
+ sp<MetaData> getFormat();
+ status_t read(MediaBuffer **buffer, const ReadOptions *options = NULL);
+
+ int GetReadedBytes();
+ int GetSampleRate();
+ virtual int SetSampleRate(int samplerate);
+ int GetChNum();
+ int* Get_pStop_ReadBuf_Flag();
+ int Set_pStop_ReadBuf_Flag(int *pStop);
+ int MediaSourceRead_buffer(unsigned char *buffer, int size);
+
+ fp_read_buffer fpread_buffer;
+ int sample_rate;
+ int ChNum;
+ int frame_size;
+ int FrameSizeDetectFlag;
+ unsigned char * FirFraBuf;
+ int FirFraBuf_Len;
+ int FirFraBuf_Offset;
+ int FrameNumReaded;
+ int *pStop_ReadBuf_Flag;
+ int64_t bytes_readed_sum_pre;
+ int64_t bytes_readed_sum;
+protected:
+ virtual ~Dtshd_MediaSource();
+
+private:
+ bool mStarted;
+ sp<DataSource> mDataSource;
+ sp<MetaData> mMeta;
+ MediaBufferGroup *mGroup;
+ int64_t mCurrentTimeUs;
+ int mBytesReaded;
+ int block_align;
+ Dtshd_MediaSource(const Dtshd_MediaSource &);
+ Dtshd_MediaSource &operator=(const Dtshd_MediaSource &);
+};
+
+
+}
+
+#endif
+
diff --git a/amadec/omx_audio/MP3_mediasource.cpp b/amadec/omx_audio/MP3_mediasource.cpp
new file mode 100755
index 0000000..adf2799
--- a/dev/null
+++ b/amadec/omx_audio/MP3_mediasource.cpp
@@ -0,0 +1,579 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <android/log.h>
+#include <cutils/properties.h>
+#include "MP3_mediasource.h"
+
+extern "C" int read_buffer(unsigned char *buffer,int size);
+
+#define LOG_TAG "MP3_Mediasource"
+#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
+
+#define kMaxReadBytes 4096
+#define MaxFrameSize 4096
+static const uint32_t kMask = 0xfffe0c00;
+
+namespace android {
+
+uint32_t U32_AT(const uint8_t *ptr)
+{
+ return ptr[0] << 24 | ptr[1] << 16 | ptr[2] << 8 | ptr[3];
+}
+inline bool MP3_MediaSource::GetMPEGAudioFrameSize(uint32_t header, int *frame_size,
+ int *out_sampling_rate, int *out_channels, int *out_bitrate, int *out_num_samples) {
+ *frame_size = 0;
+
+ if (out_sampling_rate) {
+ *out_sampling_rate = 0;
+ }
+
+ if (out_channels) {
+ *out_channels = 0;
+ }
+
+ if (out_bitrate) {
+ *out_bitrate = 0;
+ }
+
+ if (out_num_samples) {
+ *out_num_samples = 1152;
+ }
+
+ if ((header & 0xffe00000) != 0xffe00000) {
+ return false;
+ }
+
+ unsigned version = (header >> 19) & 3;
+
+ if (version == 0x01) {
+ return false;
+ }
+
+ unsigned layer = (header >> 17) & 3;
+
+ if (layer == 0x00) {
+ return false;
+ }
+
+ unsigned protection = (header >> 16) & 1;
+
+ unsigned bitrate_index = (header >> 12) & 0x0f;
+
+ if (bitrate_index == 0 || bitrate_index == 0x0f) {
+ // Disallow "free" bitrate.
+ return false;
+ }
+
+ unsigned sampling_rate_index = (header >> 10) & 3;
+
+ if (sampling_rate_index == 3) {
+ return false;
+ }
+
+ static const int kSamplingRateV1[] = { 44100, 48000, 32000 };
+ int sampling_rate = kSamplingRateV1[sampling_rate_index];
+ if (version == 2 /* V2 */) {
+ sampling_rate /= 2;
+ } else if (version == 0 /* V2.5 */) {
+ sampling_rate /= 4;
+ }
+
+ unsigned padding = (header >> 9) & 1;
+
+ if (layer == 3) {
+ // layer I
+
+ static const int kBitrateV1[] = {
+ 32, 64, 96, 128, 160, 192, 224, 256,
+ 288, 320, 352, 384, 416, 448
+ };
+
+ static const int kBitrateV2[] = {
+ 32, 48, 56, 64, 80, 96, 112, 128,
+ 144, 160, 176, 192, 224, 256
+ };
+
+ int bitrate =
+ (version == 3 /* V1 */)
+ ? kBitrateV1[bitrate_index - 1]
+ : kBitrateV2[bitrate_index - 1];
+
+ if (out_bitrate) {
+ *out_bitrate = bitrate;
+ }
+
+ *frame_size = (12000 * bitrate / sampling_rate + padding) * 4;
+
+ if (out_num_samples) {
+ *out_num_samples = 384;
+ }
+ } else {
+ // layer II or III
+
+ static const int kBitrateV1L2[] = {
+ 32, 48, 56, 64, 80, 96, 112, 128,
+ 160, 192, 224, 256, 320, 384
+ };
+
+ static const int kBitrateV1L3[] = {
+ 32, 40, 48, 56, 64, 80, 96, 112,
+ 128, 160, 192, 224, 256, 320
+ };
+
+ static const int kBitrateV2[] = {
+ 8, 16, 24, 32, 40, 48, 56, 64,
+ 80, 96, 112, 128, 144, 160
+ };
+
+ int bitrate;
+ if (version == 3 /* V1 */) {
+ bitrate = (layer == 2 /* L2 */)
+ ? kBitrateV1L2[bitrate_index - 1]
+ : kBitrateV1L3[bitrate_index - 1];
+
+ if (out_num_samples) {
+ *out_num_samples = 1152;
+ }
+ } else {
+ // V2 (or 2.5)
+
+ bitrate = kBitrateV2[bitrate_index - 1];
+ if (out_num_samples) {
+ *out_num_samples = (layer == 1 /* L3 */) ? 576 : 1152;
+ }
+ }
+
+ if (out_bitrate) {
+ *out_bitrate = bitrate;
+ }
+
+ if (version == 3 /* V1 */) {
+ *frame_size = 144000 * bitrate / sampling_rate + padding;
+ } else {
+ // V2 or V2.5
+ size_t tmp = (layer == 1 /* L3 */) ? 72000 : 144000;
+ *frame_size = tmp * bitrate / sampling_rate + padding;
+ }
+ }
+
+ if (out_sampling_rate) {
+ *out_sampling_rate = sampling_rate;
+ }
+
+ if (out_channels) {
+ int channel_mode = (header >> 6) & 3;
+
+ *out_channels = (channel_mode == 3) ? 1 : 2;
+ }
+
+ return true;
+}
+int MP3_MediaSource::MediaSourceRead_buffer(unsigned char *buffer,int size)
+{
+ int readcnt=0;
+ int readsum=0;
+
+ if(fpread_buffer!=NULL){
+ int sleep_time=0;
+ while((readsum<size) && (*pStop_ReadBuf_Flag==0)){
+ readcnt=fpread_buffer(buffer+readsum,size-readsum);
+ if(readcnt<(size-readsum)){
+ sleep_time++;
+ usleep(10000);
+ }
+ readsum+=readcnt;
+ if((sleep_time>0) && (sleep_time%100==0)){ //wait for max 10s to get audio data
+ ALOGE("[%s] Can't get data from audiobuffer,wait for %d ms\n ", __FUNCTION__,sleep_time*10);
+ }
+ }
+ bytes_readed_sum +=readsum;
+ if(*pStop_ReadBuf_Flag==1)
+ {
+ ALOGI("[%s] End of Stream: *pStop_ReadBuf_Flag==1\n ", __FUNCTION__);
+ }
+ return readsum;
+ }else{
+ ALOGE("[%s]ERR: fpread_buffer=NULL\n ", __FUNCTION__);
+ return 0;
+ }
+}
+
+unsigned int MP3_MediaSource::Find_header(unsigned char *buffer, int *frame_size,
+ int *out_sampling_rate, int *out_channels,int *out_bitrate, int *out_num_samples)
+{
+ unsigned int readedbytes = 0;
+ unsigned char header_buffer[5];
+
+ readedbytes = MediaSourceRead_buffer(header_buffer,4);
+
+ if (readedbytes < 4)
+ {
+ ALOGI("Read MP3 header is fail [%s %d]",__FUNCTION__,__LINE__);
+ return 0;
+ }
+
+ while(1){
+ uint32_t header = U32_AT((const uint8_t *)header_buffer);
+ if(GetMPEGAudioFrameSize(header, frame_size, out_sampling_rate,out_channels,
+ out_bitrate, out_num_samples)){
+ break;
+ }
+ MediaSourceRead_buffer(&header_buffer[4],1);
+ memmove(&header_buffer[0],&header_buffer[1],4);
+ readedbytes++;
+ if (*pStop_ReadBuf_Flag==1){
+ ALOGI("Stop_ReadBuf_Flag==1 stop read_buf [%s %d]",__FUNCTION__,__LINE__);
+ return 0;
+ }
+ }
+ memcpy(&buffer[0],&header_buffer[0],4);
+ return readedbytes;
+}
+
+bool MP3_MediaSource::refind_header(unsigned char *buffer, int *frame_size, unsigned char *header_buffer,
+ int offset, int *readbytes)
+{
+ int readedbytes;
+ unsigned char *pos_buffer = buffer;
+
+ memcpy(&header_buffer[0],pos_buffer,4);
+ pos_buffer += 4;
+
+ for(readedbytes = 4; readedbytes < offset; readedbytes++){
+ uint32_t header = U32_AT((const uint8_t *)header_buffer);
+
+ if(GetMPEGAudioFrameSize(header, frame_size, NULL,NULL,NULL, NULL)){
+ *readbytes = readedbytes;
+ return true;
+ }
+ memcpy(&header_buffer[4],pos_buffer++,1);
+ memmove(&header_buffer[0],&header_buffer[1],4);
+ if (*pStop_ReadBuf_Flag==1){
+ ALOGI("Stop_ReadBuf_Flag==1 stop read_buf [%s %d]",__FUNCTION__,__LINE__);
+ return false;
+ }
+ }
+ return false;
+}
+
+
+unsigned int MP3_MediaSource::Resync(uint32_t pos)
+{
+ unsigned char header_buffer[10];
+ uint32_t first_header = 0;
+ uint32_t test_header = 0;
+ int offset = 0;
+ int readbytes = 0;
+ uint32_t counter = 0;
+ int framesize = 0;
+ uint32_t position = pos;
+ uint8_t *buffer;
+ int left_bytes = 0;
+ ResyncOccurFlag=2;
+ SyncWordPosArray[0] = bytes_readed_sum;
+BeginResync:
+
+ ALOGI("Resync start!\n");
+ left_bytes = 0;
+ buffer = buf;
+ offset = 0;
+ Resync_framesize[0] = 0;
+ Resync_framesize[1] = 0;
+ Resync_framesize[2] = 0;
+
+ if(position == 0){
+ readbytes = Find_header(header_buffer,&framesize,NULL,NULL,NULL,NULL);
+ first_header = U32_AT((const uint8_t *)header_buffer);
+ memcpy(buf,&header_buffer[0],4);
+ Resync_framesize[0] = framesize;
+ }else{
+ Resync_framesize[0] = framesize = frame_size;
+ }
+ SyncWordPosArray[1] = bytes_readed_sum-4;//first syncword pos:
+ first_header = U32_AT((const uint8_t *)header_buffer);
+ position = 0;
+
+ if(MediaSourceRead_buffer(buf+4,framesize-4) != (framesize-4)){
+ ALOGE("Read MP3 data is fail [%s %d]",__FUNCTION__,__LINE__);
+ return ERROR_END_OF_STREAM;
+ }
+ offset += framesize;
+ Resynced_flag = 1;
+
+ //ALOGI("first offset = [%d]\n",offset);
+
+ do{
+ readbytes = MediaSourceRead_buffer(header_buffer,4);
+ memcpy(buffer+offset,&header_buffer[0],4);
+ offset += 4;
+ test_header = U32_AT((const uint8_t *)header_buffer);
+
+Compare:
+ if(!GetMPEGAudioFrameSize(test_header,&framesize,NULL,NULL,NULL,NULL) ||
+ (test_header & kMask != first_header & kMask))
+ {
+ if(refind_header(buffer+4, &framesize, &header_buffer[0],offset-4,&readbytes) == false)
+ {
+ goto BeginResync; //can't find first header in loaded data
+ }else{
+ first_header = U32_AT((const uint8_t *)header_buffer); //reset the first header
+ Resynced_flag = 1;
+ Resync_framesize[0] = framesize;
+ Resync_framesize[1] = 0;
+ offset -= readbytes;
+ memmove(buffer,buffer+readbytes,offset);
+ if(framesize > offset){
+ readbytes = MediaSourceRead_buffer(buffer+offset,framesize - offset);
+ offset = framesize;
+ continue;
+ }else{
+ test_header = U32_AT((const uint8_t *)(buffer+framesize));
+ } goto Compare;
+ }
+ }else{
+ Resynced_flag ++;
+ SyncWordPosArray[Resynced_flag] = bytes_readed_sum-4;//first syncword pos:
+ if(Resynced_flag > 3){
+ ALOGI("Resynced out![%s %d]",__FUNCTION__,__LINE__);
+ Resynced_flag = 3;
+ break;
+ }
+
+ left_bytes = offset - 4 - Resync_framesize[0] - Resync_framesize[1];
+ Resync_framesize[Resynced_flag-1] = framesize;
+
+ if(left_bytes == 0){
+ readbytes = MediaSourceRead_buffer(buffer+offset,framesize - 4);
+ offset += (framesize - 4);
+ }else if((left_bytes < framesize) && (left_bytes > 0)){
+ readbytes = MediaSourceRead_buffer(buffer+offset,framesize - left_bytes - 4);
+ offset += (framesize - left_bytes - 4);
+ }else if(left_bytes > framesize){
+ test_header = U32_AT((const uint8_t *)(buffer+framesize+Resync_framesize[Resynced_flag-2]));
+ goto Compare;
+ }else{
+ ALOGE("offset [%d] is invalid!left_bytes [%d] framesize [%d] [%s %d]",
+ offset,left_bytes,framesize,__FUNCTION__,__LINE__);
+ }
+ }
+ } while (Resynced_flag != 3);
+ ALOGI("SyncWordPosArray:%lld/ %lld/ %lld/ %lld/ %lld",
+ SyncWordPosArray[0],SyncWordPosArray[1],SyncWordPosArray[2],SyncWordPosArray[3],SyncWordPosArray[4]);
+ Resync_pos = 0;
+ return first_header;
+}
+
+int MP3_MediaSource::set_MP3_MetaData(aml_audio_dec_t *audec)
+{
+ mMeta->setInt32(kKeyChannelCount, audec->channels);
+ ChNum = audec->channels;
+ mMeta->setInt32(kKeySampleRate, audec->samplerate);
+ sample_rate = audec->samplerate;
+
+ ALOGI("channel_number = [%d], samplerate = [%d]\n",ChNum,sample_rate);
+
+ return 0;
+}
+
+
+//-------------------------------------------------------------------------
+MP3_MediaSource::MP3_MediaSource(void *read_buffer, aml_audio_dec_t *audec, int *exit)
+{
+ ALOGI("[%s] in line (%d) \n",__FUNCTION__,__LINE__);
+ mStarted=false;
+ mMeta=new MetaData;
+ mDataSource=NULL;
+ mGroup=NULL;
+ mCurrentTimeUs=0;
+ pStop_ReadBuf_Flag=exit;
+ fpread_buffer=(fp_read_buffer)read_buffer;
+ sample_rate=0;
+ ChNum=0;
+ frame_size=0;
+ bitrate = 0;
+ num_samples = 0;
+ Resynced_flag = 0;
+ buf = NULL;
+ mFixedHeader = 0;
+ start_flag = 1;
+
+ set_MP3_MetaData(audec);
+ buf=(uint8_t *) malloc (sizeof(uint8_t)*kMaxReadBytes);
+ ResyncOccurFlag=0;
+ memset(SyncWordPosArray,0,sizeof(int64_t)*5);
+ if(buf == NULL){
+ ALOGE("Malloc buffer is fail! [%s] [%d]\n",__FUNCTION__,__LINE__);
+ }
+
+}
+
+MP3_MediaSource::~MP3_MediaSource()
+{
+ ALOGI("[%s] in line (%d) \n",__FUNCTION__,__LINE__);
+
+ free( buf );
+ buf = NULL;
+
+ if (mStarted)
+ stop();
+}
+int MP3_MediaSource::GetSampleRate()
+{
+ return sample_rate;
+}
+
+int MP3_MediaSource::GetChNum()
+{
+ return ChNum;
+}
+
+int* MP3_MediaSource::Get_pStop_ReadBuf_Flag()
+{
+ return pStop_ReadBuf_Flag;
+}
+
+int MP3_MediaSource::Set_pStop_ReadBuf_Flag(int *pStop)
+{
+ pStop_ReadBuf_Flag = pStop;
+ return 0;
+}
+
+int MP3_MediaSource::GetReadedBytes()
+{ int bytes_used = 0;
+
+ if(ResyncOccurFlag){
+ if(ResyncOccurFlag==2){
+ bytes_used=SyncWordPosArray[ResyncOccurFlag]-SyncWordPosArray[0];
+ }else{
+ bytes_used=SyncWordPosArray[ResyncOccurFlag]-SyncWordPosArray[ResyncOccurFlag-1];
+ }
+ ResyncOccurFlag++;
+ if(ResyncOccurFlag==5)
+ ResyncOccurFlag=0;
+ }else{
+ bytes_used=frame_size;//bytes_readed_sum-bytes_readed_sum_pre;
+ }
+ if(bytes_used<0)
+ {
+ ALOGI("[%s]WARING: bytes_readed_sum(%lld) < bytes_readed_sum_pre(%lld) \n",__FUNCTION__,
+ bytes_readed_sum,bytes_readed_sum_pre);
+ bytes_used=0;
+ }
+ bytes_readed_sum_pre=bytes_readed_sum;
+ return bytes_used;
+}
+
+sp<MetaData> MP3_MediaSource::getFormat() {
+ ALOGI("[%s] in line (%d) \n",__FUNCTION__,__LINE__);
+ return mMeta;
+}
+
+status_t MP3_MediaSource::start(MetaData *params)
+{
+ ALOGI("[%s] in line (%d) \n",__FUNCTION__,__LINE__);
+ mGroup = new MediaBufferGroup;
+ mGroup->add_buffer(new MediaBuffer(MaxFrameSize));
+ mStarted = true;
+ return OK;
+}
+
+status_t MP3_MediaSource::stop()
+{
+ ALOGI("[%s] in line (%d) \n",__FUNCTION__,__LINE__);
+ delete mGroup;
+ mGroup = NULL;
+ mStarted = false;
+ return OK;
+}
+
+status_t MP3_MediaSource::read(MediaBuffer **out, const ReadOptions *options)
+{
+ *out = NULL;
+ uint32_t readedbytes = 0;
+ unsigned char header_buffer[5];
+ frame_size = 0;
+ uint32_t header = 0;
+
+ if (*pStop_ReadBuf_Flag==1){
+ ALOGI("Stop_ReadBuf_Flag==1 stop read_buf [%s %d]",__FUNCTION__,__LINE__);
+ return ERROR_END_OF_STREAM;
+ }
+
+ if(start_flag == 1){
+ ALOGI("Start Resync the begin of stream [%s %d]",__FUNCTION__,__LINE__);
+ mFixedHeader = Resync(0);
+ start_flag = 0;
+ }
+
+ MediaBuffer *buffer;
+ status_t err = mGroup->acquire_buffer(&buffer);
+ if (err != OK) {
+ return err;
+ }
+
+Read_data:
+
+ if(Resynced_flag){ //read data from resync buffer
+ if (*pStop_ReadBuf_Flag==1){
+ ALOGI("Stop_ReadBuf_Flag==1 stop read_buf [%s %d]",__FUNCTION__,__LINE__);
+ buffer->release();
+ buffer = NULL;
+ return ERROR_END_OF_STREAM;
+ }
+ frame_size = Resync_framesize[3-Resynced_flag];
+ memcpy((unsigned char*)(buffer->data()),&buf[Resync_pos],frame_size);
+ Resync_pos += frame_size;
+ Resynced_flag--;
+ }else{
+ readedbytes = Find_header(header_buffer,&frame_size,&sample_rate,&ChNum,&bitrate,&num_samples);
+
+ uint32_t header = U32_AT((const uint8_t *)header_buffer);
+
+ if((header & kMask) != (mFixedHeader & kMask)){
+ if (*pStop_ReadBuf_Flag==1){
+ ALOGI("Stop_ReadBuf_Flag==1 stop read_buf [%s %d]",__FUNCTION__,__LINE__);
+ buffer->release();
+ buffer = NULL;
+ return ERROR_END_OF_STREAM;
+ }
+ while(ResyncOccurFlag && *pStop_ReadBuf_Flag==0 )
+ usleep(10000);
+ mFixedHeader = Resync(4);
+ memcpy(&buf[0],&header_buffer[0],4);
+ ALOGI("[%s]Resync the MP3! \n",__FUNCTION__);
+ goto Read_data;
+ }
+
+ //ALOGI("frame_size = %d,sample_rate = %d,ChNum = %d, bitrate = %d, num_samples = %d readedbytes = %d\n",
+ // frame_size,sample_rate,ChNum,bitrate,num_samples,readedbytes);
+
+ if(frame_size<=0)
+ {
+ ALOGE("WARNING: Invalid frame_size %d \n",frame_size);
+ return ERROR_END_OF_STREAM;
+ }
+
+ memcpy((unsigned char*)(buffer->data()),&header_buffer[0],4);
+
+ if (MediaSourceRead_buffer(((unsigned char*)buffer->data()+4),(frame_size-4)) != (frame_size-4)){
+ buffer->release();
+ buffer = NULL;
+ return ERROR_END_OF_STREAM;
+ }
+ }
+
+ buffer->set_range(0, frame_size);
+ buffer->meta_data()->setInt64(kKeyTime, mCurrentTimeUs);
+ buffer->meta_data()->setInt32(kKeyIsSyncFrame, 1);
+
+ *out = buffer;
+ return OK;
+}
+
+
+
+
+} // namespace android
+
diff --git a/amadec/omx_audio/MP3_mediasource.h b/amadec/omx_audio/MP3_mediasource.h
new file mode 100644
index 0000000..685ae09
--- a/dev/null
+++ b/amadec/omx_audio/MP3_mediasource.h
@@ -0,0 +1,80 @@
+#ifndef MEDIA_MP3MEDIASOURCE_H_
+#define MEDIA_MP3MEDIASOURCE_H_
+
+#include "MediaSource.h"
+#include "DataSource.h"
+#include "MediaBufferGroup.h"
+#include "MetaData.h"
+#include "audio_mediasource.h"
+#include "../audio-dec.h"
+
+namespace android
+{
+
+typedef int (*fp_read_buffer)(unsigned char *, int);
+
+class MP3_MediaSource : public AudioMediaSource
+{
+public:
+ MP3_MediaSource(void *read_buffer, aml_audio_dec_t *audec, int *exit);
+
+ status_t start(MetaData *params = NULL);
+ status_t stop();
+ sp<MetaData> getFormat();
+ status_t read(MediaBuffer **buffer, const ReadOptions *options = NULL);
+
+ int GetReadedBytes();
+ int GetSampleRate();
+ int GetChNum();
+ int* Get_pStop_ReadBuf_Flag();
+ int Set_pStop_ReadBuf_Flag(int *pStop);
+
+ int set_MP3_MetaData(aml_audio_dec_t *audec);
+ int MediaSourceRead_buffer(unsigned char *buffer, int size);
+
+ inline bool GetMPEGAudioFrameSize(uint32_t header, int *frame_size, int *out_sampling_rate,
+ int *out_channels, int *out_bitrate, int *out_num_samples);
+ unsigned int Find_header(unsigned char *buffer, int *frame_size, int *out_sampling_rate,
+ int *out_channels, int *out_bitrate, int *out_num_samples);
+ bool refind_header(unsigned char *buffer, int *frame_size, unsigned char *header_buffer,
+ int offset, int *readbytes);
+ unsigned int Resync(uint32_t pos);
+
+ fp_read_buffer fpread_buffer;
+
+ int sample_rate;
+ int ChNum;
+ int frame_size;
+ int bitrate;
+ int num_samples;
+
+ int *pStop_ReadBuf_Flag;
+ int64_t bytes_readed_sum_pre;
+ int64_t bytes_readed_sum;
+
+protected:
+ virtual ~MP3_MediaSource();
+
+private:
+ bool mStarted;
+ sp<DataSource> mDataSource;
+ sp<MetaData> mMeta;
+ MediaBufferGroup *mGroup;
+ int64_t mCurrentTimeUs;
+ int Resynced_flag;
+ uint8_t *buf;
+ int Resync_framesize[3];
+ int Resync_pos;
+ uint32_t mFixedHeader;
+ int start_flag;
+ int64_t SyncWordPosArray[5];
+ int ResyncOccurFlag;
+
+ MP3_MediaSource(const MP3_MediaSource &);
+ MP3_MediaSource &operator=(const MP3_MediaSource &);
+};
+
+
+}
+
+#endif
diff --git a/amadec/omx_audio/THD_mediasource.cpp b/amadec/omx_audio/THD_mediasource.cpp
new file mode 100644
index 0000000..e29df93
--- a/dev/null
+++ b/amadec/omx_audio/THD_mediasource.cpp
@@ -0,0 +1,229 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <android/log.h>
+#include <cutils/properties.h>
+#include "THD_mediasource.h"
+
+extern "C" int read_buffer(unsigned char *buffer,int size);
+
+#define LOG_TAG "THD_Medissource"
+#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
+
+namespace android {
+
+THD_MediaSource::THD_MediaSource(void *read_buffer)
+{
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+ mStarted=false;
+ mMeta=new MetaData;
+ mDataSource=NULL;
+ mGroup=NULL;
+ mBytesReaded=0;
+ mCurrentTimeUs=0;
+ pStop_ReadBuf_Flag=NULL;
+ fpread_buffer=(fp_read_buffer)read_buffer;
+ sample_rate=48000;//96000;
+ ChNum=2;
+ frame_size=0;
+ bytes_readed_sum_pre=0;
+ bytes_readed_sum=0;
+ mSyncMain = false;
+ mMeta->setInt32(kKeyChannelCount, 2);
+ mMeta->setInt32(kKeySampleRate, 48000);
+}
+
+THD_MediaSource::~THD_MediaSource()
+{
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+ if (mStarted) {
+ stop();
+ }
+}
+
+int THD_MediaSource::GetSampleRate()
+{
+ return sample_rate;
+}
+
+int THD_MediaSource::GetChNum()
+{
+ return ChNum;
+}
+
+int* THD_MediaSource::Get_pStop_ReadBuf_Flag()
+{
+ return pStop_ReadBuf_Flag;
+}
+
+int THD_MediaSource::Set_pStop_ReadBuf_Flag(int *pStop)
+{
+ pStop_ReadBuf_Flag = pStop;
+
+ return 0;
+}
+
+int THD_MediaSource::SetReadedBytes(int size)
+{
+ mBytesReaded=size;
+ return 0;
+}
+
+int THD_MediaSource::GetReadedBytes()
+{
+ int bytes_used;
+ bytes_used=bytes_readed_sum-bytes_readed_sum_pre;
+ if(bytes_used<0)
+ {
+ ALOGI("[%s]bytes_readed_sum(%lld) < bytes_readed_sum_pre(%lld) \n",__FUNCTION__,bytes_readed_sum,bytes_readed_sum_pre);
+ bytes_used=0;
+ }
+ bytes_readed_sum_pre=bytes_readed_sum;
+ return bytes_used;
+}
+
+sp<MetaData> THD_MediaSource::getFormat() {
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+ return mMeta;
+}
+
+status_t THD_MediaSource::start(MetaData *params)
+{
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+ mGroup = new MediaBufferGroup;
+ mGroup->add_buffer(new MediaBuffer(4096));
+ mStarted = true;
+ return OK;
+}
+
+status_t THD_MediaSource::stop()
+{
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+ delete mGroup;
+ mGroup = NULL;
+ mStarted = false;
+ return OK;
+}
+
+int THD_MediaSource::MediaSourceRead_buffer(unsigned char *buffer,int size)
+{
+ int readcnt=0;
+ int readsum=0;
+ if(fpread_buffer!=NULL)
+ {
+ int sleep_time=0;
+ while((readsum<size)&& (*pStop_ReadBuf_Flag==0))
+ {
+ readcnt=fpread_buffer(buffer+readsum,size-readsum);
+ if(readcnt<(size-readsum)){
+ sleep_time++;
+ usleep(10000);
+ }
+ readsum+=readcnt;
+ if((sleep_time>0) && (sleep_time%100==0)){ //wait for max 10s to get audio data
+ ALOGE("[%s] Can't get data from audiobuffer,wait for %d ms\n ", __FUNCTION__,sleep_time*10);
+ }
+ }
+ bytes_readed_sum +=readsum;
+ if(*pStop_ReadBuf_Flag==1)
+ {
+ ALOGI("[%s] End of Stream: *pStop_ReadBuf_Flag==1\n ", __FUNCTION__);
+ }
+ return readsum;
+ }else{
+ ALOGE("[%s]ERR: fpread_buffer=NULL\n ", __FUNCTION__);
+ return 0;
+ }
+}
+
+status_t THD_MediaSource::read(MediaBuffer **out, const ReadOptions *options)
+{
+ *out = NULL;
+ uint fourheader = 0; //au size and crc check and timing
+ uint syncheader = 0; //truehd sync words(word:four bytes)
+ uchar byte;
+ uchar byte2[2];
+ uint ausize; //access unit size(byte)
+ uint i = 0;
+
+ if(!mSyncMain){
+ while(1)//max frame length is 4000 bytes
+ {
+ ALOGI("=======find sync main=====\n");
+ if(MediaSourceRead_buffer((uchar*)&byte, 1) < 1){
+ ALOGI("[%s,%d]read raw data from buffer failed\n",__FUNCTION__,__LINE__);
+ return ERROR_END_OF_STREAM;
+ }
+ fourheader = (fourheader << 8) | (syncheader >> 24);
+ syncheader = (syncheader << 8) | byte;
+ if(syncheader == TRUEHDSYNC){
+ ausize = ((fourheader >> 16) & 0x0fff) << 1;
+ ChNum = 2;
+ sample_rate = 48000;//96000;
+ mSyncMain = true;
+ ALOGI("truehd: main sync word find ok\n");
+ break;
+ }
+ }
+#if 0
+ if(i >= MAX_AUSIZE)
+ {
+ ALOGI("ERROR: can not find truehd main sync\n");
+ return ERROR_UNSUPPORTED;
+ }
+#endif
+ }else{
+ if(MediaSourceRead_buffer((uchar*)&byte2, 2) < 2){
+ ALOGI("[%s,%d]read raw data from buffer failed\n",__FUNCTION__,__LINE__);
+ return ERROR_END_OF_STREAM;
+ }
+ ausize = (((byte2[0]<< 8) | byte2[1]) & 0x0fff) << 1;
+ }
+
+ if((ausize < MIN_AUSIZE) || (ausize > MAX_AUSIZE)){
+ ALOGI("ERROR: access unit size can not accept!!!\n");
+ return ERROR_UNSUPPORTED;
+ }
+
+
+ MediaBuffer *buffer;
+ status_t err = mGroup->acquire_buffer(&buffer);
+ if (err != OK) {
+ ALOGI("acquire_buffer buffer failed.\n");
+ return err;
+ }
+
+ if(syncheader == TRUEHDSYNC){
+ memcpy((uchar *)(buffer->data()), &fourheader, 4);
+ memcpy((uchar *)((unsigned long)buffer->data() + 4), &syncheader, 4);
+ if (MediaSourceRead_buffer((uchar*)((unsigned long)buffer->data() + 8), ausize - 8) != (ausize - 8)) {
+ ALOGI("[%s %d]stream read failed\n",__FUNCTION__,__LINE__);
+ buffer->release();
+ buffer = NULL;
+ return ERROR_END_OF_STREAM;
+ }
+ char *ptr = (char *)((unsigned long)buffer->data() + 8);
+ sample_rate = ((ptr[0] >> 4) & 0xf) & 8 ? 44100 : 48000;
+ ALOGI("[%s:%d] sample_rate = %d\n", __FUNCTION__, __LINE__, sample_rate);
+ }else{
+ memcpy((uchar *)(buffer->data()), &byte2, 2);
+ if (MediaSourceRead_buffer((uchar*)((unsigned long)buffer->data() + 2), ausize - 2) != (ausize - 2)) {
+ ALOGI("[%s %d]stream read failed\n",__FUNCTION__,__LINE__);
+ buffer->release();
+ buffer = NULL;
+ return ERROR_END_OF_STREAM;
+ }
+ }
+
+
+ buffer->set_range(0, ausize);
+ buffer->meta_data()->setInt64(kKeyTime, mCurrentTimeUs);
+ buffer->meta_data()->setInt32(kKeyIsSyncFrame, 1);
+
+ *out = buffer;
+ return OK;
+}
+
+} // namespace android
+
diff --git a/amadec/omx_audio/THD_mediasource.h b/amadec/omx_audio/THD_mediasource.h
new file mode 100644
index 0000000..e8d9c65
--- a/dev/null
+++ b/amadec/omx_audio/THD_mediasource.h
@@ -0,0 +1,74 @@
+#ifndef MEDIA_THDMEDIASOURCE_H_
+#define MEDIA_THDMEDIASOURCE_H_
+
+#include "MediaSource.h"
+#include "DataSource.h"
+#include "MediaBufferGroup.h"
+#include "MetaData.h"
+#include "audio_mediasource.h"
+
+#define TRUEHDSYNC 0xf8726fba //main sync header
+#define MAX_AUSIZE 4000 //max access unit size
+#define MIN_AUSIZE 6 //min access unit size
+
+typedef unsigned char uchar;
+typedef unsigned short ushort;
+typedef unsigned int uint;
+
+
+
+namespace android
+{
+
+typedef int (*fp_read_buffer)(unsigned char *, int);
+
+class THD_MediaSource : public AudioMediaSource
+{
+public:
+ THD_MediaSource(void *read_buffer);
+
+ status_t start(MetaData *params = NULL);
+ status_t stop();
+ sp<MetaData> getFormat();
+ status_t read(MediaBuffer **buffer, const ReadOptions *options = NULL);
+
+ int GetReadedBytes();
+ int GetSampleRate();
+ int GetChNum();
+ int* Get_pStop_ReadBuf_Flag();
+ int Set_pStop_ReadBuf_Flag(int *pStop);
+
+ int SetReadedBytes(int size);
+ int MediaSourceRead_buffer(unsigned char *buffer, int size);
+
+ fp_read_buffer fpread_buffer;
+
+ int StreamAnalysis(char *buffer);
+
+ int sample_rate;
+ int ChNum;
+ int frame_size;
+ int64_t bytes_readed_sum_pre;
+ int64_t bytes_readed_sum;
+ int* pStop_ReadBuf_Flag;
+
+protected:
+ virtual ~THD_MediaSource();
+
+private:
+ bool mStarted;
+ sp<DataSource> mDataSource;
+ sp<MetaData> mMeta;
+ MediaBufferGroup *mGroup;
+ int64_t mCurrentTimeUs;
+ int mBytesReaded;
+ bool mSyncMain;
+
+ THD_MediaSource(const THD_MediaSource &);
+ THD_MediaSource &operator=(const THD_MediaSource &);
+};
+
+
+}
+
+#endif
diff --git a/amadec/omx_audio/Vorbis_mediasource.cpp b/amadec/omx_audio/Vorbis_mediasource.cpp
new file mode 100755
index 0000000..f74bc15
--- a/dev/null
+++ b/amadec/omx_audio/Vorbis_mediasource.cpp
@@ -0,0 +1,245 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <android/log.h>
+#include <cutils/properties.h>
+#include "Vorbis_mediasource.h"
+#include "audio-dec.h"
+
+
+#define LOG_TAG "Vorbis_Medissource"
+#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
+extern "C" int read_buffer(unsigned char *buffer, int size);
+namespace android
+{
+
+Vorbis_MediaSource::Vorbis_MediaSource(void *read_buffer, aml_audio_dec_t *audec)
+{
+ ALOGI("%s %d \n", __FUNCTION__, __LINE__);
+
+ mStarted = false;
+ mMeta = new MetaData;
+ mDataSource = NULL;
+ mGroup = NULL;
+ mBytesReaded = 0;
+ mCurrentTimeUs = 0;
+ pStop_ReadBuf_Flag = NULL;
+ fpread_buffer = (fp_read_buffer)read_buffer;
+ sample_rate = audec->samplerate;
+ ChNum = audec->channels > 2 ? 2 : audec->channels;
+ bytes_readed_sum_pre = 0;
+ bytes_readed_sum = 0;
+ FrameNumReaded = 0;
+ packt_size = 0;
+ mMeta->setInt32(kKeyChannelCount, audec->channels > 0 ? audec->channels : 2);
+ mMeta->setInt32(kKeySampleRate, audec->samplerate > 0 ? audec->samplerate : 48000);
+
+}
+
+
+Vorbis_MediaSource::~Vorbis_MediaSource()
+{
+ ALOGI("%s %d \n", __FUNCTION__, __LINE__);
+ if (mStarted) {
+ stop();
+ }
+}
+
+
+int Vorbis_MediaSource::GetSampleRate()
+{
+ return sample_rate;
+}
+
+int Vorbis_MediaSource::GetChNum()
+{
+ return ChNum;
+}
+
+int* Vorbis_MediaSource::Get_pStop_ReadBuf_Flag()
+{
+ return pStop_ReadBuf_Flag;
+}
+
+int Vorbis_MediaSource::Set_pStop_ReadBuf_Flag(int *pStop)
+{
+ pStop_ReadBuf_Flag = pStop;
+ return 0;
+}
+
+int Vorbis_MediaSource::GetReadedBytes()
+{
+ if (1/*FrameNumReaded<2*/) {
+ int bytes_used;
+ bytes_used = bytes_readed_sum - bytes_readed_sum_pre;
+ if (bytes_used < 0) {
+ ALOGI("[%s]bytes_readed_sum(%lld) < bytes_readed_sum_pre(%lld) \n", __FUNCTION__, bytes_readed_sum, bytes_readed_sum_pre);
+ bytes_used = 0;
+ }
+ bytes_readed_sum_pre = bytes_readed_sum;
+ return bytes_used;
+ } else {
+ return packt_size;
+ }
+}
+
+sp<MetaData> Vorbis_MediaSource::getFormat()
+{
+ ALOGI("%s %d \n", __FUNCTION__, __LINE__);
+ return mMeta;
+}
+
+status_t Vorbis_MediaSource::start(MetaData *params)
+{
+ ALOGI("%s %d \n", __FUNCTION__, __LINE__);
+ mGroup = new MediaBufferGroup;
+ mGroup->add_buffer(new MediaBuffer(8192));
+ mStarted = true;
+ return OK;
+}
+
+status_t Vorbis_MediaSource::stop()
+{
+ ALOGI("%s %d \n", __FUNCTION__, __LINE__);
+ delete mGroup;
+ mGroup = NULL;
+ mStarted = false;
+ return OK;
+}
+
+
+int Vorbis_MediaSource::MediaSourceRead_buffer(unsigned char *buffer, int size)
+{
+ int readcnt = 0;
+ int readsum = 0;
+ if (fpread_buffer != NULL) {
+ int sleep_time = 0;
+ while ((readsum < size) && (*pStop_ReadBuf_Flag == 0)) {
+ readcnt = fpread_buffer(buffer + readsum, size - readsum);
+ if (readcnt < (size - readsum)) {
+ sleep_time++;
+ usleep(10000);
+ }
+ readsum += readcnt;
+ if (sleep_time > 200) { //wait for max 2s to get audio data
+ ALOGE("[%s] Can't get data from audiobuffer,wait for %d ms\n ", __FUNCTION__, sleep_time * 10);
+ return 0;
+ }
+ }
+
+ if (*pStop_ReadBuf_Flag == 1) {
+ ALOGI("[%s] End of Stream: *pStop_ReadBuf_Flag==1\n ", __FUNCTION__);
+ }
+ return readsum;
+ } else {
+ ALOGE("[%s]ERR: fpread_buffer=NULL\n ", __FUNCTION__);
+ return 0;
+ }
+}
+
+static void dump_pcm_bin(char *path, char *buf, int size)
+{
+ FILE *fp = fopen(path, "ab+");
+ if (fp != NULL) {
+ fwrite(buf, 1, size, fp);
+ fclose(fp);
+ }
+}
+
+status_t Vorbis_MediaSource::read(MediaBuffer **out, const ReadOptions *options)
+{
+
+ *out = NULL;
+ int read_bytes_per_time;
+ MediaBuffer *buffer;
+ int byte_readed = 0;
+ status_t err;
+
+ int SyncFlag = 0, readedbytes = 0;
+ int pkt_size = 0;
+ uint8_t ptr_head[4] = {0};
+ int buf_getted = 0;
+ //for android N, need player to insert the numPageSamples at the end of input buffer
+ //android M and before,which is done by OMXCodec itself.
+ int32_t numPageSamples = -1;
+ //android N and later
+#if ANDROID_PLATFORM_SDK_VERSION >= 24
+ int32_t insert_byte = 4;
+#else
+ int32_t insert_byte = 0;
+#endif
+re_read:
+
+ //----------------------------------
+ if (MediaSourceRead_buffer(&ptr_head[0], 4) < 4) {
+ ALOGI("WARNING: fpread_buffer readbytes failed [%s %d]!\n", __FUNCTION__, __LINE__);
+ return ERROR_END_OF_STREAM;
+ }
+
+ while (!SyncFlag) {
+ if (ptr_head[0] == 'H' && ptr_head[1] == 'E' && ptr_head[2] == 'A' && ptr_head[3] == 'D') {
+ SyncFlag = 1;
+ break;
+ }
+ ptr_head[0] = ptr_head[1];
+ ptr_head[1] = ptr_head[2];
+ ptr_head[2] = ptr_head[3];
+ if (MediaSourceRead_buffer(&ptr_head[3], 1) < 1) {
+ ALOGI("WARNING: fpread_buffer readbytes failed [%s %d]!\n", __FUNCTION__, __LINE__);
+ return ERROR_END_OF_STREAM;
+ }
+
+ if (*pStop_ReadBuf_Flag == 1) {
+ ALOGI("Stop_ReadBuf_Flag==1 stop read_buf [%s %d]", __FUNCTION__, __LINE__);
+ return ERROR_END_OF_STREAM;
+ }
+ }
+
+ if (MediaSourceRead_buffer((unsigned char*)(&pkt_size), 4) < 4) {
+ ALOGI("WARNING: fpread_buffer readbytes failed [%s %d]!\n", __FUNCTION__, __LINE__);
+ return ERROR_END_OF_STREAM;
+ }
+
+ if (!buf_getted) {
+ buf_getted = 1;
+ err = mGroup->acquire_buffer(&buffer);
+ if (err != OK) {
+ ALOGE("[%s %d] mGroup->acquire_buffer ERR!\n", __FUNCTION__, __LINE__);
+ return err;
+ }
+ }
+ //mediasource should wait abuf data util player finish it
+ while (MediaSourceRead_buffer((unsigned char*)(buffer->data()), pkt_size) < pkt_size && (*pStop_ReadBuf_Flag == 0)) {
+ ALOGW("WARNING: fpread_buffer readbytes failed [%s %d]!\n", __FUNCTION__, __LINE__);
+ }
+ if (*pStop_ReadBuf_Flag == 1) {
+ buffer->release();
+ buffer = NULL;
+ return ERROR_END_OF_STREAM;
+ }
+
+ if (insert_byte > 0) {
+ buffer->set_range(0, pkt_size + insert_byte);
+ memcpy((unsigned char*)(buffer->data()) + pkt_size, &numPageSamples, sizeof(numPageSamples));
+ }
+ buffer->meta_data()->setInt64(kKeyTime, mCurrentTimeUs);
+ buffer->meta_data()->setInt32(kKeyIsSyncFrame, 1);
+ bytes_readed_sum += (pkt_size + 8);
+ ALOGV("vorbis package size %d,num %d\n", pkt_size, FrameNumReaded);
+ FrameNumReaded++;
+ if (FrameNumReaded == 2) {
+ goto re_read;
+ }
+ if (FrameNumReaded > 3) {
+ packt_size = pkt_size;
+ buffer->meta_data()->setInt32(kKeyValidSamples, -1);
+ }
+ *out = buffer;
+ return OK;
+}
+
+
+} // namespace android
+
+
diff --git a/amadec/omx_audio/Vorbis_mediasource.h b/amadec/omx_audio/Vorbis_mediasource.h
new file mode 100644
index 0000000..f94b133
--- a/dev/null
+++ b/amadec/omx_audio/Vorbis_mediasource.h
@@ -0,0 +1,58 @@
+#ifndef MEDIA_VORBIS_MEDIASOURCE_H_
+#define MEDIA_VORBIS_MEDIASOURCE_H_
+
+#include "MediaSource.h"
+#include "DataSource.h"
+#include "MediaBufferGroup.h"
+#include "MetaData.h"
+#include "audio_mediasource.h"
+#include "audio-dec.h"
+
+namespace android
+{
+
+typedef int (*fp_read_buffer)(unsigned char *, int);
+class Vorbis_MediaSource : public AudioMediaSource
+{
+public:
+ Vorbis_MediaSource(void *read_buffer, aml_audio_dec_t *audec);
+
+ status_t start(MetaData *params = NULL);
+ status_t stop();
+ sp<MetaData> getFormat();
+ status_t read(MediaBuffer **buffer, const ReadOptions *options = NULL);
+
+ int GetReadedBytes();
+ int GetSampleRate();
+ int GetChNum();
+ int* Get_pStop_ReadBuf_Flag();
+ int Set_pStop_ReadBuf_Flag(int *pStop);
+ int MediaSourceRead_buffer(unsigned char *buffer, int size);
+
+ fp_read_buffer fpread_buffer;
+ int sample_rate;
+ int ChNum;
+ int packt_size;
+ int *pStop_ReadBuf_Flag;
+ int64_t bytes_readed_sum_pre;
+ int64_t bytes_readed_sum;
+ int FrameNumReaded;
+protected:
+ virtual ~Vorbis_MediaSource();
+private:
+ bool mStarted;
+ sp<DataSource> mDataSource;
+ sp<MetaData> mMeta;
+ MediaBufferGroup *mGroup;
+ int64_t mCurrentTimeUs;
+ int mBytesReaded;
+ int block_align;
+ Vorbis_MediaSource(const Vorbis_MediaSource &);
+ Vorbis_MediaSource &operator=(const Vorbis_MediaSource &);
+};
+
+
+}
+
+#endif
+
diff --git a/amadec/omx_audio/adec_omx.cpp b/amadec/omx_audio/adec_omx.cpp
new file mode 100644
index 0000000..ccde626
--- a/dev/null
+++ b/amadec/omx_audio/adec_omx.cpp
@@ -0,0 +1,421 @@
+/*
+interface to call OMX codec
+*/
+
+#include <media/stagefright/MediaBuffer.h>
+#include <media/stagefright/SimpleDecodingSource.h>
+#include "../adec_omx_brige.h"
+#include "adec_omx.h"
+#include "audio_mediasource.h"
+#include "DDP_mediasource.h"
+#include "ALAC_mediasource.h"
+#include "MP3_mediasource.h"
+#include "ASF_mediasource.h"
+#include "DTSHD_mediasource.h"
+#include "Vorbis_mediasource.h"
+#include "THD_mediasource.h"
+#include <android/log.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <cutils/properties.h>
+#include <Amsysfsutils.h>
+#define LOG_TAG "Adec_OMX"
+#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
+
+namespace android {
+
+//#####################################################
+
+AmlOMXCodec::AmlOMXCodec(int codec_type,void *read_buffer,int *exit,aml_audio_dec_t *audec)
+{
+ m_codec=NULL;
+ status_t m_OMXClientConnectStatus=m_OMXClient.connect();
+ lock_init();
+ locked();
+ buf_decode_offset=0;
+ buf_decode_offset_pre=0;
+ if(m_OMXClientConnectStatus != OK){
+ LOGE("Err:omx client connect error\n");
+ }else{
+ const char *mine_type=NULL;
+ audec->data_width=AV_SAMPLE_FMT_S16;
+ omx_codec_type=0;
+ if(audec->channels>0){
+ audec->channels=(audec->channels>2? 2:audec->channels);
+ audec->adec_ops->channels=audec->channels;
+ }else
+ audec->adec_ops->channels=audec->channels=2;
+
+ if(audec->samplerate>0)
+ audec->adec_ops->samplerate=audec->samplerate;
+ else
+ audec->adec_ops->samplerate=audec->samplerate=48000;
+
+ LOGI("Data_width:%d Samplerate:%d Channel:%d \n",audec->data_width,audec->samplerate,audec->channels);
+
+ if(codec_type==OMX_ENABLE_CODEC_AC3)
+ {
+ mine_type=MEDIA_MIMETYPE_AUDIO_AC3;
+ m_OMXMediaSource = new DDP_MediaSource(read_buffer);
+ }
+ else if(codec_type==OMX_ENABLE_CODEC_EAC3)
+ {
+ mine_type=MEDIA_MIMETYPE_AUDIO_EC3;
+ m_OMXMediaSource = new DDP_MediaSource(read_buffer);
+ }
+ else if(codec_type==OMX_ENABLE_CODEC_ALAC)
+ {
+ mine_type=MEDIA_MIMETYPE_AUDIO_ALAC;
+ m_OMXMediaSource = new ALAC_MediaSource(read_buffer,audec);
+ }
+ else if(codec_type==OMX_ENABLE_CODEC_MPEG_LAYER_II)
+ {
+ mine_type=MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_II;
+ //mine_type=MEDIA_MIMETYPE_AUDIO_MPEG;
+ m_OMXMediaSource = new MP3_MediaSource(read_buffer,audec,exit);
+ }else if(codec_type==OMX_ENABLE_CODEC_WMA){
+ mine_type=MEDIA_MIMETYPE_AUDIO_WMA;
+ m_OMXMediaSource = new Asf_MediaSource(read_buffer,audec);
+ }else if(codec_type==OMX_ENABLE_CODEC_WMAPRO){
+ mine_type=MEDIA_MIMETYPE_AUDIO_WMAPRO;
+ m_OMXMediaSource = new Asf_MediaSource(read_buffer,audec);
+ }else if(codec_type==OMX_ENABLE_CODEC_DTSHD){
+ mine_type=MEDIA_MIMETYPE_AUDIO_DTSHD;
+ m_OMXMediaSource = new Dtshd_MediaSource(read_buffer);
+ }else if(codec_type==OMX_ENABLE_CODEC_VORBIS){
+ mine_type=MEDIA_MIMETYPE_AUDIO_VORBIS;
+ m_OMXMediaSource=new Vorbis_MediaSource(read_buffer,audec);
+ }else if(codec_type == OMX_ENABLE_CODEC_TRUEHD){
+ mine_type = MEDIA_MIMETYPE_AUDIO_TRUEHD;
+ m_OMXMediaSource = new THD_MediaSource(read_buffer);
+ }else if(codec_type==OMX_ENABLE_CODEC_WMAVOI){
+ mine_type=MEDIA_MIMETYPE_AUDIO_FFMPEG;
+ m_OMXMediaSource = new Asf_MediaSource(read_buffer,audec);
+ }
+ omx_codec_type=codec_type;
+ LOGI("mine_type=%s %s %d \n",mine_type,__FUNCTION__,__LINE__);
+
+ m_OMXMediaSource->Set_pStop_ReadBuf_Flag(exit);
+
+ sp<MetaData> metadata = m_OMXMediaSource->getFormat();
+ metadata->setCString(kKeyMIMEType,mine_type);
+
+ m_codec = SimpleDecodingSource::Create(
+ m_OMXMediaSource,
+ 0,
+ 0);
+
+ if (m_codec != NULL)
+ {
+ LOGI("OMXCodec::Create success %s %d \n",__FUNCTION__,__LINE__);
+ }else{
+ LOGE("Err: OMXCodec::Create failed %s %d \n",__FUNCTION__,__LINE__);
+ }
+ }
+ unlocked();
+}
+
+
+AmlOMXCodec::~AmlOMXCodec()
+{
+
+ m_OMXMediaSource=NULL;
+ m_codec=NULL;
+}
+
+
+status_t AmlOMXCodec::read(unsigned char *buf,unsigned *size,int *exit)
+{
+ if (m_codec == NULL) {
+ LOGE("m_codec==NULL %s %d failed!\n",__FUNCTION__,__LINE__);
+ return !OK;
+ }
+ MediaBuffer *srcBuffer;
+ status_t status;
+ m_OMXMediaSource->Set_pStop_ReadBuf_Flag(exit);
+
+ if(*exit)
+ {
+ LOGI("NOTE:exit flag enabled! [%s %d] \n",__FUNCTION__,__LINE__);
+ *size=0;
+ return OK;
+ }
+
+ status= m_codec->read(&srcBuffer,NULL);
+
+ if(srcBuffer==NULL)
+ {
+ if (status == INFO_FORMAT_CHANGED) {
+ ALOGI("format changed \n");
+ }
+ *size=0;
+ return OK;
+ }
+ if(*size>srcBuffer->range_length()) //surpose buf is large enough
+ *size=srcBuffer->range_length();
+ if(status == OK && (*size!=0) ){
+ memcpy(buf, (void*)((unsigned long)srcBuffer->data() + srcBuffer->range_offset()), *size);
+ srcBuffer->set_range(srcBuffer->range_offset() + (*size),srcBuffer->range_length() - (*size));
+ srcBuffer->meta_data()->findInt64(kKeyTime, &buf_decode_offset);
+ }
+
+ if (srcBuffer->range_length() == 0) {
+ srcBuffer->release();
+ srcBuffer = NULL;
+ }
+ return OK;
+}
+
+status_t AmlOMXCodec::start(aml_audio_dec_t *audec)
+{
+ LOGI("[%s %d] \n",__FUNCTION__,__LINE__);
+ if (m_codec == NULL) {
+ LOGE("m_codec==NULL %s %d failed!\n",__FUNCTION__,__LINE__);
+ return !OK;
+ }
+ status_t status = m_codec->start();
+ if(omx_codec_type==OMX_ENABLE_CODEC_AC3 ||omx_codec_type==OMX_ENABLE_CODEC_EAC3 \
+ || omx_codec_type==OMX_ENABLE_CODEC_DTSHD || omx_codec_type== OMX_ENABLE_CODEC_TRUEHD){
+ android::sp<android::MetaData> output_format=m_codec->getFormat();
+ int enable_flag = 0;
+ output_format->findInt32(android::kKeyAudioFlag, &enable_flag);
+ LOGI("dts/dolby audio enable flag %d \n",enable_flag);
+ audec->audio_decoder_enabled = enable_flag;
+ }
+ if (status != OK)
+ {
+ LOGE("Err:OMX client can't start OMX decoder?! status=%d (0x%08x)\n", (int)status, (int)status);
+ m_codec = NULL;
+ }
+ return status;
+}
+
+void AmlOMXCodec::stop()
+{
+ LOGI("[%s %d] enter \n",__FUNCTION__,__LINE__);
+ if(m_codec != NULL){
+ if(m_OMXMediaSource->Get_pStop_ReadBuf_Flag())
+ *m_OMXMediaSource->Get_pStop_ReadBuf_Flag()=1;
+ m_codec->pause();
+ m_codec->stop();
+ wp<MediaSource> tmp = m_codec;
+ m_codec.clear();
+ while (tmp.promote() != NULL) {
+ LOGI("[%s %d]wait m_codec free OK!\n",__FUNCTION__,__LINE__);
+ usleep(1000);
+ }
+
+ //m_OMXMediaSource->stop();//stop in omxcodec
+ m_OMXClient.disconnect();
+ m_OMXMediaSource=NULL;
+ m_codec=NULL;
+ }else
+ LOGE("m_codec==NULL m_codec->stop() failed! %s %d \n",__FUNCTION__,__LINE__);
+}
+
+void AmlOMXCodec::pause()
+{
+ LOGI("[%s %d] \n",__FUNCTION__,__LINE__);
+ if(m_codec != NULL)
+ m_codec->pause();
+ else
+ LOGE("m_codec==NULL m_codec->pause() failed! %s %d \n",__FUNCTION__,__LINE__);
+}
+
+int AmlOMXCodec::GetDecBytes()
+{
+ int used_len=0;
+
+ if (omx_codec_type == OMX_ENABLE_CODEC_AC3 || omx_codec_type == OMX_ENABLE_CODEC_EAC3)
+ {
+ used_len += m_OMXMediaSource->GetReadedBytes();
+ }
+
+ if(omx_codec_type==OMX_ENABLE_CODEC_AC3 ||omx_codec_type==OMX_ENABLE_CODEC_EAC3|| omx_codec_type==OMX_ENABLE_CODEC_DTSHD)
+ {
+ used_len += (buf_decode_offset - buf_decode_offset_pre);
+ buf_decode_offset_pre=buf_decode_offset;
+ return used_len;
+ }else{
+ return m_OMXMediaSource->GetReadedBytes();
+ }
+}
+
+void AmlOMXCodec::lock_init()
+{
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
+ pthread_mutex_init(&lock, &attr);
+ pthread_mutexattr_destroy(&attr);
+}
+void AmlOMXCodec::locked()
+{
+ pthread_mutex_lock(&lock);
+}
+void AmlOMXCodec::unlocked()
+{
+ pthread_mutex_unlock(&lock);
+}
+
+}; // namespace android
+
+//#####################################################
+extern "C"
+{
+
+android::AmlOMXCodec *arm_omx_codec=NULL;
+
+void arm_omx_codec_init(aml_audio_dec_t *audec,int codec_type,void *readbuffer,int *exit)
+{
+ char value[128]={0};
+ int ret=0;
+ android::AmlOMXCodec *arm_omx_codec=NULL;
+ amsysfs_write_prop("media.libplayer.dtsopt0", "1");
+ LOGI("property_set<media.libplayer.dtsopt0> ret/%d\n",ret);
+ arm_omx_codec=new android::AmlOMXCodec(codec_type,readbuffer,exit,audec);
+ if(arm_omx_codec==NULL){
+ property_set("media.libplayer.dtsopt0", "0");
+ LOGE("Err:arm_omx_codec_init failed\n");
+ }
+ if(property_get("media.libplayer.dtsopt0",value,NULL) > 0)
+ {
+ LOGI("[%s %d] media.libplayer.dtsopt0/%s \n",__FUNCTION__,__LINE__,value);
+ }else{
+ LOGE("[%s %d] property_set<media.libplayer.dtsopt0> failed\n",__FUNCTION__,__LINE__);
+ }
+ LOGI("[%s %d] arm_omx_codec=%p \n",__FUNCTION__,__LINE__,arm_omx_codec);
+ audec->arm_omx_codec=arm_omx_codec;
+}
+
+void arm_omx_codec_start(aml_audio_dec_t *audec)
+{
+ android::AmlOMXCodec *arm_omx_codec=(android::AmlOMXCodec *)(audec->arm_omx_codec);
+ if(arm_omx_codec!=NULL){
+ arm_omx_codec->locked();
+ arm_omx_codec->start(audec);
+ arm_omx_codec->unlocked();
+ }else
+ LOGE("arm_omx_codec==NULL arm_omx_codec->start failed! %s %d \n",__FUNCTION__,__LINE__);
+}
+
+void arm_omx_codec_pause(aml_audio_dec_t *audec)
+{
+ android::AmlOMXCodec *arm_omx_codec=(android::AmlOMXCodec *)(audec->arm_omx_codec);
+ if(arm_omx_codec!=NULL){
+ arm_omx_codec->locked();
+ arm_omx_codec->pause();
+ arm_omx_codec->unlocked();
+ }else
+ LOGE("arm_omx_codec==NULL arm_omx_codec->pause failed! %s %d \n",__FUNCTION__,__LINE__);
+}
+
+void arm_omx_codec_read(aml_audio_dec_t *audec,unsigned char *buf,unsigned *size,int *exit)
+{
+ android::AmlOMXCodec *arm_omx_codec=(android::AmlOMXCodec *)(audec->arm_omx_codec);
+ if(arm_omx_codec!=NULL){
+ arm_omx_codec->locked();
+ arm_omx_codec->read(buf,size,exit);
+ arm_omx_codec->unlocked();
+ }else
+ LOGE("arm_omx_codec==NULL arm_omx_codec->read failed! %s %d \n",__FUNCTION__,__LINE__);
+}
+
+void arm_omx_codec_close(aml_audio_dec_t *audec)
+{
+ int ret=0;
+ char value[128]={0};
+ android::AmlOMXCodec *arm_omx_codec=(android::AmlOMXCodec *)(audec->arm_omx_codec);
+ amsysfs_write_prop("media.libplayer.dtsopt0", "0");
+ LOGI("property_set<media.libplayer.dtsopt0> ret/%d\n",ret);
+ if(arm_omx_codec!=NULL){
+ arm_omx_codec->locked();
+ arm_omx_codec->stop();
+ arm_omx_codec->unlocked();
+ delete arm_omx_codec;
+ arm_omx_codec=NULL;
+ }else{
+ LOGI("NOTE:arm_omx_codec==NULL arm_omx_codec_close() do nothing! %s %d \n",__FUNCTION__,__LINE__);
+ }
+ if(property_get("media.libplayer.dtsopt0",value,NULL) > 0)
+ {
+ LOGI("[%s %d] media.libplayer.dtsopt0/%s \n",__FUNCTION__,__LINE__,value);
+ }else{
+ LOGE("[%s %d] property_set<media.libplayer.dtsopt0> failed\n",__FUNCTION__,__LINE__);
+ }
+}
+
+int arm_omx_codec_get_declen(aml_audio_dec_t *audec)
+{
+ int declen=0;
+ android::AmlOMXCodec *arm_omx_codec=(android::AmlOMXCodec *)(audec->arm_omx_codec);
+ if(arm_omx_codec!=NULL){
+ arm_omx_codec->locked();
+ declen=arm_omx_codec->GetDecBytes();
+ arm_omx_codec->unlocked();
+ }else{
+ LOGI("NOTE:arm_omx_codec==NULL arm_omx_codec_get_declen() return 0! %s %d \n",__FUNCTION__,__LINE__);
+ }
+
+ return declen;
+
+}
+
+#define DTSETC_DECODE_VERSION_CORE 350
+#define DTSETC_DECODE_VERSION_M6_M8 380
+int arm_omx_codec_get_FS(aml_audio_dec_t *audec)
+{
+ android::AmlOMXCodec *arm_omx_codec=(android::AmlOMXCodec *)(audec->arm_omx_codec);
+ if(arm_omx_codec!=NULL){
+ arm_omx_codec->locked();
+ if(arm_omx_codec->omx_codec_type==OMX_ENABLE_CODEC_DTSHD){
+ int sampleRate=0;
+ android::sp<android::MetaData> output_format=arm_omx_codec->m_codec->getFormat();
+ output_format->findInt32(android::kKeySampleRate, &sampleRate);
+ if (audec->VersionNum == -1 || (audec->VersionNum == DTSETC_DECODE_VERSION_M6_M8 && audec->DTSHDIEC958_FS == 0) )
+ {
+ output_format->findInt32(android::kKeyDtsDecoderVer,&audec->VersionNum);
+ output_format->findInt32(android::kKeyDts958Fs,&audec->DTSHDIEC958_FS);
+ output_format->findInt32(android::kKeyDts958PktSize,&audec->DTSHDIEC958_PktFrmSize);
+ output_format->findInt32(android::kKeyDts958PktType,&audec->DTSHDIEC958_PktType);
+ output_format->findInt32(android::kKeyDtsPcmSampsInFrmMaxFs,&audec->DTSHDPCM_SamsInFrmAtMaxSR);
+ }
+ arm_omx_codec->unlocked();
+ arm_omx_codec->m_OMXMediaSource->SetSampleRate(sampleRate);
+ return sampleRate;
+ }else{
+ arm_omx_codec->unlocked();
+ return arm_omx_codec->m_OMXMediaSource->GetSampleRate();
+ }
+ }else{
+ LOGI("NOTE:arm_omx_codec==NULL arm_omx_codec_get_FS() return 0! %s %d \n",__FUNCTION__,__LINE__);
+ return 0;
+ }
+}
+
+int arm_omx_codec_get_Nch(aml_audio_dec_t *audec)
+{
+ android::AmlOMXCodec *arm_omx_codec=(android::AmlOMXCodec *)(audec->arm_omx_codec);
+ if(arm_omx_codec!=NULL){
+ arm_omx_codec->locked();
+ if(arm_omx_codec->omx_codec_type==OMX_ENABLE_CODEC_DTSHD){
+ int numChannels=0;
+ android::sp<android::MetaData> output_format=arm_omx_codec->m_codec->getFormat();
+ output_format->findInt32(android::kKeyChannelCount, &numChannels);
+ arm_omx_codec->unlocked();
+ return numChannels;
+ }else{
+ arm_omx_codec->unlocked();
+ audec->adec_ops->NchOriginal =arm_omx_codec->m_OMXMediaSource->GetChNumOriginal();
+ return arm_omx_codec->m_OMXMediaSource->GetChNum();
+ }
+ }else{
+ LOGI("NOTE:arm_omx_codec==NULL arm_omx_codec_get_Nch() return 0! %s %d \n",__FUNCTION__,__LINE__);
+ return 0;
+ }
+}
+
+
+} // namespace android
diff --git a/amadec/omx_audio/adec_omx.h b/amadec/omx_audio/adec_omx.h
new file mode 100644
index 0000000..4812073
--- a/dev/null
+++ b/amadec/omx_audio/adec_omx.h
@@ -0,0 +1,71 @@
+#ifndef MEDIA_ADECOMX_H_
+#define MEDIA_ADECOMX_H_
+
+#include "OMX_Index.h"
+#include "OMX_Core.h"
+#include "OMXClient.h"
+#include "audio_mediasource.h"
+#include "../audio-dec.h"
+
+namespace android
+{
+
+static const char *MEDIA_MIMETYPE_AUDIO_AC3 = "audio/ac3";
+static const char *MEDIA_MIMETYPE_AUDIO_EC3 = "audio/eac3";
+static const char *MEDIA_MIMETYPE_AUDIO_AMR_NB = "audio/3gpp";
+static const char *MEDIA_MIMETYPE_AUDIO_AMR_WB = "audio/amr-wb";
+static const char *MEDIA_MIMETYPE_AUDIO_MPEG = "audio/mpeg"; //mp3
+static const char *MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_I = "audio/mpeg-L1";
+static const char *MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_II = "audio/mpeg-L2";
+static const char *MEDIA_MIMETYPE_AUDIO_AAC = "audio/mp4a-latm";
+static const char *MEDIA_MIMETYPE_AUDIO_QCELP = "audio/qcelp";
+static const char *MEDIA_MIMETYPE_AUDIO_VORBIS = "audio/vorbis";
+static const char *MEDIA_MIMETYPE_AUDIO_G711_ALAW = "audio/g711-alaw";
+static const char *MEDIA_MIMETYPE_AUDIO_G711_MLAW = "audio/g711-mlaw";
+static const char *MEDIA_MIMETYPE_AUDIO_RAW = "audio/raw";
+static const char *MEDIA_MIMETYPE_AUDIO_ADPCM_IMA = "audio/adpcm-ima";
+static const char *MEDIA_MIMETYPE_AUDIO_ADPCM_MS = "audio/adpcm-ms";
+static const char *MEDIA_MIMETYPE_AUDIO_FLAC = "audio/flac";
+static const char *MEDIA_MIMETYPE_AUDIO_AAC_ADTS = "audio/aac-adts";
+static const char *MEDIA_MIMETYPE_AUDIO_ALAC = "audio/alac";
+static const char *MEDIA_MIMETYPE_AUDIO_AAC_ADIF = "audio/aac-adif";
+static const char *MEDIA_MIMETYPE_AUDIO_AAC_LATM = "audio/aac-latm";
+static const char *MEDIA_MIMETYPE_AUDIO_ADTS_PROFILE = "audio/adts";
+static const char *MEDIA_MIMETYPE_AUDIO_WMA = "audio/wma";
+static const char *MEDIA_MIMETYPE_AUDIO_WMAPRO = "audio/wmapro";
+static const char *MEDIA_MIMETYPE_AUDIO_DTSHD = "audio/dtshd";
+static const char *MEDIA_MIMETYPE_AUDIO_TRUEHD = "audio/truehd";
+static const char *MEDIA_MIMETYPE_AUDIO_FFMPEG = "audio/ffmpeg";
+
+class AmlOMXCodec
+{
+public:
+
+ AmlOMXCodec(int codec_type, void *read_buffer, int *exit, aml_audio_dec *audec);
+
+ OMXClient m_OMXClient;
+ sp<AudioMediaSource> m_OMXMediaSource;
+ int read(unsigned char *buf, unsigned *size, int *exit);
+ virtual status_t start(aml_audio_dec_t *audec);
+ void pause();
+ void stop();
+ int GetDecBytes();
+ void lock_init();
+ void locked();
+ void unlocked();
+ int started_flag;
+ int omx_codec_type;
+ //protected:
+ virtual ~AmlOMXCodec();
+ //private:
+ sp<MediaSource> m_codec;
+ pthread_mutex_t lock;
+ int64_t buf_decode_offset;
+ int64_t buf_decode_offset_pre;
+
+};
+
+
+}
+
+#endif
diff --git a/amadec/omx_audio/audio_mediasource.cpp b/amadec/omx_audio/audio_mediasource.cpp
new file mode 100755
index 0000000..16333ac
--- a/dev/null
+++ b/amadec/omx_audio/audio_mediasource.cpp
@@ -0,0 +1,37 @@
+/*
+add a mediasource interface just like stagefright player
+for the input port data feed of OMX decoder
+author: jian.xu@amlogic.com
+27/2/2013
+*/
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <android/log.h>
+#include <cutils/properties.h>
+
+#include "audio_mediasource.h"
+
+extern "C" int read_buffer(unsigned char *buffer,int size);
+
+#define LOG_TAG "Audio_Medissource"
+#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
+
+namespace android {
+
+AudioMediaSource::AudioMediaSource()
+{
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+}
+
+
+AudioMediaSource::~AudioMediaSource()
+{
+ ALOGI("%s %d \n",__FUNCTION__,__LINE__);
+}
+
+
+} // namespace android
+
diff --git a/amadec/omx_audio/audio_mediasource.h b/amadec/omx_audio/audio_mediasource.h
new file mode 100644
index 0000000..957f843
--- a/dev/null
+++ b/amadec/omx_audio/audio_mediasource.h
@@ -0,0 +1,46 @@
+#ifndef OMX_AUDIOMEDIASOURCE_H_
+#define OMX_AUDIOMEDIASOURCE_H_
+
+#include "MediaSource.h"
+#include "DataSource.h"
+#include "MediaBufferGroup.h"
+#include "MetaData.h"
+
+namespace android
+{
+
+class AudioMediaSource : public MediaSource
+{
+public:
+ virtual status_t start(MetaData *params = NULL) = 0;
+ virtual status_t stop() = 0;
+ virtual sp<MetaData> getFormat() = 0;
+ virtual status_t read(MediaBuffer **buffer, const ReadOptions *options = NULL) = 0;
+
+ virtual int GetReadedBytes() = 0;
+ virtual int GetSampleRate() = 0;
+ virtual int SetSampleRate(int sample_rate){
+ return 0;
+ };
+ virtual int GetChNum() = 0;
+ virtual int GetChNumOriginal() {
+ return 0;
+ };
+ virtual int* Get_pStop_ReadBuf_Flag() = 0;
+ virtual int Set_pStop_ReadBuf_Flag(int *pStop) = 0;
+
+protected:
+
+ AudioMediaSource();
+ virtual ~AudioMediaSource();
+
+private:
+
+ AudioMediaSource(const AudioMediaSource &);
+ AudioMediaSource &operator=(const AudioMediaSource &);
+};
+
+
+}
+
+#endif
diff --git a/amadec/omx_audio/audio_medissource.h b/amadec/omx_audio/audio_medissource.h
new file mode 100644
index 0000000..35cf23b
--- a/dev/null
+++ b/amadec/omx_audio/audio_medissource.h
@@ -0,0 +1,137 @@
+
+/*
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/DataSource.h>
+#include <media/stagefright/MediaBufferGroup.h>
+#include <media/stagefright/MediaDefs.h>
+#include <media/stagefright/MediaErrors.h>
+#include <media/stagefright/MediaSource.h>
+#include <media/stagefright/MetaData.h>
+#include <utils/String8.h>
+#include <cutils/bitops.h>
+*/
+#include "MediaSource.h"
+#include "DataSource.h"
+#include "MediaBufferGroup.h"
+#include "MetaData.h"
+namespace android
+{
+
+
+#define DSPshort short
+#define DSPerr short
+#define DSPushort unsigned short /*!< DSP unsigned integer */
+#define GBL_BYTESPERWRD 2 /*!< Bytes per packed word */
+#define GBL_BITSPERWRD (GBL_BYTESPERWRD*8) /*!< Bytes per packed word */
+#define GBL_SYNCWRD ((DSPshort)0x0b77) /*!< AC-3 frame sync word */
+#define GBL_MAXFSCOD 3 /*!< Number of defined sample rates */
+#define GBL_MAXDDDATARATE 38 /*!< Number of defined data rates */
+#define BSI_BSID_STD 8 /*!< Standard ATSC A/52 bit-stream ID */
+#define BSI_ISDD(bsid) ((bsid) <= BSI_BSID_STD)
+#define GBL_MAXCHANCFGS 8 /*!< Maximum number of channel configs */
+#define BSI_BSID_AXE 16 /*!< Annex E bitstream ID */
+#define BSI_ISDDP(bsid) ((bsid) <= BSI_BSID_AXE && (bsid) > 10)
+#define BSI_BSID_BITOFFSET 40 /*!< Used to skip ahead to bit-stream ID */
+#define PTR_HEAD_SIZE 20
+
+
+/*! \brief Bit Stream Operations module decode-side state variable structure */
+typedef struct {
+ DSPshort *p_pkbuf; /*!< Pointer to bitstream buffer */
+ DSPshort pkbitptr; /*!< Bit count within bitstream word */
+ DSPshort pkdata; /*!< Current bitstream word */
+#if defined(DEBUG)
+ const DSPshort *p_start_pkbuf; /*!< Pointer to beginning of bitstream buffer */
+#endif /* defined(DEBUG) */
+} BSOD_BSTRM;
+
+
+const DSPshort gbl_chanary[GBL_MAXCHANCFGS] = { 2, 1, 2, 3, 3, 4, 4, 5 };
+/* audio coding modes */
+enum { GBL_MODE11 = 0, GBL_MODE_RSVD = 0, GBL_MODE10, GBL_MODE20,
+ GBL_MODE30, GBL_MODE21, GBL_MODE31, GBL_MODE22, GBL_MODE32
+ };
+
+const DSPushort gbl_msktab[] = {
+ 0x0000, 0x8000, 0xc000, 0xe000,
+ 0xf000, 0xf800, 0xfc00, 0xfe00,
+ 0xff00, 0xff80, 0xffc0, 0xffe0,
+ 0xfff0, 0xfff8, 0xfffc, 0xfffe, 0xffff
+};
+
+
+/*! Words per frame table based on sample rate and data rate codes */
+const DSPshort gbl_frmsizetab[GBL_MAXFSCOD][GBL_MAXDDDATARATE] = {
+ /* 48kHz */
+ {
+ 64, 64, 80, 80, 96, 96, 112, 112,
+ 128, 128, 160, 160, 192, 192, 224, 224,
+ 256, 256, 320, 320, 384, 384, 448, 448,
+ 512, 512, 640, 640, 768, 768, 896, 896,
+ 1024, 1024, 1152, 1152, 1280, 1280
+ },
+ /* 44.1kHz */
+ {
+ 69, 70, 87, 88, 104, 105, 121, 122,
+ 139, 140, 174, 175, 208, 209, 243, 244,
+ 278, 279, 348, 349, 417, 418, 487, 488,
+ 557, 558, 696, 697, 835, 836, 975, 976,
+ 1114, 1115, 1253, 1254, 1393, 1394
+ },
+ /* 32kHz */
+ {
+ 96, 96, 120, 120, 144, 144, 168, 168,
+ 192, 192, 240, 240, 288, 288, 336, 336,
+ 384, 384, 480, 480, 576, 576, 672, 672,
+ 768, 768, 960, 960, 1152, 1152, 1344, 1344,
+ 1536, 1536, 1728, 1728, 1920, 1920
+ }
+};
+
+
+
+typedef int (*fp_read_buffer)(unsigned char *, int);
+struct AudioMediaSource : public MediaSource {
+ AudioMediaSource(void *read_buffer);
+ virtual status_t start(MetaData *params = NULL);
+ virtual status_t stop();
+ virtual sp<MetaData> getFormat();
+ virtual status_t read(MediaBuffer **buffer, const ReadOptions *options = NULL);
+ int GetReadedBytes();
+ int SetReadedBytes(int size);
+ int MediaSourceRead_buffer(unsigned char *buffer, int size);
+ fp_read_buffer fpread_buffer;
+
+ //----------------------------------------
+ DSPerr bsod_init(DSPshort * p_pkbuf, DSPshort pkbitptr, BSOD_BSTRM *p_bstrm);
+ DSPerr bsod_unprj(BSOD_BSTRM *p_bstrm, DSPshort *p_data, DSPshort numbits);
+ int Get_ChNum_DD(void *buf);
+ int Get_ChNum_DDP(void *buf);
+ DSPerr bsod_skip(BSOD_BSTRM *p_bstrm, DSPshort numbits);
+ DSPerr bsid_getbsid(BSOD_BSTRM *p_inbstrm, DSPshort *p_bsid);
+ int Get_ChNum_AC3_Frame(void *buf);
+ //---------------------------------------
+
+ int sample_rate;
+ int ChNum;
+ int frame_size;
+ int64_t bytes_readed_sum_pre;
+ int64_t bytes_readed_sum;
+ int *pStop_ReadBuf_Flag;
+protected:
+ virtual ~AudioMediaSource();
+
+private:
+ bool mStarted;
+ sp<DataSource> mDataSource;
+ sp<MetaData> mMeta;
+ MediaBufferGroup *mGroup;
+ int64_t mCurrentTimeUs;
+ int mBytesReaded;
+
+ AudioMediaSource(const AudioMediaSource &);
+ AudioMediaSource &operator=(const AudioMediaSource &);
+};
+
+
+}
diff --git a/amadec/pcmenc_api.c b/amadec/pcmenc_api.c
new file mode 100644
index 0000000..09c3626
--- a/dev/null
+++ b/amadec/pcmenc_api.c
@@ -0,0 +1,147 @@
+/*************************************************************************************
+ * @file pcmenc_api.c
+ * @brief
+ *
+ * Detailed description starts here.
+ *
+ * @author jian.xu, jian.xu@amlogic.com
+ *
+ * @internal
+ * Created 20124-26
+ * Revision v1.0
+ * Compiler gcc/g++
+ * Company Amlogic Inc.
+ * Copyright Copyright (c) 2011, herbert.hu
+ *
+ * This source code is released for free distribution under the terms of the
+ * GNU General Public License as published by the Free Software Foundation.
+ *************************************************************************************
+ */
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <signal.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/mman.h>
+#include "pcmenc_api.h"
+#define AUDIODSP_PCMENC_DEV_NAME "/dev/audiodsp_pcmenc"
+
+static char *map_buf = (void *)-1L;
+static unsigned read_offset = 0;
+static unsigned buffer_size = 0;
+static int dev_fd = -1;
+#include <log-print.h>
+int pcmenc_init()
+{
+ buffer_size = 0;
+ read_offset = 0;
+ dev_fd = -1;
+ dev_fd = open(AUDIODSP_PCMENC_DEV_NAME, O_RDONLY);
+ if (dev_fd < 0) {
+ //printf("can not open %s\n", AUDIODSP_PCMENC_DEV_NAME);
+ adec_print("can not open %s\n", AUDIODSP_PCMENC_DEV_NAME);
+ return -1;
+ }
+ ioctl(dev_fd, AUDIODSP_PCMENC_GET_RING_BUF_SIZE, &buffer_size);
+ /* mapping the kernel buffer to user space to acess */
+ map_buf = mmap(0, buffer_size, PROT_READ , MAP_PRIVATE, dev_fd, 0);
+ if (map_buf == (void*)-1L) {
+ //printf("pcmenc:mmap failed,err id %d \n",errno);
+ adec_print("pcmenc:mmap failed,err id %d \n", errno);
+ close(dev_fd);
+ return -1;
+ }
+ return 0;
+}
+static unsigned pcm_read_num = 0;
+static int pcmenc_skip_pcm(int size)
+{
+ int ring_buf_content = 0;
+ int len = 0;
+ int tail = 0;
+ ioctl(dev_fd, AUDIODSP_PCMENC_GET_RING_BUF_CONTENT, &ring_buf_content);
+ if (ring_buf_content > size) {
+ if (read_offset + size > buffer_size) {
+ //tail = size - read_offset;
+ tail = buffer_size - read_offset;
+ // memcpy(inputbuf,map_buf+read_offset,tail);
+ read_offset = 0;
+ // memcpy(inputbuf+tail,map_buf+read_offset,size-tail);
+ read_offset = size - tail;
+ } else {
+ // memcpy(inputbuf,map_buf+read_offset,size);
+ read_offset += size;
+
+ }
+ pcm_read_num += size;
+ ioctl(dev_fd, AUDIODSP_PCMENC_SET_RING_BUF_RPTR, read_offset);
+ return size;
+ } else {
+ return 0;
+ }
+
+}
+int pcmenc_read_pcm(char *inputbuf, uint size)
+{
+ unsigned int ring_buf_content = 0;
+ int len = 0;
+ int tail = 0;
+ ioctl(dev_fd, AUDIODSP_PCMENC_GET_RING_BUF_CONTENT, &ring_buf_content);
+ if (ring_buf_content > buffer_size * 4 / 5) {
+ pcmenc_skip_pcm(size * 4);
+ memset(inputbuf, 0, size);
+ adec_print("pcmenc buffer full,skip %d bytes \n", 4 * size);
+ return size;
+
+ //ioctl(dev_fd, AUDIODSP_PCMENC_GET_RING_BUF_CONTENT, &ring_buf_content);
+ }
+ //adec_print("read num %d,countent %d,total %d\n",pcm_read_num,ring_buf_content,pcm_read_num+ring_buf_content);
+ if (ring_buf_content > size) {
+ if (read_offset + size > buffer_size) {
+ //tail = size - read_offset;
+ tail = buffer_size - read_offset;
+ memcpy(inputbuf, map_buf + read_offset, tail);
+ read_offset = 0;
+ memcpy(inputbuf + tail, map_buf + read_offset, size - tail);
+ read_offset = size - tail;
+ } else {
+ memcpy(inputbuf, map_buf + read_offset, size);
+ read_offset += size;
+
+ }
+ pcm_read_num += size;
+ ioctl(dev_fd, AUDIODSP_PCMENC_SET_RING_BUF_RPTR, read_offset);
+ return size;
+ } else {
+ return 0;
+ }
+}
+int pcmenc_get_pcm_info(pcm51_encoded_info_t *info)
+{
+ int ret;
+ ret = ioctl(dev_fd, AUDIODSP_PCMENC_GET_PCMINFO, info);
+ if (ret) {
+ return ret;
+ }
+ adec_print("InfoValidFlag %d,SampFs %d,NumCh %d,AcMode %d,LFEFlag %d,BitsPerSamp %d \n", \
+ info->InfoValidFlag, info->SampFs, info->NumCh, info->AcMode, info->LFEFlag, info->BitsPerSamp);
+ return 0;
+
+}
+int pcmenc_deinit()
+{
+ pcm_read_num = 0;
+
+ if (map_buf != (void *)-1L) {
+ munmap(map_buf, buffer_size);
+ }
+ if (dev_fd >= 0) {
+ close(dev_fd);
+ }
+ return 0;
+} \ No newline at end of file
diff --git a/amadec/pcmenc_api.h b/amadec/pcmenc_api.h
new file mode 100644
index 0000000..618faf9
--- a/dev/null
+++ b/amadec/pcmenc_api.h
@@ -0,0 +1,25 @@
+#ifndef __PCMENC_API_H
+#define __PCMENC_API_H
+
+typedef struct pcm51_encoded_info_s {
+ unsigned int InfoValidFlag;
+ unsigned int SampFs;
+ unsigned int NumCh;
+ unsigned int AcMode;
+ unsigned int LFEFlag;
+ unsigned int BitsPerSamp;
+} pcm51_encoded_info_t;
+
+
+#define AUDIODSP_PCMENC_GET_RING_BUF_SIZE _IOR('l', 0x01, unsigned long)
+#define AUDIODSP_PCMENC_GET_RING_BUF_CONTENT _IOR('l', 0x02, unsigned long)
+#define AUDIODSP_PCMENC_GET_RING_BUF_SPACE _IOR('l', 0x03, unsigned long)
+#define AUDIODSP_PCMENC_SET_RING_BUF_RPTR _IOW('l', 0x04, unsigned long)
+#define AUDIODSP_PCMENC_GET_PCMINFO _IOR('l', 0x05, unsigned long)
+
+
+extern int pcmenc_init();
+extern int pcmenc_read_pcm(char *inputbuf, uint size);
+extern int pcmenc_deinit();
+extern int pcmenc_get_pcm_info(pcm51_encoded_info_t *info);
+#endif \ No newline at end of file
diff --git a/amadec/spdif_api.c b/amadec/spdif_api.c
new file mode 100644
index 0000000..58d2788
--- a/dev/null
+++ b/amadec/spdif_api.c
@@ -0,0 +1,306 @@
+/*************************************************************************************
+ * @file spdif_api.c
+ * @brief
+ * Simple SPDIF test tools
+ * Detailed description starts here.
+ *
+ * @author jian.xu jian.xu@amlogic.com
+ *
+ * @internal
+ * Created 2012-4-19
+ * Revision v1.0
+ * Compiler gcc/g++
+ * Company Amlogic Inc.
+ * Copyright Copyright (c) 2011,
+ *
+ * This source code is released for free distribution under the terms of the
+ * GNU General Public License as published by the Free Software Foundation.
+ *************************************************************************************
+ */
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/mman.h>
+#include "spdif_api.h"
+#include <log-print.h>
+#define AUDIO_SPDIF_DEV_NAME "/dev/audio_spdif"
+
+static unsigned hw_rd_offset = 0;
+static unsigned wr_offset = 0;
+static unsigned iec958_buffer_size = 0;
+static int dev_fd = -1;
+static int use_kernel_wr = 0x1;
+static unsigned stream_type = STREAM_DTS;
+static short iec958_buf[6144 / 2];
+static char *map_buf = (void *)-1L;
+static unsigned first_write = 1;
+#define IEC958_LANTENCY 20
+int iec958_init()
+{
+ int ret = 0;
+ iec958_buffer_size = 0;
+ hw_rd_offset = 0;
+ wr_offset = 0;
+ first_write = 1;
+ dev_fd = open(AUDIO_SPDIF_DEV_NAME, /*O_RDONLY|O_WRONLY*/O_RDWR);
+ if (dev_fd < 0) {
+ printf("can not open %s\n", AUDIO_SPDIF_DEV_NAME);
+ ret = -1;
+ goto exit;
+ }
+ /* call 958 module init here */
+ ioctl(dev_fd, AUDIO_SPDIF_SET_958_INIT_PREPARE, 1);
+ /* get 958 dma buffer size */
+ ioctl(dev_fd, AUDIO_SPDIF_GET_958_BUF_SIZE, &iec958_buffer_size);
+ //adec_print("iec958 buffer size %x\n",iec958_buffer_size);
+ wr_offset = hw_rd_offset + 4 * 48000 * IEC958_LANTENCY / 1000; //delay
+ if (wr_offset >= iec958_buffer_size) {
+ wr_offset = iec958_buffer_size;
+ }
+ ioctl(dev_fd, AUDIO_SPDIF_SET_958_WR_OFFSET, &wr_offset);
+ /* mapping the kernel 958 dma buffer to user space to acess */
+ map_buf = mmap(0, iec958_buffer_size, PROT_READ | PROT_WRITE, MAP_SHARED/*MAP_PRIVATE*/, dev_fd, 0);
+ if (map_buf == (void *)-1L) {
+ printf("mmap failed,error num %d \n", errno);
+ ret = -2;
+ goto exit1;
+ }
+ /* enable 958 outout */
+ // ioctl(dev_fd, AUDIO_SPDIF_SET_958_ENABLE,1);
+ return 0;
+exit3:
+ if (map_buf != (void *)-1L) {
+ munmap(map_buf, iec958_buffer_size);
+ }
+exit1:
+ if (dev_fd >= 0) {
+ close(dev_fd);
+ }
+exit:
+ return ret;
+}
+
+/*
+ @param in buf, the input buffer for 61937 package,to be modify
+ @param in frame_size,the input data len
+ @return , the packaged data length,maybe different than input length
+*/
+/* note ::: now fixed on 1.5M dts stream,maybe different */
+int iec958_pack_frame(char *buf, int frame_size)
+{
+
+ short *left, *right, *pp;
+ int i, j;
+ if (stream_type == STREAM_AC3) {
+ iec958_buf[0] = 0xF872;
+ iec958_buf[1] = 0x4E1F;
+ iec958_buf[2] = ((/*dd_bsmod*/0 & 7) << 8) | 1;
+ iec958_buf[3] = frame_size * 8; //frame_size*8;//Pd as the Length-code
+ memcpy((char*)iec958_buf + 8, buf, frame_size);
+ memset((char*)iec958_buf + frame_size + 8, 0, 6144 - frame_size - 8);
+ pp = (short*)iec958_buf;
+ left = (short*)buf;
+ right = left + 16;
+ for (j = 0; j < 6144; j += 64) {
+ for (i = 0; i < 16 ; i++) {
+ *left++ = *pp;
+ pp++;
+ *right++ = *pp;
+ pp++;
+ }
+ left += 16;
+ right += 16;
+ }
+ return 6144;
+ }
+ /* dts iec60937 package according to DTS type and block num per frame */
+ else if (stream_type == STREAM_DTS) {
+ iec958_buf[0] = 0xF872;
+ iec958_buf[1] = 0x4E1F;
+ iec958_buf[2] = 11;//2 block per frame,DTS type I
+ iec958_buf[3] = 2040 * 8; //frame_size*8;//Pd as the Length-code
+ memcpy((char*)iec958_buf + 8, buf, frame_size);
+ memset((char*)iec958_buf + frame_size + 8, 0, 6144 - frame_size - 8);
+ pp = (short*)iec958_buf;
+ left = (short*)buf;
+ right = left + 16;
+ for (j = 0; j < 2048; j += 64) {
+ for (i = 0; i < 16 ; i++) {
+ *left++ = *pp;
+ pp++;
+ *right++ = *pp;
+ pp++;
+ }
+ left += 16;
+ right += 16;
+ }
+ return 2048;
+
+ }
+ /*raw wave file */
+ else {
+ memcpy(iec958_buf, buf, frame_size);
+ pp = (short*)iec958_buf;
+ left = (short*)buf;
+ right = left + 16;
+ for (j = 0; j < frame_size; j += 64) {
+ for (i = 0; i < 16 ; i++) {
+ *left++ = *pp;
+ pp++;
+ *right++ = *pp;
+ pp++;
+ }
+ left += 16;
+ right += 16;
+ }
+ return (frame_size >> 6) << 6;
+ }
+ return 0;
+}
+#define ALIGN 4096
+static int iec958_buf_space_size(int dev_fd)
+{
+ int space = 0;
+ ioctl(dev_fd, AUDIO_SPDIF_GET_958_BUF_RD_OFFSET, &hw_rd_offset);
+ if (first_write == 1) {
+ if (hw_rd_offset >= wr_offset || (wr_offset - hw_rd_offset) < (4 * 48000 * IEC958_LANTENCY / 1000)) {
+ adec_print("reset iec958 hw wr ptr\n");
+ wr_offset = hw_rd_offset + 4 * 48000 * IEC958_LANTENCY / 1000; //delay
+ if (wr_offset >= iec958_buffer_size) {
+ wr_offset = wr_offset - iec958_buffer_size;
+ }
+ }
+ first_write = 0;
+ }
+ if (wr_offset > hw_rd_offset) {
+ space = iec958_buffer_size + hw_rd_offset - wr_offset;
+ } else {
+ space = hw_rd_offset - wr_offset;
+ }
+ return space > ALIGN ? (space - ALIGN) : 0/*&(~4095)*/;
+}
+int iec958_packed_frame_write_958buf(char *buf, int frame_size)
+{
+ int tail = 0;
+ int ret;
+ /* check if i2s enable but 958 not enable */
+ int status_958 = 0;
+ int status_i2s = 0;
+ ioctl(dev_fd, AUDIO_SPDIF_GET_958_ENABLE_STATUS, &status_958);
+ if (status_958 == 0) {
+ ioctl(dev_fd, AUDIO_SPDIF_GET_I2S_ENABLE_STATUS, &status_i2s);
+ if (status_i2s) {
+ status_958 = 1;
+ ioctl(dev_fd, AUDIO_SPDIF_SET_958_ENABLE, status_958);
+ adec_print("spdif api:enable 958 output\n");
+ } else {
+ adec_print("discard data and wait i2s enable\n");
+ return 0;//output are not enable yet,just return and wait
+ }
+ }
+ while (iec958_buf_space_size(dev_fd) < frame_size) {
+ // printf("iec958 buffer full,space size %d,write size %d\n",iec958_buf_space_size(dev_fd),frame_size);
+ //adec_print("iec958 buffer full,space size %d,write size %d\n",iec958_buf_space_size(dev_fd),frame_size);
+ //usleep(5);
+ return -1;
+ }
+ if (wr_offset == iec958_buffer_size) {
+ wr_offset = 0;
+ }
+ if (frame_size + wr_offset > iec958_buffer_size) {
+ tail = iec958_buffer_size - wr_offset;
+ ioctl(dev_fd, AUDIO_SPDIF_SET_958_WR_OFFSET, &wr_offset);
+ //printf("0 tail %d,wr offset %d\n",tail,wr_offset);
+ if (!use_kernel_wr) {
+ memcpy(map_buf + wr_offset, buf, tail);
+ ret = msync(map_buf, iec958_buffer_size, MS_INVALIDATE | MS_SYNC);
+ if (ret) {
+ printf("msync0 err %d,error id %d addr %p\n", ret, errno, map_buf + wr_offset);
+ }
+ } else {
+ write(dev_fd, buf, tail);
+ }
+ wr_offset = 0;
+ ioctl(dev_fd, AUDIO_SPDIF_SET_958_WR_OFFSET, &wr_offset);
+ //printf("1 tail %d,wr offset %d\n",frame_size-tail,wr_offset);
+ if (!use_kernel_wr) {
+ memcpy(map_buf, buf + tail, frame_size - tail);
+ ret = msync(map_buf, iec958_buffer_size, MS_INVALIDATE | MS_SYNC);
+ if (ret) {
+ printf("msync1 err %d,error id %d addr %p\n", ret, errno, map_buf);
+ }
+ } else {
+ write(dev_fd, buf + tail, frame_size - tail);
+ }
+ wr_offset = frame_size - tail;
+ ioctl(dev_fd, AUDIO_SPDIF_SET_958_WR_OFFSET, &wr_offset);
+
+ } else {
+ ioctl(dev_fd, AUDIO_SPDIF_SET_958_WR_OFFSET, &wr_offset);
+ //printf("2 tail %d,wr offset %d\n",frame_size,wr_offset);
+ if (!use_kernel_wr) {
+ memcpy(map_buf + wr_offset, buf, frame_size);
+ ret = msync(map_buf + wr_offset, frame_size, MS_ASYNC | MS_INVALIDATE);
+ if (ret) {
+ printf("msync2 err %d,error id %d addr %p\n", ret, errno, map_buf + wr_offset);
+ }
+ } else {
+ write(dev_fd, buf, frame_size);
+ }
+ wr_offset += frame_size;
+ ioctl(dev_fd, AUDIO_SPDIF_SET_958_WR_OFFSET, &wr_offset);
+
+ }
+ return 0;
+}
+int iec958buf_fill_zero()
+{
+ unsigned int zero_filled_cnt = 0, i2s_status = 0, write_ret = 0;
+ char zerobuf[2048] = {0};
+ ioctl(dev_fd, AUDIO_SPDIF_GET_I2S_ENABLE_STATUS, &i2s_status);
+ while ((zero_filled_cnt < iec958_buffer_size) && i2s_status) {
+ write_ret = iec958_packed_frame_write_958buf(zerobuf, 2048);
+ if (write_ret) {
+ break;
+ }
+ zero_filled_cnt += 2048;
+ ioctl(dev_fd, AUDIO_SPDIF_GET_I2S_ENABLE_STATUS, &i2s_status);
+ }
+ return 0;
+
+}
+/*
+ @return 0:means 958 hw buffer maybe underrun,may need fill zero data
+ @return 1:means 958 hw buffer level is fine
+*/
+#define IEC958_LEVEL_THREAD 4096
+int iec958_check_958buf_level()
+{
+ int status_958 = 0;
+ int hw_958_level = 0;
+ ioctl(dev_fd, AUDIO_SPDIF_GET_958_ENABLE_STATUS, &status_958);
+ if (status_958) {
+ hw_958_level = iec958_buffer_size - iec958_buf_space_size(dev_fd);
+ if (hw_958_level < IEC958_LEVEL_THREAD) {
+ return 0;
+ }
+ }
+ return 1;
+}
+int iec958_deinit()
+{
+ if (map_buf != (void *)-1L) {
+ munmap(map_buf, iec958_buffer_size);
+ }
+ if (dev_fd >= 0) {
+ close(dev_fd);
+ }
+ return 0;
+}
diff --git a/amadec/spdif_api.h b/amadec/spdif_api.h
new file mode 100644
index 0000000..77aff0a
--- a/dev/null
+++ b/amadec/spdif_api.h
@@ -0,0 +1,26 @@
+#ifndef __SPDIF_API_H__
+#define __SPDIF_API_H__
+
+enum {
+ STREAM_AC3 = 0,
+ STREAM_DTS,
+ STREAM_PCM,
+};
+
+#define AUDIO_SPDIF_GET_958_BUF_SIZE _IOR('s', 0x01, unsigned long)
+#define AUDIO_SPDIF_GET_958_BUF_CONTENT _IOR('s', 0x02, unsigned long)
+#define AUDIO_SPDIF_GET_958_BUF_SPACE _IOR('s', 0x03, unsigned long)
+#define AUDIO_SPDIF_GET_958_BUF_RD_OFFSET _IOR('s', 0x04, unsigned long)
+#define AUDIO_SPDIF_GET_958_ENABLE_STATUS _IOR('s', 0x05, unsigned long)
+#define AUDIO_SPDIF_GET_I2S_ENABLE_STATUS _IOR('s', 0x06, unsigned long)
+#define AUDIO_SPDIF_SET_958_ENABLE _IOW('s', 0x07, unsigned long)
+#define AUDIO_SPDIF_SET_958_INIT_PREPARE _IOW('s', 0x08, unsigned long)
+#define AUDIO_SPDIF_SET_958_WR_OFFSET _IOW('s', 0x09, unsigned long)
+
+extern int iec958_init();
+extern int iec958_pack_frame(char *buf, int frame_size);
+extern int iec958_packed_frame_write_958buf(char *buf, int frame_size);
+extern int iec958_deinit();
+extern int iec958_check_958buf_level();
+extern int iec958buf_fill_zero();
+#endif
diff --git a/audio_codec/Android.mk b/audio_codec/Android.mk
new file mode 100755
index 0000000..5053e7d
--- a/dev/null
+++ b/audio_codec/Android.mk
@@ -0,0 +1 @@
+include $(call all-subdir-makefiles)
diff --git a/audio_codec/config.mk b/audio_codec/config.mk
new file mode 100644
index 0000000..a933058
--- a/dev/null
+++ b/audio_codec/config.mk
@@ -0,0 +1,10 @@
+
+LIBAUDIO_PATH:= $(call my-dir)/../
+
+LOCAL_C_INCLUDES += \
+ $(LIBAUDIO_PATH)/amadec/include \
+ $(LIBAUDIO_PATH)/amadec/ \
+
+include $(TOP)/hardware/amlogic/media/media_base_config.mk
+
+LOCAL_C_INCLUDES += $(AMACODEC_PATH)/include/
diff --git a/audio_codec/libadpcm/Android.mk b/audio_codec/libadpcm/Android.mk
new file mode 100755
index 0000000..8e840d4
--- a/dev/null
+++ b/audio_codec/libadpcm/Android.mk
@@ -0,0 +1,12 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SHARED_LIBRARIES += libutils libmedia libz libbinder libdl libcutils libc
+LOCAL_MODULE := libadpcm
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+LOCAL_ARM_MODE := arm
+LOCAL_MODULE_TAGS := optional
+include $(LOCAL_PATH)/../config.mk
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/audio_codec/libadpcm/adpcm.h b/audio_codec/libadpcm/adpcm.h
new file mode 100644
index 0000000..c03f2a0
--- a/dev/null
+++ b/audio_codec/libadpcm/adpcm.h
@@ -0,0 +1,346 @@
+#ifndef AMADEC_ADPCM_H
+#define AMADEC_ADPCM_H
+
+
+#define WAVE_TASK_STK_SIZE (2048*4)
+#define WAVE_BLOCK_SIZE 2048
+
+typedef struct {
+ unsigned int start;
+ int size;
+ unsigned int sr;
+ unsigned int ch;
+ unsigned int bps;
+ int wr;
+ int blk;
+ unsigned int sr_factor;
+ unsigned int last_rd;
+ unsigned int last_pts;
+ unsigned int totalSamplePlayed;
+ unsigned int totalSampleDecoded;
+ unsigned int totalSample;
+} t_adpcm_output_buf_manager;
+
+//------------------------------------
+//copy from amffmepg/libavcodec/avcodec.h"
+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,
+ CODEC_ID_XVID,
+ 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,
+ CODEC_ID_A64_MULTI,
+ CODEC_ID_A64_MULTI5,
+ CODEC_ID_R10K,
+ CODEC_ID_MXPEG,
+ CODEC_ID_LAGARITH,
+ CODEC_ID_PRORES,
+ CODEC_ID_JV,
+ CODEC_ID_DFA,
+ CODEC_ID_8SVX_RAW,
+
+ /* H264 MVC type */
+ CODEC_ID_H264MVC,
+
+ /* 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,
+ CODEC_ID_PCM_LXF,
+ CODEC_ID_S302M,
+ CODEC_ID_PCM_WIFIDISPLAY,
+
+ /* 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,
+ CODEC_ID_ADPCM_G722,
+
+ /* 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,
+ CODEC_ID_AAC_LATM,
+ CODEC_ID_QDMC,
+ CODEC_ID_CELT,
+
+ /* 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,
+ CODEC_ID_MICRODVD,
+
+ /* 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) */
+ CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
+};
+
+
+#endif
diff --git a/audio_codec/libadpcm/adpcm_decode.c b/audio_codec/libadpcm/adpcm_decode.c
new file mode 100644
index 0000000..8f7f5ca
--- a/dev/null
+++ b/audio_codec/libadpcm/adpcm_decode.c
@@ -0,0 +1,841 @@
+#define LOG_TAG "AdpcmDecoder"
+
+#include <stdio.h>
+#include <stdint.h>
+#include "adpcm.h"
+#include "../../amadec/adec-armdec-mgt.h"
+#include "../../amadec/audio-dec.h"
+#include <android/log.h>
+#include <sys/time.h>
+#include <stdint.h>
+#include <string.h>
+#define PRINTF(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+
+typedef struct {
+ int ValidDataLen;
+ int UsedDataLen;
+ unsigned char *BufStart;
+ unsigned char *pcur;
+} pcm_read_ctl_t;
+
+
+static int pcm_read_init(pcm_read_ctl_t *pcm_read_ctx, unsigned char* inbuf, int size)
+{
+ pcm_read_ctx->ValidDataLen = size;
+ pcm_read_ctx->UsedDataLen = 0;
+ pcm_read_ctx->BufStart = inbuf;
+ pcm_read_ctx->pcur = inbuf;
+ return 0;
+}
+
+static int pcm_read(pcm_read_ctl_t *pcm_read_ctx, unsigned char* outbuf, int size)
+{
+ int bytes_read = 0;
+ if (size <= pcm_read_ctx->ValidDataLen) {
+ memcpy(outbuf, pcm_read_ctx->pcur, size);
+ pcm_read_ctx->ValidDataLen -= size;
+ pcm_read_ctx->UsedDataLen += size;
+ pcm_read_ctx->pcur += size;
+ bytes_read = size;
+ }
+ return bytes_read;
+}
+
+struct t_wave_buf {
+ void *addr;
+ unsigned size;
+};
+static unsigned wave_timestamplen = 0;
+static unsigned wave_timestamp = 0;
+
+static int adpcm_step[89] = {
+ 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
+};
+
+static int adpcm_index[16] = {
+ -1, -1, -1, -1, 2, 4, 6, 8,
+ -1, -1, -1, -1, 2, 4, 6, 8
+};
+
+// useful macros
+// clamp a number between 0 and 88
+#define CLAMP_0_TO_88(x) if (x < 0) x = 0; else if (x > 88) x = 88;
+// clamp a number within a signed 16-bit range
+#define CLAMP_S16(x) if (x < -32768) x = -32768; \
+ else if (x > 32767) x = 32767;
+// clamp a number above 16
+#define CLAMP_ABOVE_16(x) if (x < 16) x = 16;
+// sign extend a 16-bit value
+#define SE_16BIT(x) if (x & 0x8000) x -= 0x10000;
+// sign extend a 4-bit value
+#define SE_4BIT(x) if (x & 0x8) x -= 0x10;
+static t_adpcm_output_buf_manager g_mgr;
+static int block_align = 0;
+static int offset = 0;
+//extern unsigned char buffer[1024*64];
+static unsigned char *pwavebuf = NULL;
+static struct t_wave_buf wave_decoder_buffer[] = {{0, 0}, {0, 0}}; // 0 - stream, 1 - pcm
+
+
+static int adpcm_init(aml_audio_dec_t *audec)
+{
+ audio_decoder_operations_t *adec_ops = (audio_decoder_operations_t *)audec->adec_ops;
+ PRINTF("[%s]audec->format/%d adec_ops->samplerate/%d adec_ops->channels/%d\n",
+ __FUNCTION__, audec->format, adec_ops->samplerate, adec_ops->channels);
+
+ wave_decoder_buffer[0].addr = malloc(WAVE_BLOCK_SIZE);
+ if (wave_decoder_buffer[0].addr == 0) {
+ PRINTF("[%s %d]Error: malloc adpcm buffer failed!\n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ wave_decoder_buffer[0].size = WAVE_BLOCK_SIZE;
+ wave_decoder_buffer[1].addr = malloc(WAVE_BLOCK_SIZE * 4 * 4);
+ if (wave_decoder_buffer[1].addr == 0) {
+ PRINTF("[%s %d]Error: malloc adpcm buffer failed!\n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ adec_ops->nInBufSize = WAVE_BLOCK_SIZE;
+ adec_ops->nOutBufSize = 0;
+ wave_decoder_buffer[1].size = WAVE_BLOCK_SIZE * 4 * 4; // 2byte, 2ch, compress ratio 4
+ g_mgr.start = 0;
+ g_mgr.size = 0;
+ g_mgr.bps = audec->data_width;
+ g_mgr.ch = adec_ops->channels;
+ g_mgr.sr = adec_ops->samplerate;
+ g_mgr.wr = 0;
+ g_mgr.last_rd = 0;
+ g_mgr.totalSample = 0;
+ g_mgr.totalSamplePlayed = 0;
+ g_mgr.totalSampleDecoded = 0;
+ g_mgr.last_pts = 0;
+ g_mgr.blk = 0;
+
+ block_align = audec->block_align;
+ wave_timestamplen = 0;
+ PRINTF("[%s %d]block_align/%d audec->codec_id/0x%x\n", __FUNCTION__, __LINE__, block_align, audec->codec_id);
+ return 0;
+}
+
+#define CHECK_DATA_ENOUGH_SUB(Ctl,NeedBytes,UsedSetIfNo) { \
+ if((Ctl)->ValidDataLen < (NeedBytes)){ \
+ PRINTF("[%s %d]NOTE--> no enough data\n",__FUNCTION__,__LINE__);\
+ (Ctl)->UsedDataLen-=(UsedSetIfNo); \
+ return -1; \
+ } \
+}
+
+#define CHECK_DATA_ENOUGH_SET(Ctl,NeedBytes,UsedSetIfNo) { \
+ if((Ctl)->ValidDataLen < (NeedBytes)){ \
+ PRINTF("[%s %d]NOTE--> no enough data\n",__FUNCTION__,__LINE__);\
+ (Ctl)->UsedDataLen=(UsedSetIfNo); \
+ return -1; \
+ } \
+}
+
+static int refill(aml_audio_dec_t *audec, pcm_read_ctl_t *pcm_read_ctx, unsigned char* buf, int len)
+{
+ static unsigned refill_timestamp_len = 0;
+ unsigned char *pbuf = buf;
+ unsigned char tmp_a = 0;
+ unsigned char tmp_p = 0;
+ unsigned char tmp_t = 0;
+ unsigned char tmp_s = 0;
+ int len_bak = len;
+ int tmp = 0;
+ if (wave_timestamplen == 0) { // when no apts found
+ unsigned char timestamp[4] = {0};
+ unsigned char block_length[4] = {0};
+
+ CHECK_DATA_ENOUGH_SET(pcm_read_ctx, 4, 0)
+ pcm_read(pcm_read_ctx, &tmp_a, 1);
+ pcm_read(pcm_read_ctx, &tmp_p, 1);
+ pcm_read(pcm_read_ctx, &tmp_t, 1);
+ pcm_read(pcm_read_ctx, &tmp_s, 1);
+
+ if (tmp_a == 'A' && tmp_p == 'P' && tmp_t == 'T' && tmp_s == 'S') {
+ CHECK_DATA_ENOUGH_SET(pcm_read_ctx, 8, 0)
+ pcm_read(pcm_read_ctx, timestamp, 4);
+ wave_timestamp = (timestamp[0] << 24) | (timestamp[1] << 16) | (timestamp[2] << 8) | (timestamp[3]);
+ pcm_read(pcm_read_ctx, block_length, 4);
+ wave_timestamplen = (block_length[0] << 24) | (block_length[1] << 16) | (block_length[2] << 8) | (block_length[3]);
+ refill_timestamp_len = wave_timestamplen;
+
+ CHECK_DATA_ENOUGH_SET(pcm_read_ctx, refill_timestamp_len, 0)
+
+ } else if (tmp_a == 'R' && tmp_p == 'I' && tmp_t == 'F' && tmp_s == 'F') {
+ if ((audec->codec_id == CODEC_ID_ADPCM_IMA_WAV) || (audec->codec_id == CODEC_ID_ADPCM_MS)) {
+ tmp = len;
+ while (tmp) {
+ CHECK_DATA_ENOUGH_SET(pcm_read_ctx, 8, 0)
+ pcm_read(pcm_read_ctx, &timestamp[0], 1);
+ tmp --;
+ if (timestamp[0] == 'd') {
+ pcm_read(pcm_read_ctx, &timestamp[1], 3);
+ tmp -= 3;
+ if ((timestamp[0] == 'd') && (timestamp[1] == 'a') && (timestamp[2] == 't') && (timestamp[3] == 'a')) {
+ break;
+ }
+ }
+ }
+ pcm_read(pcm_read_ctx, timestamp, 4);
+ wave_timestamplen = 0;
+ wave_timestamp = 0xffffffff;
+
+ CHECK_DATA_ENOUGH_SUB(pcm_read_ctx, len, 0)
+ } else {
+ *pbuf++ = tmp_a;
+ *pbuf++ = tmp_p;
+ *pbuf++ = tmp_t;
+ *pbuf++ = tmp_s;
+ len -= 4;
+ wave_timestamplen = 0;
+ wave_timestamp = 0xffffffff;
+
+ CHECK_DATA_ENOUGH_SET(pcm_read_ctx, len, 0)
+ }
+ } else {
+ *pbuf++ = tmp_a;
+ *pbuf++ = tmp_p;
+ *pbuf++ = tmp_t;
+ *pbuf++ = tmp_s;
+ len -= 4;
+ CHECK_DATA_ENOUGH_SET(pcm_read_ctx, len, 0)
+ wave_timestamplen = 0;
+ wave_timestamp = 0xffffffff;
+ }
+ }
+
+ if (wave_timestamplen) {
+ pcm_read(pcm_read_ctx, pbuf, refill_timestamp_len);
+ return refill_timestamp_len;
+ } else {
+ pcm_read(pcm_read_ctx, pbuf, len);
+ return len_bak;
+ }
+
+}
+
+/*IMA ADPCM*/
+#define le2me_16(x) (x)
+#define MS_IMA_ADPCM_PREAMBLE_SIZE 4
+#define LE_16(x) (le2me_16(*(unsigned short *)(x)))
+
+static void decode_nibbles(unsigned short *output,
+ int output_size, int channels,
+ int predictor_l, int index_l,
+ int predictor_r, int index_r)
+{
+ int step[2];
+ int predictor[2];
+ int index[2];
+ int diff;
+ int i;
+ int sign;
+ int delta;
+ int channel_number = 0;
+
+ step[0] = adpcm_step[index_l];
+ step[1] = adpcm_step[index_r];
+ predictor[0] = predictor_l;
+ predictor[1] = predictor_r;
+ index[0] = index_l;
+ index[1] = index_r;
+
+ for (i = 0; i < output_size; i++) {
+ delta = output[i];
+
+ index[channel_number] += adpcm_index[delta];
+ CLAMP_0_TO_88(index[channel_number]);
+
+ sign = delta & 8;
+ delta = delta & 7;
+
+ diff = step[channel_number] >> 3;
+ if (delta & 4) {
+ diff += step[channel_number];
+ }
+ if (delta & 2) {
+ diff += step[channel_number] >> 1;
+ }
+ if (delta & 1) {
+ diff += step[channel_number] >> 2;
+ }
+
+ if (sign) {
+ predictor[channel_number] -= diff;
+ } else {
+ predictor[channel_number] += diff;
+ }
+
+ CLAMP_S16(predictor[channel_number]);
+ output[i] = predictor[channel_number];
+ step[channel_number] = adpcm_step[index[channel_number]];
+
+ // toggle channel
+ channel_number ^= channels - 1;
+
+ }
+}
+
+static int ima_adpcm_decode_block(unsigned short *output,
+ unsigned char *input, int channels, int block_size)
+{
+ int predictor_l = 0;
+ int predictor_r = 0;
+ int index_l = 0;
+ int index_r = 0;
+ int i;
+ int channel_counter;
+ int channel_index;
+ int channel_index_l;
+ int channel_index_r;
+
+ predictor_l = LE_16(&input[0]);
+ SE_16BIT(predictor_l);
+ index_l = input[2];
+ if (channels == 2) {
+ predictor_r = LE_16(&input[4]);
+ SE_16BIT(predictor_r);
+ index_r = input[6];
+ }
+
+ if (channels == 1)
+ for (i = 0; i < (block_size - MS_IMA_ADPCM_PREAMBLE_SIZE * channels); i++) {
+ output[i * 2 + 0] = input[MS_IMA_ADPCM_PREAMBLE_SIZE + i] & 0x0F;
+ output[i * 2 + 1] = input[MS_IMA_ADPCM_PREAMBLE_SIZE + i] >> 4;
+ }
+ else {
+ // encoded as 8 nibbles (4 bytes) per channel; switch channel every
+ // 4th byte
+ channel_counter = 0;
+ channel_index_l = 0;
+ channel_index_r = 1;
+ channel_index = channel_index_l;
+ for (i = 0;
+ i < (block_size - MS_IMA_ADPCM_PREAMBLE_SIZE * channels); i++) {
+ output[channel_index + 0] =
+ input[MS_IMA_ADPCM_PREAMBLE_SIZE * 2 + i] & 0x0F;
+ output[channel_index + 2] =
+ input[MS_IMA_ADPCM_PREAMBLE_SIZE * 2 + i] >> 4;
+ channel_index += 4;
+ channel_counter++;
+ if (channel_counter == 4) {
+ channel_index_l = channel_index;
+ channel_index = channel_index_r;
+ } else if (channel_counter == 8) {
+ channel_index_r = channel_index;
+ channel_index = channel_index_l;
+ channel_counter = 0;
+ }
+ }
+ }
+
+ decode_nibbles(output,
+ (block_size - MS_IMA_ADPCM_PREAMBLE_SIZE * channels) * 2,
+ channels,
+ predictor_l, index_l,
+ predictor_r, index_r);
+
+ return (block_size - MS_IMA_ADPCM_PREAMBLE_SIZE * channels) * 2;
+}
+#define MSADPCM_ADAPT_COEFF_COUNT 7
+static int AdaptationTable [] = {
+ 230, 230, 230, 230, 307, 409, 512, 614,
+ 768, 614, 512, 409, 307, 230, 230, 230
+} ;
+
+/* TODO : The first 7 coef's are are always hardcode and must
+appear in the actual WAVE file. They should be read in
+in case a sound program added extras to the list. */
+
+static int AdaptCoeff1 [MSADPCM_ADAPT_COEFF_COUNT] = {
+ 256, 512, 0, 192, 240, 460, 392
+} ;
+
+static int AdaptCoeff2 [MSADPCM_ADAPT_COEFF_COUNT] = {
+ 0, -256, 0, 64, 0, -208, -232
+} ;
+
+static int ms_adpcm_decode_block(short *pcm_buf, unsigned char *buf, int channel, int block)
+{
+ int sampleblk = 2036;
+ short bpred[2];
+ short idelta[2];
+ int blockindx = 0;
+ int sampleindx = 0;
+ short bytecode = 0;
+ int predict = 0;
+ int current = 0;
+ int delta = 0;
+ int i = 0;
+ int j = 0;
+ short s0 = 0;
+ short s1 = 0;
+ short s2 = 0;
+ short s3 = 0;
+ short s4 = 0;
+ short s5 = 0;
+
+ //sampleblk = sample_block;
+ j = 0;
+ if (channel == 1) {
+ bpred[0] = buf[0];
+ bpred[1] = 0;
+ if (bpred[0] >= 7) {
+ //printf("sync error\n");
+ //goto _exit;
+ }
+ idelta[0] = buf[1] | buf[2] << 8;
+ idelta[1] = 0;
+
+ s1 = buf[3] | buf[4] << 8;
+ s0 = buf[5] | buf[6] << 8;
+
+ blockindx = 7;
+ sampleindx = 2;
+ } else if (channel == 2) {
+ bpred[0] = buf[0];
+ bpred[1] = buf[1];
+ if (bpred[0] >= 7 || bpred[1] >= 7) {
+ //printf("sync error\n");
+ //goto _exit;
+ }
+ idelta[0] = buf[2] | buf[3] << 8;
+ idelta[1] = buf[4] | buf[5] << 8;
+
+ s2 = buf[6] | buf[7] << 8;
+ s3 = buf[8] | buf[9] << 8;
+ s0 = buf[10] | buf[11] << 8;
+ s1 = buf[12] | buf[13] << 8;
+ blockindx = 14;
+ sampleindx = 4;
+ }
+
+ /*--------------------------------------------------------
+ This was left over from a time when calculations were done
+ as ints rather than shorts. Keep this around as a reminder
+ in case I ever find a file which decodes incorrectly.
+
+ if (chan_idelta [0] & 0x8000)
+ chan_idelta [0] -= 0x10000 ;
+ if (chan_idelta [1] & 0x8000)
+ chan_idelta [1] -= 0x10000 ;
+ --------------------------------------------------------*/
+
+ /* Pull apart the packed 4 bit samples and store them in their
+ ** correct sample positions.
+ */
+
+ /* Decode the encoded 4 bit samples. */
+ int chan;
+
+ for (i = channel * 2;/*i<channel*sampleblk&&*/(blockindx < block); i++) {
+ if (sampleindx <= i) {
+ if (blockindx < block) {
+ bytecode = buf[blockindx++];
+
+
+ if (channel == 1) {
+ s2 = (bytecode >> 4) & 0x0f;
+ s3 = bytecode & 0x0f;
+ } else if (channel == 2) {
+ s4 = (bytecode >> 4) & 0x0f;
+ s5 = bytecode & 0x0f;
+ }
+ sampleindx++;
+ sampleindx++;
+
+ }
+ }
+ chan = (channel > 1) ? (i % 2) : 0;
+
+ if (channel == 1) {
+ bytecode = s2 & 0x0f;
+ } else if (channel == 2) {
+ bytecode = s4 & 0x0f;
+ }
+ /* Compute next Adaptive Scale Factor (ASF) */
+ delta = idelta[chan];
+
+ /* => / 256 => FIXED_POINT_ADAPTATION_BASE == 256 */
+ idelta[chan] = (AdaptationTable[bytecode] * delta) >> 8;
+
+ if (idelta[chan] < 16) {
+ idelta[chan] = 16;
+ }
+ if (bytecode & 0x8) {
+ bytecode -= 0x10;
+ }
+ /* => / 256 => FIXED_POINT_COEFF_BASE == 256 */
+
+ if (channel == 1) {
+ predict = s1 * AdaptCoeff1[bpred[chan]];
+ predict += s0 * AdaptCoeff2[bpred[chan]];
+ } else if (channel == 2) {
+ predict = s2 * AdaptCoeff1[bpred[chan]];
+ predict += s0 * AdaptCoeff2[bpred[chan]];
+ }
+
+ predict >>= 8;
+ current = bytecode * delta + predict;
+#if 1
+ if (current > 32767) {
+ current = 32767 ;
+ } else if (current < -32768) {
+ current = -32768 ;
+ }
+#else
+ current = _min(current, 32767);
+ current = _max(current, -32768);
+#endif
+ if (channel == 1) {
+ s2 = current;
+ } else if (channel == 2) {
+ s4 = current;
+ }
+
+ pcm_buf[j++] = s0;
+
+ if (channel == 1) {
+ s0 = s1;
+ s1 = s2;
+ s2 = s3;
+ } else if (channel == 2) {
+ s0 = s1;
+ s1 = s2;
+ s2 = s3;
+ s3 = s4;
+ s4 = s5;
+ }
+ }
+
+ if (channel == 1) {
+ pcm_buf[j++] = s0;
+ pcm_buf[j++] = s1;
+ } else if (channel == 2) {
+ pcm_buf[j++] = s0;
+ pcm_buf[j++] = s1;
+ pcm_buf[j++] = s2;
+ pcm_buf[j++] = s3;
+ }
+
+ return j;
+}
+
+
+/*
+ * u-law, A-law and linear PCM conversions.
+ */
+
+#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */
+#define QUANT_MASK (0xf) /* Quantization field mask. */
+#define NSEGS (8) /* Number of A-law segments. */
+#define SEG_SHIFT (4) /* Left shift for segment number. */
+#define SEG_MASK (0x70) /* Segment field mask. */
+//static short seg_end[8] = {0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF};
+#define BIAS (0x84) /* Bias for linear code. */
+
+/*
+ * alaw2linear() - Convert an A-law value to 16-bit linear PCM
+ *
+ */
+int alaw2linear(unsigned char a_val)
+{
+ int t;
+ int seg;
+ a_val ^= 0x55;
+ t = (a_val & QUANT_MASK) << 4;
+ seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT;
+ switch (seg) {
+ case 0:
+ t += 8;
+ break;
+ case 1:
+ t += 0x108;
+ break;
+ default:
+ t += 0x108;
+ t <<= seg - 1;
+ }
+ return ((a_val & SIGN_BIT) ? t : -t);
+}
+/*
+ * ulaw2linear() - Convert a u-law value to 16-bit linear PCM
+ *
+ * First, a biased linear code is derived from the code word. An unbiased
+ * output can then be obtained by subtracting 33 from the biased code.
+ *
+ * Note that this function expects to be passed the complement of the
+ * original code word. This is in keeping with ISDN conventions.
+ */
+int ulaw2linear(unsigned char u_val)
+{
+ int t;
+ /* Complement to obtain normal u-law value. */
+ u_val = ~u_val;
+ /*
+ * Extract and bias the quantization bits. Then
+ * shift up by the segment number and subtract out the bias.
+ */
+ t = ((u_val & QUANT_MASK) << 3) + BIAS;
+ t <<= ((unsigned)u_val & SEG_MASK) >> SEG_SHIFT;
+ return ((u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS));
+}
+
+int runalawdecoder(aml_audio_dec_t *audec, pcm_read_ctl_t *pcm_read_ctx, unsigned char *buf, int len)
+{
+ int i = 0;
+ int tmp = 0;
+ short *pcm_buf = (short*)wave_decoder_buffer[1].addr;
+
+ tmp = refill(audec, pcm_read_ctx, pwavebuf, WAVE_BLOCK_SIZE);
+ if (tmp < 0) {
+ return -1;
+ }
+ for (i = 0; i < tmp; i++) {
+ pcm_buf[i] = alaw2linear(pwavebuf[i]);
+ }
+ memcpy(buf, (char*)pcm_buf, 2 * WAVE_BLOCK_SIZE);
+ return (WAVE_BLOCK_SIZE) * 2;
+}
+int runulawdecoder(aml_audio_dec_t *audec, pcm_read_ctl_t *pcm_read_ctx, unsigned char *buf, int len)
+{
+ int i = 0;
+ short *pcm_buf = (short*)wave_decoder_buffer[1].addr;
+ int tmp = 0;
+
+ tmp = refill(audec, pcm_read_ctx, pwavebuf, WAVE_BLOCK_SIZE);
+ if (tmp < 0) {
+ return -1;
+ }
+ for (i = 0; i < tmp; i++) {
+ pcm_buf[i] = ulaw2linear(pwavebuf[i]);
+ }
+ memcpy(buf, (char*)pcm_buf, 2 * WAVE_BLOCK_SIZE);
+ return (WAVE_BLOCK_SIZE) * 2;
+
+}
+int runimaadpcmdecoder(aml_audio_dec_t *audec, pcm_read_ctl_t *pcm_read_ctx, unsigned char *buf, int len)
+{
+ short *pcm_buf = (short*)wave_decoder_buffer[1].addr;
+ int Output_Size = 0;
+ int tmp = 0;
+ char buffer[5];
+ unsigned block_size = 0;
+ int UsedDataLenSave = 0;
+ if (!block_align) {
+ CHECK_DATA_ENOUGH_SET(pcm_read_ctx, 4, 0)
+ pcm_read(pcm_read_ctx, buffer, 4);
+ while (1) {
+ if ((buffer[0] == 0x11) && (buffer[1] == 0x22) && (buffer[2] == 0x33) && (buffer[3] == 0x44)) { //sync word
+ break;
+ }
+ CHECK_DATA_ENOUGH_SUB(pcm_read_ctx, 1, 3)
+ pcm_read(pcm_read_ctx, &buffer[4], 1);
+ memmove(buffer, &buffer[1], 4);
+ }
+ CHECK_DATA_ENOUGH_SUB(pcm_read_ctx, 2, 4)
+ pcm_read(pcm_read_ctx, buffer, 2);
+
+ block_size = (buffer[0] << 8) | buffer[1];
+ CHECK_DATA_ENOUGH_SUB(pcm_read_ctx, block_size, 6)
+ } else {
+ block_size = block_align;
+ CHECK_DATA_ENOUGH_SET(pcm_read_ctx, block_size, 0)
+ }
+
+ if (block_size < 4) {
+ PRINTF("[%s %d]imaadpcm block align not valid: %d\n", __FUNCTION__, __LINE__, block_size);
+ return 0;
+ }
+
+ UsedDataLenSave = pcm_read_ctx->UsedDataLen;
+ tmp = refill(audec, pcm_read_ctx, pwavebuf, block_size);
+ if (tmp < 0) {
+ pcm_read_ctx->UsedDataLen = UsedDataLenSave;
+ return -1;
+ }
+
+ if (tmp != block_size) {
+ PRINTF("[%s %d]imaadpcm: data missalign\n", __FUNCTION__, __LINE__);
+ }
+ Output_Size = ima_adpcm_decode_block((unsigned short *)pcm_buf, pwavebuf, g_mgr.ch, block_size);
+ memcpy(buf, (char*)pcm_buf, 2 * Output_Size);
+ return Output_Size * 2;
+
+}
+
+int runmsadpcmdecoder(aml_audio_dec_t *audec, pcm_read_ctl_t *pcm_read_ctx, unsigned char *buf, int len)
+{
+ short *pcm_buf = (short*)wave_decoder_buffer[1].addr;
+ int Output_Size = 0;
+ unsigned tmp = 0;
+ char buffer[5];
+ unsigned block_size = 0;
+ int UsedDataLenSave = 0;
+ if (!block_align) {
+ CHECK_DATA_ENOUGH_SET(pcm_read_ctx, 4, 0)
+ pcm_read(pcm_read_ctx, buffer, 4);
+ while (1) {
+ if ((buffer[0] == 0x11) && (buffer[1] == 0x22) && (buffer[2] == 0x33) && (buffer[3] == 0x44)) { //sync word
+ break;
+ }
+ CHECK_DATA_ENOUGH_SUB(pcm_read_ctx, 1, 3)
+ pcm_read(pcm_read_ctx, &buffer[4], 1);
+ memmove(buffer, &buffer[1], 4);
+ }
+
+ CHECK_DATA_ENOUGH_SUB(pcm_read_ctx, 2, 4)
+ pcm_read(pcm_read_ctx, buffer, 2);
+ block_size = (buffer[0] << 8) | buffer[1];
+ CHECK_DATA_ENOUGH_SUB(pcm_read_ctx, block_size, 6)
+ } else {
+ block_size = block_align;
+ CHECK_DATA_ENOUGH_SET(pcm_read_ctx, block_size, 0)
+ }
+
+ if (block_size < 4) {
+ PRINTF("[%s %d]msadpcm block align not valid: %d\n", __FUNCTION__, __LINE__, block_size);
+ return 0;
+ }
+
+ UsedDataLenSave = pcm_read_ctx->UsedDataLen;
+ tmp = refill(audec, pcm_read_ctx, pwavebuf, block_size);
+ if (tmp < 0) {
+ pcm_read_ctx->UsedDataLen = UsedDataLenSave;
+ return -1;
+
+ }
+ if (tmp != block_size) {
+ PRINTF("[%s %d]msadpcm: data missalign\n", __FUNCTION__, __LINE__);
+ }
+
+ Output_Size = ms_adpcm_decode_block(pcm_buf, pwavebuf, g_mgr.ch, block_size);
+ Output_Size = Output_Size - Output_Size % g_mgr.ch;
+ memcpy(buf, (char*)pcm_buf, 2 * Output_Size);
+ return Output_Size * 2;
+
+}
+
+
+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
+};
+
+int runpcmdecoder(aml_audio_dec_t *audec, pcm_read_ctl_t *pcm_read_ctx, unsigned char *buf, int len)
+{
+ int i/*, j*/;
+ short *pcm_buf = (short*)wave_decoder_buffer[1].addr;
+ int tmp = 0;
+ offset = 0;
+ if (g_mgr.bps == SAMPLE_FMT_U8) {
+ tmp = refill(audec, pcm_read_ctx, pwavebuf, WAVE_BLOCK_SIZE);
+ if (tmp < 0) {
+ return -1;
+ }
+ for (i = 0; i < tmp;) {
+ pcm_buf[i] = (pwavebuf[i] - 0x80) << 8;
+ i++;
+ pcm_buf[i] = (pwavebuf[i] - 0x80) << 8;
+ i++;
+ pcm_buf[i] = (pwavebuf[i] - 0x80) << 8;
+ i++;
+ pcm_buf[i] = (pwavebuf[i] - 0x80) << 8;
+ i++;
+ }
+ return (WAVE_BLOCK_SIZE) * 2;
+ } else {
+ if (refill(audec, pcm_read_ctx, pwavebuf, WAVE_BLOCK_SIZE) < 0) {
+ return -1;
+ };
+ return ((WAVE_BLOCK_SIZE >> 1) * 2);
+ }
+}
+
+static int adpcm_decode_frame(aml_audio_dec_t *audec, pcm_read_ctl_t *pcm_read_ctx, unsigned char *buf, int len)
+{
+ int buf_size = 0;
+ pwavebuf = (unsigned char*)wave_decoder_buffer[0].addr;
+
+ switch (audec->codec_id) {
+ case CODEC_ID_PCM_ALAW:
+ buf_size = runalawdecoder(audec, pcm_read_ctx, buf, len);
+ break;
+
+ case CODEC_ID_PCM_MULAW:
+ buf_size = runulawdecoder(audec, pcm_read_ctx, buf, len);
+ break;
+
+ case CODEC_ID_ADPCM_IMA_WAV:
+ buf_size = runimaadpcmdecoder(audec, pcm_read_ctx, buf, len);
+ break;
+
+ case CODEC_ID_ADPCM_MS:
+ buf_size = runmsadpcmdecoder(audec, pcm_read_ctx, buf, len);
+ break;
+ default:
+ buf_size = runpcmdecoder(audec, pcm_read_ctx, buf, len);
+ break;
+ }
+ return buf_size;
+}
+
+static int adpcm_decode_release(void)
+{
+ if (wave_decoder_buffer[0].addr) {
+ free(wave_decoder_buffer[0].addr);
+ wave_decoder_buffer[0].addr = 0;
+ wave_decoder_buffer[0].size = 0;
+ }
+ if (wave_decoder_buffer[1].addr) {
+ free(wave_decoder_buffer[1].addr);
+ wave_decoder_buffer[1].addr = 0;
+ wave_decoder_buffer[1].size = 0;
+ }
+ return 0;
+}
+
+int audio_dec_decode(audio_decoder_operations_t *adec_ops, char *outbuf, int *outlen, char *inbuf, int inlen)
+{
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)(adec_ops->priv_data);
+ pcm_read_ctl_t pcm_read_ctl = {0};
+ pcm_read_init(&pcm_read_ctl, inbuf, inlen);
+ *outlen = adpcm_decode_frame(audec, &pcm_read_ctl, outbuf, *outlen);
+ return pcm_read_ctl.UsedDataLen;
+
+}
+int audio_dec_init(audio_decoder_operations_t *adec_ops)
+{
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)(adec_ops->priv_data);
+ //PRINTF("\n\n[%s]BuildDate--%s BuildTime--%s", __FUNCTION__, __DATE__, __TIME__);
+ adpcm_init(audec);
+ return 0;
+}
+
+int audio_dec_release(audio_decoder_operations_t *adec_ops)
+{
+ adpcm_decode_release();
+ return 0;
+}
+
+int audio_dec_getinfo(audio_decoder_operations_t *adec_ops, void *pAudioInfo)
+{
+ return 0;
+}
+
+
diff --git a/audio_codec/libamr/Android.mk b/audio_codec/libamr/Android.mk
new file mode 100755
index 0000000..03ae3df
--- a/dev/null
+++ b/audio_codec/libamr/Android.mk
@@ -0,0 +1,25 @@
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE := libamr
+
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+LOCAL_ARM_MODE := arm
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/
+
+
+include $(BUILD_STATIC_LIBRARY)
+
+#################################################################################
+include $(CLEAR_VARS)
+LOCAL_SHARED_LIBRARIES += libutils libmedia libz libbinder libdl libcutils libc
+LOCAL_MODULE := libamr
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+LOCAL_ARM_MODE := arm
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY) \ No newline at end of file
diff --git a/audio_codec/libamr/Makefile b/audio_codec/libamr/Makefile
new file mode 100755
index 0000000..d6c3786
--- a/dev/null
+++ b/audio_codec/libamr/Makefile
@@ -0,0 +1,5 @@
+OBJ=$(OBJTREE)/codecs/codec_amr
+TARGET=audiodsp_codec_amr.elf
+OBJS = $(patsubst %.c, %.o, $(wildcard *.c */*.c))
+
+include $(SRCTREE)/inc.mk
diff --git a/audio_codec/libamr/amr_decode.c b/audio_codec/libamr/amr_decode.c
new file mode 100644
index 0000000..319f31e
--- a/dev/null
+++ b/audio_codec/libamr/amr_decode.c
@@ -0,0 +1,186 @@
+
+#include "sp_dec.h"
+
+#include "../../amadec/adec-armdec-mgt.h"
+#include <android/log.h>
+#include "interf_dec.h"
+#include "dec_if.h"
+
+#define LOG_TAG "AmrDecoder"
+#define amr_print(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+#define DefaultReadSize 2*1024
+#define DefaultOutBufSize 16*1024
+
+
+
+typedef void (*_AMR_DECODE_FRAME)(void*, short*, short *outlen, char *inbuf, int *consume);
+
+static _AMR_DECODE_FRAME amr_decode_frame_fun;
+static int SampleRateOut = 0;
+static void * destate = NULL;
+static const short amrnb_block_size[16] = { 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };
+
+#if 0
+int amr_read(unsigned char *pBuffer, int n)
+{
+ int i;
+ i = read_buffer(pBuffer, n);
+ return i;
+}
+#endif
+
+void * Decoder_Init()
+{
+ if (SampleRateOut == 8000) {
+ return (void *)Decoder_Interface_init();
+ } else {
+ return (void *)D_IF_init();
+ }
+}
+void amrnb_decode_frame(void* destate, short* pOutBuffer, short *outlen, char *inbuf, int *consume)
+{
+ enum Mode dec_mode;
+ int read_size;
+ unsigned char analysis[32];
+ char *tpbuf;
+ tpbuf = inbuf;
+
+ memset(analysis, 0, 32);
+ //amr_read(analysis, 1);
+ analysis[0] = *tpbuf++;
+
+ dec_mode = (analysis[0] >> 3) & 0x000F;
+ read_size = amrnb_block_size[dec_mode];
+
+ //note: the logic modification of this time refer from <opencore_souce code>:
+ // when (dec_mode==15) and (read_size==0), ie,dec_mode==RX_NO_DATA
+ // still need to send data to decoder:
+ //amr_read(&analysis[1], read_size );
+ memcpy(&analysis[1], tpbuf, read_size);
+ *consume = read_size + 1;
+ /* call decoder */
+ Decoder_Interface_Decode(destate, analysis, pOutBuffer, 0);
+}
+
+//note:maybe this decoder logic has some problem and too old now ,but can not find where
+// its souce comes from, so just let maitain current situations!!:
+void amrwb_decode_frame(void* destate, short* pOutBuffer, short *outlen, char *inbuf, int *consume)
+{
+ unsigned char serial[61];
+ short mode;
+ char *tpbuf;
+ tpbuf = inbuf;
+
+ static const short amrwb_block_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};
+ //amr_read(serial, 1);
+ serial[0] = *tpbuf++;
+
+ mode = (short)((serial[0] >> 3) & 0x0F);
+
+ if (amrwb_block_size[mode] - 1 > 0) {
+ //amr_read(&serial[1], amrwb_block_size[mode] - 1 );
+ memcpy(&serial[1], tpbuf, amrwb_block_size[mode] - 1);
+ tpbuf += amrwb_block_size[mode] - 1;
+ D_IF_decode(destate, serial, pOutBuffer, 0);
+ } else {
+ *outlen = -1;
+ amr_print("[%s %d]decoder err!\n", __FUNCTION__, __LINE__);
+ // empty frame??? need clean history???
+ // memset(pOutBuffer, 0, 320*2);
+ }
+ *consume += tpbuf - inbuf;
+}
+//static int amr_decode_frame(unsigned char *buf, int maxlen, struct frame_fmt *fmt)
+int audio_dec_decode(audio_decoder_operations_t *adec_ops, char *outbuf, int *outlen, char *inbuf, int inlen)
+{
+ //amr_print("[%s:%d]enter into amr_decoder\n", __FUNCTION__,__LINE__);
+ int res = 0;
+ int consume = 0;
+ short synth[320];
+ int outputSample;
+ short out_ret = 0;
+ memset(synth, 0, 320 * sizeof(short));
+ if (SampleRateOut == 8000) {
+ outputSample = 160;
+ } else {
+ outputSample = 160 * 2;
+ }
+ amr_decode_frame_fun(destate, synth, &out_ret, inbuf, &consume);
+
+ if (out_ret < 0) {
+ *outlen = 0;
+ return consume;
+ }
+ memcpy(outbuf, (char*)synth, outputSample * 2);
+ *outlen = outputSample * 2;
+ return consume;
+}
+
+
+//static int amr_decode_init(struct frame_fmt * fmt)
+int audio_dec_init(audio_decoder_operations_t *adec_ops)
+{
+ //struct audio_info *real_data;
+ //real_data = (struct audio_info *)fmt->private_data;
+ //amr_print("\n\n[%s]BuildDate--%s BuildTime--%s", __FUNCTION__, __DATE__, __TIME__);
+ if (adec_ops->samplerate == 16000) {
+ SampleRateOut = 16000;
+ } else {
+ SampleRateOut = 8000;
+ }
+ destate = NULL;
+ destate = Decoder_Init();
+ if (SampleRateOut == 8000) {
+ amr_decode_frame_fun = amrnb_decode_frame;
+ } else {
+ amr_decode_frame_fun = amrwb_decode_frame;
+ }
+ //fmt->valid=CHANNEL_VALID | SAMPLE_RATE_VALID | DATA_WIDTH_VALID;
+ //fmt->sample_rate = SampleRateOut;
+ //fmt->channel_num = real_data->channels;
+ //fmt->data_width = 16;
+ adec_ops->nInBufSize = DefaultReadSize;
+ adec_ops->nOutBufSize = DefaultOutBufSize;
+ amr_print("amr %s ,sr %d,ch num %d\n", (SampleRateOut == 8000) ? "NB" : "WB", adec_ops->samplerate, adec_ops->channels);
+ return 0;
+}
+
+void Decoder_exit(void *st)
+{
+ if (SampleRateOut == 8000) {
+ Decoder_Interface_exit(st);
+ } else {
+ D_IF_exit(st);
+ }
+}
+
+//static int amr_decode_release(void)
+int audio_dec_release(audio_decoder_operations_t *adec_ops)
+{
+ Decoder_exit(destate);
+ return 0;
+}
+
+int audio_dec_getinfo(audio_decoder_operations_t *adec_ops, void *pAudioInfo)
+{
+ return 0;
+}
+
+#if 0
+static struct codec_type amr_codec = {
+ .name = "amr",
+ .init = amr_decode_init,
+ .release = amr_decode_release,
+ .decode_frame = amr_decode_frame,
+};
+
+
+void __used amr_codec_init(void)
+{
+ amr_print("register amr lib \n");
+ register_codec(&amr_codec);
+}
+
+CODEC_INIT(amr_codec_init);
+#endif
diff --git a/audio_codec/libamr/amr_decode.h b/audio_codec/libamr/amr_decode.h
new file mode 100644
index 0000000..a5ed286
--- a/dev/null
+++ b/audio_codec/libamr/amr_decode.h
@@ -0,0 +1,8 @@
+
+
+
+typedef struct {
+
+
+} amr_decoder_info_t;
+
diff --git a/audio_codec/libamr/dec.h b/audio_codec/libamr/dec.h
new file mode 100755
index 0000000..e25e711
--- a/dev/null
+++ b/audio_codec/libamr/dec.h
@@ -0,0 +1,18 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef DEC_H
+#define DEC_H
+
+#include "typedef.h"
+
+void D_MAIN_reset(void *st, Word16 reset_all);
+Word32 D_MAIN_init(void **spd_state);
+void D_MAIN_close(void **spd_state);
+Word32 D_MAIN_decode(Word16 mode, Word16 prms[], Word16 synth16k[],
+ void *spd_state, UWord8 frame_type);
+
+#endif
+
diff --git a/audio_codec/libamr/dec_acelp.c b/audio_codec/libamr/dec_acelp.c
new file mode 100644
index 0000000..ab13bd8
--- a/dev/null
+++ b/audio_codec/libamr/dec_acelp.c
@@ -0,0 +1,620 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+//#include <memory.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include "typedef.h"
+#include "dec_util.h"
+
+#define L_SUBFR 64 /* Subframe size */
+#define PRED_ORDER 4
+#define MEAN_ENER 30 /* average innovation energy */
+extern const Word16 D_ROM_ph_imp_low[];
+extern const Word16 D_ROM_ph_imp_mid[];
+
+
+/*
+ * D_ACELP_add_pulse
+ *
+ * Parameters:
+ * pos I: position of pulse
+ * nb_pulse I: number of pulses
+ * track I: track
+ * code O: fixed codebook
+ *
+ * Function:
+ * Add pulses to fixed codebook
+ *
+ * Returns:
+ * void
+ */
+static void D_ACELP_add_pulse(Word32 pos[], Word32 nb_pulse,
+ Word32 track, Word16 code[])
+{
+ Word32 i, k;
+
+ for (k = 0; k < nb_pulse; k++) {
+ /* i = ((pos[k] & (16-1))*NB_TRACK) + track; */
+ i = ((pos[k] & (16 - 1)) << 2) + track;
+
+ if ((pos[k] & 16) == 0) {
+ code[i] = (Word16)(code[i] + 512);
+ } else {
+ code[i] = (Word16)(code[i] - 512);
+ }
+ }
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_1p_N1
+ *
+ * Parameters:
+ * index I: pulse index
+ * N I: number of bits for position
+ * offset I: offset
+ * pos O: position of the pulse
+
+ *
+ * Function:
+ * Decode 1 pulse with N+1 bits
+ *
+ * Returns:
+ * void
+ */
+static void D_ACELP_decode_1p_N1(Word32 index, Word32 N,
+ Word32 offset, Word32 pos[])
+{
+ Word32 i, pos1, mask;
+
+ mask = ((1 << N) - 1);
+
+ /*
+ * Decode 1 pulse with N+1 bits
+ */
+ pos1 = ((index & mask) + offset);
+ i = ((index >> N) & 1);
+
+ if (i == 1) {
+ pos1 += 16;
+ }
+
+ pos[0] = pos1;
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_2p_2N1
+ *
+ * Parameters:
+ * index I: pulse index
+ * N I: number of bits for position
+ * offset I: offset
+ * pos O: position of the pulse
+ *
+ * Function:
+ * Decode 2 pulses with 2*N+1 bits
+ *
+ * Returns:
+ * void
+ */
+static void D_ACELP_decode_2p_2N1(Word32 index, Word32 N,
+ Word32 offset, Word32 pos[])
+{
+ Word32 i, pos1, pos2;
+ Word32 mask;
+
+ mask = ((1 << N) - 1);
+
+ /*
+ * Decode 2 pulses with 2*N+1 bits
+ */
+ pos1 = (((index >> N) & mask) + offset);
+ i = (index >> (2 * N)) & 1;
+ pos2 = ((index & mask) + offset);
+
+ if ((pos2 - pos1) < 0) {
+ if (i == 1) {
+ pos1 += 16;
+ } else {
+ pos2 += 16;
+ }
+ } else {
+ if (i == 1) {
+ pos1 += 16;
+ pos2 += 16;
+ }
+ }
+
+ pos[0] = pos1;
+ pos[1] = pos2;
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_3p_3N1
+ *
+ * Parameters:
+ * index I: pulse index
+ * N I: number of bits for position
+ * offset I: offset
+ * pos O: position of the pulse
+ *
+ * Function:
+ * Decode 3 pulses with 3*N+1 bits
+ *
+ * Returns:
+ * void
+ */
+static void D_ACELP_decode_3p_3N1(Word32 index, Word32 N,
+ Word32 offset, Word32 pos[])
+{
+ Word32 j, mask, idx;
+
+ /*
+ * Decode 3 pulses with 3*N+1 bits
+ */
+ mask = ((1 << ((2 * N) - 1)) - 1);
+ idx = index & mask;
+ j = offset;
+
+ if (((index >> ((2 * N) - 1)) & 1) == 1) {
+ j += (1 << (N - 1));
+ }
+
+ D_ACELP_decode_2p_2N1(idx, N - 1, j, pos);
+ mask = ((1 << (N + 1)) - 1);
+ idx = (index >> (2 * N)) & mask;
+ D_ACELP_decode_1p_N1(idx, N, offset, pos + 2);
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_4p_4N1
+ *
+ * Parameters:
+ * index I: pulse index
+ * N I: number of bits for position
+ * offset I: offset
+ * pos O: position of the pulse
+ *
+ * Function:
+ * Decode 4 pulses with 4*N+1 bits
+ *
+ * Returns:
+ * void
+ */
+static void D_ACELP_decode_4p_4N1(Word32 index, Word32 N,
+ Word32 offset, Word32 pos[])
+{
+ Word32 j, mask, idx;
+
+ /*
+ * Decode 4 pulses with 4*N+1 bits
+ */
+ mask = ((1 << ((2 * N) - 1)) - 1);
+ idx = index & mask;
+ j = offset;
+
+ if (((index >> ((2 * N) - 1)) & 1) == 1) {
+ j += (1 << (N - 1));
+ }
+
+ D_ACELP_decode_2p_2N1(idx, N - 1, j, pos);
+ mask = ((1 << ((2 * N) + 1)) - 1);
+ idx = (index >> (2 * N)) & mask;
+ D_ACELP_decode_2p_2N1(idx, N, offset, pos + 2);
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_4p_4N
+ *
+ * Parameters:
+ * index I: pulse index
+ * N I: number of bits for position
+ * offset I: offset
+ * pos O: position of the pulse
+ *
+ * Function:
+ * Decode 4 pulses with 4*N bits
+ *
+ * Returns:
+ * void
+ */
+static void D_ACELP_decode_4p_4N(Word32 index, Word32 N,
+ Word32 offset, Word32 pos[])
+{
+ Word32 j, n_1;
+
+ /*
+ * Decode 4 pulses with 4*N bits
+ */
+ n_1 = N - 1;
+ j = offset + (1 << n_1);
+
+ switch ((index >> ((4 * N) - 2)) & 3) {
+ case 0:
+ if (((index >> ((4 * n_1) + 1)) & 1) == 0) {
+ D_ACELP_decode_4p_4N1(index, n_1, offset, pos);
+ } else {
+ D_ACELP_decode_4p_4N1(index, n_1, j, pos);
+ }
+ break;
+
+ case 1:
+ D_ACELP_decode_1p_N1((index >> ((3 * n_1) + 1)), n_1, offset, pos);
+ D_ACELP_decode_3p_3N1(index, n_1, j, pos + 1);
+ break;
+
+ case 2:
+ D_ACELP_decode_2p_2N1((index >> ((2 * n_1) + 1)), n_1, offset, pos);
+ D_ACELP_decode_2p_2N1(index, n_1, j, pos + 2);
+ break;
+
+ case 3:
+ D_ACELP_decode_3p_3N1((index >> (n_1 + 1)), n_1, offset, pos);
+ D_ACELP_decode_1p_N1(index, n_1, j, pos + 3);
+ break;
+ }
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_5p_5N
+ *
+ * Parameters:
+ * index I: pulse index
+ * N I: number of bits for position
+ * offset I: offset
+ * pos O: position of the pulse
+ *
+ * Function:
+ * Decode 5 pulses with 5*N bits
+ *
+ * Returns:
+ * void
+ */
+static void D_ACELP_decode_5p_5N(Word32 index, Word32 N,
+ Word32 offset, Word32 pos[])
+{
+ Word32 j, n_1;
+ Word32 idx;
+
+ /*
+ * Decode 5 pulses with 5*N bits
+ */
+ n_1 = N - 1;
+ j = offset + (1 << n_1);
+ idx = (index >> ((2 * N) + 1));
+
+ if (((index >> ((5 * N) - 1)) & 1) == 0) {
+ D_ACELP_decode_3p_3N1(idx, n_1, offset, pos);
+ D_ACELP_decode_2p_2N1(index, N, offset, pos + 3);
+ } else {
+ D_ACELP_decode_3p_3N1(idx, n_1, j, pos);
+ D_ACELP_decode_2p_2N1(index, N, offset, pos + 3);
+ }
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_6p_6N_2
+ *
+ * Parameters:
+ * index I: pulse index
+ * N I: number of bits for position
+ * offset I: offset
+ * pos O: position of the pulse
+ *
+ * Function:
+ * Decode 6 pulses with 6*N-2 bits
+ *
+ * Returns:
+ * void
+ */
+static void D_ACELP_decode_6p_6N_2(Word32 index, Word32 N,
+ Word32 offset, Word32 pos[])
+{
+ Word32 j, n_1, offsetA, offsetB;
+
+ n_1 = N - 1;
+ j = offset + (1 << n_1);
+ offsetA = offsetB = j;
+
+ if (((index >> ((6 * N) - 5)) & 1) == 0) {
+ offsetA = offset;
+ } else {
+ offsetB = offset;
+ }
+
+ switch ((index >> ((6 * N) - 4)) & 3) {
+ case 0:
+ D_ACELP_decode_5p_5N(index >> N, n_1, offsetA, pos);
+ D_ACELP_decode_1p_N1(index, n_1, offsetA, pos + 5);
+ break;
+
+ case 1:
+ D_ACELP_decode_5p_5N(index >> N, n_1, offsetA, pos);
+ D_ACELP_decode_1p_N1(index, n_1, offsetB, pos + 5);
+ break;
+
+ case 2:
+ D_ACELP_decode_4p_4N(index >> ((2 * n_1) + 1), n_1, offsetA, pos);
+ D_ACELP_decode_2p_2N1(index, n_1, offsetB, pos + 4);
+ break;
+
+ case 3:
+ D_ACELP_decode_3p_3N1(index >> ((3 * n_1) + 1), n_1, offset, pos);
+ D_ACELP_decode_3p_3N1(index, n_1, j, pos + 3);
+ break;
+ }
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_2t
+ *
+ * Parameters:
+ * index I: 12 bits index
+ * code O: (Q9) algebraic (fixed) codebook excitation
+ *
+ * Function:
+ * 12 bits algebraic codebook decoder.
+ * 2 tracks x 32 positions per track = 64 samples.
+ *
+ * 12 bits --> 2 pulses in a frame of 64 samples.
+ *
+ * All pulses can have two (2) possible amplitudes: +1 or -1.
+ * Each pulse can have 32 possible positions.
+ *
+ * codevector length 64
+ * number of track 2
+ * number of position 32
+ *
+ * Returns:
+ * void
+ */
+void D_ACELP_decode_2t(Word16 index, Word16 code[])
+{
+ Word32 i0, i1;
+
+ memset(code, 0, 64 * sizeof(Word16));
+
+ /* decode the positions and signs of pulses and build the codeword */
+ i0 = (index >> 5) & 0x0000003E;
+ i1 = ((index & 0x0000001F) << 1) + 1;
+
+ if (((index >> 6) & 32) == 0) {
+ code[i0] = 512;
+ } else {
+ code[i0] = -512;
+ }
+
+ if ((index & 32) == 0) {
+ code[i1] = 512;
+ } else {
+ code[i1] = -512;
+ }
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_4t
+ *
+ * Parameters:
+ * index I: index
+ * mode I: speech mode
+ * code I: (Q9) algebraic (fixed) codebook excitation
+ *
+ * Function:
+ * 20, 36, 44, 52, 64, 72, 88 bits algebraic codebook.
+ * 4 tracks x 16 positions per track = 64 samples.
+ *
+ * 20 bits 5+5+5+5 --> 4 pulses in a frame of 64 samples.
+ * 36 bits 9+9+9+9 --> 8 pulses in a frame of 64 samples.
+ * 44 bits 13+9+13+9 --> 10 pulses in a frame of 64 samples.
+ * 52 bits 13+13+13+13 --> 12 pulses in a frame of 64 samples.
+ * 64 bits 2+2+2+2+14+14+14+14 --> 16 pulses in a frame of 64 samples.
+ * 72 bits 10+2+10+2+10+14+10+14 --> 18 pulses in a frame of 64 samples.
+ * 88 bits 11+11+11+11+11+11+11+11 --> 24 pulses in a frame of 64 samples.
+ *
+ * All pulses can have two (2) possible amplitudes: +1 or -1.
+ * Each pulse can sixteen (16) possible positions.
+ *
+ * codevector length 64
+ * number of track 4
+ * number of position 16
+ *
+ * Returns:
+ * void
+ */
+void D_ACELP_decode_4t(Word16 index[], Word16 nbbits, Word16 code[])
+{
+ Word32 k, L_index, pos[6];
+
+ memset(code, 0, 64 * sizeof(Word16));
+
+ /* decode the positions and signs of pulses and build the codeword */
+ if (nbbits == 20) {
+ for (k = 0; k < 4; k++) {
+ L_index = index[k];
+ D_ACELP_decode_1p_N1(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 1, k, code);
+ }
+ } else if (nbbits == 36) {
+ for (k = 0; k < 4; k++) {
+ L_index = index[k];
+ D_ACELP_decode_2p_2N1(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 2, k, code);
+ }
+ } else if (nbbits == 44) {
+ for (k = 0; k < 4 - 2; k++) {
+ L_index = index[k];
+ D_ACELP_decode_3p_3N1(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 3, k, code);
+ }
+
+ for (k = 2; k < 4; k++) {
+ L_index = index[k];
+ D_ACELP_decode_2p_2N1(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 2, k, code);
+ }
+ } else if (nbbits == 52) {
+ for (k = 0; k < 4; k++) {
+ L_index = index[k];
+ D_ACELP_decode_3p_3N1(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 3, k, code);
+ }
+ } else if (nbbits == 64) {
+ for (k = 0; k < 4; k++) {
+ L_index = ((index[k] << 14) + index[k + 4]);
+ D_ACELP_decode_4p_4N(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 4, k, code);
+ }
+ } else if (nbbits == 72) {
+ for (k = 0; k < 4 - 2; k++) {
+ L_index = ((index[k] << 10) + index[k + 4]);
+ D_ACELP_decode_5p_5N(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 5, k, code);
+ }
+
+ for (k = 2; k < 4; k++) {
+ L_index = ((index[k] << 14) + index[k + 4]);
+ D_ACELP_decode_4p_4N(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 4, k, code);
+ }
+ } else if (nbbits == 88) {
+ for (k = 0; k < 4; k++) {
+ L_index = ((index[k] << 11) + index[k + 4]);
+ D_ACELP_decode_6p_6N_2(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 6, k, code);
+ }
+ }
+ return;
+}
+
+
+/*
+ * D_ACELP_phase_dispersion
+ *
+ * Parameters:
+ * gain_code I: (Q0) gain of code
+ * gain_pit I: (Q14) gain of pitch
+ * code I/O: code vector
+ * mode I: level, 0=hi, 1=lo, 2=off
+ * disp_mem I/O: static memory (size = 8)
+ *
+ * Function:
+ * An adaptive anti-sparseness post-processing procedure is
+ * applied to the fixed codebook vector in order to
+ * reduce perceptual artifacts arising from the sparseness
+ * of the algebraic fixed codebook vectors with only
+ * a few non-zero samples per subframe.
+ *
+ * Returns:
+ * void
+ */
+void D_ACELP_phase_dispersion(Word16 gain_code, Word16 gain_pit, Word16 code[],
+ Word16 mode, Word16 disp_mem[])
+{
+ Word32 code2[2 * L_SUBFR] = {0};
+ Word32 i, j, state;
+ Word16 *prev_gain_pit, *prev_gain_code, *prev_state;
+
+ prev_state = disp_mem;
+ prev_gain_code = disp_mem + 1;
+ prev_gain_pit = disp_mem + 2;
+
+ if (gain_pit < 9830) { /* 0.6 in Q14 */
+ state = 0;
+ } else if (gain_pit < 14746) { /* 0.9 in Q14 */
+ state = 1;
+ } else {
+ state = 2;
+ }
+
+ for (i = 5; i > 0; i--) {
+ prev_gain_pit[i] = prev_gain_pit[i - 1];
+ }
+ prev_gain_pit[0] = gain_pit;
+
+ if ((gain_code - *prev_gain_code) > (*prev_gain_code << 1)) {
+ /* onset */
+ if (state < 2) {
+ state = state + 1;
+ }
+ } else {
+ j = 0;
+
+ for (i = 0; i < 6; i++) {
+ if (prev_gain_pit[i] < 9830) { /* 0.6 in Q14 */
+ j = (j + 1);
+ }
+ }
+
+ if (j > 2) {
+ state = 0;
+ }
+
+ if ((state - *prev_state) > 1) {
+ state = state - 1;
+ }
+ }
+ *prev_gain_code = gain_code;
+ *prev_state = (Word16)state;
+
+ /* circular convolution */
+ state = state + mode; /* level of dispersion */
+
+ if (state == 0) {
+ for (i = 0; i < L_SUBFR; i++) {
+ if (code[i] != 0) {
+ for (j = 0; j < L_SUBFR; j++) {
+ code2[i + j] = code2[i + j] +
+ (((code[i] * D_ROM_ph_imp_low[j]) + 0x4000) >> 15);
+ }
+ }
+ }
+ } else if (state == 1) {
+ for (i = 0; i < L_SUBFR; i++) {
+ if (code[i] != 0) {
+ for (j = 0; j < L_SUBFR; j++) {
+ code2[i + j] = code2[i + j] +
+ (((code[i] * D_ROM_ph_imp_mid[j]) + 0x4000) >> 15);
+ }
+ }
+ }
+ }
+
+ if (state < 2) {
+ for (i = 0; i < L_SUBFR; i++) {
+ code[i] = (Word16)(code2[i] + code2[i + L_SUBFR]);
+ }
+ }
+
+ return;
+}
diff --git a/audio_codec/libamr/dec_acelp.h b/audio_codec/libamr/dec_acelp.h
new file mode 100755
index 0000000..ac39c57
--- a/dev/null
+++ b/audio_codec/libamr/dec_acelp.h
@@ -0,0 +1,17 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef DEC_ACELP_H
+#define DEC_ACELP_H
+
+#include "typedef.h"
+
+void D_ACELP_decode_2t(Word16 index, Word16 code[]);
+void D_ACELP_decode_4t(Word16 index[], Word16 nbbits, Word16 code[]);
+void D_ACELP_phase_dispersion(Word16 gain_code, Word16 gain_pit, Word16 code[],
+ Word16 mode, Word16 disp_mem[]);
+
+#endif
+
diff --git a/audio_codec/libamr/dec_dtx.c b/audio_codec/libamr/dec_dtx.c
new file mode 100644
index 0000000..f6c9caf
--- a/dev/null
+++ b/audio_codec/libamr/dec_dtx.c
@@ -0,0 +1,683 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <stdlib.h>
+#include <memory.h>
+#include <math.h>
+#include "typedef.h"
+#include "dec_dtx.h"
+#include "dec_lpc.h"
+#include "dec_util.h"
+
+
+#define MAX_31 (Word32)0x3FFFFFFF
+#define L_FRAME 256 /* Frame size */
+#define RX_SPEECH_LOST 2
+#define RX_SPEECH_BAD 3
+#define RX_SID_FIRST 4
+#define RX_SID_UPDATE 5
+#define RX_SID_BAD 6
+#define RX_NO_DATA 7
+#define ISF_GAP 128 /* 50 */
+#define D_DTX_MAX_EMPTY_THRESH 50
+#define GAIN_FACTOR 75
+#define ISF_FACTOR_LOW 256
+#define ISF_FACTOR_STEP 2
+#define ISF_DITH_GAP 448
+#define D_DTX_HANG_CONST 7 /* yields eight frames of SP HANGOVER */
+#define D_DTX_ELAPSED_FRAMES_THRESH (24 + 7 - 1)
+#define RANDOM_INITSEED 21845 /* own random init value */
+
+
+/*
+ * D_DTX_reset
+ *
+ * Parameters:
+ * st O: state struct
+ *
+ * Function:
+ * Initializes state memory
+ *
+ * Returns:
+ * non-zero with error, zero for ok
+ */
+int D_DTX_reset(D_DTX_State *st, const Word16 *isf_init)
+{
+ Word32 i;
+
+ if (st == (D_DTX_State*)NULL) {
+ return(-1);
+ }
+ st->mem_since_last_sid = 0;
+ st->mem_true_sid_period_inv = (1 << 13); /* 0.25 in Q15 */
+ st->mem_log_en = 3500;
+ st->mem_log_en_prev = 3500;
+
+ /* low level noise for better performance in DTX handover cases */
+ st->mem_cng_seed = RANDOM_INITSEED;
+ st->mem_hist_ptr = 0;
+
+ /* Init isf_hist[] and decoder log frame energy */
+ memcpy(st->mem_isf, isf_init, M * sizeof(Word16));
+ memcpy(st->mem_isf_prev, isf_init, M * sizeof(Word16));
+
+ for (i = 0; i < D_DTX_HIST_SIZE; i++) {
+ memcpy(&st->mem_isf_buf[i * M], isf_init, M * sizeof(Word16));
+ st->mem_log_en_buf[i] = 3500;
+ }
+ st->mem_dtx_hangover_count = D_DTX_HANG_CONST;
+ st->mem_dec_ana_elapsed_count = 127;
+ st->mem_sid_frame = 0;
+ st->mem_valid_data = 0;
+ st->mem_dtx_hangover_added = 0;
+ st->mem_dtx_global_state = SPEECH;
+ st->mem_data_updated = 0;
+ st->mem_dither_seed = RANDOM_INITSEED;
+ st->mem_cn_dith = 0;
+
+ return(0);
+}
+
+
+/*
+ * D_DTX_init
+ *
+ * Parameters:
+ * st I/O: state struct
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * non-zero with error, zero for ok
+ */
+int D_DTX_init(D_DTX_State **st, const Word16 *isf_init)
+{
+ D_DTX_State *s;
+
+ if (st == (D_DTX_State**)NULL) {
+ return(-1);
+ }
+
+ *st = NULL;
+
+ /* allocate memory */
+ if ((s = (D_DTX_State*)malloc(sizeof(D_DTX_State))) == NULL) {
+ return(-1);
+ }
+
+ D_DTX_reset(s, isf_init);
+ *st = s;
+
+ return(0);
+}
+
+
+/*
+ * D_DTX_exit
+ *
+ * Parameters:
+ * state I/0: State struct
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * void
+ */
+void D_DTX_exit(D_DTX_State **st)
+{
+ if (st == NULL || *st == NULL) {
+ return;
+ }
+
+ /* deallocate memory */
+ free(*st);
+ *st = NULL;
+
+ return;
+}
+
+
+/*
+ * D_DTX_rx_handler
+ *
+ * Parameters:
+ * st I/O: State struct
+ * frame_type I: Frame type
+ *
+ * Function:
+ * Analyze received frame
+ *
+ * Table of new SPD synthesis states
+ *
+ * | previous SPD_synthesis_state
+ * Incoming |
+ * frame_type | SPEECH | DTX | D_DTX_MUTE
+ * ---------------------------------------------------------------
+ * RX_SPEECH_GOOD , | | |
+ * RX_SPEECH_PR_DEGRADED | SPEECH | SPEECH | SPEECH
+ * ----------------------------------------------------------------
+ * RX_SPEECH_BAD, | SPEECH | DTX | D_DTX_MUTE
+ * ----------------------------------------------------------------
+ * RX_SID_FIRST, | DTX | DTX/(D_DTX_MUTE)| D_DTX_MUTE
+ * ----------------------------------------------------------------
+ * RX_SID_UPDATE, | DTX | DTX | DTX
+ * ----------------------------------------------------------------
+ * RX_SID_BAD, | DTX | DTX/(D_DTX_MUTE)| D_DTX_MUTE
+ * ----------------------------------------------------------------
+ * RX_NO_DATA, | SPEECH | DTX/(D_DTX_MUTE)| D_DTX_MUTE
+ * RX_SPARE |(class2 garb.)| |
+ * ----------------------------------------------------------------
+ *
+ * Returns:
+ * new state
+ */
+UWord8 D_DTX_rx_handler(D_DTX_State *st, UWord8 frame_type)
+{
+ UWord8 newState;
+ UWord8 encState;
+
+ /* DTX if SID frame or previously in DTX{_MUTE}
+ * and (NO_RX OR BAD_SPEECH)
+ */
+ if ((frame_type == RX_SID_FIRST) | (frame_type == RX_SID_UPDATE) |
+ (frame_type == RX_SID_BAD) | (((st->mem_dtx_global_state == DTX) |
+ (st->mem_dtx_global_state == D_DTX_MUTE)) & ((frame_type == RX_NO_DATA) |
+ (frame_type == RX_SPEECH_BAD) | (frame_type == RX_SPEECH_LOST)))) {
+ newState = DTX;
+
+ /* stay in mute for these input types */
+ if ((st->mem_dtx_global_state == D_DTX_MUTE) &
+ ((frame_type == RX_SID_BAD) | (frame_type == RX_SID_FIRST) |
+ (frame_type == RX_SPEECH_LOST) | (frame_type == RX_NO_DATA))) {
+ newState = D_DTX_MUTE;
+ }
+
+ /* evaluate if noise parameters are too old */
+ /* since_last_sid is reset when CN parameters have been updated */
+ st->mem_since_last_sid = D_UTIL_saturate(st->mem_since_last_sid + 1);
+
+ /* no update of sid parameters in DTX for a Word32 while */
+ if ((frame_type != RX_SID_UPDATE) &&
+ (st->mem_since_last_sid > D_DTX_MAX_EMPTY_THRESH)) {
+ newState = D_DTX_MUTE;
+ }
+ } else {
+ newState = SPEECH;
+ st->mem_since_last_sid = 0;
+ }
+
+ /*
+ * reset the decAnaElapsed Counter when receiving CNI data the first
+ * time, to robustify counter missmatch after handover
+ * this might delay the bwd CNI analysis in the new decoder slightly.
+ */
+ if ((st->mem_data_updated == 0) & (frame_type == RX_SID_UPDATE)) {
+ st->mem_dec_ana_elapsed_count = 0;
+ }
+
+ /*
+ * update the SPE-SPD DTX hangover synchronization
+ * to know when SPE has added dtx hangover
+ */
+ st->mem_dec_ana_elapsed_count++;
+
+ /* saturate */
+ if (st->mem_dec_ana_elapsed_count > 127) {
+ st->mem_dec_ana_elapsed_count = 127;
+ }
+
+ st->mem_dtx_hangover_added = 0;
+
+ if ((frame_type == RX_SID_FIRST) | (frame_type == RX_SID_UPDATE) |
+ (frame_type == RX_SID_BAD) | (frame_type == RX_NO_DATA)) {
+ encState = DTX;
+ } else {
+ encState = SPEECH;
+ }
+
+ if (encState == SPEECH) {
+ st->mem_dtx_hangover_count = D_DTX_HANG_CONST;
+ } else {
+ if (st->mem_dec_ana_elapsed_count > D_DTX_ELAPSED_FRAMES_THRESH) {
+ st->mem_dtx_hangover_added = 1;
+ st->mem_dec_ana_elapsed_count = 0;
+ st->mem_dtx_hangover_count = 0;
+ } else if (st->mem_dtx_hangover_count == 0) {
+ st->mem_dec_ana_elapsed_count = 0;
+ } else {
+ st->mem_dtx_hangover_count--;
+ }
+ }
+
+ if (newState != SPEECH) {
+ /*
+ * DTX or D_DTX_MUTE
+ * CN data is not in a first SID, first SIDs are marked as SID_BAD
+ * but will do backwards analysis if a hangover period has been added
+ * according to the state machine above
+ */
+ st->mem_sid_frame = 0;
+ st->mem_valid_data = 0;
+
+ if (frame_type == RX_SID_FIRST) {
+ st->mem_sid_frame = 1;
+ } else if (frame_type == RX_SID_UPDATE) {
+ st->mem_sid_frame = 1;
+ st->mem_valid_data = 1;
+ } else if (frame_type == RX_SID_BAD) {
+ st->mem_sid_frame = 1;
+ st->mem_dtx_hangover_added = 0; /* use old data */
+ }
+ }
+
+ return newState;
+
+ /* newState is used by both SPEECH AND DTX synthesis routines */
+}
+
+
+/*
+ * D_DTX_cn_dithering
+ *
+ * Parameters:
+ * isf I/O: CN ISF vector
+ * L_log_en_int I/O: energy parameter
+ * dither_seed I/O: random seed
+ *
+ * Function:
+ * Confort noise dithering
+ *
+ * Returns:
+ * void
+ */
+static void D_DTX_cn_dithering(Word16 isf[M], Word32 *L_log_en_int,
+ Word16 *dither_seed)
+{
+ Word32 temp, temp1, i, dither_fac, rand_dith, rand_dith2;
+
+ /* Insert comfort noise dithering for energy parameter */
+ rand_dith = D_UTIL_random(dither_seed) >> 1;
+ rand_dith2 = D_UTIL_random(dither_seed) >> 1;
+ rand_dith = rand_dith + rand_dith2;
+ *L_log_en_int = *L_log_en_int + ((rand_dith * GAIN_FACTOR) << 1);
+
+ if (*L_log_en_int < 0) {
+ *L_log_en_int = 0;
+ }
+
+ /* Insert comfort noise dithering for spectral parameters (ISF-vector) */
+ dither_fac = ISF_FACTOR_LOW;
+ rand_dith = D_UTIL_random(dither_seed) >> 1;
+ rand_dith2 = D_UTIL_random(dither_seed) >> 1;
+ rand_dith = rand_dith + rand_dith2;
+ temp = isf[0] + (((rand_dith * dither_fac) + 0x4000) >> 15);
+
+ /* Make sure that isf[0] will not get negative values */
+ if (temp < ISF_GAP) {
+ isf[0] = ISF_GAP;
+ } else {
+ isf[0] = (Word16)temp;
+ }
+
+ for (i = 1; i < M - 1; i++) {
+ dither_fac = dither_fac + ISF_FACTOR_STEP;
+ rand_dith = D_UTIL_random(dither_seed) >> 1;
+ rand_dith2 = D_UTIL_random(dither_seed) >> 1;
+ rand_dith = rand_dith + rand_dith2;
+ temp = isf[i] + (((rand_dith * dither_fac) + 0x4000) >> 15);
+ temp1 = temp - isf[i - 1];
+
+ /* Make sure that isf spacing remains at least ISF_DITH_GAP Hz */
+ if (temp1 < ISF_DITH_GAP) {
+ isf[i] = (Word16)(isf[i - 1] + ISF_DITH_GAP);
+ } else {
+ isf[i] = (Word16)temp;
+ }
+ }
+
+ /* Make sure that isf[M-2] will not get values above 16384 */
+ if (isf[M - 2] > 16384) {
+ isf[M - 2] = 16384;
+ }
+
+ return;
+}
+
+
+/*
+ * D_DTX_exe
+ *
+ * Parameters:
+ * st I/O: state struct
+ * exc2 O: CN excitation
+ * new_state I: New DTX state
+ * prms I: Vector of synthesis parameters
+ * isf O: CN ISF vector
+ *
+ * Function:
+ * Confort noise generation
+ *
+ * Returns:
+ * void
+ */
+void D_DTX_exe(D_DTX_State *st, Word16 *exc2, Word16 new_state, Word16 isf[],
+ Word16 **prms)
+{
+
+ Word32 i, j, L_tmp, ptr;
+ Word32 exp0, int_fac;
+ Word32 gain;
+ Word32 L_isf[M], L_log_en_int, level32, ener32;
+ Word16 log_en_index;
+ Word16 tmp_int_length;
+ Word16 exp, log_en_int_e, log_en_int_m, level;
+
+
+ /*
+ * This function is called if synthesis state is not SPEECH.
+ * The globally passed inputs to this function are
+ * st->sid_frame
+ * st->valid_data
+ * st->dtxHangoverAdded
+ * new_state (SPEECH, DTX, D_DTX_MUTE)
+ */
+ if ((st->mem_dtx_hangover_added != 0) & (st->mem_sid_frame != 0)) {
+ /* sid_first after dtx hangover period
+ * or sid_upd after dtxhangover
+ * consider twice the last frame
+ */
+ ptr = st->mem_hist_ptr + 1;
+
+ if (ptr == D_DTX_HIST_SIZE) {
+ ptr = 0;
+ }
+
+ memcpy(&st->mem_isf_buf[ptr * M], &st->mem_isf_buf[st->mem_hist_ptr * M],
+ M * sizeof(Word16));
+
+ st->mem_log_en_buf[ptr] = st->mem_log_en_buf[st->mem_hist_ptr];
+
+ /* compute mean log energy and isf from decoded signal (SID_FIRST) */
+ st->mem_log_en = 0;
+ memset(L_isf, 0, M * sizeof(Word32));
+
+ /* average energy and isf */
+ for (i = 0; i < D_DTX_HIST_SIZE; i++) {
+ /*
+ * Division by D_DTX_HIST_SIZE = 8 has been done in dtx_buffer log_en
+ * is in Q10
+ */
+ st->mem_log_en = (Word16)(st->mem_log_en + st->mem_log_en_buf[i]);
+
+ for (j = 0; j < M; j++) {
+ L_isf[j] = L_isf[j] + st->mem_isf_buf[i * M + j];
+ }
+ }
+
+ /* st->log_en in Q9 */
+ st->mem_log_en = (Word16)(st->mem_log_en >> 1);
+
+ /*
+ * Add 2 in Q9, in order to have only positive values for Pow2
+ * this value is subtracted back after Pow2 function
+ */
+ st->mem_log_en = (Word16)(st->mem_log_en + 1024);
+
+ if (st->mem_log_en < 0) {
+ st->mem_log_en = 0;
+ }
+
+ for (j = 0; j < M; j++) {
+ st->mem_isf[j] = (Word16)(L_isf[j] >> 3); /* divide by 8 */
+ }
+ }
+
+ if (st->mem_sid_frame != 0) {
+ /*
+ * Set old SID parameters, always shift
+ * even if there is no new valid_data
+ */
+ memcpy(st->mem_isf_prev, st->mem_isf, M * sizeof(Word16));
+ st->mem_log_en_prev = st->mem_log_en;
+
+ if (st->mem_valid_data != 0) { /* new data available (no CRC) */
+ /* st->true_sid_period_inv = 1.0f/st->since_last_sid; */
+
+ /*
+ * Compute interpolation factor, since the division only works
+ * for values of since_last_sid < 32 we have to limit
+ * the interpolation to 32 frames
+ */
+ tmp_int_length = st->mem_since_last_sid;
+
+ if (tmp_int_length > 32) {
+ tmp_int_length = 32;
+ }
+
+ if (tmp_int_length >= 2) {
+ st->mem_true_sid_period_inv =
+ (Word16)(0x2000000 / (tmp_int_length << 10));
+ } else {
+ st->mem_true_sid_period_inv = 1 << 14; /* 0.5 it Q15 */
+ }
+
+ D_LPC_isf_noise_d(*prms, st->mem_isf);
+ (*prms) += 5;
+ log_en_index = *(*prms)++;
+
+ /* read background noise stationarity information */
+ st->mem_cn_dith = *(*prms)++;
+
+ /*
+ * st->log_en = (Float32)log_en_index / 2.625 - 2.0;
+ * log2(E) in Q9 (log2(E) lies in between -2:22)
+ */
+ st->mem_log_en = (Word16)(log_en_index << (15 - 6));
+
+ /* Divide by 2.625 */
+ st->mem_log_en = (Word16)((st->mem_log_en * 12483) >> 15);
+
+ /*
+ * Subtract 2 in Q9 is done later, after Pow2 function
+ * no interpolation at startup after coder reset
+ * or when SID_UPD has been received right after SPEECH
+ */
+ if ((st->mem_data_updated == 0) ||
+ (st->mem_dtx_global_state == SPEECH)) {
+ memcpy(st->mem_isf_prev, st->mem_isf, M * sizeof(Word16));
+ st->mem_log_en_prev = st->mem_log_en;
+ }
+ } /* endif valid_data */
+ } /* endif sid_frame */
+
+ if ((st->mem_sid_frame != 0) && (st->mem_valid_data != 0)) {
+ st->mem_since_last_sid = 0;
+ }
+
+ /* Interpolate SID info */
+ if (st->mem_since_last_sid < 32) {
+ int_fac = st->mem_since_last_sid << 10; /* Q10 */
+ } else {
+ int_fac = 32767;
+ }
+ /* Q10 * Q15 -> Q10 */
+ int_fac = (int_fac * st->mem_true_sid_period_inv) >> 15;
+
+ /* Maximize to 1.0 in Q10 */
+ if (int_fac > 1024) {
+ int_fac = 1024;
+ }
+ int_fac = int_fac << 4; /* Q10 -> Q14 */
+ L_log_en_int = (int_fac * st->mem_log_en) << 1; /* Q14 * Q9 -> Q24 */
+
+ for (i = 0; i < M; i++) {
+ /* Q14 * Q15 -> Q14 */
+ isf[i] = (Word16)((int_fac * st->mem_isf[i]) >> 15);
+ }
+ int_fac = 16384 - int_fac; /* 1-k in Q14 */
+
+ /* ( Q14 * Q9 -> Q24 ) + Q24 -> Q24 */
+ L_log_en_int = L_log_en_int + ((int_fac * st->mem_log_en_prev) << 1);
+
+ for (i = 0; i < M; i++) {
+ /* Q14 + (Q14 * Q15 -> Q14) -> Q14 */
+ L_tmp = isf[i] + ((int_fac * st->mem_isf_prev[i]) >> 15);
+ isf[i] = (Word16)(L_tmp << 1); /* Q14 -> Q15 */
+ }
+
+ /* If background noise is non-stationary, insert comfort noise dithering */
+ if (st->mem_cn_dith != 0) {
+ D_DTX_cn_dithering(isf, &L_log_en_int, &st->mem_dither_seed);
+ }
+
+ /* L_log_en_int corresponds to log2(E)+2 in Q24, i.e log2(gain)+1 in Q25 */
+ L_log_en_int = (L_log_en_int >> 9); /* Q25 -> Q16 */
+
+ /* Find integer part */
+ log_en_int_e = (Word16)((L_log_en_int) >> 16);
+
+ /* Find fractional part */
+ log_en_int_m = (Word16)((L_log_en_int - (log_en_int_e << 16)) >> 1);
+
+ /*
+ * Subtract 2 from L_log_en_int in Q9,
+ * i.e divide the gain by 2 (energy by 4)
+ * Add 16 in order to have the result of pow2 in Q16
+ */
+ log_en_int_e = (Word16)(log_en_int_e + (16 - 1));
+
+ /* level = (Float32)( pow( 2.0f, log_en ) ); */
+ level32 = D_UTIL_pow2(log_en_int_e, log_en_int_m); /* Q16 */
+ exp0 = D_UTIL_norm_l(level32);
+ level32 = (level32 << exp0); /* level in Q31 */
+ exp0 = (15 - exp0);
+ level = (Word16)(level32 >> 16); /* level in Q15 */
+
+ /* generate white noise vector */
+ for (i = 0; i < L_FRAME; i++) {
+ exc2[i] = (Word16)((D_UTIL_random(&(st->mem_cng_seed)) >> 4));
+ }
+
+ /* gain = level / sqrt(ener) * sqrt(L_FRAME) */
+ /* energy of generated excitation */
+ ener32 = D_UTIL_dot_product12(exc2, exc2, L_FRAME, &exp);
+ D_UTIL_normalised_inverse_sqrt(&ener32, &exp);
+ gain = ener32 >> 16;
+ gain = (level * gain) >> 15; /* gain in Q15 */
+
+ /* Multiply by sqrt(L_FRAME)=16, i.e. shift left by 4 */
+ exp = (Word16)(exp0 + exp + 4);
+
+ if (exp >= 0) {
+ for (i = 0; i < L_FRAME; i++) {
+ L_tmp = (exc2[i] * gain) >> 15; /* Q0 * Q15 */
+ exc2[i] = (Word16)(L_tmp << exp);
+ }
+ } else {
+ exp = (Word16) - exp;
+
+ for (i = 0; i < L_FRAME; i++) {
+ L_tmp = (exc2[i] * gain) >> 15; /* Q0 * Q15 */
+ exc2[i] = (Word16)(L_tmp >> exp);
+ }
+ }
+
+ if (new_state == D_DTX_MUTE) {
+ /*
+ * mute comfort noise as it has been quite a long time since
+ * last SID update was performed
+ */
+ tmp_int_length = st->mem_since_last_sid;
+
+ if (tmp_int_length > 32) {
+ tmp_int_length = 32;
+ }
+
+ /* safety guard against division by zero */
+ if (tmp_int_length <= 0) {
+ tmp_int_length = 8;
+ }
+ st->mem_true_sid_period_inv = D_UTIL_saturate((0x02000000 / (tmp_int_length << 10)));
+ st->mem_since_last_sid = 0;
+ st->mem_log_en_prev = st->mem_log_en;
+
+ /* subtract 1/8 in Q9 (energy), i.e -3/8 dB */
+ st->mem_log_en = D_UTIL_saturate(st->mem_log_en - 64);
+ }
+
+ /* reset interpolation length timer if data has been updated. */
+ if ((st->mem_sid_frame != 0) && ((st->mem_valid_data != 0) ||
+ ((st->mem_valid_data == 0) && (st->mem_dtx_hangover_added) != 0))) {
+ st->mem_since_last_sid = 0;
+ st->mem_data_updated = 1;
+ }
+
+ return;
+}
+
+
+/*
+ * D_DTX_activity_update
+ *
+ * Parameters:
+ * st I/O: state struct
+ * isf O: ISF vector
+ * exc O: excitation
+ *
+ * Function:
+ * Confort noise generation
+ *
+ * Returns:
+ * void
+ */
+void D_DTX_activity_update(D_DTX_State *st, Word16 isf[], Word16 exc[])
+{
+
+ Word32 L_frame_en, log_en;
+ Word32 i;
+ Word16 log_en_e, log_en_m;
+
+ st->mem_hist_ptr = (Word16)(st->mem_hist_ptr + 1);
+
+ if (st->mem_hist_ptr == D_DTX_HIST_SIZE) {
+ st->mem_hist_ptr = 0;
+ }
+
+ memcpy(&st->mem_isf_buf[st->mem_hist_ptr * M], isf, M * sizeof(Word16));
+
+ /* compute log energy based on excitation frame energy in Q0 */
+ L_frame_en = 0;
+
+ for (i = 0; i < L_FRAME; i++) {
+ L_frame_en = L_frame_en + (exc[i] * exc[i]);
+ if (L_frame_en > MAX_31) {
+ L_frame_en = MAX_31;
+ break;
+ }
+ }
+
+ /*
+ * log_en =
+ * (Float32)log10(L_frame_en/(Float32)L_FRAME)/(Float32)log10(2.0f);
+ */
+ D_UTIL_log2(L_frame_en, &log_en_e, &log_en_m);
+
+ /*
+ * convert exponent and mantissa to Word16 Q7.
+ * Q7 is used to simplify averaging in dtx_enc
+ */
+ log_en = log_en_e << 7; /* Q7 */
+ log_en = log_en + (log_en_m >> (15 - 7));
+
+ /* Divide by L_FRAME = 256, i.e subtract 8 in Q7 = 1024 */
+ log_en = log_en - 1024;
+
+ /* insert into log energy buffer */
+ st->mem_log_en_buf[st->mem_hist_ptr] = (Word16)log_en;
+
+ return;
+}
diff --git a/audio_codec/libamr/dec_dtx.h b/audio_codec/libamr/dec_dtx.h
new file mode 100644
index 0000000..b8219bc
--- a/dev/null
+++ b/audio_codec/libamr/dec_dtx.h
@@ -0,0 +1,49 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef DEC_DTX_H
+#define DEC_DTX_H
+
+#include "typedef.h"
+
+#define M 16 /* Order of LP filter */
+#define SPEECH 0
+#define DTX 1
+#define D_DTX_MUTE 2
+#define D_DTX_HIST_SIZE 8
+
+typedef struct {
+ Word16 mem_isf_buf[M * D_DTX_HIST_SIZE]; /* ISF vector history (8 frames)*/
+ Word16 mem_isf[M]; /* ISF vector */
+ Word16 mem_isf_prev[M]; /* Previous ISF vector */
+ Word16 mem_log_en_buf[D_DTX_HIST_SIZE];/* logarithmic frame energy history*/
+ Word16 mem_true_sid_period_inv; /* inverse of true SID update rate */
+ Word16 mem_log_en; /* logarithmic frame energy */
+ Word16 mem_log_en_prev; /* previous logarithmic frame energy */
+ Word16 mem_cng_seed; /* Comfort noise excitation seed */
+ Word16 mem_hist_ptr; /* index to beginning of LSF history */
+ Word16 mem_dither_seed; /* comfort noise dithering seed */
+ Word16 mem_cn_dith; /* background noise stationarity information*/
+ Word16 mem_since_last_sid; /* number of frames since last SID frame */
+
+ UWord8 mem_dec_ana_elapsed_count;/* counts elapsed speech frames after DTX*/
+ UWord8 mem_dtx_global_state; /* DTX state flags */
+ UWord8 mem_data_updated; /* flags CNI updates */
+ UWord8 mem_dtx_hangover_count;/* counts down in hangover period */
+ UWord8 mem_sid_frame; /* flags SID frames */
+ UWord8 mem_valid_data; /* flags SID frames containing valid data */
+ UWord8 mem_dtx_hangover_added;/* flags hangover period at end of speech */
+
+} D_DTX_State;
+
+int D_DTX_init(D_DTX_State **st, const Word16 *isf_init);
+int D_DTX_reset(D_DTX_State *st, const Word16 *isf_init);
+void D_DTX_exit(D_DTX_State **st);
+UWord8 D_DTX_rx_handler(D_DTX_State *st, UWord8 frame_type);
+void D_DTX_exe(D_DTX_State *st, Word16 *exc2, Word16 new_state,
+ Word16 isf[], Word16 **prms);
+void D_DTX_activity_update(D_DTX_State *st, Word16 isf[], Word16 exc[]);
+
+#endif
diff --git a/audio_codec/libamr/dec_gain.c b/audio_codec/libamr/dec_gain.c
new file mode 100644
index 0000000..aa69cf2
--- a/dev/null
+++ b/audio_codec/libamr/dec_gain.c
@@ -0,0 +1,853 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <memory.h>
+#include "typedef.h"
+#include "dec_util.h"
+
+#define L_SUBFR 64 /* Subframe size */
+#define L_LTPHIST 5
+#define ONE_PER_3 10923
+#define ONE_PER_LTPHIST 6554
+#define UP_SAMP 4
+#define L_INTERPOL2 16
+
+extern const Word16 D_ROM_inter4_2[];
+extern const Word16 D_ROM_pdown_unusable[];
+extern const Word16 D_ROM_pdown_usable[];
+extern const Word16 D_ROM_cdown_unusable[];
+extern const Word16 D_ROM_cdown_usable[];
+extern const Word16 D_ROM_qua_gain6b[];
+extern const Word16 D_ROM_qua_gain7b[];
+
+/*
+ * D_GAIN_init
+ *
+ * Parameters:
+ * mem O: static memory
+ *
+ * Function:
+ * Initialisation of 2nd order quantiser energy predictor.
+ *
+ * Returns:
+ * void
+ */
+void D_GAIN_init(Word16 *mem)
+{
+
+ /* 4nd order quantizer energy predictor (init to -14.0 in Q10) */
+ mem[0] = -14336; /* past_qua_en[0] */
+ mem[1] = -14336; /* past_qua_en[1] */
+ mem[2] = -14336; /* past_qua_en[2] */
+ mem[3] = -14336; /* past_qua_en[3] */
+ /*
+ * mem[4] = 0; past_gain_pit
+ * mem[5] = 0; past_gain_code
+ * mem[6] = 0; prev_gc
+ * mem[7 - 11] = 0; pbuf[i]
+ * mem[12 - 16] = 0; gbuf[i]
+ * mem[17 - 21] = 0; pbuf2[i]
+ */
+ memset(&mem[4], 0, 18 * sizeof(Word16));
+
+ mem[22] = 21845; /* seed */
+ return;
+}
+
+
+/*
+ * D_GAIN_median
+ *
+ * Parameters:
+ * buf I: previous gains
+ *
+ * Function:
+ * Median of gains
+ *
+ * Returns:
+ * median of 5 previous gains
+ */
+static Word16 D_GAIN_median(Word16 x[])
+{
+ Word16 x1, x2, x3, x4, x5;
+ Word16 tmp;
+ x1 = x[ - 2];
+ x2 = x[ - 1];
+ x3 = x[0];
+ x4 = x[1];
+ x5 = x[2];
+
+ if (x2 < x1) {
+ tmp = x1;
+ x1 = x2;
+ x2 = tmp;
+ }
+
+ if (x3 < x1) {
+ tmp = x1;
+ x1 = x3;
+ x3 = tmp;
+ }
+
+ if (x4 < x1) {
+ tmp = x1;
+ x1 = x4;
+ x4 = tmp;
+ }
+
+ if (x5 < x1) {
+ x5 = x1;
+ }
+
+ if (x3 < x2) {
+ tmp = x2;
+ x2 = x3;
+ x3 = tmp;
+ }
+
+ if (x4 < x2) {
+ tmp = x2;
+ x2 = x4;
+ x4 = tmp;
+ }
+
+ if (x5 < x2) {
+ x5 = x2;
+ }
+
+ if (x4 < x3) {
+ x3 = x4;
+ }
+
+ if (x5 < x3) {
+ x3 = x5;
+ }
+
+ return(x3);
+}
+
+
+/*
+ * D_GAIN_decode
+ *
+ * Parameters:
+ * index I: Quantization index
+ * nbits I: number of bits (6 or 7)
+ * code I: Innovative code vector
+ * L_subfr I: Subframe size
+ * gain_pit O: (Q14) Quantized pitch gain
+ * gain_code O: (Q16) Quantized codebook gain
+ * bfi I: Bad frame indicator
+ * prev_bfi I: Previous BF indicator
+ * state I: State of BFH
+ * unusable_frame I: UF indicator
+ * vad_hist I: number of non-speech frames
+ * mem I/O: static memory (4 words)
+ *
+ *
+ * Function:
+ * Decoding of pitch and codebook gains
+ *
+ * Returns:
+ * void
+ */
+void D_GAIN_decode(Word16 index, Word16 nbits, Word16 code[], Word16 *gain_pit,
+ Word32 *gain_cod, Word16 bfi, Word16 prev_bfi,
+ Word16 state, Word16 unusable_frame, Word16 vad_hist,
+ Word16 *mem)
+{
+
+ Word32 gcode0, qua_ener, L_tmp;
+ const Word16 * p;
+ Word16 *past_gain_pit, *past_gain_code, *past_qua_en, *prev_gc;
+ Word16 *gbuf, *pbuf, *pbuf2;
+ Word16 i, tmp, exp, frac, exp_gcode0, gcode_inov;
+ Word16 g_code;
+
+ past_qua_en = mem;
+ past_gain_pit = mem + 4;
+ past_gain_code = mem + 5;
+ prev_gc = mem + 6;
+ pbuf = mem + 7;
+ gbuf = mem + 12;
+ pbuf2 = mem + 17;
+
+ /*
+ * Find energy of code and compute:
+ *
+ * L_tmp = 1.0 / sqrt(energy of code/ L_subfr)
+ */
+ L_tmp = D_UTIL_dot_product12(code, code, L_SUBFR, &exp);
+ exp = (Word16)(exp - (18 + 6)); /* exp: -18 (code in Q9), -6 (/L_subfr) */
+ D_UTIL_normalised_inverse_sqrt(&L_tmp, &exp);
+
+ if (exp > 3) {
+ L_tmp <<= (exp - 3);
+ } else {
+ L_tmp >>= (3 - exp);
+ }
+
+ gcode_inov = (Word16)(L_tmp >> 16); /* g_code_inov in Q12 */
+
+ /*
+ * Case of erasure.
+ */
+ if (bfi != 0) {
+ tmp = D_GAIN_median(&pbuf[2]);
+ *past_gain_pit = tmp;
+
+ if (*past_gain_pit > 15565) {
+ *past_gain_pit = 15565; /* 0.95 in Q14 */
+ }
+
+ if (unusable_frame != 0) {
+ *gain_pit =
+ (Word16)((D_ROM_pdown_unusable[state] * *past_gain_pit) >> 15);
+ } else {
+ *gain_pit =
+ (Word16)((D_ROM_pdown_usable[state] * *past_gain_pit) >> 15);
+ }
+
+ tmp = D_GAIN_median(&gbuf[2]);
+
+ if (vad_hist > 2) {
+ *past_gain_code = tmp;
+ } else {
+ if (unusable_frame != 0) {
+ *past_gain_code =
+ (Word16)((D_ROM_cdown_unusable[state] * tmp) >> 15);
+ } else {
+ *past_gain_code =
+ (Word16)((D_ROM_cdown_usable[state] * tmp) >> 15);
+ }
+ }
+
+ /* update table of past quantized energies */
+ L_tmp = past_qua_en[0] + past_qua_en[1] + past_qua_en[2] + past_qua_en[3];
+ qua_ener = L_tmp >> 2;
+ qua_ener = qua_ener - 3072; /* -3 in Q10 */
+
+ if (qua_ener < - 14336) {
+ qua_ener = -14336; /* -14 in Q10 */
+ }
+
+ past_qua_en[3] = past_qua_en[2];
+ past_qua_en[2] = past_qua_en[1];
+ past_qua_en[1] = past_qua_en[0];
+ past_qua_en[0] = (Word16)qua_ener;
+
+ for (i = 1; i < 5; i++) {
+ gbuf[i - 1] = gbuf[i];
+ }
+ gbuf[4] = *past_gain_code;
+
+ for (i = 1; i < 5; i++) {
+ pbuf[i - 1] = pbuf[i];
+ }
+ pbuf[4] = *past_gain_pit;
+
+ /* adjust gain according to energy of code */
+ /* past_gain_code(Q3) * gcode_inov(Q12) => Q16 */
+ *gain_cod = (*past_gain_code * gcode_inov) << 1;
+
+ return;
+ }
+
+ /*
+ * Compute gcode0.
+ * = Sum(i=0,1) pred[i]*past_qua_en[i] + mean_ener - ener_code
+ */
+
+ /* MEAN_ENER in Q24 = 0x1e000000 */
+ /* MA prediction coeff = {0.5, 0.4, 0.3, 0.2} in Q13 */
+ L_tmp = 0xF000000 + (4096 * past_qua_en[0]); /* Q13*Q10 -> Q24 */
+ L_tmp = L_tmp + (3277 * past_qua_en[1]); /* Q13*Q10 -> Q24 */
+ L_tmp = L_tmp + (2458 * past_qua_en[2]); /* Q13*Q10 -> Q24 */
+ L_tmp = L_tmp + (1638 * past_qua_en[3]); /* Q13*Q10 -> Q24 */
+ gcode0 = L_tmp >> 15; /* From Q24 to Q8 */
+
+ /*
+ * gcode0 = pow(10.0, gcode0/20)
+ * = pow(2, 3.321928*gcode0/20)
+ * = pow(2, 0.166096*gcode0)
+ */
+ L_tmp = (gcode0 * 5443) >> 7;
+ /* *0.166096 in Q15 -> Q24, From Q24 to Q16 */
+ D_UTIL_l_extract(L_tmp, &exp_gcode0, &frac);
+ /* Extract exponant of gcode0 */
+ gcode0 = D_UTIL_pow2(14, frac); /* Put 14 as exponant so that */
+
+ /*
+ * output of Pow2() will be:
+ * 16384 < Pow2() <= 32767
+ */
+ exp_gcode0 = (Word16)(exp_gcode0 - 14);
+
+ /* Read the quantized gains */
+ if (nbits == 6) {
+ p = &D_ROM_qua_gain6b[(index << 1)];
+ } else {
+ p = &D_ROM_qua_gain7b[(index << 1)];
+ }
+
+ *gain_pit = *p++; /* selected pitch gain in Q14 */
+ g_code = *p++; /* selected code gain in Q11 */
+ L_tmp = g_code * gcode0;
+ exp_gcode0 += 5;
+
+ if (exp_gcode0 >= 0) {
+ *gain_cod = L_tmp << exp_gcode0; /* gain of code in Q16 */
+ } else {
+ *gain_cod = L_tmp >> -exp_gcode0; /* gain of code in Q16 */
+ }
+
+ if (prev_bfi == 1) {
+ L_tmp = (*prev_gc * 5120) << 1; /* prev_gc(Q3) * 1.25(Q12) = Q16 */
+
+ /* if((*gain_cod > ((*prev_gc) * 1.25)) && (*gain_cod > 100.0)) */
+ if ((*gain_cod > L_tmp) & (*gain_cod > 6553600)) {
+ *gain_cod = L_tmp;
+ }
+ }
+
+ /* keep past gain code in Q3 for frame erasure (can saturate) */
+ L_tmp = (*gain_cod + 0x1000) >> 13;
+
+ if (L_tmp < 32768) {
+ *past_gain_code = (Word16)L_tmp;
+ } else {
+ *past_gain_code = 32767;
+ }
+
+ *past_gain_pit = *gain_pit;
+ *prev_gc = *past_gain_code;
+
+ for (i = 1; i < 5; i++) {
+ gbuf[i - 1] = gbuf[i];
+ }
+ gbuf[4] = *past_gain_code;
+
+ for (i = 1; i < 5; i++) {
+ pbuf[i - 1] = pbuf[i];
+ }
+ pbuf[4] = *past_gain_pit;
+
+ for (i = 1; i < 5; i++) {
+ pbuf2[i - 1] = pbuf2[i];
+ }
+ pbuf2[4] = *past_gain_pit;
+
+ /* adjust gain according to energy of code */
+ D_UTIL_l_extract(*gain_cod, &exp, &frac);
+ L_tmp = D_UTIL_mpy_32_16(exp, frac, gcode_inov);
+
+ if (L_tmp < 0xFFFFFFF) {
+ *gain_cod = (L_tmp << 3); /* gcode_inov in Q12 */
+ } else {
+ *gain_cod = 0x7FFFFFFF;
+ }
+
+ /*
+ * qua_ener = 20*log10(g_code)
+ * = 6.0206*log2(g_code)
+ * = 6.0206*(log2(g_codeQ11) - 11)
+ */
+ L_tmp = (Word32)(g_code);
+ D_UTIL_log2(L_tmp, &exp, &frac);
+ exp = (Word16)(exp - 11);
+ L_tmp = D_UTIL_mpy_32_16(exp, frac, 24660); /* x 6.0206 in Q12 */
+ qua_ener = L_tmp >> 3; /* result in Q10 */
+
+ /* update table of past quantized energies */
+ past_qua_en[3] = past_qua_en[2];
+ past_qua_en[2] = past_qua_en[1];
+ past_qua_en[1] = past_qua_en[0];
+ past_qua_en[0] = (Word16)qua_ener;
+
+ return;
+}
+
+
+/*
+ * D_GAIN_adaptive_control
+ *
+ * Parameters:
+ * sig_in I: postfilter input signal
+ * sig_out I/O: postfilter output signal
+ * l_trm I: subframe size
+ *
+ * Function:
+ * Adaptive gain control is used to compensate for
+ * the gain difference between the non-emphasized excitation and
+ * emphasized excitation.
+ *
+ * Returns:
+ * void
+ */
+void D_GAIN_adaptive_control(Word16 *sig_in, Word16 *sig_out, Word16 l_trm)
+{
+ Word32 s, temp, i, exp;
+ Word32 gain_in, gain_out, g0;
+
+ /* calculate gain_out with exponent */
+ temp = sig_out[0] >> 2;
+ s = temp * temp;
+
+ for (i = 1; i < l_trm; i++) {
+ temp = sig_out[i] >> 2;
+ s += temp * temp;
+ }
+
+ s <<= 1;
+
+ if (s == 0) {
+ return;
+ }
+ exp = (D_UTIL_norm_l(s) - 1);
+
+ if (exp >= 0) {
+ gain_out = ((s << exp) + 0x8000) >> 16;
+ } else {
+ gain_out = ((s >> -exp) + 0x8000) >> 16;
+ }
+
+ /* calculate gain_in with exponent */
+ temp = sig_in[0] >> 2;
+ s = temp * temp;
+
+ for (i = 1; i < l_trm; i++) {
+ temp = sig_in[i] >> 2;
+ s += temp * temp;
+ }
+
+ s <<= 1;
+
+ if (s == 0) {
+ g0 = 0;
+ } else {
+ i = D_UTIL_norm_l(s);
+ s = ((s << i) + 0x8000) >> 16;
+
+ if ((s < 32768) & (s > 0)) {
+ gain_in = s;
+ } else {
+ gain_in = 32767;
+ }
+ exp = exp - i;
+
+ /*
+ * g0 = sqrt(gain_in/gain_out)
+ */
+ s = (gain_out << 15) / gain_in;
+ s = s << (7 - exp); /* s = gain_out / gain_in */
+ s = D_UTIL_inverse_sqrt(s);
+ g0 = ((s << 9) + 0x8000) >> 16;
+ }
+
+ /* sig_out(n) = gain(n) sig_out(n) */
+ for (i = 0; i < l_trm; i++) {
+ s = (sig_out[i] * g0) >> 13;
+ sig_out[i] = D_UTIL_saturate(s);
+ }
+
+ return;
+}
+
+
+/*
+ * D_GAIN_insert_lag
+ *
+ * Parameters:
+ * array I/O: pitch lag history
+ * n I: history size
+ * x I: lag value
+ *
+ * Function:
+ * Insert lag into correct location
+ *
+ * Returns:
+ * void
+ */
+static void D_GAIN_insert_lag(Word16 array[], Word32 n, Word16 x)
+{
+ Word32 i;
+
+ for (i = n - 1; i >= 0; i--) {
+ if (x < array[i]) {
+ array[i + 1] = array[i];
+ } else {
+ break;
+ }
+ }
+
+ array[i + 1] = x;
+}
+
+
+/*
+ * D_GAIN_sort_lag
+ *
+ * Parameters:
+ * array I/O: pitch lag history
+ * n I: history size
+ *
+ * Function:
+ * Sorting of the lag history
+ *
+ * Returns:
+ * void
+ */
+static void D_GAIN_sort_lag(Word16 array[], Word16 n)
+{
+ Word32 i;
+
+ for (i = 0; i < n; i++) {
+ D_GAIN_insert_lag(array, i, array[i]);
+ }
+}
+
+
+/*
+ * D_GAIN_lag_concealment_init
+ *
+ * Parameters:
+ * lag_hist O: pitch lag history
+ *
+ * Function:
+ * Initialise lag history to 64
+ *
+ * Returns:
+ * void
+ */
+void D_GAIN_lag_concealment_init(Word16 lag_hist[])
+{
+ Word32 i;
+
+ for (i = 0; i < L_LTPHIST; i++) {
+ lag_hist[i] = 64;
+ }
+}
+
+
+/*
+ * D_GAIN_lag_concealment
+ *
+ * Parameters:
+ * gain_hist I: gain history
+ * lag_hist I: pitch lag history
+ * T0 O: current lag
+ * old_T0 I: previous lag
+ * seed I/O: seed for random
+ * unusable_frame I: lost frame
+ *
+ * Function:
+ * Concealment of LTP lags during bad frames
+ *
+ * Returns:
+ * void
+ */
+void D_GAIN_lag_concealment(Word16 gain_hist[], Word16 lag_hist[],
+ Word32 *T0, Word16 *old_T0, Word16 *seed,
+ Word16 unusable_frame)
+{
+ Word32 i, lagDif, tmp, tmp2, D2, meanLag = 0;
+ Word16 lag_hist2[L_LTPHIST] = {0};
+ Word16 maxLag, minLag, lastLag;
+ Word16 minGain, lastGain, secLastGain;
+ Word16 D;
+
+ /*
+ * Is lag index such that it can be aplied directly
+ * or does it has to be subtituted
+ */
+ lastGain = gain_hist[4];
+ secLastGain = gain_hist[3];
+ lastLag = lag_hist[0];
+
+ /* SMALLEST history lag */
+ minLag = lag_hist[0];
+
+ for (i = 1; i < L_LTPHIST; i++) {
+ if (lag_hist[i] < minLag) {
+ minLag = lag_hist[i];
+ }
+ }
+
+ /* BIGGEST history lag */
+ maxLag = lag_hist[0];
+
+ for (i = 1; i < L_LTPHIST; i++) {
+ if (lag_hist[i] > maxLag) {
+ maxLag = lag_hist[i];
+ }
+ }
+
+ /* SMALLEST history gain */
+ minGain = gain_hist[0];
+
+ for (i = 1; i < L_LTPHIST; i++) {
+ if (gain_hist[i] < minGain) {
+ minGain = gain_hist[i];
+ }
+ }
+
+ /* Difference between MAX and MIN lag */
+ lagDif = maxLag - minLag;
+
+ if (unusable_frame != 0) {
+ /*
+ * LTP-lag for RX_SPEECH_LOST
+ * Recognition of the LTP-history
+ */
+ if ((minGain > 8192) & (lagDif < 10)) {
+ *T0 = *old_T0;
+ } else if ((lastGain > 8192) && (secLastGain > 8192)) {
+ *T0 = lag_hist[0];
+ } else {
+ /*
+ * SORT
+ * The sorting of the lag history
+ */
+ for (i = 0; i < L_LTPHIST; i++) {
+ lag_hist2[i] = lag_hist[i];
+ }
+ D_GAIN_sort_lag(lag_hist2, 5);
+
+ /*
+ * Lag is weighted towards bigger lags
+ * and random variation is added
+ */
+ lagDif = (lag_hist2[4] - lag_hist2[2]);
+
+ if (lagDif > 40) {
+ lagDif = 40;
+ }
+
+ D = D_UTIL_random(seed); /* D={-1, ...,1} */
+
+ /* D2={-lagDif/2..lagDif/2} */
+ tmp = lagDif >> 1;
+ D2 = (tmp * D) >> 15;
+ tmp = (lag_hist2[2] + lag_hist2[3]) + lag_hist2[4];
+ *T0 = ((tmp * ONE_PER_3) >> 15) + D2;
+ }
+
+ /* New lag is not allowed to be bigger or smaller than last lag values */
+ if (*T0 > maxLag) {
+ *T0 = maxLag;
+ }
+
+ if (*T0 < minLag) {
+ *T0 = minLag;
+ }
+ } else {
+ /*
+ * LTP-lag for RX_BAD_FRAME
+ * MEAN lag
+ */
+ meanLag = 0;
+
+ for (i = 0; i < L_LTPHIST; i++) {
+ meanLag = meanLag + lag_hist[i];
+ }
+
+ meanLag = (meanLag * ONE_PER_LTPHIST) >> 15;
+ tmp = *T0 - maxLag;
+ tmp2 = *T0 - lastLag;
+
+ if ((lagDif < 10) & (*T0 > (minLag - 5)) & (tmp < 5)) {
+ *T0 = *T0;
+ } else if ((lastGain > 8192) & (secLastGain > 8192) & ((tmp2 > - 10)
+ & (tmp2 < 10))) {
+ *T0 = *T0;
+ } else if ((minGain < 6554) & (lastGain == minGain) & ((*T0 > minLag)
+ & (*T0 < maxLag))) {
+ *T0 = *T0;
+ } else if ((lagDif < 70) & (*T0 > minLag) & (*T0 < maxLag)) {
+ *T0 = *T0;
+ } else if ((*T0 > meanLag) & (*T0 < maxLag)) {
+ *T0 = *T0;
+ } else {
+ if ((minGain > 8192) & (lagDif < 10)) {
+ *T0 = lag_hist[0];
+ } else if ((lastGain > 8192) & (secLastGain > 8192)) {
+ *T0 = lag_hist[0];
+ } else {
+ /*
+ * SORT
+ * The sorting of the lag history
+ */
+ for (i = 0; i < L_LTPHIST; i++) {
+ lag_hist2[i] = lag_hist[i];
+ }
+
+ D_GAIN_sort_lag(lag_hist2, 5);
+
+ /*
+ * Lag is weighted towards bigger lags
+ * and random variation is added
+ */
+ lagDif = lag_hist2[4] - lag_hist2[2];
+
+ if (lagDif > 40) {
+ lagDif = 40;
+ }
+
+ D = D_UTIL_random(seed); /* D={-1,.., 1} */
+
+ /* D2={-lagDif/2..lagDif/2} */
+ tmp = lagDif >> 1;
+ D2 = (tmp * D) >> 15;
+ tmp = (lag_hist2[2] + lag_hist2[3]) + lag_hist2[4];
+ *T0 = ((tmp * ONE_PER_3) >> 15) + D2;
+ }
+
+ /*
+ * New lag is not allowed to be bigger or
+ * smaller than last lag values
+ */
+ if (*T0 > maxLag) {
+ *T0 = maxLag;
+ }
+
+ if (*T0 < minLag) {
+ *T0 = minLag;
+ }
+ }
+ }
+}
+
+
+/*
+ * D_GAIN_adaptive_codebook_excitation
+ *
+ * Parameters:
+ * exc I/O: excitation buffer
+ * T0 I: integer pitch lag
+ * frac I: fraction of lag
+ *
+ * Function:
+ * Compute the result of Word32 term prediction with fractional
+ * interpolation of resolution 1/4.
+ *
+ * Returns:
+ * interpolated signal (adaptive codebook excitation)
+ */
+void D_GAIN_adaptive_codebook_excitation(Word16 exc[], Word32 T0, Word32 frac)
+{
+ Word32 i, j, k, sum;
+ Word16 *x;
+
+ x = &exc[ - T0];
+ frac = -(frac);
+
+ if (frac < 0) {
+ frac = (frac + UP_SAMP);
+ x--;
+ }
+ x = x - L_INTERPOL2 + 1;
+
+ for (j = 0; j < L_SUBFR + 1; j++) {
+ sum = 0L;
+
+ for (i = 0, k = ((UP_SAMP - 1) - frac); i < 2 * L_INTERPOL2; i++,
+ k += UP_SAMP) {
+ sum += x[i] * D_ROM_inter4_2[k];
+ }
+ sum = (sum + 0x2000) >> 14;
+
+ exc[j] = D_UTIL_saturate(sum);
+
+ x++;
+ }
+ return;
+}
+
+
+/*
+ * D_GAIN_pitch_sharpening
+ *
+ * Parameters:
+ * x I/O: impulse response (or algebraic code)
+ * pit_lag I: pitch lag
+ * sharp I: (Q15) pitch sharpening factor
+ *
+ * Function:
+ * Performs Pitch sharpening routine for one subframe.
+ *
+ * Returns:
+ * void
+ */
+void D_GAIN_pitch_sharpening(Word16 *x, Word32 pit_lag, Word16 sharp)
+{
+ Word32 i;
+ Word32 tmp;
+
+ for (i = pit_lag; i < L_SUBFR; i++) {
+ tmp = x[i] << 15;
+ tmp += x[i - pit_lag] * sharp;
+ x[i] = (Word16)((tmp + 0x4000) >> 15);
+ }
+ return;
+}
+
+
+/*
+ * D_GAIN_find_voice_factor
+ *
+ * Parameters:
+ * exc I: pitch excitation
+ * Q_exc I: exc format
+ * gain_pit I: (Q14) gain of pitch
+ * code I: (Q9) fixed codebook excitation
+ * gain_code I: (Q0) gain of code
+ * L_subfr I: subframe length
+ *
+ * Function:
+ * Find the voicing factor.
+ *
+ * Returns:
+ * (Q15) 1=voice to -1=unvoiced
+ */
+Word16 D_GAIN_find_voice_factor(Word16 exc[], Word16 Q_exc,
+ Word16 gain_pit, Word16 code[],
+ Word16 gain_code, Word16 L_subfr)
+{
+
+ Word32 tmp, ener1, ener2, i;
+ Word16 exp, exp1, exp2;
+
+ ener1 = (D_UTIL_dot_product12(exc, exc, L_subfr, &exp1)) >> 16;
+ exp1 = (Word16)(exp1 - (Q_exc + Q_exc));
+ tmp = (gain_pit * gain_pit) << 1;
+ exp = D_UTIL_norm_l(tmp);
+ tmp = (tmp << exp) >> 16;
+ ener1 = (ener1 * tmp) >> 15;
+ exp1 = (Word16)((exp1 - exp) - 10); /* 10 -> gain_pit Q14 to Q9 */
+ ener2 = D_UTIL_dot_product12(code, code, L_subfr, &exp2) >> 16;
+ exp = D_UTIL_norm_s(gain_code);
+ tmp = gain_code << exp;
+ tmp = (tmp * tmp) >> 15;
+ ener2 = (ener2 * tmp) >> 15;
+ exp2 = (Word16)(exp2 - (exp << 1));
+ i = exp1 - exp2;
+
+ if (i >= 0) {
+ ener1 = ener1 >> 1;
+ ener2 = ener2 >> (i + 1);
+ } else if (i > (-16)) {
+ ener1 = ener1 >> (1 - i);
+ ener2 = ener2 >> 1;
+ } else {
+ ener1 = 0;
+ ener2 = ener2 >> 1;
+ }
+
+ tmp = ener1 - ener2;
+ ener1 = (ener1 + ener2) + 1;
+ tmp = (tmp << 15) / ener1;
+
+ return((Word16)tmp);
+}
diff --git a/audio_codec/libamr/dec_gain.h b/audio_codec/libamr/dec_gain.h
new file mode 100644
index 0000000..42e4524
--- a/dev/null
+++ b/audio_codec/libamr/dec_gain.h
@@ -0,0 +1,28 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef DEC_GAIN_H
+#define DEC_GAIN_H
+
+#include "typedef.h"
+
+void D_GAIN_init(Word16 *mem);
+void D_GAIN_decode(Word16 index, Word16 nbits, Word16 code[], Word16 *gain_pit,
+ Word32 *gain_cod, Word16 bfi, Word16 prev_bfi,
+ Word16 state, Word16 unusable_frame, Word16 vad_hist,
+ Word16 *mem);
+void D_GAIN_adaptive_control(Word16 *sig_in, Word16 *sig_out, Word16 l_trm);
+void D_GAIN_lag_concealment_init(Word16 lag_hist[]);
+void D_GAIN_lag_concealment(Word16 gain_hist[], Word16 lag_hist[], Word32 *T0,
+ Word16 *old_T0, Word16 *seed,
+ Word16 unusable_frame);
+void D_GAIN_adaptive_codebook_excitation(Word16 exc[], Word32 T0, Word32 frac);
+void D_GAIN_pitch_sharpening(Word16 *x, Word32 pit_lag, Word16 sharp);
+Word16 D_GAIN_find_voice_factor(Word16 exc[], Word16 Q_exc, Word16 gain_pit,
+ Word16 code[], Word16 gain_code,
+ Word16 L_subfr);
+
+#endif
+
diff --git a/audio_codec/libamr/dec_if.c b/audio_codec/libamr/dec_if.c
new file mode 100644
index 0000000..00f57cf
--- a/dev/null
+++ b/audio_codec/libamr/dec_if.c
@@ -0,0 +1,834 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <stdlib.h>
+#include <memory.h>
+#include "typedef.h"
+#include "dec_if.h"
+#include "if_rom.h"
+#include "dec.h"
+
+#define L_FRAME16k 320 /* Frame size at 16kHz */
+#define MODE_7k 0 /* modes */
+#define MODE_9k 1
+#define MODE_12k 2
+#define MODE_14k 3
+#define MODE_16k 4
+#define MODE_18k 5
+#define MODE_20k 6
+#define MODE_23k 7
+#define MODE_24k 8
+#define MRDTX 9
+#define NUM_OF_MODES 10
+#define LOST_FRAME 14
+#define MRNO_DATA 15
+#define EHF_MASK (Word16)0x0008 /* homing frame pattern */
+
+typedef struct {
+ Word16 reset_flag_old; /* previous was homing frame */
+ Word16 prev_ft; /* previous frame type */
+ Word16 prev_mode; /* previous mode */
+ void *decoder_state; /* Points decoder state */
+} WB_dec_if_state;
+
+#ifdef ENABLE_CPU2_DECODER
+CPU2_DATA_START
+#endif
+
+Word16 nb_of_param_first[NUM_OF_SPMODES] = {
+ 9, 14, 15,
+ 15, 15, 19,
+ 19, 19, 19
+};
+
+#ifdef ENABLE_CPU2_DECODER
+CPU2_DATA_END
+#endif
+
+extern const Word16 mode_7k[];
+extern const Word16 mode_9k[];
+extern const Word16 mode_12k[];
+extern const Word16 mode_14k[];
+extern const Word16 mode_16k[];
+extern const Word16 mode_18k[];
+extern const Word16 mode_20k[];
+extern const Word16 mode_23k[];
+extern const Word16 mode_24k[];
+extern const Word16 mode_DTX[];
+
+extern const Word16 nb_of_param[];
+
+extern const Word16 dfh_M7k[];
+extern const Word16 dfh_M9k[];
+extern const Word16 dfh_M12k[];
+extern const Word16 dfh_M14k[];
+extern const Word16 dfh_M16k[];
+extern const Word16 dfh_M18k[];
+extern const Word16 dfh_M20k[];
+extern const Word16 dfh_M23k[];
+extern const Word16 dfh_M24k[];
+
+/* overall table with the parameters of the
+ decoder homing frames for all modes */
+
+extern const Word16 *dhf[10];
+
+/*
+ * Decoder_Interface_Homing_Frame_test
+ *
+ * Parameters:
+ * input_frame I: input parameters
+ * mode I: speech mode
+ *
+ * Function:
+ * Check parameters for matching homing frame
+ *
+ * Returns:
+ * If homing frame
+ */
+Word16 D_IF_homing_frame_test(Word16 input_frame[], Word16 mode)
+{
+
+ if (mode != MODE_24k) {
+ /* perform test for COMPLETE parameter frame */
+ return (Word16)!memcmp(input_frame, dhf[mode], nb_of_param[mode] * sizeof(Word16));
+ } else {
+ /* discard high-band energy */
+ return (Word16)!(
+ (memcmp(input_frame, dhf[MODE_24k], 19 * sizeof(Word16))) |
+ (memcmp(input_frame + 20, dhf[MODE_24k] + 20, 11 * sizeof(Word16))) |
+ (memcmp(input_frame + 32, dhf[MODE_24k] + 32, 11 * sizeof(Word16))) |
+ (memcmp(input_frame + 44, dhf[MODE_24k] + 44, 11 * sizeof(Word16))));
+
+ }
+}
+
+
+Word16 D_IF_homing_frame_test_first(Word16 input_frame[], Word16 mode)
+{
+ /* perform test for FIRST SUBFRAME of parameter frame ONLY */
+ return (Word16)!memcmp(input_frame, dhf[mode], nb_of_param_first[mode] * sizeof(Word16));
+}
+
+#ifdef IF2
+/*
+ * D_IF_conversion
+ *
+ *
+ * Parameters:
+ * param O: AMR parameters
+ * stream I: input bitstream
+ * frame_type O: frame type
+ * speech_mode O: speech mode in DTX
+ * fqi O: frame quality indicator
+ *
+ * Function:
+ * Unpacks IF2 octet stream
+ *
+ * Returns:
+ * mode used mode
+ */
+Word16 D_IF_conversion(Word16 *param, UWord8 *stream, UWord8 *frame_type,
+ Word16 *speech_mode, Word16 *fqi)
+{
+ Word32 mode;
+ Word32 j;
+ Word16 const *mask;
+
+ memset(param, 0, PRMNO_24k << 1);
+ mode = *stream >> 4;
+ *fqi = (Word16)((*stream >> 3) & 0x1);
+ *stream <<= (HEADER_SIZE - 1);
+
+ switch (mode) {
+ case MRDTX:
+ mask = mode_DTX;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_SID; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ /* get SID type bit */
+
+ *frame_type = RX_SID_FIRST;
+
+ if (*stream & 0x80) {
+ *frame_type = RX_SID_UPDATE;
+ }
+
+ *stream <<= 1;
+
+ /* speech mode indicator */
+ *speech_mode = (Word16)(*stream >> 4);
+ break;
+
+ case MRNO_DATA:
+ *frame_type = RX_NO_DATA;
+ break;
+
+ case LOST_FRAME:
+ *frame_type = RX_SPEECH_LOST;
+ break;
+
+ case MODE_7k:
+ mask = mode_7k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_7k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_9k:
+ mask = mode_9k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_9k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_12k:
+ mask = mode_12k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_12k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_14k:
+ mask = mode_14k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_14k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_16k:
+ mask = mode_16k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_16k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_18k:
+ mask = mode_18k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_18k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_20k:
+ mask = mode_20k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_20k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_23k:
+ mask = mode_23k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_23k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_24k:
+ mask = mode_24k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_24k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ default:
+ *frame_type = RX_SPEECH_LOST;
+ *fqi = 0;
+ break;
+
+ }
+
+ if (*fqi == 0) {
+ if (*frame_type == RX_SPEECH_GOOD) {
+ *frame_type = RX_SPEECH_BAD;
+ }
+ if ((*frame_type == RX_SID_FIRST) | (*frame_type == RX_SID_UPDATE)) {
+ *frame_type = RX_SID_BAD;
+ }
+ }
+
+ return (Word16)mode;
+}
+
+#else
+
+/*
+ * D_IF_mms_conversion
+ *
+ *
+ * Parameters:
+ * param O: AMR parameters
+ * stream I: input bitstream
+ * frame_type O: frame type
+ * speech_mode O: speech mode in DTX
+ * fqi O: frame quality indicator
+ *
+ * Function:
+ * Unpacks MMS formatted octet stream (see RFC 3267, section 5.3)
+ *
+ * Returns:
+ * mode used mode
+ */
+Word16 D_IF_mms_conversion(Word16 *param, UWord8 *stream, UWord8 *frame_type,
+ Word16 *speech_mode, Word16 *fqi)
+{
+ Word32 mode;
+ Word32 j;
+ Word16 const *mask;
+
+ memset(param, 0, PRMNO_24k << 1);
+
+ *fqi = (Word16)((*stream >> 2) & 0x01);
+ mode = (Word32)((*stream >> 3) & 0x0F);
+
+ stream++;
+
+ switch (mode) {
+ case MRDTX:
+ mask = mode_DTX;
+
+ for (j = 1; j <= NBBITS_SID; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ /* get SID type bit */
+
+ *frame_type = RX_SID_FIRST;
+
+ if (*stream & 0x80) {
+ *frame_type = RX_SID_UPDATE;
+ }
+
+ *stream <<= 1;
+
+ /* speech mode indicator */
+ *speech_mode = (Word16)(*stream >> 4);
+ break;
+
+ case MRNO_DATA:
+ *frame_type = RX_NO_DATA;
+ break;
+
+ case LOST_FRAME:
+ *frame_type = RX_SPEECH_LOST;
+ break;
+
+ case MODE_7k:
+ mask = mode_7k;
+
+ for (j = 1; j <= NBBITS_7k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_9k:
+ mask = mode_9k;
+
+ for (j = 1; j <= NBBITS_9k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_12k:
+ mask = mode_12k;
+
+ for (j = 1; j <= NBBITS_12k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_14k:
+ mask = mode_14k;
+
+ for (j = 1; j <= NBBITS_14k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_16k:
+ mask = mode_16k;
+
+ for (j = 1; j <= NBBITS_16k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_18k:
+ mask = mode_18k;
+
+ for (j = 1; j <= NBBITS_18k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_20k:
+ mask = mode_20k;
+
+ for (j = 1; j <= NBBITS_20k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_23k:
+ mask = mode_23k;
+
+ for (j = 1; j <= NBBITS_23k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_24k:
+ mask = mode_24k;
+
+ for (j = 1; j <= NBBITS_24k; j++) {
+ if (*stream & 0x80) {
+ param[*mask] = (Word16)(param[*mask] + * (mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ default:
+ *frame_type = RX_SPEECH_LOST;
+ *fqi = 0;
+ break;
+
+ }
+
+ if (*fqi == 0) {
+ if (*frame_type == RX_SPEECH_GOOD) {
+ *frame_type = RX_SPEECH_BAD;
+ }
+ if ((*frame_type == RX_SID_FIRST) | (*frame_type == RX_SID_UPDATE)) {
+ *frame_type = RX_SID_BAD;
+ }
+ }
+
+ return (Word16)mode;
+}
+
+#endif
+
+/*
+ * D_IF_decode
+ *
+ *
+ * Parameters:
+ * st B: pointer to state structure
+ * bits I: bitstream form the encoder
+ * synth O: decoder output
+ * lfi I: lost frame indicator
+ * _good_frame, _bad_frame, _lost_frame, _no_frame
+ *
+ * Function:
+ * Decoding one frame of speech. Lost frame indicator can be used
+ * to inform encoder about the problems in the received frame.
+ * _good_frame:good speech or sid frame is received.
+ * _bad_frame: frame with possible bit errors
+ * _lost_frame:speech of sid frame is lost in transmission
+ * _no_frame: indicates non-received frames in dtx-operation
+ * Returns:
+ *
+ */
+void D_IF_decode(void *st, UWord8 *bits, Word16 *synth, Word32 lfi)
+{
+ Word32 i;
+ Word16 mode = 0; /* AMR mode */
+ Word16 speech_mode = MODE_7k; /* speech mode */
+ Word16 fqi; /* frame quality indicator */
+
+ Word16 prm[PRMNO_24k]; /* AMR parameters */
+
+ UWord8 frame_type; /* frame type */
+ Word16 reset_flag = 0; /* reset flag */
+ WB_dec_if_state * s; /* pointer to structure */
+
+ s = (WB_dec_if_state*)st;
+
+ /* bits -> param, if needed */
+ if ((lfi == _good_frame) | (lfi == _bad_frame)) {
+ /* add fqi data */
+#ifdef IF2
+ *bits = (UWord8)((Word32) * bits & ~(lfi << 3));
+#else
+ *bits = (UWord8)((Word32) * bits & ~(lfi << 2));
+#endif
+ /*
+ * extract mode information and frame_type,
+ * octets to parameters
+ */
+#ifdef IF2
+ mode = D_IF_conversion(prm, bits, &frame_type, &speech_mode, &fqi);
+#else
+ mode = D_IF_mms_conversion(prm, bits, &frame_type, &speech_mode, &fqi);
+#endif
+
+ } else if (lfi == _no_frame) {
+ frame_type = RX_NO_DATA;
+ } else {
+ frame_type = RX_SPEECH_LOST;
+ }
+
+ /*
+ * if no mode information
+ * guess one from the previous frame
+ */
+ if ((frame_type == RX_SPEECH_LOST) | (frame_type == RX_NO_DATA)) {
+ mode = s->prev_mode;
+ }
+
+ if (mode == MRDTX) {
+ mode = speech_mode;
+ }
+
+ /* if homed: check if this frame is another homing frame */
+ if (s->reset_flag_old == 1) {
+ /* only check until end of first subframe */
+ reset_flag = D_IF_homing_frame_test_first(prm, mode);
+ }
+
+ /* produce encoder homing frame if homed & input=decoder homing frame */
+ if ((reset_flag != 0) && (s->reset_flag_old != 0)) {
+ for (i = 0; i < L_FRAME16k; i++) {
+ synth[i] = EHF_MASK;
+ }
+ } else {
+ D_MAIN_decode(mode, prm, synth, s->decoder_state, frame_type);
+ }
+
+ for (i = 0; i < L_FRAME16k; i++) { /* Delete the 2 LSBs (14-bit input) */
+ synth[i] = (Word16)(synth[i] & 0xfffC);
+ }
+
+ /* if not homed: check whether current frame is a homing frame */
+ if ((s->reset_flag_old == 0) & (mode < 9)) {
+ /* check whole frame */
+ reset_flag = D_IF_homing_frame_test(prm, mode);
+ }
+ /* reset decoder if current frame is a homing frame */
+ if (reset_flag != 0) {
+ D_MAIN_reset(s->decoder_state, 1);
+ }
+ s->reset_flag_old = reset_flag;
+
+ s->prev_ft = frame_type;
+ s->prev_mode = mode;
+}
+
+/*
+ * D_IF_reset
+ *
+ * Parameters:
+ * st O: state struct
+ *
+ * Function:
+ * Reset homing frame counter
+ *
+ * Returns:
+ * void
+ */
+void D_IF_reset(WB_dec_if_state *st)
+{
+ st->reset_flag_old = 1;
+ st->prev_ft = RX_SPEECH_GOOD;
+ st->prev_mode = MODE_7k; /* minimum bitrate */
+}
+
+/*
+ * D_IF_init
+ *
+ * Parameters:
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * pointer to encoder interface structure
+ */
+void *D_IF_init(void)
+{
+ WB_dec_if_state *s = NULL;
+
+ /* allocate memory */
+ if ((s = (WB_dec_if_state*)malloc(sizeof(WB_dec_if_state))) == NULL) {
+ return NULL;
+ }
+
+ D_MAIN_init(&(s->decoder_state));
+ if (s->decoder_state == NULL) {
+ free(s);
+ return NULL;
+ }
+
+ D_IF_reset(s);
+
+ return (void *)s;
+}
+
+/*
+ * D_IF_exit
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+void D_IF_exit(void *state)
+{
+ WB_dec_if_state *s;
+
+ s = (WB_dec_if_state *)state;
+
+ /* free memory */
+ D_MAIN_close(&s->decoder_state);
+ free(s);
+ state = NULL;
+}
diff --git a/audio_codec/libamr/dec_if.h b/audio_codec/libamr/dec_if.h
new file mode 100755
index 0000000..b914218
--- a/dev/null
+++ b/audio_codec/libamr/dec_if.h
@@ -0,0 +1,23 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef DEC_IF_H
+#define DEC_IF_H
+
+#include "typedef.h"
+
+#define NB_SERIAL_MAX 61 /* max serial size */
+#define L_FRAME16k 320 /* Frame size at 16kHz */
+
+#define _good_frame 0
+#define _bad_frame 1
+#define _lost_frame 2
+#define _no_frame 3
+
+void D_IF_decode(void *st, UWord8 *bits, Word16 *synth, Word32 bfi);
+void * D_IF_init(void);
+void D_IF_exit(void *state);
+
+#endif
diff --git a/audio_codec/libamr/dec_lpc.c b/audio_codec/libamr/dec_lpc.c
new file mode 100644
index 0000000..2bcf8c4
--- a/dev/null
+++ b/audio_codec/libamr/dec_lpc.c
@@ -0,0 +1,789 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <math.h>
+//#include <stdlib.h>
+#include "typedef.h"
+#include "dec_util.h"
+
+#define M 16 /* Order of LP filter */
+#define MP1 (M + 1)
+#define M16k 20
+#define NC16k (M16k / 2)
+#define MU 10923 /* Prediction factor (1.0/3.0) in Q15 */
+#define L_MEANBUF 3
+#define ALPHA 29491 /* 0. 9 in Q15 */
+#define ONE_ALPHA (32768-ALPHA) /* (1.0 - ALPHA) in Q15 */
+#define ORDER 16 /* order of linear prediction filter */
+#define ISF_GAP 128 /* 50 Hz */
+#define INV_LENGTH 2731 /* 1/12 */
+
+extern const Word16 D_ROM_dico1_isf[];
+extern const Word16 D_ROM_dico2_isf[];
+extern const Word16 D_ROM_dico21_isf_36b[];
+extern const Word16 D_ROM_dico22_isf_36b[];
+extern const Word16 D_ROM_dico23_isf_36b[];
+extern const Word16 D_ROM_dico21_isf[];
+extern const Word16 D_ROM_dico22_isf[];
+extern const Word16 D_ROM_dico23_isf[];
+extern const Word16 D_ROM_dico24_isf[];
+extern const Word16 D_ROM_dico25_isf[];
+extern const Word16 D_ROM_dico1_isf_noise[];
+extern const Word16 D_ROM_dico2_isf_noise[];
+extern const Word16 D_ROM_dico3_isf_noise[];
+extern const Word16 D_ROM_dico4_isf_noise[];
+extern const Word16 D_ROM_dico5_isf_noise[];
+extern const Word16 D_ROM_mean_isf[];
+extern const Word16 D_ROM_mean_isf_noise[];
+extern const Word16 D_ROM_cos[];
+
+
+/*
+ * D_LPC_isf_reorder
+ *
+ * Parameters:
+ * isf I/O: vector of isfs
+ * min_dist I: quantized ISFs (in frequency domain)
+ * n I: LPC order
+ *
+ * Function:
+ * To make sure that the isfs are properly order and to keep a certain
+ * minimum distance between consecutive isfs.
+ *
+ * Returns:
+ * void
+ */
+static void D_LPC_isf_reorder(Word16 *isf, Word16 min_dist, Word16 n)
+{
+ Word32 i, isf_min;
+
+ isf_min = min_dist;
+
+ for (i = 0; i < n - 1; i++) {
+ if (isf[i] < isf_min) {
+ isf[i] = (Word16)isf_min;
+ }
+ isf_min = isf[i] + min_dist;
+ }
+
+ return;
+}
+
+
+/*
+ * D_LPC_isf_noise_d
+ *
+ * Parameters:
+ * indice I: indices of the selected codebook entries
+ * isf_q O: quantized ISFs (in frequency domain)
+ *
+ * Function:
+ * Decoding of ISF parameters
+ *
+ * Returns:
+ * void
+ */
+void D_LPC_isf_noise_d(Word16 *indice, Word16 *isf_q)
+{
+ Word32 i;
+
+ for (i = 0; i < 2; i++) {
+ isf_q[i] = D_ROM_dico1_isf_noise[indice[0] * 2 + i];
+ }
+
+ for (i = 0; i < 3; i++) {
+ isf_q[i + 2] = D_ROM_dico2_isf_noise[indice[1] * 3 + i];
+ }
+
+ for (i = 0; i < 3; i++) {
+ isf_q[i + 5] = D_ROM_dico3_isf_noise[indice[2] * 3 + i];
+ }
+
+ for (i = 0; i < 4; i++) {
+ isf_q[i + 8] = D_ROM_dico4_isf_noise[indice[3] * 4 + i];
+ }
+
+ for (i = 0; i < 4; i++) {
+ isf_q[i + 12] = D_ROM_dico5_isf_noise[indice[4] * 4 + i];
+ }
+
+ for (i = 0; i < ORDER; i++) {
+ isf_q[i] = (Word16)(isf_q[i] + D_ROM_mean_isf_noise[i]);
+ }
+
+ D_LPC_isf_reorder(isf_q, ISF_GAP, ORDER);
+
+ return;
+}
+
+
+/*
+ * D_LPC_isf_isp_conversion
+ *
+ * Parameters:
+ * isp O: (Q15) isp[m] (range: -1<=val<1)
+ * isf I: (Q15) isf[m] normalized (range: 0.0 <= val <= 0.5)
+ * m I: LPC order
+ *
+ * Function:
+ * Transformation isf to isp
+ *
+ * ISP are immitance spectral pair in cosine domain (-1 to 1).
+ * ISF are immitance spectral pair in frequency domain (0 to 6400).
+ * Returns:
+ * void
+ */
+void D_LPC_isf_isp_conversion(Word16 isf[], Word16 isp[], Word16 m)
+{
+ Word32 i, ind, offset, tmp;
+
+ for (i = 0; i < m - 1; i++) {
+ isp[i] = isf[i];
+ }
+ isp[m - 1] = (Word16)(isf[m - 1] << 1);
+
+ for (i = 0; i < m; i++) {
+ ind = isp[i] >> 7; /* ind = b7-b15 of isf[i] */
+ offset = isp[i] & 0x007f; /* offset = b0-b6 of isf[i] */
+
+ /* isp[i] = table[ind]+ ((table[ind+1]-table[ind])*offset) / 128 */
+ tmp = (D_ROM_cos[ind + 1] - D_ROM_cos[ind]) * offset;
+ isp[i] = (Word16)(D_ROM_cos[ind] + (tmp >> 7));
+ }
+ return;
+}
+
+
+/*
+ * D_LPC_isp_pol_get
+ *
+ * Parameters:
+ * isp I: Immitance spectral pairs (cosine domaine)
+ * f O: the coefficients of F1 or F2
+ * n I: no of coefficients (m/2)
+ * k16 I: 16k flag
+ *
+ * Function:
+ * Find the polynomial F1(z) or F2(z) from the ISPs.
+ * This is performed by expanding the product polynomials:
+ *
+ * F1(z) = product ( 1 - 2 isp_i z^-1 + z^-2 )
+ * i=0,2,4,6,8
+ * F2(z) = product ( 1 - 2 isp_i z^-1 + z^-2 )
+ * i=1,3,5,7
+ *
+ * where isp_i are the ISPs in the cosine domain.
+ *
+ * Returns:
+ * void
+ */
+static void D_LPC_isp_pol_get(Word16 *isp, Word32 *f, Word32 n, Word16 k16)
+{
+ Word32 i, j, t0, s1, s2;
+ Word16 hi, lo;
+
+ s1 = 8388608;
+ s2 = 512;
+
+ if (k16) {
+ s1 >>= 2;
+ s2 >>= 2;
+ }
+
+ /* All computation in Q23 */
+ f[0] = s1; /* f[0] = 1.0; in Q23 */
+ f[1] = isp[0] * (-s2); /* f[1] = -2.0*isp[0] in Q23 */
+ f += 2; /* Advance f pointer */
+ isp += 2; /* Advance isp pointer */
+
+ for (i = 2; i <= n; i++) {
+ *f = f[ - 2];
+
+ for (j = 1; j < i; j++, f--) {
+ D_UTIL_l_extract(f[- 1], &hi, &lo);
+ t0 = D_UTIL_mpy_32_16(hi, lo, *isp); /* t0 = f[-1] * isp */
+ t0 = (t0 << 1);
+ *f = (*f - t0); /* *f -= t0 */
+ *f = (*f + f[ - 2]); /* *f += f[-2] */
+ }
+
+ *f = *f - (*isp * s2); /* *f -= isp << 8 */
+ f += i; /* Advance f pointer */
+ isp += 2; /* Advance isp pointer */
+ }
+
+ return;
+}
+
+
+/*
+ * D_LPC_isp_a_conversion
+ *
+ * Parameters:
+ * isp I: (Q15) Immittance spectral pairs
+ * a O: (Q12) Predictor coefficients (order = M)
+ * m I: order of LP filter
+ *
+ * Function:
+ * Convert ISPs to predictor coefficients a[]
+ *
+ * Returns:
+ * void
+ */
+void D_LPC_isp_a_conversion(Word16 isp[], Word16 a[], Word32 adaptive_scaling,
+ Word16 m)
+{
+ Word32 j, i, nc, tmax, q, q_sug, r;
+ Word32 f1[NC16k + 1], f2[NC16k];
+ Word32 t0;
+ Word16 hi, lo;
+
+ nc = m >> 1;
+
+ if (nc > 8) {
+ D_LPC_isp_pol_get(&isp[0], f1, nc, 1);
+
+ for (i = 0; i <= nc; i++) {
+ f1[i] = (f1[i] << 2);
+ }
+ } else {
+ D_LPC_isp_pol_get(&isp[0], f1, nc, 0);
+ }
+
+ if (nc > 8) {
+ D_LPC_isp_pol_get(&isp[1], f2, nc - 1, 1);
+
+ for (i = 0; i <= nc - 1; i++) {
+ f2[i] = (f2[i] << 2);
+ }
+ } else {
+ D_LPC_isp_pol_get(&isp[1], f2, nc - 1, 0);
+ }
+
+ /*
+ * Multiply F2(z) by (1 - z^-2)
+ */
+ for (i = nc - 1; i > 1; i--) {
+ f2[i] = f2[i] - f2[i - 2]; /* f2[i] -= f2[i-2]; */
+ }
+
+ /*
+ * Scale F1(z) by (1+isp[m-1]) and F2(z) by (1-isp[m-1])
+ */
+ for (i = 0; i < nc; i++) {
+ /* f1[i] *= (1.0 + isp[M-1]); */
+ D_UTIL_l_extract(f1[i], &hi, &lo);
+ t0 = D_UTIL_mpy_32_16(hi, lo, isp[m - 1]);
+ f1[i] = f1[i] + t0;
+
+ /* f2[i] *= (1.0 - isp[M-1]); */
+ D_UTIL_l_extract(f2[i], &hi, &lo);
+ t0 = D_UTIL_mpy_32_16(hi, lo, isp[m - 1]);
+ f2[i] = f2[i] - t0;
+ }
+
+ /*
+ * A(z) = (F1(z)+F2(z))/2
+ * F1(z) is symmetric and F2(z) is antisymmetric
+ */
+
+ /* a[0] = 1.0; */
+ a[0] = 4096;
+ tmax = 1;
+
+ for (i = 1, j = m - 1; i < nc; i++, j--) {
+ /* a[i] = 0.5*(f1[i] + f2[i]); */
+ t0 = f1[i] + f2[i]; /* f1[i] + f2[i] */
+ tmax |= labs(t0);
+ a[i] = (Word16)((t0 + 0x800) >> 12); /* from Q23 to Q12 and * 0.5 */
+
+ /* a[j] = 0.5*(f1[i] - f2[i]); */
+ t0 = (f1[i] - f2[i]); /* f1[i] - f2[i] */
+ tmax |= labs(t0);
+ a[j] = (Word16)((t0 + 0x800) >> 12); /* from Q23 to Q12 and * 0.5 */
+ }
+
+ /* rescale data if overflow has occured and reprocess the loop */
+
+ if (adaptive_scaling) {
+ q = 4 - D_UTIL_norm_l(tmax); /* adaptive scaling enabled */
+ } else {
+ q = 0; /* adaptive scaling disabled */
+ }
+
+ if (q > 0) {
+ q_sug = 12 + q;
+ r = 1 << (q_sug - 1);
+
+ for (i = 1, j = m - 1; i < nc; i++, j--) {
+ /* a[i] = 0.5*(f1[i] + f2[i]); */
+ t0 = f1[i] + f2[i]; /* f1[i] + f2[i] */
+ a[i] = (Word16)((t0 + r) >> q_sug); /* from Q23 to Q12 and * 0.5 */
+
+ /* a[j] = 0.5*(f1[i] - f2[i]); */
+ t0 = f1[i] - f2[i]; /* f1[i] - f2[i] */
+ a[j] = (Word16)((t0 + r) >> q_sug); /* from Q23 to Q12 and * 0.5 */
+ }
+ a[0] = (Word16)(a[0] >> q);
+ } else {
+ q_sug = 12;
+ r = 1 << (q_sug - 1);
+ q = 0;
+ }
+
+ /* a[NC] = 0.5*f1[NC]*(1.0 + isp[M-1]); */
+ D_UTIL_l_extract(f1[nc], &hi, &lo);
+ t0 = D_UTIL_mpy_32_16(hi, lo, isp[m - 1]);
+ t0 = f1[nc] + t0;
+ a[nc] = (Word16)((t0 + r) >> q_sug); /* from Q23 to Q12 and * 0.5 */
+
+ /* a[m] = isp[m-1]; */
+ a[m] = (Word16)((isp[m - 1] >> (2 + q)) + 1); /* from Q15 to Q12 */
+ a[m] = (Word16)(a[m] >> 1);
+
+ return;
+}
+
+
+/*
+ * D_LPC_a_weight
+ *
+ * Parameters:
+ * a I: LP filter coefficients
+ * ap O: weighted LP filter coefficients
+ * gamma I: weighting factor
+ * m I: order of LP filter
+ *
+ * Function:
+ * Weighting of LP filter coefficients, ap[i] = a[i] * (gamma^i).
+ *
+ * Returns:
+ * void
+ */
+void D_LPC_a_weight(Word16 a[], Word16 ap[], Word16 gamma, Word16 m)
+{
+ Word32 i, fac;
+
+ ap[0] = a[0];
+ fac = gamma;
+
+ for (i = 1; i < m; i++) {
+ ap[i] = (Word16)(((a[i] * fac) + 0x4000) >> 15);
+ fac = ((fac * gamma) + 0x4000) >> 15;
+ }
+
+ ap[m] = (Word16)(((a[m] * fac) + 0x4000) >> 15);
+
+ return;
+}
+
+
+/*
+ * D_LPC_isf_2s3s_decode
+ *
+ * Parameters:
+ * indice I: quantisation indices
+ * isf_q O: quantised ISFs in the cosine domain
+ * past_isfq I/O: past ISF quantizer
+ * isfold I: past quantised ISF
+ * isf_buf O: isf buffer
+ * bfi I: Bad frame indicator
+ *
+ * Function:
+ * Decoding of ISF parameters.
+ *
+ * Returns:
+ * void
+ */
+void D_LPC_isf_2s3s_decode(Word16 *indice, Word16 *isf_q, Word16 *past_isfq,
+ Word16 *isfold, Word16 *isf_buf, Word16 bfi)
+{
+
+ Word32 ref_isf[M];
+ Word32 L_tmp, i, j;
+ Word16 tmp;
+
+ if (bfi == 0) { /* Good frame */
+ for (i = 0; i < 9; i++) {
+ isf_q[i] = D_ROM_dico1_isf[indice[0] * 9 + i];
+ }
+
+ for (i = 0; i < 7; i++) {
+ isf_q[i + 9] = D_ROM_dico2_isf[indice[1] * 7 + i];
+ }
+
+ for (i = 0; i < 5; i++) {
+ isf_q[i] =
+ (Word16)(isf_q[i] + D_ROM_dico21_isf_36b[indice[2] * 5 + i]);
+ }
+
+ for (i = 0; i < 4; i++) {
+ isf_q[i + 5] =
+ (Word16)(isf_q[i + 5] + D_ROM_dico22_isf_36b[indice[3] * 4 + i]);
+ }
+
+ for (i = 0; i < 7; i++) {
+ isf_q[i + 9] =
+ (Word16)(isf_q[i + 9] + D_ROM_dico23_isf_36b[indice[4] * 7 + i]);
+ }
+
+ for (i = 0; i < ORDER; i++) {
+ tmp = isf_q[i];
+ isf_q[i] =
+ (Word16)((tmp + D_ROM_mean_isf[i]) + ((MU * past_isfq[i]) >> 15));
+ past_isfq[i] = tmp;
+ }
+
+ for (i = 0; i < M; i++) {
+ for (j = (L_MEANBUF - 1); j > 0; j--) {
+ isf_buf[j * M + i] = isf_buf[(j - 1) * M + i];
+ }
+ isf_buf[i] = isf_q[i];
+ }
+
+ } else {
+ /* bad frame */
+
+ for (i = 0; i < M; i++) {
+ L_tmp = D_ROM_mean_isf[i];
+
+ for (j = 0; j < L_MEANBUF; j++) {
+ L_tmp = L_tmp + isf_buf[j * M + i];
+ }
+ ref_isf[i] = (L_tmp + 0x1) >> 2;
+ }
+
+ /* use the past ISFs slightly shifted towards their mean */
+ for (i = 0; i < ORDER; i++) {
+ isf_q[i] = (Word16)((((ALPHA * isfold[i]) >> 15) +
+ ((ONE_ALPHA * ref_isf[i]) >> 15)));
+ }
+
+ /* estimate past quantized residual to be used in next frame */
+ for (i = 0; i < ORDER; i++) {
+ /* predicted ISF */
+ L_tmp = ref_isf[i] + ((past_isfq[i] * MU) >> 15);
+ /* past_isfq[i] *= 0.5 */
+ past_isfq[i] = (Word16)((isf_q[i] - L_tmp) >> 1);
+ }
+ }
+
+ D_LPC_isf_reorder(isf_q, ISF_GAP, ORDER);
+
+ return;
+}
+
+
+/*
+ * D_LPC_isf_2s5s_decode
+ *
+ * Parameters:
+ * indice I: quantization indices
+ * isf_q O: quantized ISFs in the cosine domain
+ * past_isfq I/O: past ISF quantizer
+ * isfold I: past quantized ISF
+ * isf_buf O: isf buffer
+ * bfi I: Bad frame indicator
+ *
+ * Function:
+ * Decoding of ISF parameters.
+ *
+ * Returns:
+ * void
+ */
+void D_LPC_isf_2s5s_decode(Word16 *indice, Word16 *isf_q, Word16 *past_isfq,
+ Word16 *isfold, Word16 *isf_buf, Word16 bfi)
+{
+ Word32 ref_isf[M];
+ Word32 i, j, L_tmp;
+ Word16 tmp;
+
+ if (bfi == 0) { /* Good frame */
+ for (i = 0; i < 9; i++) {
+ isf_q[i] = D_ROM_dico1_isf[indice[0] * 9 + i];
+ }
+
+ for (i = 0; i < 7; i++) {
+ isf_q[i + 9] = D_ROM_dico2_isf[indice[1] * 7 + i];
+ }
+
+ for (i = 0; i < 3; i++) {
+ isf_q[i] = (Word16)(isf_q[i] + D_ROM_dico21_isf[indice[2] * 3 + i]);
+ }
+
+ for (i = 0; i < 3; i++) {
+ isf_q[i + 3] =
+ (Word16)(isf_q[i + 3] + D_ROM_dico22_isf[indice[3] * 3 + i]);
+ }
+
+ for (i = 0; i < 3; i++) {
+ isf_q[i + 6] =
+ (Word16)(isf_q[i + 6] + D_ROM_dico23_isf[indice[4] * 3 + i]);
+ }
+
+ for (i = 0; i < 3; i++) {
+ isf_q[i + 9] =
+ (Word16)(isf_q[i + 9] + D_ROM_dico24_isf[indice[5] * 3 + i]);
+ }
+
+ for (i = 0; i < 4; i++) {
+ isf_q[i + 12] =
+ (Word16)(isf_q[i + 12] + D_ROM_dico25_isf[indice[6] * 4 + i]);
+ }
+
+ for (i = 0; i < ORDER; i++) {
+ tmp = isf_q[i];
+ isf_q[i] =
+ (Word16)((tmp + D_ROM_mean_isf[i]) + ((MU * past_isfq[i]) >> 15));
+ past_isfq[i] = tmp;
+ }
+
+
+ for (i = 0; i < M; i++) {
+ for (j = (L_MEANBUF - 1); j > 0; j--) {
+ isf_buf[j * M + i] = isf_buf[(j - 1) * M + i];
+ }
+ isf_buf[i] = isf_q[i];
+ }
+
+ } else {
+ /* bad frame */
+
+ for (i = 0; i < M; i++) {
+ L_tmp = D_ROM_mean_isf[i];
+
+ for (j = 0; j < L_MEANBUF; j++) {
+ L_tmp = L_tmp + isf_buf[j * M + i];
+ }
+
+ ref_isf[i] = (L_tmp + 0x1) >> 2;
+ }
+
+ /* use the past ISFs slightly shifted towards their mean */
+ for (i = 0; i < ORDER; i++) {
+ isf_q[i] = (Word16)(((ALPHA * isfold[i]) >> 15) +
+ ((ONE_ALPHA * ref_isf[i]) >> 15));
+ }
+
+ /* estimate past quantized residual to be used in next frame */
+ for (i = 0; i < ORDER; i++) {
+ /* predicted ISF */
+ L_tmp = ref_isf[i] + ((past_isfq[i] * MU) >> 15);
+ /* past_isfq[i] *= 0.5 */
+ past_isfq[i] = (Word16)((isf_q[i] - L_tmp) >> 1);
+ }
+ }
+
+ D_LPC_isf_reorder(isf_q, ISF_GAP, ORDER);
+
+ return;
+}
+
+
+/*
+ * D_LPC_int_isp_find
+ *
+ * Parameters:
+ * isp_old I: isps from past frame
+ * isp_new I: isps from present frame
+ * frac I: (Q15) fraction for 3 first subfr
+ * Az O: LP coefficients in 4 subframes
+ *
+ * Function:
+ * Find the interpolated ISP parameters for all subframes.
+ *
+ * Returns:
+ * void
+ */
+void D_LPC_int_isp_find(Word16 isp_old[], Word16 isp_new[],
+ const Word16 frac[], Word16 Az[])
+{
+ Word32 tmp, i, k, fac_old, fac_new;
+ Word16 isp[M];
+
+ for (k = 0; k < 3; k++) {
+ fac_new = frac[k];
+ fac_old = (32767 - fac_new) + 1; /* 1.0 - fac_new */
+
+ for (i = 0; i < M; i++) {
+ tmp = isp_old[i] * fac_old;
+ tmp += isp_new[i] * fac_new;
+ isp[i] = (Word16)((tmp + 0x4000) >> 15);
+ }
+
+ D_LPC_isp_a_conversion(isp, Az, 0, M);
+ Az += MP1;
+ }
+
+ /* 4th subframe: isp_new (frac=1.0) */
+ D_LPC_isp_a_conversion(isp_new, Az, 0, M);
+
+ return;
+}
+
+
+/*
+ * D_LPC_isf_extrapolation
+ *
+ * Parameters:
+ * HfIsf I/O: ISF vector
+ *
+ * Function:
+ * Conversion of 16th-order 12.8kHz ISF vector
+ * into 20th-order 16kHz ISF vector
+ *
+ * Returns:
+ * void
+ */
+void D_LPC_isf_extrapolation(Word16 HfIsf[])
+{
+ Word32 IsfDiff[M - 2];
+ Word32 IsfCorr[3];
+ Word32 tmp, tmp2, tmp3, mean, i;
+ Word32 MaxCorr, exp, exp2, coeff;
+ Word16 hi, lo;
+
+ HfIsf[M16k - 1] = HfIsf[M - 1];
+
+ /* Difference vector */
+ for (i = 1; i < M - 1; i++) {
+ IsfDiff[i - 1] = HfIsf[i] - HfIsf[i - 1];
+ }
+
+ tmp = 0;
+
+ /* Mean of difference vector */
+ for (i = 3; i < (M - 1); i++) {
+ tmp = tmp + (IsfDiff[i - 1] * INV_LENGTH);
+ }
+
+ mean = (tmp + 0x4000) >> 15;
+ IsfCorr[0] = 0;
+ IsfCorr[1] = 0;
+ IsfCorr[2] = 0;
+ tmp = 0;
+
+ for (i = 0; i < M - 2; i++) {
+ if (IsfDiff[i] > tmp) {
+ tmp = IsfDiff[i];
+ }
+ }
+
+ exp = D_UTIL_norm_s((Word16)tmp);
+
+ for (i = 0; i < M - 2; i++) {
+ IsfDiff[i] = IsfDiff[i] << exp;
+ }
+
+ mean = mean << exp;
+
+ for (i = 7; i < M - 2; i++) {
+ tmp2 = IsfDiff[i] - mean;
+ tmp3 = IsfDiff[i - 2] - mean;
+ tmp = (tmp2 * tmp3) << 1;
+ D_UTIL_l_extract(tmp, &hi, &lo);
+ tmp = D_UTIL_mpy_32(hi, lo, hi, lo);
+ IsfCorr[0] = (IsfCorr[0] + tmp);
+ }
+
+ for (i = 7; i < M - 2; i++) {
+ tmp2 = IsfDiff[i] - mean;
+ tmp3 = IsfDiff[i - 3] - mean;
+ tmp = (tmp2 * tmp3) << 1;
+ D_UTIL_l_extract(tmp, &hi, &lo);
+ tmp = D_UTIL_mpy_32(hi, lo, hi, lo);
+ IsfCorr[1] = (IsfCorr[1] + tmp);
+ }
+
+ for (i = 7; i < M - 2; i++) {
+ tmp2 = IsfDiff[i] - mean;
+ tmp3 = IsfDiff[i - 4] - mean;
+ tmp = (tmp2 * tmp3) << 1;
+ D_UTIL_l_extract(tmp, &hi, &lo);
+ tmp = D_UTIL_mpy_32(hi, lo, hi, lo);
+ IsfCorr[2] = (IsfCorr[2] + tmp);
+ }
+
+ if (IsfCorr[0] > IsfCorr[1]) {
+ MaxCorr = 0;
+ } else {
+ MaxCorr = 1;
+ }
+
+ if (IsfCorr[2] > IsfCorr[MaxCorr]) {
+ MaxCorr = 2;
+ }
+
+ MaxCorr = MaxCorr + 1; /* Maximum correlation of difference vector */
+
+ for (i = M - 1; i < (M16k - 1); i++) {
+ tmp = (HfIsf[i - 1 - MaxCorr] - HfIsf[i - 2 - MaxCorr]);
+ HfIsf[i] = (Word16)(HfIsf[i - 1] + tmp);
+ }
+
+ /* tmp=7965+(HfIsf[2]-HfIsf[3]-HfIsf[4])/6; */
+ tmp = HfIsf[4] + HfIsf[3];
+ tmp = HfIsf[2] - tmp;
+ tmp = (tmp * 5461) >> 15;
+ tmp = tmp + 20390;
+
+ if (tmp > 19456) {
+ /* Maximum value of ISF should be at most 7600 Hz */
+ tmp = 19456;
+ }
+
+ tmp = tmp - HfIsf[M - 2];
+ tmp2 = HfIsf[M16k - 2] - HfIsf[M - 2];
+ exp2 = D_UTIL_norm_s((Word16)tmp2);
+ exp = D_UTIL_norm_s((Word16)tmp);
+ exp = exp - 1;
+ tmp = tmp << exp;
+ tmp2 = tmp2 << exp2;
+ coeff = (tmp << 15) / tmp2; /* Coefficient for stretching the ISF vector */
+ exp = exp2 - exp;
+
+ if (exp >= 0) {
+ for (i = M - 1; i < M16k - 1; i++) {
+ tmp = ((HfIsf[i] - HfIsf[i - 1]) * coeff) >> 15;
+ IsfDiff[i - (M - 1)] = tmp << exp;
+ }
+ } else {
+ exp = 15 - exp;
+
+ for (i = M - 1; i < M16k - 1; i++) {
+ IsfDiff[i - (M - 1)] = ((HfIsf[i] - HfIsf[i - 1]) * coeff) >> exp;
+ }
+ }
+
+ for (i = M; i < (M16k - 1); i++) {
+ /* The difference between ISF(n) and ISF(n-2) should be at least 500 Hz */
+ tmp = ((IsfDiff[i - (M - 1)] + IsfDiff[i - M]) - 1280);
+
+ if (tmp < 0) {
+ if (IsfDiff[i - (M - 1)] > IsfDiff[i - M]) {
+ IsfDiff[i - M] = (1280 - IsfDiff[i - (M - 1)]);
+ } else {
+ IsfDiff[i - (M - 1)] = (1280 - IsfDiff[i - M]);
+ }
+ }
+ }
+
+ for (i = M - 1; i < M16k - 1; i++) {
+ HfIsf[i] = (Word16)(HfIsf[i - 1] + IsfDiff[i - (M - 1)]);
+ }
+
+ for (i = 0; i < M16k - 1; i++) {
+ HfIsf[i] = (Word16)((HfIsf[i] * 13107) >> 14);
+ /* Scale the ISF vector correctly for 16000 kHz */
+ }
+
+ D_LPC_isf_isp_conversion(HfIsf, HfIsf, M16k);
+
+ return;
+}
diff --git a/audio_codec/libamr/dec_lpc.h b/audio_codec/libamr/dec_lpc.h
new file mode 100644
index 0000000..a58a755
--- a/dev/null
+++ b/audio_codec/libamr/dec_lpc.h
@@ -0,0 +1,25 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef DEC_LPC_H
+#define DEC_LPC_H
+
+#include "typedef.h"
+
+void D_LPC_isf_noise_d(Word16 *indice, Word16 *isf_q);
+void D_LPC_isf_isp_conversion(Word16 isf[], Word16 isp[], Word16 m);
+void D_LPC_isp_a_conversion(Word16 isp[], Word16 a[], Word32 adaptive_scaling,
+ Word16 m);
+void D_LPC_a_weight(Word16 a[], Word16 ap[], Word16 gamma, Word16 m);
+void D_LPC_isf_2s3s_decode(Word16 *indice, Word16 *isf_q, Word16* past_isfq,
+ Word16 *isfold, Word16 *isf_buf, Word16 bfi);
+void D_LPC_isf_2s5s_decode(Word16 *indice, Word16 *isf_q, Word16 *past_isfq,
+ Word16 *isfold, Word16 *isf_buf, Word16 bfi);
+void D_LPC_int_isp_find(Word16 isp_old[], Word16 isp_new[],
+ const Word16 frac[], Word16 Az[]);
+void D_LPC_isf_extrapolation(Word16 HfIsf[]);
+
+#endif
+
diff --git a/audio_codec/libamr/dec_main.c b/audio_codec/libamr/dec_main.c
new file mode 100644
index 0000000..ad67186
--- a/dev/null
+++ b/audio_codec/libamr/dec_main.c
@@ -0,0 +1,842 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <stdlib.h>
+#include <math.h>
+#include <memory.h>
+#include <string.h>
+#include "typedef.h"
+#include "dec_main.h"
+#include "dec_dtx.h"
+#include "dec_acelp.h"
+#include "dec_gain.h"
+#include "dec_lpc.h"
+#include "dec_util.h"
+
+
+#define MAX_16 (Word16)0x7fff
+#define MIN_16 (Word16)0x8000
+
+#define L_FRAME 256 /* Frame size */
+#define NB_SUBFR 4 /* Number of subframe per frame */
+#define L_SUBFR 64 /* Subframe size */
+#define MODE_7k 0 /* modes */
+#define MODE_9k 1
+#define MODE_12k 2
+#define MODE_14k 3
+#define MODE_16k 4
+#define MODE_18k 5
+#define MODE_20k 6
+#define MODE_23k 7
+#define MODE_24k 8
+#define RX_SPEECH_PROBABLY_DEGRADED 1 /* rx types */
+#define RX_SPEECH_LOST 2
+#define RX_SPEECH_BAD 3
+#define RX_NO_DATA 7
+#define Q_MAX 8 /* scaling max for signal */
+#define PIT_SHARP 27853 /* pitch sharpening factor = 0.85 Q15 */
+#define PIT_MIN 34 /* Minimum pitch lag with resolution 1/4 */
+#define PIT_FR2 128 /* Minimum pitch lag with resolution 1/2 */
+#define PIT_FR1_9b 160 /* Minimum pitch lag with resolution 1 */
+#define PIT_FR1_8b 92 /* Minimum pitch lag with resolution 1 */
+
+extern const Word16 D_ROM_isp[];
+extern const Word16 D_ROM_isf[];
+extern const Word16 D_ROM_interpol_frac[];
+
+#ifdef WIN32
+#pragma warning( disable : 4310)
+#endif
+
+/*
+ * Decoder_reset
+ *
+ * Parameters:
+ * st I/O: pointer to state structure
+ * reset_all I: perform full reset
+ *
+ * Function:
+ * Initialisation of variables for the decoder section.
+ *
+ *
+ * Returns:
+ * void
+ */
+void D_MAIN_reset(void *st, Word16 reset_all)
+{
+ Word32 i;
+
+ Decoder_State *dec_state;
+
+ dec_state = (Decoder_State*)st;
+ memset(dec_state->mem_exc, 0, (PIT_MAX + L_INTERPOL) * sizeof(Word16));
+ memset(dec_state->mem_isf_q, 0, M * sizeof(Word16));
+ dec_state->mem_T0_frac = 0; /* old pitch value = 64.0 */
+ dec_state->mem_T0 = 64;
+ dec_state->mem_first_frame = 1;
+ dec_state->mem_gc_thres = 0;
+ dec_state->mem_tilt_code = 0;
+ memset(dec_state->mem_ph_disp, 0, 8 * sizeof(Word16));
+
+ /* scaling memories for excitation */
+ dec_state->mem_q = Q_MAX;
+ dec_state->mem_subfr_q[3] = Q_MAX;
+ dec_state->mem_subfr_q[2] = Q_MAX;
+ dec_state->mem_subfr_q[1] = Q_MAX;
+ dec_state->mem_subfr_q[0] = Q_MAX;
+
+ if (reset_all != 0) {
+ /* routines initialization */
+ D_GAIN_init(dec_state->mem_gain);
+ memset(dec_state->mem_oversamp, 0, (2 * 12) * sizeof(Word16));
+ memset(dec_state->mem_sig_out, 0, 6 * sizeof(Word16));
+ memset(dec_state->mem_hf, 0, (31 - 1) * sizeof(Word16));
+ memset(dec_state->mem_hf3, 0, (31 - 1) * sizeof(Word16));
+ memset(dec_state->mem_hp400, 0, 6 * sizeof(Word16));
+ D_GAIN_lag_concealment_init(dec_state->mem_lag);
+
+ /* isp initialization */
+ memcpy(dec_state->mem_isp, D_ROM_isp, M * sizeof(Word16));
+ memcpy(dec_state->mem_isf, D_ROM_isf, M * sizeof(Word16));
+
+ for (i = 0; i < L_MEANBUF; i++) {
+ memcpy(&dec_state->mem_isf_buf[i * M], D_ROM_isf, M * sizeof(Word16));
+ }
+
+ /* variable initialization */
+ dec_state->mem_deemph = 0;
+ dec_state->mem_seed = 21845; /* init random with 21845 */
+ dec_state->mem_seed2 = 21845;
+ dec_state->mem_seed3 = 21845;
+ dec_state->mem_state = 0;
+ dec_state->mem_bfi = 0;
+
+ /* Static vectors to zero */
+ memset(dec_state->mem_syn_hf, 0, M16k * sizeof(Word16));
+ memset(dec_state->mem_syn_hi, 0, M * sizeof(Word16));
+ memset(dec_state->mem_syn_lo, 0, M * sizeof(Word16));
+ D_DTX_reset(dec_state->dtx_decSt, D_ROM_isf);
+ dec_state->mem_vad_hist = 0;
+ }
+
+ return;
+}
+
+
+/*
+ * Decoder_init
+ *
+ * Parameters:
+ * spd_state O: pointer to state structure
+ *
+ * Function:
+ * Initialization of variables for the decoder section.
+ * Memory allocation.
+ *
+ * Returns:
+ * return zero if succesful
+ */
+Word32 D_MAIN_init(void **spd_state)
+{
+ /* Decoder states */
+ Decoder_State *st;
+
+ *spd_state = NULL;
+
+ /*
+ * Memory allocation for coder state.
+ */
+ if ((st = (Decoder_State*)malloc(sizeof(Decoder_State))) == NULL) {
+ return(-1);
+ }
+
+ st->dtx_decSt = NULL;
+ D_DTX_init(&st->dtx_decSt, D_ROM_isf);
+ D_MAIN_reset((void *)st, 1);
+ *spd_state = (void *)st;
+
+ return(0);
+}
+
+
+/*
+ * Decoder_close
+ *
+ * Parameters:
+ * spd_state I: pointer to state structure
+ *
+ * Function:
+ * Free coder memory.
+ *
+ * Returns:
+ * void
+ */
+void D_MAIN_close(void **spd_state)
+{
+ D_DTX_exit(&(((Decoder_State *)(*spd_state))->dtx_decSt));
+ free(*spd_state);
+
+ return;
+}
+
+
+/*
+ * Decoder_exe
+ *
+ * Parameters:
+ * mode I: used mode
+ * prms I: parameter vector
+ * synth_out O: synthesis speech
+ * spe_state B: state structure
+ * frame_type I: received frame type
+ *
+ * Function:
+ * Main decoder routine.
+ *
+ * Returns:
+ * 0 if successful
+ */
+Word32 D_MAIN_decode(Word16 mode, Word16 prms[], Word16 synth16k[],
+ void *spd_state, UWord8 frame_type)
+{
+
+ Word32 code2[L_SUBFR]; /* algebraic codevector */
+ Word32 L_tmp, L_tmp2, L_gain_code, L_stab_fac;
+ Word32 i, j, i_subfr, pit_flag;
+ Word32 T0, T0_frac, T0_max, select, T0_min = 0;
+
+ Word16 exc2[L_FRAME]; /* excitation vector */
+ Word16 Aq[NB_SUBFR * (M + 1)]; /* A(z) quantized for the 4 subframes */
+ Word16 code[L_SUBFR]; /* algebraic codevector */
+ Word16 excp[L_SUBFR]; /* excitation vector */
+ Word16 HfIsf[M16k];
+ Word16 ispnew[M]; /* immittance spectral pairs at 4nd sfr*/
+ Word16 isf[M]; /* ISF (frequency domain) at 4nd sfr */
+ Word16 isf_tmp[M]; /* ISF tmp */
+ Word16 ind[8]; /* quantization indices */
+
+ Word16 index, fac, voice_fac, max, Q_new = 0;
+ Word16 gain_pit, gain_code, gain_code_lo, tmp;
+ Word16 corr_gain = 0;
+ UWord16 pit_sharp = 0;
+
+ Word16 *exc; /* Excitation vector */
+ Word16 *p_Aq; /* ptr to A(z) for the 4 subframes */
+ Word16 *p_isf; /* prt to isf */
+
+ Decoder_State *st; /* Decoder states */
+ UWord8 newDTXState, bfi, unusable_frame;
+ UWord8 vad_flag;
+
+ st = (Decoder_State*)spd_state;
+
+ /* find the new DTX state SPEECH OR DTX */
+ newDTXState = D_DTX_rx_handler(st->dtx_decSt, frame_type);
+
+ if (newDTXState != SPEECH) {
+ D_DTX_exe(st->dtx_decSt, exc2, newDTXState, isf, &prms);
+ }
+
+ /* SPEECH action state machine */
+ if ((frame_type == RX_SPEECH_BAD) |
+ (frame_type == RX_SPEECH_PROBABLY_DEGRADED)) {
+ /* bfi for all index, bits are not usable */
+ bfi = 1;
+ unusable_frame = 0;
+ } else if ((frame_type == RX_NO_DATA) | (frame_type == RX_SPEECH_LOST)) {
+ /* bfi only for lsf, gains and pitch period */
+ bfi = 1;
+ unusable_frame = 1;
+ } else {
+ bfi = 0;
+ unusable_frame = 0;
+ }
+
+ if (bfi != 0) {
+ st->mem_state = (UWord8)(st->mem_state + 1);
+
+ if (st->mem_state > 6) {
+ st->mem_state = 6;
+ }
+ } else {
+ st->mem_state = (UWord8)(st->mem_state >> 1);
+ }
+
+ /*
+ * If this frame is the first speech frame after CNI period,
+ * set the BFH state machine to an appropriate state depending
+ * on whether there was DTX muting before start of speech or not
+ * If there was DTX muting, the first speech frame is muted.
+ * If there was no DTX muting, the first speech frame is not
+ * muted. The BFH state machine starts from state 5, however, to
+ * keep the audible noise resulting from a SID frame which is
+ * erroneously interpreted as a good speech frame as small as
+ * possible (the decoder output in this case is quickly muted)
+ */
+
+ if (st->dtx_decSt->mem_dtx_global_state == DTX) {
+ st->mem_state = 5;
+ st->mem_bfi = 0;
+ } else if (st->dtx_decSt->mem_dtx_global_state == D_DTX_MUTE) {
+ st->mem_state = 5;
+ st->mem_bfi = 1;
+ }
+
+ if (newDTXState == SPEECH) {
+ vad_flag = (UWord8)(*prms++);
+
+ if (bfi == 0) {
+ if (vad_flag == 0) {
+ st->mem_vad_hist = (Word16)(st->mem_vad_hist + 1);
+
+ if (st->mem_vad_hist > 32767) {
+ st->mem_vad_hist = 32767;
+ }
+ } else {
+ st->mem_vad_hist = 0;
+ }
+ }
+ }
+
+ /*
+ * DTX-CNG
+ */
+ if (newDTXState != SPEECH) { /* CNG mode */
+ /*
+ * increase slightly energy of noise below 200 Hz
+ * Convert ISFs to the cosine domain
+ */
+ D_LPC_isf_isp_conversion(isf, ispnew, M);
+ D_LPC_isp_a_conversion(ispnew, Aq, 1, M);
+ memcpy(isf_tmp, st->mem_isf, M * sizeof(Word16));
+
+ for (i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR) {
+ j = (i_subfr >> 6);
+
+ for (i = 0; i < M; i++) {
+ L_tmp = (isf_tmp[i] * (32767 - D_ROM_interpol_frac[j])) << 1;
+ L_tmp = L_tmp + ((isf[i] * D_ROM_interpol_frac[j]) << 1);
+ HfIsf[i] = (Word16)((L_tmp + 0x8000) >> 16);
+ }
+
+ D_UTIL_dec_synthesis(Aq, &exc2[i_subfr], 0, &synth16k[i_subfr * 5 / 4],
+ (Word16) 1, HfIsf, mode, newDTXState, bfi, st);
+ }
+
+ /* reset speech coder memories */
+ D_MAIN_reset(st, 0);
+ memcpy(st->mem_isf, isf, M * sizeof(Word16));
+ st->mem_bfi = bfi;
+ st->dtx_decSt->mem_dtx_global_state = (UWord8)newDTXState;
+
+ return(0);
+ }
+
+ /*
+ * ACELP
+ */
+
+ exc = st->mem_exc + PIT_MAX + L_INTERPOL;
+
+ /* Decode the ISFs */
+ if (mode <= MODE_7k) {
+ ind[0] = *prms++;
+ ind[1] = *prms++;
+ ind[2] = *prms++;
+ ind[3] = *prms++;
+ ind[4] = *prms++;
+ D_LPC_isf_2s3s_decode(ind, isf, st->mem_isf_q, st->mem_isf,
+ st->mem_isf_buf, bfi);
+ } else {
+ ind[0] = *prms++;
+ ind[1] = *prms++;
+ ind[2] = *prms++;
+ ind[3] = *prms++;
+ ind[4] = *prms++;
+ ind[5] = *prms++;
+ ind[6] = *prms++;
+ D_LPC_isf_2s5s_decode(ind, isf, st->mem_isf_q, st->mem_isf,
+ st->mem_isf_buf, bfi);
+ }
+
+ /* Convert ISFs to the cosine domain */
+ D_LPC_isf_isp_conversion(isf, ispnew, M);
+
+ if (st->mem_first_frame != 0) {
+ st->mem_first_frame = 0;
+ memcpy(st->mem_isp, ispnew, M * sizeof(Word16));
+ }
+
+ /* Find the interpolated ISPs and convert to a[] for all subframes */
+ D_LPC_int_isp_find(st->mem_isp, ispnew, D_ROM_interpol_frac, Aq);
+
+ /* update isp memory for the next frame */
+ memcpy(st->mem_isp, ispnew, M * sizeof(Word16));
+
+ /* Check stability on isf : distance between old isf and current isf */
+ L_tmp = 0;
+ p_isf = st->mem_isf;
+
+ for (i = 0; i < M - 1; i++) {
+ tmp = (Word16)((isf[i] - p_isf[i]));
+ L_tmp = L_tmp + (tmp * tmp);
+ }
+
+ if (L_tmp < 3276928) {
+ L_tmp = L_tmp >> 7;
+ L_tmp = (L_tmp * 26214) >> 15; /* tmp = L_tmp*0.8/256 */
+ L_tmp = 20480 - L_tmp; /* 1.25 - tmp */
+ L_stab_fac = L_tmp << 1; /* Q14 -> Q15 with saturation */
+
+ if (L_stab_fac > 0x7FFF) {
+ L_stab_fac = 0x7FFF;
+ }
+ } else {
+ L_stab_fac = 0x0;
+ }
+
+ memcpy(isf_tmp, st->mem_isf, M * sizeof(Word16));
+ memcpy(st->mem_isf, isf, M * sizeof(Word16));
+
+ /*
+ * Loop for every subframe in the analysis frame
+ *
+ * The subframe size is L_SUBFR and the loop is repeated L_FRAME/L_SUBFR
+ * times
+ * - decode the pitch delay and filter mode
+ * - decode algebraic code
+ * - decode pitch and codebook gains
+ * - find voicing factor and tilt of code for next subframe
+ * - find the excitation and compute synthesis speech
+ */
+
+ p_Aq = Aq; /* pointer to interpolated LPC parameters */
+
+ for (i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR) {
+ pit_flag = i_subfr;
+
+ if ((i_subfr == (2 * L_SUBFR)) & (mode > MODE_7k)) {
+ pit_flag = 0;
+ }
+
+ /*
+ * - Decode pitch lag
+ * Lag indeces received also in case of BFI,
+ * so that the parameter pointer stays in sync.
+ */
+
+ if (pit_flag == 0) {
+ if (mode <= MODE_9k) {
+ index = *prms++;
+
+ if (index < ((PIT_FR1_8b - PIT_MIN) * 2)) {
+ T0 = (PIT_MIN + (index >> 1));
+ T0_frac = (index - ((T0 - PIT_MIN) << 1));
+ T0_frac = (T0_frac << 1);
+ } else {
+ T0 = index + (PIT_FR1_8b - ((PIT_FR1_8b - PIT_MIN) * 2));
+ T0_frac = 0;
+ }
+ } else {
+ index = *prms++;
+
+ if (index < ((PIT_FR2 - PIT_MIN) * 4)) {
+ T0 = PIT_MIN + (index >> 2);
+ T0_frac = index - ((T0 - PIT_MIN) << 2);
+ } else if (index <
+ ((((PIT_FR2 - PIT_MIN) * 4) + ((PIT_FR1_9b - PIT_FR2) * 2)))) {
+ index = (Word16)((index - ((PIT_FR2 - PIT_MIN) * 4)));
+ T0 = PIT_FR2 + (index >> 1);
+ T0_frac = index - ((T0 - PIT_FR2) << 1);
+ T0_frac = T0_frac << 1;
+ } else {
+ T0 = index + (PIT_FR1_9b - ((PIT_FR2 - PIT_MIN) * 4) -
+ ((PIT_FR1_9b - PIT_FR2) * 2));
+ T0_frac = 0;
+ }
+ }
+
+ /* find T0_min and T0_max for subframe 2 and 4 */
+ T0_min = T0 - 8;
+
+ if (T0_min < PIT_MIN) {
+ T0_min = PIT_MIN;
+ }
+
+ T0_max = T0_min + 15;
+
+ if (T0_max > PIT_MAX) {
+ T0_max = PIT_MAX;
+ T0_min = T0_max - 15;
+ }
+ } else {
+ /* if subframe 2 or 4 */
+
+ if (mode <= MODE_9k) {
+ index = *prms++;
+ T0 = T0_min + (index >> 1);
+ T0_frac = index - ((T0 - T0_min) << 1);
+ T0_frac = T0_frac << 1;
+ } else {
+ index = *prms++;
+ T0 = T0_min + (index >> 2);
+ T0_frac = index - ((T0 - T0_min) << 2);
+ }
+ }
+
+ /* check BFI after pitch lag decoding */
+ if (bfi != 0) { /* if frame erasure */
+ D_GAIN_lag_concealment(&(st->mem_gain[17]), st->mem_lag, &T0,
+ &(st->mem_T0), &(st->mem_seed3), unusable_frame);
+ T0_frac = 0;
+ }
+
+ /*
+ * Find the pitch gain, the interpolation filter
+ * and the adaptive codebook vector.
+ */
+
+ D_GAIN_adaptive_codebook_excitation(&exc[i_subfr], T0, T0_frac);
+
+ if (unusable_frame) {
+ select = 1;
+ } else {
+ if (mode <= MODE_9k) {
+ select = 0;
+ } else {
+ select = *prms++;
+ }
+ }
+
+ if (select == 0) {
+ /* find pitch excitation with lp filter */
+ for (i = 0; i < L_SUBFR; i++) {
+ L_tmp = 2949 * exc[i - 1 + i_subfr];
+ L_tmp = L_tmp + (10486 * exc[i + i_subfr]);
+ L_tmp = L_tmp + (2949 * exc[i + 1 + i_subfr]);
+ code[i] = (Word16)((L_tmp + 0x2000) >> 14);
+ }
+
+ memcpy(&exc[i_subfr], code, L_SUBFR * sizeof(Word16));
+ }
+
+ /*
+ * Decode innovative codebook.
+ * Add the fixed-gain pitch contribution to code[].
+ */
+
+ if (unusable_frame != 0) {
+ /* the innovative code doesn't need to be scaled (see Q_gain2) */
+ for (i = 0; i < L_SUBFR; i++) {
+ code[i] = (Word16)(D_UTIL_random(&(st->mem_seed)) >> 3);
+ }
+ } else if (mode <= MODE_7k) {
+ ind[0] = *prms++;
+ D_ACELP_decode_2t(ind[0], code);
+ } else if (mode <= MODE_9k) {
+ memcpy(ind, prms, 4 * sizeof(Word16));
+ prms += 4;
+ D_ACELP_decode_4t(ind, 20, code);
+ } else if (mode <= MODE_12k) {
+ memcpy(ind, prms, 4 * sizeof(Word16));
+ prms += 4;
+ D_ACELP_decode_4t(ind, 36, code);
+ } else if (mode <= MODE_14k) {
+ memcpy(ind, prms, 4 * sizeof(Word16));
+ prms += 4;
+ D_ACELP_decode_4t(ind, 44, code);
+ } else if (mode <= MODE_16k) {
+ memcpy(ind, prms, 4 * sizeof(Word16));
+ prms += 4;
+ D_ACELP_decode_4t(ind, 52, code);
+ } else if (mode <= MODE_18k) {
+ memcpy(ind, prms, 8 * sizeof(Word16));
+ prms += 8;
+ D_ACELP_decode_4t(ind, 64, code);
+ } else if (mode <= MODE_20k) {
+ memcpy(ind, prms, 8 * sizeof(Word16));
+ prms += 8;
+ D_ACELP_decode_4t(ind, 72, code);
+ } else {
+ memcpy(ind, prms, 8 * sizeof(Word16));
+ prms += 8;
+ D_ACELP_decode_4t(ind, 88, code);
+ }
+
+ tmp = 0;
+ D_UTIL_preemph(code, st->mem_tilt_code, L_SUBFR, &tmp);
+
+ L_tmp = T0;
+
+ if (T0_frac > 2) {
+ L_tmp = L_tmp + 1;
+ }
+
+ D_GAIN_pitch_sharpening(code, L_tmp, PIT_SHARP);
+
+ /*
+ * Decode codebooks gains.
+ */
+ index = *prms++; /* codebook gain index */
+
+ if (mode <= MODE_9k) {
+ D_GAIN_decode(index, 6, code, &gain_pit, &L_gain_code, bfi,
+ st->mem_bfi, st->mem_state, unusable_frame, st->mem_vad_hist,
+ st->mem_gain);
+ } else {
+ D_GAIN_decode(index, 7, code, &gain_pit, &L_gain_code, bfi,
+ st->mem_bfi, st->mem_state, unusable_frame, st->mem_vad_hist,
+ st->mem_gain);
+ }
+
+ /* find best scaling to perform on excitation (Q_new) */
+ tmp = st->mem_subfr_q[0];
+
+ for (i = 1; i < 4; i++) {
+ if (st->mem_subfr_q[i] < tmp) {
+ tmp = st->mem_subfr_q[i];
+ }
+ }
+
+ /* limit scaling (Q_new) to Q_MAX */
+ if (tmp > Q_MAX) {
+ tmp = Q_MAX;
+ }
+
+ Q_new = 0;
+ L_tmp = L_gain_code; /* L_gain_code in Q16 */
+
+ while ((L_tmp < 0x08000000L) && (Q_new < tmp)) {
+ L_tmp = (L_tmp << 1);
+ Q_new = (Word16)((Q_new + 1));
+ }
+
+ if (L_tmp < 0x7FFF7FFF) {
+ gain_code = (Word16)((L_tmp + 0x8000) >> 16);
+ /* scaled gain_code with Qnew */
+ } else {
+ gain_code = 32767;
+ }
+
+ if (Q_new > st->mem_q) {
+ D_UTIL_signal_up_scale(exc + i_subfr - (PIT_MAX + L_INTERPOL),
+ PIT_MAX + L_INTERPOL + L_SUBFR, (Word16)(Q_new - st->mem_q));
+ } else {
+ D_UTIL_signal_down_scale(exc + i_subfr - (PIT_MAX + L_INTERPOL),
+ PIT_MAX + L_INTERPOL + L_SUBFR, (Word16)(st->mem_q - Q_new));
+ }
+
+ st->mem_q = Q_new;
+
+ /*
+ * Update parameters for the next subframe.
+ * - tilt of code: 0.0 (unvoiced) to 0.5 (voiced)
+ */
+ if (bfi == 0) {
+ /* LTP-Lag history update */
+ for (i = 4; i > 0; i--) {
+ st->mem_lag[i] = st->mem_lag[i - 1];
+ }
+ st->mem_lag[0] = (Word16)T0;
+ st->mem_T0 = (Word16)T0;
+ st->mem_T0_frac = 0; /* Remove fraction in case of BFI */
+ }
+
+ /* find voice factor in Q15 (1=voiced, -1=unvoiced) */
+ memcpy(exc2, &exc[i_subfr], L_SUBFR * sizeof(Word16));
+ D_UTIL_signal_down_scale(exc2, L_SUBFR, 3);
+
+ /* post processing of excitation elements */
+ if (mode <= MODE_9k) {
+ pit_sharp = (Word16)(gain_pit << 1);
+
+ if (pit_sharp > 16384) {
+ if (pit_sharp > 32767) {
+ pit_sharp = 32767;
+ }
+
+ for (i = 0; i < L_SUBFR; i++) {
+ L_tmp = (exc2[i] * pit_sharp) >> 15;
+ L_tmp = L_tmp * gain_pit;
+ excp[i] = (Word16)((L_tmp + 0x8000) >> 16);
+ }
+ }
+ }
+
+ voice_fac = D_GAIN_find_voice_factor(exc2, -3, gain_pit, code, gain_code,
+ L_SUBFR);
+
+ /* tilt of code for next subframe: 0.5=voiced, 0=unvoiced */
+ st->mem_tilt_code = (Word16)((voice_fac >> 2) + 8192);
+
+ /*
+ * Find the total excitation.
+ * Find synthesis speech corresponding to exc[].
+ * Find maximum value of excitation for next scaling
+ */
+ memcpy(exc2, &exc[i_subfr], L_SUBFR * sizeof(Word16));
+ max = 1;
+
+ for (i = 0; i < L_SUBFR; i++) {
+ L_tmp = (code[i] * gain_code) << 5;
+ L_tmp = L_tmp + (exc[i + i_subfr] * gain_pit);
+ L_tmp = (L_tmp + 0x2000) >> 14;
+
+ if ((L_tmp > MIN_16) & (L_tmp < 32768)) {
+ exc[i + i_subfr] = (Word16)L_tmp;
+ tmp = (Word16)(abs(L_tmp));
+
+ if (tmp > max) {
+ max = tmp;
+ }
+ } else if (L_tmp > MAX_16) {
+ exc[i + i_subfr] = MAX_16;
+ max = MAX_16;
+ } else {
+ exc[i + i_subfr] = MIN_16;
+ max = MAX_16;
+ }
+ }
+
+ /* tmp = scaling possible according to max value of excitation */
+ tmp = (Word16)((D_UTIL_norm_s(max) + Q_new) - 1);
+ st->mem_subfr_q[3] = st->mem_subfr_q[2];
+ st->mem_subfr_q[2] = st->mem_subfr_q[1];
+ st->mem_subfr_q[1] = st->mem_subfr_q[0];
+ st->mem_subfr_q[0] = tmp;
+
+ /*
+ * phase dispersion to enhance noise in low bit rate
+ */
+
+ /* L_gain_code in Q16 */
+ D_UTIL_l_extract(L_gain_code, &gain_code, &gain_code_lo);
+
+ if (mode <= MODE_7k) {
+ j = 0; /* high dispersion for rate <= 7.5 kbit/s */
+ } else if (mode <= MODE_9k) {
+ j = 1; /* low dispersion for rate <= 9.6 kbit/s */
+ } else {
+ j = 2; /* no dispersion for rate > 9.6 kbit/s */
+ }
+
+ D_ACELP_phase_dispersion(gain_code, gain_pit, code, (Word16)j,
+ st->mem_ph_disp);
+
+ /*
+ * noise enhancer
+ * - Enhance excitation on noise. (modify gain of code)
+ * If signal is noisy and LPC filter is stable, move gain
+ * of code 1.5 dB toward gain of code threshold.
+ * This decrease by 3 dB noise energy variation.
+ */
+ L_tmp = 16384 - (voice_fac >> 1); /* 1=unvoiced, 0=voiced */
+ fac = (Word16)((L_stab_fac * L_tmp) >> 15);
+ L_tmp = L_gain_code;
+
+ if (L_tmp < st->mem_gc_thres) {
+ L_tmp = (L_tmp + D_UTIL_mpy_32_16(gain_code, gain_code_lo, 6226));
+
+ if (L_tmp > st->mem_gc_thres) {
+ L_tmp = st->mem_gc_thres;
+ }
+ } else {
+ L_tmp = D_UTIL_mpy_32_16(gain_code, gain_code_lo, 27536);
+
+ if (L_tmp < st->mem_gc_thres) {
+ L_tmp = st->mem_gc_thres;
+ }
+ }
+ st->mem_gc_thres = L_tmp;
+ L_gain_code =
+ D_UTIL_mpy_32_16(gain_code, gain_code_lo, (Word16)(32767 - fac));
+ D_UTIL_l_extract(L_tmp, &gain_code, &gain_code_lo);
+ L_gain_code =
+ L_gain_code + D_UTIL_mpy_32_16(gain_code, gain_code_lo, fac);
+
+ /*
+ * pitch enhancer
+ * - Enhance excitation on voice. (HP filtering of code)
+ * On voiced signal, filtering of code by a smooth fir HP
+ * filter to decrease energy of code in low frequency.
+ */
+
+ L_tmp2 = (voice_fac >> 3) + 4096; /* 0.25=voiced, 0=unvoiced */
+ L_tmp = (code[0] << 15) - (code[1] * L_tmp2);
+ code2[0] = (L_tmp + 0x4000) >> 15;
+
+ for (i = 1; i < L_SUBFR - 1; i++) {
+ L_tmp = code[i] << 15;
+ L_tmp = L_tmp - (code[i + 1] * L_tmp2);
+ L_tmp = L_tmp - (code[i - 1] * L_tmp2);
+ code2[i] = (L_tmp + 0x4000) >> 15;
+ }
+
+ L_tmp = code[L_SUBFR - 1] << 15;
+ L_tmp = L_tmp - (code[L_SUBFR - 2] * L_tmp2);
+ code2[L_SUBFR - 1] = (L_tmp + 0x4000) >> 15;
+
+ /* build excitation */
+ gain_code = (Word16)(((L_gain_code << Q_new) + 0x8000) >> 16);
+
+ for (i = 0; i < L_SUBFR; i++) {
+ L_tmp = (code2[i] * gain_code) << 5;
+ L_tmp = L_tmp + (exc2[i] * gain_pit);
+ L_tmp = (L_tmp + 0x2000) >> 14;
+
+ exc2[i] = D_UTIL_saturate(L_tmp);
+ }
+
+ if (mode <= MODE_9k) {
+ if (pit_sharp > 16384) {
+ for (i = 0; i < L_SUBFR; i++) {
+ L_tmp = (excp[i] + exc2[i]);
+ excp[i] = D_UTIL_saturate(L_tmp);
+ }
+
+ D_GAIN_adaptive_control(exc2, excp, L_SUBFR);
+ memcpy(exc2, excp, L_SUBFR * sizeof(Word16));
+ }
+ }
+
+ if (mode <= MODE_7k) {
+ j = (i_subfr >> 6);
+
+ for (i = 0; i < M; i++) {
+ L_tmp = isf_tmp[i] * (32767 - D_ROM_interpol_frac[j]);
+ L_tmp = L_tmp + (isf[i] * D_ROM_interpol_frac[j]);
+ HfIsf[i] = (Word16)((L_tmp + 0x4000) >> 15);
+ }
+ } else {
+ memset(st->mem_syn_hf, 0, (M16k - M) * sizeof(Word16));
+ }
+
+ if (mode >= MODE_24k) {
+ corr_gain = *prms++;
+ D_UTIL_dec_synthesis(p_Aq, exc2, Q_new, &synth16k[i_subfr * 5 / 4],
+ corr_gain, HfIsf, mode, newDTXState, bfi, st);
+ } else {
+ D_UTIL_dec_synthesis(p_Aq, exc2, Q_new, &synth16k[i_subfr * 5 / 4], 0,
+ HfIsf, mode, newDTXState, bfi, st);
+ }
+
+ p_Aq += (M + 1); /* interpolated LPC parameters for next subframe */
+ }
+
+ /*
+ * Update signal for next frame
+ * -> save past of exc[]
+ * -> save pitch parameters.
+ */
+
+ //memmove(st->mem_exc, &st->mem_exc[L_FRAME], (PIT_MAX + L_INTERPOL) * sizeof(Word16));
+ memcpy(st->mem_exc, &st->mem_exc[L_FRAME], (PIT_MAX + L_INTERPOL) * sizeof(Word16));
+ D_UTIL_signal_down_scale(exc, L_FRAME, Q_new);
+ D_DTX_activity_update(st->dtx_decSt, isf, exc);
+ st->dtx_decSt->mem_dtx_global_state = (UWord8)newDTXState;
+ st->mem_bfi = bfi;
+
+ return(0);
+}
diff --git a/audio_codec/libamr/dec_main.h b/audio_codec/libamr/dec_main.h
new file mode 100644
index 0000000..a033a89
--- a/dev/null
+++ b/audio_codec/libamr/dec_main.h
@@ -0,0 +1,57 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef DEC_MAIN_H
+#define DEC_MAIN_H
+
+#include "typedef.h"
+#include "dec_dtx.h"
+
+#define L_FRAME 256 /* Frame size */
+#define PIT_MAX 231 /* Maximum pitch lag */
+#define L_INTERPOL (16 + 1) /* Length of filter for interpolation */
+#define L_MEANBUF 3
+#define L_FILT 12 /* Delay of up-sampling filter */
+#define L_FILT16k 15 /* Delay of down-sampling filter */
+#define M16k 20 /* Order of LP filter */
+
+typedef struct {
+ Word32 mem_gc_thres; /* threshold for noise enhancer */
+ Word16 mem_exc[(L_FRAME + 1) + PIT_MAX + L_INTERPOL];/* old excitation vector */
+ Word16 mem_isf_buf[L_MEANBUF * M];/* isf buffer(frequency domain) */
+ Word16 mem_hf[2 * L_FILT16k]; /* HF band-pass filter memory */
+ Word16 mem_hf2[2 * L_FILT16k]; /* HF band-pass filter memory */
+ Word16 mem_hf3[2 * L_FILT16k]; /* HF band-pass filter memory */
+ Word16 mem_oversamp[2 * L_FILT]; /* synthesis oversampled filter memory */
+ Word16 mem_gain[23]; /* gain decoder memory */
+ Word16 mem_syn_hf[M16k]; /* HF synthesis memory */
+ Word16 mem_isp[M]; /* old isp (immittance spectral pairs) */
+ Word16 mem_isf[M]; /* old isf (frequency domain) */
+ Word16 mem_isf_q[M]; /* past isf quantizer */
+ Word16 mem_syn_hi[M]; /* modified synthesis memory (MSB) */
+ Word16 mem_syn_lo[M]; /* modified synthesis memory (LSB) */
+ Word16 mem_ph_disp[8]; /* phase dispersion memory */
+ Word16 mem_sig_out[6]; /* hp50 filter memory for synthesis */
+ Word16 mem_hp400[6]; /* hp400 filter memory for synthesis */
+ Word16 mem_lag[5]; /* LTP lag history */
+ Word16 mem_subfr_q[4]; /* old maximum scaling factor */
+ Word16 mem_tilt_code; /* tilt of code */
+ Word16 mem_q; /* old scaling factor */
+ Word16 mem_deemph; /* speech deemph filter memory */
+ Word16 mem_seed; /* random memory for frame erasure */
+ Word16 mem_seed2; /* random memory for HF generation */
+ Word16 mem_seed3; /* random memory for lag concealment */
+ Word16 mem_T0; /* old pitch lag */
+ Word16 mem_T0_frac; /* old pitch fraction lag */
+ UWord16 mem_vad_hist; /* VAD history */
+ D_DTX_State *dtx_decSt;
+ UWord8 mem_bfi; /* Previous BFI */
+ UWord8 mem_state; /* BGH state machine memory */
+ UWord8 mem_first_frame; /* First frame indicator */
+
+} Decoder_State;
+
+#endif
+
diff --git a/audio_codec/libamr/dec_rom.c b/audio_codec/libamr/dec_rom.c
new file mode 100644
index 0000000..6752a62
--- a/dev/null
+++ b/audio_codec/libamr/dec_rom.c
@@ -0,0 +1,2114 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include "typedef.h"
+
+#define L_SUBFR 64 /* Subframe size */
+#define L_FIR 31
+#define ORDER 16 /* Order of linear prediction filter */
+#define M 16 /* Order of LP filter */
+#define NB_SUBFR 4 /* Number of subframe per frame */
+#define UP_SAMP 4
+#define L_INTERPOL2 16
+
+#define SIZE_BK1 256
+#define SIZE_BK2 256
+#define SIZE_BK21 64
+#define SIZE_BK22 128
+#define SIZE_BK23 128
+#define SIZE_BK24 32
+#define SIZE_BK25 32
+#define SIZE_BK21_36b 128
+#define SIZE_BK22_36b 128
+#define SIZE_BK23_36b 64
+#define SIZE_BK_NOISE1 64
+#define SIZE_BK_NOISE2 64
+#define SIZE_BK_NOISE3 64
+#define SIZE_BK_NOISE4 32
+#define SIZE_BK_NOISE5 32
+
+/* 16-byte align start */
+#ifdef ENABLE_CPU2_DECODER
+CPU2_DATA_START
+#endif
+/*
+ * isf codebooks: two-stage VQ with split-by-5 in 2nd stage
+ *
+ * codebook vector dimension number of vectors
+ * ~~~~~~~~ ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
+ * 1_1 9 256
+ * 1_2 7 256
+ * 2_1 3 64
+ * 2_2 3 128
+ * 2_3 3 128
+ * 2_4 3 32
+ * 2_5 4 32
+ */
+
+/*
+ * 1st stage codebook; 1st split: isf0 to isf8
+ */
+
+const Word16 D_ROM_dico1_isf[SIZE_BK1 * 9] = {
+
+ 579, 1081, 1035, 390, 3, -263, -198, -82, 38,
+ 18, -68, -12, 313, 761, 405, 249, 111, -76,
+ 740, 1263, 1292, 1006, 997, 1019, 1017, 976, 923,
+ -91, 827, 948, 648, 613, 535, 522, 490, 421,
+ 41, -44, -281, -472, 652, 534, 193, 135, -90,
+ 41, -121, -356, -60, 663, 307, 61, -48, -344,
+ 557, 946, 1049, 867, 846, 990, 1112, 1262, 1241,
+ -118, -204, 328, 512, 870, 793, 610, 402, 186,
+ 156, 293, 74, -338, -475, -897, -594, -161, -497,
+ 226, 131, -138, 307, 169, -271, -164, -387, -624,
+ 62, -32, -61, -252, -541, -828, -1027, -523, -662,
+ 102, -61, 141, 112, -270, -251, -541, 25, -150,
+ 6, -132, -356, -686, -96, -322, -522, -31, -326,
+ -36, -209, -521, -229, 307, -132, -5, -99, -384,
+ 60, -51, -237, -668, -973, -407, -708, -75, -172,
+ 26, -138, -266, 111, -302, 43, -278, -356, -359,
+ 570, 822, 496, -154, -312, -92, 137, 279, 371,
+ -146, 368, 409, 68, 6, 77, 167, 202, 162,
+ 633, 898, 996, 756, 662, 683, 783, 909, 996,
+ -103, 294, 607, 415, 483, 462, 480, 431, 408,
+ -120, -338, -612, -524, 584, 331, 92, 433, 276,
+ -178, -293, -154, -41, 269, 100, -9, 213, 160,
+ 830, 736, 278, 820, 1254, 686, 712, 1039, 473,
+ -218, -304, 463, 454, 397, 273, 202, 286, 273,
+ -232, 7, 6, -388, -472, -427, -378, -167, -100,
+ -294, -183, 134, -47, 101, -88, -84, -117, -3,
+ 57, 17, -202, -634, -989, -1119, -533, 176, -36,
+ 120, -28, 23, 111, -319, 318, -22, -77, 266,
+ -271, -464, -434, -658, -640, -385, -385, -99, -69,
+ -198, -259, -266, -44, -39, -139, -137, 171, 66,
+ 9, -145, -377, -846, -1000, -111, -325, 342, 135,
+ -81, -286, -380, 192, -57, 307, 76, -24, -140,
+ 677, 702, 247, 56, 249, 141, -105, -236, -99,
+ 36, -39, -69, 348, 198, -93, 322, 91, -72,
+ 503, 885, 1508, 1307, 1282, 1172, 1119, 1209, 1061,
+ 416, 719, 989, 1227, 1001, 1052, 954, 741, 1044,
+ -127, -376, -657, 139, 623, 223, 501, 306, 220,
+ -113, -384, -796, 504, 438, 85, 213, -83, -194,
+ 585, 1132, 1233, 1091, 1247, 1433, 1512, 1448, 1314,
+ -174, -422, 7, 1155, 1089, 1182, 1003, 945, 806,
+ 8, -126, -317, -103, -351, -695, -98, -268, -537,
+ 33, -103, -290, 167, -39, -407, 44, -208, -375,
+ 104, -23, -64, -291, -637, -851, -1084, -61, -112,
+ -75, -306, -434, 218, -148, -354, -680, -133, -216,
+ -121, -377, -718, -97, -130, -361, -156, -379, -599,
+ -56, -254, -586, 235, 157, -214, 11, -260, -149,
+ -124, -267, -397, -580, -593, -527, -805, -385, 346,
+ -193, -440, -708, -351, -141, -255, -499, -147, -185,
+ 448, 660, 494, 208, 509, 461, 338, 291, 149,
+ -223, 88, 335, 159, 212, 191, 286, 308, 205,
+ -31, 469, 803, 659, 619, 658, 843, 987, 1113,
+ -171, -242, 514, 362, 295, 524, 552, 694, 585,
+ -64, -308, -448, -21, 284, 786, 446, 289, 92,
+ -218, -390, -7, 169, 206, 330, 352, 408, 358,
+ -36, 702, 959, 859, 861, 1115, 1269, 1357, 1305,
+ -133, -341, -65, 678, 417, 440, 486, 518, 780,
+ 33, -44, -191, -344, -461, -755, -201, 217, -31,
+ -353, -547, -44, 123, -61, -68, -79, 29, 60,
+ 73, -57, -406, -766, -1243, -1203, 240, 400, 165,
+ -73, -282, -601, -213, -171, -375, 332, 35, -103,
+ -29, -207, -553, -476, -638, -908, 172, -22, -135,
+ -192, -239, -164, -103, -111, -47, 153, 125, 110,
+ -1, -203, -570, -1030, -1424, -535, 155, 1, 147,
+ -333, -653, -865, -197, -158, -21, -44, 95, 108,
+ 389, 588, 490, 33, -237, -524, -628, -136, -260,
+ 40, -177, -462, 453, 862, 380, 131, -130, -405,
+ 842, 1678, 1841, 1549, 1474, 1256, 1082, 905, 742,
+ 370, 1216, 1768, 1633, 1212, 636, 22, -330, 71,
+ -76, -281, -741, -742, 898, 619, 277, 71, -222,
+ -32, -265, -556, -25, 994, 682, 305, 126, -165,
+ 73, 738, 893, 968, 993, 1768, 2273, 1840, 1391,
+ -69, -349, -585, 234, 1158, 903, 626, 510, 251,
+ -1, -99, -272, -210, -603, -351, -540, -811, -383,
+ -16, -230, -504, 410, 149, -205, -343, -651, -639,
+ 103, -9, -227, -205, -562, -781, -1079, -1208, -156,
+ 143, 63, -135, -67, -317, -602, -784, -1154, -640,
+ -144, -391, -674, -622, -200, -254, -660, -947, -395,
+ -40, -250, -625, 27, 543, 94, -131, -386, -673,
+ -123, -371, -757, -451, -564, -614, -415, -711, -35,
+ -116, -309, -593, -268, 239, -33, -338, -650, -135,
+ 94, 251, 554, 57, -312, -423, -154, -57, 235,
+ -268, -71, 381, 114, -44, -87, 125, 173, 133,
+ 1513, 1714, 1238, 534, 276, 315, 461, 459, 508,
+ -131, -19, 1149, 670, 486, 356, 309, 369, 296,
+ -223, -501, -899, -722, -70, 6, 131, 310, 394,
+ -99, -303, -517, 249, 64, -53, 135, -11, 453,
+ -147, -399, -730, -401, 817, 738, 802, 749, 575,
+ -154, -435, -739, 800, 593, 366, 529, 318, 326,
+ -224, 45, -39, -387, -515, -518, -608, -384, -321,
+ -315, -377, 143, -101, -113, -377, -177, -144, -12,
+ 117, 40, -239, -651, -1051, -581, -737, -990, -328,
+ 26, -50, -157, -23, -453, -283, -531, -546, 192,
+ -252, -501, -743, -589, -627, -499, -328, -118, -72,
+ -324, -494, -244, -306, -144, -177, -262, -135, -78,
+ -36, -234, -519, -961, -1290, -314, -479, -371, -45,
+ -95, -292, -535, -8, -300, 112, -164, -277, 198,
+ -99, -128, 880, 836, 579, 351, 23, -95, -217,
+ -27, -258, 124, 1011, 597, 425, 144, 7, -73,
+ 421, 1293, 1640, 1623, 1742, 1617, 1499, 1284, 1006,
+ -95, 752, 1680, 1569, 1618, 1436, 1200, 980, 712,
+ -69, -300, -683, -435, 1132, 899, 504, 332, 109,
+ -74, -323, -637, 563, 1074, 608, 371, 105, -49,
+ -78, 831, 1194, 1110, 1378, 1481, 1492, 1365, 1217,
+ -259, -121, 1440, 1334, 1628, 1490, 1438, 1223, 933,
+ -82, -306, -613, -222, -378, -675, -545, -671, -845,
+ 53, -124, -347, 422, 52, -125, -270, -529, 9,
+ 79, -89, -320, -662, -999, -1199, -1243, -676, -297,
+ -68, -273, -611, 137, -146, -397, -627, -845, -220,
+ -112, -346, -797, -826, 234, -132, -188, -278, -522,
+ -159, -405, -734, -419, 293, 74, -167, -167, 184,
+ -153, -437, -833, -1080, -336, -472, -561, -340, -253,
+ -169, -423, -820, -904, -131, -19, -346, -604, 31,
+ 33, -31, 312, 62, -148, 49, -59, 564, 486,
+ -306, -333, 194, -44, 67, 72, 147, 205, 243,
+ -207, -49, 1360, 983, 969, 991, 1014, 1110, 973,
+ -211, -172, 883, 627, 711, 674, 705, 798, 746,
+ -88, -325, -763, -974, 687, 908, 514, 382, 172,
+ -292, -612, -805, 63, 131, 270, 259, 352, 348,
+ -235, -84, 955, 818, 1120, 1289, 1559, 1480, 1285,
+ -180, -461, -614, 657, 691, 745, 854, 783, 713,
+ -97, -309, -477, -614, -777, -734, -768, -526, -472,
+ -344, -476, -35, -169, 49, -77, -150, -240, -141,
+ -52, -268, -639, -919, -1278, -1113, -342, -333, -151,
+ -68, -242, -585, -73, -209, -478, -159, -429, 133,
+ -197, -499, -1005, -1268, -272, -224, -105, -67, 17,
+ -363, -618, -414, -116, -62, 20, 10, 116, 108,
+ -195, -475, -906, -1260, -891, -441, -277, -142, -28,
+ -226, -519, -950, -700, -275, -266, -116, -105, 82,
+ 404, 511, 520, 327, 17, -194, -333, -536, -586,
+ -114, -130, 276, 237, 204, 342, 135, -16, -111,
+ 670, 1208, 1168, 860, 742, 601, 528, 403, 309,
+ 397, 621, 966, 752, 579, 398, 400, 329, 252,
+ 191, 180, -137, -467, 272, 106, -95, 17, -192,
+ -80, -290, -626, 194, 598, 196, 21, -281, 77,
+ 510, 864, 1108, 807, 939, 902, 925, 717, 481,
+ 137, 367, 534, 764, 670, 382, 296, 153, 84,
+ 303, 497, 144, -85, -125, -539, -482, -464, -764,
+ 233, 347, 68, -147, 169, -210, -242, -226, -482,
+ 307, 422, 154, -175, -386, -722, -724, -904, -1015,
+ 309, 308, 160, -60, -470, -420, -598, -791, -219,
+ 68, 121, -137, -560, -146, -446, -515, -494, -729,
+ 130, 53, -227, 46, 474, 32, -161, -192, -490,
+ 213, 164, -71, -465, -876, -161, -456, -587, -48,
+ 218, 117, 39, 177, -194, -88, -226, -418, 50,
+ 210, 547, 569, 279, 121, -44, -50, 10, -84,
+ 58, 140, 182, -5, 267, 117, 106, 211, 198,
+ 539, 835, 913, 719, 617, 544, 591, 565, 642,
+ 153, 559, 872, 460, 222, 108, 188, 180, 183,
+ 158, 119, 284, -153, -271, 229, 87, 110, -57,
+ -183, 82, 118, 21, 13, 40, 118, 191, 185,
+ 162, 889, 654, 108, -34, 244, 488, 561, 532,
+ 163, 56, 609, 341, 50, 329, 68, 266, 218,
+ 100, 206, 18, -304, -107, -436, -487, -65, -306,
+ -86, 154, 134, -30, -45, -73, -104, -80, -96,
+ 245, 330, 10, -440, -849, -1082, 79, 40, -265,
+ 196, 372, 272, -181, -493, -389, 275, 80, -59,
+ 2, -12, -246, -505, -100, -436, 21, -187, -431,
+ -221, -48, 36, -271, -186, -147, -109, 26, 71,
+ 213, 140, 72, -351, -620, -84, -363, 69, 46,
+ 91, 167, -3, -95, -99, -105, -48, 114, 147,
+ 259, 249, 172, 607, 406, 52, 59, -189, -320,
+ 115, -85, -54, 574, 128, 226, -59, -253, 130,
+ -62, 1033, 1308, 1035, 1127, 1098, 1029, 961, 823,
+ 39, 364, 757, 940, 728, 660, 659, 583, 770,
+ -115, -338, -760, -471, 394, 37, 441, 178, 6,
+ -57, -305, -525, 796, 453, 188, -4, -114, 248,
+ 71, 444, 797, 731, 1096, 1157, 1222, 1029, 811,
+ 135, 359, 551, 425, 749, 815, 874, 704, 502,
+ 132, 247, 0, -206, -449, -750, -258, -514, -633,
+ 248, 249, 91, 121, -195, -499, -90, -282, -435,
+ 78, 20, -277, -623, -983, -1224, -415, -458, -639,
+ 347, 509, 208, -179, -464, -728, -76, -237, -486,
+ -103, -343, -756, -713, -265, -609, -191, -398, -636,
+ -121, -383, -749, 567, 252, -36, -354, -417, -50,
+ 204, 100, -149, -650, -1081, -47, -7, -263, 111,
+ -46, -180, -267, -324, -562, -394, -692, 398, 292,
+ 482, 670, 683, 624, 442, 165, 116, 36, -149,
+ 108, 247, 291, 247, 355, 122, 109, 224, 296,
+ -14, 945, 990, 801, 755, 815, 847, 913, 892,
+ 292, 349, 725, 482, 388, 329, 429, 620, 667,
+ -34, 197, 213, -127, 84, 494, 620, 575, 375,
+ 126, 207, 172, 167, 362, 202, 296, 395, 455,
+ -6, 250, 539, 467, 636, 801, 1149, 1287, 1118,
+ 27, 240, 369, 280, 440, 411, 634, 892, 953,
+ 159, 170, -58, -395, -797, -690, 77, -211, -334,
+ -5, -28, -13, -74, -335, -603, 300, 88, -205,
+ 82, -33, -364, -698, -1203, -1153, 110, -146, -289,
+ 113, 1, -243, -588, -994, -496, 414, 160, 42,
+ -56, -247, -440, -693, -996, -479, 11, -178, -357,
+ -151, -353, -327, -211, -340, 141, 65, 425, 453,
+ 34, -169, -455, -932, -1215, 138, 499, 256, 324,
+ 68, 139, -15, -547, -478, 17, 306, 502, 481,
+ -32, -134, 445, 129, -143, -244, -503, -507, -599,
+ 61, -140, -345, 496, 458, -2, 20, -227, -514,
+ 394, 1765, 1666, 1339, 1117, 806, 642, 479, 380,
+ 215, 519, 920, 1053, 1090, 791, 528, 290, 155,
+ -54, -233, -647, -602, 639, 294, -2, -167, -442,
+ -78, -315, -791, -113, 820, 403, 158, -116, -356,
+ 529, 1851, 2003, 1228, 622, -41, -416, 344, 819,
+ -105, -379, -236, 1224, 893, 749, 568, 356, 214,
+ -17, -199, -144, 50, -283, -247, -578, -846, -1087,
+ 69, -11, -381, -206, 209, -284, -387, -416, -716,
+ 39, -5, -145, -374, -682, -909, -1074, -1169, -1066,
+ 287, 226, 67, -221, -662, -171, -421, -642, -707,
+ -132, -348, -538, -448, -20, -4, -354, -748, -933,
+ 4, -75, -289, -598, 317, 52, -208, -297, -559,
+ -88, -264, -358, -589, -631, -248, -523, -822, -1071,
+ 70, -8, 54, -314, -515, 92, -146, -274, -493,
+ 199, 62, 391, 158, -141, 71, -219, -203, -207,
+ 152, 40, 329, 162, -29, 48, -149, 108, 127,
+ 635, 1058, 883, 492, 372, 312, 317, 274, 241,
+ 267, 722, 1256, 882, 625, 248, 8, -81, -60,
+ -58, -138, -291, -600, -12, -2, -39, 147, 117,
+ -107, -345, -513, 459, 76, 92, -272, 388, 262,
+ 362, 516, 203, -409, -716, -831, -331, 185, 209,
+ -117, -391, -298, 671, 292, 538, 257, 166, -38,
+ -102, -319, -194, -283, -573, -262, -579, -219, -444,
+ -235, 78, 11, -168, -101, -229, -263, -321, -123,
+ 70, 50, -170, -599, -996, -588, -263, -516, -455,
+ 394, 363, 229, -136, -538, 21, -183, -348, -201,
+ -124, -368, -640, -879, -847, -209, -409, -494, -515,
+ -127, -341, -541, -425, -510, -10, -252, -473, -291,
+ 84, -69, -201, -676, -868, 103, -311, -132, -320,
+ 5, -173, -188, -297, -628, 197, -57, 7, -11,
+ 49, -160, 56, 558, 111, 33, -311, -440, -463,
+ -1, -246, -307, 862, 453, 139, -170, -355, -232,
+ 279, 966, 1642, 1478, 1463, 1123, 795, 525, 339,
+ -197, -38, 1702, 1331, 1252, 950, 692, 504, 426,
+ -108, -344, -861, -1172, 444, 354, 88, -46, -220,
+ -53, -321, -494, 1113, 744, 364, 198, -34, -75,
+ 457, 955, 1177, 1214, 1427, 1457, 1345, 917, 539,
+ -69, 199, 897, 1140, 1343, 1183, 977, 742, 522,
+ 122, 44, -269, 27, -155, -562, -307, -590, -773,
+ 154, 42, -160, 252, -129, -305, -471, -733, -371,
+ 135, 185, -82, -416, -722, -913, -504, -743, -880,
+ 149, 214, -84, -329, -680, -835, -426, -661, -81,
+ -128, -380, -735, -998, -337, 17, -182, -467, -697,
+ -84, -290, -510, -592, 13, 440, 154, -38, -279,
+ 70, -61, -246, -727, -1047, -80, -381, -535, -704,
+ 178, -2, -146, -670, -938, 482, 138, 63, 65,
+ -11, 15, 772, 443, 142, -20, -209, -126, -161,
+ -32, -249, 95, 552, 124, 30, -343, 82, -86,
+ 148, 751, 1515, 1105, 867, 606, 474, 448, 399,
+ -163, -257, 899, 1097, 906, 751, 502, 390, 294,
+ -51, -258, -447, -806, -368, 763, 464, 364, 183,
+ -166, -374, -367, 87, 35, 399, 418, 856, 833,
+ -205, -310, 588, 778, 785, 1065, 1118, 1245, 1157,
+ -173, -312, 107, 345, 400, 790, 870, 1113, 1001,
+ -7, -120, -387, -410, -614, -943, -226, -384, -491,
+ -203, -288, -51, -331, -90, -178, -408, -573, -338,
+ 56, -29, -273, -627, -1041, -798, -247, -467, 148,
+ 66, -2, -205, -205, -575, -349, -57, -352, -58,
+ -45, -225, -471, -924, -497, 77, -32, 44, -135,
+ -277, -491, -497, -502, -424, -202, -137, 77, 96,
+ 26, -179, -469, -1008, -1260, 262, -35, -132, -259,
+ -66, -232, -447, -533, -789, -191, -100, -267, 364
+};
+
+/*
+ * 1st stage codebook; 2nd split: isf9 to isf15
+ */
+
+const Word16 D_ROM_dico2_isf[SIZE_BK2 * 7] = {
+
+ 1357, 1313, 1136, 784, 438, 181, 145,
+ 636, 648, 667, 568, 442, 217, 362,
+ 427, 440, 674, 524, 332, 117, -417,
+ 121, 295, 468, 465, 230, 44, -221,
+ -147, -240, 149, 80, 390, 278, 106,
+ -418, -556, 552, 511, 235, 144, -95,
+ 43, 193, 274, 150, 67, 34, -273,
+ -43, -126, 171, 416, 282, 63, -354,
+ -372, -86, -344, -108, -94, -182, -89,
+ -600, -840, -200, 465, 258, -11, -253,
+ -48, 329, 97, -290, -543, -795, -354,
+ -570, -117, 187, 10, -133, -416, -76,
+ -618, -129, -247, -371, 45, -76, 277,
+ -1022, -1079, 126, 474, 254, 127, 52,
+ -281, 76, -167, -361, -283, -551, -283,
+ -119, -52, -1, 134, -32, -204, -415,
+ 1064, 827, 637, 684, 464, 209, 12,
+ 482, 416, 449, 371, 335, 294, 194,
+ 719, 576, 365, 135, 113, 91, -199,
+ 298, 176, 493, 366, 194, 163, 36,
+ -35, -236, -259, -36, -4, 99, 152,
+ -98, -306, -27, 228, 90, 111, -86,
+ 91, 13, -211, -258, -106, 86, -64,
+ 73, -35, -57, -31, 162, 35, -192,
+ -109, -335, -629, -66, -61, -128, 322,
+ -495, -669, -728, 193, 31, -220, 122,
+ 324, 95, -89, -91, -409, -710, -154,
+ 0, -234, 92, 33, -343, -609, -220,
+ -343, -408, -476, -655, -153, 82, 222,
+ -490, -745, -255, 49, -48, 135, -127,
+ 119, -67, -328, -390, -272, -545, -56,
+ -57, -130, -10, -7, -164, -47, -22,
+ 984, 1064, 961, 568, 210, -27, 16,
+ 811, 691, 754, 514, 224, -35, 166,
+ 662, 704, 618, 386, 57, -211, -257,
+ 510, 359, 418, 393, 91, -144, -18,
+ -193, -31, -27, 223, 89, -143, 24,
+ -112, -98, 471, 319, 185, 3, 175,
+ 252, 146, -47, 272, 48, -211, -234,
+ 146, 69, 203, 364, 68, -52, 51,
+ -259, -478, -697, -349, -758, -501, 63,
+ -501, -769, -289, 79, -311, -497, -106,
+ 251, 53, -235, -469, -895, -884, 145,
+ -416, -551, 140, -133, -523, -775, 44,
+ -326, -423, -713, -497, -86, -431, 99,
+ -757, -772, -160, -76, -46, -32, 379,
+ 85, -35, -200, -401, -663, -1040, -247,
+ -180, -330, -92, -376, 27, -183, -110,
+ 1279, 1086, 781, 502, 324, 164, 157,
+ 682, 466, 449, 277, 146, 28, 409,
+ 635, 472, 390, 107, -232, -538, -139,
+ 196, 396, 332, 213, 209, -29, -81,
+ 150, -95, -312, 76, -77, -320, -50,
+ 46, 9, 47, 175, 139, 30, 384,
+ 218, 206, -24, -250, -96, -276, -183,
+ 26, 119, 38, 14, -4, -133, -52,
+ -477, -614, -987, -715, -631, -813, 200,
+ -744, -1009, -1065, -745, -631, -171, 18,
+ -137, -251, -483, -613, -980, -1203, 12,
+ -605, -767, -562, -686, -1088, -515, 58,
+ -202, -428, -782, -1072, -96, -234, -179,
+ -480, -709, -1070, -897, -131, -92, 321,
+ -145, -193, -512, -729, -572, -765, -210,
+ -331, -585, -525, -631, -281, -208, -303,
+ 1165, 1104, 939, 828, 716, 426, 155,
+ 6, -109, 820, 778, 415, 113, -27,
+ 381, 339, 314, 265, 121, -9, -474,
+ -373, 47, 584, 442, 99, -231, -113,
+ -496, -38, -285, 262, 305, 170, 4,
+ -587, -556, 69, 66, 471, 354, 13,
+ -138, 70, -18, 106, 67, 167, -302,
+ -445, -141, 185, 191, 151, 83, -133,
+ -257, -521, -720, -198, 134, -46, -182,
+ -819, -1168, -777, 512, 359, 95, -113,
+ 137, -2, -74, -138, -401, -114, -371,
+ -242, -466, 204, 223, -31, -212, -192,
+ -532, -637, -466, -686, 256, 277, -139,
+ -1141, -1244, -381, -75, -54, 14, 88,
+ -311, 115, -143, -499, -343, 124, -416,
+ -616, -147, -135, 43, -4, 121, -369,
+ 835, 783, 641, 390, 355, 350, 64,
+ 72, 194, 443, 467, 436, 219, 372,
+ 464, 369, 192, 4, -156, -72, -226,
+ 57, 206, 303, 205, 188, 101, 265,
+ -40, -205, -488, -184, 276, 64, -26,
+ -217, -433, -297, 137, 328, 308, -289,
+ 378, 81, -308, -465, 57, -37, 227,
+ -100, 24, -36, -151, 199, 8, 143,
+ -426, -697, -1059, -133, 388, 161, 321,
+ -644, -1023, -1271, 39, 66, -123, 70,
+ 372, 177, -173, -556, -553, -304, -189,
+ -117, -369, -425, -122, -462, -152, -73,
+ -649, -850, -1189, -767, 497, 360, 222,
+ -798, -1139, -1455, -190, 430, 234, 179,
+ 42, -94, -405, -692, 38, -202, -246,
+ -169, -366, -290, -88, -64, 32, -292,
+ 1010, 923, 938, 710, 465, 230, 342,
+ 217, 300, 1054, 675, 68, -458, -179,
+ 78, 453, 316, 18, -237, -496, -243,
+ 167, 21, 424, 215, -91, -303, -170,
+ -290, -81, -70, -67, 40, 54, -59,
+ -353, -427, -90, 53, 94, 9, 54,
+ -28, 318, 283, 15, -240, -58, 79,
+ -75, -121, 229, 35, 58, 6, -133,
+ -351, -514, -744, -834, -705, -137, 164,
+ -1124, -1388, -1055, -230, -73, 40, 36,
+ -163, -233, -532, -785, -1170, -697, 96,
+ -788, -959, -246, -430, -624, -165, -8,
+ -856, -540, -630, -907, -337, -70, 76,
+ -937, -1042, -659, -733, -208, 199, -26,
+ -523, 78, -98, -501, -869, -890, -81,
+ -624, -703, -45, -348, -25, 87, -186,
+ 1005, 823, 546, 249, 90, -22, 207,
+ 298, 397, 381, 319, 200, 62, 303,
+ 473, 379, 133, -247, -632, -441, 75,
+ 284, 208, 391, 115, -25, 44, 95,
+ -72, 79, -95, -63, -129, -293, 203,
+ -164, -349, 115, 122, 69, -1, 378,
+ 348, 170, 99, 58, -179, -302, 188,
+ -190, -2, 150, 23, -51, -11, 216,
+ -615, -863, -1090, -1427, -802, -48, -6,
+ -961, -1276, -1548, -727, -58, 56, 223,
+ -124, -255, -561, -988, -1277, -148, -82,
+ -480, -660, -891, -1191, -1339, -325, 20,
+ -621, -917, -1296, -1350, 264, 289, 50,
+ -844, -1022, -1345, -1329, -293, 46, 278,
+ -260, -468, -829, -1176, -533, -560, -78,
+ -215, -484, -822, -1233, -791, 15, -138,
+ 1301, 1317, 1262, 1048, 716, 357, -64,
+ 578, 824, 925, 802, 630, 362, 102,
+ 470, 925, 767, 514, 327, 190, -112,
+ 225, 492, 495, 437, 598, 384, -45,
+ 43, 82, -42, 175, 519, 342, -64,
+ -304, -154, 159, 576, 403, 221, 327,
+ 214, 244, 122, -62, 312, 92, -160,
+ 218, 208, 310, 268, 306, 323, -199,
+ -285, -269, -79, -124, -143, -153, 236,
+ -205, -384, -426, 344, 59, -185, -184,
+ -272, 247, 126, -210, -518, -468, 78,
+ -99, -120, 502, 160, -280, -557, 304,
+ -423, -17, -283, -443, 215, 212, -140,
+ -564, -684, -228, 510, 361, 130, 323,
+ -428, 335, 98, -65, 36, -215, -246,
+ -362, 51, 364, -16, -234, 150, -165,
+ 914, 883, 751, 653, 676, 464, -153,
+ 631, 545, 535, 720, 596, 360, -81,
+ 783, 712, 512, 439, 341, 251, -391,
+ 497, 417, 249, 372, 295, 173, -193,
+ 128, -110, -385, 93, 39, 173, -231,
+ 216, -59, -253, 462, 389, 154, 69,
+ 455, 270, -4, -337, -49, 233, -322,
+ 307, 143, 53, 218, 128, 236, -156,
+ -37, -186, -240, -411, -110, 9, 399,
+ -140, -365, -628, 258, 380, 214, 277,
+ 131, 454, 177, -285, -520, 108, -214,
+ 77, -141, 201, -123, -490, -131, 60,
+ -14, -194, -521, -741, 273, 362, -33,
+ -362, -566, -287, -228, 161, 237, 317,
+ -269, 195, -75, -375, -204, 11, 77,
+ -128, -264, -156, -223, -475, 265, 27,
+ 1238, 1147, 916, 689, 432, 210, -280,
+ 800, 664, 879, 726, 411, 160, -164,
+ 454, 686, 536, 275, 147, 46, 111,
+ 303, 486, 512, 355, 241, 181, -69,
+ 79, 92, 29, 147, 233, 52, 17,
+ -171, 289, 131, 439, 271, 3, -10,
+ 413, 241, 144, 174, 155, -2, 14,
+ 58, 217, 247, 219, 149, 175, -18,
+ 228, -8, -240, -206, -513, -191, 202,
+ -96, -272, -454, 33, -300, -575, 46,
+ -10, -108, -246, -347, -770, -535, 9,
+ -326, -430, -61, -321, -704, -299, 201,
+ -1, -280, -603, -419, -185, 18, -36,
+ -516, -522, -379, -291, -181, -97, 27,
+ -159, -313, -525, -224, -510, -831, -197,
+ -292, -459, -59, -310, -562, -143, -351,
+ 1066, 912, 631, 389, 207, 86, -224,
+ 596, 512, 596, 505, 314, 122, -48,
+ 787, 861, 441, -93, -303, 33, -190,
+ 257, 469, 337, 51, 15, 298, -93,
+ 295, 73, -119, 25, 36, 23, 108,
+ -28, -3, -32, 114, 21, 185, 107,
+ 482, 305, 15, -279, -319, 52, 96,
+ 226, 46, 115, 72, -136, 133, -125,
+ 18, -207, -559, -590, -503, -482, 321,
+ -571, -789, -951, -172, -441, -538, 113,
+ 181, 14, -310, -641, -1001, -202, 159,
+ -136, -393, -433, -513, -911, -144, -22,
+ 72, -265, -706, -954, -159, 53, 332,
+ -338, -591, -852, -383, -395, 56, 44,
+ 43, -158, -464, -897, -631, -157, -294,
+ -161, -128, -328, -573, -483, -125, 11,
+ 1017, 906, 1051, 1005, 679, 341, -102,
+ 359, 334, 1567, 1314, 723, 105, 10,
+ -65, 726, 529, 301, 220, 43, -273,
+ -510, 436, 719, 566, 358, 179, 114,
+ -560, 298, 133, -120, 342, 225, 14,
+ -899, -101, 217, 617, 400, 146, -58,
+ -41, 352, 82, -196, 39, 121, -167,
+ -212, 59, 447, 284, 423, 250, -169,
+ -371, -484, -596, 30, -41, 249, 22,
+ -372, -650, -794, 477, 445, 216, -79,
+ -352, 275, 17, -443, -929, 92, 19,
+ -699, -696, 431, 264, -49, -310, 182,
+ -978, -217, -430, -400, 101, 261, 72,
+ -929, -889, -357, -13, 463, 378, 236,
+ -826, 56, 30, -299, -360, -128, -51,
+ -878, -299, -111, 75, 65, 36, 3,
+ 817, 368, -25, 354, 697, 591, -173,
+ 309, 212, 222, 751, 484, 140, -56,
+ 593, 379, 70, -8, 258, 180, 110,
+ 165, -46, 255, 297, 219, 273, 105,
+ 160, -70, -358, -181, 379, 330, 319,
+ -238, -369, -198, 740, 580, 319, -143,
+ 201, 109, -202, -456, 328, 276, -141,
+ 203, 170, 111, 42, 207, 360, 188,
+ -345, -399, -513, -233, 650, 422, 81,
+ -635, -961, -1220, 463, 539, 204, 209,
+ 202, -25, -194, -498, -787, 193, -143,
+ -449, -538, 195, -106, -331, 68, 62,
+ -228, -477, -840, -576, 317, 128, 283,
+ -671, -937, -807, -114, 391, 335, -62,
+ 246, 2, -314, -679, -303, 180, -88,
+ -107, -272, 90, -198, -28, 290, -112,
+ 885, 1149, 1021, 712, 496, 281, -83,
+ 269, 492, 787, 643, 347, 70, 124,
+ 336, 636, 499, 92, -229, -179, 191,
+ 26, 402, 564, 340, 149, -11, 135,
+ -440, 561, 470, 204, -72, -186, 140,
+ -720, 14, 355, 229, 68, -133, 465,
+ 110, 310, 103, 12, 106, 29, 158,
+ -178, 113, 161, 142, 121, 115, 27,
+ -651, -414, -645, -152, -164, -13, -429,
+ -639, -944, -681, -104, -81, 52, -189,
+ -663, -164, -316, -683, -954, -205, -83,
+ -609, -669, -172, -517, -694, 283, -80,
+ -646, -152, -383, -678, -246, -40, -143,
+ -747, -796, -745, -390, -98, 43, 275,
+ -599, -199, -398, -433, -436, -538, 31,
+ -1107, -568, -376, -265, -126, -21, 1,
+ 847, 573, 308, 392, 305, 101, 55,
+ 273, 293, 201, 267, 346, 201, 123,
+ 727, 480, 226, 2, -65, -138, 164,
+ 273, 208, 173, 292, 12, 253, 174,
+ 340, 207, 180, 88, 116, 46, 475,
+ -460, -166, -30, 13, 110, 173, 396,
+ 137, 88, 43, -137, -94, 34, 284,
+ 96, -14, 226, 40, 63, 70, 130,
+ -467, -735, -1012, -1174, -307, 305, -67,
+ -612, -920, -1146, -567, -8, 92, -25,
+ -182, -271, -492, -754, -857, 287, -75,
+ -494, -787, -689, -683, -709, 137, -326,
+ -288, -550, -903, -1105, 334, 321, -62,
+ -354, -653, -834, -445, 1, 377, -152,
+ -162, -306, -608, -937, -297, 247, -192,
+ -234, -477, -244, -488, -266, 342, -332
+};
+
+/*
+ * 2nd stage codebook; 1st split: isf2_0 to isf2_2
+ */
+const Word16 D_ROM_dico21_isf[SIZE_BK21 * 3] = {
+
+ 329, 409, 249,
+ -33, 505, 160,
+ -29, -14, 582,
+ -262, 127, 354,
+ 145, 237, 175,
+ -152, 245, 122,
+ 27, 42, 340,
+ -84, -93, 311,
+ 285, 222, -156,
+ 47, -43, -504,
+ 234, 121, 385,
+ 104, -317, 45,
+ 176, 195, 8,
+ 104, -59, -94,
+ 177, 53, 192,
+ -34, -127, 152,
+ 570, 277, -34,
+ -67, -329, -639,
+ -157, -272, 462,
+ -177, -462, 198,
+ 322, 179, 115,
+ -386, 171, 19,
+ 19, -12, 195,
+ -120, -252, 201,
+ 304, 36, -336,
+ -128, -221, -380,
+ 171, -185, 296,
+ -242, -312, 23,
+ 198, 39, 16,
+ -3, -177, -111,
+ 111, -93, 76,
+ -92, -223, 4,
+ 177, 406, -44,
+ -168, 380, -149,
+ -4, 273, 331,
+ -420, 513, 277,
+ 21, 247, 47,
+ -58, 131, -2,
+ -3, 134, 180,
+ -145, 40, 175,
+ 189, 74, -145,
+ -27, -45, -325,
+ 370, -114, -21,
+ -83, -415, -173,
+ 77, 95, -51,
+ -40, -30, -67,
+ 71, 88, 86,
+ -35, -98, 14,
+ 69, 197, -334,
+ -196, 79, -231,
+ -348, -137, 218,
+ -352, -89, -85,
+ 47, 201, -130,
+ -165, 37, -15,
+ -43, 3, 86,
+ -161, -108, 79,
+ 83, 21, -237,
+ -81, -149, -238,
+ 150, -186, -251,
+ -186, -249, -162,
+ -19, 66, -139,
+ -26, -50, -181,
+ 24, 11, 0,
+ -130, -105, -98
+};
+
+
+
+/*
+ * 2nd stage codebook; 2nd split: isf2_3 to isf2_5
+ */
+const Word16 D_ROM_dico22_isf[SIZE_BK22 * 3] = {
+
+ -127, 310, 42,
+ -242, 197, 5,
+ -151, 84, -17,
+ -214, 127, -149,
+ -247, -131, 159,
+ -268, -267, -95,
+ -217, 1, -79,
+ -271, -80, -185,
+ -45, 436, 159,
+ 165, 199, 391,
+ -33, 81, 187,
+ -66, -42, 355,
+ -298, -57, 343,
+ -108, -537, 226,
+ -144, -23, 193,
+ 176, -402, 87,
+ 53, 296, 25,
+ -84, 253, -104,
+ -58, 105, -126,
+ -169, 174, -314,
+ -48, 44, -294,
+ -164, -417, -242,
+ -139, 3, -194,
+ -155, -207, -211,
+ 119, 322, 213,
+ 333, 50, 380,
+ 237, 247, -2,
+ 466, -16, 201,
+ 238, -255, -107,
+ 67, -440, -149,
+ 122, -88, -139,
+ 88, -247, -73,
+ -41, 231, 167,
+ -62, 155, 16,
+ -65, 16, 77,
+ -68, -2, -63,
+ -151, -300, 160,
+ -18, -333, 54,
+ -56, -94, 5,
+ 2, -190, 14,
+ 92, 148, 209,
+ 108, 9, 272,
+ 108, 35, 110,
+ 142, -85, 145,
+ 47, -157, 279,
+ 3, -320, 246,
+ 43, -72, 68,
+ 86, -217, 135,
+ 36, 140, 79,
+ 56, 175, -49,
+ 26, 45, 3,
+ 73, 55, -101,
+ 109, -183, -242,
+ -4, -283, -242,
+ 48, -68, -48,
+ -6, -153, -122,
+ 161, 196, 96,
+ 232, 80, 190,
+ 165, 97, 11,
+ 258, -31, 71,
+ 267, -77, -91,
+ 311, -209, 87,
+ 152, -14, -22,
+ 150, -149, 9,
+ -324, 557, 187,
+ -384, 307, 46,
+ -251, 27, 77,
+ -365, 77, -52,
+ -482, -84, 160,
+ -424, -515, -64,
+ -294, -120, -4,
+ -476, -116, -109,
+ -97, 318, 365,
+ 106, 627, 445,
+ -190, 120, 287,
+ -146, 65, 619,
+ -427, 242, 363,
+ -361, -371, 432,
+ -347, 102, 168,
+ -629, 195, -14,
+ -65, 476, -47,
+ -297, 320, -168,
+ -55, 356, -264,
+ -391, 82, -286,
+ -51, -31, -556,
+ -178, -399, -586,
+ -205, -49, -360,
+ -343, -238, -337,
+ 220, 457, 58,
+ 561, 467, 259,
+ 340, 270, -168,
+ 450, 77, -280,
+ 60, 167, -413,
+ 133, -252, -492,
+ 216, 157, -290,
+ 282, 0, -495,
+ -226, 293, 183,
+ -157, 135, 122,
+ -158, -59, 39,
+ -133, -118, -97,
+ -332, -309, 113,
+ -160, -425, -6,
+ -149, -211, 24,
+ -80, -277, -90,
+ -11, 125, 338,
+ 130, -71, 465,
+ 5, -45, 184,
+ 237, -95, 253,
+ -139, -197, 297,
+ -19, -300, 511,
+ -63, -152, 139,
+ 250, -289, 336,
+ 124, 339, -150,
+ 34, 176, -208,
+ 171, 166, -116,
+ 94, 38, -229,
+ 75, -65, -339,
+ -78, -205, -385,
+ 0, -30, -163,
+ -56, -110, -242,
+ 321, 244, 194,
+ 505, 238, -1,
+ 317, 116, 65,
+ 309, 88, -74,
+ 452, -51, -50,
+ 334, -217, -290,
+ 211, 41, -152,
+ 238, -55, -260
+};
+
+
+/*
+ * 2nd stage codebook; 3rd split: isf2_6 to isf2_8
+ */
+const Word16 D_ROM_dico23_isf[SIZE_BK23 * 3] = {
+
+ -10, 151, 359,
+ 136, 298, 223,
+ 255, -104, 290,
+ 423, 6, 183,
+ -270, -269, -98,
+ -52, -82, 13,
+ -82, -274, -97,
+ 90, -246, -72,
+ -299, -70, 421,
+ -88, 365, 430,
+ 187, -318, 381,
+ 380, 37, 488,
+ -373, -316, 79,
+ -308, -101, 5,
+ -135, -451, 8,
+ 72, -421, -154,
+ 180, 170, -121,
+ 62, 177, -40,
+ 326, 80, -105,
+ 248, 263, -5,
+ -168, -181, -221,
+ -2, -23, -158,
+ -14, -149, -121,
+ 119, -91, -147,
+ 119, 332, -153,
+ 49, 303, 34,
+ 442, -55, -69,
+ 217, 454, 58,
+ -359, -187, -375,
+ -42, 50, -274,
+ -8, -267, -249,
+ 85, -86, -346,
+ -77, -40, 345,
+ 89, 134, 219,
+ 156, -80, 160,
+ 108, 40, 116,
+ -158, -206, 29,
+ 5, -32, 175,
+ -65, -158, 146,
+ 55, -78, 73,
+ -114, -222, 353,
+ -47, 81, 211,
+ 49, -151, 268,
+ 105, 4, 302,
+ -263, -132, 183,
+ -151, -28, 201,
+ -177, -307, 166,
+ 101, -221, 130,
+ 74, 58, -98,
+ 32, 44, 13,
+ 194, 30, -142,
+ 170, 96, 8,
+ -136, -119, -91,
+ -65, 8, -55,
+ 3, -188, 12,
+ 45, -63, -49,
+ 149, -21, -19,
+ 24, 144, 95,
+ 254, -22, 60,
+ 161, 196, 96,
+ -158, -61, 48,
+ -70, 33, 82,
+ -23, -321, 58,
+ 155, -147, 5,
+ -364, 328, 77,
+ -21, 453, 173,
+ -108, 82, 630,
+ 367, 263, 208,
+ -300, -62, -176,
+ -205, 143, -158,
+ -169, -410, -264,
+ 257, -269, -100,
+ -636, 289, -2,
+ -292, 627, 173,
+ -382, -363, 387,
+ 248, 524, 447,
+ -521, -111, -107,
+ -395, 118, -274,
+ -343, -680, -125,
+ -172, -447, -663,
+ 75, 148, -367,
+ -79, 263, -94,
+ 249, 148, -286,
+ 380, 271, -162,
+ -142, -4, -186,
+ -57, 111, -125,
+ -35, -108, -254,
+ 100, 29, -242,
+ -80, 303, -264,
+ -78, 464, -57,
+ 248, -22, -494,
+ 661, 662, 44,
+ -193, -40, -330,
+ -178, 145, -337,
+ -90, -199, -400,
+ -40, -23, -498,
+ -192, 114, 315,
+ -41, 244, 190,
+ 88, -97, 485,
+ 241, 80, 212,
+ -246, 40, 87,
+ -156, 147, 134,
+ -2, -334, 239,
+ 308, -203, 110,
+ -459, 251, 422,
+ -218, 310, 228,
+ -86, -346, 654,
+ 184, 175, 425,
+ -481, -63, 169,
+ -349, 117, 188,
+ -125, -560, 310,
+ 158, -416, 94,
+ 46, 171, -192,
+ -63, 157, 14,
+ 256, -35, -271,
+ 322, 123, 53,
+ -214, 4, -76,
+ -156, 86, -18,
+ 128, -197, -232,
+ 265, -90, -98,
+ -308, 332, -145,
+ -131, 308, 58,
+ 509, 59, -339,
+ 562, 196, -14,
+ -378, 100, -47,
+ -234, 202, 1,
+ 104, -270, -493,
+ 319, -210, -325
+};
+
+
+/*
+ * 2nd stage codebook; 4th split: isf2_9 to isf2_11
+ */
+const Word16 D_ROM_dico24_isf[SIZE_BK24 * 3] = {
+
+ -79, -89, -4,
+ -171, 77, -211,
+ 160, -193, 98,
+ 120, -103, 323,
+ 32, -22, -129,
+ 72, 78, -268,
+ 182, -76, -66,
+ 309, 99, -145,
+ -229, -157, -84,
+ -383, 98, -71,
+ -90, -352, 12,
+ -284, -178, 178,
+ -65, -125, -166,
+ -87, -175, -351,
+ 42, -198, -48,
+ 154, -140, -243,
+ -77, 18, 108,
+ -39, 355, 91,
+ 87, 8, 155,
+ -4, 158, 239,
+ 128, 95, -54,
+ 7, 246, -124,
+ 258, 15, 89,
+ 206, 216, 98,
+ -201, 9, 18,
+ -312, 233, 204,
+ -39, -174, 155,
+ -144, -9, 284,
+ -57, 70, -69,
+ -157, 187, 18,
+ 54, -30, 23,
+ 24, 135, 55
+};
+
+
+/*
+ * 2nd stage codebook; 5th split: isf2_12 to isf2_15
+ */
+const Word16 D_ROM_dico25_isf[SIZE_BK25 * 4] = {
+
+ 169, 142, -119, 115,
+ 206, -20, 94, 226,
+ -106, 313, -21, 16,
+ -62, 161, 71, 255,
+ -89, 101, -185, 125,
+ 72, -30, -201, 344,
+ -258, 33, -8, 81,
+ -104, -154, 72, 296,
+ 144, -68, -268, -25,
+ 81, -78, -87, 106,
+ 22, 155, -186, -119,
+ -46, -28, 27, 91,
+ -114, -37, -175, -33,
+ -94, -222, -189, 122,
+ -132, -119, -191, -270,
+ -172, -173, 18, -43,
+ 279, 135, -42, -128,
+ 187, -86, 229, -138,
+ 159, 240, 140, 46,
+ 69, 25, 227, 77,
+ 21, 115, 13, 8,
+ 68, -248, 126, 81,
+ -150, 137, 207, -9,
+ -154, -133, 289, 67,
+ 143, -37, -86, -326,
+ 180, -32, 19, -23,
+ 26, 168, 116, -233,
+ -32, -26, 118, -78,
+ 3, -8, -45, -115,
+ 57, -215, -54, -83,
+ -209, 112, -22, -167,
+ -91, -151, 168, -262
+};
+
+/*
+ * isf codebooks: two-stage VQ with split-by-3 in 2nd stage
+ * 1st stage is kept the same as the 46 bit quantizer
+ *
+ * codebook vector dimension number of vectors
+ * ~~~~~~~~ ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
+ * 1_1 9 256
+ * 1_2 7 256
+ * 2_1 5 128
+ * 2_2 4 128
+ * 2_3 7 64
+ */
+
+const Word16 D_ROM_dico21_isf_36b[SIZE_BK21_36b * 5] = {
+
+ -52, -96, 212, 315, -73,
+ 82, -204, 363, 136, -197,
+ -126, -331, 183, 218, 143,
+ -49, -41, 557, 230, 72,
+ 2, -73, 163, 377, 221,
+ 133, 111, 278, 215, -110,
+ -102, -20, 284, 113, 273,
+ 84, 319, 290, 18, 85,
+ -25, -5, 125, 132, -204,
+ -38, -5, 286, -9, -356,
+ -140, -256, 92, 117, -189,
+ -144, 191, 313, 51, -98,
+ 167, -10, 44, 247, 36,
+ 381, 197, 238, 74, 6,
+ 38, -408, 29, -3, -85,
+ 92, 266, 157, -25, -200,
+ 161, -121, 70, 84, -140,
+ -16, -86, 112, -94, -189,
+ -269, -270, 351, 107, -24,
+ -68, -67, 492, -103, -155,
+ -53, -131, 62, 122, 10,
+ 135, 84, 283, -55, -120,
+ -12, -219, 331, -81, 167,
+ 220, -136, 147, -172, -42,
+ 140, -95, -109, -88, -194,
+ 0, -2, -4, -33, -381,
+ -66, -217, 152, -186, -402,
+ 244, 108, 156, -140, -395,
+ 113, -136, -196, 110, -24,
+ 214, 118, 11, -64, -131,
+ -110, -286, -6, -332, 16,
+ 94, 97, 79, -291, -205,
+ -5, -39, -20, 252, -96,
+ 76, 174, 101, 163, 61,
+ -69, -239, -55, 399, 6,
+ -115, 319, 164, 275, 196,
+ -15, 36, -47, 331, 121,
+ 226, 209, 271, 325, 184,
+ 13, -80, -218, 471, 353,
+ 288, 378, 16, -51, 251,
+ 174, 116, 52, 149, -279,
+ 235, 276, 39, 120, -48,
+ 0, -108, -108, 241, -339,
+ -93, 534, 45, 33, -87,
+ 194, 149, -71, 405, -44,
+ 409, 370, 81, -186, -154,
+ 25, -102, -448, 124, -173,
+ 22, 408, -110, -310, -214,
+ -26, 23, -83, 114, 14,
+ -110, 164, 52, 223, -82,
+ 37, -25, -263, 306, -15,
+ -466, 415, 292, 165, -18,
+ 29, -19, -171, 155, 182,
+ 179, 144, -27, 231, 258,
+ -103, -247, -396, 238, 113,
+ 375, -154, -109, -4, 156,
+ 98, 85, -292, -5, -124,
+ 116, 139, -116, -98, -294,
+ -14, -83, -278, -117, -378,
+ 106, 33, -106, -344, -484,
+ 119, 17, -412, 138, 166,
+ 384, 101, -204, 88, -156,
+ -121, -284, -300, -1, -166,
+ 280, 33, -152, -313, -81,
+ -37, 22, 229, 153, 37,
+ -60, -83, 236, -8, -41,
+ -169, -228, 126, -20, 363,
+ -235, 17, 364, -156, 156,
+ -25, -30, 72, 144, 156,
+ 153, -26, 256, 97, 144,
+ -21, -37, 48, -65, 250,
+ 63, 77, 273, -128, 124,
+ -129, -26, 40, 9, -115,
+ -6, 82, 38, -90, -182,
+ -336, -13, 28, 158, 91,
+ -30, 241, 137, -170, -17,
+ 146, 14, -11, 33, 61,
+ 192, 197, 54, -84, 85,
+ 23, -200, -78, -29, 140,
+ 122, 237, 106, -341, 136,
+ -57, -142, -85, -16, -74,
+ -59, -90, -8, -187, -20,
+ -211, -267, 216, -179, -110,
+ -50, -7, 220, -267, -70,
+ -57, -42, -17, -15, 71,
+ 32, 21, 63, -137, 33,
+ -137, -175, 104, -68, 97,
+ -67, -43, 133, -301, 221,
+ -116, -200, -81, -92, -272,
+ -64, -41, -54, -244, -220,
+ -287, -242, -50, -87, -89,
+ -245, 236, 102, -166, -295,
+ 66, 24, -162, -71, 95,
+ 66, 136, -90, -220, -36,
+ -98, -161, -222, -188, 29,
+ -18, 18, -19, -415, 9,
+ 49, 61, 100, 39, -56,
+ -111, 82, 135, -31, 52,
+ -90, -153, -93, 189, 182,
+ -214, 295, 119, -74, 284,
+ 2, 137, 37, 47, 182,
+ 92, 117, 184, -53, 373,
+ -21, -14, -35, 136, 391,
+ 146, 129, -164, -28, 333,
+ 92, 80, -84, 100, -134,
+ -8, 217, -32, 3, -47,
+ -151, 251, -215, 142, 92,
+ -224, 310, -172, -275, 98,
+ 159, 155, -177, 112, 53,
+ 205, 27, 8, -240, 192,
+ 169, 120, -319, -201, 106,
+ 11, 36, -86, -237, 455,
+ -109, -154, -163, 174, -55,
+ -38, 32, -101, -78, -59,
+ -205, -321, -97, 69, 79,
+ -310, 44, 18, -185, 34,
+ -115, -20, -148, -39, 203,
+ -29, 154, -30, -158, 166,
+ -45, -131, -317, -24, 363,
+ -165, -205, -112, -222, 265,
+ -32, -44, -150, 54, -193,
+ -6, -38, -255, -169, -115,
+ -266, 87, -189, -36, -169,
+ -60, -87, -266, -436, -170,
+ -68, -81, -278, 24, 38,
+ -23, -19, -155, -256, 141,
+ -61, -226, -565, -175, 71,
+ 9, -29, -237, -515, 263
+};
+
+const Word16 D_ROM_dico22_isf_36b[SIZE_BK22_36b * 4] = {
+
+ -298, -6, 95, 31,
+ -213, -87, -122, 261,
+ 4, -49, 208, 14,
+ -129, -110, 30, 118,
+ -214, 258, 110, -235,
+ -41, -18, -126, 120,
+ 103, 65, 127, -37,
+ 126, -36, -24, 25,
+ -138, -67, -278, -186,
+ -164, -194, -201, 78,
+ -211, -87, -51, -221,
+ -174, -79, -94, -39,
+ 23, -6, -157, -240,
+ 22, -110, -153, -68,
+ 148, -5, -2, -149,
+ -1, -135, -39, -179,
+ 68, 360, -117, -15,
+ 137, 47, -278, 146,
+ 136, 260, 135, 65,
+ 61, 116, -45, 97,
+ 231, 379, 87, -120,
+ 338, 177, -272, 3,
+ 266, 156, 28, -69,
+ 260, 84, -85, 86,
+ -266, 154, -256, -182,
+ -17, -65, -304, -6,
+ -40, 175, -151, -180,
+ -27, 27, -87, -63,
+ 121, 114, -166, -469,
+ 159, -66, -323, -231,
+ 214, 152, -141, -212,
+ 137, 36, -184, -51,
+ -282, -237, 40, 10,
+ -48, -235, -37, 251,
+ -54, -323, 136, 29,
+ -88, -174, 213, 198,
+ -390, 99, -63, -375,
+ 107, -169, -164, 424,
+ 69, -111, 141, -167,
+ 74, -129, 65, 144,
+ -353, -207, -205, -109,
+ -160, -386, -355, 98,
+ -176, -493, -20, -143,
+ -252, -432, -2, 216,
+ -90, -174, -168, -411,
+ 13, -284, -229, -160,
+ -87, -279, 34, -251,
+ -75, -263, -58, -42,
+ 420, 53, -211, -358,
+ 384, -35, -374, 396,
+ 68, -228, 323, -2,
+ 167, -307, 192, 194,
+ 459, 329, -5, -332,
+ 375, 79, -7, 313,
+ 282, -124, 200, -92,
+ 271, -162, -70, 180,
+ -157, -298, -514, -309,
+ 58, -163, -546, 18,
+ 124, -364, 167, -238,
+ 83, -411, -117, 96,
+ 140, -112, -388, -624,
+ 259, -133, -317, 41,
+ 163, -130, -64, -334,
+ 226, -165, -124, -110,
+ -466, -61, 6, 229,
+ -153, 205, -145, 242,
+ -159, 48, 195, 148,
+ -58, 28, 31, 279,
+ -303, 185, 279, -4,
+ -61, 197, 59, 86,
+ -114, 123, 168, -52,
+ 35, 36, 100, 126,
+ -407, 102, -77, -40,
+ -338, -1, -342, 156,
+ -179, 105, -34, -97,
+ -185, 84, -35, 108,
+ -133, 107, -91, -357,
+ -180, 54, -229, 24,
+ -44, 47, 47, -182,
+ -66, 13, 45, 4,
+ -339, 251, 64, 226,
+ -42, 101, -350, 275,
+ -99, 398, 142, 121,
+ 111, 12, -102, 260,
+ 0, 505, 260, -94,
+ 161, 285, -96, 224,
+ -4, 206, 314, 33,
+ 167, 139, 88, 204,
+ -235, 316, -60, -25,
+ -8, -150, -312, 201,
+ -36, 292, 61, -104,
+ -40, 174, -162, 42,
+ -21, 402, -29, -351,
+ 21, 152, -360, -93,
+ 57, 191, 212, -196,
+ 76, 158, -21, -69,
+ -328, -185, 331, 119,
+ -53, 285, 56, 337,
+ -107, -24, 405, 29,
+ -18, 137, 272, 277,
+ -255, 22, 173, -191,
+ 295, 322, 325, 302,
+ 21, -27, 332, -178,
+ 119, 13, 271, 129,
+ -455, -180, 116, -191,
+ -227, 62, -148, 524,
+ -176, -287, 282, -157,
+ -243, 13, 199, 430,
+ -59, -49, 115, -365,
+ 72, -172, -137, 93,
+ -138, -126, 141, -84,
+ 5, -124, 38, -20,
+ -258, 311, 601, 213,
+ 94, 130, -61, 502,
+ -1, -157, 485, 313,
+ 146, -74, 158, 345,
+ 276, 135, 280, -57,
+ 490, 252, 99, 43,
+ 267, -74, 429, 105,
+ 278, -23, 119, 94,
+ -542, 488, 257, -115,
+ -84, -244, -438, 478,
+ -113, -545, 387, 101,
+ -95, -306, 111, 498,
+ 95, 166, 22, -301,
+ 420, -15, -58, -78,
+ 270, 29, 122, -282,
+ 160, -240, 50, -38
+};
+
+const Word16 D_ROM_dico23_isf_36b[SIZE_BK23_36b * 7] = {
+
+ 81, -18, 68, -27, -122, -280, -4,
+ 45, -177, 209, -30, -136, -74, 131,
+ -44, 101, -75, -88, -48, -137, -54,
+ -245, -28, 63, -18, -112, -103, 58,
+ -79, -6, 220, -65, 114, -35, -50,
+ 109, -65, 143, -114, 129, 76, 125,
+ 166, 90, -61, -242, 186, -74, -43,
+ -46, -92, 49, -227, 24, -155, 39,
+ 67, 85, 99, -42, 53, -184, -281,
+ 142, -122, 0, 21, -142, -15, -17,
+ 223, 92, -21, -48, -82, -14, -167,
+ 51, -37, -243, -30, -90, 18, -56,
+ 54, 105, 74, 86, 69, 13, -101,
+ 196, 72, -89, 43, 65, 19, 39,
+ 121, 34, 131, -82, 25, 213, -156,
+ 101, -102, -136, -21, 57, 214, 22,
+ 36, -124, 205, 204, 58, -156, -83,
+ 83, -117, 137, 137, 85, 116, 44,
+ -92, -148, -68, 11, -102, -197, -220,
+ -76, -185, -58, 132, -26, -183, 85,
+ -7, -31, -2, 23, 205, -151, 10,
+ -27, -37, -5, -18, 292, 131, 1,
+ 117, -168, 9, -93, 80, -59, -125,
+ -182, -244, 98, -24, 135, -22, 94,
+ 221, 97, 106, 42, 43, -160, 83,
+ 25, -64, -21, 6, 14, -15, 154,
+ 126, 15, -140, 150, -10, -207, -114,
+ 79, -63, -211, -70, -28, -217, 165,
+ 46, 38, -22, 281, 132, -62, 109,
+ 112, 54, -112, -93, 208, 27, 296,
+ 115, 10, -147, 41, 216, 42, -276,
+ 50, -115, -254, 167, 117, -2, 61,
+ 17, 144, 34, -72, -186, -150, 272,
+ -29, -66, -89, -95, -149, 129, 251,
+ 122, 0, -50, -234, -91, 36, 26,
+ -105, -102, -88, -121, -236, -7, -11,
+ -204, 109, 5, -191, 105, -15, 163,
+ -80, 32, -24, -209, 41, 294, 70,
+ -106, -94, -204, -118, 120, -50, -37,
+ -82, -241, 46, -131, -29, 150, -55,
+ 33, 155, 120, -89, -8, 7, 62,
+ 213, 82, 61, 18, -161, 144, 152,
+ 30, 131, 65, -87, -255, -17, -107,
+ -8, 85, -64, 51, -162, 223, -53,
+ -134, 261, 69, -56, 218, 72, -111,
+ 2, 155, -113, -87, 49, 85, -28,
+ -163, 42, -1, -196, 7, 39, -245,
+ 14, -137, -79, 11, -160, 202, -293,
+ -94, 33, 208, 100, 56, -44, 326,
+ -78, -41, 232, 13, -142, 227, 80,
+ -16, -87, 201, 33, -133, 15, -183,
+ -58, -192, -47, 184, -128, 133, 99,
+ -205, 11, -155, 78, 52, 72, 141,
+ -246, 26, 99, 151, 59, 115, -64,
+ -79, -47, -16, -14, 6, 47, -43,
+ -72, -178, -27, 162, 112, 43, -174,
+ -175, 238, 186, 71, -54, -188, -76,
+ -225, 233, 39, -39, -158, 122, 44,
+ -26, 43, 84, 130, -93, -51, 22,
+ 3, 92, -150, 136, -182, -57, 97,
+ -131, 179, -78, 80, 91, -165, 90,
+ -2, 148, 15, 130, 65, 175, 117,
+ -138, 114, -137, 132, 3, -10, -186,
+ 140, -4, -37, 254, -62, 92, -109
+};
+
+/*
+ * isf codebooks: split-by-5 VQ
+ *
+ * codebook vector dimension number of vectors
+ * ~~~~~~~~ ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
+ * 1 2 64
+ * 2 3 64
+ * 3 3 64
+ * 4 4 32
+ * 5 4 32
+ */
+
+/*
+ * 1st split: isf0 to isf1
+ */
+const Word16 D_ROM_dico1_isf_noise[SIZE_BK_NOISE1 * 2] = {
+ -269, -673,
+ -222, -537,
+ -233, -430,
+ -138, -451,
+ -212, -331,
+ -192, -241,
+ -87, -231,
+ -191, -128,
+ -70, -106,
+ -164, -6,
+ 74, -179,
+ 27, -33,
+ -102, 74,
+ -162, 115,
+ -94, 172,
+ -6, 130,
+ -143, 234,
+ 14, 218,
+ -65, 270,
+ 88, 182,
+ -124, 341,
+ -44, 381,
+ 38, 335,
+ 117, 274,
+ -112, 454,
+ 74, 431,
+ -5, 488,
+ 175, 384,
+ -83, 561,
+ 122, 529,
+ 21, 601,
+ 229, 481,
+ 231, 303,
+ 226, 608,
+ 300, 372,
+ 210, 187,
+ 306, 265,
+ 328, 473,
+ 382, 331,
+ 371, 132,
+ 139, 58,
+ 365, 21,
+ 250, -82,
+ 443, 218,
+ 483, 110,
+ 426, 415,
+ 579, 222,
+ 518, 333,
+ 573, 448,
+ 455, 529,
+ 685, 329,
+ 332, 580,
+ 595, 593,
+ 468, 645,
+ 762, 517,
+ 326, 709,
+ 485, 793,
+ 130, 684,
+ 671, 737,
+ 354, 876,
+ 88, 806,
+ -65, 706,
+ -35, 1016,
+ 266, 1123
+};
+
+
+/*
+ * 2nd split: isf2 to isf4
+ */
+const Word16 D_ROM_dico2_isf_noise[SIZE_BK_NOISE2 * 3] = {
+ -824, -884, -949,
+ -805, -456, -418,
+ -442, -438, -541,
+ -217, -578, -793,
+ -168, -444, -582,
+ -287, -492, -274,
+ -552, -297, -300,
+ -163, -333, -358,
+ -370, -232, -232,
+ -175, -358, -159,
+ -381, -21, -357,
+ -184, -159, -162,
+ -53, -191, -280,
+ 18, -267, -215,
+ -138, 61, -283,
+ 71, -95, -294,
+ 13, -156, -546,
+ 0, -83, -79,
+ 44, 97, -316,
+ 178, -52, -213,
+ 222, -261, -422,
+ 237, -118, -44,
+ 141, 145, -132,
+ 363, 81, -287,
+ 213, 65, 34,
+ -107, 94, -5,
+ 91, -29, 126,
+ -355, 51, -41,
+ -219, -76, 145,
+ -63, 100, 244,
+ -719, 44, 27,
+ -572, -124, 155,
+ -423, 133, 315,
+ -917, 71, 224,
+ -268, 318, 131,
+ -93, -190, 420,
+ -97, 122, 491,
+ -79, 317, 355,
+ 130, 100, 325,
+ 86, -293, 210,
+ 133, 258, 161,
+ 176, -73, 465,
+ 195, 300, 384,
+ 348, 22, 221,
+ 376, 183, 409,
+ 377, 286, 202,
+ 242, 213, 659,
+ 257, 565, 248,
+ 344, 408, -76,
+ 405, 440, 509,
+ 612, 385, 379,
+ 536, 607, 216,
+ -56, 582, 192,
+ 100, 517, 567,
+ -365, 448, 445,
+ 728, 347, 10,
+ 505, 357, 759,
+ 636, 582, 658,
+ 335, 517, 852,
+ 378, 809, 572,
+ -195, 878, 829,
+ 529, 707, 987,
+ 918, 726, 392,
+ 1250, 997, 1063
+};
+
+/*
+ * 3rd split: isf5 to isf7
+ */
+const Word16 D_ROM_dico3_isf_noise[SIZE_BK_NOISE3 * 3] = {
+ -805, -838, -774,
+ -522, -627, -828,
+ -477, -486, -603,
+ -295, -481, -634,
+ -366, -384, -393,
+ -186, -414, -396,
+ -237, -394, -106,
+ -252, -202, -275,
+ -61, -177, -442,
+ -84, -198, -199,
+ -179, -125, -31,
+ -72, -47, -163,
+ -298, -220, 215,
+ -64, -168, 251,
+ -133, 156, -59,
+ -30, -2, 127,
+ 54, 66, -61,
+ -233, 21, 251,
+ 209, -50, 32,
+ 33, 194, 136,
+ -117, -18, 475,
+ 202, 46, 309,
+ 256, 185, 53,
+ 35, 200, 390,
+ 200, 263, 242,
+ -216, 302, 294,
+ 128, 358, 0,
+ 19, 431, 287,
+ 224, 447, 280,
+ 367, 165, 213,
+ 397, 314, 319,
+ 383, 379, 75,
+ 277, 325, 462,
+ 394, 505, 334,
+ 251, 98, -213,
+ 450, 153, 448,
+ 565, 226, 76,
+ 470, 383, 502,
+ 635, 390, 278,
+ 237, 135, 620,
+ 342, 401, 649,
+ 331, 551, 518,
+ 130, 418, 592,
+ 531, 306, 737,
+ 729, 389, 580,
+ 497, 557, 699,
+ 296, 383, 874,
+ 283, 624, 759,
+ 126, 622, 476,
+ 559, 595, 472,
+ 382, 770, 616,
+ 719, 613, 745,
+ 540, 639, 928,
+ 517, 826, 801,
+ 684, 811, 604,
+ 752, 786, 857,
+ 933, 661, 350,
+ 694, 450, 1061,
+ 562, 911, 1051,
+ 824, 813, 1104,
+ 758, 1047, 882,
+ 1140, 917, 889,
+ 1039, 1246, 1426,
+ 1483, 1666, 1876
+};
+
+/*
+ * 4th split: isf8 to isf11
+ */
+const Word16 D_ROM_dico4_isf_noise[SIZE_BK_NOISE4 * 4] = {
+ -776, -854, -891, -920,
+ -552, -610, -663, -741,
+ -321, -370, -476, -565,
+ 274, -160, -456, 201,
+ 265, 67, -160, -306,
+ -8, -210, 79, 272,
+ 163, 236, 307, 308,
+ 578, 317, 64, 298,
+ -9, 197, 342, 620,
+ 343, 232, 314, 622,
+ 173, 149, 548, 527,
+ 356, 370, 481, 376,
+ 135, 444, 488, 556,
+ 391, 471, 487, 653,
+ 228, 424, 576, 835,
+ 422, 372, 722, 682,
+ 295, 673, 693, 635,
+ 539, 596, 590, 449,
+ 475, 618, 659, 818,
+ 735, 517, 491, 673,
+ 602, 346, 257, 877,
+ 625, 635, 849, 720,
+ 727, 818, 698, 595,
+ 653, 481, 690, 1139,
+ 814, 762, 704, 908,
+ 507, 747, 898, 936,
+ 848, 855, 924, 785,
+ 646, 1037, 882, 795,
+ 772, 845, 1024, 1151,
+ 1133, 983, 818, 921,
+ 940, 1068, 1252, 1302,
+ 1588, 1767, 1718, 1513
+};
+
+/*
+ * 5th split: isf12 to isf15
+ */
+const Word16 D_ROM_dico5_isf_noise[SIZE_BK_NOISE5 * 4] = {
+ -810, -879, -945, -254,
+ 248, 184, 671, 128,
+ 288, 703, 918, 99,
+ 658, 558, 662, 219,
+ 552, 585, 910, 208,
+ 559, 804, 759, 119,
+ 606, 774, 921, -139,
+ 782, 761, 748, 208,
+ 756, 708, 983, 56,
+ 544, 864, 1010, 152,
+ 737, 698, 987, 299,
+ 771, 924, 879, 103,
+ 536, 785, 961, 405,
+ 667, 916, 801, 328,
+ 738, 705, 773, 439,
+ 823, 871, 992, 355,
+ 640, 1004, 1052, 369,
+ 724, 822, 949, 597,
+ 415, 655, 729, 482,
+ 1009, 896, 793, 363,
+ 908, 803, 687, -25,
+ 1016, 838, 1011, 189,
+ 947, 1112, 942, 222,
+ 914, 1049, 981, 527,
+ 956, 987, 1011, -120,
+ 781, 1049, 1121, 92,
+ 1178, 1053, 884, 47,
+ 1123, 1059, 1182, 118,
+ 933, 972, 1277, 357,
+ 1109, 918, 1101, 503,
+ 1039, 1286, 1220, 317,
+ 1351, 1207, 1010, 326
+};
+
+/*
+ * Table of pitch and codebook gains
+ *
+ * g_pitch(Q14), g_code(Q11)
+ *
+ * pitch gain are ordered in table to reduce complexity
+ * during quantization of gains.
+ */
+
+/* Number of quantization level is 64 */
+const Word16 D_ROM_qua_gain6b[64 * 2] = {
+ 1566, 1332,
+ 1577, 3557,
+ 3071, 6490,
+ 4193, 10163,
+ 4496, 2534,
+ 5019, 4488,
+ 5586, 15614,
+ 5725, 1422,
+ 6453, 580,
+ 6724, 6831,
+ 7657, 3527,
+ 8072, 2099,
+ 8232, 5319,
+ 8827, 8775,
+ 9740, 2868,
+ 9856, 1465,
+ 10087, 12488,
+ 10241, 4453,
+ 10859, 6618,
+ 11321, 3587,
+ 11417, 1800,
+ 11643, 2428,
+ 11718, 988,
+ 12312, 5093,
+ 12523, 8413,
+ 12574, 26214,
+ 12601, 3396,
+ 13172, 1623,
+ 13285, 2423,
+ 13418, 6087,
+ 13459, 12810,
+ 13656, 3607,
+ 14111, 4521,
+ 14144, 1229,
+ 14425, 1871,
+ 14431, 7234,
+ 14445, 2834,
+ 14628, 10036,
+ 14860, 17496,
+ 15161, 3629,
+ 15209, 5819,
+ 15299, 2256,
+ 15518, 4722,
+ 15663, 1060,
+ 15759, 7972,
+ 15939, 11964,
+ 16020, 2996,
+ 16086, 1707,
+ 16521, 4254,
+ 16576, 6224,
+ 16894, 2380,
+ 16906, 681,
+ 17213, 8406,
+ 17610, 3418,
+ 17895, 5269,
+ 18168, 11748,
+ 18230, 1575,
+ 18607, 32767,
+ 18728, 21684,
+ 19137, 2543,
+ 19422, 6577,
+ 19446, 4097,
+ 19450, 9056,
+ 20371, 14885
+};
+
+/* Number of quantization level is 128 */
+const Word16 D_ROM_qua_gain7b[128 * 2] = {
+ 204, 441,
+ 464, 1977,
+ 869, 1077,
+ 1072, 3062,
+ 1281, 4759,
+ 1647, 1539,
+ 1845, 7020,
+ 1853, 634,
+ 1995, 2336,
+ 2351, 15400,
+ 2661, 1165,
+ 2702, 3900,
+ 2710, 10133,
+ 3195, 1752,
+ 3498, 2624,
+ 3663, 849,
+ 3984, 5697,
+ 4214, 3399,
+ 4415, 1304,
+ 4695, 2056,
+ 5376, 4558,
+ 5386, 676,
+ 5518, 23554,
+ 5567, 7794,
+ 5644, 3061,
+ 5672, 1513,
+ 5957, 2338,
+ 6533, 1060,
+ 6804, 5998,
+ 6820, 1767,
+ 6937, 3837,
+ 7277, 414,
+ 7305, 2665,
+ 7466, 11304,
+ 7942, 794,
+ 8007, 1982,
+ 8007, 1366,
+ 8326, 3105,
+ 8336, 4810,
+ 8708, 7954,
+ 8989, 2279,
+ 9031, 1055,
+ 9247, 3568,
+ 9283, 1631,
+ 9654, 6311,
+ 9811, 2605,
+ 10120, 683,
+ 10143, 4179,
+ 10245, 1946,
+ 10335, 1218,
+ 10468, 9960,
+ 10651, 3000,
+ 10951, 1530,
+ 10969, 5290,
+ 11203, 2305,
+ 11325, 3562,
+ 11771, 6754,
+ 11839, 1849,
+ 11941, 4495,
+ 11954, 1298,
+ 11975, 15223,
+ 11977, 883,
+ 11986, 2842,
+ 12438, 2141,
+ 12593, 3665,
+ 12636, 8367,
+ 12658, 1594,
+ 12886, 2628,
+ 12984, 4942,
+ 13146, 1115,
+ 13224, 524,
+ 13341, 3163,
+ 13399, 1923,
+ 13549, 5961,
+ 13606, 1401,
+ 13655, 2399,
+ 13782, 3909,
+ 13868, 10923,
+ 14226, 1723,
+ 14232, 2939,
+ 14278, 7528,
+ 14439, 4598,
+ 14451, 984,
+ 14458, 2265,
+ 14792, 1403,
+ 14818, 3445,
+ 14899, 5709,
+ 15017, 15362,
+ 15048, 1946,
+ 15069, 2655,
+ 15405, 9591,
+ 15405, 4079,
+ 15570, 7183,
+ 15687, 2286,
+ 15691, 1624,
+ 15699, 3068,
+ 15772, 5149,
+ 15868, 1205,
+ 15970, 696,
+ 16249, 3584,
+ 16338, 1917,
+ 16424, 2560,
+ 16483, 4438,
+ 16529, 6410,
+ 16620, 11966,
+ 16839, 8780,
+ 17030, 3050,
+ 17033, 18325,
+ 17092, 1568,
+ 17123, 5197,
+ 17351, 2113,
+ 17374, 980,
+ 17566, 26214,
+ 17609, 3912,
+ 17639, 32767,
+ 18151, 7871,
+ 18197, 2516,
+ 18202, 5649,
+ 18679, 3283,
+ 18930, 1370,
+ 19271, 13757,
+ 19317, 4120,
+ 19460, 1973,
+ 19654, 10018,
+ 19764, 6792,
+ 19912, 5135,
+ 20040, 2841,
+ 21234, 19833
+};
+
+/*
+ * 1/4 resolution interpolation filter (-3 dB at 0.856*fs/2) in Q14
+ */
+const Word16 D_ROM_inter4_2[UP_SAMP * 2 * L_INTERPOL2] = {
+ 0, 1, 2, 1,
+ -2, -7, -10, -7,
+ 4, 19, 28, 22,
+ -2, -33, -55, -49,
+ -10, 47, 91, 92,
+ 38, -52, -133, -153,
+ -88, 43, 175, 231,
+ 165, -9, -209, -325,
+ -275, -60, 226, 431,
+ 424, 175, -213, -544,
+ -619, -355, 153, 656,
+ 871, 626, -16, -762,
+ -1207, -1044, -249, 853,
+ 1699, 1749, 780, -923,
+ -2598, -3267, -2147, 968,
+ 5531, 10359, 14031, 15401,
+ 14031, 10359, 5531, 968,
+ -2147, -3267, -2598, -923,
+ 780, 1749, 1699, 853,
+ -249, -1044, -1207, -762,
+ -16, 626, 871, 656,
+ 153, -355, -619, -544,
+ -213, 175, 424, 431,
+ 226, -60, -275, -325,
+ -209, -9, 165, 231,
+ 175, 43, -88, -153,
+ -133, -52, 38, 92,
+ 91, 47, -10, -49,
+ -55, -33, -2, 22,
+ 28, 19, 4, -7,
+ -10, -7, -2, 1,
+ 2, 1, 0, 0
+};
+
+/*
+ * 1/5 resolution interpolation filter (in Q14)
+ * -1.5dB @ 6kHz, -6dB @ 6.4kHz, -10dB @ 6.6kHz, -20dB @ 6.9kHz, -25dB @ 7kHz, -55dB @ 8kHz
+ */
+const Word16 D_ROM_fir_up[120] = {
+ -1, -4, -7, -6, 0,
+ 12, 24, 30, 23, 0,
+ -33, -62, -73, -52, 0,
+ 68, 124, 139, 96, 0,
+ -119, -213, -235, -160, 0,
+ 191, 338, 368, 247, 0,
+ -291, -510, -552, -369, 0,
+ 430, 752, 812, 542, 0,
+ -634, -1111, -1204, -809, 0,
+ 963, 1708, 1881, 1288, 0,
+ -1616, -2974, -3432, -2496, 0,
+ 3792, 8219, 12368, 15317, 16384,
+ 15317, 12368, 8219, 3792, 0,
+ -2496, -3432, -2974, -1616, 0,
+ 1288, 1881, 1708, 963, 0,
+ -809, -1204, -1111, -634, 0,
+ 542, 812, 752, 430, 0,
+ -369, -552, -510, -291, 0,
+ 247, 368, 338, 191, 0,
+ -160, -235, -213, -119, 0,
+ 96, 139, 124, 68, 0,
+ -52, -73, -62, -33, 0,
+ 23, 30, 24, 12, 0,
+ -6, -7, -4, -1, 0
+};
+
+/* table x4/5 */
+const Word16 D_ROM_fir_down[120] = {
+ -1, -3, -6, -5,
+ 0, 9, 19, 24,
+ 18, 0, -26, -50,
+ -58, -41, 0, 54,
+ 99, 111, 77, 0,
+ -95, -170, -188, -128,
+ 0, 153, 270, 294,
+ 198, 0, -233, -408,
+ -441, -295, 0, 344,
+ 601, 649, 434, 0,
+ -507, -888, -964, -647,
+ 0, 770, 1366, 1505,
+ 1030, 0, -1293, -2379,
+ -2746, -1997, 0, 3034,
+ 6575, 9894, 12254, 13107,
+ 12254, 9894, 6575, 3034,
+ 0, -1997, -2746, -2379,
+ -1293, 0, 1030, 1505,
+ 1366, 770, 0, -647,
+ -964, -888, -507, 0,
+ 434, 649, 601, 344,
+ 0, -295, -441, -408,
+ -233, 0, 198, 294,
+ 270, 153, 0, -128,
+ -188, -170, -95, 0,
+ 77, 111, 99, 54,
+ 0, -41, -58, -50,
+ -26, 0, 18, 24,
+ 19, 9, 0, -5,
+ -6, -3, -1, 0
+};
+
+/*
+ * Impulse response with phase dispersion
+ */
+
+/* 2.0 - 6.4 kHz phase dispersion */
+const Word16 D_ROM_ph_imp_low[L_SUBFR] = {
+ 20182, 9693, 3270, -3437, 2864, -5240, 1589, -1357,
+ 600, 3893, -1497, -698, 1203, -5249, 1199, 5371,
+ -1488, -705, -2887, 1976, 898, 721, -3876, 4227,
+ -5112, 6400, -1032, -4725, 4093, -4352, 3205, 2130,
+ -1996, -1835, 2648, -1786, -406, 573, 2484, -3608,
+ 3139, -1363, -2566, 3808, -639, -2051, -541, 2376,
+ 3932, -6262, 1432, -3601, 4889, 370, 567, -1163,
+ -2854, 1914, 39, -2418, 3454, 2975, -4021, 3431
+};
+
+/* 3.2 - 6.4 kHz phase dispersion */
+const Word16 D_ROM_ph_imp_mid[L_SUBFR] = {
+ 24098, 10460, -5263, -763, 2048, -927, 1753, -3323,
+ 2212, 652, -2146, 2487, -3539, 4109, -2107, -374,
+ -626, 4270, -5485, 2235, 1858, -2769, 744, 1140,
+ -763, -1615, 4060, -4574, 2982, -1163, 731, -1098,
+ 803, 167, -714, 606, -560, 639, 43, -1766,
+ 3228, -2782, 665, 763, 233, -2002, 1291, 1871,
+ -3470, 1032, 2710, -4040, 3624, -4214, 5292, -4270,
+ 1563, 108, -580, 1642, -2458, 957, 544, 2540
+};
+
+/*
+ * Table for synthesis of signal at 16kHz with HF extension.
+ */
+const Word16 D_ROM_hp_gain[16] = {
+ 3624, 4673, 5597, 6479, 7425, 8378, 9324, 10264,
+ 11210, 12206, 13391, 14844, 16770, 19655, 24289, 32728
+};
+
+/*
+ * isp and isf tables for initialization
+ */
+const Word16 D_ROM_isp[M] = {
+ 32138, 30274, 27246, 23170, 18205, 12540, 6393, 0,
+ -6393, -12540, -18205, -23170, -27246, -30274, -32138, 1475
+};
+
+const Word16 D_ROM_isf[M] = {
+ 1024, 2048, 3072, 4096, 5120, 6144, 7168, 8192,
+ 9216, 10240, 11264, 12288, 13312, 14336, 15360, 3840
+};
+
+/*
+ * means of ISFs
+ */
+const Word16 D_ROM_mean_isf[ORDER] = {
+ 738, 1326, 2336, 3578, 4596, 5662, 6711, 7730,
+ 8750, 9753, 10705, 11728, 12833, 13971, 15043, 4037
+};
+
+const Word16 D_ROM_mean_isf_noise[ORDER] = {
+ 478, 1100, 2213, 3267, 4219, 5222, 6198, 7240,
+ 8229, 9153, 10098, 11108, 12144, 13184, 14165, 3803
+};
+
+/* 16-byte align end */
+
+/*
+ * LTP gain & fixed codebook gain consealement
+ */
+
+/* pitch gain weight */
+const Word16 D_ROM_pdown_unusable[7] = {32767, 31130, 29491, 24576, 7537, 1638, 328};
+const Word16 D_ROM_cdown_unusable[7] = {32767, 16384, 8192, 8192, 8192, 4915, 3277};
+
+/* codebook gain weight */
+const Word16 D_ROM_pdown_usable[7] = {32767, 32113, 31457, 24576, 7537, 1638, 328};
+const Word16 D_ROM_cdown_usable[7] = {32767, 32113, 32113, 32113, 32113, 32113, 22938};
+
+
+/*
+ * filter coefficients (gain=4.0)
+ */
+const Word16 D_ROM_fir_6k_7k[L_FIR] = {
+ -32, 47, 32, -27, -369,
+ 1122, -1421, 0, 3798, -8880,
+ 12349, -10984, 3548, 7766, -18001,
+ 22118, -18001, 7766, 3548, -10984,
+ 12349, -8880, 3798, 0, -1421,
+ 1122, -369, -27, 32, 47,
+ -32
+};
+
+const Word16 D_ROM_fir_7k[L_FIR] = {
+ -21, 47, -89, 146, -203,
+ 229, -177, 0, 335, -839,
+ 1485, -2211, 2931, -3542, 3953,
+ 28682, 3953, -3542, 2931, -2211,
+ 1485, -839, 335, 0, -177,
+ 229, -203, 146, -89, 47,
+ -21
+};
+
+/*
+ * LPC interpolation coef {0.45, 0.8, 0.96, 1.0}; in Q15
+ */
+const Word16 D_ROM_interpol_frac[NB_SUBFR] = {14746, 26214, 31457, 32767};
+
+/*
+ * Math tables
+ */
+const Word16 D_ROM_pow2[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
+};
+
+const Word16 D_ROM_isqrt[49] = {
+ 32767, 31790, 30894, 30070, 29309, 28602, 27945, 27330, 26755, 26214,
+ 25705, 25225, 24770, 24339, 23930, 23541, 23170, 22817, 22479, 22155,
+ 21845, 21548, 21263, 20988, 20724, 20470, 20225, 19988, 19760, 19539,
+ 19326, 19119, 18919, 18725, 18536, 18354, 18176, 18004, 17837, 17674,
+ 17515, 17361, 17211, 17064, 16921, 16782, 16646, 16514, 16384
+};
+
+const Word16 D_ROM_log2[33] = {
+ 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
+};
+
+/* table of cos(x) in Q15 */
+const Word16 D_ROM_cos[129] = {
+ 32767,
+ 32758, 32729, 32679, 32610, 32522, 32413, 32286, 32138,
+ 31972, 31786, 31581, 31357, 31114, 30853, 30572, 30274,
+ 29957, 29622, 29269, 28899, 28511, 28106, 27684, 27246,
+ 26791, 26320, 25833, 25330, 24812, 24279, 23732, 23170,
+ 22595, 22006, 21403, 20788, 20160, 19520, 18868, 18205,
+ 17531, 16846, 16151, 15447, 14733, 14010, 13279, 12540,
+ 11793, 11039, 10279, 9512, 8740, 7962, 7180, 6393,
+ 5602, 4808, 4011, 3212, 2411, 1608, 804, 0,
+ -804, -1608, -2411, -3212, -4011, -4808, -5602, -6393,
+ -7180, -7962, -8740, -9512, -10279, -11039, -11793, -12540,
+ -13279, -14010, -14733, -15447, -16151, -16846, -17531, -18205,
+ -18868, -19520, -20160, -20788, -21403, -22006, -22595, -23170,
+ -23732, -24279, -24812, -25330, -25833, -26320, -26791, -27246,
+ -27684, -28106, -28511, -28899, -29269, -29622, -29957, -30274,
+ -30572, -30853, -31114, -31357, -31581, -31786, -31972, -32138,
+ -32286, -32413, -32522, -32610, -32679, -32729, -32758, -32768
+};
+
+#ifdef ENABLE_CPU2_DECODER
+CPU2_DATA_END
+#endif
+
+
+
diff --git a/audio_codec/libamr/dec_util.c b/audio_codec/libamr/dec_util.c
new file mode 100644
index 0000000..9d0f6c5
--- a/dev/null
+++ b/audio_codec/libamr/dec_util.c
@@ -0,0 +1,1304 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <math.h>
+//#include <memory.h>
+#include "typedef.h"
+#include "dec_main.h"
+#include "dec_lpc.h"
+
+#define MAX_16 (Word16)0x7FFF
+#define MIN_16 (Word16)0x8000
+#define L_SUBFR 64 /* Subframe size */
+#define L_SUBFR16k 80 /* Subframe size at 16kHz */
+#define M16k 20 /* Order of LP filter */
+#define PREEMPH_FAC 22282 /* preemphasis factor (0.68 in Q15) */
+#define FAC4 4
+#define FAC5 5
+#define UP_FAC 20480 /* 5/4 in Q14 */
+#define INV_FAC5 6554 /* 1/5 in Q15 */
+#define NB_COEF_UP 12
+#define L_FIR 31
+#define MODE_7k 0
+#define MODE_24k 8
+
+
+extern const Word16 D_ROM_pow2[];
+extern const Word16 D_ROM_isqrt[];
+extern const Word16 D_ROM_log2[];
+extern const Word16 D_ROM_fir_up[];
+extern const Word16 D_ROM_fir_6k_7k[];
+extern const Word16 D_ROM_fir_7k[];
+extern const Word16 D_ROM_hp_gain[];
+
+#ifdef WIN32
+#pragma warning( disable : 4310)
+#endif
+/*
+ * D_UTIL_random
+ *
+ * Parameters:
+ * seed I/O: seed for random number
+ *
+ * Function:
+ * Signed 16 bits random generator.
+ *
+ * Returns:
+ * random number
+ */
+Word16 D_UTIL_random(Word16 *seed)
+{
+ /*static Word16 seed = 21845;*/
+ *seed = (Word16)(*seed * 31821L + 13849L);
+ return(*seed);
+}
+
+
+/*
+ * D_UTIL_pow2
+ *
+ * Parameters:
+ * exponant I: (Q0) Integer part. (range: 0 <= val <= 30)
+ * fraction I: (Q15) Fractionnal part. (range: 0.0 <= val < 1.0)
+ *
+ * Function:
+ * L_x = pow(2.0, exponant.fraction) (exponant = interger part)
+ * = pow(2.0, 0.fraction) << exponant
+ *
+ * Algorithm:
+ *
+ * The function Pow2(L_x) is approximated by a table and linear
+ * interpolation.
+ *
+ * 1 - i = bit10 - b15 of fraction, 0 <= i <= 31
+ * 2 - a = bit0 - b9 of fraction
+ * 3 - L_x = table[i] << 16 - (table[i] - table[i + 1]) * a * 2
+ * 4 - L_x = L_x >> (30-exponant) (with rounding)
+ *
+ * Returns:
+ * range 0 <= val <= 0x7fffffff
+ */
+Word32 D_UTIL_pow2(Word16 exponant, Word16 fraction)
+{
+ Word32 L_x, tmp, i, exp;
+ Word16 a;
+
+ L_x = fraction * 32; /* L_x = fraction<<6 */
+ i = L_x >> 15; /* Extract b10-b16 of fraction */
+ a = (Word16)(L_x); /* Extract b0-b9 of fraction */
+ a = (Word16)(a & (Word16)0x7fff);
+ L_x = D_ROM_pow2[i] << 16; /* table[i] << 16 */
+ tmp = D_ROM_pow2[i] - D_ROM_pow2[i + 1]; /* table[i] - table[i+1] */
+ tmp = L_x - ((tmp * a) << 1); /* L_x -= tmp*a*2 */
+ exp = 30 - exponant;
+ if (exp <= 31) {
+ L_x = tmp >> exp;
+
+ if ((1 << (exp - 1)) & tmp) {
+ L_x++;
+ }
+ } else {
+ L_x = 0;
+ }
+
+ return(L_x);
+}
+
+
+/*
+ * D_UTIL_norm_l
+ *
+ * Parameters:
+ * L_var1 I: 32 bit Word32 signed integer (Word32) whose value
+ * falls in the range 0x8000 0000 <= var1 <= 0x7fff ffff.
+ *
+ * Function:
+ * Produces the number of left shifts needed to normalize the 32 bit
+ * variable L_var1 for positive values on the interval with minimum of
+ * 1073741824 and maximum of 2147483647, and for negative values on
+ * the interval with minimum of -2147483648 and maximum of -1073741824;
+ * in order to normalize the result, the following operation must be done :
+ * norm_L_var1 = L_shl(L_var1,norm_l(L_var1)).
+ *
+ * Returns:
+ * 16 bit Word16 signed integer (Word16) whose value falls in the range
+ * 0x0000 0000 <= var_out <= 0x0000 001f.
+ */
+Word16 D_UTIL_norm_l(Word32 L_var1)
+{
+ Word16 var_out;
+
+ if (L_var1 == 0) {
+ var_out = 0;
+ } else {
+ if (L_var1 == (Word32)0xffffffffL) {
+ var_out = 31;
+ } else {
+ if (L_var1 < 0) {
+ L_var1 = ~L_var1;
+ }
+
+ for (var_out = 0; L_var1 < (Word32)0x40000000L; var_out++) {
+ L_var1 <<= 1;
+ }
+ }
+ }
+
+ return(var_out);
+}
+
+
+/*
+ * D_UTIL_norm_s
+ *
+ * Parameters:
+ * L_var1 I: 32 bit Word32 signed integer (Word32) whose value
+ * falls in the range 0xffff 8000 <= var1 <= 0x0000 7fff.
+ *
+ * Function:
+ * Produces the number of left shift needed to normalize the 16 bit
+ * variable var1 for positive values on the interval with minimum
+ * of 16384 and maximum of 32767, and for negative values on
+ * the interval with minimum of -32768 and maximum of -16384.
+ *
+ * Returns:
+ * 16 bit Word16 signed integer (Word16) whose value falls in the range
+ * 0x0000 0000 <= var_out <= 0x0000 000f.
+ */
+Word16 D_UTIL_norm_s(Word16 var1)
+{
+ Word16 var_out;
+
+ if (var1 == 0) {
+ var_out = 0;
+ } else {
+ if (var1 == -1) {
+ var_out = 15;
+ } else {
+ if (var1 < 0) {
+ var1 = (Word16)~var1;
+ }
+
+ for (var_out = 0; var1 < 0x4000; var_out++) {
+ var1 <<= 1;
+ }
+ }
+ }
+ return(var_out);
+}
+
+
+/*
+ * D_UTIL_dot_product12
+ *
+ * Parameters:
+ * x I: 12bit x vector
+ * y I: 12bit y vector
+ * lg I: vector length
+ * exp O: exponent of result (0..+30)
+ *
+ * Function:
+ * Compute scalar product of <x[],y[]> using accumulator.
+ * The result is normalized (in Q31) with exponent (0..30).
+ *
+ * Returns:
+ * Q31 normalised result (1 < val <= -1)
+ */
+Word32 D_UTIL_dot_product12(Word16 x[], Word16 y[], Word16 lg, Word16 *exp)
+{
+ Word32 sum, i, sft;
+
+ sum = 0L;
+
+ for (i = 0; i < lg; i++) {
+ sum += x[i] * y[i];
+ }
+ sum = (sum << 1) + 1;
+
+ /* Normalize acc in Q31 */
+ sft = D_UTIL_norm_l(sum);
+ sum = sum << sft;
+ *exp = (Word16)(30 - sft); /* exponent = 0..30 */
+
+ return(sum);
+}
+
+
+/*
+ * D_UTIL_normalised_inverse_sqrt
+ *
+ * Parameters:
+ * frac I/O: (Q31) normalized value (1.0 < frac <= 0.5)
+ * exp I/O: exponent (value = frac x 2^exponent)
+ *
+ * Function:
+ * Compute 1/sqrt(value).
+ * If value is negative or zero, result is 1 (frac=7fffffff, exp=0).
+ *
+ * The function 1/sqrt(value) is approximated by a table and linear
+ * interpolation.
+ * 1. If exponant is odd then shift fraction right once.
+ * 2. exponant = -((exponant - 1) >> 1)
+ * 3. i = bit25 - b30 of fraction, 16 <= i <= 63 ->because of normalization.
+ * 4. a = bit10 - b24
+ * 5. i -= 16
+ * 6. fraction = table[i]<<16 - (table[i] - table[i+1]) * a * 2
+ *
+ * Returns:
+ * void
+ */
+void D_UTIL_normalised_inverse_sqrt(Word32 *frac, Word16 *exp)
+{
+ Word32 i, tmp;
+ Word16 a;
+
+ if (*frac <= (Word32)0) {
+ *exp = 0;
+ *frac = 0x7fffffffL;
+ return;
+ }
+
+ if ((*exp & 0x1) == 1) { /* If exponant odd -> shift right */
+ *frac = *frac >> 1;
+ }
+ *exp = (Word16)(-((*exp - 1) >> 1));
+ *frac = *frac >> 9;
+ i = *frac >> 16; /* Extract b25-b31 */
+ *frac = *frac >> 1;
+ a = (Word16)(*frac); /* Extract b10-b24 */
+ a = (Word16)(a & (Word16)0x7fff);
+ i = i - 16;
+ *frac = D_ROM_isqrt[i] << 16; /* table[i] << 16 */
+ tmp = D_ROM_isqrt[i] - D_ROM_isqrt[i + 1]; /* table[i] - table[i+1]) */
+ *frac = *frac - ((tmp * a) << 1); /* frac -= tmp*a*2 */
+
+ return;
+}
+
+
+/*
+ * D_UTIL_inverse_sqrt
+ *
+ * Parameters:
+ * L_x I/O: (Q0) input value (range: 0<=val<=7fffffff)
+ *
+ * Function:
+ * Compute 1/sqrt(L_x).
+ * If value is negative or zero, result is 1 (7fffffff).
+ *
+ * The function 1/sqrt(value) is approximated by a table and linear
+ * interpolation.
+ * 1. Normalization of L_x
+ * 2. call Normalised_Inverse_sqrt(L_x, exponant)
+ * 3. L_y = L_x << exponant
+ *
+ * Returns:
+ * (Q31) output value (range: 0 <= val < 1)
+ */
+Word32 D_UTIL_inverse_sqrt(Word32 L_x)
+{
+ Word32 L_y;
+ Word16 exp;
+
+ exp = D_UTIL_norm_l(L_x);
+ L_x = (L_x << exp); /* L_x is normalized */
+ exp = (Word16)(31 - exp);
+ D_UTIL_normalised_inverse_sqrt(&L_x, &exp);
+
+ if (exp < 0) {
+ L_y = (L_x >> -exp); /* denormalization */
+ } else {
+ L_y = (L_x << exp); /* denormalization */
+ }
+
+ return(L_y);
+}
+
+
+/*
+ * D_UTIL_normalised_log2
+ *
+ * Parameters:
+ * L_x I: input value (normalized)
+ * exp I: norm_l (L_x)
+ * exponent O: Integer part of Log2. (range: 0<=val<=30)
+ * fraction O: Fractional part of Log2. (range: 0<=val<1)
+ *
+ * Function:
+ * Computes log2(L_x, exp), where L_x is positive and
+ * normalized, and exp is the normalisation exponent
+ * If L_x is negative or zero, the result is 0.
+ *
+ * The function Log2(L_x) is approximated by a table and linear
+ * interpolation. The following steps are used to compute Log2(L_x)
+ *
+ * 1. exponent = 30 - norm_exponent
+ * 2. i = bit25 - b31 of L_x; 32 <= i <= 63 (because of normalization).
+ * 3. a = bit10 - b24
+ * 4. i -= 32
+ * 5. fraction = table[i] << 16 - (table[i] - table[i + 1]) * a * 2
+ *
+ *
+ * Returns:
+ * void
+ */
+static void D_UTIL_normalised_log2(Word32 L_x, Word16 exp, Word16 *exponent,
+ Word16 *fraction)
+{
+ Word32 i, a, tmp;
+ Word32 L_y;
+
+ if (L_x <= 0) {
+ *exponent = 0;
+ *fraction = 0;
+ return;
+ }
+
+ *exponent = (Word16)(30 - exp);
+
+ L_x = L_x >> 10;
+ i = L_x >> 15; /* Extract b25-b31 */
+ a = L_x; /* Extract b10-b24 of fraction */
+ a = a & 0x00007fff;
+ i = i - 32;
+ L_y = D_ROM_log2[i] << 16; /* table[i] << 16 */
+ tmp = D_ROM_log2[i] - D_ROM_log2[i + 1]; /* table[i] - table[i+1] */
+ L_y = L_y - ((tmp * a) << 1); /* L_y -= tmp*a*2 */
+ *fraction = (Word16)(L_y >> 16);
+
+ return;
+}
+
+
+/*
+ * D_UTIL_log2
+ *
+ * Parameters:
+ * L_x I: input value
+ * exponent O: Integer part of Log2. (range: 0<=val<=30)
+ * fraction O: Fractional part of Log2. (range: 0<=val<1)
+ *
+ * Function:
+ * Computes log2(L_x), where L_x is positive.
+ * If L_x is negative or zero, the result is 0.
+ *
+ * Returns:
+ * void
+ */
+void D_UTIL_log2(Word32 L_x, Word16 *exponent, Word16 *fraction)
+{
+ Word16 exp;
+
+ exp = D_UTIL_norm_l(L_x);
+ D_UTIL_normalised_log2((L_x << exp), exp, exponent, fraction);
+}
+
+
+/*
+ * D_UTIL_l_extract
+ *
+ * Parameters:
+ * L_32 I: 32 bit integer.
+ * hi O: b16 to b31 of L_32
+ * lo O: (L_32 - hi<<16)>>1
+ *
+ * Function:
+ * Extract from a 32 bit integer two 16 bit DPF.
+ *
+ * Returns:
+ * void
+ */
+void D_UTIL_l_extract(Word32 L_32, Word16 *hi, Word16 *lo)
+{
+ *hi = (Word16)(L_32 >> 16);
+ *lo = (Word16)((L_32 >> 1) - (*hi * 32768));
+
+ return;
+}
+
+
+/*
+ * D_UTIL_mpy_32_16
+ *
+ * Parameters:
+ * hi I: hi part of 32 bit number
+ * lo I: lo part of 32 bit number
+ * n I: 16 bit number
+ *
+ * Function:
+ * Multiply a 16 bit integer by a 32 bit (DPF). The result is divided
+ * by 2^15.
+ *
+ * L_32 = (hi1*lo2)<<1 + ((lo1*lo2)>>15)<<1
+ *
+ * Returns:
+ * 32 bit result
+ */
+Word32 D_UTIL_mpy_32_16(Word16 hi, Word16 lo, Word16 n)
+{
+ Word32 L_32;
+
+ L_32 = hi * n;
+ L_32 += (lo * n) >> 15;
+
+ return(L_32 << 1);
+}
+
+
+/*
+ * D_UTIL_mpy_32
+ *
+ * Parameters:
+ * hi1 I: hi part of first number
+ * lo1 I: lo part of first number
+ * hi2 I: hi part of second number
+ * lo2 I: lo part of second number
+ *
+ * Function:
+ * Multiply two 32 bit integers (DPF). The result is divided by 2^31
+ *
+ * L_32 = (hi1*lo2)<<1 + ((lo1*lo2)>>15)<<1
+ *
+ * Returns:
+ * 32 bit result
+ */
+Word32 D_UTIL_mpy_32(Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2)
+{
+ Word32 L_32;
+
+ L_32 = hi1 * hi2;
+ L_32 += (hi1 * lo2) >> 15;
+ L_32 += (lo1 * hi2) >> 15;
+
+ return(L_32 << 1);
+}
+
+/*
+ * D_UTIL_saturate
+ *
+ * Parameters:
+ * inp I: 32-bit number
+ *
+ * Function:
+ * Saturation to 16-bit number
+ *
+ * Returns:
+ * 16-bit number
+ */
+Word16 D_UTIL_saturate(Word32 inp)
+{
+ Word16 out;
+ if ((inp < MAX_16) & (inp > MIN_16)) {
+ out = (Word16)inp;
+ } else {
+ if (inp > 0) {
+ out = MAX_16;
+ } else {
+ out = MIN_16;
+ }
+ }
+
+ return(out);
+}
+
+/*
+ * D_UTIL_signal_up_scale
+ *
+ * Parameters:
+ * x I/O: signal to scale
+ * lg I: size of x[]
+ * exp I: exponent: x = round(x << exp)
+ *
+ * Function:
+ * Scale signal up to get maximum of dynamic.
+ *
+ * Returns:
+ * 32 bit result
+ */
+void D_UTIL_signal_up_scale(Word16 x[], Word16 lg, Word16 exp)
+{
+ Word32 i, tmp;
+
+ for (i = 0; i < lg; i++) {
+ tmp = x[i] << exp;
+ x[i] = D_UTIL_saturate(tmp);
+ }
+
+ return;
+}
+
+
+/*
+ * D_UTIL_signal_down_scale
+ *
+ * Parameters:
+ * x I/O: signal to scale
+ * lg I: size of x[]
+ * exp I: exponent: x = round(x << exp)
+ *
+ * Function:
+ * Scale signal up to get maximum of dynamic.
+ *
+ * Returns:
+ * 32 bit result
+ */
+void D_UTIL_signal_down_scale(Word16 x[], Word16 lg, Word16 exp)
+{
+ Word32 i, tmp;
+
+ for (i = 0; i < lg; i++) {
+ tmp = x[i] << 16;
+ tmp = tmp >> exp;
+ x[i] = (Word16)((tmp + 0x8000) >> 16);
+ }
+
+ return;
+}
+
+
+/*
+ * D_UTIL_deemph_32
+ *
+ * Parameters:
+ * x_hi I: input signal (bit31..16)
+ * x_lo I: input signal (bit15..4)
+ * y O: output signal (x16)
+ * mu I: (Q15) deemphasis factor
+ * L I: vector size
+ * mem I/O: memory (y[-1])
+ *
+ * Function:
+ * Filtering through 1/(1-mu z^-1)
+ *
+ * Returns:
+ * void
+ */
+static void D_UTIL_deemph_32(Word16 x_hi[], Word16 x_lo[], Word16 y[],
+ Word16 mu, Word16 L, Word16 *mem)
+{
+ Word32 i, fac;
+ Word32 tmp;
+
+ fac = mu >> 1; /* Q15 --> Q14 */
+
+ /* L_tmp = hi<<16 + lo<<4 */
+ tmp = (x_hi[0] << 12) + x_lo[0];
+ tmp = (tmp << 6) + (*mem * fac);
+ tmp = (tmp + 0x2000) >> 14;
+ y[0] = D_UTIL_saturate(tmp);
+
+ for (i = 1; i < L; i++) {
+ tmp = (x_hi[i] << 12) + x_lo[i];
+ tmp = (tmp << 6) + (y[i - 1] * fac);
+ tmp = (tmp + 0x2000) >> 14;
+ y[i] = D_UTIL_saturate(tmp);
+ }
+
+ *mem = y[L - 1];
+
+ return;
+}
+
+
+/*
+ * D_UTIL_synthesis_32
+ *
+ * Parameters:
+ * a I: LP filter coefficients
+ * m I: order of LP filter
+ * exc I: excitation
+ * Qnew I: exc scaling = 0(min) to 8(max)
+ * sig_hi O: synthesis high
+ * sig_lo O: synthesis low
+ * lg I: size of filtering
+ *
+ * Function:
+ * Perform the synthesis filtering 1/A(z).
+ *
+ * Returns:
+ * void
+ */
+static void D_UTIL_synthesis_32(Word16 a[], Word16 m, Word16 exc[],
+ Word16 Qnew, Word16 sig_hi[], Word16 sig_lo[],
+ Word16 lg)
+{
+ Word32 i, j, a0, s;
+ Word32 tmp, tmp2;
+
+ /* See if a[0] is scaled */
+ s = D_UTIL_norm_s((Word16)a[0]) - 2;
+
+ a0 = a[0] >> (4 + Qnew); /* input / 16 and >>Qnew */
+
+ /* Do the filtering. */
+ for (i = 0; i < lg; i++) {
+ tmp = 0;
+
+ for (j = 1; j <= m; j++) {
+ tmp -= sig_lo[i - j] * a[j];
+ }
+
+ tmp = tmp >> (15 - 4); /* -4 : sig_lo[i] << 4 */
+
+ tmp2 = exc[i] * a0;
+
+ for (j = 1; j <= m; j++) {
+ tmp2 -= sig_hi[i - j] * a[j];
+ }
+
+ tmp += tmp2 << 1;
+ tmp <<= s;
+
+ /* sig_hi = bit16 to bit31 of synthesis */
+ sig_hi[i] = (Word16)(tmp >> 13);
+
+ /* sig_lo = bit4 to bit15 of synthesis */
+ sig_lo[i] = (Word16)((tmp >> 1) - (sig_hi[i] * 4096));
+ }
+
+ return;
+}
+
+
+/*
+ * D_UTIL_hp50_12k8
+ *
+ * Parameters:
+ * signal I/O: signal
+ * lg I: lenght of signal
+ * mem I/O: filter memory [6]
+ *
+ * Function:
+ * 2nd order high pass filter with cut off frequency at 50 Hz.
+ *
+ * Algorithm:
+ *
+ * y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2]
+ * + a[1]*y[i-1] + a[2]*y[i-2];
+ *
+ * b[3] = {0.989501953f, -1.979003906f, 0.989501953f};
+ * a[3] = {1.000000000F, 1.978881836f,-0.966308594f};
+ *
+ *
+ * Returns:
+ * void
+ */
+static void D_UTIL_hp50_12k8(Word16 signal[], Word16 lg, Word16 mem[])
+{
+ Word32 i, L_tmp;
+ Word16 y2_hi, y2_lo, y1_hi, y1_lo, x0, x1, x2;
+
+ y2_hi = mem[0];
+ y2_lo = mem[1];
+ y1_hi = mem[2];
+ y1_lo = mem[3];
+ x0 = mem[4];
+ x1 = mem[5];
+
+ for (i = 0; i < lg; i++) {
+ x2 = x1;
+ x1 = x0;
+ x0 = signal[i];
+
+ /* y[i] = b[0]*x[i] + b[1]*x[i-1] + b140[2]*x[i-2] */
+ /* + a[1]*y[i-1] + a[2] * y[i-2]; */
+ L_tmp = 8192L; /* rounding to maximise precision */
+ L_tmp = L_tmp + (y1_lo * 16211);
+ L_tmp = L_tmp + (y2_lo * (-8021));
+ L_tmp = L_tmp >> 14;
+ L_tmp = L_tmp + (y1_hi * 32422);
+ L_tmp = L_tmp + (y2_hi * (-16042));
+ L_tmp = L_tmp + (x0 * 8106);
+ L_tmp = L_tmp + (x1 * (-16212));
+ L_tmp = L_tmp + (x2 * 8106);
+ L_tmp = L_tmp << 2; /* coeff Q11 --> Q14 */
+ y2_hi = y1_hi;
+ y2_lo = y1_lo;
+ D_UTIL_l_extract(L_tmp, &y1_hi, &y1_lo);
+ L_tmp = (L_tmp + 0x4000) >> 15; /* coeff Q14 --> Q15 with saturation */
+ signal[i] = D_UTIL_saturate(L_tmp);
+
+ }
+ mem[0] = y2_hi;
+ mem[1] = y2_lo;
+ mem[2] = y1_hi;
+ mem[3] = y1_lo;
+ mem[4] = x0;
+ mem[5] = x1;
+
+ return;
+}
+
+
+/*
+ * D_UTIL_interpol
+ *
+ * Parameters:
+ * x I: input vector
+ * fir I: filter coefficient
+ * frac I: fraction (0..resol)
+ * up_samp I: resolution
+ * nb_coef I: number of coefficients
+ *
+ * Function:
+ * Fractional interpolation of signal at position (frac/up_samp)
+ *
+ * Returns:
+ * result of interpolation
+ */
+Word16 D_UTIL_interpol(Word16 *x, Word16 const *fir, Word16 frac,
+ Word16 resol, Word16 nb_coef)
+{
+ Word32 i, k;
+ Word32 sum;
+
+ x = x - nb_coef + 1;
+ sum = 0L;
+
+ for (i = 0, k = ((resol - 1) - frac); i < 2 * nb_coef; i++,
+ k = (Word16)(k + resol)) {
+ sum = sum + (x[i] * fir[k]);
+ }
+
+ if ((sum < 536846336) & (sum > -536879104)) {
+ sum = (sum + 0x2000) >> 14;
+ } else if (sum > 536846336) {
+ sum = 32767;
+ } else {
+ sum = -32768;
+ }
+
+ return((Word16)sum); /* saturation can occur here */
+}
+
+
+/*
+ * D_UTIL_up_samp
+ *
+ * Parameters:
+ * res_d I: signal to upsampling
+ * res_u O: upsampled output
+ * L_frame I: length of output
+ *
+ * Function:
+ * Upsampling
+ *
+ * Returns:
+ * void
+ */
+static void D_UTIL_up_samp(Word16 *sig_d, Word16 *sig_u, Word16 L_frame)
+{
+ Word32 pos, i, j;
+ Word16 frac;
+
+ pos = 0; /* position with 1/5 resolution */
+
+ for (j = 0; j < L_frame; j++) {
+ i = (pos * INV_FAC5) >> 15; /* integer part = pos * 1/5 */
+ frac = (Word16)(pos - ((i << 2) + i)); /* frac = pos - (pos/5)*5 */
+ sig_u[j] = D_UTIL_interpol(&sig_d[i], D_ROM_fir_up, frac, FAC5, NB_COEF_UP);
+ pos = pos + FAC4; /* position + 4/5 */
+ }
+
+ return;
+}
+
+
+/*
+ * D_UTIL_oversamp_16k
+ *
+ * Parameters:
+ * sig12k8 I: signal to oversampling
+ * lg I: length of input
+ * sig16k O: oversampled signal
+ * mem I/O: memory (2*12)
+ *
+ * Function:
+ * Oversampling from 12.8kHz to 16kHz
+ *
+ * Returns:
+ * void
+ */
+static void D_UTIL_oversamp_16k(Word16 sig12k8[], Word16 lg, Word16 sig16k[],
+ Word16 mem[])
+{
+ Word16 lg_up;
+ Word16 signal[L_SUBFR + (2 * NB_COEF_UP)];
+
+ memcpy(signal, mem, (2 * NB_COEF_UP) * sizeof(Word16));
+ memcpy(signal + (2 * NB_COEF_UP), sig12k8, lg * sizeof(Word16));
+ lg_up = (Word16)(((lg * UP_FAC) >> 15) << 1);
+ D_UTIL_up_samp(signal + NB_COEF_UP, sig16k, lg_up);
+ memcpy(mem, signal + lg, (2 * NB_COEF_UP) * sizeof(Word16));
+
+ return;
+}
+
+
+/*
+ * D_UTIL_hp400_12k8
+ *
+ * Parameters:
+ * signal I/O: signal
+ * lg I: lenght of signal
+ * mem I/O: filter memory [6]
+ *
+ * Function:
+ * 2nd order high pass filter with cut off frequency at 400 Hz.
+ *
+ * Algorithm:
+ *
+ * y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2]
+ * + a[1]*y[i-1] + a[2]*y[i-2];
+ *
+ * b[3] = {0.893554687, -1.787109375, 0.893554687};
+ * a[3] = {1.000000000, 1.787109375, -0.864257812};
+ *
+ *
+ * Returns:
+ * void
+ */
+void D_UTIL_hp400_12k8(Word16 signal[], Word16 lg, Word16 mem[])
+{
+
+ Word32 i, L_tmp;
+ Word16 y2_hi, y2_lo, y1_hi, y1_lo, x0, x1, x2;
+
+ y2_hi = mem[0];
+ y2_lo = mem[1];
+ y1_hi = mem[2];
+ y1_lo = mem[3];
+ x0 = mem[4];
+ x1 = mem[5];
+
+ for (i = 0; i < lg; i++) {
+ x2 = x1;
+ x1 = x0;
+ x0 = signal[i];
+
+ /* y[i] = b[0]*x[i] + b[1]*x[i-1] + b140[2]*x[i-2] */
+ /* + a[1]*y[i-1] + a[2] * y[i-2]; */
+ L_tmp = 8192L + (y1_lo * 29280);
+ L_tmp = L_tmp + (y2_lo * (-14160));
+ L_tmp = (L_tmp >> 14);
+ L_tmp = L_tmp + (y1_hi * 58560);
+ L_tmp = L_tmp + (y2_hi * (-28320));
+ L_tmp = L_tmp + (x0 * 1830);
+ L_tmp = L_tmp + (x1 * (-3660));
+ L_tmp = L_tmp + (x2 * 1830);
+ L_tmp = (L_tmp << 1); /* coeff Q12 --> Q13 */
+ y2_hi = y1_hi;
+ y2_lo = y1_lo;
+ D_UTIL_l_extract(L_tmp, &y1_hi, &y1_lo);
+
+ /* signal is divided by 16 to avoid overflow in energy computation */
+ signal[i] = (Word16)((L_tmp + 0x8000) >> 16);
+ }
+ mem[0] = y2_hi;
+ mem[1] = y2_lo;
+ mem[2] = y1_hi;
+ mem[3] = y1_lo;
+ mem[4] = x0;
+ mem[5] = x1;
+
+ return;
+}
+
+
+/*
+ * D_UTIL_synthesis
+ *
+ * Parameters:
+ * a I: LP filter coefficients
+ * m I: order of LP filter
+ * x I: input signal
+ * y O: output signal
+ * lg I: size of filtering
+ * mem I/O: initial filter states
+ * update_m I: update memory flag
+ *
+ * Function:
+ * Perform the synthesis filtering 1/A(z).
+ *
+ * Returns:
+ * void
+ */
+static void D_UTIL_synthesis(Word16 a[], Word16 m, Word16 x[], Word16 y[],
+ Word16 lg, Word16 mem[], Word16 update)
+{
+ Word32 i, j, tmp, s;
+ Word16 y_buf[L_SUBFR16k + M16k], a0;
+ Word16 *yy;
+
+ yy = &y_buf[m];
+
+ /* See if a[0] is scaled */
+ s = D_UTIL_norm_s(a[0]) - 2;
+ /* copy initial filter states into synthesis buffer */
+ memcpy(y_buf, mem, m * sizeof(Word16));
+
+ a0 = (Word16)(a[0] >> 1); /* input / 2 */
+
+ /* Do the filtering. */
+ for (i = 0; i < lg; i++) {
+ tmp = x[i] * a0;
+
+ for (j = 1; j <= m; j++) {
+ tmp -= a[j] * yy[i - j];
+ }
+ tmp <<= s;
+
+ y[i] = yy[i] = (Word16)((tmp + 0x800) >> 12);
+ }
+
+ /* Update memory if required */
+ if (update) {
+ memcpy(mem, &yy[lg - m], m * sizeof(Word16));
+ }
+
+ return;
+}
+
+
+/*
+ * D_UTIL_bp_6k_7k
+ *
+ * Parameters:
+ * signal I/O: signal
+ * lg I: lenght of signal
+ * mem I/O: filter memory [4]
+ *
+ * Function:
+ * 15th order band pass 6kHz to 7kHz FIR filter.
+ *
+ * Returns:
+ * void
+ */
+void D_UTIL_bp_6k_7k(Word16 signal[], Word16 lg, Word16 mem[])
+{
+ Word32 x[L_SUBFR16k + (L_FIR - 1)];
+ Word32 i, j, tmp;
+
+ for (i = 0; i < (L_FIR - 1); i++) {
+ x[i] = (Word16)mem[i]; /* gain of filter = 4 */
+ }
+
+ for (i = 0; i < lg; i++) {
+ x[i + L_FIR - 1] = signal[i] >> 2; /* gain of filter = 4 */
+ }
+
+ for (i = 0; i < lg; i++) {
+ tmp = 0;
+
+ for (j = 0; j < L_FIR; j++) {
+ tmp += x[i + j] * D_ROM_fir_6k_7k[j];
+ }
+
+ signal[i] = (Word16)((tmp + 0x4000) >> 15);
+ }
+
+ for (i = 0; i < (L_FIR - 1); i++) {
+ mem[i] = (Word16)x[lg + i]; /* gain of filter = 4 */
+ }
+
+ return;
+}
+
+
+/*
+ * D_UTIL_hp_7k
+ *
+ * Parameters:
+ * signal I/O: ISF vector
+ * lg I: length of signal
+ * mem I/O: memory (30)
+ *
+ * Function:
+ * 15th order high pass 7kHz FIR filter
+ *
+ * Returns:
+ * void
+ */
+static void D_UTIL_hp_7k(Word16 signal[], Word16 lg, Word16 mem[])
+{
+
+ Word32 i, j, tmp;
+ Word16 x[L_SUBFR16k + (L_FIR - 1)];
+
+ memcpy(x, mem, (L_FIR - 1) * sizeof(Word16));
+ memcpy(&x[L_FIR - 1], signal, lg * sizeof(Word16));
+
+ for (i = 0; i < lg; i++) {
+ tmp = 0;
+
+ for (j = 0; j < L_FIR; j++) {
+ tmp += x[i + j] * D_ROM_fir_7k[j];
+ }
+
+ signal[i] = (Word16)((tmp + 0x4000) >> 15);
+ }
+
+ memcpy(mem, x + lg, (L_FIR - 1) * sizeof(Word16));
+
+ return;
+}
+
+
+/*
+ * D_UTIL_Dec_synthesis
+ *
+ * Parameters:
+ * Aq I: quantized Az
+ * exc I: excitation at 12kHz
+ * Q_new I: scaling performed on exc
+ * synth16k O: 16kHz synthesis signal
+ * prms I: parameters
+ * HfIsf I/O: High frequency ISF:s
+ * mode I: codec mode
+ * newDTXState I: dtx state
+ * bfi I: bad frame indicator
+ * st I/O: State structure
+ *
+ * Function:
+ * Synthesis of signal at 16kHz with HF extension.
+ *
+ * Returns:
+ * void
+ */
+void D_UTIL_dec_synthesis(Word16 Aq[], Word16 exc[], Word16 Q_new,
+ Word16 synth16k[], Word16 prms, Word16 HfIsf[],
+ Word16 mode, Word16 newDTXState, Word16 bfi,
+ Decoder_State *st)
+{
+ Word32 tmp, i;
+ Word16 exp;
+ Word16 ener, exp_ener;
+ Word32 fac;
+ Word16 synth_hi[M + L_SUBFR], synth_lo[M + L_SUBFR];
+ Word16 synth[L_SUBFR];
+ Word16 HF[L_SUBFR16k]; /* High Frequency vector */
+ Word16 Ap[M16k + 1];
+ Word16 HfA[M16k + 1];
+ Word16 HF_corr_gain;
+ Word16 HF_gain_ind;
+ Word32 gain1, gain2;
+ Word16 weight1, weight2;
+
+ /*
+ * Speech synthesis
+ *
+ * - Find synthesis speech corresponding to exc2[].
+ * - Perform fixed deemphasis and hp 50hz filtering.
+ * - Oversampling from 12.8kHz to 16kHz.
+ */
+ memcpy(synth_hi, st->mem_syn_hi, M * sizeof(Word16));
+ memcpy(synth_lo, st->mem_syn_lo, M * sizeof(Word16));
+ D_UTIL_synthesis_32(Aq, M, exc, Q_new, synth_hi + M, synth_lo + M, L_SUBFR);
+ memcpy(st->mem_syn_hi, synth_hi + L_SUBFR, M * sizeof(Word16));
+ memcpy(st->mem_syn_lo, synth_lo + L_SUBFR, M * sizeof(Word16));
+ D_UTIL_deemph_32(synth_hi + M, synth_lo + M, synth, PREEMPH_FAC, L_SUBFR,
+ &(st->mem_deemph));
+ D_UTIL_hp50_12k8(synth, L_SUBFR, st->mem_sig_out);
+ D_UTIL_oversamp_16k(synth, L_SUBFR, synth16k, st->mem_oversamp);
+
+ /*
+ * HF noise synthesis
+ *
+ * - Generate HF noise between 5.5 and 7.5 kHz.
+ * - Set energy of noise according to synthesis tilt.
+ * tilt > 0.8 ==> - 14 dB (voiced)
+ * tilt 0.5 ==> - 6 dB (voiced or noise)
+ * tilt < 0.0 ==> 0 dB (noise)
+ */
+
+ /* generate white noise vector */
+ for (i = 0; i < L_SUBFR16k; i++) {
+ HF[i] = (Word16)(D_UTIL_random(&(st->mem_seed2)) >> 3);
+ }
+
+ /* energy of excitation */
+ D_UTIL_signal_down_scale(exc, L_SUBFR, 3);
+ Q_new = (Word16)(Q_new - 3);
+ ener = (Word16)(D_UTIL_dot_product12(exc, exc, L_SUBFR, &exp_ener) >> 16);
+ exp_ener = (Word16)(exp_ener - (Q_new << 1));
+
+ /* set energy of white noise to energy of excitation */
+ tmp = (Word16)(D_UTIL_dot_product12(HF, HF, L_SUBFR16k, &exp) >> 16);
+
+ if (tmp > ener) {
+ tmp = tmp >> 1; /* Be sure tmp < ener */
+ exp = (Word16)(exp + 1);
+ }
+
+ tmp = (tmp << 15) / ener;
+
+ if (tmp > 32767) {
+ tmp = 32767;
+ }
+
+ tmp = tmp << 16; /* result is normalized */
+ exp = (Word16)(exp - exp_ener);
+ D_UTIL_normalised_inverse_sqrt(&tmp, &exp);
+
+ /* L_tmp x 2, L_tmp in Q31 */
+ /* tmp = 2 x sqrt(ener_exc/ener_hf) */
+ if (exp >= 0) {
+ tmp = tmp >> (15 - exp);
+ } else {
+ tmp = tmp >> (-exp);
+ tmp = tmp >> 15;
+ }
+
+ /* saturation */
+ if (tmp > 0x7FFF) {
+ tmp = 0x7FFF;
+ }
+
+ for (i = 0; i < L_SUBFR16k; i++) {
+ HF[i] = (Word16)((HF[i] * tmp) >> 15);
+ }
+
+ /* find tilt of synthesis speech (tilt: 1=voiced, -1=unvoiced) */
+ D_UTIL_hp400_12k8(synth, L_SUBFR, st->mem_hp400);
+ tmp = 0L;
+
+ for (i = 0; i < L_SUBFR; i++) {
+ tmp = tmp + (synth[i] * synth[i]);
+ }
+
+ tmp = (tmp << 1) + 1;
+ exp = D_UTIL_norm_l(tmp);
+ ener = (Word16)((tmp << exp) >> 16); /* ener = r[0] */
+ tmp = 0L;
+
+ for (i = 1; i < L_SUBFR; i++) {
+ tmp = tmp + (synth[i] * synth[i - 1]);
+ }
+
+ tmp = (tmp << 1) + 1;
+ tmp = (tmp << exp) >> 16; /* tmp = r[1] */
+
+ if (tmp > 0) {
+ fac = ((tmp << 15) / ener);
+
+ if (fac > 32767) {
+ fac = 32767;
+ }
+ } else {
+ fac = 0;
+ }
+
+ /* modify energy of white noise according to synthesis tilt */
+ gain1 = (32767 - fac);
+ gain2 = ((32767 - fac) * 20480) >> 15;
+ gain2 = (gain2 << 1);
+
+ if (gain2 > 32767) {
+ gain2 = 32767;
+ }
+
+ if (st->mem_vad_hist > 0) {
+ weight1 = 0;
+ weight2 = 32767;
+ } else {
+ weight1 = 32767;
+ weight2 = 0;
+ }
+
+ tmp = (weight1 * gain1) >> 15;
+ tmp = tmp + ((weight2 * gain2) >> 15);
+
+ if (tmp != 0) {
+ tmp = tmp + 1;
+ }
+
+ if (tmp < 3277) {
+ tmp = 3277; /* 0.1 in Q15 */
+ }
+
+ if ((mode == MODE_24k) & (bfi == 0)) {
+ /* HF correction gain */
+ HF_gain_ind = prms;
+ HF_corr_gain = D_ROM_hp_gain[HF_gain_ind];
+
+ /* HF gain */
+ for (i = 0; i < L_SUBFR16k; i++) {
+ HF[i] = (Word16)(((HF[i] * HF_corr_gain) >> 15) << 1);
+ }
+ } else {
+ for (i = 0; i < L_SUBFR16k; i++) {
+ HF[i] = (Word16)((HF[i] * tmp) >> 15);
+ }
+ }
+
+ if ((mode <= MODE_7k) & (newDTXState == SPEECH)) {
+ D_LPC_isf_extrapolation(HfIsf);
+ D_LPC_isp_a_conversion(HfIsf, HfA, 0, M16k);
+ D_LPC_a_weight(HfA, Ap, 29491, M16k); /* fac=0.9 */
+ D_UTIL_synthesis(Ap, M16k, HF, HF, L_SUBFR16k, st->mem_syn_hf, 1);
+ } else {
+ /* synthesis of noise: 4.8kHz..5.6kHz --> 6kHz..7kHz */
+ D_LPC_a_weight(Aq, Ap, 19661, M); /* fac=0.6 */
+ D_UTIL_synthesis(Ap, M, HF, HF, L_SUBFR16k, st->mem_syn_hf + (M16k - M), 1);
+ }
+
+ /* noise High Pass filtering (1ms of delay) */
+ D_UTIL_bp_6k_7k(HF, L_SUBFR16k, st->mem_hf);
+
+ if (mode == MODE_24k) {
+ /* Low Pass filtering (7 kHz) */
+ D_UTIL_hp_7k(HF, L_SUBFR16k, st->mem_hf3);
+ }
+
+ /* add filtered HF noise to speech synthesis */
+ for (i = 0; i < L_SUBFR16k; i++) {
+ tmp = (synth16k[i] + HF[i]);
+ synth16k[i] = D_UTIL_saturate(tmp);
+ }
+
+ return;
+}
+
+
+/*
+ * D_UTIL_preemph
+ *
+ * Parameters:
+ * x I/O: signal
+ * mu I: preemphasis factor
+ * lg I: vector size
+ * mem I/O: memory (x[-1])
+ *
+ * Function:
+ * Filtering through 1 - mu z^-1
+ *
+ *
+ * Returns:
+ * void
+ */
+void D_UTIL_preemph(Word16 x[], Word16 mu, Word16 lg, Word16 *mem)
+{
+ Word32 i, L_tmp;
+ Word16 temp;
+
+ temp = x[lg - 1];
+
+ for (i = lg - 1; i > 0; i--) {
+ L_tmp = x[i] << 15;
+ L_tmp = L_tmp - (x[i - 1] * mu);
+ x[i] = (Word16)((L_tmp + 0x4000) >> 15);
+ }
+
+ L_tmp = x[0] << 15;
+ L_tmp = L_tmp - (*mem * mu);
+ x[0] = (Word16)((L_tmp + 0x4000) >> 15);
+ *mem = temp;
+
+ return;
+}
diff --git a/audio_codec/libamr/dec_util.h b/audio_codec/libamr/dec_util.h
new file mode 100644
index 0000000..0d5c5bd
--- a/dev/null
+++ b/audio_codec/libamr/dec_util.h
@@ -0,0 +1,33 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef DEC_UTIL_H
+#define DEC_UTIL_H
+
+#include "typedef.h"
+#include "dec_main.h"
+
+Word16 D_UTIL_random(Word16 *seed);
+
+Word32 D_UTIL_pow2(Word16 exponant, Word16 fraction);
+Word16 D_UTIL_norm_l(Word32 L_var1);
+Word16 D_UTIL_norm_s(Word16 var1);
+Word32 D_UTIL_dot_product12(Word16 x[], Word16 y[], Word16 lg, Word16 *exp);
+void D_UTIL_normalised_inverse_sqrt(Word32 *frac, Word16 *exp);
+Word32 D_UTIL_inverse_sqrt(Word32 L_x);
+void D_UTIL_log2(Word32 L_x, Word16 *exponent, Word16 *fraction);
+void D_UTIL_l_extract(Word32 L_32, Word16 *hi, Word16 *lo);
+Word32 D_UTIL_mpy_32_16(Word16 hi, Word16 lo, Word16 n);
+Word32 D_UTIL_mpy_32(Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2);
+Word16 D_UTIL_saturate(Word32 inp);
+void D_UTIL_signal_up_scale(Word16 x[], Word16 lg, Word16 exp);
+void D_UTIL_signal_down_scale(Word16 x[], Word16 lg, Word16 exp);
+void D_UTIL_dec_synthesis(Word16 Aq[], Word16 exc[], Word16 Q_new,
+ Word16 synth16k[], Word16 prms, Word16 HfIsf[],
+ Word16 mode, Word16 newDTXState, Word16 bfi,
+ Decoder_State *st);
+void D_UTIL_preemph(Word16 x[], Word16 mu, Word16 lg, Word16 *mem);
+
+#endif
diff --git a/audio_codec/libamr/if_rom.c b/audio_codec/libamr/if_rom.c
new file mode 100644
index 0000000..094d2dd
--- a/dev/null
+++ b/audio_codec/libamr/if_rom.c
@@ -0,0 +1,1030 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef IF_H
+#define IF_H
+
+#include "typedef.h"
+
+/*
+ * definition of constants
+ */
+#define NUM_OF_SPMODES 9
+
+/* number of parameters */
+#define PRMNO_7k 18
+#define PRMNO_9k 32
+#define PRMNO_12k 36
+#define PRMNO_14k 36
+#define PRMNO_16k 36
+#define PRMNO_18k 52
+#define PRMNO_20k 52
+#define PRMNO_23k 52
+#define PRMNO_24k 56
+#define PRMNO_SID 7
+#define NB_PARM_MAX PRMNO_24k
+
+/* number of bits */
+#ifndef NBBITS_7k
+#define NBBITS_7k 132
+#define NBBITS_9k 177
+#define NBBITS_12k 253
+#define NBBITS_14k 285
+#define NBBITS_16k 317
+#define NBBITS_18k 365
+#define NBBITS_20k 397
+#define NBBITS_23k 461
+#define NBBITS_24k 477
+#define NBBITS_SID 35
+#endif
+
+/* number of total bits */
+#define HEADER_SIZE 6 /* real size + 1 */
+#define T_NBBITS_7k (NBBITS_7k + HEADER_SIZE)
+#define T_NBBITS_9k (NBBITS_9k + HEADER_SIZE)
+#define T_NBBITS_12k (NBBITS_12k + HEADER_SIZE)
+#define T_NBBITS_14k (NBBITS_14k + HEADER_SIZE)
+#define T_NBBITS_16k (NBBITS_16k + HEADER_SIZE)
+#define T_NBBITS_18k (NBBITS_18k + HEADER_SIZE)
+#define T_NBBITS_20k (NBBITS_20k + HEADER_SIZE)
+#define T_NBBITS_23k (NBBITS_23k + HEADER_SIZE)
+#define T_NBBITS_24k (NBBITS_24k + HEADER_SIZE)
+#define T_NBBITS_SID (NBBITS_SID + HEADER_SIZE)
+
+#define TX_SPEECH 0
+#define TX_SID_FIRST 1
+#define TX_SID_UPDATE 2
+#define TX_NO_DATA 3
+
+#define RX_SPEECH_GOOD 0
+#define RX_SPEECH_PROBABLY_DEGRADED 1
+#define RX_SPEECH_LOST 2
+#define RX_SPEECH_BAD 3
+#define RX_SID_FIRST 4
+#define RX_SID_UPDATE 5
+#define RX_SID_BAD 6
+#define RX_NO_DATA 7
+
+#ifdef ENABLE_CPU2_DECODER
+CPU2_DATA_START
+#endif
+
+/* One encoded frame (bytes) */
+/*
+ * 6 bytes are used both for mode 9 and 10.
+ * Mode 9 is used in encoder and mode 10 in IF2
+ */
+#ifdef IF2
+const UWord8 block_size[16] = {18, 23, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};
+#else
+const UWord8 block_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};
+#endif
+/*
+ * tables
+ */
+
+const Word16 mode_7k[NBBITS_7k << 1] = {
+ 0, 0x1, 1, 0x8, 1, 0x4, 1, 0x2,
+ 8, 0x2, 11, 0x2, 14, 0x2, 17, 0x2,
+ 8, 0x1, 11, 0x1, 1, 0x1, 1, 0x10,
+ 6, 0x80, 6, 0x40, 6, 0x20, 6, 0x10,
+ 8, 0x10, 11, 0x10, 14, 0x10, 17, 0x10,
+ 8, 0x4, 11, 0x4, 14, 0x4, 17, 0x4,
+ 14, 0x1, 17, 0x1, 17, 0x8, 6, 0x8,
+ 6, 0x4, 11, 0x20, 17, 0x20, 1, 0x80,
+ 1, 0x20, 8, 0x20, 14, 0x20, 11, 0x8,
+ 14, 0x8, 8, 0x8, 1, 0x40, 9, 0x10,
+ 15, 0x10, 15, 0x8, 12, 0x10, 3, 0x10,
+ 3, 0x2, 3, 0x1, 9, 0x8, 12, 0x8,
+ 3, 0x20, 3, 0x8, 3, 0x4, 3, 0x40,
+ 2, 0x8, 12, 0x4, 6, 0x2, 12, 0x2,
+ 9, 0x4, 15, 0x4, 2, 0x4, 4, 0x40,
+ 4, 0x20, 4, 0x10, 4, 0x8, 4, 0x4,
+ 2, 0x2, 2, 0x1, 6, 0x1, 12, 0x1,
+ 9, 0x2, 15, 0x2, 2, 0x80, 2, 0x20,
+ 2, 0x40, 2, 0x10, 9, 0x1, 15, 0x1,
+ 4, 0x2, 4, 0x1, 5, 0x20, 5, 0x10,
+ 5, 0x4, 5, 0x8, 5, 0x2, 5, 0x1,
+ 7, 0x800, 7, 0x20, 10, 0x800, 10, 0x20,
+ 13, 0x800, 13, 0x20, 16, 0x800, 16, 0x20,
+ 7, 0x400, 10, 0x400, 13, 0x400, 16, 0x400,
+ 7, 0x10, 10, 0x10, 13, 0x10, 16, 0x10,
+ 7, 0x200, 10, 0x200, 13, 0x200, 16, 0x200,
+ 7, 0x8, 10, 0x8, 13, 0x8, 16, 0x8,
+ 7, 0x100, 10, 0x100, 13, 0x100, 16, 0x100,
+ 7, 0x4, 10, 0x4, 13, 0x4, 16, 0x4,
+ 7, 0x80, 10, 0x80, 13, 0x80, 16, 0x80,
+ 7, 0x2, 10, 0x2, 13, 0x2, 16, 0x2,
+ 7, 0x40, 10, 0x40, 13, 0x40, 16, 0x40,
+ 7, 0x1, 10, 0x1, 13, 0x1, 16, 0x1
+};
+
+const Word16 mode_9k[NBBITS_9k << 1] = {
+ 0, 0x1, 1, 0x10, 1, 0x4, 1, 0x2,
+ 1, 0x8, 1, 0x20, 8, 0x80, 8, 0x40,
+ 8, 0x20, 20, 0x80, 20, 0x40, 20, 0x20,
+ 13, 0x20, 19, 0x20, 25, 0x20, 31, 0x20,
+ 13, 0x1, 19, 0x1, 25, 0x1, 31, 0x1,
+ 13, 0x8, 19, 0x8, 25, 0x8, 31, 0x8,
+ 13, 0x4, 19, 0x4, 25, 0x4, 31, 0x4,
+ 13, 0x2, 19, 0x2, 25, 0x2, 31, 0x2,
+ 13, 0x10, 19, 0x10, 25, 0x10, 31, 0x10,
+ 8, 0x10, 20, 0x10, 8, 0x8, 1, 0x40,
+ 1, 0x80, 14, 0x10, 20, 0x8, 26, 0x10,
+ 3, 0x8, 3, 0x2, 2, 0x10, 3, 0x20,
+ 3, 0x10, 3, 0x4, 2, 0x1, 4, 0x10,
+ 2, 0x8, 2, 0x40, 2, 0x4, 4, 0x20,
+ 4, 0x40, 3, 0x1, 4, 0x8, 1, 0x1,
+ 2, 0x2, 8, 0x4, 20, 0x4, 5, 0x20,
+ 14, 0x8, 26, 0x8, 2, 0x80, 5, 0x8,
+ 2, 0x20, 14, 0x4, 26, 0x4, 8, 0x2,
+ 20, 0x2, 4, 0x2, 4, 0x4, 14, 0x2,
+ 26, 0x2, 5, 0x4, 5, 0x2, 4, 0x1,
+ 7, 0x1, 5, 0x10, 5, 0x40, 8, 0x1,
+ 20, 0x1, 6, 0x10, 5, 0x1, 6, 0x4,
+ 6, 0x8, 6, 0x2, 14, 0x1, 26, 0x1,
+ 6, 0x1, 7, 0x10, 7, 0x8, 7, 0x4,
+ 7, 0x2, 9, 0x10, 10, 0x10, 11, 0x10,
+ 12, 0x10, 15, 0x10, 16, 0x10, 17, 0x10,
+ 18, 0x10, 21, 0x10, 22, 0x10, 23, 0x10,
+ 24, 0x10, 27, 0x10, 28, 0x10, 29, 0x10,
+ 30, 0x10, 9, 0x8, 15, 0x8, 21, 0x8,
+ 27, 0x8, 10, 0x8, 16, 0x8, 22, 0x8,
+ 28, 0x8, 11, 0x8, 17, 0x8, 23, 0x8,
+ 29, 0x8, 12, 0x8, 18, 0x8, 24, 0x8,
+ 30, 0x8, 9, 0x4, 15, 0x4, 21, 0x4,
+ 27, 0x4, 10, 0x4, 16, 0x4, 22, 0x4,
+ 28, 0x4, 11, 0x4, 17, 0x4, 23, 0x4,
+ 29, 0x4, 12, 0x4, 18, 0x4, 24, 0x4,
+ 30, 0x4, 9, 0x2, 15, 0x2, 21, 0x2,
+ 27, 0x2, 10, 0x2, 16, 0x2, 22, 0x2,
+ 28, 0x2, 11, 0x2, 17, 0x2, 23, 0x2,
+ 29, 0x2, 12, 0x2, 18, 0x2, 24, 0x2,
+ 30, 0x2, 9, 0x1, 15, 0x1, 21, 0x1,
+ 27, 0x1, 10, 0x1, 16, 0x1, 22, 0x1,
+ 28, 0x1, 11, 0x1, 17, 0x1, 23, 0x1,
+ 29, 0x1, 12, 0x1, 18, 0x1, 24, 0x1,
+ 30, 0x1
+};
+
+const Word16 mode_12k[NBBITS_12k << 1] = {
+ 0, 0x1, 1, 0x10, 1, 0x4, 14, 0x40,
+ 21, 0x40, 28, 0x40, 35, 0x40, 1, 0x2,
+ 1, 0x8, 1, 0x20, 8, 0x100, 8, 0x80,
+ 8, 0x40, 8, 0x20, 8, 0x10, 22, 0x100,
+ 22, 0x80, 22, 0x40, 22, 0x20, 22, 0x10,
+ 14, 0x20, 21, 0x20, 28, 0x20, 35, 0x20,
+ 14, 0x1, 21, 0x1, 28, 0x1, 35, 0x1,
+ 14, 0x8, 21, 0x8, 28, 0x8, 35, 0x8,
+ 14, 0x4, 21, 0x4, 28, 0x4, 35, 0x4,
+ 15, 0x20, 29, 0x20, 14, 0x2, 21, 0x2,
+ 28, 0x2, 35, 0x2, 14, 0x10, 21, 0x10,
+ 28, 0x10, 35, 0x10, 8, 0x8, 1, 0x40,
+ 1, 0x80, 15, 0x10, 29, 0x10, 22, 0x8,
+ 3, 0x8, 3, 0x2, 2, 0x10, 3, 0x20,
+ 3, 0x10, 3, 0x4, 2, 0x1, 4, 0x10,
+ 2, 0x8, 2, 0x40, 2, 0x4, 4, 0x20,
+ 4, 0x40, 3, 0x1, 4, 0x8, 1, 0x1,
+ 2, 0x2, 8, 0x4, 22, 0x4, 5, 0x20,
+ 15, 0x8, 29, 0x8, 2, 0x80, 5, 0x8,
+ 2, 0x20, 15, 0x4, 29, 0x4, 8, 0x2,
+ 22, 0x2, 4, 0x2, 4, 0x4, 15, 0x2,
+ 29, 0x2, 5, 0x4, 5, 0x2, 4, 0x1,
+ 7, 0x1, 5, 0x10, 5, 0x40, 8, 0x1,
+ 22, 0x1, 6, 0x10, 5, 0x1, 6, 0x4,
+ 6, 0x8, 6, 0x2, 15, 0x1, 29, 0x1,
+ 6, 0x1, 7, 0x10, 7, 0x8, 7, 0x4,
+ 7, 0x2, 9, 0x1, 16, 0x1, 23, 0x1,
+ 30, 0x1, 10, 0x100, 11, 0x100, 12, 0x100,
+ 13, 0x100, 17, 0x100, 18, 0x100, 19, 0x100,
+ 20, 0x100, 24, 0x100, 25, 0x100, 26, 0x100,
+ 27, 0x100, 31, 0x100, 32, 0x100, 33, 0x100,
+ 34, 0x100, 10, 0x80, 17, 0x80, 24, 0x80,
+ 31, 0x80, 10, 0x8, 17, 0x8, 24, 0x8,
+ 31, 0x8, 11, 0x80, 18, 0x80, 25, 0x80,
+ 32, 0x80, 11, 0x8, 18, 0x8, 25, 0x8,
+ 32, 0x8, 12, 0x80, 19, 0x80, 26, 0x80,
+ 33, 0x80, 12, 0x8, 19, 0x8, 26, 0x8,
+ 33, 0x8, 13, 0x80, 20, 0x80, 27, 0x80,
+ 34, 0x80, 13, 0x8, 20, 0x8, 27, 0x8,
+ 34, 0x8, 10, 0x40, 17, 0x40, 24, 0x40,
+ 31, 0x40, 10, 0x4, 17, 0x4, 24, 0x4,
+ 31, 0x4, 11, 0x40, 18, 0x40, 25, 0x40,
+ 32, 0x40, 11, 0x4, 18, 0x4, 25, 0x4,
+ 32, 0x4, 12, 0x40, 19, 0x40, 26, 0x40,
+ 33, 0x40, 12, 0x4, 19, 0x4, 26, 0x4,
+ 33, 0x4, 13, 0x40, 20, 0x40, 27, 0x40,
+ 34, 0x40, 13, 0x4, 20, 0x4, 27, 0x4,
+ 34, 0x4, 10, 0x20, 17, 0x20, 24, 0x20,
+ 31, 0x20, 10, 0x2, 17, 0x2, 24, 0x2,
+ 31, 0x2, 11, 0x20, 18, 0x20, 25, 0x20,
+ 32, 0x20, 11, 0x2, 18, 0x2, 25, 0x2,
+ 32, 0x2, 12, 0x20, 19, 0x20, 26, 0x20,
+ 33, 0x20, 12, 0x2, 19, 0x2, 26, 0x2,
+ 33, 0x2, 13, 0x20, 20, 0x20, 27, 0x20,
+ 34, 0x20, 13, 0x2, 20, 0x2, 27, 0x2,
+ 34, 0x2, 10, 0x10, 17, 0x10, 24, 0x10,
+ 31, 0x10, 10, 0x1, 17, 0x1, 24, 0x1,
+ 31, 0x1, 11, 0x10, 18, 0x10, 25, 0x10,
+ 32, 0x10, 11, 0x1, 18, 0x1, 25, 0x1,
+ 32, 0x1, 12, 0x10, 19, 0x10, 26, 0x10,
+ 33, 0x10, 12, 0x1, 19, 0x1, 26, 0x1,
+ 33, 0x1, 13, 0x10, 20, 0x10, 27, 0x10,
+ 34, 0x10, 13, 0x1, 20, 0x1, 27, 0x1,
+ 34, 0x1
+};
+
+const Word16 mode_14k[NBBITS_14k << 1] = {
+ 0, 0x1, 1, 0x10, 1, 0x4, 14, 0x40,
+ 21, 0x40, 28, 0x40, 35, 0x40, 1, 0x2,
+ 1, 0x8, 1, 0x20, 8, 0x100, 8, 0x80,
+ 8, 0x40, 8, 0x20, 8, 0x10, 22, 0x100,
+ 22, 0x80, 22, 0x40, 22, 0x20, 22, 0x10,
+ 14, 0x20, 21, 0x20, 28, 0x20, 35, 0x20,
+ 14, 0x1, 21, 0x1, 28, 0x1, 35, 0x1,
+ 14, 0x8, 21, 0x8, 28, 0x8, 35, 0x8,
+ 14, 0x4, 21, 0x4, 28, 0x4, 35, 0x4,
+ 15, 0x20, 29, 0x20, 14, 0x2, 21, 0x2,
+ 28, 0x2, 35, 0x2, 14, 0x10, 21, 0x10,
+ 28, 0x10, 35, 0x10, 8, 0x8, 1, 0x40,
+ 1, 0x80, 15, 0x10, 29, 0x10, 22, 0x8,
+ 3, 0x8, 3, 0x2, 2, 0x10, 3, 0x20,
+ 3, 0x10, 3, 0x4, 2, 0x1, 4, 0x10,
+ 2, 0x8, 2, 0x40, 2, 0x4, 4, 0x20,
+ 4, 0x40, 3, 0x1, 4, 0x8, 1, 0x1,
+ 2, 0x2, 8, 0x4, 22, 0x4, 5, 0x20,
+ 15, 0x8, 29, 0x8, 2, 0x80, 5, 0x8,
+ 2, 0x20, 15, 0x4, 29, 0x4, 8, 0x2,
+ 22, 0x2, 4, 0x2, 4, 0x4, 15, 0x2,
+ 29, 0x2, 5, 0x4, 5, 0x2, 4, 0x1,
+ 7, 0x1, 5, 0x10, 5, 0x40, 8, 0x1,
+ 22, 0x1, 6, 0x10, 5, 0x1, 6, 0x4,
+ 6, 0x8, 6, 0x2, 15, 0x1, 29, 0x1,
+ 6, 0x1, 7, 0x10, 7, 0x8, 7, 0x4,
+ 7, 0x2, 9, 0x1, 16, 0x1, 23, 0x1,
+ 30, 0x1, 10, 0x80, 17, 0x80, 24, 0x80,
+ 31, 0x80, 11, 0x80, 18, 0x80, 25, 0x80,
+ 32, 0x80, 10, 0x1000, 17, 0x1000, 24, 0x1000,
+ 31, 0x1000, 10, 0x40, 17, 0x40, 24, 0x40,
+ 31, 0x40, 11, 0x1000, 18, 0x1000, 25, 0x1000,
+ 32, 0x1000, 11, 0x40, 18, 0x40, 25, 0x40,
+ 32, 0x40, 12, 0x100, 19, 0x100, 26, 0x100,
+ 33, 0x100, 13, 0x100, 20, 0x100, 27, 0x100,
+ 34, 0x100, 12, 0x80, 19, 0x80, 26, 0x80,
+ 33, 0x80, 13, 0x80, 20, 0x80, 27, 0x80,
+ 34, 0x80, 12, 0x40, 19, 0x40, 26, 0x40,
+ 33, 0x40, 13, 0x40, 20, 0x40, 27, 0x40,
+ 34, 0x40, 12, 0x20, 19, 0x20, 26, 0x20,
+ 33, 0x20, 13, 0x20, 20, 0x20, 27, 0x20,
+ 34, 0x20, 10, 0x20, 17, 0x20, 24, 0x20,
+ 31, 0x20, 11, 0x20, 18, 0x20, 25, 0x20,
+ 32, 0x20, 10, 0x10, 17, 0x10, 24, 0x10,
+ 31, 0x10, 11, 0x10, 18, 0x10, 25, 0x10,
+ 32, 0x10, 12, 0x10, 19, 0x10, 26, 0x10,
+ 33, 0x10, 13, 0x10, 20, 0x10, 27, 0x10,
+ 34, 0x10, 10, 0x800, 17, 0x800, 24, 0x800,
+ 31, 0x800, 10, 0x8, 17, 0x8, 24, 0x8,
+ 31, 0x8, 11, 0x800, 18, 0x800, 25, 0x800,
+ 32, 0x800, 11, 0x8, 18, 0x8, 25, 0x8,
+ 32, 0x8, 12, 0x8, 19, 0x8, 26, 0x8,
+ 33, 0x8, 13, 0x8, 20, 0x8, 27, 0x8,
+ 34, 0x8, 10, 0x400, 17, 0x400, 24, 0x400,
+ 31, 0x400, 10, 0x4, 17, 0x4, 24, 0x4,
+ 31, 0x4, 11, 0x400, 18, 0x400, 25, 0x400,
+ 32, 0x400, 11, 0x4, 18, 0x4, 25, 0x4,
+ 32, 0x4, 12, 0x4, 19, 0x4, 26, 0x4,
+ 33, 0x4, 13, 0x4, 20, 0x4, 27, 0x4,
+ 34, 0x4, 10, 0x200, 17, 0x200, 24, 0x200,
+ 31, 0x200, 10, 0x2, 17, 0x2, 24, 0x2,
+ 31, 0x2, 11, 0x200, 18, 0x200, 25, 0x200,
+ 32, 0x200, 11, 0x2, 18, 0x2, 25, 0x2,
+ 32, 0x2, 12, 0x2, 19, 0x2, 26, 0x2,
+ 33, 0x2, 13, 0x2, 20, 0x2, 27, 0x2,
+ 34, 0x2, 10, 0x100, 17, 0x100, 24, 0x100,
+ 31, 0x100, 10, 0x1, 17, 0x1, 24, 0x1,
+ 31, 0x1, 11, 0x100, 18, 0x100, 25, 0x100,
+ 32, 0x100, 11, 0x1, 18, 0x1, 25, 0x1,
+ 32, 0x1, 12, 0x1, 19, 0x1, 26, 0x1,
+ 33, 0x1, 13, 0x1, 20, 0x1, 27, 0x1,
+ 34, 0x1
+};
+
+const Word16 mode_16k[NBBITS_16k << 1] = {
+ 0, 0x1, 1, 0x10, 1, 0x4, 14, 0x40,
+ 21, 0x40, 28, 0x40, 35, 0x40, 1, 0x2,
+ 1, 0x8, 1, 0x20, 8, 0x100, 8, 0x80,
+ 8, 0x40, 8, 0x20, 8, 0x10, 22, 0x100,
+ 22, 0x80, 22, 0x40, 22, 0x20, 22, 0x10,
+ 14, 0x20, 21, 0x20, 28, 0x20, 35, 0x20,
+ 14, 0x1, 21, 0x1, 28, 0x1, 35, 0x1,
+ 14, 0x8, 21, 0x8, 28, 0x8, 35, 0x8,
+ 14, 0x4, 21, 0x4, 28, 0x4, 35, 0x4,
+ 15, 0x20, 29, 0x20, 14, 0x2, 21, 0x2,
+ 28, 0x2, 35, 0x2, 14, 0x10, 21, 0x10,
+ 28, 0x10, 35, 0x10, 8, 0x8, 1, 0x40,
+ 1, 0x80, 15, 0x10, 29, 0x10, 22, 0x8,
+ 3, 0x8, 3, 0x2, 2, 0x10, 3, 0x20,
+ 3, 0x10, 3, 0x4, 2, 0x1, 4, 0x10,
+ 2, 0x8, 2, 0x40, 2, 0x4, 4, 0x20,
+ 4, 0x40, 3, 0x1, 4, 0x8, 1, 0x1,
+ 2, 0x2, 8, 0x4, 22, 0x4, 5, 0x20,
+ 15, 0x8, 29, 0x8, 2, 0x80, 5, 0x8,
+ 2, 0x20, 15, 0x4, 29, 0x4, 8, 0x2,
+ 22, 0x2, 4, 0x2, 4, 0x4, 15, 0x2,
+ 29, 0x2, 5, 0x4, 5, 0x2, 4, 0x1,
+ 7, 0x1, 5, 0x10, 5, 0x40, 8, 0x1,
+ 22, 0x1, 6, 0x10, 5, 0x1, 6, 0x4,
+ 6, 0x8, 6, 0x2, 15, 0x1, 29, 0x1,
+ 6, 0x1, 7, 0x10, 7, 0x8, 7, 0x4,
+ 7, 0x2, 9, 0x1, 16, 0x1, 23, 0x1,
+ 30, 0x1, 10, 0x40, 17, 0x40, 24, 0x40,
+ 31, 0x40, 11, 0x40, 18, 0x40, 25, 0x40,
+ 32, 0x40, 12, 0x40, 19, 0x40, 26, 0x40,
+ 33, 0x40, 13, 0x40, 20, 0x40, 27, 0x40,
+ 34, 0x40, 10, 0x1000, 17, 0x1000, 24, 0x1000,
+ 31, 0x1000, 11, 0x1000, 18, 0x1000, 25, 0x1000,
+ 32, 0x1000, 12, 0x1000, 19, 0x1000, 26, 0x1000,
+ 33, 0x1000, 13, 0x1000, 20, 0x1000, 27, 0x1000,
+ 34, 0x1000, 10, 0x80, 17, 0x80, 24, 0x80,
+ 31, 0x80, 11, 0x80, 18, 0x80, 25, 0x80,
+ 32, 0x80, 12, 0x80, 19, 0x80, 26, 0x80,
+ 33, 0x80, 13, 0x80, 20, 0x80, 27, 0x80,
+ 34, 0x80, 10, 0x800, 17, 0x800, 24, 0x800,
+ 31, 0x800, 11, 0x800, 18, 0x800, 25, 0x800,
+ 32, 0x800, 12, 0x800, 19, 0x800, 26, 0x800,
+ 33, 0x800, 13, 0x800, 20, 0x800, 27, 0x800,
+ 34, 0x800, 10, 0x400, 17, 0x400, 24, 0x400,
+ 31, 0x400, 10, 0x20, 17, 0x20, 24, 0x20,
+ 31, 0x20, 10, 0x4, 17, 0x4, 24, 0x4,
+ 31, 0x4, 11, 0x400, 18, 0x400, 25, 0x400,
+ 32, 0x400, 11, 0x20, 18, 0x20, 25, 0x20,
+ 32, 0x20, 11, 0x4, 18, 0x4, 25, 0x4,
+ 32, 0x4, 12, 0x400, 19, 0x400, 26, 0x400,
+ 33, 0x400, 12, 0x20, 19, 0x20, 26, 0x20,
+ 33, 0x20, 12, 0x4, 19, 0x4, 26, 0x4,
+ 33, 0x4, 13, 0x400, 20, 0x400, 27, 0x400,
+ 34, 0x400, 13, 0x20, 20, 0x20, 27, 0x20,
+ 34, 0x20, 13, 0x4, 20, 0x4, 27, 0x4,
+ 34, 0x4, 10, 0x200, 17, 0x200, 24, 0x200,
+ 31, 0x200, 10, 0x10, 17, 0x10, 24, 0x10,
+ 31, 0x10, 10, 0x2, 17, 0x2, 24, 0x2,
+ 31, 0x2, 11, 0x200, 18, 0x200, 25, 0x200,
+ 32, 0x200, 11, 0x10, 18, 0x10, 25, 0x10,
+ 32, 0x10, 11, 0x2, 18, 0x2, 25, 0x2,
+ 32, 0x2, 12, 0x200, 19, 0x200, 26, 0x200,
+ 33, 0x200, 12, 0x10, 19, 0x10, 26, 0x10,
+ 33, 0x10, 12, 0x2, 19, 0x2, 26, 0x2,
+ 33, 0x2, 13, 0x200, 20, 0x200, 27, 0x200,
+ 34, 0x200, 13, 0x10, 20, 0x10, 27, 0x10,
+ 34, 0x10, 13, 0x2, 20, 0x2, 27, 0x2,
+ 34, 0x2, 10, 0x100, 17, 0x100, 24, 0x100,
+ 31, 0x100, 10, 0x8, 17, 0x8, 24, 0x8,
+ 31, 0x8, 10, 0x1, 17, 0x1, 24, 0x1,
+ 31, 0x1, 11, 0x100, 18, 0x100, 25, 0x100,
+ 32, 0x100, 11, 0x8, 18, 0x8, 25, 0x8,
+ 32, 0x8, 11, 0x1, 18, 0x1, 25, 0x1,
+ 32, 0x1, 12, 0x100, 19, 0x100, 26, 0x100,
+ 33, 0x100, 12, 0x8, 19, 0x8, 26, 0x8,
+ 33, 0x8, 12, 0x1, 19, 0x1, 26, 0x1,
+ 33, 0x1, 13, 0x100, 20, 0x100, 27, 0x100,
+ 34, 0x100, 13, 0x8, 20, 0x8, 27, 0x8,
+ 34, 0x8, 13, 0x1, 20, 0x1, 27, 0x1,
+ 34, 0x1
+};
+
+const Word16 mode_18k[NBBITS_18k << 1] = {
+ 0, 0x1, 1, 0x10, 1, 0x4, 18, 0x40,
+ 29, 0x40, 40, 0x40, 51, 0x40, 1, 0x2,
+ 1, 0x8, 1, 0x20, 8, 0x100, 8, 0x80,
+ 8, 0x40, 8, 0x20, 8, 0x10, 30, 0x100,
+ 30, 0x80, 30, 0x40, 30, 0x20, 30, 0x10,
+ 18, 0x20, 29, 0x20, 40, 0x20, 51, 0x20,
+ 18, 0x1, 29, 0x1, 40, 0x1, 51, 0x1,
+ 18, 0x8, 29, 0x8, 40, 0x8, 51, 0x8,
+ 18, 0x4, 29, 0x4, 40, 0x4, 51, 0x4,
+ 19, 0x20, 41, 0x20, 18, 0x2, 29, 0x2,
+ 40, 0x2, 51, 0x2, 18, 0x10, 29, 0x10,
+ 40, 0x10, 51, 0x10, 8, 0x8, 1, 0x40,
+ 1, 0x80, 19, 0x10, 41, 0x10, 30, 0x8,
+ 3, 0x8, 3, 0x2, 2, 0x10, 3, 0x20,
+ 3, 0x10, 3, 0x4, 2, 0x1, 4, 0x10,
+ 2, 0x8, 2, 0x40, 2, 0x4, 4, 0x20,
+ 4, 0x40, 3, 0x1, 4, 0x8, 1, 0x1,
+ 2, 0x2, 8, 0x4, 30, 0x4, 5, 0x20,
+ 19, 0x8, 41, 0x8, 2, 0x80, 5, 0x8,
+ 2, 0x20, 19, 0x4, 41, 0x4, 8, 0x2,
+ 30, 0x2, 4, 0x2, 4, 0x4, 19, 0x2,
+ 41, 0x2, 5, 0x4, 5, 0x2, 4, 0x1,
+ 7, 0x1, 5, 0x10, 5, 0x40, 8, 0x1,
+ 30, 0x1, 6, 0x10, 5, 0x1, 6, 0x4,
+ 6, 0x8, 6, 0x2, 19, 0x1, 41, 0x1,
+ 6, 0x1, 7, 0x10, 7, 0x8, 7, 0x4,
+ 7, 0x2, 9, 0x1, 20, 0x1, 31, 0x1,
+ 42, 0x1, 28, 0x1, 45, 0x1, 21, 0x1,
+ 17, 0x1, 22, 0x1, 11, 0x1, 39, 0x1,
+ 10, 0x1, 12, 0x1, 50, 0x1, 23, 0x2,
+ 23, 0x1, 43, 0x1, 25, 0x1, 10, 0x2,
+ 33, 0x1, 44, 0x1, 13, 0x2, 32, 0x1,
+ 22, 0x2, 26, 0x1, 46, 0x2, 35, 0x2,
+ 13, 0x1, 16, 0x1, 12, 0x2, 14, 0x1,
+ 43, 0x2, 15, 0x1, 24, 0x1, 24, 0x2,
+ 21, 0x2, 34, 0x1, 44, 0x2, 46, 0x1,
+ 49, 0x1, 11, 0x2, 45, 0x2, 27, 0x1,
+ 48, 0x1, 47, 0x1, 34, 0x2, 32, 0x2,
+ 38, 0x1, 37, 0x1, 33, 0x2, 36, 0x1,
+ 50, 0x20, 35, 0x1, 26, 0x2000, 15, 0x40,
+ 27, 0x2000, 15, 0x20, 26, 0x40, 50, 0x40,
+ 17, 0x200, 47, 0x2000, 14, 0x2000, 27, 0x40,
+ 17, 0x20, 48, 0x40, 14, 0x40, 28, 0x40,
+ 16, 0x20, 27, 0x20, 16, 0x2000, 14, 0x20,
+ 28, 0x20, 25, 0x20, 49, 0x40, 47, 0x40,
+ 25, 0x2000, 39, 0x20, 14, 0x200, 48, 0x20,
+ 26, 0x20, 25, 0x40, 16, 0x200, 49, 0x20,
+ 17, 0x400, 47, 0x20, 49, 0x2000, 39, 0x40,
+ 14, 0x400, 17, 0x2000, 27, 0x200, 37, 0x40,
+ 17, 0x40, 15, 0x2000, 17, 0x80, 28, 0x200,
+ 37, 0x20, 38, 0x40, 27, 0x400, 14, 0x80,
+ 28, 0x2000, 16, 0x400, 50, 0x2000, 16, 0x40,
+ 48, 0x80, 15, 0x200, 49, 0x200, 48, 0x2000,
+ 49, 0x400, 38, 0x2000, 26, 0x200, 50, 0x200,
+ 25, 0x200, 15, 0x400, 39, 0x400, 36, 0x20,
+ 38, 0x20, 47, 0x80, 50, 0x10, 50, 0x400,
+ 26, 0x80, 36, 0x40, 47, 0x200, 48, 0x200,
+ 28, 0x400, 39, 0x200, 25, 0x400, 27, 0x80,
+ 39, 0x2000, 50, 0x80, 38, 0x200, 15, 0x80,
+ 25, 0x80, 17, 0x10, 28, 0x80, 26, 0x400,
+ 37, 0x2000, 38, 0x80, 49, 0x80, 47, 0x400,
+ 38, 0x400, 15, 0x10, 36, 0x2000, 16, 0x80,
+ 49, 0x10, 36, 0x80, 36, 0x200, 36, 0x400,
+ 39, 0x80, 37, 0x200, 37, 0x400, 48, 0x400,
+ 36, 0x10, 47, 0x10, 16, 0x10, 14, 0x10,
+ 27, 0x10, 39, 0x10, 14, 0x1000, 28, 0x10,
+ 25, 0x10, 48, 0x10, 27, 0x1000, 37, 0x10,
+ 37, 0x80, 38, 0x10, 17, 0x8, 26, 0x1000,
+ 26, 0x10, 50, 0x8, 14, 0x8, 25, 0x1000,
+ 17, 0x1000, 47, 0x8, 16, 0x1000, 28, 0x1000,
+ 47, 0x1000, 15, 0x1000, 36, 0x8, 15, 0x8,
+ 28, 0x8, 17, 0x100, 49, 0x8, 27, 0x8,
+ 50, 0x1000, 48, 0x1000, 48, 0x8, 39, 0x8,
+ 37, 0x1000, 26, 0x8, 17, 0x4, 47, 0x4,
+ 14, 0x100, 50, 0x4, 48, 0x4, 38, 0x1000,
+ 28, 0x100, 27, 0x100, 39, 0x100, 16, 0x4,
+ 16, 0x100, 25, 0x8, 16, 0x8, 15, 0x4,
+ 14, 0x4, 39, 0x1000, 39, 0x4, 37, 0x8,
+ 36, 0x1000, 38, 0x8, 27, 0x4, 15, 0x100,
+ 25, 0x4, 36, 0x4, 49, 0x100, 26, 0x4,
+ 49, 0x1000, 28, 0x4, 49, 0x4, 37, 0x4,
+ 26, 0x100, 47, 0x100, 25, 0x100, 50, 0x100,
+ 38, 0x4, 48, 0x100, 38, 0x100, 37, 0x100,
+ 36, 0x100, 50, 0x2, 26, 0x800, 17, 0x2,
+ 14, 0x800, 28, 0x800, 27, 0x800, 25, 0x800,
+ 37, 0x800, 14, 0x2, 47, 0x800, 49, 0x800,
+ 47, 0x2, 49, 0x2, 17, 0x800, 38, 0x800,
+ 15, 0x800, 39, 0x2, 16, 0x2, 15, 0x2,
+ 50, 0x800, 48, 0x800, 27, 0x2, 37, 0x2,
+ 28, 0x2, 48, 0x2, 16, 0x800, 25, 0x2,
+ 26, 0x2, 39, 0x800, 36, 0x800, 36, 0x2,
+ 38, 0x2
+};
+
+const Word16 mode_20k[NBBITS_20k << 1] = {
+ 0, 0x1, 1, 0x10, 1, 0x4, 18, 0x40,
+ 29, 0x40, 40, 0x40, 51, 0x40, 1, 0x2,
+ 1, 0x8, 1, 0x20, 8, 0x100, 8, 0x80,
+ 8, 0x40, 8, 0x20, 8, 0x10, 30, 0x100,
+ 30, 0x80, 30, 0x40, 30, 0x20, 30, 0x10,
+ 18, 0x20, 29, 0x20, 40, 0x20, 51, 0x20,
+ 18, 0x1, 29, 0x1, 40, 0x1, 51, 0x1,
+ 18, 0x8, 29, 0x8, 40, 0x8, 51, 0x8,
+ 18, 0x4, 29, 0x4, 40, 0x4, 51, 0x4,
+ 19, 0x20, 41, 0x20, 18, 0x2, 29, 0x2,
+ 40, 0x2, 51, 0x2, 18, 0x10, 29, 0x10,
+ 40, 0x10, 51, 0x10, 8, 0x8, 1, 0x40,
+ 1, 0x80, 19, 0x10, 41, 0x10, 30, 0x8,
+ 3, 0x8, 3, 0x2, 2, 0x10, 3, 0x20,
+ 3, 0x10, 3, 0x4, 2, 0x1, 4, 0x10,
+ 2, 0x8, 2, 0x40, 2, 0x4, 4, 0x20,
+ 4, 0x40, 3, 0x1, 4, 0x8, 1, 0x1,
+ 2, 0x2, 8, 0x4, 30, 0x4, 5, 0x20,
+ 19, 0x8, 41, 0x8, 2, 0x80, 5, 0x8,
+ 2, 0x20, 19, 0x4, 41, 0x4, 8, 0x2,
+ 30, 0x2, 4, 0x2, 4, 0x4, 19, 0x2,
+ 41, 0x2, 5, 0x4, 5, 0x2, 4, 0x1,
+ 7, 0x1, 5, 0x10, 5, 0x40, 8, 0x1,
+ 30, 0x1, 6, 0x10, 5, 0x1, 6, 0x4,
+ 6, 0x8, 6, 0x2, 19, 0x1, 41, 0x1,
+ 6, 0x1, 7, 0x10, 7, 0x8, 7, 0x4,
+ 7, 0x2, 9, 0x1, 20, 0x1, 31, 0x1,
+ 42, 0x1, 10, 0x8, 11, 0x8, 15, 0x100,
+ 46, 0x2, 14, 0x100, 43, 0x8, 21, 0x8,
+ 48, 0x100, 22, 0x8, 44, 0x8, 24, 0x2,
+ 45, 0x2, 26, 0x100, 23, 0x2, 35, 0x2,
+ 12, 0x2, 25, 0x100, 36, 0x100, 22, 0x200,
+ 47, 0x100, 10, 0x200, 33, 0x8, 32, 0x8,
+ 13, 0x2, 34, 0x2, 24, 0x1, 11, 0x200,
+ 13, 0x1, 28, 0x2000, 16, 0x2000, 37, 0x100,
+ 21, 0x200, 23, 0x1, 46, 0x1, 35, 0x1,
+ 45, 0x1, 27, 0x2000, 50, 0x2000, 43, 0x200,
+ 12, 0x1, 44, 0x200, 49, 0x2000, 17, 0x2000,
+ 32, 0x200, 33, 0x200, 34, 0x1, 39, 0x2000,
+ 38, 0x2000, 10, 0x10, 10, 0x100, 22, 0x10,
+ 11, 0x100, 15, 0x80, 26, 0x80, 43, 0x100,
+ 21, 0x10, 25, 0x80, 22, 0x100, 11, 0x10,
+ 50, 0x10, 44, 0x100, 44, 0x10, 47, 0x80,
+ 16, 0x1000, 14, 0x80, 21, 0x100, 32, 0x100,
+ 43, 0x10, 17, 0x10, 33, 0x100, 27, 0x100,
+ 48, 0x80, 32, 0x10, 10, 0x4, 33, 0x10,
+ 28, 0x1000, 28, 0x20, 21, 0x4, 17, 0x1000,
+ 44, 0x4, 37, 0x80, 32, 0x4, 39, 0x10,
+ 27, 0x1000, 27, 0x10, 39, 0x20, 15, 0x40,
+ 27, 0x20, 36, 0x80, 17, 0x20, 49, 0x1000,
+ 50, 0x20, 16, 0x20, 43, 0x4, 49, 0x10,
+ 25, 0x40, 49, 0x20, 14, 0x40, 16, 0x10,
+ 39, 0x100, 26, 0x40, 11, 0x4, 28, 0x10,
+ 27, 0x200, 16, 0x100, 39, 0x1000, 28, 0x200,
+ 49, 0x100, 50, 0x100, 50, 0x1000, 28, 0x100,
+ 48, 0x40, 17, 0x40, 17, 0x200, 17, 0x100,
+ 50, 0x40, 22, 0x4, 16, 0x200, 16, 0x40,
+ 38, 0x1000, 50, 0x200, 39, 0x200, 38, 0x20,
+ 38, 0x10, 47, 0x40, 28, 0x40, 37, 0x40,
+ 33, 0x4, 49, 0x200, 50, 0x8, 39, 0x8,
+ 39, 0x40, 36, 0x40, 17, 0x8, 49, 0x40,
+ 27, 0x8, 15, 0x8, 27, 0x40, 38, 0x8,
+ 28, 0x8, 38, 0x100, 38, 0x200, 26, 0x8,
+ 49, 0x8, 14, 0x8, 22, 0x80, 38, 0x40,
+ 10, 0x80, 47, 0x8, 43, 0x1, 26, 0x4,
+ 11, 0x1, 16, 0x8, 44, 0x80, 28, 0x800,
+ 47, 0x4, 11, 0x80, 15, 0x4, 21, 0x1,
+ 21, 0x80, 27, 0x800, 10, 0x1, 43, 0x80,
+ 44, 0x1, 25, 0x8, 48, 0x8, 33, 0x1,
+ 27, 0x4, 25, 0x4, 36, 0x4, 36, 0x8,
+ 17, 0x4, 32, 0x1, 27, 0x80, 14, 0x4,
+ 50, 0x2, 17, 0x800, 15, 0x20, 50, 0x4,
+ 16, 0x4, 48, 0x4, 38, 0x4, 33, 0x80,
+ 16, 0x800, 37, 0x8, 39, 0x4, 25, 0x20,
+ 22, 0x1, 32, 0x80, 37, 0x4, 17, 0x2,
+ 49, 0x4, 26, 0x20, 39, 0x800, 14, 0x20,
+ 50, 0x800, 39, 0x2, 17, 0x80, 16, 0x80,
+ 49, 0x800, 47, 0x20, 48, 0x20, 28, 0x4,
+ 38, 0x800, 28, 0x2, 10, 0x2, 50, 0x80,
+ 38, 0x2, 28, 0x80, 16, 0x2, 25, 0x2,
+ 15, 0x2, 39, 0x80, 49, 0x2, 49, 0x80,
+ 27, 0x2, 36, 0x20, 26, 0x2, 44, 0x2,
+ 44, 0x40, 22, 0x2, 37, 0x20, 36, 0x2,
+ 33, 0x2, 32, 0x2, 11, 0x2, 47, 0x2,
+ 21, 0x2, 10, 0x40, 14, 0x2, 43, 0x40,
+ 22, 0x40, 37, 0x2, 48, 0x2, 43, 0x2,
+ 11, 0x40, 38, 0x80, 25, 0x200, 21, 0x40,
+ 48, 0x200, 14, 0x200, 15, 0x200, 50, 0x1,
+ 37, 0x200, 33, 0x40, 26, 0x200, 32, 0x40,
+ 27, 0x400, 36, 0x200, 28, 0x400, 47, 0x200,
+ 17, 0x1, 17, 0x400, 39, 0x1, 16, 0x400,
+ 50, 0x400, 26, 0x10, 16, 0x1, 49, 0x1,
+ 27, 0x1, 15, 0x10, 39, 0x400, 25, 0x10,
+ 28, 0x1, 49, 0x400, 38, 0x400, 14, 0x10,
+ 38, 0x1, 47, 0x1, 47, 0x10, 48, 0x10,
+ 36, 0x10, 26, 0x1, 25, 0x1, 37, 0x10,
+ 14, 0x1, 15, 0x1, 21, 0x20, 43, 0x20,
+ 37, 0x1, 48, 0x1, 11, 0x20, 44, 0x20,
+ 10, 0x20, 36, 0x1, 22, 0x20, 33, 0x20,
+ 32, 0x20
+};
+
+const Word16 mode_23k[NBBITS_23k << 1] = {
+ 0, 0x1, 1, 0x10, 1, 0x4, 18, 0x40,
+ 29, 0x40, 40, 0x40, 51, 0x40, 1, 0x2,
+ 1, 0x8, 1, 0x20, 8, 0x100, 8, 0x80,
+ 8, 0x40, 8, 0x20, 8, 0x10, 30, 0x100,
+ 30, 0x80, 30, 0x40, 30, 0x20, 30, 0x10,
+ 18, 0x20, 29, 0x20, 40, 0x20, 51, 0x20,
+ 18, 0x1, 29, 0x1, 40, 0x1, 51, 0x1,
+ 18, 0x8, 29, 0x8, 40, 0x8, 51, 0x8,
+ 18, 0x4, 29, 0x4, 40, 0x4, 51, 0x4,
+ 19, 0x20, 41, 0x20, 18, 0x2, 29, 0x2,
+ 40, 0x2, 51, 0x2, 18, 0x10, 29, 0x10,
+ 40, 0x10, 51, 0x10, 8, 0x8, 1, 0x40,
+ 1, 0x80, 19, 0x10, 41, 0x10, 30, 0x8,
+ 3, 0x8, 3, 0x2, 2, 0x10, 3, 0x20,
+ 3, 0x10, 3, 0x4, 2, 0x1, 4, 0x10,
+ 2, 0x8, 2, 0x40, 2, 0x4, 4, 0x20,
+ 4, 0x40, 3, 0x1, 4, 0x8, 1, 0x1,
+ 2, 0x2, 8, 0x4, 30, 0x4, 5, 0x20,
+ 19, 0x8, 41, 0x8, 2, 0x80, 5, 0x8,
+ 2, 0x20, 19, 0x4, 41, 0x4, 8, 0x2,
+ 30, 0x2, 4, 0x2, 4, 0x4, 19, 0x2,
+ 41, 0x2, 5, 0x4, 5, 0x2, 4, 0x1,
+ 7, 0x1, 5, 0x10, 5, 0x40, 8, 0x1,
+ 30, 0x1, 6, 0x10, 5, 0x1, 6, 0x4,
+ 6, 0x8, 6, 0x2, 19, 0x1, 41, 0x1,
+ 6, 0x1, 7, 0x10, 7, 0x8, 7, 0x4,
+ 7, 0x2, 9, 0x1, 20, 0x1, 31, 0x1,
+ 42, 0x1, 23, 0x400, 24, 0x400, 22, 0x400,
+ 12, 0x400, 10, 0x400, 46, 0x400, 13, 0x400,
+ 21, 0x400, 35, 0x400, 44, 0x400, 43, 0x400,
+ 33, 0x400, 11, 0x400, 23, 0x100, 45, 0x400,
+ 34, 0x400, 24, 0x100, 35, 0x100, 13, 0x100,
+ 11, 0x100, 23, 0x200, 46, 0x100, 22, 0x100,
+ 10, 0x100, 13, 0x200, 10, 0x200, 46, 0x200,
+ 43, 0x100, 21, 0x100, 12, 0x100, 21, 0x200,
+ 32, 0x400, 22, 0x200, 12, 0x200, 45, 0x200,
+ 45, 0x100, 44, 0x200, 44, 0x100, 24, 0x200,
+ 35, 0x200, 11, 0x200, 32, 0x100, 32, 0x200,
+ 43, 0x200, 33, 0x100, 34, 0x100, 33, 0x200,
+ 34, 0x200, 23, 0x80, 10, 0x80, 24, 0x80,
+ 12, 0x80, 13, 0x80, 11, 0x80, 43, 0x80,
+ 46, 0x80, 22, 0x80, 21, 0x80, 50, 0x200,
+ 35, 0x80, 45, 0x80, 13, 0x4, 11, 0x4,
+ 33, 0x80, 10, 0x40, 32, 0x80, 43, 0x4,
+ 17, 0x200, 47, 0x200, 21, 0x4, 14, 0x200,
+ 44, 0x80, 24, 0x4, 12, 0x4, 22, 0x4,
+ 10, 0x4, 13, 0x40, 25, 0x200, 16, 0x200,
+ 11, 0x40, 39, 0x200, 23, 0x4, 35, 0x4,
+ 44, 0x40, 45, 0x4, 49, 0x200, 35, 0x40,
+ 27, 0x200, 46, 0x4, 34, 0x80, 28, 0x200,
+ 15, 0x200, 26, 0x200, 23, 0x40, 16, 0x20,
+ 36, 0x200, 46, 0x40, 15, 0x40, 37, 0x200,
+ 24, 0x40, 38, 0x200, 43, 0x40, 48, 0x200,
+ 22, 0x40, 10, 0x8, 45, 0x40, 12, 0x40,
+ 48, 0x40, 26, 0x20, 17, 0x400, 23, 0x8,
+ 49, 0x400, 15, 0x400, 48, 0x10, 17, 0x20,
+ 33, 0x40, 21, 0x40, 49, 0x40, 25, 0x20,
+ 50, 0x40, 26, 0x40, 28, 0x400, 27, 0x40,
+ 13, 0x8, 34, 0x4, 44, 0x4, 27, 0x20,
+ 21, 0x8, 32, 0x40, 22, 0x8, 50, 0x400,
+ 27, 0x400, 48, 0x20, 14, 0x400, 32, 0x4,
+ 17, 0x40, 16, 0x40, 34, 0x40, 15, 0x20,
+ 39, 0x10, 24, 0x8, 47, 0x40, 13, 0x20,
+ 17, 0x10, 28, 0x40, 47, 0x400, 45, 0x8,
+ 25, 0x10, 16, 0x10, 33, 0x4, 39, 0x20,
+ 14, 0x40, 28, 0x20, 49, 0x20, 12, 0x8,
+ 36, 0x400, 50, 0x20, 25, 0x400, 39, 0x40,
+ 23, 0x20, 14, 0x10, 26, 0x10, 47, 0x20,
+ 38, 0x40, 37, 0x400, 14, 0x20, 36, 0x20,
+ 15, 0x10, 16, 0x400, 11, 0x20, 25, 0x40,
+ 48, 0x400, 26, 0x400, 44, 0x8, 43, 0x8,
+ 49, 0x10, 10, 0x20, 43, 0x20, 39, 0x400,
+ 11, 0x8, 50, 0x10, 21, 0x2, 37, 0x40,
+ 21, 0x20, 28, 0x10, 47, 0x10, 37, 0x20,
+ 35, 0x8, 24, 0x20, 38, 0x20, 46, 0x20,
+ 32, 0x8, 10, 0x10, 23, 0x1, 37, 0x10,
+ 13, 0x10, 21, 0x1, 27, 0x10, 33, 0x20,
+ 36, 0x40, 23, 0x10, 46, 0x8, 12, 0x20,
+ 24, 0x2, 13, 0x1, 10, 0x1, 44, 0x20,
+ 22, 0x20, 38, 0x10, 24, 0x1, 38, 0x400,
+ 32, 0x20, 45, 0x20, 43, 0x1, 44, 0x10,
+ 34, 0x8, 35, 0x1, 46, 0x1, 22, 0x2,
+ 33, 0x1, 36, 0x10, 35, 0x20, 43, 0x10,
+ 45, 0x1, 23, 0x2, 22, 0x1, 12, 0x1,
+ 13, 0x2, 14, 0x100, 27, 0x8, 11, 0x1,
+ 12, 0x2, 11, 0x2, 17, 0x100, 44, 0x1,
+ 21, 0x10, 24, 0x10, 45, 0x10, 16, 0x100,
+ 22, 0x10, 48, 0x8, 11, 0x10, 43, 0x2,
+ 28, 0x100, 27, 0x100, 10, 0x2, 32, 0x2,
+ 33, 0x8, 17, 0x8, 35, 0x2, 47, 0x100,
+ 15, 0x100, 12, 0x10, 16, 0x8, 39, 0x8,
+ 15, 0x8, 34, 0x20, 34, 0x1, 44, 0x2,
+ 27, 0x4, 45, 0x2, 35, 0x10, 46, 0x10,
+ 33, 0x2, 50, 0x100, 48, 0x100, 26, 0x8,
+ 25, 0x8, 25, 0x100, 50, 0x8, 14, 0x8,
+ 32, 0x1, 49, 0x100, 26, 0x100, 39, 0x100,
+ 38, 0x8, 17, 0x4, 28, 0x8, 37, 0x100,
+ 46, 0x2, 50, 0x4, 36, 0x100, 34, 0x10,
+ 15, 0x4, 14, 0x4, 33, 0x10, 49, 0x8,
+ 32, 0x10, 48, 0x4, 38, 0x100, 34, 0x2,
+ 47, 0x4, 25, 0x4, 36, 0x8, 26, 0x4,
+ 37, 0x8, 16, 0x4, 48, 0x2, 28, 0x4,
+ 37, 0x4, 39, 0x4, 47, 0x8, 36, 0x4,
+ 17, 0x2, 38, 0x4, 49, 0x4, 27, 0x2,
+ 14, 0x2, 25, 0x2, 50, 0x2, 28, 0x2,
+ 15, 0x2, 47, 0x2, 39, 0x2, 26, 0x2,
+ 16, 0x2, 49, 0x2, 37, 0x2, 47, 0x80,
+ 36, 0x2, 38, 0x2, 16, 0x80, 14, 0x80,
+ 17, 0x80, 50, 0x80, 39, 0x80, 28, 0x80,
+ 49, 0x80, 15, 0x80, 38, 0x80, 25, 0x80,
+ 37, 0x80, 26, 0x80, 27, 0x80, 48, 0x80,
+ 50, 0x1, 36, 0x80, 39, 0x1, 14, 0x1,
+ 49, 0x1, 26, 0x1, 25, 0x1, 15, 0x1,
+ 48, 0x1, 38, 0x1, 27, 0x1, 28, 0x1,
+ 16, 0x1, 17, 0x1, 47, 0x1, 37, 0x1,
+ 36, 0x1
+};
+
+const Word16 mode_24k[NBBITS_24k << 1] = {
+ 0, 0x1, 1, 0x10, 1, 0x4, 18, 0x40,
+ 30, 0x40, 42, 0x40, 54, 0x40, 1, 0x2,
+ 1, 0x8, 1, 0x20, 8, 0x100, 8, 0x80,
+ 8, 0x40, 8, 0x20, 8, 0x10, 32, 0x100,
+ 32, 0x80, 32, 0x40, 32, 0x20, 32, 0x10,
+ 18, 0x20, 30, 0x20, 42, 0x20, 54, 0x20,
+ 18, 0x1, 30, 0x1, 42, 0x1, 54, 0x1,
+ 18, 0x8, 30, 0x8, 42, 0x8, 54, 0x8,
+ 18, 0x4, 30, 0x4, 42, 0x4, 54, 0x4,
+ 20, 0x20, 44, 0x20, 18, 0x2, 30, 0x2,
+ 42, 0x2, 54, 0x2, 18, 0x10, 30, 0x10,
+ 42, 0x10, 54, 0x10, 8, 0x8, 1, 0x40,
+ 1, 0x80, 20, 0x10, 44, 0x10, 32, 0x8,
+ 3, 0x8, 3, 0x2, 2, 0x10, 3, 0x20,
+ 3, 0x10, 3, 0x4, 2, 0x1, 4, 0x10,
+ 2, 0x8, 2, 0x40, 2, 0x4, 4, 0x20,
+ 4, 0x40, 3, 0x1, 4, 0x8, 1, 0x1,
+ 2, 0x2, 8, 0x4, 32, 0x4, 5, 0x20,
+ 19, 0x8, 19, 0x4, 19, 0x2, 19, 0x1,
+ 31, 0x8, 31, 0x4, 31, 0x2, 31, 0x1,
+ 43, 0x8, 43, 0x4, 43, 0x2, 43, 0x1,
+ 55, 0x8, 55, 0x4, 55, 0x2, 55, 0x1,
+ 20, 0x8, 44, 0x8, 2, 0x80, 5, 0x8,
+ 2, 0x20, 20, 0x4, 44, 0x4, 8, 0x2,
+ 32, 0x2, 4, 0x2, 4, 0x4, 20, 0x2,
+ 44, 0x2, 5, 0x4, 5, 0x2, 4, 0x1,
+ 7, 0x1, 5, 0x10, 5, 0x40, 8, 0x1,
+ 32, 0x1, 6, 0x10, 5, 0x1, 6, 0x4,
+ 6, 0x8, 6, 0x2, 20, 0x1, 44, 0x1,
+ 6, 0x1, 7, 0x10, 7, 0x8, 7, 0x4,
+ 7, 0x2, 9, 0x1, 21, 0x1, 33, 0x1,
+ 45, 0x1, 24, 0x400, 25, 0x400, 23, 0x400,
+ 12, 0x400, 10, 0x400, 49, 0x400, 13, 0x400,
+ 22, 0x400, 37, 0x400, 47, 0x400, 46, 0x400,
+ 35, 0x400, 11, 0x400, 24, 0x100, 48, 0x400,
+ 36, 0x400, 25, 0x100, 37, 0x100, 13, 0x100,
+ 11, 0x100, 24, 0x200, 49, 0x100, 23, 0x100,
+ 10, 0x100, 13, 0x200, 10, 0x200, 49, 0x200,
+ 46, 0x100, 22, 0x100, 12, 0x100, 22, 0x200,
+ 34, 0x400, 23, 0x200, 12, 0x200, 48, 0x200,
+ 48, 0x100, 47, 0x200, 47, 0x100, 25, 0x200,
+ 37, 0x200, 11, 0x200, 34, 0x100, 34, 0x200,
+ 46, 0x200, 35, 0x100, 36, 0x100, 35, 0x200,
+ 36, 0x200, 24, 0x80, 10, 0x80, 25, 0x80,
+ 12, 0x80, 13, 0x80, 11, 0x80, 46, 0x80,
+ 49, 0x80, 23, 0x80, 22, 0x80, 53, 0x200,
+ 37, 0x80, 48, 0x80, 13, 0x4, 11, 0x4,
+ 35, 0x80, 10, 0x40, 34, 0x80, 46, 0x4,
+ 17, 0x200, 50, 0x200, 22, 0x4, 14, 0x200,
+ 47, 0x80, 25, 0x4, 12, 0x4, 23, 0x4,
+ 10, 0x4, 13, 0x40, 26, 0x200, 16, 0x200,
+ 11, 0x40, 41, 0x200, 24, 0x4, 37, 0x4,
+ 47, 0x40, 48, 0x4, 52, 0x200, 37, 0x40,
+ 28, 0x200, 49, 0x4, 36, 0x80, 29, 0x200,
+ 15, 0x200, 27, 0x200, 24, 0x40, 16, 0x20,
+ 38, 0x200, 49, 0x40, 15, 0x40, 39, 0x200,
+ 25, 0x40, 40, 0x200, 46, 0x40, 51, 0x200,
+ 23, 0x40, 10, 0x8, 48, 0x40, 12, 0x40,
+ 51, 0x40, 27, 0x20, 17, 0x400, 24, 0x8,
+ 52, 0x400, 15, 0x400, 51, 0x10, 17, 0x20,
+ 35, 0x40, 22, 0x40, 52, 0x40, 26, 0x20,
+ 53, 0x40, 27, 0x40, 29, 0x400, 28, 0x40,
+ 13, 0x8, 36, 0x4, 47, 0x4, 28, 0x20,
+ 22, 0x8, 34, 0x40, 23, 0x8, 53, 0x400,
+ 28, 0x400, 51, 0x20, 14, 0x400, 34, 0x4,
+ 17, 0x40, 16, 0x40, 36, 0x40, 15, 0x20,
+ 41, 0x10, 25, 0x8, 50, 0x40, 13, 0x20,
+ 17, 0x10, 29, 0x40, 50, 0x400, 48, 0x8,
+ 26, 0x10, 16, 0x10, 35, 0x4, 41, 0x20,
+ 14, 0x40, 29, 0x20, 52, 0x20, 12, 0x8,
+ 38, 0x400, 53, 0x20, 26, 0x400, 41, 0x40,
+ 24, 0x20, 14, 0x10, 27, 0x10, 50, 0x20,
+ 40, 0x40, 39, 0x400, 14, 0x20, 38, 0x20,
+ 15, 0x10, 16, 0x400, 11, 0x20, 26, 0x40,
+ 51, 0x400, 27, 0x400, 47, 0x8, 46, 0x8,
+ 52, 0x10, 10, 0x20, 46, 0x20, 41, 0x400,
+ 11, 0x8, 53, 0x10, 22, 0x2, 39, 0x40,
+ 22, 0x20, 29, 0x10, 50, 0x10, 39, 0x20,
+ 37, 0x8, 25, 0x20, 40, 0x20, 49, 0x20,
+ 34, 0x8, 10, 0x10, 24, 0x1, 39, 0x10,
+ 13, 0x10, 22, 0x1, 28, 0x10, 35, 0x20,
+ 38, 0x40, 24, 0x10, 49, 0x8, 12, 0x20,
+ 25, 0x2, 13, 0x1, 10, 0x1, 47, 0x20,
+ 23, 0x20, 40, 0x10, 25, 0x1, 40, 0x400,
+ 34, 0x20, 48, 0x20, 46, 0x1, 47, 0x10,
+ 36, 0x8, 37, 0x1, 49, 0x1, 23, 0x2,
+ 35, 0x1, 38, 0x10, 37, 0x20, 46, 0x10,
+ 48, 0x1, 24, 0x2, 23, 0x1, 12, 0x1,
+ 13, 0x2, 14, 0x100, 28, 0x8, 11, 0x1,
+ 12, 0x2, 11, 0x2, 17, 0x100, 47, 0x1,
+ 22, 0x10, 25, 0x10, 48, 0x10, 16, 0x100,
+ 23, 0x10, 51, 0x8, 11, 0x10, 46, 0x2,
+ 29, 0x100, 28, 0x100, 10, 0x2, 34, 0x2,
+ 35, 0x8, 17, 0x8, 37, 0x2, 50, 0x100,
+ 15, 0x100, 12, 0x10, 16, 0x8, 41, 0x8,
+ 15, 0x8, 36, 0x20, 36, 0x1, 47, 0x2,
+ 28, 0x4, 48, 0x2, 37, 0x10, 49, 0x10,
+ 35, 0x2, 53, 0x100, 51, 0x100, 27, 0x8,
+ 26, 0x8, 26, 0x100, 53, 0x8, 14, 0x8,
+ 34, 0x1, 52, 0x100, 27, 0x100, 41, 0x100,
+ 40, 0x8, 17, 0x4, 29, 0x8, 39, 0x100,
+ 49, 0x2, 53, 0x4, 38, 0x100, 36, 0x10,
+ 15, 0x4, 14, 0x4, 35, 0x10, 52, 0x8,
+ 34, 0x10, 51, 0x4, 40, 0x100, 36, 0x2,
+ 50, 0x4, 26, 0x4, 38, 0x8, 27, 0x4,
+ 39, 0x8, 16, 0x4, 51, 0x2, 29, 0x4,
+ 39, 0x4, 41, 0x4, 50, 0x8, 38, 0x4,
+ 17, 0x2, 40, 0x4, 52, 0x4, 28, 0x2,
+ 14, 0x2, 26, 0x2, 53, 0x2, 29, 0x2,
+ 15, 0x2, 50, 0x2, 41, 0x2, 27, 0x2,
+ 16, 0x2, 52, 0x2, 39, 0x2, 50, 0x80,
+ 38, 0x2, 40, 0x2, 16, 0x80, 14, 0x80,
+ 17, 0x80, 53, 0x80, 41, 0x80, 29, 0x80,
+ 52, 0x80, 15, 0x80, 40, 0x80, 26, 0x80,
+ 39, 0x80, 27, 0x80, 28, 0x80, 51, 0x80,
+ 53, 0x1, 38, 0x80, 41, 0x1, 14, 0x1,
+ 52, 0x1, 27, 0x1, 26, 0x1, 15, 0x1,
+ 51, 0x1, 40, 0x1, 28, 0x1, 29, 0x1,
+ 16, 0x1, 17, 0x1, 50, 0x1, 39, 0x1,
+ 38, 0x1
+};
+
+const Word16 mode_DTX[NBBITS_SID << 1] = {
+ 0, 0x20, 0, 0x10, 0, 0x8, 0, 0x4,
+ 0, 0x2, 0, 0x1, 1, 0x20, 1, 0x10,
+ 1, 0x8, 1, 0x4, 1, 0x2, 1, 0x1,
+ 2, 0x20, 2, 0x10, 2, 0x8, 2, 0x4,
+ 2, 0x2, 2, 0x1, 3, 0x10, 3, 0x8,
+ 3, 0x4, 3, 0x2, 3, 0x1, 4, 0x10,
+ 4, 0x8, 4, 0x4, 4, 0x2, 4, 0x1,
+ 5, 0x20, 5, 0x10, 5, 0x8, 5, 0x4,
+ 5, 0x2, 5, 0x1, 6, 0x1
+};
+
+const Word16 nb_of_param[NUM_OF_SPMODES] = {
+ PRMNO_7k, PRMNO_9k, PRMNO_12k,
+ PRMNO_14k, PRMNO_16k, PRMNO_18k,
+ PRMNO_20k, PRMNO_23k, PRMNO_24k
+};
+
+const Word16 dfh_M7k[PRMNO_7k] = {
+ 0, 49, 131,
+ 84, 5, 50,
+ 29, 2015, 8,
+ 0, 2061, 8,
+ 1, 3560, 8,
+ 0, 2981, 8
+};
+
+const Word16 dfh_M9k[PRMNO_9k] = {
+ 0, 49, 131,
+ 55, 49, 38,
+ 26, 29, 29,
+ 3, 15, 7,
+ 15, 8, 16,
+ 13, 7, 17,
+ 16, 8, 0,
+ 16, 20, 16,
+ 27, 8, 23,
+ 0, 27, 0,
+ 27, 8
+};
+
+const Word16 dfh_M12k[PRMNO_12k] = {
+ 0, 49, 131,
+ 55, 49, 38,
+ 26, 29, 58,
+ 1, 7, 63,
+ 127, 15, 70,
+ 37, 1, 209,
+ 210, 224, 96,
+ 31, 7, 1,
+ 256, 260, 271,
+ 443, 31, 47,
+ 0, 400, 238,
+ 436, 347, 31
+};
+
+const Word16 dfh_M14k[PRMNO_14k] = {
+ 0, 49, 131,
+ 55, 49, 38,
+ 26, 29, 58,
+ 1, 3847, 3845,
+ 63, 127, 70,
+ 34, 0, 3128,
+ 4517, 192, 96,
+ 0, 2, 1,
+ 4160, 8036, 267,
+ 443, 31, 46,
+ 0, 3840, 7091,
+ 432, 395, 31
+};
+
+const Word16 dfh_M16k[PRMNO_16k] = {
+ 0, 49, 131,
+ 55, 49, 38,
+ 26, 29, 58,
+ 1, 3847, 3845,
+ 3847, 3843, 70,
+ 31, 0, 3648,
+ 4764, 824, 2864,
+ 0, 6, 1,
+ 4160, 5220, 4319,
+ 7131, 31, 47,
+ 0, 112, 3764,
+ 219, 211, 31
+};
+
+const Word16 dfh_M18k[PRMNO_18k] = {
+ 0, 49, 131,
+ 55, 49, 38,
+ 26, 29, 58,
+ 1, 3, 2,
+ 3, 2, 7223,
+ 703, 7223, 703,
+ 70, 0, 1,
+ 3, 2, 2,
+ 3, 9475, 9483,
+ 3090, 8737, 0,
+ 0, 1, 0,
+ 0, 2, 0,
+ 4112, 4400, 8415,
+ 14047, 31, 38,
+ 0, 2, 1,
+ 3, 1, 91,
+ 426, 13545, 12955,
+ 0
+};
+
+const Word16 dfh_M20k[PRMNO_20k] = {
+ 0, 49, 131,
+ 55, 49, 38,
+ 26, 29, 58,
+ 1, 161, 759,
+ 3, 2, 127,
+ 516, 6167, 447,
+ 70, 11, 1,
+ 264, 641, 2,
+ 3, 123, 562,
+ 8347, 4354, 0,
+ 1, 1, 264,
+ 408, 3, 0,
+ 256, 308, 9487,
+ 14047, 31, 46,
+ 0, 320, 885,
+ 2, 2, 464,
+ 439, 11347, 12739,
+ 0
+};
+
+const Word16 dfh_M23k[PRMNO_23k] = {
+ 0, 49, 131,
+ 55, 49, 38,
+ 26, 29, 58,
+ 1, 1154, 1729,
+ 1154, 1761, 447,
+ 1519, 959, 495,
+ 70, 27, 1,
+ 1800, 1253, 665,
+ 1960, 546, 164,
+ 1043, 335, 0,
+ 28, 1, 580,
+ 196, 1187, 383,
+ 1031, 1052, 359,
+ 1531, 31, 45,
+ 1, 1024, 893,
+ 1272, 1920, 101,
+ 876, 203, 1119,
+ 31
+};
+
+const Word16 dfh_M24k[PRMNO_24k] = {
+ 0, 49, 131,
+ 55, 49, 38,
+ 26, 29, 58,
+ 1, 1729, 1154,
+ 1761, 1154, 1519,
+ 959, 495, 447,
+ 70, 3, 42,
+ 1, 580, 1436,
+ 1362, 1250, 901,
+ 714, 24, 45,
+ 0, 0, 0,
+ 1, 68, 708,
+ 1212, 383, 1048,
+ 1611, 1756, 1467,
+ 31, 1, 23,
+ 0, 1536, 1460,
+ 861, 1554, 410,
+ 1368, 1008, 594,
+ 31, 0
+};
+
+/*
+ * overall table with the parameters of the
+ * decoder homing frames for all modes
+ */
+
+const Word16 *dhf[10] = {
+ dfh_M7k,
+ dfh_M9k,
+ dfh_M12k,
+ dfh_M14k,
+ dfh_M16k,
+ dfh_M18k,
+ dfh_M20k,
+ dfh_M23k,
+ dfh_M24k,
+ dfh_M24k
+};
+
+#ifdef ENABLE_CPU2_DECODER
+CPU2_DATA_END
+#endif
+
+#endif
diff --git a/audio_codec/libamr/if_rom.h b/audio_codec/libamr/if_rom.h
new file mode 100755
index 0000000..c0fa70c
--- a/dev/null
+++ b/audio_codec/libamr/if_rom.h
@@ -0,0 +1,70 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef IF_ROM_H
+#define IF_ROM_H
+
+#include "typedef.h"
+
+/*
+ * definition of constants
+ */
+#define NUM_OF_SPMODES 9
+
+/* number of parameters */
+#define PRMNO_7k 18
+#define PRMNO_9k 32
+#define PRMNO_12k 36
+#define PRMNO_14k 36
+#define PRMNO_16k 36
+#define PRMNO_18k 52
+#define PRMNO_20k 52
+#define PRMNO_23k 52
+#define PRMNO_24k 56
+#define PRMNO_SID 7
+#define NB_PARM_MAX PRMNO_24k
+
+/* number of bits */
+#ifndef NBBITS_7k
+#define NBBITS_7k 132
+#define NBBITS_9k 177
+#define NBBITS_12k 253
+#define NBBITS_14k 285
+#define NBBITS_16k 317
+#define NBBITS_18k 365
+#define NBBITS_20k 397
+#define NBBITS_23k 461
+#define NBBITS_24k 477
+#define NBBITS_SID 35
+#endif
+
+/* number of total bits */
+#define HEADER_SIZE 6 /* real size + 1 */
+#define T_NBBITS_7k (NBBITS_7k + HEADER_SIZE)
+#define T_NBBITS_9k (NBBITS_9k + HEADER_SIZE)
+#define T_NBBITS_12k (NBBITS_12k + HEADER_SIZE)
+#define T_NBBITS_14k (NBBITS_14k + HEADER_SIZE)
+#define T_NBBITS_16k (NBBITS_16k + HEADER_SIZE)
+#define T_NBBITS_18k (NBBITS_18k + HEADER_SIZE)
+#define T_NBBITS_20k (NBBITS_20k + HEADER_SIZE)
+#define T_NBBITS_23k (NBBITS_23k + HEADER_SIZE)
+#define T_NBBITS_24k (NBBITS_24k + HEADER_SIZE)
+#define T_NBBITS_SID (NBBITS_SID + HEADER_SIZE)
+
+#define TX_SPEECH 0
+#define TX_SID_FIRST 1
+#define TX_SID_UPDATE 2
+#define TX_NO_DATA 3
+
+#define RX_SPEECH_GOOD 0
+#define RX_SPEECH_PROBABLY_DEGRADED 1
+#define RX_SPEECH_LOST 2
+#define RX_SPEECH_BAD 3
+#define RX_SID_FIRST 4
+#define RX_SID_UPDATE 5
+#define RX_SID_BAD 6
+#define RX_NO_DATA 7
+
+#endif
diff --git a/audio_codec/libamr/interf_dec.c b/audio_codec/libamr/interf_dec.c
new file mode 100644
index 0000000..291ef20
--- a/dev/null
+++ b/audio_codec/libamr/interf_dec.c
@@ -0,0 +1,906 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * R99 V3.5.0 2003-03
+ * REL-4 V4.4.0 2003-03
+ * REL-5 V5.1.0 2003-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * interf_dec.c
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * This module provides means to conversion from 3GPP or ETSI
+ * bitstream to AMR parameters
+ */
+
+/*
+ * include files
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <memory.h>
+#include "typedef.h"
+#include "sp_dec.h"
+#include "interf_rom.h"
+#include "rom_dec.h"
+
+/*
+ * definition of constants
+ */
+#define EHF_MASK 0x0008 /* encoder homing frame pattern */
+typedef
+
+struct {
+ int reset_flag_old; /* previous was homing frame */
+
+
+ enum RXFrameType prev_ft; /* previous frame type */
+ enum Mode prev_mode; /* previous mode */
+ void *decoder_State; /* Points decoder state */
+
+
+} dec_interface_State;
+
+#ifdef ETSI
+
+
+/*
+ * Bin2Int
+ *
+ *
+ * Parameters:
+ * no_of_bits I: number of bits associated with value
+ * bits O: address where bits are written
+ *
+ * Function:
+ * Read nuber of bits from the array and convert to integer.
+ *
+ * Returns:
+ * value
+ */
+static Word16 Bin2Int(Word16 no_of_bits, Word16 *bitstream)
+{
+ Word32 value, i, bit;
+
+
+ value = 0;
+
+ for (i = 0; i < no_of_bits; i++) {
+ value = value << 1;
+ bit = *bitstream++;
+
+ if (bit == 0x1) {
+ value = value + 1;
+ }
+ }
+ return(Word16)(value);
+}
+
+
+/*
+ * Bits2Prm
+ *
+ *
+ * Parameters:
+ * mode I: AMR mode
+ * bits I: serial bits
+ * param O: AMR parameters
+ *
+ * Function:
+ * Retrieves the vector of encoder parameters from
+ * the received serial bits in a frame.
+ *
+ * Returns:
+ * void
+ */
+static void Bits2Prm(enum Mode mode, Word16 bits[], Word16 prm[])
+{
+ Word32 i;
+
+
+ switch (mode) {
+ case MR122:
+ for (i = 0; i < PRMNO_MR122; i++) {
+ prm[i] = Bin2Int(bitno_MR122[i], bits);
+ bits += bitno_MR122[i];
+ }
+ break;
+
+ case MR102:
+ for (i = 0; i < PRMNO_MR102; i++) {
+ prm[i] = Bin2Int(bitno_MR102[i], bits);
+ bits += bitno_MR102[i];
+ }
+ break;
+
+ case MR795:
+ for (i = 0; i < PRMNO_MR795; i++) {
+ prm[i] = Bin2Int(bitno_MR795[i], bits);
+ bits += bitno_MR795[i];
+ }
+ break;
+
+ case MR74:
+ for (i = 0; i < PRMNO_MR74; i++) {
+ prm[i] = Bin2Int(bitno_MR74[i], bits);
+ bits += bitno_MR74[i];
+ }
+ break;
+
+ case MR67:
+ for (i = 0; i < PRMNO_MR67; i++) {
+ prm[i] = Bin2Int(bitno_MR67[i], bits);
+ bits += bitno_MR67[i];
+ }
+ break;
+
+ case MR59:
+ for (i = 0; i < PRMNO_MR59; i++) {
+ prm[i] = Bin2Int(bitno_MR59[i], bits);
+ bits += bitno_MR59[i];
+ }
+ break;
+
+ case MR515:
+ for (i = 0; i < PRMNO_MR515; i++) {
+ prm[i] = Bin2Int(bitno_MR515[i], bits);
+ bits += bitno_MR515[i];
+ }
+ break;
+
+ case MR475:
+ for (i = 0; i < PRMNO_MR475; i++) {
+ prm[i] = Bin2Int(bitno_MR475[i], bits);
+ bits += bitno_MR475[i];
+ }
+ break;
+
+ case MRDTX:
+ for (i = 0; i < PRMNO_MRDTX; i++) {
+ prm[i] = Bin2Int(bitno_MRDTX[i], bits);
+ bits += bitno_MRDTX[i];
+ }
+ break;
+ }
+ return;
+}
+
+#else
+
+#ifndef IF2
+
+/*
+ * DecoderMMS
+ *
+ *
+ * Parameters:
+ * param O: AMR parameters
+ * stream I: input bitstream
+ * frame_type O: frame type
+ * speech_mode O: speech mode in DTX
+ *
+ * Function:
+ * AMR file storage format frame to decoder parameters
+ *
+ * Returns:
+ * mode used mode
+ */
+enum Mode DecoderMMS(Word16 *param, UWord8 *stream, enum RXFrameType
+ *frame_type, enum Mode *speech_mode, Word16 *q_bit)
+{
+ enum Mode mode;
+ Word32 j;
+ Word16 *mask;
+
+
+ memset(param, 0, PRMNO_MR122 << 1);
+ *q_bit = 0x01 & (*stream >> 2);
+ mode = 0x0F & (*stream >> 3);
+ stream++;
+
+ if (mode == MRDTX) {
+ mask = order_MRDTX;
+
+ for (j = 1; j < 36; j++) {
+ if (*stream & 0x80) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ /* get SID type bit */
+
+ *frame_type = RX_SID_FIRST;
+ if (*stream & 0x80) {
+ *frame_type = RX_SID_UPDATE;
+ }
+
+ /* since there is update, use it */
+ /* *frame_type = RX_SID_UPDATE; */
+
+ /* speech mode indicator */
+ *speech_mode = (*stream >> 4) && 0x07;
+
+ } else if (mode == 15) {
+ *frame_type = RX_NO_DATA;
+ } else if (mode == MR475) {
+ mask = order_MR475;
+
+ for (j = 1; j < 96; j++) {
+ if (*stream & 0x80) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ } else if (mode == MR515) {
+ mask = order_MR515;
+
+ for (j = 1; j < 104; j++) {
+ if (*stream & 0x80) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ } else if (mode == MR59) {
+ mask = order_MR59;
+
+ for (j = 1; j < 119; j++) {
+ if (*stream & 0x80) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ } else if (mode == MR67) {
+ mask = order_MR67;
+
+ for (j = 1; j < 135; j++) {
+ if (*stream & 0x80) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ } else if (mode == MR74) {
+ mask = order_MR74;
+
+ for (j = 1; j < 149; j++) {
+ if (*stream & 0x80) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ } else if (mode == MR795) {
+ mask = order_MR795;
+
+ for (j = 1; j < 160; j++) {
+ if (*stream & 0x80) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ } else if (mode == MR102) {
+ mask = order_MR102;
+
+ for (j = 1; j < 205; j++) {
+ if (*stream & 0x80) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ } else if (mode == MR122) {
+ mask = order_MR122;
+
+ for (j = 1; j < 245; j++) {
+ if (*stream & 0x80) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream <<= 1;
+ } else {
+ stream++;
+ }
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ } else {
+ *frame_type = RX_SPEECH_BAD;
+ }
+ return mode;
+}
+
+#else
+
+/*
+ * Decoder3GPP
+ *
+ *
+ * Parameters:
+ * param O: AMR parameters
+ * stream I: input bitstream
+ * frame_type O: frame type
+ * speech_mode O: speech mode in DTX
+ *
+ * Function:
+ * Resets state memory
+ *
+ * Returns:
+ * mode used mode
+ */
+enum Mode Decoder3GPP(Word16 *param, UWord8 *stream, enum RXFrameType
+ *frame_type, enum Mode *speech_mode)
+{
+ enum Mode mode;
+ Word32 j;
+ Word16 *mask;
+
+
+ memset(param, 0, PRMNO_MR122 << 1);
+ mode = 0xF & *stream;
+ *stream >>= 4;
+
+ if (mode == MRDTX) {
+ mask = order_MRDTX;
+
+ for (j = 5; j < 40; j++) {
+ if (*stream & 0x1) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream >>= 1;
+ } else {
+ stream++;
+ }
+ }
+
+ /* get SID type bit */
+
+ *frame_type = RX_SID_FIRST;
+ if (*stream) {
+ *frame_type = RX_SID_UPDATE;
+ }
+
+ /* since there is update, use it */
+ /* *frame_type = RX_SID_UPDATE; */
+ stream++;
+
+ /* speech mode indicator */
+ *speech_mode = *stream;
+ } else if (mode == 15) {
+ *frame_type = RX_NO_DATA;
+ } else if (mode == MR475) {
+ mask = order_MR475;
+
+ for (j = 5; j < 100; j++) {
+ if (*stream & 0x1) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream >>= 1;
+ } else {
+ stream++;
+ }
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ } else if (mode == MR515) {
+ mask = order_MR515;
+
+ for (j = 5; j < 108; j++) {
+ if (*stream & 0x1) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream >>= 1;
+ } else {
+ stream++;
+ }
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ } else if (mode == MR59) {
+ mask = order_MR59;
+
+ for (j = 5; j < 123; j++) {
+ if (*stream & 0x1) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream >>= 1;
+ } else {
+ stream++;
+ }
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ } else if (mode == MR67) {
+ mask = order_MR67;
+
+ for (j = 5; j < 139; j++) {
+ if (*stream & 0x1) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream >>= 1;
+ } else {
+ stream++;
+ }
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ } else if (mode == MR74) {
+ mask = order_MR74;
+
+ for (j = 5; j < 153; j++) {
+ if (*stream & 0x1) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream >>= 1;
+ } else {
+ stream++;
+ }
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ } else if (mode == MR795) {
+ mask = order_MR795;
+
+ for (j = 5; j < 164; j++) {
+ if (*stream & 0x1) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream >>= 1;
+ } else {
+ stream++;
+ }
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ } else if (mode == MR102) {
+ mask = order_MR102;
+
+ for (j = 5; j < 209; j++) {
+ if (*stream & 0x1) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream >>= 1;
+ } else {
+ stream++;
+ }
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ } else if (mode == MR122) {
+ mask = order_MR122;
+
+ for (j = 5; j < 249; j++) {
+ if (*stream & 0x1) {
+ param[ * mask] = (short)(param[ * mask] + * (mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8) {
+ *stream >>= 1;
+ } else {
+ stream++;
+ }
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ } else {
+ *frame_type = RX_SPEECH_BAD;
+ }
+ return mode;
+}
+#endif
+#endif
+
+/*
+ * Decoder_Interface_reset
+ *
+ *
+ * Parameters:
+ * st O: state struct
+ *
+ * Function:
+ * Reset homing frame counter
+ *
+ * Returns:
+ * void
+ */
+void Decoder_Interface_reset(dec_interface_State *st)
+{
+ st->reset_flag_old = 1;
+ st->prev_ft = RX_SPEECH_GOOD;
+ st->prev_mode = MR475; /* minimum bitrate */
+}
+
+
+/*
+ * Decoder_Interface_init
+ *
+ *
+ * Parameters:
+ * void
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * success : pointer to structure
+ * failure : NULL
+ */
+static dec_interface_State g_dec_interface_State;
+void * Decoder_Interface_init(void)
+{
+ dec_interface_State * s;
+
+ /* allocate memory */
+ /*if ( ( s = ( dec_interface_State * ) tlsf_malloc( sizeof( dec_interface_State ) ) ) ==
+ NULL ) {
+ fprintf( stderr, "Decoder_Interface_init: "
+ "can not malloc state structure\n" );
+ return NULL;
+ }*/
+ s = &g_dec_interface_State;
+
+ s->decoder_State = Speech_Decode_Frame_init();
+
+ if (s->decoder_State == NULL) {
+ // tlsf_free( s );
+ return NULL;
+ }
+ Decoder_Interface_reset(s);
+ return (void *)s;
+}
+
+
+/*
+ * Decoder_Interface_exit
+ *
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+void Decoder_Interface_exit(void *state)
+{
+ dec_interface_State * s;
+ s = (dec_interface_State *)state;
+
+ /* free memory */
+ Speech_Decode_Frame_exit(s->decoder_State);
+ // tlsf_free( s );
+ s = NULL;
+ state = NULL;
+}
+
+
+/*
+ * Decoder_Interface_Decode
+ *
+ *
+ * Parameters:
+ * st B: state structure
+ * bits I: bit stream
+ * synth O: synthesized speech
+ * bfi I: bad frame indicator
+ *
+ * Function:
+ * Decode bit stream to synthesized speech
+ *
+ * Returns:
+ * Void
+ */
+void Decoder_Interface_Decode(void *st,
+
+#ifndef ETSI
+ UWord8 *bits,
+
+#else
+ Word16 *bits,
+#endif
+
+ Word16 *synth, int bfi)
+{
+ enum Mode mode; /* AMR mode */
+
+#ifndef ETSI
+ enum Mode speech_mode = MR475; /* speech mode */
+#endif
+
+ Word16 prm[PRMNO_MR122]; /* AMR parameters */
+
+ enum RXFrameType frame_type; /* frame type */
+ dec_interface_State * s; /* pointer to structure */
+
+ const Word16 *homing; /* pointer to homing frame */
+ Word16 homingSize; /* frame size for homing frame */
+ Word32 i; /* counter */
+ Word32 resetFlag = 1; /* homing frame */
+
+#ifndef ETSI
+#ifndef IF2
+ Word16 q_bit;
+#endif
+#endif
+
+ s = (dec_interface_State *)st;
+
+#ifndef ETSI
+
+ /*
+ * extract mode information and frametype,
+ * octets to parameters
+ */
+#ifdef IF2
+ mode = Decoder3GPP(prm, bits, &frame_type, &speech_mode);
+#else
+ mode = DecoderMMS(prm, bits, &frame_type, &speech_mode, &q_bit);
+ if (!bfi) {
+ bfi = 1 - q_bit;
+ }
+#endif
+
+ /*
+ * if no mode information
+ * guess one from the previous frame
+ */
+ if (frame_type == RX_SPEECH_BAD) {
+ if (s->prev_ft > 3) {
+ frame_type = RX_SID_BAD;
+ mode = MRDTX;
+ } else {
+ mode = s->prev_mode;
+ }
+ } else if (frame_type == RX_NO_DATA) {
+ mode = s->prev_mode;
+ }
+
+ if (bfi == 1) {
+ if (mode < 8) {
+ frame_type = RX_SPEECH_BAD;
+ } else if (mode != 15) {
+ frame_type = RX_SID_BAD;
+ }
+ }
+
+#else
+ bfi = 0;
+ frame_type = bits[0];
+
+ switch (frame_type) {
+ case 0:
+ frame_type = RX_SPEECH_GOOD;
+ mode = bits[245];
+ Bits2Prm(mode, &bits[1], prm);
+ break;
+
+ case 1:
+ frame_type = RX_SID_FIRST;
+ mode = s->prev_mode;
+ break;
+
+ case 2:
+ frame_type = RX_SID_UPDATE;
+ mode = s->prev_mode;
+ Bits2Prm(MRDTX, &bits[1], prm);
+ break;
+
+ case 3:
+ frame_type = RX_NO_DATA;
+ mode = s->prev_mode;
+ break;
+ }
+
+#endif
+
+ /* test for homing frame */
+ if (s->reset_flag_old == 1) {
+ switch (mode) {
+ case MR122:
+ homing = dhf_MR122;
+ homingSize = 18;
+ break;
+
+ case MR102:
+ homing = dhf_MR102;
+ homingSize = 12;
+ break;
+
+ case MR795:
+ homing = dhf_MR795;
+ homingSize = 8;
+ break;
+
+ case MR74:
+ homing = dhf_MR74;
+ homingSize = 7;
+ break;
+
+ case MR67:
+ homing = dhf_MR67;
+ homingSize = 7;
+ break;
+
+ case MR59:
+ homing = dhf_MR59;
+ homingSize = 7;
+ break;
+
+ case MR515:
+ homing = dhf_MR515;
+ homingSize = 7;
+ break;
+
+ case MR475:
+ homing = dhf_MR475;
+ homingSize = 7;
+ break;
+
+ default:
+ homing = NULL;
+ homingSize = 0;
+ break;
+ }
+
+ for (i = 0; i < homingSize; i++) {
+ resetFlag = prm[i] ^ homing[i];
+
+ if (resetFlag) {
+ break;
+ }
+ }
+ }
+
+ if ((resetFlag == 0) && (s->reset_flag_old != 0)) {
+ for (i = 0; i < 160; i++) {
+ synth[i] = EHF_MASK;
+ }
+ } else {
+ Speech_Decode_Frame(s->decoder_State, mode, prm, frame_type, synth);
+ }
+
+ if (s->reset_flag_old == 0) {
+ /* check whole frame */
+ switch (mode) {
+ case MR122:
+ homing = dhf_MR122;
+ homingSize = PRMNO_MR122;
+ break;
+
+ case MR102:
+ homing = dhf_MR102;
+ homingSize = PRMNO_MR102;
+ break;
+
+ case MR795:
+ homing = dhf_MR795;
+ homingSize = PRMNO_MR795;
+ break;
+
+ case MR74:
+ homing = dhf_MR74;
+ homingSize = PRMNO_MR74;
+ break;
+
+ case MR67:
+ homing = dhf_MR67;
+ homingSize = PRMNO_MR67;
+ break;
+
+ case MR59:
+ homing = dhf_MR59;
+ homingSize = PRMNO_MR59;
+ break;
+
+ case MR515:
+ homing = dhf_MR515;
+ homingSize = PRMNO_MR515;
+ break;
+
+ case MR475:
+ homing = dhf_MR475;
+ homingSize = PRMNO_MR475;
+ break;
+
+ default:
+ homing = NULL;
+ homingSize = 0;
+ }
+
+ for (i = 0; i < homingSize; i++) {
+ resetFlag = prm[i] ^ homing[i];
+
+ if (resetFlag) {
+ break;
+ }
+ }
+ }
+
+ /* reset decoder if current frame is a homing frame */
+ if (resetFlag == 0) {
+ Speech_Decode_Frame_reset(s->decoder_State);
+ }
+ s->reset_flag_old = !resetFlag;
+ s->prev_ft = frame_type;
+ s->prev_mode = mode;
+}
diff --git a/audio_codec/libamr/interf_dec.h b/audio_codec/libamr/interf_dec.h
new file mode 100644
index 0000000..2570ee9
--- a/dev/null
+++ b/audio_codec/libamr/interf_dec.h
@@ -0,0 +1,56 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * R99 V3.5.0 2003-03
+ * REL-4 V4.4.0 2003-03
+ * REL-5 V5.1.0 2003-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * interf_dec.h
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * Defines interface to AMR decoder
+ *
+ */
+
+#ifndef _interf_dec_h_
+#define _interf_dec_h_
+
+/*
+ * Function prototypes
+ */
+/*
+ * Conversion from packed bitstream to endoded parameters
+ * Decoding parameters to speech
+ */
+void Decoder_Interface_Decode(void *st,
+
+#ifndef ETSI
+ unsigned char *bits,
+
+#else
+ short *bits,
+#endif
+
+ short *synth, int bfi);
+
+/*
+ * Reserve and init. memory
+ */
+void *Decoder_Interface_init(void);
+
+/*
+ * Exit and free memory
+ */
+void Decoder_Interface_exit(void *state);
+
+#endif
+
diff --git a/audio_codec/libamr/interf_rom.h b/audio_codec/libamr/interf_rom.h
new file mode 100644
index 0000000..fca6916
--- a/dev/null
+++ b/audio_codec/libamr/interf_rom.h
@@ -0,0 +1,1788 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * R99 V3.5.0 2003-03
+ * REL-4 V4.4.0 2003-03
+ * REL-5 V5.1.0 2003-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * interf_rom.h
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * Tables: Subjective importance
+ * Homing frames
+ *
+ *
+ */
+
+#ifndef _interf_rom_h_
+#define _interf_rom_h_
+
+/*
+ * include files
+ */
+#include"typedef.h"
+
+/*
+ * definition of constants
+ */
+
+/* number of parameters */
+#define PRMNO_MR475 17
+#define PRMNO_MR515 19
+#define PRMNO_MR59 19
+#define PRMNO_MR67 19
+#define PRMNO_MR74 19
+#define PRMNO_MR795 23
+#define PRMNO_MR102 39
+#define PRMNO_MR122 57
+#define PRMNO_MRDTX 5
+
+#ifdef ENABLE_CPU2_DECODER
+CPU2_DATA_START
+#endif
+
+/*
+ * tables
+ */
+#ifndef IF2
+#ifndef ETSI
+static const UWord8 block_size[16] = { 13, 14, 16, 18, 20, 21, 27, 32,
+ 6 , 0 , 0 , 0 , 0 , 0 , 0 , 1
+ };
+
+static const UWord8 toc_byte[16] = {0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C,
+ 0x44, 0x4C, 0x54, 0x5C, 0x64, 0x6C, 0x74, 0x7C
+ };
+#endif
+#else
+/* One encoded frame (bytes) */
+static const UWord8 block_size[16] = { 13, 14, 16, 18, 19, 21, 26, 31,
+ 5 , 0 , 0 , 0 , 0 , 0 , 0 , 1
+ };
+#endif
+
+/* Subjective importance of the speech encoded bits */
+static Word16 order_MR475[] = {
+ 0, 0x80,
+ 0, 0x40,
+ 0, 0x20,
+ 0, 0x10,
+ 0, 0x8,
+ 0, 0x4,
+ 0, 0x2,
+ 0, 0x1,
+ 1, 0x80,
+ 1, 0x40,
+ 1, 0x20,
+ 1, 0x10,
+ 1, 0x8,
+ 1, 0x4,
+ 1, 0x2,
+ 1, 0x1,
+ 3, 0x80,
+ 3, 0x40,
+ 3, 0x20,
+ 3, 0x10,
+ 3, 0x8,
+ 3, 0x4,
+ 7, 0x8,
+ 7, 0x4,
+ 10, 0x8,
+ 10, 0x4,
+ 14, 0x8,
+ 14, 0x4,
+ 6, 0x1,
+ 6, 0x2,
+ 6, 0x4,
+ 6, 0x8,
+ 13, 0x1,
+ 13, 0x2,
+ 13, 0x4,
+ 13, 0x8,
+ 2, 0x20,
+ 2, 0x10,
+ 2, 0x4,
+ 2, 0x1,
+ 13, 0x10,
+ 13, 0x20,
+ 13, 0x40,
+ 13, 0x80,
+ 3, 0x2,
+ 3, 0x1,
+ 6, 0x10,
+ 6, 0x20,
+ 6, 0x40,
+ 6, 0x80,
+ 5, 0x2,
+ 5, 0x1,
+ 2, 0x40,
+ 2, 0x8,
+ 2, 0x2,
+ 7, 0x2,
+ 7, 0x1,
+ 9, 0x2,
+ 9, 0x1,
+ 10, 0x2,
+ 10, 0x1,
+ 12, 0x2,
+ 12, 0x1,
+ 14, 0x2,
+ 14, 0x1,
+ 16, 0x2,
+ 16, 0x1,
+ 4, 0x20,
+ 4, 0x10,
+ 4, 0x4,
+ 4, 0x2,
+ 8, 0x20,
+ 8, 0x10,
+ 8, 0x4,
+ 8, 0x2,
+ 11, 0x20,
+ 11, 0x10,
+ 11, 0x4,
+ 11, 0x2,
+ 15, 0x20,
+ 15, 0x10,
+ 15, 0x4,
+ 15, 0x2,
+ 4, 0x8,
+ 8, 0x8,
+ 11, 0x8,
+ 15, 0x8,
+ 4, 0x1,
+ 8, 0x1,
+ 11, 0x1,
+ 15, 0x1,
+ 4, 0x40,
+ 8, 0x40,
+ 11, 0x40,
+ 15, 0x40
+};
+static Word16 order_MR515[] = {
+ 0, 0x1,
+ 0, 0x2,
+ 0, 0x4,
+ 0, 0x8,
+ 0, 0x10,
+ 0, 0x20,
+ 0, 0x40,
+ 0, 0x80,
+ 1, 0x1,
+ 1, 0x2,
+ 1, 0x4,
+ 1, 0x8,
+ 1, 0x10,
+ 1, 0x20,
+ 1, 0x40,
+ 1, 0x80,
+ 3, 0x80,
+ 3, 0x40,
+ 3, 0x20,
+ 3, 0x10,
+ 3, 0x8,
+ 7, 0x8,
+ 11, 0x8,
+ 15, 0x8,
+ 6, 0x1,
+ 6, 0x2,
+ 6, 0x4,
+ 10, 0x1,
+ 10, 0x2,
+ 10, 0x4,
+ 14, 0x1,
+ 14, 0x2,
+ 14, 0x4,
+ 18, 0x1,
+ 18, 0x2,
+ 18, 0x4,
+ 6, 0x8,
+ 10, 0x8,
+ 14, 0x8,
+ 18, 0x8,
+ 3, 0x4,
+ 7, 0x4,
+ 11, 0x4,
+ 15, 0x4,
+ 2, 0x10,
+ 6, 0x10,
+ 10, 0x10,
+ 14, 0x10,
+ 18, 0x10,
+ 3, 0x2,
+ 7, 0x2,
+ 11, 0x2,
+ 2, 0x20,
+ 2, 0x4,
+ 2, 0x1,
+ 6, 0x20,
+ 10, 0x20,
+ 14, 0x20,
+ 18, 0x20,
+ 2, 0x2,
+ 3, 0x1,
+ 7, 0x1,
+ 11, 0x1,
+ 15, 0x2,
+ 2, 0x8,
+ 2, 0x40,
+ 15, 0x1,
+ 5, 0x1,
+ 5, 0x2,
+ 9, 0x1,
+ 9, 0x2,
+ 13, 0x1,
+ 4, 0x4,
+ 8, 0x4,
+ 12, 0x4,
+ 16, 0x4,
+ 13, 0x2,
+ 17, 0x1,
+ 17, 0x2,
+ 4, 0x2,
+ 8, 0x2,
+ 12, 0x2,
+ 16, 0x2,
+ 4, 0x20,
+ 8, 0x20,
+ 4, 0x10,
+ 8, 0x10,
+ 12, 0x20,
+ 12, 0x10,
+ 16, 0x20,
+ 16, 0x10,
+ 4, 0x40,
+ 8, 0x40,
+ 12, 0x40,
+ 16, 0x40,
+ 4, 0x1,
+ 8, 0x1,
+ 12, 0x1,
+ 16, 0x1,
+ 4, 0x8,
+ 8, 0x8,
+ 12, 0x8,
+ 16, 0x8
+};
+static Word16 order_MR59[] = {
+ 0, 0x80,
+ 0, 0x40,
+ 0, 0x8,
+ 0, 0x4,
+ 0, 0x10,
+ 0, 0x2,
+ 0, 0x1,
+ 0, 0x20,
+ 1, 0x8,
+ 1, 0x2,
+ 1, 0x100,
+ 1, 0x80,
+ 1, 0x20,
+ 1, 0x10,
+ 1, 0x4,
+ 1, 0x40,
+ 1, 0x1,
+ 3, 0x20,
+ 11, 0x20,
+ 3, 0x10,
+ 11, 0x10,
+ 3, 0x40,
+ 11, 0x40,
+ 3, 0x80,
+ 11, 0x80,
+ 3, 0x8,
+ 11, 0x8,
+ 7, 0x8,
+ 15, 0x8,
+ 6, 0x1,
+ 10, 0x1,
+ 14, 0x1,
+ 18, 0x1,
+ 3, 0x4,
+ 11, 0x4,
+ 7, 0x4,
+ 15, 0x4,
+ 6, 0x2,
+ 10, 0x2,
+ 14, 0x2,
+ 18, 0x2,
+ 7, 0x2,
+ 15, 0x2,
+ 3, 0x2,
+ 11, 0x2,
+ 3, 0x1,
+ 11, 0x1,
+ 6, 0x4,
+ 10, 0x4,
+ 14, 0x4,
+ 18, 0x4,
+ 6, 0x8,
+ 10, 0x8,
+ 14, 0x8,
+ 18, 0x8,
+ 6, 0x10,
+ 10, 0x10,
+ 14, 0x10,
+ 18, 0x10,
+ 2, 0x40,
+ 2, 0x10,
+ 2, 0x4,
+ 2, 0x8,
+ 2, 0x80,
+ 2, 0x100,
+ 2, 0x20,
+ 2, 0x2,
+ 17, 0x1,
+ 5, 0x2,
+ 13, 0x2,
+ 17, 0x2,
+ 9, 0x2,
+ 9, 0x1,
+ 5, 0x1,
+ 13, 0x1,
+ 2, 0x1,
+ 6, 0x20,
+ 10, 0x20,
+ 14, 0x20,
+ 18, 0x20,
+ 7, 0x1,
+ 15, 0x1,
+ 4, 0x4,
+ 8, 0x4,
+ 12, 0x4,
+ 16, 0x4,
+ 4, 0x8,
+ 8, 0x8,
+ 12, 0x8,
+ 16, 0x8,
+ 4, 0x40,
+ 8, 0x40,
+ 12, 0x40,
+ 16, 0x40,
+ 4, 0x80,
+ 8, 0x80,
+ 12, 0x80,
+ 16, 0x80,
+ 4, 0x100,
+ 8, 0x100,
+ 12, 0x100,
+ 16, 0x100,
+ 4, 0x1,
+ 8, 0x1,
+ 12, 0x1,
+ 16, 0x1,
+ 4, 0x2,
+ 8, 0x2,
+ 12, 0x2,
+ 16, 0x2,
+ 4, 0x10,
+ 8, 0x10,
+ 12, 0x10,
+ 16, 0x10,
+ 4, 0x20,
+ 8, 0x20,
+ 12, 0x20,
+ 16, 0x20
+};
+static Word16 order_MR67[] = {
+ 0, 0x80,
+ 0, 0x40,
+ 0, 0x8,
+ 0, 0x10,
+ 0, 0x4,
+ 0, 0x2,
+ 1, 0x8,
+ 0, 0x1,
+ 0, 0x20,
+ 1, 0x100,
+ 1, 0x80,
+ 1, 0x20,
+ 1, 0x2,
+ 1, 0x10,
+ 1, 0x4,
+ 1, 0x40,
+ 3, 0x20,
+ 11, 0x20,
+ 3, 0x10,
+ 11, 0x10,
+ 3, 0x40,
+ 11, 0x40,
+ 3, 0x80,
+ 11, 0x80,
+ 3, 0x8,
+ 11, 0x8,
+ 1, 0x1,
+ 7, 0x8,
+ 15, 0x8,
+ 7, 0x4,
+ 15, 0x4,
+ 3, 0x4,
+ 11, 0x4,
+ 7, 0x2,
+ 15, 0x2,
+ 6, 0x40,
+ 10, 0x40,
+ 14, 0x40,
+ 18, 0x40,
+ 3, 0x2,
+ 11, 0x2,
+ 6, 0x8,
+ 10, 0x8,
+ 14, 0x8,
+ 18, 0x8,
+ 6, 0x4,
+ 10, 0x4,
+ 14, 0x4,
+ 18, 0x4,
+ 7, 0x1,
+ 15, 0x1,
+ 3, 0x1,
+ 11, 0x1,
+ 2, 0x40,
+ 2, 0x4,
+ 6, 0x2,
+ 10, 0x2,
+ 14, 0x2,
+ 18, 0x2,
+ 2, 0x10,
+ 2, 0x8,
+ 2, 0x80,
+ 2, 0x100,
+ 2, 0x20,
+ 2, 0x2,
+ 2, 0x1,
+ 6, 0x10,
+ 10, 0x10,
+ 14, 0x10,
+ 18, 0x10,
+ 5, 0x1,
+ 9, 0x1,
+ 13, 0x1,
+ 17, 0x1,
+ 6, 0x1,
+ 10, 0x1,
+ 14, 0x1,
+ 18, 0x1,
+ 5, 0x2,
+ 9, 0x2,
+ 13, 0x2,
+ 17, 0x2,
+ 18, 0x20,
+ 14, 0x20,
+ 10, 0x20,
+ 6, 0x20,
+ 5, 0x4,
+ 9, 0x4,
+ 13, 0x4,
+ 17, 0x4,
+ 4, 0x4,
+ 8, 0x4,
+ 12, 0x4,
+ 16, 0x4,
+ 4, 0x20,
+ 8, 0x20,
+ 12, 0x20,
+ 16, 0x20,
+ 4, 0x40,
+ 8, 0x40,
+ 12, 0x40,
+ 16, 0x40,
+ 4, 0x200,
+ 8, 0x200,
+ 12, 0x200,
+ 16, 0x200,
+ 4, 0x400,
+ 8, 0x400,
+ 12, 0x400,
+ 16, 0x400,
+ 4, 0x1,
+ 8, 0x1,
+ 12, 0x1,
+ 16, 0x1,
+ 4, 0x2,
+ 8, 0x2,
+ 12, 0x2,
+ 16, 0x2,
+ 4, 0x8,
+ 8, 0x8,
+ 12, 0x8,
+ 16, 0x8,
+ 4, 0x10,
+ 8, 0x10,
+ 12, 0x10,
+ 16, 0x10,
+ 4, 0x80,
+ 8, 0x80,
+ 12, 0x80,
+ 16, 0x80,
+ 4, 0x100,
+ 8, 0x100,
+ 12, 0x100,
+ 16, 0x100
+};
+static Word16 order_MR74[] = {
+ 0, 0x80,
+ 0, 0x40,
+ 0, 0x20,
+ 0, 0x10,
+ 0, 0x8,
+ 0, 0x4,
+ 0, 0x2,
+ 0, 0x1,
+ 1, 0x100,
+ 1, 0x80,
+ 1, 0x40,
+ 1, 0x20,
+ 1, 0x10,
+ 1, 0x8,
+ 1, 0x4,
+ 1, 0x2,
+ 1, 0x1,
+ 3, 0x80,
+ 11, 0x80,
+ 3, 0x40,
+ 11, 0x40,
+ 3, 0x20,
+ 11, 0x20,
+ 3, 0x10,
+ 11, 0x10,
+ 3, 0x8,
+ 11, 0x8,
+ 6, 0x40,
+ 10, 0x40,
+ 14, 0x40,
+ 18, 0x40,
+ 6, 0x20,
+ 10, 0x20,
+ 14, 0x20,
+ 18, 0x20,
+ 6, 0x8,
+ 10, 0x8,
+ 14, 0x8,
+ 18, 0x8,
+ 6, 0x4,
+ 10, 0x4,
+ 14, 0x4,
+ 18, 0x4,
+ 7, 0x10,
+ 15, 0x10,
+ 7, 0x8,
+ 15, 0x8,
+ 2, 0x10,
+ 2, 0x8,
+ 2, 0x4,
+ 2, 0x100,
+ 2, 0x80,
+ 2, 0x40,
+ 3, 0x4,
+ 7, 0x4,
+ 11, 0x4,
+ 15, 0x4,
+ 6, 0x2,
+ 10, 0x2,
+ 14, 0x2,
+ 18, 0x2,
+ 2, 0x20,
+ 2, 0x2,
+ 2, 0x1,
+ 5, 0x1,
+ 9, 0x1,
+ 13, 0x1,
+ 17, 0x1,
+ 6, 0x1,
+ 10, 0x1,
+ 14, 0x1,
+ 18, 0x1,
+ 5, 0x2,
+ 9, 0x2,
+ 13, 0x2,
+ 17, 0x2,
+ 5, 0x4,
+ 9, 0x4,
+ 6, 0x10,
+ 10, 0x10,
+ 14, 0x10,
+ 18, 0x10,
+ 13, 0x4,
+ 17, 0x4,
+ 5, 0x8,
+ 9, 0x8,
+ 13, 0x8,
+ 17, 0x8,
+ 3, 0x2,
+ 3, 0x1,
+ 7, 0x2,
+ 7, 0x1,
+ 11, 0x2,
+ 11, 0x1,
+ 15, 0x2,
+ 15, 0x1,
+ 4, 0x20,
+ 4, 0x10,
+ 4, 0x8,
+ 4, 0x4,
+ 4, 0x2,
+ 4, 0x1,
+ 8, 0x20,
+ 8, 0x10,
+ 8, 0x8,
+ 8, 0x4,
+ 8, 0x2,
+ 8, 0x1,
+ 12, 0x20,
+ 12, 0x10,
+ 12, 0x8,
+ 12, 0x4,
+ 12, 0x2,
+ 12, 0x1,
+ 16, 0x20,
+ 16, 0x10,
+ 16, 0x8,
+ 16, 0x4,
+ 16, 0x2,
+ 16, 0x1,
+ 4, 0x1000,
+ 8, 0x1000,
+ 12, 0x1000,
+ 16, 0x1000,
+ 4, 0x800,
+ 8, 0x800,
+ 12, 0x800,
+ 16, 0x800,
+ 4, 0x400,
+ 8, 0x400,
+ 12, 0x400,
+ 16, 0x400,
+ 4, 0x200,
+ 8, 0x200,
+ 12, 0x200,
+ 16, 0x200,
+ 4, 0x100,
+ 8, 0x100,
+ 12, 0x100,
+ 16, 0x100,
+ 4, 0x80,
+ 8, 0x80,
+ 12, 0x80,
+ 16, 0x80,
+ 4, 0x40,
+ 8, 0x40,
+ 12, 0x40,
+ 16, 0x40
+};
+static Word16 order_MR795[] = {
+ 0, 0x1,
+ 0, 0x2,
+ 0, 0x4,
+ 0, 0x8,
+ 0, 0x10,
+ 0, 0x20,
+ 0, 0x40,
+ 1, 0x8,
+ 1, 0x2,
+ 1, 0x100,
+ 1, 0x80,
+ 1, 0x20,
+ 1, 0x10,
+ 1, 0x4,
+ 1, 0x40,
+ 1, 0x1,
+ 2, 0x40,
+ 2, 0x10,
+ 2, 0x4,
+ 2, 0x8,
+ 2, 0x80,
+ 2, 0x100,
+ 2, 0x20,
+ 7, 0x10,
+ 12, 0x10,
+ 17, 0x10,
+ 22, 0x10,
+ 7, 0x8,
+ 12, 0x8,
+ 17, 0x8,
+ 22, 0x8,
+ 7, 0x4,
+ 12, 0x4,
+ 17, 0x4,
+ 22, 0x4,
+ 6, 0x8,
+ 11, 0x8,
+ 16, 0x8,
+ 21, 0x8,
+ 6, 0x4,
+ 11, 0x4,
+ 16, 0x4,
+ 21, 0x4,
+ 3, 0x80,
+ 13, 0x80,
+ 3, 0x40,
+ 13, 0x40,
+ 3, 0x20,
+ 13, 0x20,
+ 3, 0x10,
+ 13, 0x10,
+ 3, 0x8,
+ 13, 0x8,
+ 8, 0x20,
+ 18, 0x20,
+ 8, 0x10,
+ 18, 0x10,
+ 8, 0x8,
+ 18, 0x8,
+ 7, 0x2,
+ 12, 0x2,
+ 17, 0x2,
+ 22, 0x2,
+ 3, 0x4,
+ 13, 0x4,
+ 8, 0x4,
+ 18, 0x4,
+ 0, 0x80,
+ 0, 0x100,
+ 2, 0x2,
+ 2, 0x1,
+ 3, 0x2,
+ 13, 0x2,
+ 3, 0x1,
+ 13, 0x1,
+ 8, 0x2,
+ 18, 0x2,
+ 8, 0x1,
+ 18, 0x1,
+ 6, 0x2,
+ 11, 0x2,
+ 16, 0x2,
+ 21, 0x2,
+ 7, 0x1,
+ 12, 0x1,
+ 17, 0x1,
+ 22, 0x1,
+ 6, 0x1,
+ 11, 0x1,
+ 16, 0x1,
+ 21, 0x1,
+ 15, 0x1,
+ 15, 0x2,
+ 15, 0x4,
+ 4, 0x2,
+ 9, 0x2,
+ 14, 0x2,
+ 19, 0x2,
+ 4, 0x10,
+ 9, 0x10,
+ 14, 0x10,
+ 19, 0x10,
+ 4, 0x80,
+ 9, 0x80,
+ 14, 0x80,
+ 19, 0x80,
+ 4, 0x800,
+ 9, 0x800,
+ 14, 0x800,
+ 19, 0x800,
+ 15, 0x8,
+ 20, 0x1,
+ 20, 0x2,
+ 20, 0x4,
+ 20, 0x8,
+ 10, 0x1,
+ 10, 0x2,
+ 10, 0x4,
+ 10, 0x8,
+ 5, 0x1,
+ 5, 0x2,
+ 5, 0x4,
+ 5, 0x8,
+ 4, 0x1,
+ 4, 0x4,
+ 4, 0x8,
+ 4, 0x20,
+ 4, 0x100,
+ 4, 0x1000,
+ 9, 0x1,
+ 9, 0x4,
+ 9, 0x8,
+ 9, 0x20,
+ 9, 0x100,
+ 9, 0x1000,
+ 14, 0x1,
+ 14, 0x4,
+ 14, 0x8,
+ 14, 0x20,
+ 14, 0x100,
+ 14, 0x1000,
+ 19, 0x1,
+ 19, 0x4,
+ 19, 0x8,
+ 19, 0x20,
+ 19, 0x100,
+ 19, 0x1000,
+ 4, 0x40,
+ 9, 0x40,
+ 14, 0x40,
+ 19, 0x40,
+ 4, 0x400,
+ 9, 0x400,
+ 14, 0x400,
+ 19, 0x400,
+ 4, 0x200,
+ 9, 0x200,
+ 14, 0x200,
+ 19, 0x200,
+ 0, 0x1,
+ 0, 0x2,
+ 0, 0x4,
+ 0, 0x8,
+ 0, 0x10,
+ 0, 0x20,
+ 0, 0x40,
+ 1, 0x8,
+ 1, 0x2,
+ 1, 0x100,
+ 1, 0x80,
+ 1, 0x20,
+ 1, 0x10,
+ 1, 0x4,
+ 1, 0x40,
+ 1, 0x1,
+ 2, 0x40,
+ 2, 0x10,
+ 2, 0x4,
+ 2, 0x8,
+ 2, 0x80,
+ 2, 0x100,
+ 2, 0x20,
+ 7, 0x10,
+ 12, 0x10,
+ 17, 0x10,
+ 22, 0x10,
+ 7, 0x8,
+ 12, 0x8,
+ 17, 0x8,
+ 22, 0x8,
+ 7, 0x4,
+ 12, 0x4,
+ 17, 0x4,
+ 22, 0x4,
+ 6, 0x8,
+ 11, 0x8,
+ 16, 0x8,
+ 21, 0x8,
+ 6, 0x4,
+ 11, 0x4,
+ 16, 0x4,
+ 21, 0x4,
+ 3, 0x80,
+ 13, 0x80,
+ 3, 0x40,
+ 13, 0x40,
+ 3, 0x20,
+ 13, 0x20,
+ 3, 0x10,
+ 13, 0x10,
+ 3, 0x8,
+ 13, 0x8,
+ 8, 0x20,
+ 18, 0x20,
+ 8, 0x10,
+ 18, 0x10,
+ 8, 0x8,
+ 18, 0x8,
+ 7, 0x2,
+ 12, 0x2,
+ 17, 0x2,
+ 22, 0x2,
+ 3, 0x4,
+ 13, 0x4,
+ 8, 0x4,
+ 18, 0x4,
+ 0, 0x80,
+ 0, 0x100,
+ 2, 0x2,
+ 2, 0x1,
+ 3, 0x2,
+ 13, 0x2,
+ 3, 0x1,
+ 13, 0x1,
+ 8, 0x2,
+ 18, 0x2,
+ 8, 0x1,
+ 18, 0x1,
+ 6, 0x2,
+ 11, 0x2,
+ 16, 0x2,
+ 21, 0x2,
+ 7, 0x1,
+ 12, 0x1,
+ 17, 0x1,
+ 22, 0x1,
+ 6, 0x1,
+ 11, 0x1,
+ 16, 0x1,
+ 21, 0x1,
+ 15, 0x1,
+ 15, 0x2,
+ 15, 0x4,
+ 4, 0x2,
+ 9, 0x2,
+ 14, 0x2,
+ 19, 0x2,
+ 4, 0x10,
+ 9, 0x10,
+ 14, 0x10,
+ 19, 0x10,
+ 4, 0x80,
+ 9, 0x80,
+ 14, 0x80,
+ 19, 0x80,
+ 4, 0x800,
+ 9, 0x800,
+ 14, 0x800,
+ 19, 0x800,
+ 15, 0x8,
+ 20, 0x1,
+ 20, 0x2,
+ 20, 0x4,
+ 20, 0x8,
+ 10, 0x1,
+ 10, 0x2,
+ 10, 0x4,
+ 10, 0x8,
+ 5, 0x1,
+ 5, 0x2,
+ 5, 0x4,
+ 5, 0x8,
+ 4, 0x1,
+ 4, 0x4,
+ 4, 0x8,
+ 4, 0x20,
+ 4, 0x100,
+ 4, 0x1000,
+ 9, 0x1,
+ 9, 0x4,
+ 9, 0x8,
+ 9, 0x20,
+ 9, 0x100,
+ 9, 0x1000,
+ 14, 0x1,
+ 14, 0x4,
+ 14, 0x8,
+ 14, 0x20,
+ 14, 0x100,
+ 14, 0x1000,
+ 19, 0x1,
+ 19, 0x4,
+ 19, 0x8,
+ 19, 0x20,
+ 19, 0x100,
+ 19, 0x1000,
+ 4, 0x40,
+ 9, 0x40,
+ 14, 0x40,
+ 19, 0x40,
+ 4, 0x400,
+ 9, 0x400,
+ 14, 0x400,
+ 19, 0x400,
+ 4, 0x200,
+ 9, 0x200,
+ 14, 0x200,
+ 19, 0x200
+};
+static Word16 order_MR102[] = {
+ 0, 0x1,
+ 0, 0x2,
+ 0, 0x4,
+ 0, 0x8,
+ 0, 0x10,
+ 0, 0x20,
+ 0, 0x40,
+ 0, 0x80,
+ 1, 0x1,
+ 1, 0x2,
+ 1, 0x4,
+ 1, 0x8,
+ 1, 0x10,
+ 1, 0x20,
+ 1, 0x40,
+ 1, 0x80,
+ 1, 0x100,
+ 3, 0x80,
+ 3, 0x40,
+ 3, 0x20,
+ 3, 0x10,
+ 3, 0x8,
+ 3, 0x4,
+ 21, 0x80,
+ 21, 0x40,
+ 21, 0x20,
+ 21, 0x10,
+ 21, 0x8,
+ 21, 0x4,
+ 12, 0x10,
+ 12, 0x8,
+ 30, 0x10,
+ 30, 0x8,
+ 11, 0x40,
+ 11, 0x8,
+ 11, 0x4,
+ 20, 0x40,
+ 20, 0x8,
+ 20, 0x4,
+ 29, 0x40,
+ 29, 0x8,
+ 29, 0x4,
+ 38, 0x40,
+ 38, 0x8,
+ 38, 0x4,
+ 3, 0x2,
+ 3, 0x1,
+ 21, 0x2,
+ 21, 0x1,
+ 12, 0x4,
+ 12, 0x2,
+ 30, 0x4,
+ 30, 0x2,
+ 11, 0x20,
+ 20, 0x20,
+ 29, 0x20,
+ 38, 0x20,
+ 2, 0x40,
+ 2, 0x4,
+ 2, 0x10,
+ 2, 0x8,
+ 2, 0x80,
+ 2, 0x100,
+ 2, 0x20,
+ 2, 0x2,
+ 2, 0x1,
+ 7, 0x1,
+ 6, 0x1,
+ 5, 0x1,
+ 4, 0x1,
+ 16, 0x1,
+ 15, 0x1,
+ 14, 0x1,
+ 13, 0x1,
+ 25, 0x1,
+ 24, 0x1,
+ 23, 0x1,
+ 22, 0x1,
+ 34, 0x1,
+ 33, 0x1,
+ 32, 0x1,
+ 31, 0x1,
+ 11, 0x2,
+ 11, 0x10,
+ 11, 0x1,
+ 20, 0x2,
+ 20, 0x10,
+ 20, 0x1,
+ 29, 0x2,
+ 29, 0x10,
+ 29, 0x1,
+ 38, 0x2,
+ 38, 0x10,
+ 38, 0x1,
+ 12, 0x1,
+ 30, 0x1,
+ 17, 0x200,
+ 17, 0x100,
+ 18, 0x100,
+ 18, 0x200,
+ 18, 0x80,
+ 17, 0x80,
+ 18, 0x20,
+ 17, 0x20,
+ 17, 0x40,
+ 18, 0x40,
+ 19, 0x40,
+ 19, 0x20,
+ 18, 0x10,
+ 19, 0x8,
+ 17, 0x10,
+ 19, 0x10,
+ 17, 0x8,
+ 18, 0x8,
+ 26, 0x200,
+ 26, 0x100,
+ 27, 0x100,
+ 27, 0x200,
+ 27, 0x80,
+ 26, 0x80,
+ 27, 0x20,
+ 26, 0x20,
+ 26, 0x40,
+ 27, 0x40,
+ 28, 0x40,
+ 28, 0x20,
+ 27, 0x10,
+ 28, 0x8,
+ 26, 0x10,
+ 28, 0x10,
+ 26, 0x8,
+ 27, 0x8,
+ 35, 0x200,
+ 35, 0x100,
+ 36, 0x100,
+ 36, 0x200,
+ 36, 0x80,
+ 35, 0x80,
+ 36, 0x20,
+ 35, 0x20,
+ 35, 0x40,
+ 36, 0x40,
+ 37, 0x40,
+ 37, 0x20,
+ 36, 0x10,
+ 37, 0x8,
+ 35, 0x10,
+ 37, 0x10,
+ 35, 0x8,
+ 36, 0x8,
+ 8, 0x200,
+ 8, 0x100,
+ 9, 0x100,
+ 9, 0x200,
+ 9, 0x80,
+ 8, 0x80,
+ 9, 0x20,
+ 8, 0x20,
+ 8, 0x40,
+ 9, 0x40,
+ 10, 0x40,
+ 10, 0x20,
+ 9, 0x10,
+ 10, 0x8,
+ 8, 0x10,
+ 10, 0x10,
+ 8, 0x8,
+ 9, 0x8,
+ 37, 0x4,
+ 35, 0x1,
+ 36, 0x1,
+ 37, 0x1,
+ 35, 0x4,
+ 37, 0x2,
+ 35, 0x2,
+ 36, 0x4,
+ 36, 0x2,
+ 28, 0x4,
+ 26, 0x1,
+ 27, 0x1,
+ 28, 0x1,
+ 26, 0x4,
+ 28, 0x2,
+ 26, 0x2,
+ 27, 0x4,
+ 27, 0x2,
+ 19, 0x4,
+ 17, 0x1,
+ 18, 0x1,
+ 19, 0x1,
+ 17, 0x4,
+ 19, 0x2,
+ 17, 0x2,
+ 18, 0x4,
+ 18, 0x2,
+ 10, 0x4,
+ 8, 0x1,
+ 9, 0x1,
+ 10, 0x1,
+ 8, 0x4,
+ 10, 0x2,
+ 8, 0x2,
+ 9, 0x4,
+ 9, 0x2
+};
+static Word16 order_MR122[] = {
+ 0, 0x40,
+ 0, 0x20,
+ 0, 0x10,
+ 0, 0x8,
+ 0, 0x4,
+ 0, 0x2,
+ 0, 0x1,
+ 1, 0x80,
+ 1, 0x40,
+ 1, 0x20,
+ 1, 0x10,
+ 1, 0x8,
+ 1, 0x4,
+ 1, 0x2,
+ 1, 0x1,
+ 2, 0x1,
+ 2, 0x100,
+ 2, 0x80,
+ 2, 0x40,
+ 2, 0x20,
+ 2, 0x10,
+ 2, 0x8,
+ 2, 0x4,
+ 2, 0x2,
+ 3, 0x80,
+ 3, 0x40,
+ 3, 0x20,
+ 3, 0x10,
+ 3, 0x8,
+ 5, 0x100,
+ 31, 0x100,
+ 5, 0x80,
+ 31, 0x80,
+ 5, 0x40,
+ 31, 0x40,
+ 5, 0x20,
+ 31, 0x20,
+ 5, 0x10,
+ 31, 0x10,
+ 5, 0x8,
+ 31, 0x8,
+ 5, 0x4,
+ 31, 0x4,
+ 5, 0x2,
+ 31, 0x2,
+ 5, 0x1,
+ 31, 0x1,
+ 6, 0x8,
+ 19, 0x8,
+ 32, 0x8,
+ 45, 0x8,
+ 6, 0x4,
+ 19, 0x4,
+ 32, 0x4,
+ 45, 0x4,
+ 6, 0x2,
+ 19, 0x2,
+ 32, 0x2,
+ 45, 0x2,
+ 17, 0x10,
+ 30, 0x10,
+ 43, 0x10,
+ 56, 0x10,
+ 17, 0x8,
+ 30, 0x8,
+ 43, 0x8,
+ 56, 0x8,
+ 17, 0x4,
+ 30, 0x4,
+ 43, 0x4,
+ 56, 0x4,
+ 18, 0x20,
+ 44, 0x20,
+ 18, 0x10,
+ 44, 0x10,
+ 18, 0x8,
+ 44, 0x8,
+ 18, 0x4,
+ 44, 0x4,
+ 18, 0x2,
+ 44, 0x2,
+ 3, 0x4,
+ 3, 0x2,
+ 3, 0x1,
+ 4, 0x20,
+ 4, 0x10,
+ 4, 0x8,
+ 4, 0x4,
+ 6, 0x1,
+ 19, 0x1,
+ 32, 0x1,
+ 45, 0x1,
+ 17, 0x2,
+ 30, 0x2,
+ 43, 0x2,
+ 56, 0x2,
+ 7, 0x8,
+ 20, 0x8,
+ 33, 0x8,
+ 46, 0x8,
+ 8, 0x8,
+ 21, 0x8,
+ 34, 0x8,
+ 47, 0x8,
+ 17, 0x1,
+ 30, 0x1,
+ 43, 0x1,
+ 56, 0x1,
+ 9, 0x8,
+ 22, 0x8,
+ 35, 0x8,
+ 48, 0x8,
+ 10, 0x8,
+ 23, 0x8,
+ 36, 0x8,
+ 49, 0x8,
+ 11, 0x8,
+ 24, 0x8,
+ 37, 0x8,
+ 50, 0x8,
+ 4, 0x2,
+ 4, 0x1,
+ 7, 0x1,
+ 7, 0x2,
+ 7, 0x4,
+ 8, 0x1,
+ 8, 0x2,
+ 8, 0x4,
+ 9, 0x1,
+ 9, 0x2,
+ 9, 0x4,
+ 10, 0x1,
+ 10, 0x2,
+ 10, 0x4,
+ 11, 0x1,
+ 11, 0x2,
+ 11, 0x4,
+ 20, 0x1,
+ 20, 0x2,
+ 20, 0x4,
+ 21, 0x1,
+ 21, 0x2,
+ 21, 0x4,
+ 22, 0x1,
+ 22, 0x2,
+ 22, 0x4,
+ 23, 0x1,
+ 23, 0x2,
+ 23, 0x4,
+ 24, 0x1,
+ 24, 0x2,
+ 24, 0x4,
+ 33, 0x1,
+ 33, 0x2,
+ 33, 0x4,
+ 34, 0x1,
+ 34, 0x2,
+ 34, 0x4,
+ 35, 0x1,
+ 35, 0x2,
+ 35, 0x4,
+ 36, 0x1,
+ 36, 0x2,
+ 36, 0x4,
+ 37, 0x1,
+ 37, 0x2,
+ 37, 0x4,
+ 46, 0x1,
+ 46, 0x2,
+ 46, 0x4,
+ 47, 0x1,
+ 47, 0x2,
+ 47, 0x4,
+ 48, 0x1,
+ 48, 0x2,
+ 48, 0x4,
+ 49, 0x1,
+ 49, 0x2,
+ 49, 0x4,
+ 50, 0x1,
+ 50, 0x2,
+ 50, 0x4,
+ 12, 0x1,
+ 12, 0x2,
+ 12, 0x4,
+ 13, 0x1,
+ 13, 0x2,
+ 13, 0x4,
+ 14, 0x1,
+ 14, 0x2,
+ 14, 0x4,
+ 15, 0x1,
+ 15, 0x2,
+ 15, 0x4,
+ 16, 0x1,
+ 16, 0x2,
+ 16, 0x4,
+ 25, 0x1,
+ 25, 0x2,
+ 25, 0x4,
+ 26, 0x1,
+ 26, 0x2,
+ 26, 0x4,
+ 27, 0x1,
+ 27, 0x2,
+ 27, 0x4,
+ 28, 0x1,
+ 28, 0x2,
+ 28, 0x4,
+ 29, 0x1,
+ 29, 0x2,
+ 29, 0x4,
+ 38, 0x1,
+ 38, 0x2,
+ 38, 0x4,
+ 39, 0x1,
+ 39, 0x2,
+ 39, 0x4,
+ 40, 0x1,
+ 40, 0x2,
+ 40, 0x4,
+ 41, 0x1,
+ 41, 0x2,
+ 41, 0x4,
+ 42, 0x1,
+ 42, 0x2,
+ 42, 0x4,
+ 51, 0x1,
+ 51, 0x2,
+ 51, 0x4,
+ 52, 0x1,
+ 52, 0x2,
+ 52, 0x4,
+ 53, 0x1,
+ 53, 0x2,
+ 53, 0x4,
+ 54, 0x1,
+ 54, 0x2,
+ 54, 0x4,
+ 55, 0x1,
+ 55, 0x2,
+ 55, 0x4,
+ 18, 0x1,
+ 44, 0x1
+};
+static Word16 order_MRDTX[] = {
+ 0, 0x4,
+ 0, 0x2,
+ 0, 0x1,
+ 1, 0x80,
+ 1, 0x40,
+ 1, 0x20,
+ 1, 0x10,
+ 1, 0x8,
+ 1, 0x4,
+ 1, 0x2,
+ 1, 0x1,
+ 2, 0x100,
+ 2, 0x80,
+ 2, 0x40,
+ 2, 0x20,
+ 2, 0x10,
+ 2, 0x8,
+ 2, 0x4,
+ 2, 0x2,
+ 2, 0x1,
+ 3, 0x100,
+ 3, 0x80,
+ 3, 0x40,
+ 3, 0x20,
+ 3, 0x10,
+ 3, 0x8,
+ 3, 0x4,
+ 3, 0x2,
+ 3, 0x1,
+ 4, 0x20,
+ 4, 0x10,
+ 4, 0x8,
+ 4, 0x4,
+ 4, 0x2,
+ 4, 0x1
+};
+
+/* Homing frames for the decoder */
+static const Word16 dhf_MR475[PRMNO_MR475] = {
+ 0x00F8,
+ 0x009D,
+ 0x001C,
+ 0x0066,
+ 0x0000,
+ 0x0003,
+ 0x0028,
+ 0x000F,
+ 0x0038,
+ 0x0001,
+ 0x000F,
+ 0x0031,
+ 0x0002,
+ 0x0008,
+ 0x000F,
+ 0x0026,
+ 0x0003
+};
+static const Word16 dhf_MR515[PRMNO_MR515] = {
+ 0x00F8,
+ 0x009D,
+ 0x001C,
+ 0x0066,
+ 0x0000,
+ 0x0003,
+ 0x0037,
+ 0x000F,
+ 0x0000,
+ 0x0003,
+ 0x0005,
+ 0x000F,
+ 0x0037,
+ 0x0003,
+ 0x0037,
+ 0x000F,
+ 0x0023,
+ 0x0003,
+ 0x001F
+};
+static const Word16 dhf_MR59[PRMNO_MR59] = {
+ 0x00F8,
+ 0x00E3,
+ 0x002F,
+ 0x00BD,
+ 0x0000,
+ 0x0003,
+ 0x0037,
+ 0x000F,
+ 0x0001,
+ 0x0003,
+ 0x000F,
+ 0x0060,
+ 0x00F9,
+ 0x0003,
+ 0x0037,
+ 0x000F,
+ 0x0000,
+ 0x0003,
+ 0x0037
+};
+static const Word16 dhf_MR67[PRMNO_MR67] = {
+ 0x00F8,
+ 0x00E3,
+ 0x002F,
+ 0x00BD,
+ 0x0002,
+ 0x0007,
+ 0x0000,
+ 0x000F,
+ 0x0098,
+ 0x0007,
+ 0x0061,
+ 0x0060,
+ 0x05C5,
+ 0x0007,
+ 0x0000,
+ 0x000F,
+ 0x0318,
+ 0x0007,
+ 0x0000
+};
+static const Word16 dhf_MR74[PRMNO_MR74] = {
+ 0x00F8,
+ 0x00E3,
+ 0x002F,
+ 0x00BD,
+ 0x0006,
+ 0x000F,
+ 0x0000,
+ 0x001B,
+ 0x0208,
+ 0x000F,
+ 0x0062,
+ 0x0060,
+ 0x1BA6,
+ 0x000F,
+ 0x0000,
+ 0x001B,
+ 0x0006,
+ 0x000F,
+ 0x0000
+};
+static const Word16 dhf_MR795[PRMNO_MR795] = {
+ 0x00C2,
+ 0x00E3,
+ 0x002F,
+ 0x00BD,
+ 0x0006,
+ 0x000F,
+ 0x000A,
+ 0x0000,
+ 0x0039,
+ 0x1C08,
+ 0x0007,
+ 0x000A,
+ 0x000B,
+ 0x0063,
+ 0x11A6,
+ 0x000F,
+ 0x0001,
+ 0x0000,
+ 0x0039,
+ 0x09A0,
+ 0x000F,
+ 0x0002,
+ 0x0001
+};
+static const Word16 dhf_MR102[PRMNO_MR102] = {
+ 0x00F8,
+ 0x00E3,
+ 0x002F,
+ 0x0045,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x001B,
+ 0x0000,
+ 0x0001,
+ 0x0000,
+ 0x0001,
+ 0x0326,
+ 0x00CE,
+ 0x007E,
+ 0x0051,
+ 0x0062,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x015A,
+ 0x0359,
+ 0x0076,
+ 0x0000,
+ 0x001B,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x017C,
+ 0x0215,
+ 0x0038,
+ 0x0030
+};
+static const Word16 dhf_MR122[PRMNO_MR122] = {
+ 0x0004,
+ 0x002A,
+ 0x00DB,
+ 0x0096,
+ 0x002A,
+ 0x0156,
+ 0x000B,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0036,
+ 0x000B,
+ 0x0000,
+ 0x000F,
+ 0x000E,
+ 0x000C,
+ 0x000D,
+ 0x0000,
+ 0x0001,
+ 0x0005,
+ 0x0007,
+ 0x0001,
+ 0x0008,
+ 0x0024,
+ 0x0000,
+ 0x0001,
+ 0x0000,
+ 0x0005,
+ 0x0006,
+ 0x0001,
+ 0x0002,
+ 0x0004,
+ 0x0007,
+ 0x0004,
+ 0x0002,
+ 0x0003,
+ 0x0036,
+ 0x000B,
+ 0x0000,
+ 0x0002,
+ 0x0004,
+ 0x0000,
+ 0x0003,
+ 0x0006,
+ 0x0001,
+ 0x0007,
+ 0x0006,
+ 0x0005,
+ 0x0000
+};
+
+
+/* parameter sizes (# of bits), one table per mode */
+static const Word16 bitno_MR475[PRMNO_MR475] = {
+ 8, 8, 7, /* LSP VQ */
+ 8, 7, 2, 8, /* first subframe */
+ 4, 7, 2, /* second subframe */
+ 4, 7, 2, 8, /* third subframe */
+ 4, 7, 2 /* fourth subframe */
+};
+static const Word16 bitno_MR515[PRMNO_MR515] = {
+ 8, 8, 7, /* LSP VQ */
+ 8, 7, 2, 6, /* first subframe */
+ 4, 7, 2, 6, /* second subframe */
+ 4, 7, 2, 6, /* third subframe */
+ 4, 7, 2, 6 /* fourth subframe */
+};
+static const Word16 bitno_MR59[PRMNO_MR59] = {
+ 8, 9, 9, /* LSP VQ */
+ 8, 9, 2, 6, /* first subframe */
+ 4, 9, 2, 6, /* second subframe */
+ 8, 9, 2, 6, /* third subframe */
+ 4, 9, 2, 6 /* fourth subframe */
+};
+static const Word16 bitno_MR67[PRMNO_MR67] = {
+ 8, 9, 9, /* LSP VQ */
+ 8, 11, 3, 7, /* first subframe */
+ 4, 11, 3, 7, /* second subframe */
+ 8, 11, 3, 7, /* third subframe */
+ 4, 11, 3, 7 /* fourth subframe */
+};
+static const Word16 bitno_MR74[PRMNO_MR74] = {
+ 8, 9, 9, /* LSP VQ */
+ 8, 13, 4, 7, /* first subframe */
+ 5, 13, 4, 7, /* second subframe */
+ 8, 13, 4, 7, /* third subframe */
+ 5, 13, 4, 7 /* fourth subframe */
+};
+static const Word16 bitno_MR795[PRMNO_MR795] = {
+ 9, 9, 9, /* LSP VQ */
+ 8, 13, 4, 4, 5, /* first subframe */
+ 6, 13, 4, 4, 5, /* second subframe */
+ 8, 13, 4, 4, 5, /* third subframe */
+ 6, 13, 4, 4, 5 /* fourth subframe */
+};
+static const Word16 bitno_MR102[PRMNO_MR102] = {
+ 8, 9, 9, /* LSP VQ */
+ 8, 1, 1, 1, 1, 10, 10, 7, 7, /* first subframe */
+ 5, 1, 1, 1, 1, 10, 10, 7, 7, /* second subframe */
+ 8, 1, 1, 1, 1, 10, 10, 7, 7, /* third subframe */
+ 5, 1, 1, 1, 1, 10, 10, 7, 7 /* fourth subframe */
+};
+static const Word16 bitno_MR122[PRMNO_MR122] = {
+ 7, 8, 9, 8, 6, /* LSP VQ */
+ 9, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 5, /* first subframe */
+ 6, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 5, /* second subframe */
+ 9, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 5, /* third subframe */
+ 6, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 5 /* fourth subframe */
+};
+static const Word16 bitno_MRDTX[PRMNO_MRDTX] = {
+ 3, 8, 9, 9, 6
+};
+
+#ifdef ENABLE_CPU2_DECODER
+CPU2_DATA_END
+#endif
+
+#endif
diff --git a/audio_codec/libamr/rom_dec.h b/audio_codec/libamr/rom_dec.h
new file mode 100644
index 0000000..787cf91
--- a/dev/null
+++ b/audio_codec/libamr/rom_dec.h
@@ -0,0 +1,13274 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * R99 V3.5.0 2003-03
+ * REL-4 V4.4.0 2003-03
+ * REL-5 V5.1.0 2003-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * rom_dec.h
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * This file contains all the tables needed by AMR decoder functions.
+ *
+ */
+
+#ifndef _ROM_DEC_H_
+#define _ROM_DEC_H_
+
+/*
+ * include files
+ */
+#include"typedef.h"
+#include"interf_rom.h"
+
+/*
+ * definition of constants
+ */
+#define M 10 /* Order of LP filter */
+#define MP1 (M+1) /* Order of LP filter + 1 */
+#define L_WINDOW 240 /* Window size in LP analysis */
+#define L_NEXT 40 /* Overhead in LP analysis */
+#define LTPG_MEM_SIZE 5 /* number of stored past LTP coding gains + 1 */
+#define N_FRAME 7 /* old pitch gains in average calculation */
+#define DTX_HIST_SIZE 8 /* DTX history size */
+#define L_TOTAL 320 /* Total size of speech buffer. */
+#define L_FRAME 160 /* Frame size */
+#define L_FRAME_BY2 80 /* Frame size divided by 2 */
+#define L_SUBFR 40 /* Subframe size */
+#define L_CODE 40 /* codevector length */
+#define PIT_MAX 143 /* Maximum pitch lag */
+#define PIT_MIN 20 /* Minimum pitch lag */
+#define PIT_MIN_MR122 18 /* Minimum pitch lag (MR122 mode) */
+#define L_INTERPOL (10+1) /* Length of filter for interpolation */
+#define NPRED 4 /* number of prediction taps */
+#define SHARPMIN 0 /* Minimum value of pitch sharpening */
+#define MAX_PRM_SIZE 57 /* max. num. of params */
+#define L_INTER_SRCH 4 /* Length of filter for CL LTP search interpolation */
+#define GP_CLIP 0.95F /* Pitch gain clipping */
+#define UP_SAMP_MAX 6
+#define NB_TRACK 5 /* number of tracks */
+#define NB_TRACK_MR102 4 /* number of tracks mode mr102 */
+#define STEP 5 /* codebook step size */
+#define STEP_MR102 4 /* codebook step size mode mr102 */
+#define NC M/2 /* Order of LP filter divided by 2 */
+
+/* vad */
+#define COMPLEN 9 /* Number of sub-bands used by VAD */
+#define L_ENERGYHIST 60
+#define L_CBGAINHIST 7
+#define PHDGAINMEMSIZE 5
+#define MIN_ENERGY -14336 /* 14 Q10 */
+#define MIN_ENERGY_MR122 -2381 /* 14 / (20*log10(2)) Q10 */
+#define PN_INITIAL_SEED 0x70816958L /* Pseudo noise generator seed value */
+#define MIN_16 (Word16)-32768
+#define MAX_16 (Word16)0x7fff
+#define MAX_32 (Word32)0x7fffffffL
+#define EXPCONST 5243 /* 0.16 in Q15 */
+#define DTX_MAX_EMPTY_THRESH 50
+#define DTX_ELAPSED_FRAMES_THRESH (24 + 7 -1)
+#define LSF_GAP 205 /* Minimum distance between LSF after quantization; 50 Hz = 205 */
+#define LSP_PRED_FAC_MR122 21299 /* MR122 LSP prediction factor (0.65 Q15) */
+#define POS_CODE 8191
+#define NEG_CODE 8191
+#define NMAX 9 /* largest N used in median calculation */
+#define MEAN_ENER_MR122 783741L /* 36/(20*log10(2)) (Q17) */
+#define SHARPMAX 13017 /* Maximum value of pitch sharpening */
+#define FRAMEENERGYLIMIT 17578 /* 150 */
+#define LOWERNOISELIMIT 20 /* 5 */
+#define UPPERNOISELIMIT 1953 /* 50 */
+#define AZ_SIZE (4*M+4) /* Size of array of LP filters in 4 subfr.s */
+#define AGC_FAC 29491 /* Factor for automatic gain control 0.9 */
+#define PHDGAINMEMSIZE 5
+#define PHDTHR1LTP 9830 /* 0.6 in Q14 */
+#define PHDTHR2LTP 14746 /* 0.9 in Q14 */
+#define ONFACTPLUS1 16384 /* 2.0 in Q13 */
+#define ONLENGTH 2
+#define DTX_HANG_CONST 7 /* yields eight frames of SP HANGOVER */
+
+/* number of parameters */
+#define PRMNO_MR475 17
+#define PRMNO_MR515 19
+#define PRMNO_MR59 19
+#define PRMNO_MR67 19
+#define PRMNO_MR74 19
+#define PRMNO_MR795 23
+#define PRMNO_MR102 39
+#define PRMNO_MR122 57
+#define PRMNO_MRDTX 5
+
+#ifdef ENABLE_CPU2_DECODER
+CPU2_DATA_START
+#endif
+
+/*
+ * tables
+ */
+
+/* level adjustment for different modes Q11 */
+static const Word16 dtx_log_en_adjust[9] = {
+ - 1023,
+ /* MR475 */ - 878,
+ /* MR515 */ - 732,
+ /* MR59 */ - 586,
+ /* MR67 */ - 440,
+ /* MR74 */ - 294,
+ /* MR795 */ - 148,
+ /* MR102 */ 0,
+ /* MR122 */ 0,
+ /* MRDTX */
+};
+
+/* attenuation factors for codebook gain */
+static const Word32 cdown[7] = {
+ 32767,
+ 32112,
+ 32112,
+ 32112,
+ 32112,
+ 32112,
+ 22937
+};
+
+/* attenuation factors for adaptive codebook gain */
+static const Word32 pdown[7] = {
+ 32767,
+ 32112,
+ 32112,
+ 26214,
+ 9830,
+ 6553,
+ 6553
+};
+
+/* algebraic code book gain MA predictor coefficients */
+static const Word32 pred[NPRED] = {
+ 5571,
+ 4751,
+ 2785,
+ 1556
+};
+
+/* algebraic code book gain MA predictor coefficients (MR122) */
+static const Word32 pred_MR122[NPRED] = {
+ 44,
+ 37,
+ 22,
+ 12
+};
+
+static const Word32 gamma4_gamma3_MR122[M] = {
+ 22938,
+ 16057,
+ 11240,
+ 7868,
+ 5508,
+ 3856,
+ 2699,
+ 1889,
+ 1322,
+ 925
+};
+static const Word32 gamma3[M] = {
+ 18022,
+ 9912,
+ 5451,
+ 2998,
+ 1649,
+ 907,
+ 499,
+ 274,
+ 151,
+ 83
+};
+static const Word32 gamma4_MR122[M] = {
+ 24576,
+ 18432,
+ 13824,
+ 10368,
+ 7776,
+ 5832,
+ 4374,
+ 3281,
+ 2461,
+ 1846
+};
+
+
+/* adaptive codebook gain quantization table (MR122, MR795) */
+#define NB_QUA_PITCH 16
+static const Word32 qua_gain_pitch[NB_QUA_PITCH] = {
+ 0,
+ 3277,
+ 6556,
+ 8192,
+ 9830,
+ 11469,
+ 12288,
+ 13107,
+ 13926,
+ 14746,
+ 15565,
+ 16384,
+ 17203,
+ 18022,
+ 18842,
+ 19661
+};
+
+/* fixed codebook gain quantization table (MR122, MR795) */
+#define NB_QUA_CODE 32
+static const Word32 qua_gain_code[NB_QUA_CODE * 3] = {
+ /* gain factor (g_fac) and quantized energy error (qua_ener_MR122, qua_ener)
+ * are stored:
+ *
+ * qua_ener_MR122 = log2(g_fac) (not the rounded floating point value, but
+ * the value the original EFR algorithm
+ * calculates from g_fac [using Log2])
+ * qua_ener = 20*log10(g_fac); (rounded floating point value)
+ *
+ *
+ * g_fac (Q11),
+ * qua_ener_MR122 (Q10),
+ * qua_ener (Q10)
+ */ 159,
+ - 3776,
+ - 22731,
+ 206,
+ - 3394,
+ - 20428,
+ 268,
+ - 3005,
+ - 18088,
+ 349,
+ - 2615,
+ - 15739,
+ 419,
+ - 2345,
+ - 14113,
+ 482,
+ - 2138,
+ - 12867,
+ 554,
+ - 1932,
+ - 11629,
+ 637,
+ - 1726,
+ - 10387,
+ 733,
+ - 1518,
+ - 9139,
+ 842,
+ - 1314,
+ - 7906,
+ 969,
+ - 1106,
+ - 6656,
+ 1114,
+ - 900,
+ - 5416,
+ 1281,
+ - 694,
+ - 4173,
+ 1473,
+ - 487,
+ - 2931,
+ 1694,
+ - 281,
+ - 1688,
+ 1948,
+ - 75,
+ - 445,
+ 2241,
+ 133,
+ 801,
+ 2577,
+ 339,
+ 2044,
+ 2963,
+ 545,
+ 3285,
+ 3408,
+ 752,
+ 4530,
+ 3919,
+ 958,
+ 5772,
+ 4507,
+ 1165,
+ 7016,
+ 5183,
+ 1371,
+ 8259,
+ 5960,
+ 1577,
+ 9501,
+ 6855,
+ 1784,
+ 10745,
+ 7883,
+ 1991,
+ 11988,
+ 9065,
+ 2197,
+ 13231,
+ 10425,
+ 2404,
+ 14474,
+ 12510,
+ 2673,
+ 16096,
+ 16263,
+ 3060,
+ 18429,
+ 21142,
+ 3448,
+ 20763,
+ 27485,
+ 3836,
+ 23097
+};
+
+/* gray coding table */
+static const Word8 gray[8] = {
+ 0,
+ 1,
+ 3,
+ 2,
+ 6,
+ 4,
+ 5,
+ 7
+};
+
+/* gray decoding table */
+static const Word32 dgray[8] = {
+ 0,
+ 1,
+ 3,
+ 2,
+ 5,
+ 6,
+ 4,
+ 7
+};
+
+/* table[i] = sqrt((i+16)*2^-6) * 2^15, i.e. sqrt(x) scaled Q15 */
+static const Word32 sqrt_table[49] = {
+ 16384,
+ 16888,
+ 17378,
+ 17854,
+ 18318,
+ 18770,
+ 19212,
+ 19644,
+ 20066,
+ 20480,
+ 20886,
+ 21283,
+ 21674,
+ 22058,
+ 22435,
+ 22806,
+ 23170,
+ 23530,
+ 23884,
+ 24232,
+ 24576,
+ 24915,
+ 25249,
+ 25580,
+ 25905,
+ 26227,
+ 26545,
+ 26859,
+ 27170,
+ 27477,
+ 27780,
+ 28081,
+ 28378,
+ 28672,
+ 28963,
+ 29251,
+ 29537,
+ 29819,
+ 30099,
+ 30377,
+ 30652,
+ 30924,
+ 31194,
+ 31462,
+ 31727,
+ 31991,
+ 32252,
+ 32511,
+ 32767
+};
+
+static const Word32 inv_sqrt_table[49] = {
+ 32767,
+ 31790,
+ 30894,
+ 30070,
+ 29309,
+ 28602,
+ 27945,
+ 27330,
+ 26755,
+ 26214,
+ 25705,
+ 25225,
+ 24770,
+ 24339,
+ 23930,
+ 23541,
+ 23170,
+ 22817,
+ 22479,
+ 22155,
+ 21845,
+ 21548,
+ 21263,
+ 20988,
+ 20724,
+ 20470,
+ 20225,
+ 19988,
+ 19760,
+ 19539,
+ 19326,
+ 19119,
+ 18919,
+ 18725,
+ 18536,
+ 18354,
+ 18176,
+ 18004,
+ 17837,
+ 17674,
+ 17515,
+ 17361,
+ 17211,
+ 17064,
+ 16921,
+ 16782,
+ 16646,
+ 16514,
+ 16384
+};
+/* table used inbase 2 logharithm computation */
+static const Word32 log2_table[33] = {
+ 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
+};
+
+/* table used in 2 to the power computation */
+static const Word32 pow2_table[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
+};
+
+/* table of cos(x) */
+static const Word32 cos_table[65] = {
+ 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,
+ - 32768
+};
+
+/* slope used to compute y = acos(x) */
+static const Word32 acos_slope[64] = {
+ - 26887,
+ - 8812,
+ - 5323,
+ - 3813,
+ - 2979,
+ - 2444,
+ - 2081,
+ - 1811,
+ - 1608,
+ - 1450,
+ - 1322,
+ - 1219,
+ - 1132,
+ - 1059,
+ - 998,
+ - 946,
+ - 901,
+ - 861,
+ - 827,
+ - 797,
+ - 772,
+ - 750,
+ - 730,
+ - 713,
+ - 699,
+ - 687,
+ - 677,
+ - 668,
+ - 662,
+ - 657,
+ - 654,
+ - 652,
+ - 652,
+ - 654,
+ - 657,
+ - 662,
+ - 668,
+ - 677,
+ - 687,
+ - 699,
+ - 713,
+ - 730,
+ - 750,
+ - 772,
+ - 797,
+ - 827,
+ - 861,
+ - 901,
+ - 946,
+ - 998,
+ - 1059,
+ - 1132,
+ - 1219,
+ - 1322,
+ - 1450,
+ - 1608,
+ - 1811,
+ - 2081,
+ - 2444,
+ - 2979,
+ - 3813,
+ - 5323,
+ - 8812,
+ - 26887
+};
+
+/* All impulse responses are in Q15 */
+/* phase dispersion impulse response (MR795) */
+static const Word32 ph_imp_low_MR795[] = {
+ 26777,
+ 801,
+ 2505,
+ - 683,
+ - 1382,
+ 582,
+ 604,
+ - 1274,
+ 3511,
+ - 5894,
+ 4534,
+ - 499,
+ - 1940,
+ 3011,
+ - 5058,
+ 5614,
+ - 1990,
+ - 1061,
+ - 1459,
+ 4442,
+ - 700,
+ - 5335,
+ 4609,
+ 452,
+ - 589,
+ - 3352,
+ 2953,
+ 1267,
+ - 1212,
+ - 2590,
+ 1731,
+ 3670,
+ - 4475,
+ - 975,
+ 4391,
+ - 2537,
+ 949,
+ - 1363,
+ - 979,
+ 5734
+};
+/* phase dispersion impulse response (MR795) */
+static const Word32 ph_imp_mid_MR795[] = {
+ 30274,
+ 3831,
+ - 4036,
+ 2972,
+ - 1048,
+ - 1002,
+ 2477,
+ - 3043,
+ 2815,
+ - 2231,
+ 1753,
+ - 1611,
+ 1714,
+ - 1775,
+ 1543,
+ - 1008,
+ 429,
+ - 169,
+ 472,
+ - 1264,
+ 2176,
+ - 2706,
+ 2523,
+ - 1621,
+ 344,
+ 826,
+ - 1529,
+ 1724,
+ - 1657,
+ 1701,
+ - 2063,
+ 2644,
+ - 3060,
+ 2897,
+ - 1978,
+ 557,
+ 780,
+ - 1369,
+ 842,
+ 655
+};
+
+/* phase dispersion impulse response (MR475 - MR67) */
+static const Word32 ph_imp_low[] = {
+ 14690,
+ 11518,
+ 1268,
+ - 2761,
+ - 5671,
+ 7514,
+ - 35,
+ - 2807,
+ - 3040,
+ 4823,
+ 2952,
+ - 8424,
+ 3785,
+ 1455,
+ 2179,
+ - 8637,
+ 8051,
+ - 2103,
+ - 1454,
+ 777,
+ 1108,
+ - 2385,
+ 2254,
+ - 363,
+ - 674,
+ - 2103,
+ 6046,
+ - 5681,
+ 1072,
+ 3123,
+ - 5058,
+ 5312,
+ - 2329,
+ - 3728,
+ 6924,
+ - 3889,
+ 675,
+ - 1775,
+ 29,
+ 10145
+};
+
+/* phase dispersion impulse response (MR475 - MR67) */
+static const Word32 ph_imp_mid[] = {
+ 30274,
+ 3831,
+ - 4036,
+ 2972,
+ - 1048,
+ - 1002,
+ 2477,
+ - 3043,
+ 2815,
+ - 2231,
+ 1753,
+ - 1611,
+ 1714,
+ - 1775,
+ 1543,
+ - 1008,
+ 429,
+ - 169,
+ 472,
+ - 1264,
+ 2176,
+ - 2706,
+ 2523,
+ - 1621,
+ 344,
+ 826,
+ - 1529,
+ 1724,
+ - 1657,
+ 1701,
+ - 2063,
+ 2644,
+ - 3060,
+ 2897,
+ - 1978,
+ 557,
+ 780,
+ - 1369,
+ 842,
+ 655
+};
+
+/* initialization table for the MA predictor in DTX */
+#define PAST_RQ_INIT_SIZE 8
+
+/* initalization table for MA predictor in dtx mode */
+static const Word32 past_rq_init[80] = {
+ - 258,
+ - 318,
+ - 439,
+ - 634,
+ - 656,
+ - 773,
+ - 711,
+ - 502,
+ - 268,
+ - 193,
+ - 2,
+ 125,
+ 122,
+ - 39,
+ - 9,
+ 105,
+ 129,
+ 283,
+ 372,
+ 575,
+ - 277,
+ - 324,
+ - 197,
+ - 487,
+ - 445,
+ - 362,
+ - 292,
+ - 27,
+ 177,
+ 543,
+ 342,
+ 517,
+ 516,
+ 130,
+ 27,
+ - 104,
+ - 120,
+ - 140,
+ - 74,
+ - 56,
+ - 564,
+ - 943,
+ - 1520,
+ - 965,
+ - 814,
+ - 526,
+ - 322,
+ - 2,
+ 159,
+ 657,
+ - 312,
+ - 284,
+ - 386,
+ - 597,
+ - 493,
+ - 526,
+ - 418,
+ - 229,
+ 105,
+ 449,
+ - 557,
+ - 870,
+ - 1075,
+ - 919,
+ - 950,
+ - 752,
+ - 709,
+ - 316,
+ 62,
+ 486,
+ - 314,
+ - 191,
+ - 203,
+ - 330,
+ - 160,
+ - 103,
+ - 51,
+ 131,
+ 338,
+ 515
+};
+
+#define ALPHA 29491
+#define ONE_ALPHA 3277
+/* LSF means (not in MR122) */
+static const Word32 mean_lsf_3[10] = {
+ 1546,
+ 2272,
+ 3778,
+ 5488,
+ 6972,
+ 8382,
+ 10047,
+ 11229,
+ 12766,
+ 13714
+};
+
+#define ALPHA_122 31128
+#define ONE_ALPHA_122 1639
+/* LSF means ->normalize frequency domain */
+static const Word32 mean_lsf_5[10] = {
+ 1384,
+ 2077,
+ 3420,
+ 5108,
+ 6742,
+ 8122,
+ 9863,
+ 11092,
+ 12714,
+ 13701
+};
+
+/* LSF prediction factors (not in MR122) */
+static const Word32 pred_fac[10] = {
+ 9556,
+ 10769,
+ 12571,
+ 13292,
+ 14381,
+ 11651,
+ 10588,
+ 9767,
+ 8593,
+ 6484
+};
+#define DICO1_SIZE_3 256
+#define DICO2_SIZE_3 512
+#define DICO3_SIZE_3 512
+
+/* 1st LSF quantizer (not in MR122 and MR795) */
+static const Word32 dico1_lsf_3[] = {
+ 6,
+ 82,
+ - 131,
+ 154,
+ - 56,
+ - 735,
+ 183,
+ - 65,
+ - 265,
+ 9,
+ - 210,
+ - 361,
+ 113,
+ 718,
+ 1817,
+ 1010,
+ 1214,
+ 1573,
+ 857,
+ 1333,
+ 2276,
+ 827,
+ 1568,
+ 1933,
+ 717,
+ 1989,
+ 2206,
+ 838,
+ 1172,
+ 1823,
+ 721,
+ 1000,
+ 2154,
+ 286,
+ 476,
+ 1509,
+ - 247,
+ - 531,
+ 230,
+ 147,
+ - 82,
+ 569,
+ 26,
+ - 177,
+ - 944,
+ - 27,
+ - 273,
+ 692,
+ - 164,
+ - 264,
+ - 183,
+ 224,
+ 790,
+ 1039,
+ 899,
+ 946,
+ 601,
+ 485,
+ 771,
+ 1150,
+ 524,
+ 677,
+ 903,
+ - 140,
+ 375,
+ 778,
+ 410,
+ 676,
+ 429,
+ 301,
+ 530,
+ 1009,
+ 719,
+ 646,
+ 38,
+ 226,
+ 367,
+ 40,
+ 145,
+ - 45,
+ - 505,
+ 290,
+ 121,
+ - 121,
+ 302,
+ 127,
+ 166,
+ - 124,
+ - 383,
+ - 956,
+ - 358,
+ - 455,
+ - 977,
+ 715,
+ 878,
+ 894,
+ 978,
+ 923,
+ 211,
+ 477,
+ 272,
+ 64,
+ 188,
+ - 78,
+ 17,
+ - 143,
+ - 65,
+ 38,
+ 643,
+ 586,
+ 621,
+ - 134,
+ - 426,
+ - 651,
+ 347,
+ 545,
+ 2820,
+ 1188,
+ 2726,
+ 2442,
+ 142,
+ - 80,
+ 1735,
+ 283,
+ 130,
+ 461,
+ - 262,
+ - 399,
+ - 1145,
+ - 411,
+ 155,
+ 430,
+ 329,
+ 375,
+ 779,
+ 53,
+ - 226,
+ - 139,
+ - 129,
+ - 236,
+ 1682,
+ 285,
+ 744,
+ 1327,
+ 738,
+ 697,
+ 1664,
+ 312,
+ 409,
+ 266,
+ 325,
+ 720,
+ 135,
+ 1,
+ 221,
+ 453,
+ 8,
+ 203,
+ 145,
+ 299,
+ 640,
+ 760,
+ 29,
+ 468,
+ 638,
+ 103,
+ 429,
+ 379,
+ 420,
+ 954,
+ 932,
+ 1326,
+ 1210,
+ 1258,
+ 704,
+ 1012,
+ 1152,
+ - 166,
+ - 444,
+ - 266,
+ - 316,
+ - 130,
+ - 376,
+ 191,
+ 1151,
+ 1904,
+ - 240,
+ - 543,
+ - 1260,
+ - 112,
+ 268,
+ 1207,
+ 70,
+ 1062,
+ 1583,
+ 278,
+ 1360,
+ 1574,
+ - 258,
+ - 272,
+ - 768,
+ 19,
+ 563,
+ 2240,
+ - 3,
+ - 265,
+ 135,
+ - 295,
+ - 591,
+ - 388,
+ 140,
+ 354,
+ - 206,
+ - 260,
+ - 504,
+ - 795,
+ - 433,
+ - 718,
+ - 1319,
+ 109,
+ 331,
+ 962,
+ - 429,
+ - 87,
+ 652,
+ - 296,
+ 426,
+ 1019,
+ - 239,
+ 775,
+ 851,
+ 489,
+ 1334,
+ 1073,
+ - 334,
+ - 332,
+ 25,
+ 543,
+ 1206,
+ 1807,
+ 326,
+ 61,
+ 727,
+ 578,
+ 849,
+ 1405,
+ - 208,
+ - 277,
+ 329,
+ - 152,
+ 64,
+ 669,
+ - 434,
+ - 678,
+ - 727,
+ - 454,
+ - 71,
+ 251,
+ 605,
+ 480,
+ 254,
+ - 482,
+ 11,
+ 996,
+ - 289,
+ 395,
+ 486,
+ 722,
+ 1049,
+ 1440,
+ - 30,
+ - 316,
+ - 786,
+ - 106,
+ - 115,
+ - 619,
+ 861,
+ 1474,
+ 1412,
+ 1055,
+ 1366,
+ 1184,
+ 812,
+ 1237,
+ 925,
+ 42,
+ - 251,
+ - 576,
+ 342,
+ 141,
+ - 454,
+ - 168,
+ - 80,
+ 1359,
+ - 342,
+ - 656,
+ - 1763,
+ 100,
+ 821,
+ 725,
+ 990,
+ 747,
+ 800,
+ 332,
+ 440,
+ 568,
+ 663,
+ 379,
+ 852,
+ 112,
+ 165,
+ - 369,
+ 597,
+ 910,
+ 282,
+ - 8,
+ 834,
+ 1281,
+ - 352,
+ 572,
+ 695,
+ 462,
+ 2246,
+ 1806,
+ 345,
+ 190,
+ 1374,
+ 416,
+ 915,
+ 2166,
+ 168,
+ - 82,
+ 280,
+ - 516,
+ - 446,
+ 840,
+ 47,
+ 533,
+ 44,
+ - 362,
+ - 711,
+ - 1143,
+ 22,
+ 193,
+ 1472,
+ - 85,
+ 233,
+ 1813,
+ - 62,
+ 579,
+ 1504,
+ 550,
+ 944,
+ 1749,
+ 723,
+ 650,
+ 1148,
+ 972,
+ 884,
+ 1395,
+ - 425,
+ 643,
+ 0,
+ 1000,
+ 952,
+ 1098,
+ 249,
+ 1446,
+ 672,
+ - 334,
+ - 87,
+ 2172,
+ - 554,
+ 1882,
+ 2672,
+ 140,
+ 1826,
+ 1853,
+ 920,
+ 1749,
+ 2590,
+ 1076,
+ 1933,
+ 2038,
+ - 137,
+ - 443,
+ - 1555,
+ 1269,
+ 1174,
+ 468,
+ - 493,
+ - 122,
+ 1521,
+ - 451,
+ 1033,
+ 1214,
+ 482,
+ 1695,
+ 1118,
+ 815,
+ 649,
+ 384,
+ - 446,
+ - 692,
+ 107,
+ - 319,
+ - 605,
+ - 118,
+ - 207,
+ - 505,
+ 525,
+ - 468,
+ - 12,
+ 2736,
+ 75,
+ 1934,
+ 1305,
+ 880,
+ 2358,
+ 2267,
+ 1285,
+ 1575,
+ 2004,
+ - 48,
+ - 304,
+ - 1186,
+ - 435,
+ - 461,
+ - 251,
+ - 366,
+ - 404,
+ - 547,
+ - 289,
+ - 605,
+ - 597,
+ - 538,
+ - 810,
+ - 165,
+ - 120,
+ 3,
+ 356,
+ 639,
+ 1241,
+ 1502,
+ 96,
+ 177,
+ 750,
+ - 435,
+ - 585,
+ - 1174,
+ - 356,
+ 109,
+ - 79,
+ - 485,
+ 288,
+ 2005,
+ 9,
+ 1116,
+ 731,
+ 880,
+ 2134,
+ 946,
+ - 265,
+ 1585,
+ 1065,
+ 1157,
+ 1210,
+ 843,
+ - 498,
+ - 668,
+ 431,
+ 374,
+ 321,
+ - 229,
+ 1440,
+ 2101,
+ 1381,
+ 449,
+ 461,
+ 1155,
+ - 105,
+ 39,
+ - 384,
+ - 263,
+ 367,
+ 182,
+ - 371,
+ - 660,
+ 773,
+ - 188,
+ 1151,
+ 971,
+ 1333,
+ 1632,
+ 1435,
+ 774,
+ 1267,
+ 1221,
+ - 482,
+ - 832,
+ - 1489,
+ - 237,
+ - 210,
+ 860,
+ 890,
+ 1615,
+ 1064,
+ 472,
+ 1062,
+ 1192,
+ 185,
+ 1077,
+ 989,
+ - 568,
+ - 992,
+ - 1704,
+ - 449,
+ - 902,
+ - 2043,
+ - 142,
+ - 377,
+ - 458,
+ - 210,
+ - 554,
+ - 1029,
+ - 11,
+ 1133,
+ 2265,
+ - 329,
+ - 675,
+ - 893,
+ - 250,
+ 657,
+ 1187,
+ 519,
+ 1510,
+ 1779,
+ 520,
+ 539,
+ 1403,
+ 527,
+ 1421,
+ 1302,
+ - 563,
+ - 871,
+ - 1248,
+ - 147,
+ - 463,
+ 879,
+ - 76,
+ 2334,
+ 2840,
+ 563,
+ 2573,
+ 2385,
+ 632,
+ 1926,
+ 2920,
+ 719,
+ 2023,
+ 1840,
+ - 545,
+ - 723,
+ 1108,
+ 129,
+ - 125,
+ 884,
+ 1417,
+ 1632,
+ 925,
+ - 94,
+ 1566,
+ 1751,
+ - 341,
+ 1533,
+ 1551,
+ 591,
+ 395,
+ - 274,
+ - 76,
+ 981,
+ 2831,
+ 153,
+ 2985,
+ 1844,
+ 1032,
+ 2565,
+ 2749,
+ 1508,
+ 2832,
+ 1879,
+ 791,
+ 1199,
+ 538,
+ - 190,
+ - 453,
+ 1489,
+ - 278,
+ - 548,
+ 1158,
+ - 245,
+ 1941,
+ 2044,
+ 1024,
+ 1560,
+ 1650,
+ 512,
+ 253,
+ 466,
+ - 62,
+ - 323,
+ 1151,
+ - 473,
+ - 376,
+ 507,
+ - 433,
+ 1380,
+ 2162,
+ 899,
+ 1943,
+ 1445,
+ 134,
+ 704,
+ 440,
+ 460,
+ 525,
+ - 28,
+ - 450,
+ 279,
+ 1338,
+ 0,
+ 971,
+ 252,
+ - 445,
+ - 627,
+ - 991,
+ - 348,
+ - 602,
+ - 1424,
+ 398,
+ 712,
+ 1656,
+ - 107,
+ 314,
+ - 178,
+ 93,
+ 2226,
+ 2238,
+ 518,
+ 849,
+ 656,
+ - 462,
+ - 711,
+ - 447,
+ 174,
+ - 34,
+ 1191,
+ - 119,
+ 42,
+ 1005,
+ - 372,
+ 274,
+ 758,
+ 1036,
+ 2352,
+ 1838,
+ 675,
+ 1724,
+ 1498,
+ 430,
+ 1286,
+ 2133,
+ - 129,
+ - 439,
+ 0,
+ - 373,
+ 800,
+ 2144,
+ 6,
+ 1587,
+ 2478,
+ 478,
+ 596,
+ 2128,
+ - 428,
+ - 736,
+ 1505,
+ 385,
+ 178,
+ 980,
+ 139,
+ 449,
+ 1225,
+ - 526,
+ - 842,
+ - 982,
+ 145,
+ 1554,
+ 1242,
+ 623,
+ 1448,
+ 656,
+ 349,
+ 1016,
+ 1482,
+ 31,
+ - 280,
+ 415,
+ - 316,
+ 724,
+ 1641,
+ 360,
+ 1058,
+ 556,
+ - 436,
+ - 358,
+ 1201,
+ - 355,
+ 1123,
+ 1939,
+ 401,
+ 1584,
+ 2248,
+ - 527,
+ - 1012,
+ 355,
+ 233,
+ 238,
+ 2233,
+ - 550,
+ - 897,
+ - 639,
+ - 365,
+ - 501,
+ 1957,
+ 389,
+ 1860,
+ 1621,
+ 162,
+ 1132,
+ 1264,
+ - 237,
+ 1174,
+ 1390,
+ - 640,
+ - 411,
+ 116,
+ - 228,
+ 1694,
+ 2298,
+ 1639,
+ 2186,
+ 2267,
+ 562,
+ 1273,
+ 2658,
+ 323,
+ 338,
+ 1774,
+ 578,
+ 1107,
+ 852,
+ 22,
+ 594,
+ 934,
+ - 143,
+ 718,
+ 446
+};
+
+/* 2nd LSF quantizer (not in MR122) */
+static const Word32 dico2_lsf_3[] = {
+ 50,
+ 71,
+ - 9,
+ - 338,
+ - 698,
+ - 1407,
+ 102,
+ - 138,
+ - 820,
+ - 310,
+ - 469,
+ - 1147,
+ 414,
+ 67,
+ - 267,
+ 1060,
+ 814,
+ 1441,
+ 1548,
+ 1360,
+ 1272,
+ 1754,
+ 1895,
+ 1661,
+ 2019,
+ 2133,
+ 1820,
+ 1808,
+ 2318,
+ 1845,
+ 644,
+ - 93,
+ 454,
+ 858,
+ 329,
+ - 136,
+ 489,
+ - 258,
+ - 128,
+ - 198,
+ - 745,
+ - 41,
+ - 52,
+ - 265,
+ - 985,
+ 346,
+ 137,
+ 479,
+ - 1741,
+ - 748,
+ - 684,
+ - 1163,
+ - 1725,
+ - 367,
+ - 895,
+ - 1145,
+ - 784,
+ - 488,
+ - 946,
+ - 968,
+ - 85,
+ - 390,
+ - 725,
+ 215,
+ - 340,
+ - 171,
+ 1020,
+ 916,
+ 1969,
+ 564,
+ 179,
+ 746,
+ 662,
+ 977,
+ 1734,
+ 887,
+ 622,
+ 914,
+ 939,
+ 856,
+ 1165,
+ 309,
+ 688,
+ 803,
+ 917,
+ 161,
+ 570,
+ 118,
+ - 20,
+ - 283,
+ - 816,
+ - 42,
+ 204,
+ - 1228,
+ - 325,
+ - 462,
+ - 963,
+ - 202,
+ - 143,
+ - 988,
+ - 484,
+ - 361,
+ - 702,
+ - 978,
+ - 477,
+ - 302,
+ - 790,
+ - 1188,
+ - 100,
+ - 786,
+ - 1088,
+ - 1054,
+ - 947,
+ - 1684,
+ - 202,
+ - 843,
+ - 782,
+ - 1039,
+ - 1378,
+ - 901,
+ - 624,
+ - 110,
+ - 85,
+ 356,
+ 213,
+ - 10,
+ - 493,
+ 364,
+ 774,
+ 425,
+ 822,
+ 479,
+ - 83,
+ 557,
+ 520,
+ - 992,
+ - 1560,
+ - 572,
+ - 603,
+ - 741,
+ - 26,
+ - 502,
+ - 638,
+ - 903,
+ 209,
+ 306,
+ 147,
+ - 316,
+ - 593,
+ - 596,
+ - 85,
+ - 211,
+ - 225,
+ - 918,
+ - 529,
+ 117,
+ 233,
+ - 439,
+ - 738,
+ 1101,
+ 751,
+ 633,
+ 1457,
+ 1716,
+ 1511,
+ 1765,
+ 1457,
+ 910,
+ 1122,
+ 1156,
+ 849,
+ 1354,
+ 868,
+ 470,
+ - 871,
+ - 1150,
+ - 1796,
+ - 871,
+ - 861,
+ - 992,
+ - 118,
+ 155,
+ 212,
+ - 1051,
+ - 849,
+ - 606,
+ - 1117,
+ - 1849,
+ - 2750,
+ - 1019,
+ - 1427,
+ - 1869,
+ 370,
+ - 184,
+ - 414,
+ 959,
+ 493,
+ 104,
+ 958,
+ 1039,
+ 543,
+ 154,
+ 653,
+ 201,
+ 1249,
+ 507,
+ 150,
+ 663,
+ 503,
+ 230,
+ 623,
+ 777,
+ 675,
+ 659,
+ 88,
+ - 110,
+ 843,
+ 244,
+ 224,
+ 382,
+ 541,
+ 302,
+ 724,
+ 433,
+ 666,
+ 1166,
+ 734,
+ 341,
+ - 138,
+ 20,
+ - 397,
+ - 1183,
+ - 424,
+ - 46,
+ - 321,
+ - 352,
+ - 124,
+ 1333,
+ 1021,
+ 1080,
+ 262,
+ 366,
+ 723,
+ 922,
+ 283,
+ - 551,
+ 31,
+ - 636,
+ - 611,
+ - 689,
+ - 697,
+ - 415,
+ - 952,
+ - 779,
+ - 201,
+ - 1329,
+ - 598,
+ - 359,
+ - 953,
+ - 1285,
+ 166,
+ 493,
+ 305,
+ 221,
+ 846,
+ 703,
+ 610,
+ 840,
+ 936,
+ 774,
+ - 723,
+ - 1324,
+ - 1261,
+ - 357,
+ - 1025,
+ - 1388,
+ - 1096,
+ - 1376,
+ - 365,
+ - 1416,
+ - 1881,
+ - 608,
+ - 1798,
+ - 1727,
+ - 674,
+ - 545,
+ - 1173,
+ - 703,
+ 678,
+ 786,
+ 148,
+ - 123,
+ 696,
+ 1288,
+ 644,
+ 350,
+ - 10,
+ 414,
+ 614,
+ 15,
+ 137,
+ 344,
+ - 211,
+ - 814,
+ - 1512,
+ - 819,
+ - 391,
+ - 930,
+ - 588,
+ 47,
+ - 591,
+ - 898,
+ - 909,
+ - 1097,
+ - 163,
+ - 1272,
+ - 1167,
+ - 157,
+ - 1464,
+ - 1525,
+ - 389,
+ - 1274,
+ - 1188,
+ - 624,
+ 671,
+ 213,
+ 454,
+ 124,
+ - 274,
+ - 525,
+ - 729,
+ - 496,
+ - 152,
+ - 1344,
+ 122,
+ 135,
+ - 2905,
+ - 589,
+ - 394,
+ - 1728,
+ 441,
+ - 50,
+ 1476,
+ 904,
+ 787,
+ 316,
+ 236,
+ - 440,
+ - 347,
+ 217,
+ 413,
+ - 911,
+ - 917,
+ 121,
+ - 455,
+ - 932,
+ 202,
+ - 92,
+ - 465,
+ - 375,
+ 488,
+ 390,
+ 474,
+ 876,
+ 729,
+ 316,
+ - 1815,
+ - 1312,
+ - 669,
+ 87,
+ 962,
+ 432,
+ 563,
+ - 249,
+ - 1058,
+ 250,
+ 285,
+ 1105,
+ 1141,
+ 427,
+ 696,
+ - 1038,
+ - 1664,
+ - 1582,
+ - 948,
+ 346,
+ 160,
+ - 309,
+ - 272,
+ - 858,
+ 670,
+ 624,
+ 1250,
+ - 944,
+ - 408,
+ - 666,
+ - 606,
+ - 320,
+ - 384,
+ - 492,
+ 230,
+ 65,
+ 334,
+ - 50,
+ - 16,
+ - 16,
+ - 690,
+ - 1397,
+ 1791,
+ 1716,
+ 1399,
+ 2478,
+ 2063,
+ 1404,
+ 1245,
+ 1471,
+ 1426,
+ - 382,
+ - 1037,
+ - 2,
+ 173,
+ - 398,
+ 1145,
+ 1491,
+ 2024,
+ 1801,
+ 772,
+ 1274,
+ 1506,
+ 1429,
+ 1735,
+ 2001,
+ 1079,
+ 1218,
+ 1273,
+ - 1154,
+ - 1851,
+ - 1329,
+ - 808,
+ - 1133,
+ - 1096,
+ - 451,
+ - 1033,
+ - 1722,
+ 65,
+ 578,
+ - 84,
+ - 1476,
+ - 2434,
+ - 1778,
+ - 765,
+ - 1366,
+ - 494,
+ - 218,
+ - 594,
+ - 931,
+ 337,
+ - 236,
+ 562,
+ 2357,
+ 2662,
+ 1938,
+ 1489,
+ 1276,
+ 874,
+ 189,
+ 358,
+ 374,
+ - 1519,
+ - 2281,
+ - 2346,
+ - 967,
+ - 1271,
+ - 2095,
+ - 628,
+ - 1188,
+ - 1542,
+ 1661,
+ 1043,
+ 546,
+ 565,
+ 1061,
+ 732,
+ - 64,
+ - 836,
+ - 434,
+ - 436,
+ - 96,
+ 203,
+ 1078,
+ 1216,
+ 1636,
+ 907,
+ 1534,
+ 986,
+ 326,
+ 965,
+ 845,
+ 142,
+ - 84,
+ 197,
+ 470,
+ 2379,
+ 1570,
+ 1133,
+ 470,
+ 1214,
+ 395,
+ 1376,
+ 1200,
+ 1125,
+ 1042,
+ 348,
+ - 543,
+ - 1234,
+ - 376,
+ - 215,
+ - 181,
+ 481,
+ - 1947,
+ - 1621,
+ - 210,
+ - 750,
+ - 1185,
+ 390,
+ 29,
+ - 399,
+ 27,
+ 820,
+ 1236,
+ 755,
+ 695,
+ 979,
+ 409,
+ - 174,
+ 1197,
+ 1035,
+ 912,
+ 1356,
+ 1846,
+ - 992,
+ - 1437,
+ 484,
+ - 1485,
+ - 1700,
+ 208,
+ - 412,
+ 1204,
+ 1432,
+ - 271,
+ 896,
+ 1144,
+ - 416,
+ 1777,
+ 1434,
+ - 1696,
+ - 2644,
+ - 204,
+ - 1789,
+ - 1551,
+ 1033,
+ - 1656,
+ - 1559,
+ 1303,
+ - 1253,
+ - 1589,
+ 1081,
+ - 669,
+ - 1095,
+ - 66,
+ - 682,
+ 320,
+ - 345,
+ 659,
+ 305,
+ 1069,
+ - 1292,
+ - 804,
+ - 19,
+ - 1635,
+ - 1291,
+ 29,
+ - 1683,
+ - 497,
+ 71,
+ - 287,
+ - 7,
+ - 100,
+ - 494,
+ - 962,
+ - 237,
+ 852,
+ 1881,
+ 1740,
+ - 1217,
+ - 1387,
+ 227,
+ - 660,
+ 302,
+ 373,
+ 96,
+ 1087,
+ 1257,
+ - 1074,
+ - 1669,
+ 160,
+ 485,
+ 2076,
+ 1798,
+ - 934,
+ - 220,
+ 552,
+ - 596,
+ - 612,
+ 237,
+ 336,
+ 1720,
+ 879,
+ 643,
+ 629,
+ 434,
+ 1267,
+ 522,
+ 1633,
+ 15,
+ 244,
+ - 441,
+ 1475,
+ 717,
+ 184,
+ 1819,
+ 1590,
+ 1709,
+ 988,
+ 261,
+ 937,
+ 2093,
+ 2345,
+ 1520,
+ 2139,
+ 1858,
+ 1606,
+ - 577,
+ - 579,
+ - 1203,
+ - 956,
+ 135,
+ - 488,
+ - 464,
+ 51,
+ - 338,
+ - 629,
+ - 348,
+ - 723,
+ 1146,
+ 2073,
+ 1442,
+ 2192,
+ 1466,
+ 911,
+ - 1444,
+ - 1572,
+ - 2278,
+ 1400,
+ 710,
+ 1297,
+ 1335,
+ 633,
+ 928,
+ 1434,
+ 2194,
+ 2594,
+ 2422,
+ 2204,
+ 1881,
+ 982,
+ 2242,
+ 1854,
+ 380,
+ 792,
+ 1145,
+ - 63,
+ - 539,
+ 414,
+ - 252,
+ - 964,
+ - 314,
+ - 1261,
+ - 683,
+ - 780,
+ - 831,
+ - 526,
+ - 1005,
+ - 1666,
+ - 1135,
+ - 424,
+ - 1611,
+ - 452,
+ - 299,
+ 1268,
+ 1048,
+ 642,
+ 1147,
+ 853,
+ 856,
+ - 675,
+ - 336,
+ 139,
+ 2268,
+ 1343,
+ 1418,
+ 29,
+ 768,
+ 797,
+ - 1224,
+ 423,
+ 564,
+ - 1318,
+ - 1082,
+ 245,
+ - 1302,
+ - 812,
+ 573,
+ - 1298,
+ - 1617,
+ 646,
+ - 968,
+ 834,
+ 723,
+ 993,
+ 1652,
+ 2027,
+ - 191,
+ - 817,
+ 432,
+ 662,
+ 60,
+ 198,
+ 626,
+ 997,
+ 1330,
+ 1648,
+ 1963,
+ 1289,
+ - 1597,
+ - 93,
+ - 45,
+ - 1088,
+ 37,
+ - 84,
+ 1653,
+ 2607,
+ 2337,
+ 1065,
+ 2040,
+ 2377,
+ 1139,
+ 2326,
+ 2118,
+ 859,
+ 357,
+ 1510,
+ 664,
+ 1227,
+ 1099,
+ 479,
+ 1360,
+ 912,
+ 1897,
+ 1754,
+ 2019,
+ 1168,
+ 1909,
+ 1784,
+ 399,
+ 34,
+ 256,
+ - 593,
+ - 304,
+ - 1053,
+ 547,
+ 1694,
+ 1407,
+ 647,
+ - 99,
+ - 341,
+ 1492,
+ 1647,
+ 1190,
+ 38,
+ - 644,
+ - 212,
+ 395,
+ 846,
+ 222,
+ - 704,
+ - 765,
+ - 716,
+ - 724,
+ - 1964,
+ - 2804,
+ - 150,
+ 291,
+ - 82,
+ 1233,
+ 1459,
+ 1007,
+ - 140,
+ - 155,
+ 153,
+ 439,
+ 297,
+ 1568,
+ - 1529,
+ - 410,
+ - 636,
+ 1536,
+ 455,
+ - 237,
+ - 1328,
+ - 139,
+ - 260,
+ 531,
+ 554,
+ 868,
+ 269,
+ 1264,
+ 606,
+ - 233,
+ 883,
+ 463,
+ 742,
+ 600,
+ - 120,
+ - 73,
+ 421,
+ 212,
+ - 439,
+ - 58,
+ 804,
+ - 1286,
+ - 1241,
+ 728,
+ 294,
+ - 490,
+ 50,
+ - 591,
+ - 905,
+ - 1254,
+ 42,
+ - 687,
+ 147,
+ - 25,
+ 273,
+ 596,
+ - 311,
+ 1213,
+ 601,
+ - 754,
+ 849,
+ 584,
+ 429,
+ 607,
+ 587,
+ - 602,
+ - 166,
+ 461,
+ - 796,
+ - 823,
+ 777,
+ 1380,
+ 910,
+ 1755,
+ 119,
+ 1417,
+ 972,
+ - 219,
+ - 880,
+ - 1596,
+ - 1049,
+ - 1010,
+ 438,
+ - 713,
+ - 1379,
+ 78,
+ 0,
+ - 447,
+ - 1179,
+ - 1136,
+ - 1319,
+ - 1573,
+ 2248,
+ 1767,
+ 1309,
+ 946,
+ 1583,
+ 1432,
+ 1150,
+ 482,
+ 436,
+ - 469,
+ - 1108,
+ 618,
+ - 447,
+ - 966,
+ 1088,
+ - 1252,
+ - 1515,
+ - 114,
+ - 1104,
+ - 2008,
+ - 579,
+ 210,
+ 613,
+ 497,
+ - 1975,
+ - 1437,
+ 642,
+ - 1269,
+ - 856,
+ 1011,
+ - 1646,
+ - 1185,
+ 1063,
+ - 1555,
+ - 672,
+ 1204,
+ - 1692,
+ - 1114,
+ 623,
+ - 979,
+ - 1326,
+ - 1277,
+ 539,
+ - 147,
+ 894,
+ - 1354,
+ - 897,
+ - 434,
+ 888,
+ 475,
+ 428,
+ 153,
+ - 384,
+ 338,
+ - 1492,
+ - 511,
+ 359,
+ - 974,
+ - 1115,
+ - 470,
+ 105,
+ - 550,
+ 677,
+ - 937,
+ - 1145,
+ 877,
+ 380,
+ - 260,
+ 210,
+ 1685,
+ 924,
+ 1256,
+ 1775,
+ 1190,
+ 1095,
+ 1419,
+ 631,
+ 533,
+ 627,
+ 299,
+ - 347,
+ - 411,
+ - 534,
+ 647,
+ - 650,
+ 29,
+ - 595,
+ - 378,
+ - 1367,
+ 1563,
+ 1402,
+ 1121,
+ 1465,
+ 1089,
+ 1410,
+ 648,
+ - 2096,
+ - 1090,
+ - 6,
+ 311,
+ - 194,
+ - 869,
+ - 639,
+ - 831,
+ 416,
+ - 1162,
+ - 1224,
+ 1349,
+ - 1247,
+ - 941,
+ 1813,
+ - 2193,
+ - 1987,
+ 453,
+ - 619,
+ - 1367,
+ - 956,
+ - 1606,
+ - 1972,
+ - 1507,
+ - 1175,
+ - 1057,
+ - 1104,
+ - 377,
+ 601,
+ 201,
+ 1876,
+ 825,
+ 374,
+ - 430,
+ - 1323,
+ 29,
+ - 1397,
+ - 1249,
+ - 1331,
+ - 1007,
+ - 1504,
+ 960,
+ - 1401,
+ - 2009,
+ 197,
+ - 1379,
+ - 1949,
+ - 236,
+ - 1077,
+ 123,
+ 422,
+ 615,
+ 1269,
+ 546,
+ - 306,
+ 1526,
+ 904,
+ 1194,
+ 1788,
+ 1177,
+ - 626,
+ - 884,
+ - 1526,
+ 199,
+ 766,
+ 1504,
+ - 1065,
+ 862,
+ 197,
+ - 1034,
+ - 1773,
+ - 887,
+ - 800,
+ 145,
+ 599,
+ - 1134,
+ - 519,
+ 626,
+ - 1205,
+ - 1926,
+ 500,
+ - 910,
+ - 1041,
+ - 1395,
+ - 1476,
+ - 1567,
+ - 969,
+ - 523,
+ 842,
+ 34,
+ 1794,
+ 646,
+ 862,
+ - 1207,
+ - 1888,
+ - 1002,
+ - 78,
+ - 9,
+ - 672,
+ 1044,
+ 759,
+ 80,
+ - 600,
+ 1139,
+ 1019,
+ 57,
+ 2000,
+ 1422,
+ - 833,
+ 1414,
+ 1121,
+ - 1202,
+ 1630,
+ 1260,
+ - 461,
+ 1420,
+ 1244,
+ 1537,
+ 975,
+ 253,
+ - 283,
+ 324,
+ - 359,
+ 599,
+ - 195,
+ 106,
+ 588,
+ 62,
+ - 587,
+ - 757,
+ 645,
+ 205,
+ 51,
+ 1201,
+ 758,
+ - 1209,
+ 673,
+ - 390,
+ - 624,
+ 1581,
+ 941,
+ - 151,
+ 1023,
+ 735,
+ 2820,
+ 1301,
+ 690,
+ - 302,
+ 524,
+ - 99,
+ - 900,
+ - 1588,
+ - 1189,
+ 1084,
+ 251,
+ 238,
+ 2014,
+ 1792,
+ 1010,
+ 1245,
+ 1633,
+ 1741,
+ - 1227,
+ - 1540,
+ - 1208,
+ - 621,
+ 456,
+ - 109,
+ 40,
+ - 65,
+ 788,
+ - 805,
+ - 699,
+ - 1350,
+ - 583,
+ 904,
+ 832,
+ - 801,
+ 532,
+ 594,
+ 1972,
+ 1408,
+ 1351,
+ - 1177,
+ - 1880,
+ - 2114,
+ - 773,
+ 568,
+ 948,
+ - 1015,
+ 1079,
+ 1260,
+ - 1111,
+ 482,
+ - 130,
+ 1778,
+ 1044,
+ 780,
+ - 1491,
+ 245,
+ 912,
+ - 316,
+ - 1141,
+ - 917,
+ - 536,
+ - 1442,
+ - 2346,
+ - 785,
+ - 1546,
+ - 1988,
+ - 2003,
+ 257,
+ 909,
+ - 1849,
+ - 633,
+ - 1209,
+ - 1538,
+ - 1918,
+ - 1054,
+ 1606,
+ 2239,
+ 1576,
+ - 567,
+ - 1500,
+ - 1544,
+ - 1279,
+ 195,
+ 1369,
+ - 817,
+ 293,
+ 1219,
+ - 525,
+ 630,
+ 1197,
+ - 1698,
+ - 2425,
+ - 1840,
+ - 303,
+ 731,
+ 747,
+ - 1169,
+ - 251,
+ 269,
+ - 950,
+ - 75,
+ 1684,
+ - 1182,
+ - 453,
+ 1005,
+ - 1599,
+ 585,
+ 378,
+ - 2075,
+ - 571,
+ - 427,
+ - 529,
+ - 1159,
+ - 1171,
+ - 283,
+ - 205,
+ - 564,
+ - 796,
+ 1246,
+ 717,
+ 2277,
+ 927,
+ 539,
+ - 454,
+ 559,
+ 440,
+ - 717,
+ 1460,
+ 1615,
+ - 1030,
+ 1052,
+ 1610,
+ - 1169,
+ - 138,
+ 847,
+ 226,
+ 39,
+ - 612,
+ - 1251,
+ - 106,
+ - 729,
+ - 651,
+ 968,
+ 1302,
+ - 714,
+ - 636,
+ 1727,
+ 353,
+ 1069,
+ 410,
+ - 798,
+ - 156,
+ 1099,
+ - 574,
+ 918,
+ 446,
+ - 1310,
+ 1012,
+ 466,
+ 1408,
+ 1591,
+ 765,
+ 1429,
+ 1380,
+ 1757,
+ 1949,
+ 1956,
+ 2378,
+ 1578,
+ 2047,
+ 2148,
+ 916,
+ 98,
+ - 7,
+ 1893,
+ 1418,
+ 2141,
+ 348,
+ 1405,
+ 1579,
+ 152,
+ 1134,
+ 1801,
+ - 267,
+ 154,
+ 1395,
+ - 1166,
+ 469,
+ 1054,
+ - 1142,
+ - 405,
+ - 1073,
+ - 1341,
+ - 2264,
+ - 1581,
+ - 364,
+ 869,
+ 1706,
+ - 1162,
+ 549,
+ 1550,
+ - 1225,
+ - 1932,
+ - 1666,
+ - 1485,
+ - 1977,
+ - 2055,
+ - 1727,
+ - 906,
+ - 98,
+ - 1897,
+ 233,
+ 1492,
+ 892,
+ 108,
+ - 331,
+ - 1728,
+ - 1170,
+ - 1700,
+ - 1060,
+ 1980,
+ 1790,
+ - 1070,
+ - 1741,
+ - 1909,
+ - 11,
+ 1539,
+ 1317,
+ - 1600,
+ 94,
+ 497,
+ 421,
+ 443,
+ - 197,
+ - 1578,
+ - 349,
+ - 994,
+ - 599,
+ - 539,
+ 1140,
+ - 965,
+ - 1419,
+ - 129,
+ - 1341,
+ 175,
+ - 447,
+ - 375,
+ 1311,
+ 2055,
+ - 371,
+ - 650,
+ - 307,
+ - 1073,
+ 605,
+ 365,
+ - 2057,
+ - 113,
+ 430,
+ 652,
+ 914,
+ 967,
+ - 1012,
+ - 1586,
+ - 2323,
+ 1505,
+ 1248,
+ 559,
+ 262,
+ - 486,
+ - 401,
+ - 1727,
+ 1342,
+ 1546,
+ 50,
+ 56,
+ 432,
+ - 330,
+ 119,
+ - 604,
+ - 1517,
+ - 1080,
+ - 810,
+ 946,
+ 1127,
+ 1055,
+ - 1400,
+ - 1703,
+ - 1712,
+ - 1270,
+ - 704,
+ - 1317,
+ 807,
+ 1821,
+ 1143,
+ 2760,
+ 1606,
+ 2171,
+ 1120,
+ 409,
+ - 150,
+ - 147,
+ 404,
+ 959,
+ 2439,
+ 1911,
+ 2189,
+ - 906,
+ - 141,
+ - 866,
+ - 904,
+ - 142,
+ - 458,
+ - 557,
+ - 708,
+ - 1679,
+ - 830,
+ - 1431,
+ - 1583,
+ - 1842,
+ - 1346,
+ - 1086,
+ - 1604,
+ - 272,
+ 915,
+ - 1196,
+ 772,
+ 1056,
+ - 638,
+ - 1234,
+ - 1897,
+ - 500,
+ - 81,
+ - 822,
+ - 1289,
+ - 1613,
+ - 735,
+ - 117,
+ 785,
+ 168,
+ - 1090,
+ 1133,
+ 922,
+ - 1096,
+ - 746,
+ 1384,
+ 287,
+ - 547,
+ - 1063,
+ - 1376,
+ - 2201,
+ - 1204,
+ - 2176,
+ - 1570,
+ - 1757,
+ - 1511,
+ - 2241,
+ - 771,
+ - 1737,
+ 1099,
+ 830,
+ - 1588,
+ 724,
+ 1243,
+ - 1542,
+ 693,
+ 805,
+ - 1690,
+ - 240,
+ 1665,
+ - 1700,
+ - 4,
+ - 668,
+ 2149,
+ 816,
+ 1042,
+ - 818,
+ - 1841,
+ 22,
+ - 764,
+ - 507,
+ 449,
+ - 1151,
+ - 617,
+ 289,
+ - 843,
+ - 1596,
+ - 240,
+ 498,
+ - 234,
+ - 657,
+ - 752,
+ 480,
+ 1678,
+ - 319,
+ - 481,
+ 193,
+ - 811,
+ 171,
+ - 119,
+ - 2128,
+ - 202,
+ - 848,
+ 1717,
+ 1140,
+ 1700
+};
+
+/* 3rd LSF quantizer (not in MR122, MR515 and MR475) */
+static const Word32 dico3_lsf_3[] = {
+ 67,
+ - 17,
+ 66,
+ - 12,
+ - 1690,
+ - 581,
+ - 104,
+ - 272,
+ - 1076,
+ - 1186,
+ - 1845,
+ - 376,
+ - 1140,
+ - 926,
+ - 420,
+ - 58,
+ - 259,
+ - 656,
+ - 1134,
+ - 553,
+ 1788,
+ 1227,
+ 455,
+ 129,
+ 462,
+ 441,
+ - 240,
+ - 528,
+ 840,
+ 514,
+ 130,
+ - 75,
+ 1114,
+ 623,
+ 153,
+ 216,
+ 1068,
+ 564,
+ - 6,
+ - 276,
+ 1119,
+ 727,
+ 190,
+ - 68,
+ 704,
+ 306,
+ 119,
+ - 264,
+ 329,
+ 61,
+ - 100,
+ 156,
+ 364,
+ 123,
+ 183,
+ - 208,
+ - 171,
+ - 123,
+ 220,
+ - 65,
+ - 306,
+ - 62,
+ 402,
+ 17,
+ - 660,
+ - 938,
+ - 266,
+ 0,
+ 385,
+ 235,
+ 276,
+ 285,
+ 320,
+ 268,
+ - 336,
+ - 200,
+ - 724,
+ 17,
+ - 84,
+ 381,
+ - 544,
+ 429,
+ 494,
+ 519,
+ - 117,
+ 288,
+ 304,
+ 329,
+ 643,
+ 157,
+ 701,
+ 508,
+ 1200,
+ 625,
+ 796,
+ 608,
+ 998,
+ 421,
+ 492,
+ 632,
+ 1204,
+ 780,
+ 446,
+ 132,
+ 1257,
+ 844,
+ 547,
+ 449,
+ 829,
+ 658,
+ 541,
+ 470,
+ 1132,
+ 1258,
+ 918,
+ 639,
+ 547,
+ 51,
+ 423,
+ 279,
+ 9,
+ 392,
+ 83,
+ 94,
+ 542,
+ 543,
+ 229,
+ - 147,
+ - 198,
+ 129,
+ 194,
+ - 185,
+ - 863,
+ - 1321,
+ - 302,
+ 30,
+ - 597,
+ - 629,
+ - 19,
+ 114,
+ - 900,
+ - 1081,
+ 466,
+ 353,
+ - 1483,
+ - 1573,
+ 15,
+ - 143,
+ - 1708,
+ - 2059,
+ - 751,
+ 196,
+ - 1876,
+ - 2067,
+ - 642,
+ - 258,
+ - 2335,
+ - 1470,
+ - 450,
+ - 564,
+ - 584,
+ - 186,
+ - 872,
+ - 414,
+ - 1805,
+ - 988,
+ - 1125,
+ - 1310,
+ - 726,
+ - 1129,
+ 28,
+ 169,
+ - 1039,
+ - 864,
+ - 718,
+ - 246,
+ 484,
+ 36,
+ - 233,
+ - 49,
+ 265,
+ 67,
+ 289,
+ 467,
+ 178,
+ 543,
+ 810,
+ 540,
+ 84,
+ 282,
+ 672,
+ 703,
+ - 975,
+ - 777,
+ 129,
+ 287,
+ - 938,
+ - 227,
+ 955,
+ 595,
+ - 1617,
+ - 289,
+ 836,
+ 649,
+ - 1847,
+ - 215,
+ 1106,
+ 718,
+ - 2034,
+ - 1085,
+ 650,
+ 440,
+ - 2101,
+ - 529,
+ 907,
+ 575,
+ - 2011,
+ - 336,
+ 670,
+ 204,
+ - 2389,
+ - 692,
+ 360,
+ 137,
+ - 2156,
+ - 2204,
+ - 9,
+ 280,
+ - 266,
+ 119,
+ 39,
+ 193,
+ 78,
+ - 59,
+ - 120,
+ 226,
+ - 975,
+ - 858,
+ - 781,
+ - 1095,
+ - 619,
+ - 413,
+ - 451,
+ - 842,
+ - 1216,
+ - 1321,
+ - 813,
+ - 883,
+ - 1376,
+ - 1615,
+ - 394,
+ - 428,
+ - 737,
+ - 1113,
+ - 549,
+ - 790,
+ - 880,
+ - 975,
+ - 967,
+ - 642,
+ - 985,
+ - 886,
+ - 1273,
+ - 1361,
+ - 473,
+ - 804,
+ - 1401,
+ - 1407,
+ 160,
+ - 265,
+ - 919,
+ - 275,
+ - 248,
+ - 250,
+ - 718,
+ - 380,
+ 97,
+ - 103,
+ - 375,
+ - 229,
+ - 415,
+ - 193,
+ - 135,
+ - 555,
+ 628,
+ 361,
+ 119,
+ 216,
+ 579,
+ 364,
+ 391,
+ 209,
+ 634,
+ 522,
+ - 154,
+ - 148,
+ 526,
+ 389,
+ 170,
+ 33,
+ 105,
+ 267,
+ 64,
+ 380,
+ - 1503,
+ - 1000,
+ - 30,
+ - 369,
+ - 1070,
+ 58,
+ 647,
+ 223,
+ - 1520,
+ - 291,
+ 621,
+ 307,
+ - 1531,
+ 156,
+ 762,
+ 404,
+ - 2029,
+ 141,
+ 734,
+ 499,
+ - 1849,
+ - 650,
+ 306,
+ 512,
+ - 187,
+ - 104,
+ - 59,
+ 438,
+ 134,
+ - 230,
+ 156,
+ - 186,
+ - 61,
+ - 260,
+ - 16,
+ 10,
+ - 569,
+ - 3,
+ - 421,
+ - 297,
+ - 1725,
+ - 521,
+ - 346,
+ 178,
+ - 1362,
+ - 59,
+ - 44,
+ 157,
+ - 2146,
+ - 461,
+ - 470,
+ - 349,
+ - 2170,
+ - 1,
+ - 369,
+ - 121,
+ - 1579,
+ - 373,
+ - 900,
+ - 1015,
+ - 1117,
+ - 591,
+ - 613,
+ - 784,
+ - 561,
+ 122,
+ - 75,
+ - 449,
+ - 4,
+ - 171,
+ - 123,
+ - 372,
+ 192,
+ 168,
+ - 76,
+ - 132,
+ 252,
+ - 107,
+ 340,
+ 210,
+ 392,
+ 509,
+ 272,
+ 181,
+ - 109,
+ 145,
+ 218,
+ 119,
+ - 416,
+ - 263,
+ 485,
+ 265,
+ - 181,
+ - 8,
+ - 286,
+ 226,
+ - 244,
+ - 218,
+ 69,
+ - 290,
+ - 158,
+ 191,
+ - 1,
+ - 64,
+ - 592,
+ - 90,
+ 213,
+ - 96,
+ 255,
+ 435,
+ 178,
+ - 80,
+ - 369,
+ - 18,
+ - 33,
+ - 80,
+ - 42,
+ 415,
+ 140,
+ - 222,
+ 1143,
+ 651,
+ 649,
+ 329,
+ 767,
+ 556,
+ 249,
+ 235,
+ 948,
+ 413,
+ 442,
+ 279,
+ 141,
+ 339,
+ 356,
+ 557,
+ - 470,
+ - 170,
+ 99,
+ 237,
+ - 569,
+ - 800,
+ 352,
+ 565,
+ 282,
+ 473,
+ 470,
+ 332,
+ - 199,
+ - 690,
+ - 1284,
+ - 917,
+ - 193,
+ - 426,
+ - 800,
+ - 1122,
+ - 26,
+ - 371,
+ - 490,
+ - 193,
+ 637,
+ 595,
+ 519,
+ 330,
+ 408,
+ - 115,
+ 79,
+ 12,
+ 477,
+ 87,
+ - 103,
+ - 376,
+ - 666,
+ - 347,
+ - 277,
+ - 291,
+ - 510,
+ - 481,
+ 169,
+ 297,
+ - 829,
+ - 738,
+ - 205,
+ - 171,
+ - 320,
+ - 540,
+ 328,
+ 283,
+ - 859,
+ - 958,
+ 442,
+ - 2,
+ 556,
+ 686,
+ 130,
+ 56,
+ 1383,
+ 1012,
+ 755,
+ 427,
+ 612,
+ 741,
+ 628,
+ 553,
+ - 339,
+ - 796,
+ 134,
+ 277,
+ - 633,
+ - 1085,
+ - 2,
+ - 246,
+ - 880,
+ - 1035,
+ - 1607,
+ - 1064,
+ - 994,
+ - 474,
+ - 1138,
+ - 488,
+ - 414,
+ - 795,
+ 73,
+ - 206,
+ - 8,
+ - 139,
+ 439,
+ 204,
+ - 176,
+ - 578,
+ 23,
+ 131,
+ - 269,
+ - 757,
+ - 191,
+ 245,
+ - 109,
+ - 338,
+ 112,
+ 316,
+ 120,
+ - 406,
+ - 118,
+ 611,
+ - 180,
+ - 186,
+ - 645,
+ 115,
+ - 173,
+ 34,
+ - 518,
+ - 489,
+ - 151,
+ 61,
+ - 583,
+ - 844,
+ 220,
+ - 138,
+ - 681,
+ - 1020,
+ 391,
+ - 17,
+ - 598,
+ - 321,
+ 157,
+ - 295,
+ 129,
+ 155,
+ - 926,
+ - 875,
+ - 987,
+ 285,
+ 241,
+ - 83,
+ - 125,
+ - 125,
+ 620,
+ 597,
+ 432,
+ 92,
+ 393,
+ 78,
+ 409,
+ 61,
+ - 393,
+ - 739,
+ - 413,
+ - 748,
+ 83,
+ 54,
+ 361,
+ 27,
+ - 1084,
+ 130,
+ - 337,
+ - 694,
+ - 1565,
+ 297,
+ 318,
+ - 19,
+ - 1873,
+ 36,
+ 51,
+ - 317,
+ - 2323,
+ - 246,
+ 231,
+ - 84,
+ - 2306,
+ - 783,
+ 40,
+ - 179,
+ - 2233,
+ - 930,
+ - 474,
+ - 462,
+ - 754,
+ - 86,
+ - 288,
+ - 626,
+ - 2411,
+ - 455,
+ - 63,
+ 171,
+ - 1099,
+ - 1094,
+ - 26,
+ - 143,
+ - 1193,
+ - 455,
+ - 406,
+ - 381,
+ - 605,
+ - 210,
+ - 96,
+ - 51,
+ - 580,
+ - 476,
+ - 276,
+ - 15,
+ - 1195,
+ - 634,
+ - 1203,
+ - 881,
+ - 378,
+ - 221,
+ - 669,
+ - 952,
+ 594,
+ 178,
+ - 403,
+ - 676,
+ 763,
+ 327,
+ 601,
+ 290,
+ 172,
+ 300,
+ 203,
+ 157,
+ - 56,
+ - 336,
+ 356,
+ 24,
+ - 228,
+ - 296,
+ - 259,
+ - 29,
+ - 186,
+ 263,
+ 416,
+ 14,
+ - 353,
+ 373,
+ - 12,
+ - 216,
+ 257,
+ 96,
+ 174,
+ 57,
+ - 1526,
+ - 616,
+ - 954,
+ - 499,
+ - 497,
+ - 152,
+ - 333,
+ 125,
+ 105,
+ 200,
+ 179,
+ - 97,
+ - 331,
+ - 224,
+ 765,
+ 697,
+ 760,
+ 256,
+ 301,
+ 59,
+ 455,
+ - 85,
+ 204,
+ 288,
+ - 514,
+ 240,
+ 251,
+ - 109,
+ 256,
+ 417,
+ - 34,
+ - 413,
+ 101,
+ 430,
+ 384,
+ 156,
+ - 31,
+ - 10,
+ 206,
+ 426,
+ 589,
+ 145,
+ 143,
+ 71,
+ 808,
+ 906,
+ 333,
+ 349,
+ 986,
+ 938,
+ 589,
+ 331,
+ 1300,
+ 824,
+ 187,
+ 509,
+ 1062,
+ 653,
+ 379,
+ 466,
+ 1462,
+ 937,
+ 401,
+ 274,
+ 787,
+ 861,
+ 265,
+ 2,
+ 609,
+ 553,
+ 28,
+ 305,
+ 926,
+ 340,
+ 106,
+ 386,
+ 241,
+ - 267,
+ - 147,
+ 225,
+ - 178,
+ - 534,
+ 347,
+ 502,
+ - 643,
+ - 381,
+ 397,
+ 30,
+ - 651,
+ - 733,
+ - 435,
+ 398,
+ - 407,
+ - 726,
+ - 484,
+ - 248,
+ - 789,
+ - 914,
+ - 438,
+ - 476,
+ - 498,
+ - 390,
+ 75,
+ - 295,
+ - 964,
+ - 590,
+ - 606,
+ 150,
+ - 121,
+ - 49,
+ - 155,
+ - 78,
+ 935,
+ 550,
+ 389,
+ 38,
+ - 321,
+ 127,
+ 424,
+ 315,
+ - 285,
+ - 113,
+ 283,
+ 259,
+ 658,
+ 203,
+ 322,
+ 486,
+ 903,
+ 505,
+ 748,
+ 417,
+ 611,
+ 423,
+ 555,
+ 512,
+ 239,
+ - 83,
+ - 578,
+ - 19,
+ - 339,
+ - 731,
+ 349,
+ 13,
+ - 934,
+ - 1399,
+ - 114,
+ - 360,
+ 107,
+ 692,
+ 182,
+ 90,
+ - 1243,
+ - 1538,
+ - 1551,
+ - 725,
+ - 568,
+ - 903,
+ - 1363,
+ - 525,
+ - 517,
+ - 853,
+ - 861,
+ - 1004,
+ - 168,
+ - 690,
+ - 835,
+ 63,
+ - 137,
+ - 556,
+ - 547,
+ 144,
+ - 286,
+ - 817,
+ 485,
+ 319,
+ - 147,
+ - 408,
+ 526,
+ 246,
+ - 347,
+ - 434,
+ 297,
+ - 28,
+ - 290,
+ - 471,
+ - 1110,
+ - 1285,
+ - 460,
+ - 359,
+ - 988,
+ - 794,
+ 1347,
+ 1299,
+ 690,
+ 523,
+ 1216,
+ 1068,
+ 1094,
+ 757,
+ 825,
+ 1140,
+ 752,
+ 494,
+ 1252,
+ 1365,
+ 1195,
+ 898,
+ 521,
+ 1053,
+ 532,
+ 432,
+ - 334,
+ - 216,
+ - 313,
+ - 263,
+ - 160,
+ 52,
+ - 472,
+ - 155,
+ 127,
+ 136,
+ - 380,
+ 44,
+ 851,
+ 410,
+ - 162,
+ - 489,
+ 123,
+ - 255,
+ - 796,
+ - 667,
+ 1090,
+ 917,
+ 789,
+ 493,
+ 1397,
+ 1197,
+ 558,
+ 202,
+ - 51,
+ - 118,
+ - 342,
+ - 701,
+ 83,
+ 108,
+ - 42,
+ - 441,
+ 61,
+ 95,
+ 287,
+ 256,
+ - 27,
+ 89,
+ 524,
+ 531,
+ 351,
+ 227,
+ 592,
+ 545,
+ 697,
+ 155,
+ - 164,
+ 307,
+ 638,
+ 274,
+ - 489,
+ - 50,
+ 754,
+ 240,
+ - 166,
+ - 124,
+ - 116,
+ - 579,
+ - 1212,
+ - 63,
+ 190,
+ - 295,
+ - 1040,
+ - 1296,
+ 147,
+ - 376,
+ - 177,
+ - 113,
+ 841,
+ 1241,
+ 1051,
+ 668,
+ 2,
+ 293,
+ 551,
+ 304,
+ - 1096,
+ - 953,
+ - 248,
+ 376,
+ - 750,
+ - 965,
+ 87,
+ 516,
+ - 275,
+ - 516,
+ 689,
+ 391,
+ - 379,
+ - 643,
+ 876,
+ 594,
+ - 390,
+ - 1013,
+ - 645,
+ 573,
+ - 107,
+ - 568,
+ - 689,
+ - 826,
+ - 1025,
+ - 27,
+ - 328,
+ - 203,
+ 861,
+ 749,
+ 548,
+ 233,
+ - 1660,
+ - 1043,
+ 451,
+ 108,
+ - 660,
+ - 620,
+ 430,
+ 236,
+ 21,
+ - 396,
+ - 1158,
+ - 631,
+ 1372,
+ 1298,
+ 967,
+ 577,
+ 1125,
+ 1125,
+ 589,
+ 454,
+ - 323,
+ - 865,
+ - 467,
+ 153,
+ - 468,
+ - 699,
+ - 804,
+ - 509,
+ - 392,
+ - 718,
+ - 204,
+ - 35,
+ - 603,
+ - 1093,
+ - 567,
+ - 162,
+ - 505,
+ - 1004,
+ - 102,
+ 350,
+ 219,
+ 224,
+ 423,
+ 252,
+ 395,
+ 591,
+ 608,
+ 363,
+ - 746,
+ - 96,
+ 373,
+ 172,
+ 171,
+ 295,
+ 714,
+ 339,
+ 233,
+ 77,
+ 107,
+ 277,
+ 157,
+ 153,
+ - 499,
+ - 356,
+ 1547,
+ 1073,
+ 576,
+ 494,
+ - 292,
+ - 339,
+ - 504,
+ - 592,
+ - 903,
+ - 72,
+ - 619,
+ - 481,
+ - 1594,
+ - 1117,
+ - 567,
+ - 254,
+ - 793,
+ - 507,
+ - 564,
+ - 291,
+ - 492,
+ - 532,
+ 502,
+ 560,
+ - 382,
+ 427,
+ 600,
+ 230,
+ - 227,
+ 477,
+ 251,
+ 75,
+ 285,
+ 842,
+ 813,
+ 476,
+ - 1310,
+ - 1333,
+ 186,
+ 377,
+ - 587,
+ - 917,
+ 643,
+ 381,
+ - 1186,
+ - 553,
+ 411,
+ 82,
+ - 1127,
+ - 820,
+ - 174,
+ - 540,
+ - 604,
+ 119,
+ 543,
+ 205,
+ - 380,
+ 657,
+ 909,
+ 567,
+ 112,
+ - 298,
+ - 374,
+ 114,
+ - 857,
+ - 251,
+ 56,
+ 159,
+ 401,
+ 345,
+ - 34,
+ - 140,
+ - 111,
+ - 607,
+ 41,
+ 614,
+ 355,
+ - 114,
+ - 77,
+ 474,
+ 578,
+ 56,
+ 1450,
+ 924,
+ 1098,
+ 1420,
+ 741,
+ 400,
+ 246,
+ 22,
+ 588,
+ 313,
+ - 121,
+ 327,
+ 831,
+ 472,
+ - 1138,
+ - 608,
+ 856,
+ 552,
+ - 1241,
+ - 1072,
+ 638,
+ 600,
+ - 358,
+ 254,
+ - 333,
+ - 303,
+ - 646,
+ 739,
+ 358,
+ 74,
+ 1226,
+ 1671,
+ 1221,
+ 849,
+ 2241,
+ 1624,
+ 983,
+ 636,
+ 1841,
+ 1477,
+ 749,
+ 384,
+ 350,
+ 263,
+ 87,
+ 128,
+ - 1902,
+ - 941,
+ - 144,
+ - 64,
+ - 1734,
+ - 255,
+ 288,
+ - 31,
+ - 2644,
+ - 1238,
+ 366,
+ 235,
+ - 1643,
+ - 1092,
+ - 1344,
+ - 304,
+ - 541,
+ - 1075,
+ - 1116,
+ 123,
+ - 1178,
+ - 252,
+ - 816,
+ - 180,
+ - 1016,
+ 533,
+ 565,
+ 233,
+ - 487,
+ - 430,
+ - 188,
+ 334,
+ 867,
+ 1236,
+ 534,
+ 171,
+ - 1590,
+ - 1607,
+ 635,
+ 630,
+ - 2196,
+ 310,
+ 924,
+ 412,
+ - 2358,
+ - 328,
+ 956,
+ 529,
+ - 2639,
+ - 377,
+ 630,
+ 278,
+ - 2602,
+ 317,
+ 799,
+ 299,
+ - 2406,
+ 133,
+ 340,
+ 31,
+ - 2156,
+ - 1468,
+ 131,
+ 125,
+ - 1184,
+ - 490,
+ - 139,
+ 46,
+ - 744,
+ 447,
+ 891,
+ 564,
+ 67,
+ - 451,
+ 646,
+ 604,
+ - 553,
+ - 429,
+ - 876,
+ 396,
+ 162,
+ - 66,
+ 1305,
+ 915,
+ 479,
+ 579,
+ 1088,
+ 794,
+ 450,
+ 278,
+ 566,
+ 324,
+ - 1057,
+ - 154,
+ 148,
+ - 177,
+ - 2545,
+ 168,
+ 1070,
+ 592,
+ - 2351,
+ - 42,
+ 819,
+ 345,
+ - 2344,
+ - 707,
+ 721,
+ 250,
+ - 2175,
+ - 1497,
+ - 309,
+ 122,
+ - 78,
+ - 73,
+ 120,
+ 173,
+ - 4,
+ 262,
+ - 263,
+ - 261,
+ - 431,
+ - 64,
+ - 405,
+ - 732,
+ - 2609,
+ 116,
+ - 83,
+ - 193,
+ - 1525,
+ - 944,
+ - 477,
+ - 725,
+ - 508,
+ 307,
+ 170,
+ 172,
+ 832,
+ 417,
+ 832,
+ 686,
+ - 225,
+ 177,
+ 894,
+ 818,
+ - 482,
+ - 389,
+ 1279,
+ 1039,
+ - 383,
+ 201,
+ - 350,
+ 40,
+ 730,
+ 635,
+ 226,
+ 526,
+ 503,
+ 462,
+ 338,
+ 398,
+ 535,
+ 714,
+ 40,
+ - 282,
+ 1482,
+ 1471,
+ 1085,
+ 731,
+ 1561,
+ 1072,
+ 909,
+ 693,
+ 1419,
+ 1282,
+ 889,
+ 879,
+ 1153,
+ 728,
+ 1186,
+ 840,
+ - 226,
+ 1130,
+ 949,
+ 689,
+ - 494,
+ - 986,
+ - 1556,
+ - 128,
+ - 568,
+ - 721,
+ - 713,
+ - 26,
+ 317,
+ 524,
+ 70,
+ 135,
+ - 405,
+ - 865,
+ - 1766,
+ - 652,
+ - 174,
+ - 801,
+ 885,
+ 773,
+ - 153,
+ - 91,
+ 1099,
+ 751,
+ - 506,
+ - 1149,
+ 853,
+ 646,
+ 241,
+ 782,
+ 519,
+ 539,
+ 1853,
+ 1700,
+ 1101,
+ 684,
+ - 1249,
+ - 1486,
+ - 464,
+ 188,
+ - 893,
+ - 1409,
+ - 1312,
+ - 341,
+ - 135,
+ 438,
+ - 175,
+ 18,
+ 1111,
+ 976,
+ 319,
+ 208,
+ - 1430,
+ - 1768,
+ 83,
+ 458,
+ - 530,
+ - 1000,
+ 307,
+ 129,
+ - 840,
+ - 15,
+ - 29,
+ - 356,
+ - 911,
+ - 924,
+ - 1147,
+ - 242,
+ - 119,
+ - 528,
+ 127,
+ - 133,
+ - 761,
+ - 765,
+ 190,
+ - 83,
+ - 315,
+ 895,
+ 522,
+ 231,
+ - 222,
+ 102,
+ - 63,
+ - 428,
+ 316,
+ 699,
+ 379,
+ 70,
+ 25,
+ 716,
+ 314,
+ - 108,
+ 507,
+ 874,
+ 566,
+ 238,
+ 108,
+ 941,
+ 519,
+ 195,
+ 425,
+ - 60,
+ - 427,
+ 257,
+ 139,
+ - 103,
+ - 630,
+ 446,
+ 334,
+ 370,
+ 412,
+ 48,
+ - 172,
+ - 690,
+ - 283,
+ 557,
+ 187,
+ - 286,
+ 158,
+ 483,
+ 140,
+ 270,
+ - 344,
+ - 631,
+ 924,
+ 579,
+ - 116,
+ 132,
+ 142,
+ 466,
+ - 68,
+ - 64,
+ 230,
+ - 145,
+ - 302,
+ - 542,
+ - 803,
+ - 912,
+ 1018,
+ 737,
+ - 773,
+ 1015,
+ 630,
+ 297,
+ - 2596,
+ 95,
+ 445,
+ 336,
+ - 2122,
+ 491,
+ 510,
+ 191,
+ - 1253,
+ 161,
+ - 2,
+ - 324,
+ - 1450,
+ - 633,
+ - 712,
+ - 105,
+ - 842,
+ - 254,
+ - 411,
+ 100,
+ - 640,
+ - 290,
+ 1010,
+ 763,
+ - 650,
+ 313,
+ 1169,
+ 730,
+ 140,
+ 505,
+ 1030,
+ 766,
+ 772,
+ 287,
+ 1067,
+ 823,
+ 495,
+ 749,
+ 305,
+ 323,
+ - 164,
+ 462,
+ 78,
+ 399,
+ - 342,
+ - 874,
+ 69,
+ 597,
+ - 16,
+ 620,
+ 621,
+ 337,
+ - 138,
+ - 444,
+ - 265,
+ 218,
+ 84,
+ - 450,
+ 953,
+ 666,
+ - 222,
+ - 803,
+ 541,
+ 604,
+ - 921,
+ - 1376,
+ 244,
+ 116,
+ - 841,
+ - 723,
+ 630,
+ 588,
+ 140,
+ 663,
+ 294,
+ 368,
+ 935,
+ 1046,
+ 881,
+ 759,
+ 1746,
+ 1464,
+ 916,
+ 628,
+ 436,
+ 963,
+ 281,
+ 1,
+ - 119,
+ 74,
+ 542,
+ 213,
+ 1,
+ - 567,
+ 301,
+ 241,
+ 260,
+ 435,
+ 222,
+ 396,
+ 936,
+ 957,
+ 1108,
+ 703,
+ 510,
+ 506,
+ 808,
+ 478,
+ 601,
+ 694,
+ 960,
+ 620,
+ 972,
+ 741,
+ 980,
+ 600,
+ 834,
+ 717,
+ 767,
+ 684,
+ 643,
+ 972,
+ 935,
+ 638,
+ 501,
+ 661,
+ 720,
+ 851,
+ - 105,
+ - 632,
+ - 303,
+ - 117,
+ - 429,
+ 130,
+ 789,
+ 442,
+ - 522,
+ - 188,
+ 704,
+ 373,
+ - 759,
+ 42,
+ 814,
+ 523,
+ - 531,
+ - 1137,
+ 373,
+ 578,
+ - 682,
+ - 1203,
+ - 455,
+ 285,
+ - 1163,
+ - 1577,
+ - 1098,
+ 44,
+ 81,
+ - 82,
+ 712,
+ 363,
+ 477,
+ 246,
+ 954,
+ 622,
+ 1604,
+ 1622,
+ 1277,
+ 891,
+ 1409,
+ 859,
+ 924,
+ 892,
+ 774,
+ 1041,
+ 947,
+ 1142,
+ 40,
+ - 546,
+ - 75,
+ 288,
+ - 616,
+ - 106,
+ - 697,
+ - 26,
+ - 169,
+ - 160,
+ - 891,
+ - 739,
+ - 279,
+ - 384,
+ - 1029,
+ - 350,
+ 1781,
+ 1308,
+ 1046,
+ 816,
+ 1580,
+ 1533,
+ 1472,
+ 1178,
+ 1505,
+ 1076,
+ 1216,
+ 899,
+ 890,
+ 904,
+ 564,
+ 654,
+ 920,
+ 692,
+ 1021,
+ 856,
+ - 493,
+ 132,
+ 177,
+ 505,
+ 71,
+ 195,
+ - 28,
+ 97,
+ 456,
+ 351,
+ - 164,
+ 88,
+ 439,
+ 278,
+ - 40,
+ 350,
+ 1395,
+ 949,
+ 234,
+ - 95,
+ - 805,
+ - 472,
+ 38,
+ - 163,
+ 367,
+ - 98,
+ 489,
+ 523,
+ 1025,
+ 1178,
+ 1212,
+ 906,
+ 319,
+ 1314,
+ 814,
+ 461,
+ - 123,
+ - 543,
+ - 804,
+ 447,
+ - 748,
+ - 324,
+ - 897,
+ - 1127,
+ - 737,
+ - 501,
+ - 789,
+ - 713,
+ 715,
+ 777,
+ 1239,
+ 922,
+ 1949,
+ 1939,
+ 1368,
+ 865,
+ 730,
+ 880,
+ 758,
+ 388,
+ - 871,
+ 454,
+ 17,
+ - 251,
+ - 381,
+ - 810,
+ - 1583,
+ 239,
+ - 521,
+ - 966,
+ - 792,
+ 259,
+ - 890,
+ - 1358,
+ - 770,
+ - 73,
+ 166,
+ 349,
+ - 212,
+ 323,
+ - 840,
+ - 301,
+ 473,
+ 435,
+ - 679,
+ - 464,
+ 728,
+ 351,
+ - 156,
+ - 199,
+ 667,
+ 432,
+ 29,
+ - 252,
+ 415,
+ 480,
+ - 731,
+ - 379,
+ 145,
+ 559,
+ - 528,
+ - 631,
+ - 1158,
+ - 159,
+ 445,
+ 273,
+ 123,
+ 639,
+ 373,
+ - 126,
+ 800,
+ 568,
+ 84,
+ - 162,
+ 720,
+ 712,
+ - 830,
+ - 536,
+ - 185,
+ 222,
+ 408,
+ 452,
+ 501,
+ 771,
+ - 897,
+ - 1355,
+ - 67,
+ 442,
+ - 792,
+ - 1406,
+ 566,
+ 602,
+ 167,
+ - 326,
+ 509,
+ 330,
+ - 95,
+ - 626,
+ - 730,
+ - 344,
+ 1668,
+ 1217,
+ 779,
+ 455,
+ 1316,
+ 828,
+ 584,
+ 719,
+ 404,
+ - 31,
+ 1013,
+ 789,
+ 89,
+ 107,
+ 891,
+ 549,
+ 871,
+ 1581,
+ 917,
+ 671,
+ 866,
+ 1479,
+ 1289,
+ 854,
+ 391,
+ 1068,
+ 1122,
+ 812,
+ 78,
+ - 562,
+ 345,
+ 563,
+ 429,
+ - 103,
+ 417,
+ 787,
+ - 122,
+ - 437,
+ 411,
+ 788,
+ - 913,
+ - 417,
+ 602,
+ 754,
+ - 226,
+ - 16,
+ 151,
+ 760,
+ - 700,
+ 118,
+ - 104,
+ - 14,
+ - 1128,
+ 48,
+ 284,
+ 393,
+ - 390,
+ - 419,
+ - 639,
+ - 116,
+ - 910,
+ 306,
+ 316,
+ - 13,
+ 1207,
+ 984,
+ 821,
+ 669,
+ - 1195,
+ - 693,
+ 140,
+ - 213,
+ - 884,
+ - 416,
+ - 199,
+ - 558,
+ - 616,
+ 245,
+ - 404,
+ - 664,
+ 262,
+ 56,
+ - 617,
+ - 724,
+ - 85,
+ - 491,
+ - 320,
+ - 656,
+ - 570,
+ - 831,
+ - 129,
+ - 528,
+ - 1506,
+ - 63,
+ - 367,
+ - 385,
+ - 358,
+ - 321,
+ 4,
+ 51,
+ - 366,
+ - 214,
+ 319,
+ 511,
+ 146,
+ 671,
+ - 17,
+ - 291,
+ - 110,
+ 464,
+ - 139,
+ - 496,
+ - 202,
+ 220,
+ - 312,
+ - 631,
+ - 660,
+ - 73,
+ - 655,
+ - 820,
+ - 662,
+ - 653,
+ - 1288,
+ - 857,
+ - 430,
+ - 953,
+ - 959,
+ - 264,
+ - 49,
+ - 468,
+ - 72,
+ - 381,
+ - 350,
+ - 563,
+ - 193,
+ - 407,
+ 55,
+ - 408,
+ - 803,
+ 11,
+ - 309,
+ 649,
+ 188,
+ - 198,
+ - 512,
+ 461,
+ - 79,
+ - 458,
+ - 1318,
+ - 263,
+ - 134,
+ - 523,
+ - 1657,
+ - 435,
+ - 495,
+ - 765,
+ 57,
+ - 347,
+ - 414,
+ 434,
+ - 1141,
+ - 242,
+ - 664,
+ - 857,
+ 34,
+ - 68,
+ - 707,
+ - 338
+};
+#define MR515_3_SIZE 128
+
+/* 3rd LSF quantizer (MR515 and MR475) */
+static const Word32 mr515_3_lsf[] = {
+ 419,
+ 163,
+ - 30,
+ - 262,
+ - 455,
+ - 789,
+ - 1430,
+ - 721,
+ 1006,
+ 664,
+ 269,
+ 25,
+ 619,
+ 260,
+ 183,
+ 96,
+ - 968,
+ - 1358,
+ - 388,
+ 135,
+ - 693,
+ 835,
+ 456,
+ 154,
+ 1105,
+ 703,
+ 569,
+ 363,
+ 1625,
+ 1326,
+ 985,
+ 748,
+ - 220,
+ 219,
+ 76,
+ - 208,
+ - 1455,
+ - 1662,
+ 49,
+ 149,
+ - 964,
+ - 172,
+ - 752,
+ - 336,
+ 625,
+ 209,
+ - 250,
+ - 66,
+ - 1017,
+ - 838,
+ - 2,
+ 317,
+ - 2168,
+ - 1485,
+ - 138,
+ 123,
+ - 1876,
+ - 2099,
+ - 521,
+ 85,
+ - 967,
+ - 366,
+ - 695,
+ - 881,
+ - 921,
+ - 1011,
+ - 763,
+ - 949,
+ - 124,
+ - 256,
+ - 352,
+ - 660,
+ 178,
+ 463,
+ 354,
+ 304,
+ - 1744,
+ - 591,
+ - 282,
+ 79,
+ - 2249,
+ 175,
+ 867,
+ 499,
+ - 138,
+ - 180,
+ - 181,
+ - 21,
+ - 2291,
+ - 1241,
+ - 460,
+ - 520,
+ - 771,
+ 451,
+ - 10,
+ - 308,
+ 271,
+ - 65,
+ 4,
+ 214,
+ - 279,
+ - 435,
+ - 43,
+ - 348,
+ - 670,
+ 35,
+ - 65,
+ - 211,
+ 806,
+ 535,
+ 85,
+ 297,
+ 57,
+ 239,
+ 722,
+ 493,
+ 225,
+ 661,
+ 840,
+ 547,
+ - 540,
+ - 376,
+ 14,
+ 349,
+ 469,
+ 721,
+ 331,
+ 162,
+ - 544,
+ - 752,
+ - 62,
+ - 10,
+ 398,
+ - 88,
+ 724,
+ 701,
+ - 19,
+ - 533,
+ - 94,
+ 601,
+ 136,
+ - 71,
+ - 681,
+ - 747,
+ - 166,
+ - 344,
+ 261,
+ - 50,
+ 161,
+ - 52,
+ 485,
+ 337,
+ - 1675,
+ 50,
+ 190,
+ - 93,
+ - 2282,
+ - 231,
+ - 194,
+ - 82,
+ - 95,
+ - 595,
+ - 154,
+ 128,
+ 894,
+ 501,
+ 588,
+ 457,
+ - 345,
+ 206,
+ 122,
+ 110,
+ - 631,
+ - 227,
+ - 569,
+ 3,
+ 408,
+ 239,
+ 397,
+ 226,
+ - 197,
+ - 2,
+ 128,
+ 491,
+ 1281,
+ 904,
+ 292,
+ 215,
+ 538,
+ 306,
+ 259,
+ 509,
+ - 677,
+ - 1047,
+ 13,
+ 321,
+ - 679,
+ - 588,
+ - 358,
+ - 212,
+ - 558,
+ 243,
+ 646,
+ 479,
+ 486,
+ 342,
+ 634,
+ 532,
+ 107,
+ 802,
+ 331,
+ 136,
+ - 112,
+ - 398,
+ - 1031,
+ - 286,
+ - 326,
+ - 705,
+ 288,
+ 272,
+ 1299,
+ 1144,
+ 1178,
+ 860,
+ - 423,
+ 121,
+ - 385,
+ - 148,
+ - 295,
+ - 302,
+ - 834,
+ - 819,
+ 16,
+ - 24,
+ - 201,
+ - 476,
+ 555,
+ 91,
+ - 245,
+ 294,
+ - 38,
+ - 379,
+ - 962,
+ - 1221,
+ - 1191,
+ - 1518,
+ - 273,
+ - 395,
+ - 390,
+ - 1013,
+ - 645,
+ 573,
+ - 1843,
+ - 1030,
+ 505,
+ 468,
+ 744,
+ 947,
+ 609,
+ 493,
+ - 689,
+ - 1172,
+ - 628,
+ - 135,
+ - 1026,
+ 195,
+ 411,
+ 196,
+ 1582,
+ 1147,
+ 575,
+ 337,
+ - 1239,
+ - 777,
+ - 648,
+ - 142,
+ 595,
+ 825,
+ 967,
+ 735,
+ - 1206,
+ - 970,
+ - 81,
+ - 342,
+ - 745,
+ 13,
+ - 72,
+ 375,
+ 454,
+ 19,
+ 1407,
+ 921,
+ - 1647,
+ - 172,
+ 861,
+ 562,
+ 928,
+ 1537,
+ 1063,
+ 740,
+ - 2472,
+ - 952,
+ 264,
+ 82,
+ - 502,
+ - 965,
+ - 1334,
+ 123,
+ 867,
+ 1236,
+ 534,
+ 171,
+ - 2320,
+ - 460,
+ 780,
+ 363,
+ - 1190,
+ - 617,
+ 252,
+ - 61,
+ - 174,
+ 34,
+ 1011,
+ 788,
+ - 2333,
+ 247,
+ 423,
+ 153,
+ - 16,
+ - 355,
+ 262,
+ 449,
+ - 1576,
+ - 1073,
+ - 544,
+ - 371,
+ - 615,
+ - 305,
+ 1051,
+ 805,
+ 687,
+ 528,
+ 6,
+ - 182,
+ 935,
+ 875,
+ 1002,
+ 809,
+ 199,
+ 257,
+ 126,
+ 76,
+ - 584,
+ - 1138,
+ 599,
+ 556,
+ - 1105,
+ - 1391,
+ - 1591,
+ - 519,
+ - 977,
+ - 1325,
+ 108,
+ 347,
+ - 722,
+ - 975,
+ 365,
+ 101,
+ - 145,
+ 681,
+ 249,
+ - 153,
+ 0,
+ - 334,
+ - 570,
+ 159,
+ 412,
+ 285,
+ - 336,
+ - 617,
+ - 953,
+ - 966,
+ 887,
+ 689,
+ - 1251,
+ 84,
+ - 185,
+ - 398,
+ - 592,
+ 433,
+ 1044,
+ 653,
+ 85,
+ 329,
+ - 40,
+ 361,
+ - 433,
+ - 705,
+ 466,
+ 574,
+ - 154,
+ 654,
+ 592,
+ 290,
+ - 167,
+ 72,
+ 349,
+ 175,
+ 674,
+ 297,
+ 977,
+ 720,
+ 1235,
+ 1204,
+ 757,
+ 488,
+ - 400,
+ - 269,
+ 538,
+ 372,
+ - 1350,
+ - 1387,
+ - 1194,
+ - 91,
+ 1262,
+ 876,
+ 775,
+ 700,
+ - 599,
+ - 38,
+ - 430,
+ - 722,
+ 1976,
+ 1630,
+ 991,
+ 608,
+ 111,
+ 276,
+ - 226,
+ - 96,
+ - 947,
+ - 388,
+ - 11,
+ - 7,
+ - 303,
+ - 531,
+ - 839,
+ 338,
+ 1734,
+ 1710,
+ 1405,
+ 1013,
+ - 516,
+ - 855,
+ - 645,
+ 210,
+ - 688,
+ - 416,
+ 513,
+ 230,
+ - 822,
+ - 637,
+ - 1146,
+ - 320,
+ - 952,
+ - 658,
+ - 694,
+ 183,
+ - 114,
+ - 623,
+ 818,
+ 674,
+ - 191,
+ - 204,
+ 731,
+ 635,
+ 51,
+ 1221,
+ 883,
+ 576,
+ - 954,
+ - 431,
+ 826,
+ 598,
+ - 342,
+ - 755,
+ - 900,
+ - 407,
+ - 1126,
+ - 354,
+ - 206,
+ - 512,
+ - 547,
+ - 810,
+ - 357,
+ - 620,
+ 66,
+ 515,
+ - 73,
+ - 410,
+ - 872,
+ - 945,
+ - 1444,
+ - 1227,
+ 191,
+ - 17,
+ - 544,
+ - 231,
+ - 1540,
+ - 544,
+ - 901,
+ - 886
+};
+#define MR795_1_SIZE 512
+
+/* 1st LSF quantizer (MR795) */
+static const Word32 mr795_1_lsf[] = {
+ - 890,
+ - 1550,
+ - 2541,
+ - 819,
+ - 970,
+ 175,
+ - 826,
+ - 1234,
+ - 762,
+ - 599,
+ - 22,
+ 634,
+ - 811,
+ - 987,
+ - 902,
+ - 323,
+ 203,
+ 26,
+ - 383,
+ - 235,
+ - 781,
+ - 399,
+ 1262,
+ 906,
+ - 932,
+ - 1399,
+ - 1380,
+ - 624,
+ 93,
+ 87,
+ - 414,
+ - 539,
+ - 691,
+ 37,
+ 633,
+ 510,
+ - 387,
+ - 476,
+ - 1330,
+ 399,
+ 66,
+ 263,
+ - 407,
+ - 49,
+ - 335,
+ - 417,
+ 1041,
+ 1865,
+ - 779,
+ - 1089,
+ - 1440,
+ - 746,
+ - 858,
+ 832,
+ - 581,
+ - 759,
+ - 371,
+ - 673,
+ - 506,
+ 2088,
+ - 560,
+ - 634,
+ - 1179,
+ 271,
+ 241,
+ 14,
+ - 438,
+ - 244,
+ - 397,
+ 463,
+ 1202,
+ 1047,
+ - 606,
+ - 797,
+ - 1438,
+ - 51,
+ - 323,
+ 481,
+ - 224,
+ - 584,
+ - 527,
+ 494,
+ 881,
+ 682,
+ - 433,
+ - 306,
+ - 1002,
+ 554,
+ 659,
+ 222,
+ 171,
+ - 160,
+ - 353,
+ 681,
+ 1798,
+ 1565,
+ - 852,
+ - 1181,
+ - 1695,
+ - 336,
+ - 666,
+ 114,
+ - 581,
+ - 756,
+ - 744,
+ - 195,
+ 375,
+ 497,
+ - 465,
+ - 804,
+ - 1098,
+ 154,
+ 282,
+ - 131,
+ - 50,
+ - 191,
+ - 719,
+ 323,
+ 732,
+ 1542,
+ - 722,
+ - 819,
+ - 1404,
+ 105,
+ - 250,
+ 185,
+ - 178,
+ - 502,
+ - 742,
+ 321,
+ 510,
+ 1111,
+ - 323,
+ - 567,
+ - 966,
+ 127,
+ 484,
+ 338,
+ - 160,
+ 52,
+ - 338,
+ 732,
+ 1367,
+ 1554,
+ - 626,
+ - 802,
+ - 1696,
+ - 286,
+ - 586,
+ 676,
+ - 695,
+ - 343,
+ - 370,
+ - 490,
+ 295,
+ 1893,
+ - 630,
+ - 574,
+ - 1014,
+ - 80,
+ 645,
+ - 69,
+ - 6,
+ - 318,
+ - 364,
+ 782,
+ 1450,
+ 1038,
+ - 313,
+ - 733,
+ - 1395,
+ 120,
+ 60,
+ 477,
+ - 264,
+ - 585,
+ - 123,
+ 711,
+ 1245,
+ 633,
+ - 91,
+ - 355,
+ - 1016,
+ 771,
+ 758,
+ 261,
+ 253,
+ 81,
+ - 474,
+ 930,
+ 2215,
+ 1720,
+ - 808,
+ - 1099,
+ - 1925,
+ - 560,
+ - 782,
+ 169,
+ - 804,
+ - 1074,
+ - 188,
+ - 626,
+ - 55,
+ 1405,
+ - 694,
+ - 716,
+ - 1194,
+ - 660,
+ 354,
+ 329,
+ - 514,
+ - 55,
+ - 543,
+ 366,
+ 1033,
+ 1182,
+ - 658,
+ - 959,
+ - 1357,
+ - 55,
+ - 184,
+ 93,
+ - 605,
+ - 286,
+ - 662,
+ 404,
+ 449,
+ 827,
+ - 286,
+ - 350,
+ - 1263,
+ 628,
+ 306,
+ 227,
+ - 16,
+ 147,
+ - 623,
+ 186,
+ 923,
+ 2146,
+ - 674,
+ - 890,
+ - 1606,
+ - 443,
+ - 228,
+ 339,
+ - 369,
+ - 790,
+ - 409,
+ 231,
+ 86,
+ 1469,
+ - 448,
+ - 581,
+ - 1061,
+ 594,
+ 450,
+ - 177,
+ - 124,
+ - 170,
+ - 447,
+ 671,
+ 1159,
+ 1404,
+ - 476,
+ - 667,
+ - 1511,
+ - 77,
+ - 138,
+ 716,
+ - 177,
+ - 372,
+ - 381,
+ 451,
+ 934,
+ 915,
+ - 250,
+ - 432,
+ - 822,
+ 272,
+ 828,
+ 446,
+ 26,
+ 19,
+ - 31,
+ 698,
+ 1692,
+ 2168,
+ - 646,
+ - 977,
+ - 1924,
+ - 179,
+ - 473,
+ 268,
+ - 379,
+ - 745,
+ - 691,
+ 11,
+ 127,
+ 1033,
+ - 488,
+ - 917,
+ - 825,
+ 61,
+ 323,
+ 135,
+ 147,
+ - 145,
+ - 686,
+ 685,
+ 786,
+ 1682,
+ - 506,
+ - 848,
+ - 1297,
+ 35,
+ 90,
+ 222,
+ - 23,
+ - 346,
+ - 670,
+ 455,
+ 591,
+ 1287,
+ - 203,
+ - 593,
+ - 1086,
+ 652,
+ 352,
+ 437,
+ 39,
+ 63,
+ - 457,
+ 841,
+ 1265,
+ 2105,
+ - 520,
+ - 882,
+ - 1584,
+ - 328,
+ - 711,
+ 1421,
+ - 596,
+ - 342,
+ - 70,
+ 209,
+ 173,
+ 1928,
+ - 423,
+ - 598,
+ - 921,
+ 421,
+ 605,
+ - 38,
+ - 2,
+ - 245,
+ - 127,
+ 896,
+ 1969,
+ 1135,
+ - 379,
+ - 518,
+ - 1579,
+ 173,
+ 118,
+ 753,
+ - 55,
+ - 381,
+ - 52,
+ 985,
+ 1021,
+ 753,
+ - 2,
+ - 291,
+ - 891,
+ 753,
+ 992,
+ 423,
+ 264,
+ 131,
+ - 196,
+ 895,
+ 2274,
+ 2543,
+ - 635,
+ - 1088,
+ - 2499,
+ - 529,
+ - 982,
+ 526,
+ - 764,
+ - 830,
+ - 548,
+ - 436,
+ 316,
+ 599,
+ - 675,
+ - 940,
+ - 746,
+ - 57,
+ 236,
+ - 11,
+ - 201,
+ - 81,
+ - 798,
+ 16,
+ 845,
+ 1558,
+ - 737,
+ - 985,
+ - 1212,
+ - 468,
+ 17,
+ 290,
+ - 279,
+ - 584,
+ - 700,
+ 183,
+ 822,
+ 705,
+ - 265,
+ - 492,
+ - 1187,
+ 421,
+ 152,
+ 468,
+ - 390,
+ 166,
+ - 268,
+ 39,
+ 1550,
+ 1868,
+ - 635,
+ - 966,
+ - 1571,
+ - 453,
+ - 492,
+ 910,
+ - 284,
+ - 1027,
+ - 75,
+ - 181,
+ - 133,
+ 1852,
+ - 445,
+ - 624,
+ - 1174,
+ 420,
+ 367,
+ - 49,
+ - 389,
+ - 212,
+ - 169,
+ 707,
+ 1073,
+ 1208,
+ - 539,
+ - 710,
+ - 1449,
+ 83,
+ - 163,
+ 484,
+ - 236,
+ - 543,
+ - 355,
+ 338,
+ 1175,
+ 814,
+ - 246,
+ - 309,
+ - 958,
+ 606,
+ 760,
+ 60,
+ 166,
+ - 8,
+ - 163,
+ - 306,
+ 1849,
+ 2563,
+ - 747,
+ - 1025,
+ - 1783,
+ - 419,
+ - 446,
+ 209,
+ - 718,
+ - 566,
+ - 534,
+ - 506,
+ 693,
+ 857,
+ - 463,
+ - 697,
+ - 1082,
+ 325,
+ 431,
+ - 206,
+ - 15,
+ - 8,
+ - 763,
+ 545,
+ 919,
+ 1518,
+ - 611,
+ - 783,
+ - 1313,
+ 256,
+ - 55,
+ 208,
+ - 165,
+ - 348,
+ - 662,
+ 321,
+ 680,
+ 930,
+ - 326,
+ - 429,
+ - 951,
+ 484,
+ 446,
+ 570,
+ - 197,
+ 72,
+ - 73,
+ 909,
+ 1455,
+ 1741,
+ - 563,
+ - 737,
+ - 1974,
+ - 124,
+ - 416,
+ 718,
+ - 478,
+ - 404,
+ - 314,
+ - 16,
+ 446,
+ 1636,
+ - 551,
+ - 537,
+ - 750,
+ - 58,
+ 638,
+ 214,
+ 55,
+ - 185,
+ - 271,
+ 1148,
+ 1301,
+ 1212,
+ - 483,
+ - 671,
+ - 1264,
+ 117,
+ 285,
+ 543,
+ - 204,
+ - 391,
+ - 111,
+ 513,
+ 1538,
+ 854,
+ - 114,
+ - 190,
+ - 978,
+ 877,
+ 595,
+ 464,
+ 260,
+ 260,
+ - 311,
+ 748,
+ 2283,
+ 2216,
+ - 517,
+ - 945,
+ - 2171,
+ - 326,
+ - 708,
+ 378,
+ - 812,
+ - 691,
+ - 232,
+ - 560,
+ 687,
+ 1409,
+ - 732,
+ - 690,
+ - 836,
+ - 359,
+ 645,
+ 386,
+ - 265,
+ 62,
+ - 678,
+ 145,
+ 1644,
+ 1208,
+ - 555,
+ - 988,
+ - 1233,
+ - 78,
+ 14,
+ 114,
+ - 327,
+ - 358,
+ - 489,
+ 392,
+ 677,
+ 697,
+ - 201,
+ - 236,
+ - 1140,
+ 693,
+ 449,
+ 178,
+ - 243,
+ 256,
+ - 433,
+ 611,
+ 1385,
+ 2456,
+ - 612,
+ - 901,
+ - 1464,
+ - 307,
+ - 17,
+ 499,
+ - 315,
+ - 667,
+ - 254,
+ 256,
+ 428,
+ 1463,
+ - 486,
+ - 422,
+ - 1056,
+ 655,
+ 370,
+ 18,
+ - 102,
+ - 185,
+ - 276,
+ 755,
+ 1578,
+ 1335,
+ - 488,
+ - 603,
+ - 1418,
+ 182,
+ - 93,
+ 870,
+ - 73,
+ - 458,
+ - 348,
+ 835,
+ 862,
+ 957,
+ - 282,
+ - 333,
+ - 746,
+ 547,
+ 839,
+ 428,
+ 273,
+ - 89,
+ 13,
+ 940,
+ 1708,
+ 2576,
+ - 418,
+ - 1084,
+ - 1758,
+ - 44,
+ - 358,
+ 259,
+ - 497,
+ - 643,
+ - 560,
+ 99,
+ 557,
+ 961,
+ - 421,
+ - 766,
+ - 917,
+ 295,
+ 326,
+ 184,
+ 175,
+ 15,
+ - 626,
+ 532,
+ 878,
+ 1981,
+ - 443,
+ - 768,
+ - 1275,
+ 221,
+ 156,
+ 268,
+ 39,
+ - 363,
+ - 505,
+ 695,
+ 772,
+ 1140,
+ - 162,
+ - 459,
+ - 912,
+ 709,
+ 444,
+ 658,
+ 25,
+ 303,
+ - 312,
+ 1268,
+ 1410,
+ 1715,
+ - 297,
+ - 766,
+ - 1836,
+ - 263,
+ - 108,
+ 1070,
+ - 406,
+ - 13,
+ - 129,
+ 57,
+ 438,
+ 2734,
+ - 374,
+ - 487,
+ - 835,
+ 304,
+ 696,
+ 164,
+ 104,
+ - 235,
+ 5,
+ 1611,
+ 1900,
+ 1399,
+ - 229,
+ - 582,
+ - 1325,
+ 405,
+ 192,
+ 817,
+ - 87,
+ - 438,
+ 111,
+ 1028,
+ 1199,
+ 993,
+ 68,
+ - 175,
+ - 934,
+ 1033,
+ 1117,
+ 451,
+ 478,
+ 200,
+ - 248,
+ 2127,
+ 2696,
+ 2042,
+ - 835,
+ - 1323,
+ - 2131,
+ - 799,
+ - 692,
+ 466,
+ - 812,
+ - 1032,
+ - 469,
+ - 622,
+ 288,
+ 920,
+ - 701,
+ - 841,
+ - 1070,
+ - 411,
+ 512,
+ 8,
+ - 390,
+ - 91,
+ - 744,
+ - 30,
+ 1043,
+ 1161,
+ - 822,
+ - 1148,
+ - 1156,
+ - 294,
+ - 46,
+ 110,
+ - 411,
+ - 374,
+ - 678,
+ 214,
+ 531,
+ 668,
+ - 406,
+ - 420,
+ - 1194,
+ 487,
+ 232,
+ 303,
+ - 318,
+ 91,
+ - 472,
+ 123,
+ 1232,
+ 2445,
+ - 722,
+ - 952,
+ - 1495,
+ - 738,
+ - 675,
+ 1332,
+ - 543,
+ - 606,
+ - 211,
+ - 95,
+ - 98,
+ 1508,
+ - 549,
+ - 514,
+ - 1193,
+ 473,
+ 211,
+ 73,
+ - 288,
+ - 112,
+ - 389,
+ 537,
+ 1332,
+ 1258,
+ - 567,
+ - 755,
+ - 1545,
+ 71,
+ - 283,
+ 632,
+ - 170,
+ - 481,
+ - 493,
+ 681,
+ 1002,
+ 817,
+ - 356,
+ - 331,
+ - 877,
+ 419,
+ 706,
+ 346,
+ 241,
+ - 34,
+ - 326,
+ 377,
+ 1950,
+ 1883,
+ - 727,
+ - 1075,
+ - 1625,
+ - 233,
+ - 543,
+ 116,
+ - 524,
+ - 806,
+ - 585,
+ - 73,
+ 478,
+ 729,
+ - 288,
+ - 925,
+ - 1143,
+ 173,
+ 447,
+ - 52,
+ 68,
+ - 229,
+ - 606,
+ 449,
+ 529,
+ 1797,
+ - 591,
+ - 875,
+ - 1363,
+ 183,
+ - 144,
+ 324,
+ - 103,
+ - 452,
+ - 666,
+ 623,
+ 488,
+ 1176,
+ - 238,
+ - 511,
+ - 1004,
+ 326,
+ 552,
+ 458,
+ 136,
+ 108,
+ - 319,
+ 626,
+ 1343,
+ 1883,
+ - 490,
+ - 646,
+ - 1730,
+ - 186,
+ - 449,
+ 984,
+ - 738,
+ - 76,
+ - 170,
+ - 550,
+ 755,
+ 2560,
+ - 496,
+ - 510,
+ - 947,
+ 210,
+ 694,
+ - 52,
+ 84,
+ - 322,
+ - 199,
+ 1090,
+ 1625,
+ 1224,
+ - 376,
+ - 603,
+ - 1396,
+ 343,
+ 74,
+ 632,
+ - 175,
+ - 502,
+ - 32,
+ 972,
+ 1332,
+ 734,
+ 52,
+ - 295,
+ - 1113,
+ 1065,
+ 918,
+ 160,
+ 393,
+ 107,
+ - 397,
+ 1214,
+ 2649,
+ 1741,
+ - 632,
+ - 1201,
+ - 1891,
+ - 719,
+ - 277,
+ 353,
+ - 651,
+ - 880,
+ - 122,
+ - 211,
+ 209,
+ 1338,
+ - 562,
+ - 714,
+ - 1059,
+ - 208,
+ 388,
+ 159,
+ - 320,
+ - 61,
+ - 551,
+ 293,
+ 1092,
+ 1443,
+ - 648,
+ - 865,
+ - 1253,
+ - 49,
+ - 143,
+ 305,
+ - 401,
+ - 227,
+ - 585,
+ 561,
+ 532,
+ 927,
+ - 117,
+ - 443,
+ - 1188,
+ 507,
+ 436,
+ 292,
+ - 79,
+ 233,
+ - 458,
+ 671,
+ 1025,
+ 2396,
+ - 633,
+ - 842,
+ - 1525,
+ - 308,
+ - 286,
+ 640,
+ - 373,
+ - 621,
+ - 407,
+ 418,
+ 253,
+ 1305,
+ - 315,
+ - 581,
+ - 1137,
+ 572,
+ 685,
+ - 281,
+ 61,
+ - 68,
+ - 371,
+ 991,
+ 1101,
+ 1498,
+ - 493,
+ - 683,
+ - 1362,
+ - 47,
+ 164,
+ 704,
+ - 256,
+ - 314,
+ - 268,
+ 631,
+ 949,
+ 1052,
+ - 118,
+ - 348,
+ - 833,
+ 68,
+ 1180,
+ 568,
+ 152,
+ 117,
+ 34,
+ 1113,
+ 1902,
+ 2239,
+ - 601,
+ - 959,
+ - 1706,
+ - 143,
+ - 489,
+ 480,
+ - 332,
+ - 655,
+ - 574,
+ 54,
+ 353,
+ 1192,
+ - 462,
+ - 652,
+ - 796,
+ 150,
+ 549,
+ 112,
+ 195,
+ - 111,
+ - 515,
+ 679,
+ 1108,
+ 1647,
+ - 558,
+ - 749,
+ - 1217,
+ - 9,
+ 272,
+ 341,
+ - 53,
+ - 265,
+ - 535,
+ 489,
+ 843,
+ 1298,
+ - 120,
+ - 482,
+ - 1032,
+ 632,
+ 543,
+ 408,
+ 179,
+ 306,
+ - 526,
+ 1124,
+ 1464,
+ 2244,
+ - 417,
+ - 786,
+ - 1562,
+ - 224,
+ - 384,
+ 1364,
+ - 377,
+ - 459,
+ - 25,
+ 385,
+ 489,
+ 2174,
+ - 332,
+ - 651,
+ - 829,
+ 544,
+ 553,
+ 61,
+ 22,
+ - 113,
+ - 89,
+ 1128,
+ 1725,
+ 1524,
+ - 216,
+ - 373,
+ - 1653,
+ 161,
+ 316,
+ 908,
+ - 165,
+ - 222,
+ - 67,
+ 1362,
+ 1175,
+ 789,
+ 73,
+ - 252,
+ - 767,
+ 738,
+ 932,
+ 616,
+ 362,
+ 246,
+ - 126,
+ 787,
+ 2654,
+ 3027,
+ - 691,
+ - 1106,
+ - 2190,
+ - 565,
+ - 588,
+ 524,
+ - 590,
+ - 979,
+ - 490,
+ - 263,
+ 397,
+ 982,
+ - 577,
+ - 837,
+ - 945,
+ - 22,
+ 435,
+ - 49,
+ - 190,
+ - 118,
+ - 629,
+ - 88,
+ 1240,
+ 1513,
+ - 636,
+ - 1051,
+ - 1019,
+ - 291,
+ 189,
+ 259,
+ - 257,
+ - 470,
+ - 629,
+ 145,
+ 945,
+ 894,
+ - 326,
+ - 364,
+ - 1094,
+ 543,
+ 260,
+ 630,
+ - 202,
+ 189,
+ - 209,
+ 357,
+ 1379,
+ 2091,
+ - 569,
+ - 1075,
+ - 1449,
+ - 714,
+ - 239,
+ 919,
+ - 420,
+ - 705,
+ - 84,
+ - 109,
+ - 114,
+ 2407,
+ - 413,
+ - 529,
+ - 1177,
+ 482,
+ 368,
+ 131,
+ - 186,
+ - 72,
+ - 131,
+ 861,
+ 1255,
+ 1220,
+ - 611,
+ - 658,
+ - 1341,
+ 227,
+ - 121,
+ 631,
+ - 176,
+ - 489,
+ - 218,
+ 745,
+ 1175,
+ 957,
+ - 321,
+ - 148,
+ - 936,
+ 671,
+ 966,
+ 216,
+ 340,
+ - 3,
+ - 143,
+ 469,
+ 1848,
+ 2437,
+ - 729,
+ - 961,
+ - 1683,
+ - 213,
+ - 254,
+ 321,
+ - 511,
+ - 438,
+ - 521,
+ - 126,
+ 725,
+ 903,
+ - 340,
+ - 685,
+ - 1032,
+ 316,
+ 480,
+ 20,
+ 23,
+ - 89,
+ - 551,
+ 353,
+ 1051,
+ 1789,
+ - 544,
+ - 757,
+ - 1364,
+ 298,
+ - 25,
+ 436,
+ - 100,
+ - 392,
+ - 519,
+ 467,
+ 754,
+ 1078,
+ - 210,
+ - 398,
+ - 1078,
+ 620,
+ 658,
+ 630,
+ 33,
+ 147,
+ - 178,
+ 921,
+ 1687,
+ 1921,
+ - 325,
+ - 528,
+ - 1978,
+ 2,
+ - 285,
+ 910,
+ - 371,
+ - 490,
+ - 230,
+ 0,
+ 597,
+ 2010,
+ - 496,
+ - 395,
+ - 834,
+ 37,
+ 945,
+ 245,
+ 181,
+ - 160,
+ - 144,
+ 1481,
+ 1373,
+ 1357,
+ - 355,
+ - 601,
+ - 1270,
+ 298,
+ 322,
+ 672,
+ - 193,
+ - 336,
+ 77,
+ 1089,
+ 1533,
+ 922,
+ 177,
+ - 39,
+ - 1125,
+ 996,
+ 781,
+ 536,
+ 456,
+ 366,
+ - 432,
+ 1415,
+ 2440,
+ 2279,
+ - 466,
+ - 758,
+ - 2325,
+ - 303,
+ - 509,
+ 387,
+ - 727,
+ - 557,
+ 66,
+ - 145,
+ 643,
+ 1248,
+ - 544,
+ - 676,
+ - 916,
+ - 225,
+ 862,
+ 588,
+ - 152,
+ 40,
+ - 533,
+ 423,
+ 1423,
+ 1558,
+ - 572,
+ - 843,
+ - 1145,
+ - 128,
+ 85,
+ 461,
+ - 238,
+ - 257,
+ - 584,
+ 605,
+ 748,
+ 861,
+ 24,
+ - 202,
+ - 1409,
+ 797,
+ 487,
+ 303,
+ - 181,
+ 364,
+ - 182,
+ 616,
+ 1378,
+ 2942,
+ - 494,
+ - 852,
+ - 1441,
+ - 292,
+ 61,
+ 812,
+ - 84,
+ - 723,
+ - 182,
+ 555,
+ 532,
+ 1506,
+ - 365,
+ - 493,
+ - 1057,
+ 822,
+ 588,
+ 11,
+ - 14,
+ - 18,
+ - 230,
+ 1001,
+ 1401,
+ 1451,
+ - 474,
+ - 569,
+ - 1292,
+ 302,
+ 62,
+ 1062,
+ - 70,
+ - 376,
+ - 222,
+ 982,
+ 974,
+ 1149,
+ - 196,
+ - 234,
+ - 795,
+ 479,
+ 1098,
+ 499,
+ 362,
+ 58,
+ 70,
+ 1147,
+ 2069,
+ 2857,
+ - 487,
+ - 878,
+ - 1824,
+ 73,
+ - 288,
+ 348,
+ - 358,
+ - 500,
+ - 508,
+ 199,
+ 721,
+ 1242,
+ - 78,
+ - 697,
+ - 795,
+ 361,
+ 536,
+ 196,
+ 374,
+ 110,
+ - 735,
+ 847,
+ 1051,
+ 1896,
+ - 366,
+ - 713,
+ - 1182,
+ 315,
+ 320,
+ 429,
+ 72,
+ - 215,
+ - 450,
+ 759,
+ 886,
+ 1363,
+ - 30,
+ - 428,
+ - 834,
+ 861,
+ 627,
+ 796,
+ 118,
+ 468,
+ - 279,
+ 1355,
+ 1883,
+ 1893,
+ - 188,
+ - 642,
+ - 1612,
+ 63,
+ - 175,
+ 1198,
+ - 418,
+ - 211,
+ 51,
+ 414,
+ 587,
+ 2601,
+ - 234,
+ - 557,
+ - 858,
+ 424,
+ 889,
+ 222,
+ 136,
+ - 101,
+ 83,
+ 1413,
+ 2278,
+ 1383,
+ - 84,
+ - 445,
+ - 1389,
+ 414,
+ 313,
+ 1045,
+ 29,
+ - 343,
+ 65,
+ 1552,
+ 1647,
+ 980,
+ 183,
+ - 91,
+ - 829,
+ 1273,
+ 1413,
+ 360,
+ 553,
+ 272,
+ - 107,
+ 1587,
+ 3149,
+ 2603
+};
+#define DICO1_SIZE_5 128
+#define DICO2_SIZE_5 256
+#define DICO3_SIZE_5 256
+#define DICO4_SIZE_5 256
+#define DICO5_SIZE_5 64
+
+/* 1st LSF quantizer (MR122) */
+static const Word32 dico1_lsf_5[DICO1_SIZE_5 * 4] = {
+ - 451,
+ - 1065,
+ - 529,
+ - 1305,
+ - 450,
+ - 756,
+ - 497,
+ - 863,
+ - 384,
+ - 619,
+ - 413,
+ - 669,
+ - 317,
+ - 538,
+ - 331,
+ - 556,
+ - 414,
+ - 508,
+ - 424,
+ - 378,
+ - 274,
+ - 324,
+ - 434,
+ - 614,
+ - 226,
+ - 500,
+ - 232,
+ - 514,
+ - 263,
+ - 377,
+ - 298,
+ - 410,
+ - 151,
+ - 710,
+ - 174,
+ - 818,
+ - 149,
+ - 412,
+ - 156,
+ - 429,
+ - 288,
+ - 462,
+ - 186,
+ - 203,
+ - 170,
+ - 302,
+ - 191,
+ - 321,
+ - 131,
+ - 147,
+ - 297,
+ - 395,
+ - 228,
+ - 214,
+ - 245,
+ - 192,
+ - 67,
+ - 316,
+ - 71,
+ - 327,
+ - 104,
+ - 205,
+ - 94,
+ - 183,
+ - 143,
+ - 38,
+ - 193,
+ - 95,
+ 16,
+ - 76,
+ - 124,
+ - 248,
+ 23,
+ - 237,
+ 24,
+ - 244,
+ 18,
+ - 136,
+ 44,
+ - 111,
+ - 33,
+ - 24,
+ - 25,
+ 0,
+ 149,
+ 19,
+ 23,
+ - 143,
+ 158,
+ - 169,
+ 174,
+ - 181,
+ 133,
+ - 55,
+ 165,
+ - 26,
+ 111,
+ 84,
+ 98,
+ 75,
+ 87,
+ 183,
+ - 115,
+ - 11,
+ - 8,
+ 130,
+ 11,
+ 170,
+ 254,
+ 77,
+ 205,
+ 17,
+ 183,
+ 112,
+ 262,
+ 194,
+ 202,
+ 287,
+ 95,
+ 189,
+ - 42,
+ - 105,
+ 234,
+ 179,
+ 39,
+ 186,
+ 163,
+ 345,
+ 332,
+ 199,
+ 299,
+ 161,
+ - 54,
+ 285,
+ - 78,
+ 281,
+ - 133,
+ 141,
+ - 182,
+ 111,
+ 249,
+ 341,
+ 271,
+ 364,
+ 93,
+ 403,
+ 75,
+ 391,
+ 92,
+ 510,
+ - 138,
+ 220,
+ - 185,
+ - 29,
+ - 34,
+ 361,
+ - 115,
+ 320,
+ 3,
+ 554,
+ 99,
+ 286,
+ 218,
+ 591,
+ - 245,
+ 406,
+ - 268,
+ 453,
+ 0,
+ 580,
+ 25,
+ 606,
+ 275,
+ 532,
+ 148,
+ 450,
+ - 73,
+ 739,
+ - 285,
+ 518,
+ - 288,
+ 94,
+ - 203,
+ 674,
+ - 140,
+ - 74,
+ 205,
+ 714,
+ - 114,
+ 299,
+ 176,
+ 923,
+ 182,
+ 557,
+ 240,
+ 705,
+ - 16,
+ 513,
+ 485,
+ 593,
+ 293,
+ 384,
+ 451,
+ 617,
+ - 38,
+ 50,
+ 563,
+ 529,
+ 303,
+ 209,
+ 459,
+ 363,
+ 433,
+ 452,
+ 450,
+ 454,
+ 367,
+ 606,
+ 477,
+ 741,
+ 432,
+ 353,
+ 368,
+ 267,
+ 361,
+ 716,
+ 273,
+ 583,
+ 453,
+ 166,
+ 510,
+ 172,
+ 201,
+ 629,
+ 274,
+ 191,
+ 568,
+ 639,
+ 302,
+ 298,
+ 634,
+ 387,
+ 643,
+ 350,
+ 587,
+ 560,
+ 612,
+ 565,
+ 600,
+ 788,
+ 487,
+ 672,
+ 512,
+ 1015,
+ 321,
+ 333,
+ 357,
+ 854,
+ - 125,
+ 413,
+ 474,
+ 712,
+ 17,
+ - 151,
+ 564,
+ 285,
+ 270,
+ - 241,
+ 971,
+ 889,
+ 489,
+ 220,
+ 510,
+ 896,
+ 549,
+ 924,
+ 327,
+ 825,
+ 290,
+ 911,
+ 540,
+ 1108,
+ 158,
+ 805,
+ 199,
+ 957,
+ 511,
+ 730,
+ 100,
+ 874,
+ 13,
+ 791,
+ 435,
+ 632,
+ 676,
+ 972,
+ 249,
+ 900,
+ 467,
+ 1218,
+ 781,
+ 1074,
+ 585,
+ 785,
+ - 23,
+ 669,
+ 267,
+ 1043,
+ 619,
+ 1084,
+ 615,
+ 1145,
+ 622,
+ 905,
+ 916,
+ 1049,
+ 80,
+ 331,
+ 584,
+ 1075,
+ 89,
+ 639,
+ 988,
+ 961,
+ 770,
+ 720,
+ 798,
+ 699,
+ 492,
+ 447,
+ 899,
+ 627,
+ 271,
+ 1188,
+ 725,
+ 1333,
+ 87,
+ 603,
+ 832,
+ 1603,
+ 616,
+ 1127,
+ 890,
+ 1505,
+ 1000,
+ 1156,
+ 866,
+ 1009,
+ 995,
+ 827,
+ 1149,
+ 858,
+ 817,
+ 1450,
+ 773,
+ 1320,
+ 500,
+ 1389,
+ 312,
+ 1153,
+ - 20,
+ 1084,
+ 64,
+ 1283,
+ 2,
+ 1172,
+ 399,
+ 1869,
+ 514,
+ 1706,
+ 502,
+ 1636,
+ 886,
+ 1522,
+ 416,
+ 600,
+ 1131,
+ 1350,
+ 1275,
+ 1390,
+ 889,
+ 1795,
+ 914,
+ 1766,
+ 227,
+ 1183,
+ 1250,
+ 1826,
+ 505,
+ 1854,
+ 919,
+ 2353,
+ - 199,
+ 431,
+ 152,
+ 1735,
+ - 213,
+ - 28,
+ 392,
+ 1334,
+ - 153,
+ - 52,
+ 978,
+ 1151,
+ - 323,
+ - 400,
+ 813,
+ 1703,
+ - 136,
+ 84,
+ 1449,
+ 2015,
+ - 331,
+ - 143,
+ - 137,
+ 1192,
+ - 256,
+ 534,
+ - 157,
+ 1031,
+ - 307,
+ - 439,
+ 542,
+ 731,
+ - 329,
+ - 420,
+ - 97,
+ 616,
+ - 362,
+ - 168,
+ - 322,
+ 366,
+ - 247,
+ - 110,
+ - 211,
+ 89,
+ - 196,
+ - 309,
+ 20,
+ 59,
+ - 364,
+ - 463,
+ - 286,
+ 89,
+ - 336,
+ 175,
+ - 432,
+ 141,
+ - 379,
+ - 190,
+ - 434,
+ - 196,
+ - 79,
+ 150,
+ - 278,
+ - 227,
+ - 280,
+ 166,
+ - 555,
+ - 422,
+ - 155,
+ 541,
+ - 366,
+ 54,
+ - 29,
+ - 83,
+ - 301,
+ - 774,
+ 186,
+ 628,
+ - 397,
+ - 264,
+ 242,
+ 293,
+ - 197,
+ - 585,
+ 124,
+ 410,
+ 53,
+ - 133,
+ 10,
+ 340,
+ - 570,
+ - 1065,
+ 65,
+ - 446,
+ 68,
+ - 493,
+ 383,
+ 937,
+ - 357,
+ - 711,
+ - 359,
+ - 250,
+ - 677,
+ - 1068,
+ 292,
+ - 26,
+ 363,
+ 6,
+ 607,
+ 1313,
+ - 127,
+ - 10,
+ 1513,
+ 1886,
+ 713,
+ 972,
+ 1469,
+ 2181,
+ 1443,
+ 2016
+};
+
+/* 2nd LSF quantizer (MR122) */
+static const Word32 dico2_lsf_5[DICO2_SIZE_5 * 4] = {
+ - 1631,
+ - 1600,
+ - 1796,
+ - 2290,
+ - 1027,
+ - 1770,
+ - 1100,
+ - 2025,
+ - 1277,
+ - 1388,
+ - 1367,
+ - 1534,
+ - 947,
+ - 1461,
+ - 972,
+ - 1524,
+ - 999,
+ - 1222,
+ - 1020,
+ - 1172,
+ - 815,
+ - 987,
+ - 992,
+ - 1371,
+ - 1216,
+ - 1006,
+ - 1289,
+ - 1094,
+ - 744,
+ - 1268,
+ - 755,
+ - 1293,
+ - 862,
+ - 923,
+ - 905,
+ - 984,
+ - 678,
+ - 1051,
+ - 685,
+ - 1050,
+ - 1087,
+ - 985,
+ - 1062,
+ - 679,
+ - 989,
+ - 641,
+ - 1127,
+ - 976,
+ - 762,
+ - 654,
+ - 890,
+ - 806,
+ - 833,
+ - 1091,
+ - 706,
+ - 629,
+ - 621,
+ - 806,
+ - 640,
+ - 812,
+ - 775,
+ - 634,
+ - 779,
+ - 543,
+ - 996,
+ - 565,
+ - 1075,
+ - 580,
+ - 546,
+ - 611,
+ - 572,
+ - 619,
+ - 760,
+ - 290,
+ - 879,
+ - 526,
+ - 823,
+ - 462,
+ - 795,
+ - 253,
+ - 553,
+ - 415,
+ - 589,
+ - 439,
+ - 533,
+ - 340,
+ - 692,
+ - 935,
+ - 505,
+ - 772,
+ - 702,
+ - 1131,
+ - 263,
+ - 306,
+ - 971,
+ - 483,
+ - 445,
+ - 74,
+ - 555,
+ - 548,
+ - 614,
+ - 129,
+ - 693,
+ - 234,
+ - 396,
+ - 246,
+ - 475,
+ - 250,
+ - 265,
+ - 404,
+ - 376,
+ - 514,
+ - 417,
+ - 510,
+ - 300,
+ - 313,
+ - 334,
+ - 664,
+ - 463,
+ - 814,
+ - 386,
+ - 704,
+ - 337,
+ - 615,
+ - 234,
+ - 201,
+ - 233,
+ - 239,
+ - 167,
+ - 567,
+ - 203,
+ - 619,
+ - 147,
+ - 415,
+ - 115,
+ - 352,
+ - 166,
+ - 750,
+ - 171,
+ - 761,
+ - 270,
+ - 879,
+ - 264,
+ - 903,
+ - 367,
+ - 744,
+ 43,
+ - 475,
+ 14,
+ - 653,
+ 43,
+ - 670,
+ 11,
+ - 448,
+ - 59,
+ - 521,
+ - 126,
+ - 119,
+ - 155,
+ - 613,
+ - 42,
+ - 863,
+ - 27,
+ - 931,
+ 136,
+ - 483,
+ 183,
+ - 468,
+ 55,
+ - 298,
+ 55,
+ - 304,
+ 313,
+ - 609,
+ 313,
+ - 720,
+ 322,
+ - 167,
+ 100,
+ - 541,
+ - 3,
+ - 119,
+ - 111,
+ - 187,
+ 233,
+ - 236,
+ 260,
+ - 234,
+ 26,
+ - 165,
+ 134,
+ - 45,
+ - 40,
+ - 549,
+ 360,
+ - 203,
+ 378,
+ - 388,
+ 450,
+ - 383,
+ 275,
+ 20,
+ 182,
+ - 103,
+ 246,
+ - 111,
+ 431,
+ 37,
+ 462,
+ - 146,
+ 487,
+ - 157,
+ - 284,
+ - 59,
+ 503,
+ - 184,
+ 24,
+ 53,
+ - 3,
+ 54,
+ 122,
+ 259,
+ 333,
+ 66,
+ 484,
+ 104,
+ 436,
+ 68,
+ 195,
+ 116,
+ 190,
+ 206,
+ 269,
+ - 9,
+ 482,
+ 352,
+ 382,
+ 285,
+ 399,
+ 277,
+ 452,
+ 256,
+ 69,
+ 186,
+ 13,
+ 297,
+ - 13,
+ 259,
+ - 95,
+ 30,
+ 56,
+ 394,
+ 196,
+ 425,
+ 205,
+ 456,
+ 281,
+ 577,
+ 15,
+ 191,
+ 375,
+ 290,
+ 407,
+ 576,
+ - 56,
+ 227,
+ 544,
+ 405,
+ 0,
+ 549,
+ - 92,
+ 528,
+ - 229,
+ 351,
+ - 245,
+ 338,
+ - 362,
+ 435,
+ 167,
+ 527,
+ - 75,
+ 302,
+ 91,
+ 824,
+ 129,
+ 599,
+ 496,
+ 679,
+ 186,
+ 749,
+ 153,
+ 737,
+ - 281,
+ 600,
+ - 348,
+ 615,
+ - 236,
+ 769,
+ 41,
+ 881,
+ 38,
+ 890,
+ - 220,
+ 841,
+ - 357,
+ 883,
+ - 393,
+ 903,
+ - 634,
+ 474,
+ - 444,
+ 850,
+ - 175,
+ 678,
+ - 493,
+ 242,
+ - 519,
+ 785,
+ - 714,
+ 582,
+ - 541,
+ 366,
+ - 543,
+ 434,
+ - 597,
+ 500,
+ - 765,
+ 222,
+ - 702,
+ 917,
+ - 743,
+ 962,
+ - 869,
+ 501,
+ - 899,
+ 548,
+ - 379,
+ 200,
+ - 435,
+ 157,
+ - 819,
+ 214,
+ - 861,
+ 157,
+ - 614,
+ 40,
+ - 632,
+ 94,
+ - 883,
+ - 54,
+ - 741,
+ 516,
+ - 501,
+ 298,
+ - 614,
+ - 171,
+ - 870,
+ - 161,
+ - 865,
+ - 23,
+ - 818,
+ 93,
+ - 1015,
+ - 267,
+ - 662,
+ - 359,
+ - 549,
+ 2,
+ - 442,
+ - 121,
+ - 377,
+ 0,
+ - 227,
+ 33,
+ - 414,
+ - 126,
+ - 129,
+ 212,
+ - 934,
+ 34,
+ - 1082,
+ - 282,
+ - 1119,
+ - 268,
+ - 710,
+ - 825,
+ - 420,
+ - 191,
+ - 1076,
+ - 928,
+ - 917,
+ - 93,
+ - 628,
+ - 358,
+ 97,
+ 7,
+ - 206,
+ - 393,
+ - 101,
+ 24,
+ - 203,
+ 38,
+ - 168,
+ 83,
+ - 599,
+ - 423,
+ - 279,
+ 426,
+ - 700,
+ 118,
+ - 75,
+ 206,
+ - 981,
+ - 673,
+ - 680,
+ 417,
+ - 367,
+ 37,
+ - 279,
+ 474,
+ - 129,
+ - 318,
+ 319,
+ 296,
+ - 626,
+ - 39,
+ 343,
+ 602,
+ - 696,
+ - 39,
+ - 303,
+ 940,
+ 104,
+ 233,
+ - 380,
+ 137,
+ - 36,
+ 269,
+ - 75,
+ - 214,
+ 120,
+ 43,
+ - 529,
+ - 477,
+ 459,
+ 164,
+ - 202,
+ - 229,
+ - 49,
+ - 167,
+ 609,
+ 792,
+ 98,
+ - 220,
+ 915,
+ 148,
+ 293,
+ 283,
+ 869,
+ 91,
+ 575,
+ 394,
+ 326,
+ - 78,
+ 717,
+ 67,
+ 365,
+ - 323,
+ 616,
+ - 36,
+ 731,
+ 27,
+ 619,
+ 238,
+ 632,
+ 273,
+ 448,
+ 99,
+ 801,
+ 476,
+ 869,
+ 273,
+ 685,
+ 64,
+ 789,
+ 72,
+ 1021,
+ 217,
+ 793,
+ 459,
+ 734,
+ 360,
+ 646,
+ 480,
+ 360,
+ 322,
+ 429,
+ 464,
+ 638,
+ 430,
+ 756,
+ 363,
+ 1000,
+ 404,
+ 683,
+ 528,
+ 602,
+ 615,
+ 655,
+ 413,
+ 946,
+ 687,
+ 937,
+ 602,
+ 904,
+ 604,
+ 555,
+ 737,
+ 786,
+ 662,
+ 467,
+ 654,
+ 362,
+ 589,
+ 929,
+ 710,
+ 498,
+ 478,
+ 415,
+ 420,
+ 693,
+ 883,
+ 813,
+ 683,
+ 781,
+ 925,
+ 913,
+ 939,
+ 726,
+ 732,
+ 491,
+ 853,
+ 531,
+ 948,
+ 734,
+ 963,
+ 315,
+ 808,
+ 761,
+ 755,
+ 1144,
+ 760,
+ 655,
+ 1076,
+ 826,
+ 1057,
+ 1091,
+ 838,
+ 1003,
+ 808,
+ 1047,
+ 1133,
+ 659,
+ 1101,
+ 992,
+ 1050,
+ 1074,
+ 1075,
+ 971,
+ 694,
+ 1226,
+ 1054,
+ 571,
+ 841,
+ 884,
+ 1404,
+ 1379,
+ 1096,
+ 1080,
+ 861,
+ 1231,
+ 735,
+ 1284,
+ 760,
+ 1272,
+ 991,
+ 1367,
+ 1053,
+ 1257,
+ 700,
+ 1050,
+ 534,
+ 988,
+ 453,
+ 1264,
+ 599,
+ 1140,
+ 679,
+ 1621,
+ 815,
+ 1384,
+ 521,
+ 1317,
+ 393,
+ 1564,
+ 805,
+ 1448,
+ 686,
+ 1068,
+ 648,
+ 875,
+ 307,
+ 1083,
+ 361,
+ 1047,
+ 317,
+ 1417,
+ 964,
+ 675,
+ 571,
+ 1152,
+ 79,
+ 1114,
+ - 47,
+ 1530,
+ 311,
+ 1721,
+ 314,
+ 1166,
+ 689,
+ 514,
+ - 94,
+ 349,
+ 282,
+ 1412,
+ 328,
+ 1025,
+ 487,
+ - 65,
+ 57,
+ 805,
+ 970,
+ 36,
+ 62,
+ 769,
+ - 263,
+ 791,
+ - 346,
+ 637,
+ 699,
+ - 137,
+ 620,
+ 534,
+ 541,
+ - 735,
+ 194,
+ 711,
+ 300,
+ - 268,
+ - 863,
+ 926,
+ 769,
+ - 708,
+ - 428,
+ 506,
+ 174,
+ - 892,
+ - 630,
+ 435,
+ 547,
+ - 1435,
+ - 258,
+ 621,
+ 471,
+ - 1018,
+ - 1368,
+ - 393,
+ 521,
+ - 920,
+ - 686,
+ - 25,
+ 20,
+ - 982,
+ - 1156,
+ 340,
+ 9,
+ - 1558,
+ - 1135,
+ - 352,
+ 48,
+ - 1579,
+ - 402,
+ - 887,
+ 6,
+ - 1156,
+ - 888,
+ - 548,
+ - 352,
+ - 1643,
+ - 1168,
+ - 159,
+ 610,
+ - 2024,
+ - 963,
+ - 225,
+ 193,
+ - 1656,
+ - 1960,
+ - 245,
+ - 493,
+ - 964,
+ - 1680,
+ - 936,
+ - 635,
+ - 1299,
+ - 1744,
+ - 1388,
+ - 604,
+ - 1540,
+ - 835,
+ - 1397,
+ - 135,
+ - 1588,
+ - 290,
+ - 1670,
+ - 712,
+ - 2011,
+ - 1632,
+ - 1663,
+ - 27,
+ - 2258,
+ - 811,
+ - 1157,
+ 184,
+ - 1265,
+ 189,
+ - 1367,
+ 586,
+ - 2011,
+ 201,
+ - 790,
+ 712,
+ - 1210,
+ 3,
+ - 1033,
+ 808,
+ - 1251,
+ 830,
+ - 111,
+ 635,
+ - 1636,
+ 447,
+ - 463,
+ - 949,
+ - 445,
+ - 928,
+ - 504,
+ - 1162,
+ - 501,
+ - 1211,
+ 144,
+ - 351,
+ - 372,
+ - 1052,
+ - 283,
+ - 1059,
+ - 279,
+ - 1123,
+ - 575,
+ - 1438,
+ - 587,
+ - 1614,
+ - 935,
+ - 984,
+ 229,
+ 690,
+ - 921,
+ - 719,
+ - 403,
+ 1362,
+ - 685,
+ - 465,
+ 874,
+ 397,
+ - 509,
+ - 46,
+ 317,
+ 1334,
+ - 485,
+ 456,
+ 813,
+ 439,
+ - 411,
+ 339,
+ 898,
+ 1067,
+ - 425,
+ 46,
+ 1441,
+ 497,
+ - 909,
+ - 800,
+ 1465,
+ 1046,
+ - 254,
+ - 321,
+ 1430,
+ 1165,
+ 68,
+ 350,
+ 1034,
+ 666,
+ 370,
+ 11,
+ 1311,
+ 790,
+ 143,
+ 232,
+ 1041,
+ 1562,
+ - 114,
+ 663,
+ 1616,
+ 1078,
+ 454,
+ 579,
+ 1275,
+ 1040,
+ - 76,
+ 909,
+ 752,
+ 1067,
+ 153,
+ 512,
+ 348,
+ 1214,
+ 614,
+ 385,
+ 1843,
+ 808,
+ 269,
+ 1034,
+ 203,
+ 1086,
+ 652,
+ 1017,
+ 1783,
+ 1130,
+ 429,
+ 1327,
+ 387,
+ 1384,
+ - 49,
+ 1183,
+ - 72,
+ 1215,
+ - 416,
+ 1001,
+ 544,
+ 1749,
+ - 352,
+ 1223,
+ - 502,
+ 1199,
+ - 589,
+ 569,
+ - 227,
+ 1630,
+ - 142,
+ 1578,
+ - 230,
+ 1715,
+ - 714,
+ 1288,
+ - 838,
+ 1398,
+ 1131,
+ 1357,
+ - 208,
+ 1232,
+ 437,
+ 965,
+ - 929,
+ 818,
+ 811,
+ 1410,
+ 859,
+ 1507,
+ 164,
+ 1212,
+ 1387,
+ 1793,
+ 484,
+ 1874,
+ 456,
+ 2063,
+ 996,
+ 1170,
+ 1326,
+ 1402,
+ 1316,
+ 1360,
+ 1135,
+ 1262,
+ 1234,
+ 1618,
+ 1361,
+ 1768,
+ 1421,
+ 1227,
+ 1584,
+ 1347,
+ 854,
+ 672,
+ 1685,
+ 1566,
+ 1139,
+ 1270,
+ 2016,
+ 1825,
+ 1773,
+ 1581,
+ 1532,
+ 1460,
+ 1487,
+ 946,
+ 1659,
+ 1021,
+ 1744,
+ 1212,
+ 1392,
+ 977,
+ 1772,
+ 1161,
+ 1826,
+ 1164,
+ 1718,
+ 1429,
+ 1973,
+ 1591,
+ 1185,
+ 864,
+ 2132,
+ 1061,
+ 1799,
+ 814,
+ 1838,
+ 757,
+ 2104,
+ 1315,
+ 2054,
+ 1258,
+ 2113,
+ 915,
+ 2331,
+ 930,
+ 1467,
+ 1147,
+ 2590,
+ 1439,
+ 2245,
+ 1744,
+ 2090,
+ 1620,
+ 2358,
+ 1454,
+ 2666,
+ 1506,
+ 1876,
+ 1837,
+ 2070,
+ 1975,
+ 1739,
+ 1577,
+ 682,
+ 1289,
+ 1584,
+ 2045,
+ 1454,
+ 2098,
+ 2498,
+ 2004,
+ 2711,
+ 2066,
+ 726,
+ 1588,
+ 2756,
+ 2336,
+ 228,
+ 847,
+ 2456,
+ 1659,
+ 36,
+ 301,
+ 1942,
+ 1957,
+ - 446,
+ - 96,
+ 2154,
+ 1396,
+ 1533,
+ 1101,
+ 14,
+ 608,
+ - 923,
+ - 732,
+ 1383,
+ 1982,
+ 1345,
+ 952,
+ - 680,
+ 321,
+ 1281,
+ 1268,
+ - 1594,
+ 365,
+ 941,
+ 946,
+ - 1737,
+ - 822,
+ 2374,
+ 2787,
+ 1821,
+ 2788
+};
+
+/* 3rd LSF quantizer (MR122) */
+static const Word32 dico3_lsf_5[DICO3_SIZE_5 * 4] = {
+ - 1812,
+ - 2275,
+ - 1879,
+ - 2537,
+ - 1640,
+ - 1848,
+ - 1695,
+ - 2004,
+ - 1220,
+ - 1912,
+ - 1221,
+ - 2106,
+ - 1559,
+ - 1588,
+ - 1573,
+ - 1556,
+ - 1195,
+ - 1615,
+ - 1224,
+ - 1727,
+ - 1359,
+ - 1151,
+ - 1616,
+ - 1948,
+ - 1274,
+ - 1391,
+ - 1305,
+ - 1403,
+ - 1607,
+ - 1179,
+ - 1676,
+ - 1311,
+ - 1443,
+ - 1478,
+ - 1367,
+ - 898,
+ - 1256,
+ - 1059,
+ - 1331,
+ - 1134,
+ - 982,
+ - 1133,
+ - 1149,
+ - 1504,
+ - 1080,
+ - 1308,
+ - 1020,
+ - 1183,
+ - 980,
+ - 1486,
+ - 967,
+ - 1495,
+ - 988,
+ - 922,
+ - 1047,
+ - 1077,
+ - 838,
+ - 1179,
+ - 858,
+ - 1222,
+ - 1131,
+ - 1041,
+ - 1064,
+ - 767,
+ - 872,
+ - 1157,
+ - 701,
+ - 880,
+ - 706,
+ - 906,
+ - 774,
+ - 1016,
+ - 578,
+ - 1080,
+ - 801,
+ - 1478,
+ - 591,
+ - 1111,
+ - 592,
+ - 1146,
+ - 713,
+ - 1388,
+ - 640,
+ - 1376,
+ - 597,
+ - 1059,
+ - 416,
+ - 903,
+ - 686,
+ - 832,
+ - 661,
+ - 708,
+ - 444,
+ - 868,
+ - 490,
+ - 921,
+ - 374,
+ - 776,
+ - 619,
+ - 1170,
+ - 585,
+ - 549,
+ - 769,
+ - 795,
+ - 435,
+ - 659,
+ - 530,
+ - 741,
+ - 498,
+ - 837,
+ - 357,
+ - 597,
+ - 279,
+ - 871,
+ - 243,
+ - 887,
+ - 282,
+ - 665,
+ - 280,
+ - 667,
+ - 165,
+ - 560,
+ - 394,
+ - 903,
+ - 362,
+ - 410,
+ - 448,
+ - 583,
+ - 409,
+ - 574,
+ - 313,
+ - 357,
+ - 637,
+ - 548,
+ - 570,
+ - 436,
+ - 896,
+ - 504,
+ - 382,
+ - 757,
+ - 58,
+ - 481,
+ - 165,
+ - 618,
+ - 191,
+ - 374,
+ - 234,
+ - 382,
+ - 222,
+ - 683,
+ - 25,
+ - 480,
+ - 418,
+ - 359,
+ - 730,
+ - 353,
+ - 324,
+ - 157,
+ - 432,
+ - 322,
+ - 394,
+ - 303,
+ - 284,
+ - 104,
+ - 601,
+ - 289,
+ - 556,
+ - 196,
+ - 588,
+ - 150,
+ - 659,
+ - 608,
+ - 473,
+ - 24,
+ - 68,
+ - 448,
+ - 474,
+ - 8,
+ - 506,
+ - 45,
+ - 748,
+ - 184,
+ - 844,
+ - 252,
+ - 901,
+ - 91,
+ - 584,
+ - 97,
+ - 652,
+ 138,
+ - 764,
+ - 131,
+ - 678,
+ - 12,
+ - 670,
+ 165,
+ - 259,
+ - 3,
+ - 840,
+ - 107,
+ - 909,
+ 37,
+ - 992,
+ 44,
+ - 854,
+ - 415,
+ - 839,
+ 13,
+ - 1001,
+ - 271,
+ - 1026,
+ - 309,
+ - 798,
+ - 478,
+ - 832,
+ - 488,
+ - 943,
+ 168,
+ - 1112,
+ - 387,
+ - 1185,
+ - 101,
+ - 1183,
+ - 40,
+ - 941,
+ - 316,
+ - 1030,
+ - 770,
+ - 1044,
+ - 625,
+ - 1081,
+ - 538,
+ - 1224,
+ - 299,
+ - 1312,
+ - 436,
+ - 1197,
+ - 663,
+ - 1167,
+ - 161,
+ - 1216,
+ - 690,
+ - 1237,
+ - 831,
+ - 1432,
+ - 720,
+ - 1403,
+ - 493,
+ - 898,
+ - 740,
+ - 922,
+ - 801,
+ - 1102,
+ - 402,
+ - 1579,
+ - 964,
+ - 1061,
+ - 638,
+ - 1269,
+ - 1438,
+ - 1499,
+ - 934,
+ - 1502,
+ - 895,
+ - 1598,
+ - 564,
+ - 1723,
+ - 717,
+ - 606,
+ - 597,
+ - 1166,
+ - 1085,
+ - 1369,
+ - 468,
+ - 1946,
+ - 1493,
+ - 1838,
+ - 953,
+ - 1932,
+ - 931,
+ - 1499,
+ - 188,
+ - 1635,
+ - 421,
+ - 1457,
+ - 338,
+ - 1448,
+ - 22,
+ - 1942,
+ - 422,
+ - 2006,
+ - 249,
+ - 496,
+ - 114,
+ - 1910,
+ - 755,
+ - 1289,
+ 174,
+ - 1451,
+ - 109,
+ - 482,
+ - 257,
+ - 1221,
+ - 508,
+ - 1617,
+ 151,
+ - 1694,
+ 208,
+ - 654,
+ 107,
+ - 1651,
+ 29,
+ - 1141,
+ 279,
+ - 1215,
+ 306,
+ - 1228,
+ - 506,
+ - 730,
+ - 175,
+ - 1236,
+ - 101,
+ - 969,
+ 551,
+ - 870,
+ 278,
+ - 823,
+ 315,
+ - 563,
+ 376,
+ - 1051,
+ 228,
+ - 507,
+ 280,
+ - 599,
+ 281,
+ - 758,
+ 253,
+ - 305,
+ 379,
+ - 755,
+ - 134,
+ - 611,
+ 660,
+ - 824,
+ 536,
+ - 817,
+ 646,
+ - 413,
+ 49,
+ - 341,
+ 177,
+ - 453,
+ 526,
+ - 482,
+ 589,
+ - 71,
+ 339,
+ - 657,
+ 264,
+ - 244,
+ 295,
+ - 237,
+ 315,
+ - 387,
+ 569,
+ - 506,
+ - 9,
+ - 377,
+ 14,
+ - 160,
+ 661,
+ - 216,
+ 40,
+ - 308,
+ - 46,
+ 95,
+ 214,
+ - 242,
+ 167,
+ - 86,
+ 192,
+ - 56,
+ 27,
+ - 76,
+ 31,
+ 36,
+ 309,
+ - 106,
+ - 182,
+ - 113,
+ 74,
+ - 441,
+ - 22,
+ 23,
+ 139,
+ 81,
+ - 11,
+ 44,
+ 15,
+ - 87,
+ - 137,
+ - 118,
+ - 207,
+ - 158,
+ - 58,
+ 272,
+ - 92,
+ - 156,
+ - 441,
+ 8,
+ - 136,
+ 128,
+ - 221,
+ 101,
+ - 218,
+ 40,
+ - 197,
+ - 76,
+ - 456,
+ 9,
+ - 445,
+ 33,
+ - 423,
+ 226,
+ 60,
+ 73,
+ - 222,
+ 156,
+ - 399,
+ 280,
+ - 318,
+ 245,
+ - 341,
+ 166,
+ - 499,
+ 339,
+ - 190,
+ 327,
+ - 219,
+ 325,
+ - 137,
+ - 89,
+ - 596,
+ 100,
+ - 627,
+ 144,
+ - 677,
+ 487,
+ 28,
+ 252,
+ - 391,
+ 214,
+ - 41,
+ 282,
+ - 28,
+ 99,
+ - 286,
+ 331,
+ 49,
+ 459,
+ - 388,
+ 565,
+ - 369,
+ 436,
+ 28,
+ 336,
+ - 9,
+ 397,
+ - 167,
+ 618,
+ 34,
+ 596,
+ - 17,
+ 561,
+ - 140,
+ 299,
+ 79,
+ 522,
+ 125,
+ 203,
+ 2,
+ 244,
+ 288,
+ 255,
+ 211,
+ 175,
+ 82,
+ 596,
+ 187,
+ 517,
+ 108,
+ 381,
+ 255,
+ 365,
+ 297,
+ 497,
+ 352,
+ 327,
+ - 82,
+ 25,
+ 210,
+ 371,
+ 245,
+ 261,
+ 3,
+ 545,
+ 449,
+ 140,
+ 294,
+ 44,
+ 295,
+ 212,
+ 347,
+ 244,
+ 494,
+ 331,
+ 528,
+ 201,
+ 307,
+ 349,
+ 411,
+ 613,
+ 284,
+ 614,
+ 413,
+ 464,
+ 322,
+ 624,
+ 397,
+ 97,
+ 200,
+ - 160,
+ 384,
+ 149,
+ 362,
+ 495,
+ 525,
+ 269,
+ 585,
+ 33,
+ 491,
+ - 121,
+ 433,
+ 427,
+ 611,
+ 498,
+ 516,
+ 171,
+ 443,
+ 497,
+ 666,
+ 440,
+ 275,
+ 566,
+ 575,
+ 146,
+ 639,
+ 155,
+ 670,
+ - 33,
+ 173,
+ 212,
+ 696,
+ - 166,
+ 601,
+ - 191,
+ 695,
+ - 489,
+ 503,
+ 175,
+ 742,
+ 214,
+ 476,
+ 372,
+ 1083,
+ 578,
+ 530,
+ 586,
+ 777,
+ 425,
+ 874,
+ 315,
+ 841,
+ 374,
+ 848,
+ - 165,
+ 565,
+ 35,
+ 991,
+ - 39,
+ 1062,
+ 329,
+ 712,
+ 786,
+ 840,
+ 645,
+ 795,
+ 661,
+ 676,
+ 571,
+ 918,
+ 632,
+ 1079,
+ 673,
+ 817,
+ 318,
+ 388,
+ 874,
+ 1012,
+ 564,
+ 848,
+ 880,
+ 620,
+ 557,
+ 479,
+ 671,
+ 453,
+ 692,
+ 468,
+ 840,
+ 642,
+ 844,
+ 645,
+ 506,
+ 428,
+ 897,
+ 567,
+ 837,
+ 387,
+ 962,
+ 499,
+ 691,
+ 561,
+ 939,
+ 926,
+ 783,
+ 296,
+ 790,
+ 268,
+ 1028,
+ 530,
+ 874,
+ 329,
+ 548,
+ 143,
+ 675,
+ 291,
+ 503,
+ 66,
+ 1041,
+ 359,
+ 786,
+ 97,
+ 805,
+ 33,
+ 837,
+ 470,
+ 511,
+ 49,
+ 1092,
+ 327,
+ 1174,
+ 323,
+ 3,
+ 242,
+ 872,
+ 474,
+ 689,
+ 429,
+ 1329,
+ 678,
+ 1042,
+ 620,
+ 1109,
+ 664,
+ 321,
+ 193,
+ 889,
+ 950,
+ 1153,
+ 874,
+ 893,
+ 635,
+ 877,
+ 862,
+ 948,
+ 913,
+ 1293,
+ 665,
+ 1320,
+ 639,
+ 997,
+ 793,
+ 1402,
+ 1030,
+ 1176,
+ 1012,
+ 1110,
+ 959,
+ 1410,
+ 925,
+ 1403,
+ 915,
+ 543,
+ 862,
+ 1116,
+ 1222,
+ 835,
+ 1190,
+ 835,
+ 1190,
+ 959,
+ 1148,
+ 1147,
+ 1376,
+ 1300,
+ 1193,
+ 1415,
+ 1231,
+ 1335,
+ 1341,
+ 746,
+ 1092,
+ 1711,
+ 1283,
+ 1389,
+ 1073,
+ 1334,
+ 1566,
+ 1153,
+ 1475,
+ 1645,
+ 1137,
+ 1825,
+ 1220,
+ 1056,
+ 1382,
+ 1521,
+ 1730,
+ 1632,
+ 1545,
+ 1620,
+ 1542,
+ 855,
+ 1596,
+ 865,
+ 1667,
+ 693,
+ 885,
+ 1716,
+ 1519,
+ 1167,
+ 1296,
+ 2209,
+ 1760,
+ 1952,
+ 1493,
+ 2020,
+ 1482,
+ 1534,
+ 1866,
+ 1694,
+ 2008,
+ 1566,
+ 748,
+ 1761,
+ 825,
+ 294,
+ 1392,
+ 1084,
+ 2058,
+ 621,
+ 1315,
+ 365,
+ 1287,
+ 198,
+ 1028,
+ 488,
+ 1408,
+ 249,
+ 403,
+ 1014,
+ 1561,
+ 324,
+ 363,
+ 1645,
+ 1044,
+ 193,
+ 367,
+ 2034,
+ 1859,
+ - 251,
+ 579,
+ 750,
+ 994,
+ - 243,
+ 30,
+ 1325,
+ 879,
+ - 28,
+ - 169,
+ 624,
+ 917,
+ - 453,
+ 159,
+ 186,
+ 1370,
+ - 614,
+ 6,
+ 537,
+ 392,
+ - 94,
+ - 291,
+ 781,
+ 229,
+ - 128,
+ - 298,
+ 245,
+ 491,
+ - 701,
+ - 648,
+ 972,
+ 789,
+ - 501,
+ - 640,
+ 178,
+ 255,
+ - 365,
+ - 390,
+ - 255,
+ 317,
+ - 958,
+ - 294,
+ - 191,
+ 228,
+ - 775,
+ - 447,
+ 157,
+ - 237,
+ - 657,
+ - 720,
+ - 407,
+ 92,
+ - 117,
+ - 611,
+ 334,
+ - 230,
+ - 679,
+ - 1084,
+ - 144,
+ - 317,
+ - 901,
+ - 861,
+ - 738,
+ - 360,
+ - 85,
+ - 727,
+ - 90,
+ - 787,
+ 100,
+ - 22,
+ - 391,
+ - 263,
+ - 56,
+ - 73,
+ - 337,
+ - 754,
+ 5,
+ - 189,
+ - 706,
+ - 624,
+ 89,
+ - 344,
+ - 135,
+ - 1113,
+ - 353,
+ - 237,
+ - 684,
+ - 1135,
+ - 275,
+ - 1102,
+ - 269,
+ - 1203,
+ 152,
+ 145,
+ - 722,
+ - 1232,
+ 49,
+ 80,
+ - 1248,
+ - 776,
+ - 248,
+ 391,
+ - 732,
+ - 547,
+ 469,
+ 218,
+ - 255,
+ - 864,
+ 69,
+ 366,
+ - 166,
+ - 485,
+ - 688,
+ 191,
+ - 1212,
+ - 1196,
+ - 170,
+ - 169,
+ - 1308,
+ - 1631,
+ 321,
+ 470,
+ - 1419,
+ - 1243,
+ - 64,
+ 272,
+ - 1361,
+ - 248,
+ 492,
+ 565,
+ - 721,
+ - 609,
+ 195,
+ 485,
+ - 573,
+ - 133,
+ 427,
+ 202,
+ - 171,
+ - 118,
+ 199,
+ 575,
+ 2,
+ - 31,
+ 694,
+ 755,
+ - 1366,
+ - 39,
+ 552,
+ 557,
+ - 489,
+ 271,
+ 680,
+ 537,
+ 13,
+ - 453,
+ 855,
+ 954,
+ - 133,
+ - 52,
+ - 81,
+ 738,
+ - 1169,
+ 637,
+ 1055,
+ 1059,
+ - 95,
+ 676,
+ 1259,
+ 1081,
+ 489,
+ 305,
+ - 449,
+ 954,
+ - 534,
+ 996,
+ - 969,
+ 866,
+ - 1058,
+ 1059,
+ - 1294,
+ 618,
+ - 1416,
+ 617,
+ - 458,
+ 1366,
+ - 159,
+ 1821,
+ - 774,
+ - 528,
+ - 14,
+ 1110,
+ - 1202,
+ - 901,
+ - 772,
+ 433,
+ - 1256,
+ - 1255,
+ - 1011,
+ - 302,
+ - 602,
+ - 585,
+ - 759,
+ - 1618,
+ - 760,
+ - 1549,
+ - 840,
+ - 1921,
+ - 816,
+ - 539,
+ - 1769,
+ - 2235,
+ - 227,
+ - 36,
+ - 2034,
+ - 1831,
+ - 2107,
+ - 1126,
+ - 2471,
+ - 1816,
+ - 1470,
+ 252,
+ - 2701,
+ - 415,
+ - 571,
+ - 467,
+ 1509,
+ 1554,
+ 2180,
+ 1975,
+ 2326,
+ 2020
+};
+
+/* 4th LSF quantizer (MR122) */
+static const Word32 dico4_lsf_5[DICO4_SIZE_5 * 4] = {
+ - 1857,
+ - 1681,
+ - 1857,
+ - 1755,
+ - 2056,
+ - 1150,
+ - 2134,
+ - 1654,
+ - 1619,
+ - 1099,
+ - 1704,
+ - 1131,
+ - 1345,
+ - 1608,
+ - 1359,
+ - 1638,
+ - 1338,
+ - 1293,
+ - 1325,
+ - 1265,
+ - 1664,
+ - 1649,
+ - 1487,
+ - 851,
+ - 1346,
+ - 1832,
+ - 1413,
+ - 2188,
+ - 1282,
+ - 681,
+ - 1785,
+ - 1649,
+ - 966,
+ - 1082,
+ - 1183,
+ - 1676,
+ - 1054,
+ - 1073,
+ - 1142,
+ - 1158,
+ - 1207,
+ - 744,
+ - 1274,
+ - 997,
+ - 934,
+ - 1383,
+ - 927,
+ - 1416,
+ - 1010,
+ - 1305,
+ - 783,
+ - 955,
+ - 1049,
+ - 900,
+ - 993,
+ - 817,
+ - 737,
+ - 823,
+ - 972,
+ - 1189,
+ - 738,
+ - 1094,
+ - 738,
+ - 1154,
+ - 784,
+ - 801,
+ - 810,
+ - 786,
+ - 892,
+ - 520,
+ - 1000,
+ - 818,
+ - 644,
+ - 965,
+ - 577,
+ - 882,
+ - 541,
+ - 694,
+ - 671,
+ - 917,
+ - 595,
+ - 642,
+ - 646,
+ - 615,
+ - 956,
+ - 621,
+ - 925,
+ - 515,
+ - 727,
+ - 483,
+ - 815,
+ - 485,
+ - 840,
+ - 578,
+ - 440,
+ - 713,
+ - 578,
+ - 325,
+ - 657,
+ - 670,
+ - 386,
+ - 570,
+ - 441,
+ - 666,
+ - 514,
+ - 787,
+ - 392,
+ - 529,
+ - 522,
+ - 453,
+ - 487,
+ - 423,
+ - 616,
+ - 585,
+ - 617,
+ - 157,
+ - 662,
+ - 268,
+ - 680,
+ - 348,
+ - 322,
+ - 323,
+ - 632,
+ - 444,
+ - 304,
+ - 430,
+ - 332,
+ - 458,
+ - 277,
+ - 468,
+ - 659,
+ - 793,
+ - 319,
+ - 636,
+ - 227,
+ - 554,
+ - 373,
+ - 347,
+ - 334,
+ - 210,
+ - 456,
+ - 192,
+ - 530,
+ - 242,
+ - 216,
+ - 198,
+ - 366,
+ - 370,
+ - 338,
+ - 161,
+ - 409,
+ - 748,
+ - 107,
+ - 380,
+ - 294,
+ - 643,
+ - 223,
+ - 665,
+ - 234,
+ - 741,
+ - 141,
+ - 496,
+ - 130,
+ - 510,
+ - 139,
+ - 327,
+ - 172,
+ - 305,
+ - 306,
+ - 580,
+ - 164,
+ - 263,
+ - 262,
+ - 172,
+ - 67,
+ - 402,
+ 31,
+ - 366,
+ - 10,
+ - 436,
+ - 86,
+ - 527,
+ 71,
+ - 377,
+ - 22,
+ - 609,
+ - 12,
+ - 678,
+ - 67,
+ - 319,
+ 63,
+ - 191,
+ 35,
+ - 181,
+ - 39,
+ - 242,
+ 126,
+ - 167,
+ - 140,
+ - 544,
+ 155,
+ - 297,
+ 174,
+ - 297,
+ 38,
+ - 8,
+ 117,
+ - 380,
+ 197,
+ - 452,
+ 240,
+ - 522,
+ 223,
+ - 103,
+ 110,
+ - 187,
+ 87,
+ - 155,
+ 169,
+ - 47,
+ 157,
+ 26,
+ - 83,
+ - 100,
+ 128,
+ 80,
+ 209,
+ - 62,
+ 6,
+ 7,
+ 22,
+ 5,
+ 318,
+ - 20,
+ 248,
+ - 45,
+ - 200,
+ - 63,
+ 156,
+ - 69,
+ 250,
+ - 183,
+ 369,
+ - 126,
+ - 113,
+ - 76,
+ - 142,
+ - 122,
+ - 64,
+ - 254,
+ - 31,
+ 35,
+ - 177,
+ - 71,
+ - 7,
+ 171,
+ 93,
+ 27,
+ 108,
+ 212,
+ - 330,
+ - 209,
+ - 123,
+ - 70,
+ - 279,
+ 95,
+ - 96,
+ 20,
+ - 188,
+ - 61,
+ - 314,
+ 87,
+ - 300,
+ - 78,
+ - 354,
+ - 134,
+ 11,
+ 122,
+ - 140,
+ 122,
+ - 275,
+ 152,
+ - 293,
+ 140,
+ - 82,
+ 138,
+ - 321,
+ - 111,
+ - 480,
+ - 156,
+ - 359,
+ 76,
+ - 254,
+ - 40,
+ - 635,
+ - 96,
+ - 522,
+ 79,
+ - 507,
+ 8,
+ - 268,
+ 303,
+ - 539,
+ 68,
+ - 446,
+ 61,
+ - 522,
+ 306,
+ 111,
+ 189,
+ - 435,
+ 122,
+ - 379,
+ 166,
+ - 571,
+ - 398,
+ - 632,
+ - 74,
+ - 747,
+ - 95,
+ - 455,
+ 194,
+ - 952,
+ 83,
+ - 798,
+ 192,
+ - 755,
+ 192,
+ - 781,
+ - 162,
+ - 619,
+ 234,
+ - 663,
+ - 297,
+ - 488,
+ - 109,
+ - 964,
+ - 132,
+ - 838,
+ - 68,
+ - 843,
+ 58,
+ - 1112,
+ - 86,
+ - 805,
+ - 299,
+ - 944,
+ - 253,
+ - 778,
+ - 50,
+ - 965,
+ - 549,
+ - 352,
+ - 98,
+ - 992,
+ - 343,
+ - 1117,
+ - 315,
+ - 1117,
+ - 307,
+ - 1155,
+ - 374,
+ - 637,
+ - 230,
+ - 1166,
+ - 43,
+ - 1299,
+ - 100,
+ - 925,
+ - 393,
+ - 1274,
+ - 600,
+ - 689,
+ - 130,
+ - 1479,
+ - 312,
+ - 1321,
+ - 254,
+ - 1464,
+ - 442,
+ - 1292,
+ - 613,
+ - 1261,
+ - 503,
+ - 1501,
+ - 368,
+ - 1322,
+ 26,
+ - 1432,
+ - 66,
+ - 1743,
+ - 161,
+ - 1644,
+ - 467,
+ - 1760,
+ - 548,
+ - 1393,
+ - 568,
+ - 1556,
+ - 871,
+ - 1495,
+ - 1034,
+ - 1387,
+ - 571,
+ - 1917,
+ - 528,
+ - 1783,
+ - 123,
+ - 1897,
+ - 231,
+ - 2054,
+ - 323,
+ - 2052,
+ - 906,
+ - 1976,
+ - 567,
+ - 1917,
+ - 620,
+ - 2047,
+ - 989,
+ - 1077,
+ - 370,
+ - 2031,
+ - 704,
+ - 2355,
+ - 749,
+ - 2740,
+ - 1089,
+ - 1909,
+ 159,
+ - 2012,
+ 248,
+ - 626,
+ - 123,
+ - 2339,
+ - 962,
+ - 669,
+ - 408,
+ - 1379,
+ - 1174,
+ - 452,
+ - 364,
+ - 1044,
+ - 735,
+ - 132,
+ 183,
+ - 1620,
+ - 752,
+ - 547,
+ - 307,
+ - 777,
+ - 1261,
+ - 98,
+ 41,
+ - 880,
+ - 1091,
+ - 257,
+ 97,
+ - 1602,
+ - 1833,
+ 31,
+ - 26,
+ - 644,
+ - 561,
+ - 180,
+ - 546,
+ - 385,
+ - 1095,
+ - 410,
+ - 802,
+ - 414,
+ - 827,
+ - 457,
+ - 970,
+ - 490,
+ - 1109,
+ - 215,
+ - 916,
+ - 144,
+ - 937,
+ - 493,
+ - 1269,
+ - 517,
+ - 1507,
+ 181,
+ 101,
+ - 332,
+ - 889,
+ - 836,
+ - 937,
+ - 559,
+ - 429,
+ - 629,
+ - 547,
+ - 183,
+ - 337,
+ - 545,
+ - 82,
+ - 250,
+ - 286,
+ 5,
+ - 132,
+ - 348,
+ - 252,
+ - 293,
+ - 472,
+ - 158,
+ 100,
+ - 29,
+ 197,
+ - 236,
+ - 424,
+ - 861,
+ - 213,
+ - 140,
+ - 7,
+ - 427,
+ - 443,
+ 187,
+ - 97,
+ - 684,
+ - 736,
+ - 293,
+ 258,
+ - 368,
+ - 152,
+ - 150,
+ 392,
+ - 609,
+ 175,
+ - 142,
+ 299,
+ - 138,
+ 152,
+ - 119,
+ 329,
+ - 486,
+ - 52,
+ 293,
+ 198,
+ - 183,
+ 117,
+ 175,
+ 331,
+ - 58,
+ - 274,
+ 231,
+ 300,
+ - 288,
+ 330,
+ - 305,
+ 372,
+ - 111,
+ 409,
+ - 9,
+ 423,
+ 83,
+ 256,
+ 67,
+ 367,
+ - 19,
+ 248,
+ 91,
+ 113,
+ - 35,
+ 406,
+ - 191,
+ 154,
+ 238,
+ 296,
+ 5,
+ 197,
+ 141,
+ 221,
+ 313,
+ 198,
+ 211,
+ 421,
+ 244,
+ 334,
+ 88,
+ 426,
+ - 243,
+ 454,
+ 202,
+ 552,
+ - 5,
+ 403,
+ 291,
+ 185,
+ 219,
+ 301,
+ 251,
+ 138,
+ 128,
+ 69,
+ 197,
+ 288,
+ - 140,
+ - 61,
+ 188,
+ 361,
+ 197,
+ 598,
+ 442,
+ 273,
+ 290,
+ 143,
+ 472,
+ 482,
+ 157,
+ 370,
+ 415,
+ 321,
+ 372,
+ 385,
+ 402,
+ 552,
+ 155,
+ 24,
+ 550,
+ 263,
+ - 11,
+ 21,
+ 360,
+ 227,
+ 147,
+ - 254,
+ 424,
+ 97,
+ 366,
+ - 13,
+ 375,
+ 141,
+ 449,
+ 232,
+ 396,
+ 507,
+ 474,
+ 272,
+ 701,
+ 324,
+ 362,
+ - 47,
+ 587,
+ 148,
+ 543,
+ 69,
+ 400,
+ - 51,
+ 561,
+ 59,
+ 220,
+ - 10,
+ 352,
+ 147,
+ 206,
+ 211,
+ 653,
+ 185,
+ 563,
+ 297,
+ 565,
+ 284,
+ 594,
+ 121,
+ 766,
+ 192,
+ 398,
+ 118,
+ 642,
+ 434,
+ 233,
+ 264,
+ 481,
+ 467,
+ 129,
+ - 165,
+ 699,
+ 239,
+ 90,
+ 26,
+ 342,
+ 474,
+ - 55,
+ 27,
+ 388,
+ 94,
+ - 172,
+ 0,
+ 725,
+ 379,
+ - 60,
+ 337,
+ 370,
+ 465,
+ 95,
+ 319,
+ 806,
+ 595,
+ 78,
+ 260,
+ 497,
+ 851,
+ 210,
+ 560,
+ 458,
+ 574,
+ - 464,
+ 202,
+ 497,
+ 625,
+ - 202,
+ 152,
+ 48,
+ 712,
+ - 20,
+ 566,
+ 100,
+ 715,
+ 455,
+ 468,
+ 411,
+ 605,
+ 319,
+ 646,
+ 195,
+ 615,
+ 401,
+ 538,
+ 680,
+ 739,
+ 201,
+ 667,
+ 434,
+ 954,
+ 454,
+ 425,
+ 646,
+ 491,
+ 606,
+ 681,
+ 416,
+ 508,
+ 497,
+ 822,
+ 426,
+ 815,
+ 660,
+ 647,
+ 628,
+ 716,
+ 697,
+ 466,
+ 618,
+ 457,
+ 685,
+ 460,
+ 365,
+ 309,
+ 721,
+ 567,
+ 836,
+ 601,
+ 609,
+ 300,
+ 825,
+ 459,
+ 943,
+ 687,
+ 681,
+ 533,
+ 915,
+ 598,
+ 591,
+ 243,
+ 876,
+ 451,
+ 874,
+ 420,
+ 786,
+ 317,
+ 732,
+ 220,
+ 922,
+ 317,
+ 1108,
+ 367,
+ 531,
+ 466,
+ 1028,
+ 649,
+ 1053,
+ 615,
+ 1034,
+ 553,
+ 829,
+ 602,
+ 1021,
+ 799,
+ 927,
+ 803,
+ 878,
+ 763,
+ 799,
+ 496,
+ 1373,
+ 773,
+ 585,
+ 770,
+ 803,
+ 930,
+ 1099,
+ 793,
+ 1222,
+ 862,
+ 1209,
+ 895,
+ 1025,
+ 727,
+ 772,
+ 845,
+ 1172,
+ 1115,
+ 867,
+ 1021,
+ 830,
+ 1013,
+ 841,
+ 910,
+ 506,
+ 703,
+ 1239,
+ 1077,
+ 620,
+ 819,
+ 1196,
+ 1083,
+ 1155,
+ 1081,
+ 1142,
+ 907,
+ 1547,
+ 1121,
+ 1309,
+ 648,
+ 1343,
+ 612,
+ 1484,
+ 988,
+ 1479,
+ 937,
+ 985,
+ 1328,
+ 955,
+ 1341,
+ 429,
+ 910,
+ 841,
+ 1338,
+ 564,
+ 1179,
+ 412,
+ 1156,
+ 1427,
+ 1320,
+ 1434,
+ 1330,
+ 640,
+ 760,
+ 1726,
+ 1410,
+ 190,
+ 555,
+ 1073,
+ 1005,
+ 426,
+ 257,
+ 839,
+ 980,
+ 235,
+ 231,
+ 1520,
+ 1167,
+ 109,
+ 293,
+ 1014,
+ 1569,
+ 305,
+ 142,
+ 1148,
+ 539,
+ - 291,
+ - 108,
+ 1213,
+ 972,
+ 22,
+ - 216,
+ 667,
+ 828,
+ - 482,
+ 438,
+ 453,
+ 1431,
+ - 581,
+ - 422,
+ 789,
+ 387,
+ - 358,
+ - 454,
+ 174,
+ 780,
+ - 36,
+ - 372,
+ 390,
+ - 134,
+ - 629,
+ 160,
+ - 306,
+ 751,
+ - 1258,
+ - 331,
+ 177,
+ 522,
+ - 248,
+ 574,
+ - 251,
+ 639,
+ - 531,
+ 407,
+ - 596,
+ 394,
+ - 419,
+ 789,
+ - 617,
+ 801,
+ - 986,
+ 399,
+ - 857,
+ 727,
+ - 7,
+ 518,
+ - 703,
+ 310,
+ - 1143,
+ - 24,
+ - 1002,
+ 287,
+ - 960,
+ 363,
+ - 1299,
+ 312,
+ - 1534,
+ 245,
+ - 1557,
+ 305,
+ 28,
+ 153,
+ - 859,
+ - 175,
+ - 33,
+ 332,
+ - 1398,
+ - 154,
+ 212,
+ 410,
+ - 593,
+ - 197,
+ - 1092,
+ - 704,
+ - 904,
+ - 65,
+ 282,
+ 367,
+ - 918,
+ - 686,
+ 345,
+ 93,
+ - 258,
+ - 357,
+ 696,
+ 644,
+ - 693,
+ - 28,
+ 448,
+ 493,
+ - 273,
+ 193,
+ 527,
+ 546,
+ - 243,
+ - 513,
+ 384,
+ - 136,
+ 273,
+ - 353,
+ 512,
+ - 142,
+ 537,
+ - 198,
+ 941,
+ 750,
+ 83,
+ 248,
+ 578,
+ 861,
+ - 56,
+ 592,
+ 842,
+ 44,
+ 892,
+ 24,
+ 33,
+ 890,
+ - 16,
+ 982,
+ 831,
+ 1398,
+ 1535,
+ 1898,
+ 1716,
+ 1376,
+ 1948,
+ 1465
+};
+
+/* 5th LSF quantizer (MR122) */
+static const Word32 dico5_lsf_5[DICO5_SIZE_5 * 4] = {
+ - 1002,
+ - 929,
+ - 1096,
+ - 1203,
+ - 641,
+ - 931,
+ - 604,
+ - 961,
+ - 779,
+ - 673,
+ - 835,
+ - 788,
+ - 416,
+ - 664,
+ - 458,
+ - 766,
+ - 652,
+ - 521,
+ - 662,
+ - 495,
+ - 1023,
+ - 509,
+ - 1023,
+ - 428,
+ - 444,
+ - 552,
+ - 368,
+ - 449,
+ - 479,
+ - 211,
+ - 1054,
+ - 903,
+ - 316,
+ - 249,
+ - 569,
+ - 591,
+ - 569,
+ - 275,
+ - 541,
+ - 191,
+ - 716,
+ - 188,
+ - 842,
+ - 264,
+ - 333,
+ - 248,
+ - 318,
+ - 228,
+ - 275,
+ 1,
+ - 567,
+ - 228,
+ - 115,
+ - 221,
+ - 238,
+ - 374,
+ - 197,
+ - 507,
+ - 222,
+ - 579,
+ - 258,
+ - 432,
+ - 61,
+ - 244,
+ - 345,
+ 2,
+ - 338,
+ 39,
+ - 215,
+ - 169,
+ - 58,
+ 0,
+ - 56,
+ - 6,
+ - 203,
+ - 131,
+ 1,
+ - 186,
+ - 5,
+ - 211,
+ 6,
+ - 380,
+ 11,
+ - 418,
+ - 116,
+ 131,
+ - 134,
+ 113,
+ 89,
+ - 4,
+ 71,
+ - 2,
+ - 19,
+ - 192,
+ 262,
+ 24,
+ 189,
+ 151,
+ - 133,
+ - 109,
+ 186,
+ - 153,
+ 166,
+ - 219,
+ 37,
+ 139,
+ 193,
+ 171,
+ 337,
+ 124,
+ 158,
+ - 61,
+ 141,
+ 226,
+ - 13,
+ 190,
+ 231,
+ 34,
+ 354,
+ 109,
+ 316,
+ 201,
+ 244,
+ 164,
+ 330,
+ - 85,
+ 390,
+ - 84,
+ 254,
+ 327,
+ 257,
+ 335,
+ 491,
+ 147,
+ 476,
+ 105,
+ 54,
+ 77,
+ 437,
+ 370,
+ 421,
+ 314,
+ 449,
+ 342,
+ 329,
+ 126,
+ 673,
+ 292,
+ 571,
+ 388,
+ 243,
+ 193,
+ 653,
+ 320,
+ 621,
+ 280,
+ 194,
+ 380,
+ 517,
+ 581,
+ 45,
+ 323,
+ 111,
+ 422,
+ 489,
+ 395,
+ 734,
+ 534,
+ 622,
+ 546,
+ 486,
+ 502,
+ 318,
+ 572,
+ 189,
+ 550,
+ 385,
+ 422,
+ - 157,
+ 153,
+ - 125,
+ 382,
+ - 197,
+ 386,
+ - 263,
+ 334,
+ 228,
+ 697,
+ - 188,
+ 1,
+ 51,
+ 297,
+ - 507,
+ 213,
+ - 376,
+ 397,
+ - 24,
+ 255,
+ - 547,
+ 89,
+ - 502,
+ - 94,
+ 387,
+ 179,
+ - 620,
+ 68,
+ - 684,
+ 112,
+ - 642,
+ - 350,
+ - 260,
+ 172,
+ - 438,
+ - 324,
+ 264,
+ 648,
+ - 964,
+ - 4,
+ - 1121,
+ 7,
+ - 134,
+ 134,
+ - 1133,
+ - 306,
+ 143,
+ 96,
+ - 420,
+ - 497,
+ - 1221,
+ - 350,
+ - 1527,
+ - 685,
+ - 161,
+ 72,
+ 873,
+ 691,
+ 732,
+ 283,
+ 921,
+ 353,
+ 334,
+ 475,
+ 1095,
+ 821,
+ 864,
+ 524,
+ 843,
+ 497,
+ 714,
+ 711,
+ 788,
+ 750,
+ 1076,
+ 714,
+ 1204,
+ 753
+};
+
+
+
+/* Scaling factors for the lsp variability operation */
+static const Word16 lsf_hist_mean_scale[M] = {
+ 20000,
+ 20000,
+ 20000,
+ 20000,
+ 20000,
+ 18000,
+ 16384,
+ 8192,
+ 0,
+ 0
+};
+
+/*
+ * The tables contains the following data:
+ *
+ * g_pitch (Q14),
+ * g_fac (Q12), (g_code = g_code0*g_fac),
+ * qua_ener_MR122 (Q10), (log2(g_fac))
+ * qua_ener (Q10) (20*log10(g_fac))
+ *
+ * The log2() and log10() values are calculated on the fixed point value
+ * (g_fac Q12) and not on the original floating point value of g_fac
+ * to make the quantizer/MA predictdor use corresponding values.
+ */
+
+#define MR475_VQ_SIZE 256
+
+/* The table contains the following data:
+ *
+ * g_pitch(0) (Q14) for sub-
+ * g_fac(0) (Q12) frame 0 and 2
+ * g_pitch(1) (Q14) for sub-
+ * g_fac(2) (Q12) frame 1 and 3
+ *
+ */
+static const Word32 table_gain_MR475[MR475_VQ_SIZE * 4] = {
+ /*
+ * g_pit(0),
+ * g_fac(0),
+ * g_pit(1),
+ * g_fac(1)
+ */ 812,
+ 128,
+ 542,
+ 140,
+ 2873,
+ 1135,
+ 2266,
+ 3402,
+ 2067,
+ 563,
+ 12677,
+ 647,
+ 4132,
+ 1798,
+ 5601,
+ 5285,
+ 7689,
+ 374,
+ 3735,
+ 441,
+ 10912,
+ 2638,
+ 11807,
+ 2494,
+ 20490,
+ 797,
+ 5218,
+ 675,
+ 6724,
+ 8354,
+ 5282,
+ 1696,
+ 1488,
+ 428,
+ 5882,
+ 452,
+ 5332,
+ 4072,
+ 3583,
+ 1268,
+ 2469,
+ 901,
+ 15894,
+ 1005,
+ 14982,
+ 3271,
+ 10331,
+ 4858,
+ 3635,
+ 2021,
+ 2596,
+ 835,
+ 12360,
+ 4892,
+ 12206,
+ 1704,
+ 13432,
+ 1604,
+ 9118,
+ 2341,
+ 3968,
+ 1538,
+ 5479,
+ 9936,
+ 3795,
+ 417,
+ 1359,
+ 414,
+ 3640,
+ 1569,
+ 7995,
+ 3541,
+ 11405,
+ 645,
+ 8552,
+ 635,
+ 4056,
+ 1377,
+ 16608,
+ 6124,
+ 11420,
+ 700,
+ 2007,
+ 607,
+ 12415,
+ 1578,
+ 11119,
+ 4654,
+ 13680,
+ 1708,
+ 11990,
+ 1229,
+ 7996,
+ 7297,
+ 13231,
+ 5715,
+ 2428,
+ 1159,
+ 2073,
+ 1941,
+ 6218,
+ 6121,
+ 3546,
+ 1804,
+ 8925,
+ 1802,
+ 8679,
+ 1580,
+ 13935,
+ 3576,
+ 13313,
+ 6237,
+ 6142,
+ 1130,
+ 5994,
+ 1734,
+ 14141,
+ 4662,
+ 11271,
+ 3321,
+ 12226,
+ 1551,
+ 13931,
+ 3015,
+ 5081,
+ 10464,
+ 9444,
+ 6706,
+ 1689,
+ 683,
+ 1436,
+ 1306,
+ 7212,
+ 3933,
+ 4082,
+ 2713,
+ 7793,
+ 704,
+ 15070,
+ 802,
+ 6299,
+ 5212,
+ 4337,
+ 5357,
+ 6676,
+ 541,
+ 6062,
+ 626,
+ 13651,
+ 3700,
+ 11498,
+ 2408,
+ 16156,
+ 716,
+ 12177,
+ 751,
+ 8065,
+ 11489,
+ 6314,
+ 2256,
+ 4466,
+ 496,
+ 7293,
+ 523,
+ 10213,
+ 3833,
+ 8394,
+ 3037,
+ 8403,
+ 966,
+ 14228,
+ 1880,
+ 8703,
+ 5409,
+ 16395,
+ 4863,
+ 7420,
+ 1979,
+ 6089,
+ 1230,
+ 9371,
+ 4398,
+ 14558,
+ 3363,
+ 13559,
+ 2873,
+ 13163,
+ 1465,
+ 5534,
+ 1678,
+ 13138,
+ 14771,
+ 7338,
+ 600,
+ 1318,
+ 548,
+ 4252,
+ 3539,
+ 10044,
+ 2364,
+ 10587,
+ 622,
+ 13088,
+ 669,
+ 14126,
+ 3526,
+ 5039,
+ 9784,
+ 15338,
+ 619,
+ 3115,
+ 590,
+ 16442,
+ 3013,
+ 15542,
+ 4168,
+ 15537,
+ 1611,
+ 15405,
+ 1228,
+ 16023,
+ 9299,
+ 7534,
+ 4976,
+ 1990,
+ 1213,
+ 11447,
+ 1157,
+ 12512,
+ 5519,
+ 9475,
+ 2644,
+ 7716,
+ 2034,
+ 13280,
+ 2239,
+ 16011,
+ 5093,
+ 8066,
+ 6761,
+ 10083,
+ 1413,
+ 5002,
+ 2347,
+ 12523,
+ 5975,
+ 15126,
+ 2899,
+ 18264,
+ 2289,
+ 15827,
+ 2527,
+ 16265,
+ 10254,
+ 14651,
+ 11319,
+ 1797,
+ 337,
+ 3115,
+ 397,
+ 3510,
+ 2928,
+ 4592,
+ 2670,
+ 7519,
+ 628,
+ 11415,
+ 656,
+ 5946,
+ 2435,
+ 6544,
+ 7367,
+ 8238,
+ 829,
+ 4000,
+ 863,
+ 10032,
+ 2492,
+ 16057,
+ 3551,
+ 18204,
+ 1054,
+ 6103,
+ 1454,
+ 5884,
+ 7900,
+ 18752,
+ 3468,
+ 1864,
+ 544,
+ 9198,
+ 683,
+ 11623,
+ 4160,
+ 4594,
+ 1644,
+ 3158,
+ 1157,
+ 15953,
+ 2560,
+ 12349,
+ 3733,
+ 17420,
+ 5260,
+ 6106,
+ 2004,
+ 2917,
+ 1742,
+ 16467,
+ 5257,
+ 16787,
+ 1680,
+ 17205,
+ 1759,
+ 4773,
+ 3231,
+ 7386,
+ 6035,
+ 14342,
+ 10012,
+ 4035,
+ 442,
+ 4194,
+ 458,
+ 9214,
+ 2242,
+ 7427,
+ 4217,
+ 12860,
+ 801,
+ 11186,
+ 825,
+ 12648,
+ 2084,
+ 12956,
+ 6554,
+ 9505,
+ 996,
+ 6629,
+ 985,
+ 10537,
+ 2502,
+ 15289,
+ 5006,
+ 12602,
+ 2055,
+ 15484,
+ 1653,
+ 16194,
+ 6921,
+ 14231,
+ 5790,
+ 2626,
+ 828,
+ 5615,
+ 1686,
+ 13663,
+ 5778,
+ 3668,
+ 1554,
+ 11313,
+ 2633,
+ 9770,
+ 1459,
+ 14003,
+ 4733,
+ 15897,
+ 6291,
+ 6278,
+ 1870,
+ 7910,
+ 2285,
+ 16978,
+ 4571,
+ 16576,
+ 3849,
+ 15248,
+ 2311,
+ 16023,
+ 3244,
+ 14459,
+ 17808,
+ 11847,
+ 2763,
+ 1981,
+ 1407,
+ 1400,
+ 876,
+ 4335,
+ 3547,
+ 4391,
+ 4210,
+ 5405,
+ 680,
+ 17461,
+ 781,
+ 6501,
+ 5118,
+ 8091,
+ 7677,
+ 7355,
+ 794,
+ 8333,
+ 1182,
+ 15041,
+ 3160,
+ 14928,
+ 3039,
+ 20421,
+ 880,
+ 14545,
+ 852,
+ 12337,
+ 14708,
+ 6904,
+ 1920,
+ 4225,
+ 933,
+ 8218,
+ 1087,
+ 10659,
+ 4084,
+ 10082,
+ 4533,
+ 2735,
+ 840,
+ 20657,
+ 1081,
+ 16711,
+ 5966,
+ 15873,
+ 4578,
+ 10871,
+ 2574,
+ 3773,
+ 1166,
+ 14519,
+ 4044,
+ 20699,
+ 2627,
+ 15219,
+ 2734,
+ 15274,
+ 2186,
+ 6257,
+ 3226,
+ 13125,
+ 19480,
+ 7196,
+ 930,
+ 2462,
+ 1618,
+ 4515,
+ 3092,
+ 13852,
+ 4277,
+ 10460,
+ 833,
+ 17339,
+ 810,
+ 16891,
+ 2289,
+ 15546,
+ 8217,
+ 13603,
+ 1684,
+ 3197,
+ 1834,
+ 15948,
+ 2820,
+ 15812,
+ 5327,
+ 17006,
+ 2438,
+ 16788,
+ 1326,
+ 15671,
+ 8156,
+ 11726,
+ 8556,
+ 3762,
+ 2053,
+ 9563,
+ 1317,
+ 13561,
+ 6790,
+ 12227,
+ 1936,
+ 8180,
+ 3550,
+ 13287,
+ 1778,
+ 16299,
+ 6599,
+ 16291,
+ 7758,
+ 8521,
+ 2551,
+ 7225,
+ 2645,
+ 18269,
+ 7489,
+ 16885,
+ 2248,
+ 17882,
+ 2884,
+ 17265,
+ 3328,
+ 9417,
+ 20162,
+ 11042,
+ 8320,
+ 1286,
+ 620,
+ 1431,
+ 583,
+ 5993,
+ 2289,
+ 3978,
+ 3626,
+ 5144,
+ 752,
+ 13409,
+ 830,
+ 5553,
+ 2860,
+ 11764,
+ 5908,
+ 10737,
+ 560,
+ 5446,
+ 564,
+ 13321,
+ 3008,
+ 11946,
+ 3683,
+ 19887,
+ 798,
+ 9825,
+ 728,
+ 13663,
+ 8748,
+ 7391,
+ 3053,
+ 2515,
+ 778,
+ 6050,
+ 833,
+ 6469,
+ 5074,
+ 8305,
+ 2463,
+ 6141,
+ 1865,
+ 15308,
+ 1262,
+ 14408,
+ 4547,
+ 13663,
+ 4515,
+ 3137,
+ 2983,
+ 2479,
+ 1259,
+ 15088,
+ 4647,
+ 15382,
+ 2607,
+ 14492,
+ 2392,
+ 12462,
+ 2537,
+ 7539,
+ 2949,
+ 12909,
+ 12060,
+ 5468,
+ 684,
+ 3141,
+ 722,
+ 5081,
+ 1274,
+ 12732,
+ 4200,
+ 15302,
+ 681,
+ 7819,
+ 592,
+ 6534,
+ 2021,
+ 16478,
+ 8737,
+ 13364,
+ 882,
+ 5397,
+ 899,
+ 14656,
+ 2178,
+ 14741,
+ 4227,
+ 14270,
+ 1298,
+ 13929,
+ 2029,
+ 15477,
+ 7482,
+ 15815,
+ 4572,
+ 2521,
+ 2013,
+ 5062,
+ 1804,
+ 5159,
+ 6582,
+ 7130,
+ 3597,
+ 10920,
+ 1611,
+ 11729,
+ 1708,
+ 16903,
+ 3455,
+ 16268,
+ 6640,
+ 9306,
+ 1007,
+ 9369,
+ 2106,
+ 19182,
+ 5037,
+ 12441,
+ 4269,
+ 15919,
+ 1332,
+ 15357,
+ 3512,
+ 11898,
+ 14141,
+ 16101,
+ 6854,
+ 2010,
+ 737,
+ 3779,
+ 861,
+ 11454,
+ 2880,
+ 3564,
+ 3540,
+ 9057,
+ 1241,
+ 12391,
+ 896,
+ 8546,
+ 4629,
+ 11561,
+ 5776,
+ 8129,
+ 589,
+ 8218,
+ 588,
+ 18728,
+ 3755,
+ 12973,
+ 3149,
+ 15729,
+ 758,
+ 16634,
+ 754,
+ 15222,
+ 11138,
+ 15871,
+ 2208,
+ 4673,
+ 610,
+ 10218,
+ 678,
+ 15257,
+ 4146,
+ 5729,
+ 3327,
+ 8377,
+ 1670,
+ 19862,
+ 2321,
+ 15450,
+ 5511,
+ 14054,
+ 5481,
+ 5728,
+ 2888,
+ 7580,
+ 1346,
+ 14384,
+ 5325,
+ 16236,
+ 3950,
+ 15118,
+ 3744,
+ 15306,
+ 1435,
+ 14597,
+ 4070,
+ 12301,
+ 15696,
+ 7617,
+ 1699,
+ 2170,
+ 884,
+ 4459,
+ 4567,
+ 18094,
+ 3306,
+ 12742,
+ 815,
+ 14926,
+ 907,
+ 15016,
+ 4281,
+ 15518,
+ 8368,
+ 17994,
+ 1087,
+ 2358,
+ 865,
+ 16281,
+ 3787,
+ 15679,
+ 4596,
+ 16356,
+ 1534,
+ 16584,
+ 2210,
+ 16833,
+ 9697,
+ 15929,
+ 4513,
+ 3277,
+ 1085,
+ 9643,
+ 2187,
+ 11973,
+ 6068,
+ 9199,
+ 4462,
+ 8955,
+ 1629,
+ 10289,
+ 3062,
+ 16481,
+ 5155,
+ 15466,
+ 7066,
+ 13678,
+ 2543,
+ 5273,
+ 2277,
+ 16746,
+ 6213,
+ 16655,
+ 3408,
+ 20304,
+ 3363,
+ 18688,
+ 1985,
+ 14172,
+ 12867,
+ 15154,
+ 15703,
+ 4473,
+ 1020,
+ 1681,
+ 886,
+ 4311,
+ 4301,
+ 8952,
+ 3657,
+ 5893,
+ 1147,
+ 11647,
+ 1452,
+ 15886,
+ 2227,
+ 4582,
+ 6644,
+ 6929,
+ 1205,
+ 6220,
+ 799,
+ 12415,
+ 3409,
+ 15968,
+ 3877,
+ 19859,
+ 2109,
+ 9689,
+ 2141,
+ 14742,
+ 8830,
+ 14480,
+ 2599,
+ 1817,
+ 1238,
+ 7771,
+ 813,
+ 19079,
+ 4410,
+ 5554,
+ 2064,
+ 3687,
+ 2844,
+ 17435,
+ 2256,
+ 16697,
+ 4486,
+ 16199,
+ 5388,
+ 8028,
+ 2763,
+ 3405,
+ 2119,
+ 17426,
+ 5477,
+ 13698,
+ 2786,
+ 19879,
+ 2720,
+ 9098,
+ 3880,
+ 18172,
+ 4833,
+ 17336,
+ 12207,
+ 5116,
+ 996,
+ 4935,
+ 988,
+ 9888,
+ 3081,
+ 6014,
+ 5371,
+ 15881,
+ 1667,
+ 8405,
+ 1183,
+ 15087,
+ 2366,
+ 19777,
+ 7002,
+ 11963,
+ 1562,
+ 7279,
+ 1128,
+ 16859,
+ 1532,
+ 15762,
+ 5381,
+ 14708,
+ 2065,
+ 20105,
+ 2155,
+ 17158,
+ 8245,
+ 17911,
+ 6318,
+ 5467,
+ 1504,
+ 4100,
+ 2574,
+ 17421,
+ 6810,
+ 5673,
+ 2888,
+ 16636,
+ 3382,
+ 8975,
+ 1831,
+ 20159,
+ 4737,
+ 19550,
+ 7294,
+ 6658,
+ 2781,
+ 11472,
+ 3321,
+ 19397,
+ 5054,
+ 18878,
+ 4722,
+ 16439,
+ 2373,
+ 20430,
+ 4386,
+ 11353,
+ 26526,
+ 11593,
+ 3068,
+ 2866,
+ 1566,
+ 5108,
+ 1070,
+ 9614,
+ 4915,
+ 4939,
+ 3536,
+ 7541,
+ 878,
+ 20717,
+ 851,
+ 6938,
+ 4395,
+ 16799,
+ 7733,
+ 10137,
+ 1019,
+ 9845,
+ 964,
+ 15494,
+ 3955,
+ 15459,
+ 3430,
+ 18863,
+ 982,
+ 20120,
+ 963,
+ 16876,
+ 12887,
+ 14334,
+ 4200,
+ 6599,
+ 1220,
+ 9222,
+ 814,
+ 16942,
+ 5134,
+ 5661,
+ 4898,
+ 5488,
+ 1798,
+ 20258,
+ 3962,
+ 17005,
+ 6178,
+ 17929,
+ 5929,
+ 9365,
+ 3420,
+ 7474,
+ 1971,
+ 19537,
+ 5177,
+ 19003,
+ 3006,
+ 16454,
+ 3788,
+ 16070,
+ 2367,
+ 8664,
+ 2743,
+ 9445,
+ 26358,
+ 10856,
+ 1287,
+ 3555,
+ 1009,
+ 5606,
+ 3622,
+ 19453,
+ 5512,
+ 12453,
+ 797,
+ 20634,
+ 911,
+ 15427,
+ 3066,
+ 17037,
+ 10275,
+ 18883,
+ 2633,
+ 3913,
+ 1268,
+ 19519,
+ 3371,
+ 18052,
+ 5230,
+ 19291,
+ 1678,
+ 19508,
+ 3172,
+ 18072,
+ 10754,
+ 16625,
+ 6845,
+ 3134,
+ 2298,
+ 10869,
+ 2437,
+ 15580,
+ 6913,
+ 12597,
+ 3381,
+ 11116,
+ 3297,
+ 16762,
+ 2424,
+ 18853,
+ 6715,
+ 17171,
+ 9887,
+ 12743,
+ 2605,
+ 8937,
+ 3140,
+ 19033,
+ 7764,
+ 18347,
+ 3880,
+ 20475,
+ 3682,
+ 19602,
+ 3380,
+ 13044,
+ 19373,
+ 10526,
+ 23124
+};
+
+
+/* table used in 'high' rates: MR67 MR74 */
+#define VQ_SIZE_HIGHRATES 128
+static const Word32 table_gain_highrates[VQ_SIZE_HIGHRATES * 4] = {
+ /*
+ * Note: every 4th value (qua_ener) contains the original values from IS641
+ * to ensure bit-exactness; however, they are not exactly the
+ * rounded value of (20*log10(g_fac))
+ */ /*
+* g_pit,
+* g_fac,
+* qua_ener_MR122,
+* qua_ener
+*/ 577,
+ 662,
+ - 2692,
+ - 16214,
+ 806,
+ 1836,
+ - 1185,
+ - 7135,
+ 3109,
+ 1052,
+ - 2008,
+ - 12086,
+ 4181,
+ 1387,
+ - 1600,
+ - 9629,
+ 2373,
+ 1425,
+ - 1560,
+ - 9394,
+ 3248,
+ 1985,
+ - 1070,
+ - 6442,
+ 1827,
+ 2320,
+ - 840,
+ - 5056,
+ 941,
+ 3314,
+ - 313,
+ - 1885,
+ 2351,
+ 2977,
+ - 471,
+ - 2838,
+ 3616,
+ 2420,
+ - 777,
+ - 4681,
+ 3451,
+ 3096,
+ - 414,
+ - 2490,
+ 2955,
+ 4301,
+ 72,
+ 434,
+ 1848,
+ 4500,
+ 139,
+ 836,
+ 3884,
+ 5416,
+ 413,
+ 2484,
+ 1187,
+ 7210,
+ 835,
+ 5030,
+ 3083,
+ 9000,
+ 1163,
+ 7002,
+ 7384,
+ 883,
+ - 2267,
+ - 13647,
+ 5962,
+ 1506,
+ - 1478,
+ - 8900,
+ 5155,
+ 2134,
+ - 963,
+ - 5800,
+ 7944,
+ 2009,
+ - 1052,
+ - 6335,
+ 6507,
+ 2250,
+ - 885,
+ - 5327,
+ 7670,
+ 2752,
+ - 588,
+ - 3537,
+ 5952,
+ 3016,
+ - 452,
+ - 2724,
+ 4898,
+ 3764,
+ - 125,
+ - 751,
+ 6989,
+ 3588,
+ - 196,
+ - 1177,
+ 8174,
+ 3978,
+ - 43,
+ - 260,
+ 6064,
+ 4404,
+ 107,
+ 645,
+ 7709,
+ 5087,
+ 320,
+ 1928,
+ 5523,
+ 6021,
+ 569,
+ 3426,
+ 7769,
+ 7126,
+ 818,
+ 4926,
+ 6060,
+ 7938,
+ 977,
+ 5885,
+ 5594,
+ 11487,
+ 1523,
+ 9172,
+ 10581,
+ 1356,
+ - 1633,
+ - 9831,
+ 9049,
+ 1597,
+ - 1391,
+ - 8380,
+ 9794,
+ 2035,
+ - 1033,
+ - 6220,
+ 8946,
+ 2415,
+ - 780,
+ - 4700,
+ 10296,
+ 2584,
+ - 681,
+ - 4099,
+ 9407,
+ 2734,
+ - 597,
+ - 3595,
+ 8700,
+ 3218,
+ - 356,
+ - 2144,
+ 9757,
+ 3395,
+ - 277,
+ - 1669,
+ 10177,
+ 3892,
+ - 75,
+ - 454,
+ 9170,
+ 4528,
+ 148,
+ 891,
+ 10152,
+ 5004,
+ 296,
+ 1781,
+ 9114,
+ 5735,
+ 497,
+ 2993,
+ 10500,
+ 6266,
+ 628,
+ 3782,
+ 10110,
+ 7631,
+ 919,
+ 5534,
+ 8844,
+ 8727,
+ 1117,
+ 6728,
+ 8956,
+ 12496,
+ 1648,
+ 9921,
+ 12924,
+ 976,
+ - 2119,
+ - 12753,
+ 11435,
+ 1755,
+ - 1252,
+ - 7539,
+ 12138,
+ 2328,
+ - 835,
+ - 5024,
+ 11388,
+ 2368,
+ - 810,
+ - 4872,
+ 10700,
+ 3064,
+ - 429,
+ - 2580,
+ 12332,
+ 2861,
+ - 530,
+ - 3192,
+ 11722,
+ 3327,
+ - 307,
+ - 1848,
+ 11270,
+ 3700,
+ - 150,
+ - 904,
+ 10861,
+ 4413,
+ 110,
+ 663,
+ 12082,
+ 4533,
+ 150,
+ 902,
+ 11283,
+ 5205,
+ 354,
+ 2132,
+ 11960,
+ 6305,
+ 637,
+ 3837,
+ 11167,
+ 7534,
+ 900,
+ 5420,
+ 12128,
+ 8329,
+ 1049,
+ 6312,
+ 10969,
+ 10777,
+ 1429,
+ 8604,
+ 10300,
+ 17376,
+ 2135,
+ 12853,
+ 13899,
+ 1681,
+ - 1316,
+ - 7921,
+ 12580,
+ 2045,
+ - 1026,
+ - 6179,
+ 13265,
+ 2439,
+ - 766,
+ - 4610,
+ 14033,
+ 2989,
+ - 465,
+ - 2802,
+ 13452,
+ 3098,
+ - 413,
+ - 2482,
+ 12396,
+ 3658,
+ - 167,
+ - 1006,
+ 13510,
+ 3780,
+ - 119,
+ - 713,
+ 12880,
+ 4272,
+ 62,
+ 374,
+ 13533,
+ 4861,
+ 253,
+ 1523,
+ 12667,
+ 5457,
+ 424,
+ 2552,
+ 13854,
+ 6106,
+ 590,
+ 3551,
+ 13031,
+ 6483,
+ 678,
+ 4084,
+ 13557,
+ 7721,
+ 937,
+ 5639,
+ 12957,
+ 9311,
+ 1213,
+ 7304,
+ 13714,
+ 11551,
+ 1532,
+ 9221,
+ 12591,
+ 15206,
+ 1938,
+ 11667,
+ 15113,
+ 1540,
+ - 1445,
+ - 8700,
+ 15072,
+ 2333,
+ - 832,
+ - 5007,
+ 14527,
+ 2511,
+ - 723,
+ - 4352,
+ 14692,
+ 3199,
+ - 365,
+ - 2197,
+ 15382,
+ 3560,
+ - 207,
+ - 1247,
+ 14133,
+ 3960,
+ - 50,
+ - 300,
+ 15102,
+ 4236,
+ 50,
+ 298,
+ 14332,
+ 4824,
+ 242,
+ 1454,
+ 14846,
+ 5451,
+ 422,
+ 2542,
+ 15306,
+ 6083,
+ 584,
+ 3518,
+ 14329,
+ 6888,
+ 768,
+ 4623,
+ 15060,
+ 7689,
+ 930,
+ 5602,
+ 14406,
+ 9426,
+ 1231,
+ 7413,
+ 15387,
+ 9741,
+ 1280,
+ 7706,
+ 14824,
+ 14271,
+ 1844,
+ 11102,
+ 13600,
+ 24939,
+ 2669,
+ 16067,
+ 16396,
+ 1969,
+ - 1082,
+ - 6517,
+ 16817,
+ 2832,
+ - 545,
+ - 3283,
+ 15713,
+ 2843,
+ - 539,
+ - 3248,
+ 16104,
+ 3336,
+ - 303,
+ - 1825,
+ 16384,
+ 3963,
+ - 49,
+ - 294,
+ 16940,
+ 4579,
+ 165,
+ 992,
+ 15711,
+ 4599,
+ 171,
+ 1030,
+ 16222,
+ 5448,
+ 421,
+ 2537,
+ 16832,
+ 6382,
+ 655,
+ 3945,
+ 15745,
+ 7141,
+ 821,
+ 4944,
+ 16326,
+ 7469,
+ 888,
+ 5343,
+ 16611,
+ 8624,
+ 1100,
+ 6622,
+ 17028,
+ 10418,
+ 1379,
+ 8303,
+ 15905,
+ 11817,
+ 1565,
+ 9423,
+ 16878,
+ 14690,
+ 1887,
+ 11360,
+ 16515,
+ 20870,
+ 2406,
+ 14483,
+ 18142,
+ 2083,
+ - 999,
+ - 6013,
+ 19401,
+ 3178,
+ - 375,
+ - 2257,
+ 17508,
+ 3426,
+ - 264,
+ - 1589,
+ 20054,
+ 4027,
+ - 25,
+ - 151,
+ 18069,
+ 4249,
+ 54,
+ 326,
+ 18952,
+ 5066,
+ 314,
+ 1890,
+ 17711,
+ 5402,
+ 409,
+ 2461,
+ 19835,
+ 6192,
+ 610,
+ 3676,
+ 17950,
+ 7014,
+ 795,
+ 4784,
+ 21318,
+ 7877,
+ 966,
+ 5816,
+ 17910,
+ 9289,
+ 1210,
+ 7283,
+ 19144,
+ 9290,
+ 1210,
+ 7284,
+ 20517,
+ 11381,
+ 1510,
+ 9089,
+ 18075,
+ 14485,
+ 1866,
+ 11234,
+ 19999,
+ 17882,
+ 2177,
+ 13108,
+ 18842,
+ 32764,
+ 3072,
+ 18494
+};
+
+/* table used in 'low' rates: MR475, MR515, MR59 */
+#define VQ_SIZE_LOWRATES 64
+static const Word32 table_gain_lowrates[VQ_SIZE_LOWRATES * 4] = {
+ /*
+ * g_pit,
+ * g_fac,
+ * qua_ener_MR122,
+ * qua_ener
+ */ 10813,
+ 28753,
+ 2879,
+ 17333,
+ 20480,
+ 2785,
+ - 570,
+ - 3431,
+ 18841,
+ 6594,
+ 703,
+ 4235,
+ 6225,
+ 7413,
+ 876,
+ 5276,
+ 17203,
+ 10444,
+ 1383,
+ 8325,
+ 21626,
+ 1269,
+ - 1731,
+ - 10422,
+ 21135,
+ 4423,
+ 113,
+ 683,
+ 11304,
+ 1556,
+ - 1430,
+ - 8609,
+ 19005,
+ 12820,
+ 1686,
+ 10148,
+ 17367,
+ 2498,
+ - 731,
+ - 4398,
+ 17858,
+ 4833,
+ 244,
+ 1472,
+ 9994,
+ 2498,
+ - 731,
+ - 4398,
+ 17530,
+ 7864,
+ 964,
+ 5802,
+ 14254,
+ 1884,
+ - 1147,
+ - 6907,
+ 15892,
+ 3153,
+ - 387,
+ - 2327,
+ 6717,
+ 1802,
+ - 1213,
+ - 7303,
+ 18186,
+ 20193,
+ 2357,
+ 14189,
+ 18022,
+ 3031,
+ - 445,
+ - 2678,
+ 16711,
+ 5857,
+ 528,
+ 3181,
+ 8847,
+ 4014,
+ - 30,
+ - 180,
+ 15892,
+ 8970,
+ 1158,
+ 6972,
+ 18022,
+ 1392,
+ - 1594,
+ - 9599,
+ 16711,
+ 4096,
+ 0,
+ 0,
+ 8192,
+ 655,
+ - 2708,
+ - 16305,
+ 15237,
+ 13926,
+ 1808,
+ 10884,
+ 14254,
+ 3112,
+ - 406,
+ - 2444,
+ 14090,
+ 4669,
+ 193,
+ 1165,
+ 5406,
+ 2703,
+ - 614,
+ - 3697,
+ 13434,
+ 6553,
+ 694,
+ 4180,
+ 12451,
+ 901,
+ - 2237,
+ - 13468,
+ 12451,
+ 2662,
+ - 637,
+ - 3833,
+ 3768,
+ 655,
+ - 2708,
+ - 16305,
+ 14745,
+ 23511,
+ 2582,
+ 15543,
+ 19169,
+ 2457,
+ - 755,
+ - 4546,
+ 20152,
+ 5079,
+ 318,
+ 1913,
+ 6881,
+ 4096,
+ 0,
+ 0,
+ 20480,
+ 8560,
+ 1089,
+ 6556,
+ 19660,
+ 737,
+ - 2534,
+ - 15255,
+ 19005,
+ 4259,
+ 58,
+ 347,
+ 7864,
+ 2088,
+ - 995,
+ - 5993,
+ 11468,
+ 12288,
+ 1623,
+ 9771,
+ 15892,
+ 1474,
+ - 1510,
+ - 9090,
+ 15728,
+ 4628,
+ 180,
+ 1086,
+ 9175,
+ 1433,
+ - 1552,
+ - 9341,
+ 16056,
+ 7004,
+ 793,
+ 4772,
+ 14827,
+ 737,
+ - 2534,
+ - 15255,
+ 15073,
+ 2252,
+ - 884,
+ - 5321,
+ 5079,
+ 1228,
+ - 1780,
+ - 10714,
+ 13271,
+ 17326,
+ 2131,
+ 12827,
+ 16547,
+ 2334,
+ - 831,
+ - 5002,
+ 15073,
+ 5816,
+ 518,
+ 3118,
+ 3932,
+ 3686,
+ - 156,
+ - 938,
+ 14254,
+ 8601,
+ 1096,
+ 6598,
+ 16875,
+ 778,
+ - 2454,
+ - 14774,
+ 15073,
+ 3809,
+ - 107,
+ - 646,
+ 6062,
+ 614,
+ - 2804,
+ - 16879,
+ 9338,
+ 9256,
+ 1204,
+ 7251,
+ 13271,
+ 1761,
+ - 1247,
+ - 7508,
+ 13271,
+ 3522,
+ - 223,
+ - 1343,
+ 2457,
+ 1966,
+ - 1084,
+ - 6529,
+ 11468,
+ 5529,
+ 443,
+ 2668,
+ 10485,
+ 737,
+ - 2534,
+ - 15255,
+ 11632,
+ 3194,
+ - 367,
+ - 2212,
+ 1474,
+ 778,
+ - 2454,
+ - 14774
+};
+
+static const Word32 inter6[61] = {
+ 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
+};
+
+/*
+ * window for non-MR122 modesm; uses 40 samples lookahead
+ * used only in BuildCNParam
+ */
+static const Word32 window_200_40[L_WINDOW] = {
+ 2621, 2623, 2629, 2638, 2651, 2668, 2689, 2713, 2741, 2772,
+ 2808, 2847, 2890, 2936, 2986, 3040, 3097, 3158, 3223, 3291,
+ 3363, 3438, 3517, 3599, 3685, 3774, 3867, 3963, 4063, 4166,
+ 4272, 4382, 4495, 4611, 4731, 4853, 4979, 5108, 5240, 5376,
+ 5514, 5655, 5800, 5947, 6097, 6250, 6406, 6565, 6726, 6890,
+ 7057, 7227, 7399, 7573, 7750, 7930, 8112, 8296, 8483, 8672,
+ 8863, 9057, 9252, 9450, 9650, 9852, 10055, 10261, 10468, 10677,
+ 10888, 11101, 11315, 11531, 11748, 11967, 12187, 12409, 12632, 12856,
+ 13082, 13308, 13536, 13764, 13994, 14225, 14456, 14688, 14921, 15155,
+ 15389, 15624, 15859, 16095, 16331, 16568, 16805, 17042, 17279, 17516,
+ 17754, 17991, 18228, 18465, 18702, 18939, 19175, 19411, 19647, 19882,
+ 20117, 20350, 20584, 20816, 21048, 21279, 21509, 21738, 21967, 22194,
+ 22420, 22644, 22868, 23090, 23311, 23531, 23749, 23965, 24181, 24394,
+ 24606, 24816, 25024, 25231, 25435, 25638, 25839, 26037, 26234, 26428,
+ 26621, 26811, 26999, 27184, 27368, 27548, 27727, 27903, 28076, 28247,
+ 28415, 28581, 28743, 28903, 29061, 29215, 29367, 29515, 29661, 29804,
+ 29944, 30081, 30214, 30345, 30472, 30597, 30718, 30836, 30950, 31062,
+ 31170, 31274, 31376, 31474, 31568, 31659, 31747, 31831, 31911, 31988,
+ 32062, 32132, 32198, 32261, 32320, 32376, 32428, 32476, 32521, 32561,
+ 32599, 32632, 32662, 32688, 32711, 32729, 32744, 32755, 32763, 32767,
+ 32767, 32741, 32665, 32537, 32359, 32129, 31850, 31521, 31143, 30716,
+ 30242, 29720, 29151, 28538, 27879, 27177, 26433, 25647, 24821, 23957,
+ 23055, 22117, 21145, 20139, 19102, 18036, 16941, 15820, 14674, 13505,
+ 12315, 11106, 9879, 8637, 7381, 6114, 4838, 3554, 2264, 971
+};
+
+
+
+
+/* comparision optimization tables */
+/* definition of bad speech */
+static const UWord8 table_speech_bad[9] = {0, 0, 1, 1, 0, 0, 0, 1, 0};
+static const UWord8 table_SID[9] = {0, 0, 0, 0, 1, 1, 1, 0, 0};
+static const UWord8 table_DTX[9] = {0, 0, 0, 0, 1, 1, 1, 1, 0};
+static const UWord8 table_mute[9] = {0, 0, 0, 0, 1, 0, 1, 1, 0};
+
+/* track start positions for fixed codebook routines */
+static const Word8 startPos[16] = {
+ 0,
+ 2,
+ 0,
+ 3,
+ 0,
+ 2,
+ 0,
+ 3,
+ 1,
+ 3,
+ 2,
+ 4,
+ 1,
+ 4,
+ 1,
+ 4
+};
+
+
+
+#ifdef ENABLE_CPU2_DECODER
+CPU2_DATA_END
+#endif
+
+#endif
+
diff --git a/audio_codec/libamr/sp_dec.c b/audio_codec/libamr/sp_dec.c
new file mode 100644
index 0000000..8ccca93
--- a/dev/null
+++ b/audio_codec/libamr/sp_dec.c
@@ -0,0 +1,6078 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * R99 V3.5.0 2003-03
+ * REL-4 V4.4.0 2003-03
+ * REL-5 V5.1.0 2003-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * sp_dec.c
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * This module contains all the functions needed decoding AMR
+ * encoder parameters to 16-bit speech samples
+ *
+ */
+/*
+ * include files
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <memory.h>
+#include <math.h>
+#include "sp_dec.h"
+#include "rom_dec.h"
+
+
+/*
+ * Declare structure types
+ */
+enum DTXStateType {
+ SPEECH = 0, DTX, DTX_MUTE
+};
+
+/*
+ * Decoder memory structure
+ */
+typedef struct {
+ /* history vector of past synthesis speech energy */
+ Word32 frameEnergyHist[L_ENERGYHIST];
+
+
+ /* state flags */
+ Word16 bgHangover; /* counter; number of frames after last speech frame */
+
+
+} Bgn_scdState;
+typedef struct {
+ Word32 hangCount; /* counter; */
+ /* history vector of past synthesis speech energy */
+ Word32 cbGainHistory[L_CBGAINHIST];
+ Word16 hangVar; /* counter; */
+
+} Cb_gain_averageState;
+typedef struct {
+ Word32 lsp_meanSave[M]; /* Averaged LSPs saved for efficiency */
+
+
+} lsp_avgState;
+typedef struct {
+ Word32 past_r_q[M]; /* Past quantized prediction error, Q15 */
+ Word32 past_lsf_q[M]; /* Past dequantized lsfs, Q15 */
+
+
+} D_plsfState;
+typedef struct {
+ Word32 pbuf[5];
+ Word32 past_gain_pit;
+ Word32 prev_gp;
+
+
+} ec_gain_pitchState;
+typedef struct {
+ Word32 gbuf[5];
+ Word32 past_gain_code;
+ Word32 prev_gc;
+
+
+} ec_gain_codeState;
+typedef struct {
+ /*
+ * normal MA predictor memory, Q10
+ * (contains 20*log10(quaErr))
+ */
+ Word32 past_qua_en[4];
+
+
+ /*
+ * MA predictor memory for MR122 mode, Q10
+ * (contains log2(quaErr))
+ */
+ Word32 past_qua_en_MR122[4];
+
+
+} gc_predState;
+typedef struct {
+ Word32 gainMem[PHDGAINMEMSIZE];
+ Word32 prevCbGain;
+ Word32 prevState;
+ Word16 lockFull;
+ Word16 onset;
+
+
+} ph_dispState;
+typedef struct {
+ enum DTXStateType dtxGlobalState; /* contains previous state */
+
+ Word32 log_en;
+ Word32 old_log_en;
+ Word32 pn_seed_rx;
+ Word32 lsp[M];
+ Word32 lsp_old[M];
+ Word32 lsf_hist[M * DTX_HIST_SIZE];
+ Word32 lsf_hist_mean[M * DTX_HIST_SIZE];
+ Word32 log_en_hist[DTX_HIST_SIZE];
+ Word32 true_sid_period_inv;
+ Word16 since_last_sid;
+ Word16 lsf_hist_ptr;
+ Word16 log_pg_mean;
+ Word16 log_en_hist_ptr;
+ Word16 log_en_adjust;
+ Word16 dtxHangoverCount;
+ Word16 decAnaElapsedCount;
+ Word16 sid_frame;
+ Word16 valid_data;
+ Word16 dtxHangoverAdded;
+
+
+ /* updated in main decoder */
+ Word16 data_updated; /* marker to know if CNI data is ever renewed */
+
+
+} dtx_decState;
+typedef struct {
+ Word32 past_gain;
+
+
+} agcState;
+typedef struct {
+ /* Excitation vector */
+ Word32 old_exc[L_SUBFR + PIT_MAX + L_INTERPOL];
+ Word32 *exc;
+ Word32 lsp_old[M];
+
+
+ /* Filter's memory */
+ Word32 mem_syn[M];
+
+
+ /* pitch sharpening */
+ Word32 sharp;
+ Word32 old_T0;
+
+
+ /* Variable holding received ltpLag, used in background noise and BFI */
+ Word32 T0_lagBuff;
+
+
+ /* Variables for the source characteristic detector (SCD) */
+ Word32 inBackgroundNoise;
+ Word32 voicedHangover;
+ Word32 ltpGainHistory[9];
+
+
+ /* Memories for bad frame handling */
+ Word32 excEnergyHist[9];
+ Word16 prev_bf;
+ Word16 prev_pdf;
+ Word16 state;
+ Word16 nodataSeed;
+
+
+ Bgn_scdState * background_state;
+ Cb_gain_averageState * Cb_gain_averState;
+ lsp_avgState * lsp_avg_st;
+ D_plsfState * lsfState;
+ ec_gain_pitchState * ec_gain_p_st;
+ ec_gain_codeState * ec_gain_c_st;
+ gc_predState * pred_state;
+ ph_dispState * ph_disp_st;
+ dtx_decState * dtxDecoderState;
+} Decoder_amrState;
+typedef struct {
+ Word32 res2[L_SUBFR];
+ Word32 mem_syn_pst[M];
+ Word32 synth_buf[M + L_FRAME];
+ Word32 preemph_state_mem_pre;
+ agcState * agc_state;
+} Post_FilterState;
+typedef struct {
+ Word32 y2_hi;
+ Word32 y2_lo;
+ Word32 y1_hi;
+ Word32 y1_lo;
+ Word32 x0;
+ Word32 x1;
+
+
+} Post_ProcessState;
+typedef struct {
+ Decoder_amrState * decoder_amrState;
+ Post_FilterState * post_state;
+ Post_ProcessState * postHP_state;
+} Speech_Decode_FrameState;
+
+
+/*
+ * CodAmrReset
+ *
+ *
+ * Parameters:
+ * state B: state structure
+ * mode I: AMR mode
+ *
+ * Function:
+ * Resets state memory
+ *
+ * Returns:
+ * void
+ */
+static void Decoder_amr_reset(Decoder_amrState *state, enum Mode mode)
+{
+ Word32 i;
+
+ /* Cb_gain_average_reset */
+ memset(state->Cb_gain_averState->cbGainHistory, 0, L_CBGAINHIST << 2);
+ state->Cb_gain_averState->hangVar = 0;
+ state->Cb_gain_averState->hangCount = 0;
+
+ /* Initialize static pointer */
+ state->exc = state->old_exc + PIT_MAX + L_INTERPOL;
+
+ /* Static vectors to zero */
+ memset(state->old_exc, 0, (PIT_MAX + L_INTERPOL) << 2);
+
+ if (mode != MRDTX) {
+ memset(state->mem_syn, 0, M << 2);
+ }
+
+ /* initialize pitch sharpening */
+ state->sharp = SHARPMIN;
+ state->old_T0 = 40;
+
+ /* Initialize state->lsp_old [] */
+ if (mode != MRDTX) {
+ state->lsp_old[0] = 30000;
+ state->lsp_old[1] = 26000;
+ state->lsp_old[2] = 21000;
+ state->lsp_old[3] = 15000;
+ state->lsp_old[4] = 8000;
+ state->lsp_old[5] = 0;
+ state->lsp_old[6] = -8000;
+ state->lsp_old[7] = -15000;
+ state->lsp_old[8] = -21000;
+ state->lsp_old[9] = -26000;
+ }
+
+ /* Initialize memories of bad frame handling */
+ state->prev_bf = 0;
+ state->prev_pdf = 0;
+ state->state = 0;
+ state->T0_lagBuff = 40;
+ state->inBackgroundNoise = 0;
+ state->voicedHangover = 0;
+
+ if (mode != MRDTX) {
+ memset(state->excEnergyHist, 0, 9 << 2);
+ }
+ memset(state->ltpGainHistory, 0, 9 << 2);
+
+ if (mode != MRDTX) {
+ state->lsp_avg_st->lsp_meanSave[0] = 1384;
+ state->lsp_avg_st->lsp_meanSave[1] = 2077;
+ state->lsp_avg_st->lsp_meanSave[2] = 3420;
+ state->lsp_avg_st->lsp_meanSave[3] = 5108;
+ state->lsp_avg_st->lsp_meanSave[4] = 6742;
+ state->lsp_avg_st->lsp_meanSave[5] = 8122;
+ state->lsp_avg_st->lsp_meanSave[6] = 9863;
+ state->lsp_avg_st->lsp_meanSave[7] = 11092;
+ state->lsp_avg_st->lsp_meanSave[8] = 12714;
+ state->lsp_avg_st->lsp_meanSave[9] = 13701;
+ }
+ memset(state->lsfState->past_r_q, 0, M << 2);
+
+ /* Past dequantized lsfs */
+ state->lsfState->past_lsf_q[0] = 1384;
+ state->lsfState->past_lsf_q[1] = 2077;
+ state->lsfState->past_lsf_q[2] = 3420;
+ state->lsfState->past_lsf_q[3] = 5108;
+ state->lsfState->past_lsf_q[4] = 6742;
+ state->lsfState->past_lsf_q[5] = 8122;
+ state->lsfState->past_lsf_q[6] = 9863;
+ state->lsfState->past_lsf_q[7] = 11092;
+ state->lsfState->past_lsf_q[8] = 12714;
+ state->lsfState->past_lsf_q[9] = 13701;
+
+ for (i = 0; i < 5; i++) {
+ state->ec_gain_p_st->pbuf[i] = 1640;
+ }
+ state->ec_gain_p_st->past_gain_pit = 0;
+ state->ec_gain_p_st->prev_gp = 16384;
+
+ for (i = 0; i < 5; i++) {
+ state->ec_gain_c_st->gbuf[i] = 1;
+ }
+ state->ec_gain_c_st->past_gain_code = 0;
+ state->ec_gain_c_st->prev_gc = 1;
+
+ if (mode != MRDTX) {
+ for (i = 0; i < NPRED; i++) {
+ state->pred_state->past_qua_en[i] = MIN_ENERGY;
+ state->pred_state->past_qua_en_MR122[i] = MIN_ENERGY_MR122;
+ }
+ }
+ state->nodataSeed = 21845;
+
+ /* Static vectors to zero */
+ memset(state->background_state->frameEnergyHist, 0, L_ENERGYHIST << 2);
+
+ /* Initialize hangover handling */
+ state->background_state->bgHangover = 0;
+
+ /* phDispReset */
+ memset(state->ph_disp_st->gainMem, 0, PHDGAINMEMSIZE << 2);
+ state->ph_disp_st->prevState = 0;
+ state->ph_disp_st->prevCbGain = 0;
+ state->ph_disp_st->lockFull = 0;
+ state->ph_disp_st->onset = 0; /* assume no onset in start */
+
+ if (mode != MRDTX) {
+ state->dtxDecoderState->since_last_sid = 0;
+ state->dtxDecoderState->true_sid_period_inv = 8192;
+ state->dtxDecoderState->log_en = 3500;
+ state->dtxDecoderState->old_log_en = 3500;
+
+ /* low level noise for better performance in DTX handover cases*/
+ state->dtxDecoderState->pn_seed_rx = PN_INITIAL_SEED;
+
+ /* Initialize state->lsp [] */
+ state->dtxDecoderState->lsp[0] = 30000;
+ state->dtxDecoderState->lsp[1] = 26000;
+ state->dtxDecoderState->lsp[2] = 21000;
+ state->dtxDecoderState->lsp[3] = 15000;
+ state->dtxDecoderState->lsp[4] = 8000;
+ state->dtxDecoderState->lsp[5] = 0;
+ state->dtxDecoderState->lsp[6] = -8000;
+ state->dtxDecoderState->lsp[7] = -15000;
+ state->dtxDecoderState->lsp[8] = -21000;
+ state->dtxDecoderState->lsp[9] = -26000;
+
+ /* Initialize state->lsp_old [] */
+ state->dtxDecoderState->lsp_old[0] = 30000;
+ state->dtxDecoderState->lsp_old[1] = 26000;
+ state->dtxDecoderState->lsp_old[2] = 21000;
+ state->dtxDecoderState->lsp_old[3] = 15000;
+ state->dtxDecoderState->lsp_old[4] = 8000;
+ state->dtxDecoderState->lsp_old[5] = 0;
+ state->dtxDecoderState->lsp_old[6] = -8000;
+ state->dtxDecoderState->lsp_old[7] = -15000;
+ state->dtxDecoderState->lsp_old[8] = -21000;
+ state->dtxDecoderState->lsp_old[9] = -26000;
+ state->dtxDecoderState->lsf_hist_ptr = 0;
+ state->dtxDecoderState->log_pg_mean = 0;
+ state->dtxDecoderState->log_en_hist_ptr = 0;
+
+ /* initialize decoder lsf history */
+ state->dtxDecoderState->lsf_hist[0] = 1384;
+ state->dtxDecoderState->lsf_hist[1] = 2077;
+ state->dtxDecoderState->lsf_hist[2] = 3420;
+ state->dtxDecoderState->lsf_hist[3] = 5108;
+ state->dtxDecoderState->lsf_hist[4] = 6742;
+ state->dtxDecoderState->lsf_hist[5] = 8122;
+ state->dtxDecoderState->lsf_hist[6] = 9863;
+ state->dtxDecoderState->lsf_hist[7] = 11092;
+ state->dtxDecoderState->lsf_hist[8] = 12714;
+ state->dtxDecoderState->lsf_hist[9] = 13701;
+
+ for (i = 1; i < DTX_HIST_SIZE; i++) {
+ memcpy(&state->dtxDecoderState->lsf_hist[M * i], &state->
+ dtxDecoderState->lsf_hist[0], M << 2);
+ }
+ memset(state->dtxDecoderState->lsf_hist_mean, 0, M * DTX_HIST_SIZE << 2);
+
+ /* initialize decoder log frame energy */
+ for (i = 0; i < DTX_HIST_SIZE; i++) {
+ state->dtxDecoderState->log_en_hist[i] = state->dtxDecoderState->log_en
+ ;
+ }
+ state->dtxDecoderState->log_en_adjust = 0;
+ state->dtxDecoderState->dtxHangoverCount = DTX_HANG_CONST;
+ state->dtxDecoderState->decAnaElapsedCount = 31;
+ state->dtxDecoderState->sid_frame = 0;
+ state->dtxDecoderState->valid_data = 0;
+ state->dtxDecoderState->dtxHangoverAdded = 0;
+ state->dtxDecoderState->dtxGlobalState = DTX;
+ state->dtxDecoderState->data_updated = 0;
+ }
+ return;
+}
+
+
+/*
+ * rx_dtx_handler
+ *
+ *
+ * Parameters:
+ * st->dtxGlobalState I: DTX state
+ * st->since_last_sid B: Frames after last SID frame
+ * st->data_updated I: SID update flag
+ * st->decAnaElapsedCount B: state machine that synch with the GSMEFR txDtx machine
+ * st->dtxHangoverAdded B: DTX hangover
+ * st->sid_frame O: SID frame indicator
+ * st->valid_data O: Vaild data indicator
+ * frame_type O: Frame type
+ *
+ * Function:
+ * Find the new DTX state
+ *
+ * Returns:
+ * DTXStateType DTX, DTX_MUTE or SPEECH
+ */
+static enum DTXStateType rx_dtx_handler(dtx_decState *st, enum RXFrameType frame_type)
+{
+ enum DTXStateType newState;
+ enum DTXStateType encState;
+
+ /* DTX if SID frame or previously in DTX{_MUTE} and (NO_RX OR BAD_SPEECH) */
+ if (table_SID[frame_type] | ((st->dtxGlobalState != SPEECH) &
+ table_speech_bad[frame_type])) {
+ newState = DTX;
+
+ /* stay in mute for these input types */
+ if ((st->dtxGlobalState == DTX_MUTE) & table_mute[frame_type]) {
+ newState = DTX_MUTE;
+ }
+
+ /*
+ * evaluate if noise parameters are too old
+ * since_last_sid is reset when CN parameters have been updated
+ */
+ st->since_last_sid += 1;
+
+ /* no update of sid parameters in DTX for a long while */
+ if ((frame_type != RX_SID_UPDATE) & (st->since_last_sid > DTX_MAX_EMPTY_THRESH)) {
+ newState = DTX_MUTE;
+ }
+ } else {
+ newState = SPEECH;
+ st->since_last_sid = 0;
+ }
+
+ /*
+ * reset the decAnaElapsed Counter when receiving CNI data the first
+ * time, to robustify counter missmatch after handover
+ * this might delay the bwd CNI analysis in the new decoder slightly.
+ */
+ if ((st->data_updated == 0) & (frame_type == RX_SID_UPDATE)) {
+ st->decAnaElapsedCount = 0;
+ }
+
+ /*
+ * update the SPE-SPD DTX hangover synchronization
+ * to know when SPE has added dtx hangover
+ */
+ st->decAnaElapsedCount += 1;
+ st->dtxHangoverAdded = 0;
+ encState = SPEECH;
+
+ if (table_DTX[frame_type]) {
+ encState = DTX;
+ if ((frame_type == RX_NO_DATA) & (newState == SPEECH)) {
+ encState = SPEECH;
+ }
+ }
+
+ if (encState == SPEECH) {
+ st->dtxHangoverCount = DTX_HANG_CONST;
+ } else {
+ if (st->decAnaElapsedCount > DTX_ELAPSED_FRAMES_THRESH) {
+ st->dtxHangoverAdded = 1;
+ st->decAnaElapsedCount = 0;
+ st->dtxHangoverCount = 0;
+ } else if (st->dtxHangoverCount == 0) {
+ st->decAnaElapsedCount = 0;
+ } else {
+ st->dtxHangoverCount -= 1;
+ }
+ }
+
+ if (newState != SPEECH) {
+ /*
+ * DTX or DTX_MUTE
+ * CN data is not in a first SID, first SIDs are marked as SID_BAD
+ * but will do backwards analysis if a hangover period has been added
+ * according to the state machine above
+ */
+ st->sid_frame = 0;
+ st->valid_data = 0;
+
+ if (frame_type == RX_SID_FIRST) {
+ st->sid_frame = 1;
+ } else if (frame_type == RX_SID_UPDATE) {
+ st->sid_frame = 1;
+ st->valid_data = 1;
+ } else if (frame_type == RX_SID_BAD) {
+ st->sid_frame = 1;
+
+ /* use old data */
+ st->dtxHangoverAdded = 0;
+ }
+ }
+
+ /* newState is used by both SPEECH AND DTX synthesis routines */
+ return newState;
+}
+
+
+/*
+ * Lsf_lsp
+ *
+ *
+ * Parameters:
+ * lsf I: vector of LSFs
+ * lsp O: vector of LSPs
+ *
+ * Function:
+ * Transformation lsf to lsp, order M
+ *
+ * Returns:
+ * void
+ */
+static void Lsf_lsp(Word32 lsf[], Word32 lsp[])
+{
+ Word32 i, ind, offset, tmp;
+
+
+ for (i = 0; i < M; i++) {
+ /* ind = b8-b15 of lsf[i] */
+ ind = lsf[i] >> 8;
+
+ /* offset = b0-b7 of lsf[i] */
+ offset = lsf[i] & 0x00ff;
+
+ /* lsp[i] = table[ind]+ ((table[ind+1]-table[ind])*offset) / 256 */
+ tmp = ((cos_table[ind + 1] - cos_table[ind]) * offset) << 1;
+ lsp[i] = cos_table[ind] + (tmp >> 9);
+ }
+ return;
+}
+
+
+/*
+ * D_plsf_3
+ *
+ *
+ * Parameters:
+ * st->past_lsf_q I: Past dequantized LFSs
+ * st->past_r_q B: past quantized residual
+ * mode I: AMR mode
+ * bfi B: bad frame indicator
+ * indice I: quantization indices of 3 submatrices, Q0
+ * lsp1_q O: quantized 1st LSP vector
+ *
+ * Function:
+ * Decodes the LSP parameters using the received quantization indices.
+ * 1st order MA prediction and split by 3 vector quantization (split-VQ)
+ *
+ * Returns:
+ * void
+ */
+static void D_plsf_3(D_plsfState *st, enum Mode mode, Word16 bfi, Word16 *
+ indice, Word32 *lsp1_q)
+{
+ Word32 lsf1_r[M], lsf1_q[M];
+ Word32 i, index, temp;
+ const Word32 *p_cb1, *p_cb2, *p_cb3, *p_dico;
+
+
+ /* if bad frame */
+ if (bfi != 0) {
+ /* use the past LSFs slightly shifted towards their mean */
+ for (i = 0; i < M; i++) {
+ /* lsfi_q[i] = ALPHA*past_lsf_q[i] + ONE_ALPHA*meanLsf[i]; */
+ lsf1_q[i] = ((st->past_lsf_q[i] * ALPHA) >> 15) + ((mean_lsf_3[i]
+ * ONE_ALPHA) >> 15);
+ }
+
+ /* estimate past quantized residual to be used in next frame */
+ if (mode != MRDTX) {
+ for (i = 0; i < M; i++) {
+ /* temp = meanLsf[i] + pastR2_q[i] * pred_fac; */
+ temp = mean_lsf_3[i] + ((st->past_r_q[i] * pred_fac[i]) >> 15);
+ st->past_r_q[i] = lsf1_q[i] - temp;
+ }
+ } else {
+ for (i = 0; i < M; i++) {
+ /* temp = meanLsf[i] + pastR2_q[i]; */
+ temp = mean_lsf_3[i] + st->past_r_q[i];
+ st->past_r_q[i] = lsf1_q[i] - temp;
+ }
+ }
+ }
+
+ /* if good LSFs received */
+ else {
+ if ((mode == MR475) | (mode == MR515)) {
+ /* MR475, MR515 */
+ p_cb1 = dico1_lsf_3;
+ p_cb2 = dico2_lsf_3;
+ p_cb3 = mr515_3_lsf;
+ } else if (mode == MR795) {
+ /* MR795 */
+ p_cb1 = mr795_1_lsf;
+ p_cb2 = dico2_lsf_3;
+ p_cb3 = dico3_lsf_3;
+ } else {
+ /* MR59, MR67, MR74, MR102, MRDTX */
+ p_cb1 = dico1_lsf_3;
+ p_cb2 = dico2_lsf_3;
+ p_cb3 = dico3_lsf_3;
+ }
+
+ /* decode prediction residuals from 3 received indices */
+ index = *indice++;
+ p_dico = &p_cb1[index + index + index];
+ index = *indice++;
+ lsf1_r[0] = *p_dico++;
+ lsf1_r[1] = *p_dico++;
+ lsf1_r[2] = *p_dico++;
+
+ if ((mode == MR475) | (mode == MR515)) {
+ /* MR475, MR515 only using every second entry */
+ index = index << 1;
+ }
+ p_dico = &p_cb2[index + index + index];
+ index = *indice++;
+ lsf1_r[3] = *p_dico++;
+ lsf1_r[4] = *p_dico++;
+ lsf1_r[5] = *p_dico++;
+ p_dico = &p_cb3[index << 2];
+ lsf1_r[6] = *p_dico++;
+ lsf1_r[7] = *p_dico++;
+ lsf1_r[8] = *p_dico++;
+ lsf1_r[9] = *p_dico++;
+
+ /* Compute quantized LSFs and update the past quantized residual */
+ if (mode != MRDTX) {
+ for (i = 0; i < M; i++) {
+ lsf1_q[i] = lsf1_r[i] + (mean_lsf_3[i] + ((st->past_r_q[i] *
+ pred_fac[i]) >> 15));
+ }
+ memcpy(st->past_r_q, lsf1_r, M << 2);
+ } else {
+ for (i = 0; i < M; i++) {
+ lsf1_q[i] = lsf1_r[i] + (mean_lsf_3[i] + st->past_r_q[i]);
+ }
+ memcpy(st->past_r_q, lsf1_r, M << 2);
+ }
+ }
+
+ /* verification that LSFs has minimum distance of LSF_GAP Hz */
+ temp = LSF_GAP;
+
+ for (i = 0; i < M; i++) {
+ if (lsf1_q[i] < temp) {
+ lsf1_q[i] = temp;
+ }
+ temp = lsf1_q[i] + LSF_GAP;
+ }
+ memcpy(st->past_lsf_q, lsf1_q, M << 2);
+
+ /* convert LSFs to the cosine domain */
+ Lsf_lsp(lsf1_q, lsp1_q);
+ return;
+}
+
+
+/*
+ * pseudonoise
+ *
+ *
+ * Parameters:
+ * shift_reg B: Old CN generator shift register state
+ * no_bits I: Number of bits
+ *
+ * Function:
+ * pseudonoise
+ *
+ * Returns:
+ * noise_bits
+ */
+static Word32 pseudonoise(Word32 *shift_reg, Word32 no_bits)
+{
+ Word32 noise_bits, Sn, i;
+ Word32 s_reg;
+
+
+ s_reg = *shift_reg;
+ noise_bits = 0;
+
+ for (i = 0; i < no_bits; i++) {
+ /* State n == 31 */
+ Sn = s_reg & 0x00000001L;
+
+ /* State n == 3 */
+ if (s_reg & 0x10000000L) {
+ Sn = Sn ^ 0x1L;
+ } else {
+ Sn = Sn ^ 0x0L;
+ }
+ noise_bits = (noise_bits << 1) | (s_reg & 1);
+ s_reg = s_reg >> 1;
+
+ if (Sn & 1) {
+ s_reg = s_reg | 0x40000000L;
+ }
+ }
+ *shift_reg = s_reg;
+ return noise_bits;
+}
+
+
+/*
+ * Lsp_lsf
+ *
+ *
+ * Parameters:
+ * lsp I: LSP vector (range: -1<=val<1)
+ * lsf O: LSF vector Old CN generator shift register state
+ *
+ * Function:
+ * Transformation lsp to lsf, LPC order M
+ * lsf[i] = arccos(lsp[i])/(2*pi)
+ *
+ * Returns:
+ * void
+ */
+static void Lsp_lsf(Word32 lsp[], Word32 lsf[])
+{
+ Word32 i, ind = 63; /* begin at end of table -1 */
+
+
+ for (i = M - 1; i >= 0; i--) {
+ /* find value in table that is just greater than lsp[i] */
+ while (cos_table[ind] < lsp[i]) {
+ ind--;
+ }
+ lsf[i] = ((((lsp[i] - cos_table[ind]) * acos_slope[ind]) + 0x800)
+ >> 12) + (ind << 8);
+ }
+ return;
+}
+
+
+/*
+ * Reorder_lsf
+ *
+ *
+ * Parameters:
+ * lsf B: vector of LSFs (range: 0<=val<=0.5)
+ * min_dist I: minimum required distance
+ *
+ * Function:
+ * Make sure that the LSFs are properly ordered and to keep a certain minimum
+ * distance between adjacent LSFs. LPC order = M.
+ *
+ * Returns:
+ * void
+ */
+static void Reorder_lsf(Word32 *lsf, Word32 min_dist)
+{
+ Word32 lsf_min, i;
+
+
+ lsf_min = min_dist;
+
+ for (i = 0; i < M; i++) {
+ if (lsf[i] < lsf_min) {
+ lsf[i] = lsf_min;
+ }
+ lsf_min = lsf[i] + min_dist;
+ }
+}
+
+/* VC5.0 Global optimization does not work with this function */
+#if _MSC_VER == 1100
+#pragma optimize( "g", off )
+#endif
+/*
+ * Get_lsp_pol
+ *
+ *
+ * Parameters:
+ * lsp I: line spectral frequencies
+ * f O: polynomial F1(z) or F2(z)
+ *
+ * Function:
+ * Find the polynomial F1(z) or F2(z) from the LSPs.
+ *
+ * F1(z) = product ( 1 - 2 lsp[i] z^-1 + z^-2 )
+ * i=0,2,4,6,8
+ * F2(z) = product ( 1 - 2 lsp[i] z^-1 + z^-2 )
+ * i=1,3,5,7,9
+ *
+ * where lsp[] is the LSP vector in the cosine domain.
+ *
+ * The expansion is performed using the following recursion:
+ *
+ * f[0] = 1
+ * b = -2.0 * lsp[0]
+ * f[1] = b
+ * for i=2 to 5 do
+ * b = -2.0 * lsp[2*i-2];
+ * f[i] = b*f[i-1] + 2.0*f[i-2];
+ * for j=i-1 down to 2 do
+ * f[j] = f[j] + b*f[j-1] + f[j-2];
+ * f[1] = f[1] + b;
+ *
+ * Returns:
+ * void
+ */
+static void Get_lsp_pol(Word32 *lsp, Word32 *f)
+{
+ Word32 f0, f1, f2, f3, f4, f5;
+ Word32 l1, l2, l3, l4;
+
+ /* f[0] = 1.0; */
+ f0 = 16777216L;
+
+ /* f1 = *lsp * -1024; */
+ f1 = -lsp[0] << 10;
+ l1 = lsp[2];
+ l2 = lsp[4];
+ l3 = lsp[6];
+ l4 = lsp[8];
+ f2 = f0 << 1;
+ f2 -= (((f1 >> 16) * l1) + (((f1 & 0xFFFE) * l1) >> 16)) << 2;
+ f1 -= l1 << 10;
+ f3 = f1 << 1;
+ f3 -= (((f2 >> 16) * l2) + (((f2 & 0xFFFE) * l2) >> 16)) << 2;
+ f2 += f0;
+ f2 -= (((f1 >> 16) * l2) + (((f1 & 0xFFFE) * l2) >> 16)) << 2;
+ f1 -= l2 << 10;
+ f4 = f2 << 1;
+ f4 -= (((f3 >> 16) * l3) + (((f3 & 0xFFFE) * l3) >> 16)) << 2;
+ f3 += f1;
+ f3 -= (((f2 >> 16) * l3) + (((f2 & 0xFFFE) * l3) >> 16)) << 2;
+ f2 += f0;
+ f2 -= (((f1 >> 16) * l3) + (((f1 & 0xFFFE) * l3) >> 16)) << 2;
+ f1 -= l3 << 10;
+ f5 = f3 << 1;
+ f5 -= (((f4 >> 16) * l4) + (((f4 & 0xFFFE) * l4) >> 16)) << 2;
+ f4 += f2;
+ f4 -= (((f3 >> 16) * l4) + (((f3 & 0xFFFE) * l4) >> 16)) << 2;
+ f3 += f1;
+ f3 -= (((f2 >> 16) * l4) + (((f2 & 0xFFFE) * l4) >> 16)) << 2;
+ f2 += f0;
+ f2 -= (((f1 >> 16) * l4) + (((f1 & 0xFFFE) * l4) >> 16)) << 2;
+ f1 -= l4 << 10;
+ f[0] = f0;
+ f[1] = f1;
+ f[2] = f2;
+ f[3] = f3;
+ f[4] = f4;
+ f[5] = f5;
+
+ return;
+}
+#if _MSC_VER == 1100
+#pragma optimize( "", on )
+#endif
+
+
+/*
+ * Lsp_Az
+ *
+ *
+ * Parameters:
+ * lsp I: Line spectral frequencies
+ * a O: Predictor coefficients
+ *
+ * Function:
+ * Converts from the line spectral pairs (LSP) to LP coefficients,
+ * for a 10th order filter.
+ *
+ * Find the coefficients of F1(z) and F2(z)
+ * Multiply F1(z) by 1+z^{-1} and F2(z) by 1-z^{-1}
+ * A(z) = ( F1(z) + F2(z) ) / 2
+ *
+ * Returns:
+ * void
+ */
+static void Lsp_Az(Word32 lsp[], Word32 a[])
+{
+ Word32 f1[6], f2[6];
+ Word32 T0, i, j;
+
+
+ Get_lsp_pol(&lsp[0], f1);
+ Get_lsp_pol(&lsp[1], f2);
+
+ for (i = 5; i > 0; i--) {
+ f1[i] += f1[i - 1];
+ f2[i] -= f2[i - 1];
+ }
+ a[0] = 4096;
+
+ for (i = 1, j = 10; i <= 5; i++, j--) {
+ T0 = f1[i] + f2[i];
+ a[i] = (Word16)(T0 >> 13); /* emulate fixed point bug */
+ if ((T0 & 4096) != 0) {
+ a[i]++;
+ }
+ T0 = f1[i] - f2[i];
+ a[j] = (Word16)(T0 >> 13); /* emulate fixed point bug */
+
+ if ((T0 & 4096) != 0) {
+ a[j]++;
+ }
+ }
+ return;
+}
+
+
+/*
+ * A_Refl
+ *
+ *
+ * Parameters:
+ * a I: Directform coefficients
+ * refl O: Reflection coefficients
+ *
+ * Function:
+ * Converts from the directform coefficients to reflection coefficients
+ *
+ * Returns:
+ * void
+ */
+static void A_Refl(Word32 a[], Word32 refl[])
+{
+ /* local variables */
+ int normShift;
+ Word32 aState[M], bState[M];
+ Word32 normProd, acc, temp, mult, scale, i, j;
+
+
+ /* initialize states */
+ memcpy(aState, a, M << 2);
+
+ /* backward Levinson recursion */
+ for (i = M - 1; i >= 0; i--) {
+ if (labs(aState[i]) >= 4096) {
+ goto ExitRefl;
+ }
+ refl[i] = aState[i] << 3;
+ temp = (refl[i] * refl[i]) << 1;
+ acc = (MAX_32 - temp);
+ normShift = 0;
+ if (acc != 0) {
+ temp = acc;
+ while (!(temp & 0x40000000)) {
+ normShift++;
+ temp = temp << 1;
+ }
+ } else {
+ normShift = 0;
+ }
+ scale = 15 - normShift;
+ acc = (acc << normShift);
+ temp = (acc + (Word32)0x00008000L);
+
+ if (temp > 0) {
+ normProd = temp >> 16;
+ mult = 0x20000000L / normProd;
+ } else {
+ mult = 16384;
+ }
+
+ for (j = 0; j < i; j++) {
+ acc = aState[j] << 16;
+ acc -= (refl[i] * aState[i - j - 1]) << 1;
+ temp = (acc + (Word32)0x00008000L) >> 16;
+ temp = (mult * temp) << 1;
+
+ if (scale > 0) {
+ if ((temp & ((Word32)1 << (scale - 1))) != 0) {
+ temp = (temp >> scale) + 1;
+ } else {
+ temp = (temp >> scale);
+ }
+ } else {
+ temp = (temp >> scale);
+ }
+
+ if (labs(temp) > 32767) {
+ goto ExitRefl;
+ }
+ bState[j] = temp;
+ }
+ memcpy(aState, bState, i << 2);
+ }
+ return;
+ExitRefl:
+ memset(refl, 0, M << 2);
+}
+
+
+/*
+ * Log2_norm
+ *
+ *
+ * Parameters:
+ * x I: input value
+ * exp I: exponent
+ * exponent O: Integer part of Log2. (range: 0<=val<=30)
+ * fraction O: Fractional part of Log2. (range: 0<=val<1)
+ *
+ * Function:
+ * Computes log2
+ *
+ * Computes log2(L_x, exp), where L_x is positive and
+ * normalized, and exp is the normalisation exponent
+ * If L_x is negative or zero, the result is 0.
+ *
+ * The function Log2(L_x) is approximated by a table and linear
+ * interpolation. The following steps are used to compute Log2(L_x)
+ *
+ * exponent = 30-normExponent
+ * i = bit25-b31 of L_x; 32<=i<=63 (because of normalization).
+ * a = bit10-b24
+ * i -=32
+ * fraction = table[i]<<16 - (table[i] - table[i+1]) * a * 2
+ *
+ * Returns:
+ * void
+ */
+static void Log2_norm(Word32 x, Word32 exp, Word32 *exponent, Word32 *
+ fraction)
+{
+ Word32 y, i, a;
+
+
+ if (x <= 0) {
+ *exponent = 0;
+ *fraction = 0;
+ return;
+ }
+
+ /* Extract b25-b31 */
+ i = x >> 25;
+ i = i - 32;
+
+ /* Extract b10-b24 of fraction */
+ a = x >> 9;
+ a = a & 0xFFFE; /* 2a */
+
+ /* fraction */
+ y = (log2_table[i] << 16) - a * (log2_table[i] - log2_table[i + 1]);
+ *fraction = y >> 16;
+ *exponent = 30 - exp;
+ return;
+}
+
+
+/*
+ * Log2
+ *
+ *
+ * Parameters:
+ * x I: input value
+ * exponent O: Integer part of Log2. (range: 0<=val<=30)
+ * fraction O: Fractional part of Log2. (range: 0<=val<1)
+ *
+ * Function:
+ * Computes log2(L_x)
+ * If x is negative or zero, the result is 0.
+ *
+ * Returns:
+ * void
+ */
+static void Log2(Word32 x, Word32 *exponent, Word32 *fraction)
+{
+ int tmp, exp = 0;
+
+ if (x != 0) {
+ tmp = x;
+ while (!((tmp & 0x80000000) ^((tmp & 0x40000000) << 1))) {
+ exp++;
+ tmp = tmp << 1;
+ }
+ }
+ Log2_norm(x << exp, exp, exponent, fraction);
+}
+
+
+/*
+ * Pow2
+ *
+ *
+ * Parameters:
+ * exponent I: Integer part. (range: 0<=val<=30)
+ * fraction O: Fractional part. (range: 0.0<=val<1.0)
+ *
+ * Function:
+ * pow(2.0, exponent.fraction)
+ *
+ * The function Pow2(L_x) is approximated by a table and linear interpolation.
+ *
+ * i = bit10-b15 of fraction, 0 <= i <= 31
+ * a = biT0-b9 of fraction
+ * x = table[i]<<16 - (table[i] - table[i+1]) * a * 2
+ * x = L_x >> (30-exponent) (with rounding)
+ *
+ * Returns:
+ * result (range: 0<=val<=0x7fffffff)
+ */
+static Word32 Pow2(Word32 exponent, Word32 fraction)
+{
+ Word32 i, a, tmp, x, exp;
+
+
+ /* Extract b10-b16 of fraction */
+ i = fraction >> 10;
+
+ /* Extract b0-b9 of fraction */
+ a = (fraction << 5) & 0x7fff;
+
+ /* table[i] << 16 */
+ x = pow2_table[i] << 16;
+
+ /* table[i] - table[i+1] */
+ tmp = pow2_table[i] - pow2_table[i + 1];
+
+ /* L_x -= tmp*a*2 */
+ x -= (tmp * a) << 1;
+
+ if (exponent >= -1) {
+ exp = (30 - exponent);
+
+ /* Rounding */
+ if ((x & ((Word32)1 << (exp - 1))) != 0) {
+ x = (x >> exp) + 1;
+ } else {
+ x = x >> exp;
+ }
+ } else {
+ x = 0;
+ }
+ return(x);
+}
+
+
+/*
+ * Build_CN_code
+ *
+ *
+ * Parameters:
+ * seed B: Old CN generator shift register state
+ * cod O: Generated CN fixed codebook vector
+ *
+ * Function:
+ * Generate CN fixed codebook vector
+ *
+ * Returns:
+ * void
+ */
+static void Build_CN_code(Word32 *seed, Word32 cod[])
+{
+ Word32 i, j, k;
+
+
+ memset(cod, 0, L_SUBFR << 2);
+
+ for (k = 0; k < 10; k++) {
+ i = pseudonoise(seed, 2); /* generate pulse position */
+ i = (i * 20) >> 1;
+ i = (i + k);
+ j = pseudonoise(seed, 1); /* generate sign */
+
+ if (j > 0) {
+ cod[i] = 4096;
+ } else {
+ cod[i] = -4096;
+ }
+ }
+ return;
+}
+
+
+/*
+ * Build_CN_param
+ *
+ *
+ * Parameters:
+ * seed B: Old CN generator shift register state
+ * nParam I: number of params
+ * paramSizeTable I: size of params
+ * parm O: CN Generated params
+ *
+ * Function:
+ * Generate parameters for comfort noise generation
+ *
+ * Returns:
+ * void
+ */
+static void Build_CN_param(Word16 *seed, enum Mode mode, Word16 parm[])
+{
+ Word32 i;
+ const Word32 *p;
+
+
+ *seed = (Word16)((*seed * 31821) + 13849L);
+ p = &window_200_40[ * seed & 0x7F];
+
+ switch (mode) {
+ case MR122:
+ for (i = 0; i < PRMNO_MR122; i++) {
+ parm[i] = (Word16)(*p++ & ~(0xFFFF << bitno_MR122[i]));
+ }
+ break;
+
+ case MR102:
+ for (i = 0; i < PRMNO_MR102; i++) {
+ parm[i] = (Word16)(*p++ & ~(0xFFFF << bitno_MR102[i]));
+ }
+ break;
+
+ case MR795:
+ for (i = 0; i < PRMNO_MR795; i++) {
+ parm[i] = (Word16)(*p++ & ~(0xFFFF << bitno_MR795[i]));
+ }
+ break;
+
+ case MR74:
+ for (i = 0; i < PRMNO_MR74; i++) {
+ parm[i] = (Word16)(*p++ & ~(0xFFFF << bitno_MR74[i]));
+ }
+ break;
+
+ case MR67:
+ for (i = 0; i < PRMNO_MR67; i++) {
+ parm[i] = (Word16)(*p++ & ~(0xFFFF << bitno_MR67[i]));
+ }
+ break;
+
+ case MR59:
+ for (i = 0; i < PRMNO_MR59; i++) {
+ parm[i] = (Word16)(*p++ & ~(0xFFFF << bitno_MR59[i]));
+ }
+ break;
+
+ case MR515:
+ for (i = 0; i < PRMNO_MR515; i++) {
+ parm[i] = (Word16)(*p++ & ~(0xFFFF << bitno_MR515[i]));
+ }
+ break;
+
+ case MR475:
+ for (i = 0; i < PRMNO_MR475; i++) {
+ parm[i] = (Word16)(*p++ & ~(0xFFFF << bitno_MR475[i]));
+ }
+ break;
+ }
+}
+
+
+/*
+ * Syn_filt
+ *
+ *
+ * Parameters:
+ * a I: prediction coefficients [M+1]
+ * x I: input signal
+ * y O: output signal
+ * lg I: size of filtering
+ * mem B: memory associated with this filtering
+ * update I: 0=no update, 1=update of memory.
+ *
+ * Function:
+ * Perform synthesis filtering through 1/A(z).
+ *
+ * Returns:
+ * void
+ */
+volatile int kk_entery = 0;
+static Word32 Syn_filt(Word32 a[], Word32 x[], Word32 y[], Word32 lg, Word32 mem[]
+ , Word32 update)
+{
+ Word32 tmp[50]; /* malloc is slow */
+ Word32 s, a0, overflow = 0;
+ Word32 *yy, *yy_limit;
+
+
+ /* Copy mem[] to yy[] */
+ memcpy(tmp, mem, 40);
+ yy = tmp + M;
+ yy_limit = yy + lg;
+ a0 = a[0];
+ kk_entery++;
+ /* Do the filtering. */
+ while (yy < yy_limit) {
+
+ s = *x++ * a0;
+ s -= yy[-1] * a[1];
+ s -= yy[-2] * a[2];
+ s -= yy[-3] * a[3];
+ s -= yy[-4] * a[4];
+ s -= yy[-5] * a[5];
+ s -= yy[-6] * a[6];
+ s -= yy[-7] * a[7];
+ s -= yy[-8] * a[8];
+ s -= yy[-9] * a[9];
+ s -= yy[-10] * a[10];
+ if (labs(s) < 0x7ffffff) {
+ *yy = (s + 0x800L) >> 12;
+ } else if (s > 0) {
+ *yy = 32767;
+ overflow = 1;
+ } else {
+ *yy = -32768;
+ overflow = 1;
+ }
+ yy++;
+ }
+ memcpy(y, &tmp[M], lg << 2);
+
+ /* Update of memory if update==1 */
+ if (update) {
+ memcpy(mem, &y[lg - M], 40);
+ }
+ return overflow;
+}
+
+/*
+ * Syn_filt_overflow
+ *
+ *
+ * Parameters:
+ * a I: prediction coefficients [M+1]
+ * x I: input signal
+ * y O: output signal
+ * lg I: size of filtering
+ * mem B: memory associated with this filtering
+ * update I: 0=no update, 1=update of memory.
+ *
+ * Function:
+ * Perform synthesis filtering through 1/A(z).
+ * Saturate after every multiplication.
+ * Returns:
+ * void
+ */
+static void Syn_filt_overflow(Word32 a[], Word32 x[], Word32 y[], Word32 lg, Word32 mem[]
+ , Word32 update)
+{
+ Word32 tmp[50]; /* malloc is slow */
+ Word32 i, j, s, a0;
+ Word32 *yy;
+
+
+ /* Copy mem[] to yy[] */
+ memcpy(tmp, mem, 40);
+ yy = tmp + M;
+ a0 = a[0];
+
+ /* Do the filtering. */
+ for (i = 0; i < lg; i++) {
+ s = x[i] * a0;
+
+ for (j = 1; j <= M; j++) {
+ s -= a[j] * yy[ - j];
+ if (s > 1073741823) {
+ s = 1073741823;
+ } else if (s < -1073741824) {
+ s = -1073741824;
+ }
+ }
+
+ if (labs(s) < 0x7FFE800) {
+ *yy = (s + 0x800L) >> 12;
+ } else if (s > 0) {
+ *yy = 32767;
+ } else {
+ *yy = -32768;
+ }
+ yy++;
+ }
+ memcpy(y, &tmp[M], lg << 2);
+
+ /* Update of memory if update==1 */
+ if (update) {
+ memcpy(mem, &y[lg - M], 40);
+ }
+ return;
+}
+
+/*
+ * dtx_dec
+ *
+ *
+ * Parameters:
+ * st B: DTX state struct
+ * mem_syn I: AMR decoder state
+ * lsfState B: LSF state struct
+ * pred_state->past_qua_en O: table of past quantized energies
+ * pred_state->past_qua_en_MR122 O: table of past quantized energies MR122
+ * averState->hangVar O:
+ * averState->hangCount O: hangover variable
+ * new_state I: new DTX state
+ * mode I: AMR mode
+ * parm I: vector of synthesis parameters
+ * synth O: synthesised speech
+ * A_t O: decoded LP filter in 4 subframes
+ *
+ * Function:
+ * DTX
+ *
+ * Returns:
+ * void
+ */
+static void dtx_dec(dtx_decState *st, Word32 *mem_syn, D_plsfState *lsfState,
+ gc_predState *pred_state, Cb_gain_averageState *averState, enum
+ DTXStateType new_state, enum Mode mode, Word16 parm[], Word32 synth[],
+ Word32 A_t[])
+{
+ Word32 ex[L_SUBFR], acoeff[11], acoeff_variab[M + 1], lsp_int[M];
+ Word32 refl[M], lsf[M], lsf_int[M], lsf_int_variab[M], lsp_int_variab[M];
+ Word32 i, j, int_fac, log_en_int, pred_err, log_pg_e, log_pg_m, log_pg;
+ Word32 negative, lsf_mean, lsf_variab_index, lsf_variab_factor, ptr;
+ Word16 log_en_index, log_en_int_e, log_en_int_m, level, ma_pred_init,
+ tmp_int_length;
+
+
+ if ((st->dtxHangoverAdded != 0) & (st->sid_frame != 0)) {
+ /*
+ * sidFirst after dtx hangover period
+ * or sidUpd after dtxhangover
+ */
+ /* set log_en_adjust to correct value */
+ st->log_en_adjust = dtx_log_en_adjust[mode];
+ ptr = st->lsf_hist_ptr + M;
+
+ if (ptr == 80) {
+ ptr = 0;
+ }
+ memcpy(&st->lsf_hist[ptr], &st->lsf_hist[st->lsf_hist_ptr], M << 2);
+ ptr = st->log_en_hist_ptr + 1;
+
+ if (ptr == DTX_HIST_SIZE) {
+ ptr = 0;
+ }
+ st->log_en_hist[ptr] = st->log_en_hist[st->log_en_hist_ptr]; /* Q11 */
+
+ /*
+ * compute mean log energy and lsp
+ * from decoded signal (SID_FIRST)
+ */
+ st->log_en = 0;
+ memset(lsf, 0, M << 2);
+
+ /* average energy and lsp */
+ for (i = 0; i < DTX_HIST_SIZE; i++) {
+ st->log_en = st->log_en + (st->log_en_hist[i] >> 3);
+
+ for (j = 0; j < M; j++) {
+ lsf[j] += st->lsf_hist[i * M + j];
+ }
+ }
+
+ for (j = 0; j < M; j++) {
+ lsf[j] = lsf[j] >> 3; /* divide by 8 */
+ }
+ Lsf_lsp(lsf, st->lsp);
+
+ /*
+ * make log_en speech coder mode independent
+ * added again later before synthesis
+ */
+ st->log_en = st->log_en - st->log_en_adjust;
+
+ /* compute lsf variability vector */
+ memcpy(st->lsf_hist_mean, st->lsf_hist, 80 << 2);
+
+ for (i = 0; i < M; i++) {
+ lsf_mean = 0;
+
+ /* compute mean lsf */
+ for (j = 0; j < 8; j++) {
+ lsf_mean += st->lsf_hist_mean[i + j * M];
+ }
+ lsf_mean = lsf_mean >> 3;
+
+ /*
+ * subtract mean and limit to within reasonable limits
+ * moreover the upper lsf's are attenuated
+ */
+ for (j = 0; j < 8; j++) {
+ /* subtract mean */
+ st->lsf_hist_mean[i + j * M] = st->lsf_hist_mean[i + j * M] -
+ lsf_mean;
+
+ /* attenuate deviation from mean, especially for upper lsf's */
+ st->lsf_hist_mean[i + j * M] = (st->lsf_hist_mean[i + j * M] *
+ lsf_hist_mean_scale[i]) >> 15;
+
+ /* limit the deviation */
+ if (st->lsf_hist_mean[i + j * M] < 0) {
+ negative = 1;
+ } else {
+ negative = 0;
+ }
+ st->lsf_hist_mean[i + j * M] = labs(st->lsf_hist_mean[i + j * M]);
+
+ /* apply soft limit */
+ if (st->lsf_hist_mean[i + j * M] > 655) {
+ st->lsf_hist_mean[i + j * M] = 655 + ((st->lsf_hist_mean[i + j
+ * M] - 655) >> 2);
+ }
+
+ /* apply hard limit */
+ if (st->lsf_hist_mean[i + j * M] > 1310) {
+ st->lsf_hist_mean[i + j * M] = 1310;
+ }
+
+ if (negative != 0) {
+ st->lsf_hist_mean[i + j * M] = -st->lsf_hist_mean[i + j * M];
+ }
+ }
+ }
+ }
+
+ if (st->sid_frame != 0) {
+ /*
+ * Set old SID parameters, always shift
+ * even if there is no new valid_data
+ */
+ memcpy(st->lsp_old, st->lsp, M << 2);
+ st->old_log_en = st->log_en;
+
+ if (st->valid_data != 0) { /* new data available (no CRC) */
+ /* Compute interpolation factor, since the division only works
+ * for values of since_last_sid < 32 we have to limit the
+ * interpolation to 32 frames
+ */
+ tmp_int_length = st->since_last_sid;
+ st->since_last_sid = 0;
+
+ if (tmp_int_length > 32) {
+ tmp_int_length = 32;
+ }
+
+ if (tmp_int_length >= 2) {
+ st->true_sid_period_inv = 0x2000000 / (tmp_int_length
+ << 10);
+ } else {
+ st->true_sid_period_inv = 16384; /* 0.5 it Q15 */
+ }
+ memcpy(lsfState->past_r_q, &past_rq_init[parm[0] * M], M << 2);
+ D_plsf_3(lsfState, MRDTX, 0, &parm[1], st->lsp);
+
+ /* reset for next speech frame */
+ memset(lsfState->past_r_q, 0, M << 2);
+ log_en_index = parm[4];
+
+ /* Q11 and divide by 4 */
+ st->log_en = (Word16)(log_en_index << 9);
+
+ /* Subtract 2.5 in Q11 */
+ st->log_en = (Word16)(st->log_en - 5120);
+
+ /* Index 0 is reserved for silence */
+ if (log_en_index == 0) {
+ st->log_en = MIN_16;
+ }
+
+ /*
+ * no interpolation at startup after coder reset
+ * or when SID_UPD has been received right after SPEECH
+ */
+ if ((st->data_updated == 0) || (st->dtxGlobalState == SPEECH)) {
+ memcpy(st->lsp_old, st->lsp, M << 2);
+ st->old_log_en = st->log_en;
+ }
+ } /* endif valid_data */
+
+ /* initialize gain predictor memory of other modes */
+ ma_pred_init = (Word16)((st->log_en >> 1) - 9000);
+
+ if (ma_pred_init > 0) {
+ ma_pred_init = 0;
+ }
+
+ if (ma_pred_init < - 14436) {
+ ma_pred_init = -14436;
+ }
+ pred_state->past_qua_en[0] = ma_pred_init;
+ pred_state->past_qua_en[1] = ma_pred_init;
+ pred_state->past_qua_en[2] = ma_pred_init;
+ pred_state->past_qua_en[3] = ma_pred_init;
+
+ /* past_qua_en for other modes than MR122 */
+ ma_pred_init = (Word16)((5443 * ma_pred_init) >> 15);
+
+ /* scale down by factor 20*log10(2) in Q15 */
+ pred_state->past_qua_en_MR122[0] = ma_pred_init;
+ pred_state->past_qua_en_MR122[1] = ma_pred_init;
+ pred_state->past_qua_en_MR122[2] = ma_pred_init;
+ pred_state->past_qua_en_MR122[3] = ma_pred_init;
+ } /* endif sid_frame */
+
+ /*
+ * CN generation
+ * recompute level adjustment factor Q11
+ * st->log_en_adjust = 0.9*st->log_en_adjust +
+ * 0.1*dtx_log_en_adjust[mode]);
+ */
+ st->log_en_adjust = (Word16)(((st->log_en_adjust * 29491) >> 15) + ((
+ (dtx_log_en_adjust[mode] << 5) * 3277) >> 20));
+
+ /* Interpolate SID info */
+ /* Q10 */
+ if (st->since_last_sid > 30) {
+ int_fac = 32767;
+ } else {
+ int_fac = (Word16)((st->since_last_sid + 1) << 10);
+ }
+
+ /* Q10 * Q15 -> Q10 */
+ int_fac = (int_fac * st->true_sid_period_inv) >> 15;
+
+ /* Maximize to 1.0 in Q10 */
+ if (int_fac > 1024) {
+ int_fac = 1024;
+ }
+
+ /* Q10 -> Q14 */
+ int_fac = (Word16)(int_fac << 4);
+
+ /* Q14 * Q11->Q26 */
+ log_en_int = (int_fac * st->log_en) << 1;
+
+ for (i = 0; i < M; i++) {
+ /* Q14 * Q15 -> Q14 */
+ lsp_int[i] = (int_fac * st->lsp[i]) >> 15;
+ }
+
+ /* 1-k in Q14 */
+ int_fac = 16384 - int_fac;
+
+ /* (Q14 * Q11 -> Q26) + Q26 -> Q26 */
+ log_en_int += (int_fac * st->old_log_en) << 1;
+
+ for (i = 0; i < M; i++) {
+ /* Q14 + (Q14 * Q15 -> Q14) -> Q14 */
+ lsp_int[i] = lsp_int[i] + ((int_fac * st->lsp_old[i]) >> 15);
+
+ /* Q14 -> Q15 */
+ lsp_int[i] = lsp_int[i] << 1;
+ }
+
+ /* compute the amount of lsf variability */
+ /* -0.6 in Q12 */
+ lsf_variab_factor = st->log_pg_mean - 2457;
+
+ /* *0.3 Q12*Q15 -> Q12 */
+ lsf_variab_factor = 4096 - ((lsf_variab_factor * 9830) >> 15);
+
+ /* limit to values between 0..1 in Q12 */
+ if (lsf_variab_factor >= 4096) {
+ lsf_variab_factor = 32767;
+ } else if (lsf_variab_factor < 0) {
+ lsf_variab_factor = 0;
+ } else {
+ lsf_variab_factor = lsf_variab_factor << 3; /* -> Q15 */
+ }
+
+ /* get index of vector to do variability with */
+ lsf_variab_index = pseudonoise(&st->pn_seed_rx, 3);
+
+ /* convert to lsf */
+ Lsp_lsf(lsp_int, lsf_int);
+
+ /* apply lsf variability */
+ memcpy(lsf_int_variab, lsf_int, M << 2);
+
+ for (i = 0; i < M; i++) {
+ lsf_int_variab[i] = lsf_int_variab[i] + ((lsf_variab_factor * st->
+ lsf_hist_mean[i + lsf_variab_index * M]) >> 15);
+ }
+
+ /* make sure that LSP's are ordered */
+ Reorder_lsf(lsf_int, LSF_GAP);
+ Reorder_lsf(lsf_int_variab, LSF_GAP);
+
+ /* copy lsf to speech decoders lsf state */
+ memcpy(lsfState->past_lsf_q, lsf_int, M << 2);
+
+ /* convert to lsp */
+ Lsf_lsp(lsf_int, lsp_int);
+ Lsf_lsp(lsf_int_variab, lsp_int_variab);
+
+ /* Compute acoeffs Q12 acoeff is used for level
+ * normalization and Post_Filter, acoeff_variab is
+ * used for synthesis filter
+ * by doing this we make sure that the level
+ * in high frequenncies does not jump up and down
+ */
+ Lsp_Az(lsp_int, acoeff);
+ Lsp_Az(lsp_int_variab, acoeff_variab);
+
+ /* For use in Post_Filter */
+ memcpy(&A_t[0], acoeff, MP1 << 2);
+ memcpy(&A_t[MP1], acoeff, MP1 << 2);
+ memcpy(&A_t[MP1 << 1], acoeff, MP1 << 2);
+ memcpy(&A_t[MP1 + MP1 + MP1], acoeff, MP1 << 2);
+
+ /* Compute reflection coefficients Q15 */
+ A_Refl(&acoeff[1], refl);
+
+ /* Compute prediction error in Q15 */
+ /* 0.99997 in Q15 */
+ pred_err = MAX_16;
+
+ for (i = 0; i < M; i++) {
+ pred_err = (pred_err * (MAX_16 - ((refl[i] * refl[i]) >> 15))) >>
+ 15;
+ }
+
+ /* compute logarithm of prediction gain */
+ Log2(pred_err, &log_pg_e, &log_pg_m);
+
+ /* convert exponent and mantissa to Word16 Q12 */
+ /* Q12 */
+ log_pg = (log_pg_e - 15) << 12;
+ /* saturate */
+ if (log_pg < -32768) {
+ log_pg = -32768;
+ }
+ log_pg = (-(log_pg + (log_pg_m >> 3))) >> 1;
+ st->log_pg_mean = (Word16)(((29491 * st->log_pg_mean) >> 15) + ((3277
+ * log_pg) >> 15));
+
+ /* Compute interpolated log energy */
+ /* Q26 -> Q16 */
+ log_en_int = log_en_int >> 10;
+
+ /* Add 4 in Q16 */
+ log_en_int += 262144L;
+
+ /* subtract prediction gain */
+ log_en_int = log_en_int - (log_pg << 4);
+
+ /* adjust level to speech coder mode */
+ log_en_int += st->log_en_adjust << 5;
+ log_en_int_e = (Word16)(log_en_int >> 16);
+ log_en_int_m = (Word16)((log_en_int - (log_en_int_e << 16)) >> 1);
+
+ /* Q4 */
+ level = (Word16)(Pow2(log_en_int_e, log_en_int_m));
+
+ for (i = 0; i < 4; i++) {
+ /* Compute innovation vector */
+ Build_CN_code(&st->pn_seed_rx, ex);
+
+ for (j = 0; j < L_SUBFR; j++) {
+ ex[j] = (level * ex[j]) >> 15;
+ }
+
+ /* Synthesize */
+ Syn_filt(acoeff_variab, ex, &synth[i * L_SUBFR], L_SUBFR, mem_syn, 1);
+ } /* next i */
+
+ /* reset codebook averaging variables */
+ averState->hangVar = 20;
+ averState->hangCount = 0;
+
+ if (new_state == DTX_MUTE) {
+ /*
+ * mute comfort noise as it has been quite a long time since
+ * last SID update was performed
+ */
+ Word32 num, denom;
+
+
+ tmp_int_length = st->since_last_sid;
+
+ if (tmp_int_length > 32) {
+ tmp_int_length = 32;
+ }
+
+ if (tmp_int_length == 1) {
+ st->true_sid_period_inv = MAX_16;
+ } else {
+ num = 1024;
+ denom = (tmp_int_length << 10);
+ st->true_sid_period_inv = 0;
+
+ for (i = 0; i < 15; i++) {
+ st->true_sid_period_inv <<= 1;
+ num <<= 1;
+
+ if (num >= denom) {
+ num = num - denom;
+ st->true_sid_period_inv += 1;
+ }
+ }
+ }
+ st->since_last_sid = 0;
+ memcpy(st->lsp_old, st->lsp, M << 2);
+ st->old_log_en = st->log_en;
+
+ /* subtract 1/8 in Q11 i.e -6/8 dB */
+ st->log_en = st->log_en - 256;
+ if (st->log_en < -32768) {
+ st->log_en = -32768;
+ }
+ }
+
+ /*
+ * reset interpolation length timer
+ * if data has been updated.
+ */
+ if ((st->sid_frame != 0) & ((st->valid_data != 0) || ((st->valid_data
+ == 0) & (st->dtxHangoverAdded != 0)))) {
+ st->since_last_sid = 0;
+ st->data_updated = 1;
+ }
+ return;
+}
+
+
+/*
+ * lsp_avg
+ *
+ *
+ * Parameters:
+ * st->lsp_meanSave B: LSP averages
+ * lsp I: LSPs
+ *
+ * Function:
+ * Calculate the LSP averages
+ *
+ * Returns:
+ * void
+ */
+static void lsp_avg(lsp_avgState *st, Word32 *lsp)
+{
+ Word32 i, tmp;
+
+
+ for (i = 0; i < M; i++) {
+ /* mean = 0.84*mean */
+ tmp = (st->lsp_meanSave[i] << 16);
+ tmp -= (EXPCONST * st->lsp_meanSave[i]) << 1;
+
+ /* Add 0.16 of newest LSPs to mean */
+ tmp += (EXPCONST * lsp[i]) << 1;
+
+ /* Save means */
+ tmp += 0x00008000L;
+ st->lsp_meanSave[i] = tmp >> 16;
+ }
+ return;
+}
+
+
+/*
+ * Int_lpc_1and3
+ *
+ *
+ * Parameters:
+ * lsp_old I: LSP vector at the 4th subfr. of past frame [M]
+ * lsp_mid I: LSP vector at the 2nd subframe of present frame [M]
+ * lsp_new I: LSP vector at the 4th subframe of present frame [M]
+ * Az O: interpolated LP parameters in subframes 1 and 3
+ * [AZ_SIZE]
+ *
+ * Function:
+ * Interpolates the LSPs and converts to LPC parameters
+ * to get a different LP filter in each subframe.
+ *
+ * The 20 ms speech frame is divided into 4 subframes.
+ * The LSPs are quantized and transmitted at the 2nd and
+ * 4th subframes (twice per frame) and interpolated at the
+ * 1st and 3rd subframe.
+ *
+ * Returns:
+ * void
+ */
+static void Int_lpc_1and3(Word32 lsp_old[], Word32 lsp_mid[], Word32 lsp_new[],
+ Word32 Az[])
+{
+ Word32 lsp[M];
+ Word32 i;
+
+ Word32 *Az1;
+ Az1 = Az;
+ /* lsp[i] = lsp_mid[i] * 0.5 + lsp_old[i] * 0.5 */
+ for (i = 0; i < 10; i++) {
+ lsp[i] = (lsp_mid[i] >> 1) + (lsp_old[i] >> 1);
+ }
+
+ /* Subframe 1 */
+ Lsp_Az(lsp, Az);
+ Az += MP1;
+
+ /* Subframe 2 */
+ Lsp_Az(lsp_mid, Az);
+ Az += MP1;
+
+ for (i = 0; i < 10; i++) {
+ lsp[i] = (lsp_mid[i] >> 1) + (lsp_new[i] >> 1);
+ }
+
+ /* Subframe 3 */
+ Lsp_Az(lsp, Az);
+ Az += MP1;
+
+ /* Subframe 4 */
+ Lsp_Az(lsp_new, Az);
+ return;
+}
+
+
+/*
+ * Int_lpc_1to3
+ *
+ *
+ * Parameters:
+ * lsp_old I: LSP vector at the 4th subframe of past frame [M]
+ * lsp_new I: LSP vector at the 4th subframe of present frame [M]
+ * Az O: interpolated LP parameters in all subframes
+ * [AZ_SIZE]
+ *
+ * Function:
+ * Interpolates the LSPs and converts to LPC parameters to get a different
+ * LP filter in each subframe.
+ *
+ * The 20 ms speech frame is divided into 4 subframes.
+ * The LSPs are quantized and transmitted at the 4th
+ * subframes (once per frame) and interpolated at the
+ * 1st, 2nd and 3rd subframe.
+ *
+ * Returns:
+ * void
+ */
+static void Int_lpc_1to3(Word32 lsp_old[], Word32 lsp_new[], Word32 Az[])
+{
+ Word32 lsp[M];
+ Word32 i;
+
+
+ for (i = 0; i < 10; i++) {
+ lsp[i] = (lsp_new[i] >> 2) + (lsp_old[i] - (lsp_old[i] >> 2));
+ }
+
+ /* Subframe 1 */
+ Lsp_Az(lsp, Az);
+ Az += MP1;
+
+ for (i = 0; i < 10; i++) {
+ lsp[i] = (lsp_old[i] >> 1) + (lsp_new[i] >> 1);
+ }
+
+ /* Subframe 2 */
+ Lsp_Az(lsp, Az);
+ Az += MP1;
+
+ for (i = 0; i < 10; i++) {
+ lsp[i] = (lsp_old[i] >> 2) + (lsp_new[i] - (lsp_new[i] >> 2));
+ }
+
+ /* Subframe 3 */
+ Lsp_Az(lsp, Az);
+ Az += MP1;
+
+ /* Subframe 4 */
+ Lsp_Az(lsp_new, Az);
+ return;
+}
+
+
+/*
+ * D_plsf_5
+ *
+ *
+ * Parameters:
+ * st->past_lsf_q I: Past dequantized LFSs
+ * st->past_r_q B: past quantized residual
+ * bfi B: bad frame indicator
+ * indice I: quantization indices of 3 submatrices, Q0
+ * lsp1_q O: quantized 1st LSP vector
+ * lsp2_q O: quantized 2nd LSP vector
+ *
+ * Function:
+ * Decodes the 2 sets of LSP parameters in a frame
+ * using the received quantization indices.
+ *
+ * Returns:
+ * void
+ */
+static void D_plsf_5(D_plsfState *st, Word16 bfi, Word16 *indice, Word32 *lsp1_q
+ , Word32 *lsp2_q)
+{
+ Word32 lsf1_r[M], lsf2_r[M], lsf1_q[M], lsf2_q[M];
+ Word32 i, temp1, temp2, sign;
+ const Word32 *p_dico;
+
+
+ /* if bad frame */
+ if (bfi != 0) {
+ /* use the past LSFs slightly shifted towards their mean */
+ for (i = 0; i < M; i += 2) {
+ /* lsfi_q[i] = ALPHA*st->past_lsf_q[i] + ONE_ALPHA*meanLsf[i]; */
+ lsf1_q[i] = ((st->past_lsf_q[i] * ALPHA_122) >> 15) + ((mean_lsf_5[i]
+ * ONE_ALPHA_122) >> 15);
+ lsf1_q[i + 1] = ((st->past_lsf_q[i + 1] * ALPHA_122) >> 15) + ((
+ mean_lsf_5[i + 1] * ONE_ALPHA_122) >> 15);
+ }
+ memcpy(lsf2_q, lsf1_q, M << 2);
+
+ /* estimate past quantized residual to be used in next frame */
+ for (i = 0; i < M; i += 2) {
+ /* temp = meanLsf[i] + st->past_r_q[i] * LSPPpred_facMR122; */
+ temp1 = mean_lsf_5[i] + ((st->past_r_q[i] * LSP_PRED_FAC_MR122) >>
+ 15);
+ temp2 = mean_lsf_5[i + 1] + ((st->past_r_q[i + 1] * LSP_PRED_FAC_MR122
+ ) >> 15);
+ st->past_r_q[i] = lsf2_q[i] - temp1;
+ st->past_r_q[i + 1] = lsf2_q[i + 1] - temp2;
+ }
+ }
+
+ /* if good LSFs received */
+ else {
+ /* decode prediction residuals from 5 received indices */
+ p_dico = &dico1_lsf_5[indice[0] << 2];
+ lsf1_r[0] = *p_dico++;
+ lsf1_r[1] = *p_dico++;
+ lsf2_r[0] = *p_dico++;
+ lsf2_r[1] = *p_dico++;
+ p_dico = &dico2_lsf_5[indice[1] << 2];
+ lsf1_r[2] = *p_dico++;
+ lsf1_r[3] = *p_dico++;
+ lsf2_r[2] = *p_dico++;
+ lsf2_r[3] = *p_dico++;
+ sign = (Word16)(indice[2] & 1);
+ i = indice[2] >> 1;
+ p_dico = &dico3_lsf_5[i << 2];
+
+ if (sign == 0) {
+ lsf1_r[4] = *p_dico++;
+ lsf1_r[5] = *p_dico++;
+ lsf2_r[4] = *p_dico++;
+ lsf2_r[5] = *p_dico++;
+ } else {
+ lsf1_r[4] = (Word16)(-(*p_dico++));
+ lsf1_r[5] = (Word16)(-(*p_dico++));
+ lsf2_r[4] = (Word16)(-(*p_dico++));
+ lsf2_r[5] = (Word16)(-(*p_dico++));
+ }
+ p_dico = &dico4_lsf_5[(indice[3] << 2)];
+ lsf1_r[6] = *p_dico++;
+ lsf1_r[7] = *p_dico++;
+ lsf2_r[6] = *p_dico++;
+ lsf2_r[7] = *p_dico++;
+ p_dico = &dico5_lsf_5[(indice[4] << 2)];
+ lsf1_r[8] = *p_dico++;
+ lsf1_r[9] = *p_dico++;
+ lsf2_r[8] = *p_dico++;
+ lsf2_r[9] = *p_dico++;
+
+ /* Compute quantized LSFs and update the past quantized residual */
+ for (i = 0; i < M; i++) {
+ temp1 = mean_lsf_5[i] + ((st->past_r_q[i] * LSP_PRED_FAC_MR122) >>
+ 15);
+ lsf1_q[i] = lsf1_r[i] + temp1;
+ lsf2_q[i] = lsf2_r[i] + temp1;
+ st->past_r_q[i] = lsf2_r[i];
+ }
+ }
+
+ /* verification that LSFs have minimum distance of LSF_GAP Hz */
+ Reorder_lsf(lsf1_q, LSF_GAP);
+ Reorder_lsf(lsf2_q, LSF_GAP);
+ memcpy(st->past_lsf_q, lsf2_q, M << 2);
+
+ /* convert LSFs to the cosine domain */
+ Lsf_lsp(lsf1_q, lsp1_q);
+ Lsf_lsp(lsf2_q, lsp2_q);
+ return;
+}
+
+
+/*
+ * Dec_lag3
+ *
+ *
+ * Parameters:
+ * index I: received pitch index
+ * t0_min I: minimum of search range
+ * t0_max I: maximum of search range
+ * i_subfr I: subframe flag
+ * T0_prev I: integer pitch delay of last subframe used
+ * in 2nd and 4th subframes
+ * T0 O: integer part of pitch lag
+ * T0_frac O : fractional part of pitch lag
+ * flag4 I : flag for encoding with 4 bits
+ * Function:
+ * Decoding of fractional pitch lag with 1/3 resolution.
+ * Extract the integer and fraction parts of the pitch lag from
+ * the received adaptive codebook index.
+ *
+ * The fractional lag in 1st and 3rd subframes is encoded with 8 bits
+ * while that in 2nd and 4th subframes is relatively encoded with 4, 5
+ * and 6 bits depending on the mode.
+ *
+ * Returns:
+ * void
+ */
+static void Dec_lag3(Word32 index, Word32 t0_min, Word32 t0_max, Word32 i_subfr
+ , Word32 T0_prev, Word32 *T0, Word32 *T0_frac, Word32 flag4)
+{
+ Word32 i, tmp_lag;
+
+
+ /* if 1st or 3rd subframe */
+ if (i_subfr == 0) {
+ if (index < 197) {
+ *T0 = (((index + 2) * 10923) >> 15) + 19;
+ i = *T0 + *T0 + *T0;
+ *T0_frac = (index - i) + 58;
+ } else {
+ *T0 = index - 112;
+ *T0_frac = 0;
+ }
+ }
+
+ /* 2nd or 4th subframe */
+ else {
+ if (flag4 == 0) {
+ /* 'normal' decoding: either with 5 or 6 bit resolution */
+ i = (((index + 2) * 10923) >> 15) - 1;
+ *T0 = i + t0_min;
+ i = i + i + i;
+ *T0_frac = (index - 2) - i;
+ } else {
+ /* decoding with 4 bit resolution */
+ tmp_lag = T0_prev;
+
+ if ((tmp_lag - t0_min) > 5) {
+ tmp_lag = t0_min + 5;
+ }
+
+ if ((t0_max - tmp_lag) > 4) {
+ tmp_lag = t0_max - 4;
+ }
+
+ if (index < 4) {
+ i = (tmp_lag - 5);
+ *T0 = i + index;
+ *T0_frac = 0;
+ } else {
+ if (index < 12) {
+ i = (((index - 5) * 10923) >> 15) - 1;
+ *T0 = i + tmp_lag;
+ i = i + i + i;
+ *T0_frac = (index - 9) - i;
+ } else {
+ i = (index - 12) + tmp_lag;
+ *T0 = i + 1;
+ *T0_frac = 0;
+ }
+ }
+ } /* end if (decoding with 4 bit resolution) */
+ }
+ return;
+}
+
+
+/*
+ * Pred_lt_3or6_40
+ *
+ *
+ * Parameters:
+ * exc B: excitation buffer
+ * T0 I: integer pitch lag
+ * frac I: fraction of lag
+ * flag3 I: if set, upsampling rate = 3 (6 otherwise)
+ *
+ * Function:
+ * Compute the result of long term prediction with fractional
+ * interpolation of resolution 1/3 or 1/6. (Interpolated past excitation).
+ *
+ * Once the fractional pitch lag is determined,
+ * the adaptive codebook vector v(n) is computed by interpolating
+ * the past excitation signal u(n) at the given integer delay k
+ * and phase (fraction) :
+ *
+ * 9 9
+ * v(n) = SUM[ u(n-k-i) * b60(t+i*6) ] + SUM[ u(n-k+1+i) * b60(6-t+i*6) ],
+ * i=0 i=0
+ * n = 0, ...,39, t = 0, ...,5.
+ *
+ * The interpolation filter b60 is based on a Hamming windowed sin(x)/x
+ * function truncated at ± 59 and padded with zeros at ± 60 (b60(60)=0)).
+ * The filter has a cut-off frequency (-3 dB) at 3 600 Hz in
+ * the over-sampled domain.
+ *
+ * Returns:
+ * void
+ */
+static void Pred_lt_3or6_40(Word32 exc[], Word32 T0, Word32 frac, Word32 flag3)
+{
+ Word32 s, i;
+ Word32 *x0, *x1, *x2;
+ const Word32 *c1, *c2;
+
+
+ x0 = &exc[ - T0];
+ frac = -frac;
+
+ if (flag3 != 0) {
+ frac <<= 1; /* inter_3l[k] = inter6[2*k] -> k' = 2*k */
+ }
+
+ if (frac < 0) {
+ frac += 6;
+ x0--;
+ }
+ c1 = &inter6[frac];
+ c2 = &inter6[6 - frac];
+
+ for (i = 0; i < 40; i++) {
+ x1 = x0++;
+ x2 = x0;
+ s = x1[0] * c1[0];
+ s += x1[ - 1] * c1[6];
+ s += x1[ - 2] * c1[12];
+ s += x1[ - 3] * c1[18];
+ s += x1[ - 4] * c1[24];
+ s += x1[ - 5] * c1[30];
+ s += x1[ - 6] * c1[36];
+ s += x1[ - 7] * c1[42];
+ s += x1[ - 8] * c1[48];
+ s += x1[ - 9] * c1[54];
+ s += x2[0] * c2[0];
+ s += x2[1] * c2[6];
+ s += x2[2] * c2[12];
+ s += x2[3] * c2[18];
+ s += x2[4] * c2[24];
+ s += x2[5] * c2[30];
+ s += x2[6] * c2[36];
+ s += x2[7] * c2[42];
+ s += x2[8] * c2[48];
+ s += x2[9] * c2[54];
+ exc[i] = (s + 0x4000) >> 15;
+
+ }
+}
+
+
+/*
+ * Dec_lag6
+ *
+ *
+ * Parameters:
+ * index I: received pitch index
+ * pit_min I: minimum pitch lag
+ * pit_max I: maximum pitch lag
+ * i_subfr I: subframe flag
+ * T0 B: integer part of pitch lag
+ * T0_frac O : fractional part of pitch lag
+ *
+ * Function:
+ * Decoding of fractional pitch lag with 1/6 resolution.
+ * Extract the integer and fraction parts of the pitch lag from
+ * the received adaptive codebook index.
+ *
+ * The fractional lag in 1st and 3rd subframes is encoded with 9 bits
+ * while that in 2nd and 4th subframes is relatively encoded with 6 bits.
+ * Note that in relative encoding only 61 values are used. If the
+ * decoder receives 61, 62, or 63 as the relative pitch index, it means
+ * that a transmission error occurred. In this case, the pitch lag from
+ * previous subframe (actually from previous frame) is used.
+ *
+ * Returns:
+ * void
+ */
+static void Dec_lag6(Word32 index, Word32 pit_min, Word32 pit_max, Word32
+ i_subfr, Word32 *T0, Word32 *T0_frac)
+{
+ Word32 t0_min, t0_max, i;
+
+
+ /* if 1st or 3rd subframe */
+ if (i_subfr == 0) {
+ if (index < 463) {
+ /* T0 = (index+5)/6 + 17 */
+ *T0 = (index + 5) / 6 + 17;
+ i = *T0 + *T0 + *T0;
+
+ /* *T0_frac = index - T0*6 + 105 */
+ *T0_frac = (index - (i + i)) + 105;
+ } else {
+ *T0 = index - 368;
+ *T0_frac = 0;
+ }
+ }
+
+ /* second or fourth subframe */
+ else {
+ /* find t0_min and t0_max for 2nd (or 4th) subframe */
+ t0_min = *T0 - 5;
+
+ if (t0_min < pit_min) {
+ t0_min = pit_min;
+ }
+ t0_max = t0_min + 9;
+
+ if (t0_max > pit_max) {
+ t0_max = pit_max;
+ t0_min = t0_max - 9;
+ }
+
+ /* i = (index+5)/6 - 1 */
+ i = (index + 5) / 6 - 1;
+ *T0 = i + t0_min;
+ i = i + i + i;
+ *T0_frac = (index - 3) - (i + i);
+ }
+}
+
+
+/*
+ * decompress10
+ *
+ *
+ * Parameters:
+ * MSBs I: MSB part of the index
+ * LSBs I: LSB part of the index
+ * index1 I: index for first pos in posIndex
+ * index2 I: index for second pos in posIndex
+ * index3 I: index for third pos in posIndex
+ * pos_indx O: position of 3 pulses (decompressed)
+ * Function:
+ * Decompression of the linear codeword
+ *
+ * Returns:
+ * void
+ */
+static void decompress10(Word32 MSBs, Word32 LSBs, Word32 index1, Word32 index2
+ , Word32 index3, Word32 pos_indx[])
+{
+ Word32 divMSB;
+
+ if (MSBs > 124) {
+ MSBs = 124;
+ }
+ /*
+ * pos_indx[index1] = ((MSBs-25*(MSBs/25))%5)*2 + (LSBs-4*(LSBs/4))%2;
+ * pos_indx[index2] = ((MSBs-25*(MSBs/25))/5)*2 + (LSBs-4*(LSBs/4))/2;
+ * pos_indx[index3] = (MSBs/25)*2 + LSBs/4;
+ */
+ divMSB = MSBs / 25;
+ pos_indx[index1] = (((MSBs - 25 * (divMSB)) % 5) << 1) + (LSBs & 0x1
+ );
+ pos_indx[index2] = (((MSBs - 25 * (divMSB)) / 5) << 1) + ((LSBs &
+ 0x2) >> 1);
+ pos_indx[index3] = (divMSB << 1) + (LSBs >> 2);
+ return;
+}
+
+
+/*
+ * decompress_codewords
+ *
+ *
+ * Parameters:
+ * indx I: position of 8 pulses (compressed)
+ * pos_indx O: position index of 8 pulses (position only)
+ *
+ * Function:
+ * Decompression of the linear codewords to 4+three indeces
+ * one bit from each pulse is made robust to errors by
+ * minimizing the phase shift of a bit error.
+ *
+ * i0,i4,i1 => one index (7+3) bits, 3 LSBs more robust
+ * i2,i6,i5 => one index (7+3) bits, 3 LSBs more robust
+ * i3,i7 => one index (5+2) bits, 2-3 LSbs more robust
+ *
+ * Returns:
+ * void
+ */
+static void decompress_codewords(Word16 indx[], Word32 pos_indx[])
+{
+ Word32 ia, ib, MSBs, LSBs, MSBs0_24, tmp;
+
+
+ /*
+ * First index: 10x10x10 -> 2x5x2x5x2x5-> 125x2x2x2 -> 7+1x3 bits
+ * MSBs = indx[NB_TRACK]/8;
+ * LSBs = indx[NB_TRACK]%8;
+ */
+ MSBs = *indx >> 3;
+ LSBs = *indx & 0x7;
+ decompress10(MSBs, LSBs, 0, 4, 1, pos_indx);
+
+ /*
+ * Second index: 10x10x10 -> 2x5x2x5x2x5-> 125x2x2x2 -> 7+1x3 bits
+ * MSBs = indx[NB_TRACK+1]/8;
+ * LSBs = indx[NB_TRACK+1]%8;
+ */
+ MSBs = indx[1] >> 3;
+ LSBs = indx[1] & 0x7;
+ decompress10(MSBs, LSBs, 2, 6, 5, pos_indx);
+
+ /*
+ * Third index: 10x10 -> 2x5x2x5-> 25x2x2 -> 5+1x2 bits
+ * MSBs = indx[NB_TRACK+2]/4;
+ * LSBs = indx[NB_TRACK+2]%4;
+ * MSBs0_24 = (MSBs*25+12)/32;
+ * if ((MSBs0_24/5)%2==1)
+ * pos_indx[3] = (4-(MSBs0_24%5))*2 + LSBs%2;
+ * else
+ * pos_indx[3] = (MSBs0_24%5)*2 + LSBs%2;
+ * pos_indx[7] = (MSBs0_24/5)*2 + LSBs/2;
+ */
+ MSBs = indx[2] >> 2;
+ LSBs = indx[2] & 0x3;
+ MSBs0_24 = (((MSBs * 25) + 12) >> 5);
+ tmp = (MSBs0_24 * 6554) >> 15;
+ ia = tmp & 0x1;
+ ib = (MSBs0_24 - (tmp * 5));
+
+ if (ia == 1) {
+ ib = 4 - ib;
+ }
+ pos_indx[3] = (ib << 1) + (LSBs & 0x1);
+ pos_indx[7] = (tmp << 1) + (LSBs >> 1);
+}
+
+
+/*
+ * decode_2i40_9bits
+ *
+ *
+ * Parameters:
+ * subNr I: subframe number
+ * sign I: signs of 2 pulses
+ * index I: Positions of the 2 pulses
+ * cod O: algebraic (fixed) codebook excitation
+ *
+ * Function:
+ * Algebraic codebook decoder
+ *
+ * Returns:
+ * void
+ */
+static void decode_2i40_9bits(Word32 subNr, Word32 sign, Word32 index, Word32
+ cod[])
+{
+ Word32 pos[2];
+ Word32 i, j, k;
+
+
+ /* Decode the positions */
+ /* table bit is the MSB */
+ j = (index & 64) >> 6;
+ i = index & 7;
+
+ /* pos0 =i*5+startPos[j*8+subNr*2] */
+ i = (i + (i << 2));
+ k = startPos[(j << 3) + (subNr << 1)];
+ pos[0] = i + k;
+ index = index >> 3;
+ i = index & 7;
+
+ /* pos1 =i*5+startPos[j*8+subNr*2+1] */
+ i = (i + (i << 2));
+ k = startPos[((j << 3) + (subNr << 1)) + 1];
+ pos[1] = (Word16)(i + k);
+
+ /* decode the signs and build the codeword */
+ memset(cod, 0, L_SUBFR << 2);
+
+ for (j = 0; j < 2; j++) {
+ i = sign & 1;
+ sign = sign >> 1;
+
+ if (i != 0) {
+ cod[pos[j]] = 8191; /* +1.0 */
+ } else {
+ cod[pos[j]] = -8192; /* -1.0 */
+ }
+ }
+ return;
+}
+
+
+/*
+ * decode_2i40_11bits
+ *
+ *
+ * Parameters:
+ * sign I: signs of 2 pulses
+ * index I: Positions of the 2 pulses
+ * cod O: algebraic (fixed) codebook excitation
+ *
+ * Function:
+ * Algebraic codebook decoder
+ *
+ * Returns:
+ * void
+ */
+static void decode_2i40_11bits(Word32 sign, Word32 index, Word32 cod[])
+{
+ Word32 pos[2];
+ Word32 i, j;
+
+
+ /* Decode the positions */
+ j = index & 1;
+ index = index >> 1;
+ i = index & 7;
+
+ /* pos0 =i*5+1+j*2 */
+ i = (i + (i << 2));
+ i = (i + 1);
+ j = (j << 1);
+ pos[0] = i + j;
+ index = index >> 3;
+ j = index & 3;
+ index = index >> 2;
+ i = index & 7;
+
+ if (j == 3) {
+ /* pos1 =i*5+4 */
+ i = (i + (i << 2));
+ pos[1] = i + 4;
+ } else {
+ /* pos1 =i*5+j */
+ i = (i + (i << 2));
+ pos[1] = i + j;
+ }
+
+ /* decode the signs and build the codeword */
+ memset(cod, 0, L_SUBFR << 2);
+
+ for (j = 0; j < 2; j++) {
+ i = sign & 1;
+ sign = sign >> 1;
+
+ if (i != 0) {
+ cod[pos[j]] = 8191; /* +1.0 */
+ } else {
+ cod[pos[j]] = -8192; /* -1.0 */
+ }
+ }
+ return;
+}
+
+
+/*
+ * decode_3i40_14bits
+ *
+ *
+ * Parameters:
+ * sign I: signs of 3 pulses
+ * index I: Positions of the 3 pulses
+ * cod O: algebraic (fixed) codebook excitation
+ *
+ * Function:
+ * Algebraic codebook decoder
+ *
+ * Returns:
+ * void
+ */
+static void decode_3i40_14bits(Word32 sign, Word32 index, Word32 cod[])
+{
+ Word32 pos[3];
+ Word32 i, j;
+
+
+ /* Decode the positions */
+ i = index & 7;
+
+ /* pos0 =i*5 */
+ pos[0] = i + (i << 2);
+ index = index >> 3;
+ j = index & 1;
+ index = index >> 1;
+ i = index & 7;
+
+ /* pos1 =i*5+1+j*2 */
+ i = (i + (i << 2));
+ i = (i + 1);
+ j = (j << 1);
+ pos[1] = i + j;
+ index = index >> 3;
+ j = index & 1;
+ index = index >> 1;
+ i = index & 7;
+
+ /* pos2 =i*5+2+j*2 */
+ i = (i + (i << 2));
+ i = (i + 2);
+ j = (j << 1);
+ pos[2] = i + j;
+
+ /* decode the signs and build the codeword */
+ memset(cod, 0, L_SUBFR << 2);
+
+ for (j = 0; j < 3; j++) {
+ i = sign & 1;
+ sign = sign >> 1;
+
+ if (i > 0) {
+ cod[pos[j]] = 8191; /* +1.0 */
+ } else {
+ cod[pos[j]] = -8192; /* -1.0 */
+ }
+ }
+ return;
+}
+
+
+/*
+ * decode_3i40_14bits
+ *
+ *
+ * Parameters:
+ * sign I: signs of 4 pulses
+ * index I: Positions of the 4 pulses
+ * cod O: algebraic (fixed) codebook excitation
+ *
+ * Function:
+ * Algebraic codebook decoder
+ *
+ * Returns:
+ * void
+ */
+static void decode_4i40_17bits(Word32 sign, Word32 index, Word32 cod[])
+{
+ Word32 pos[4];
+ Word32 i, j;
+
+
+ /* Decode the positions */
+ i = index & 7;
+ i = dgray[i];
+
+ /* pos0 =i*5 */
+ pos[0] = i + (i << 2);
+ index = index >> 3;
+ i = index & 7;
+ i = dgray[i];
+
+ /* pos1 =i*5+1 */
+ i = (i + (i << 2));
+ pos[1] = i + 1;
+ index = index >> 3;
+ i = index & 7;
+ i = dgray[i];
+
+ /* pos2 =i*5+1 */
+ i = (i + (i << 2));
+ pos[2] = i + 2;
+ index = index >> 3;
+ j = index & 1;
+ index = index >> 1;
+ i = index & 7;
+ i = dgray[i];
+
+ /* pos3 =i*5+3+j */
+ i = (i + (i << 2));
+ i = (i + 3);
+ pos[3] = i + j;
+
+ /* decode the signs and build the codeword */
+ memset(cod, 0, L_SUBFR << 2);
+
+ for (j = 0; j < 4; j++) {
+ i = sign & 1;
+ sign = sign >> 1;
+
+ if (i != 0) {
+ cod[pos[j]] = 8191;
+ } else {
+ cod[pos[j]] = -8192;
+ }
+ }
+ return;
+}
+
+
+/*
+ * decode_8i40_31bits
+ *
+ *
+ * Parameters:
+ * index I: index of 8 pulses (sign+position)
+ * cod O: algebraic (fixed) codebook excitation
+ *
+ * Function:
+ * Algebraic codebook decoder
+ *
+ * Returns:
+ * void
+ */
+static void decode_8i40_31bits(Word16 index[], Word32 cod[])
+{
+ Word32 linear_codewords[8];
+ Word32 i, j, pos1, pos2, sign;
+
+
+ memset(cod, 0, L_CODE << 2);
+ decompress_codewords(&index[NB_TRACK_MR102], linear_codewords);
+
+ /* decode the positions and signs of pulses and build the codeword */
+ for (j = 0; j < NB_TRACK_MR102; j++) {
+ /* compute index i */
+ i = linear_codewords[j];
+ i <<= 2;
+
+ /* position of pulse "j" */
+ pos1 = i + j;
+
+ if (index[j] == 0) {
+ sign = POS_CODE; /* +1.0 */
+ } else {
+ sign = -NEG_CODE; /* -1.0 */
+ }
+
+ /* compute index i */
+ i = linear_codewords[j + 4];
+ i = i << 2;
+
+ /* position of pulse "j+4" */
+ pos2 = i + j;
+ cod[pos1] = sign;
+
+ if (pos2 < pos1) {
+ sign = -(sign);
+ }
+ cod[pos2] = cod[pos2] + sign;
+ }
+ return;
+}
+
+
+/*
+ * decode_10i40_35bits
+ *
+ *
+ * Parameters:
+ * index I: index of 10 pulses (sign+position)
+ * cod O: algebraic (fixed) codebook excitation
+ *
+ * Function:
+ * Algebraic codebook decoder
+ *
+ * Returns:
+ * void
+ */
+static void decode_10i40_35bits(Word16 index[], Word32 cod[])
+{
+ Word32 i, j, pos1, pos2, sign, tmp;
+
+
+ memset(cod, 0, L_CODE << 2);
+
+ /* decode the positions and signs of pulses and build the codeword */
+ for (j = 0; j < 5; j++) {
+ /* compute index i */
+ tmp = index[j];
+ i = tmp & 7;
+ i = dgray[i];
+ i = (i * 5);
+
+ /* position of pulse "j" */
+ pos1 = (i + j);
+ i = (tmp >> 3) & 1;
+
+ if (i == 0) {
+ sign = 4096; /* +1.0 */
+ } else {
+ sign = -4096; /* -1.0 */
+ }
+
+ /* compute index i */
+ i = index[j + 5] & 7;
+ i = dgray[i];
+ i = i * 5;
+
+ /* position of pulse "j+5" */
+ pos2 = (i + j);
+ cod[pos1] = sign;
+
+ if (pos2 < pos1) {
+ sign = -(sign);
+ }
+ cod[pos2] = cod[pos2] + sign;
+ }
+ return;
+}
+
+
+/*
+ * gmed_n
+ *
+ *
+ * Parameters:
+ * ind I: values
+ * n I: The number of gains (odd)
+ *
+ * Function:
+ * Calculates N-point median.
+ *
+ * Returns:
+ * index of the median value
+ */
+static Word32 gmed_n(Word32 ind[], Word32 n)
+{
+ Word32 tmp[NMAX], tmp2[NMAX];
+ Word32 max, medianIndex, i, j, ix = 0;
+
+
+ for (i = 0; i < n; i++) {
+ tmp2[i] = ind[i];
+ }
+
+ for (i = 0; i < n; i++) {
+ max = -32767;
+
+ for (j = 0; j < n; j++) {
+ if (tmp2[j] >= max) {
+ max = tmp2[j];
+ ix = j;
+ }
+ }
+ tmp2[ix] = -32768;
+ tmp[i] = ix;
+ }
+ medianIndex = tmp[(n >> 1)];
+ return(ind[medianIndex]);
+}
+
+
+/*
+ * ec_gain_pitch
+ *
+ *
+ * Parameters:
+ * st->pbuf I: last five gains
+ * st->past_gain_pit I: past gain
+ * state I: state of the state machine
+ * gain_pitch O: pitch gain
+ *
+ * Function:
+ * Calculates pitch from previous values.
+ *
+ * Returns:
+ * void
+ */
+static void ec_gain_pitch(ec_gain_pitchState *st, Word16 state, Word32 *
+ gain_pitch)
+{
+ Word32 tmp;
+
+
+ /* calculate median of last five gains */
+ tmp = gmed_n(st->pbuf, 5);
+
+ /* new gain = minimum(median, past_gain) * pdown[state] */
+ if (tmp > st->past_gain_pit) {
+ tmp = st->past_gain_pit;
+ }
+ *gain_pitch = (tmp * pdown[state]) >> 15;
+}
+
+
+/*
+ * d_gain_pitch
+ *
+ *
+ * Parameters:
+ * mode I: AMR mode
+ * index I: index of quantization
+ *
+ * Function:
+ * Decodes the pitch gain using the received index
+ *
+ * Returns:
+ * gain
+ */
+static Word32 d_gain_pitch(enum Mode mode, Word32 index)
+{
+ Word32 gain;
+
+
+ if (mode == MR122) {
+ /* clear 2 LSBits */
+ gain = (qua_gain_pitch[index] >> 2) << 2;
+ } else {
+ gain = qua_gain_pitch[index];
+ }
+ return gain;
+}
+
+
+/*
+ * ec_gain_pitch_update
+ *
+ *
+ * Parameters:
+ * st->prev_gp B: previous pitch gain
+ * st->past_gain_pit O: past gain
+ * st->pbuf B: past gain buffer
+ * bfi I: bad frame indicator
+ * prev_bf I: previous frame was bad
+ * gain_pitch B: pitch gain
+ *
+ * Function:
+ * Update the pitch gain concealment state
+ * Limit gain_pitch if the previous frame was bad
+ *
+ * Returns:
+ * gain
+ */
+static void ec_gain_pitch_update(ec_gain_pitchState *st, Word32 bfi,
+ Word32 prev_bf, Word32 *gain_pitch)
+{
+ if (bfi == 0) {
+ if (prev_bf != 0) {
+ if (*gain_pitch > st->prev_gp) {
+ *gain_pitch = st->prev_gp;
+ }
+ }
+ st->prev_gp = *gain_pitch;
+ }
+ st->past_gain_pit = *gain_pitch;
+
+ /* if (st->past_gain_pit > 1.0) */
+ if (st->past_gain_pit > 16384) {
+ st->past_gain_pit = 16384;
+ }
+ st->pbuf[0] = st->pbuf[1];
+ st->pbuf[1] = st->pbuf[2];
+ st->pbuf[2] = st->pbuf[3];
+ st->pbuf[3] = st->pbuf[4];
+ st->pbuf[4] = st->past_gain_pit;
+}
+
+
+/*
+ * gc_pred (366)
+ *
+ *
+ * Parameters:
+ * st->past_qua_en I: MA predictor
+ * st->past_qua_en_MR122 I: MA predictor MR122
+ * mode I: AMR mode
+ * code I: innovative codebook vector
+ * exp_gcode0 O: predicted gain factor (exponent)
+ * frac_gcode0 O: predicted gain factor (fraction)
+ * exp_en I: innovation energy (MR795) (exponent)
+ * frac_en I: innovation energy (MR795) (fraction)
+ *
+ * Function:
+ * MA prediction of the innovation energy
+ *
+ * Mean removed innovation energy (dB) in subframe n
+ * N-1
+ * E(n) = 10*log(gc*gc * SUM[(code(i) * code(i)]/N) - EMean
+ * i=0
+ * N=40
+ *
+ * Mean innovation energy (dB)
+ * N-1
+ * Ei(n) = 10*log(SUM[(code(i) * code(i)]/N)
+ * i=0
+ *
+ * Predicted energy
+ * 4
+ * Ep(n) = SUM[b(i) * R(n-i)]
+ * i=1
+ * b = [0.68 0.58 0.34 0.19]
+ * R(k) is quantified prediction error at subframe k
+ *
+ * E_Mean = 36 dB (MR122)
+ *
+ * Predicted gain gc is found by
+ *
+ * gc = POW[10, 0.05 * (Ep(n) + EMean - Ei)]
+ *
+ * Returns:
+ * void
+ */
+static void gc_pred(gc_predState *st, enum Mode mode, Word32 *code, Word32 *
+ exp_gcode0, Word32 *frac_gcode0, Word32 *exp_en, Word32 *frac_en)
+{
+ Word32 exp, frac, ener_code = 0, i = 0;
+
+
+ /* energy of code:
+ * ener_code = sum(code[i]^2)
+ */
+ while (i < L_SUBFR) {
+ ener_code += code[i] * code[i];
+ i++;
+ }
+
+ if ((0x3fffffff <= ener_code) | (ener_code < 0)) {
+ ener_code = MAX_32;
+ } else {
+ ener_code <<= 1;
+ }
+
+ if (mode == MR122) {
+ Word32 ener;
+
+
+ /* ener_code = ener_code / lcode; lcode = 40; 1/40 = 26214 Q20 */
+ ener_code = ((ener_code + 0x00008000L) >> 16) * 52428;
+
+ /* Q9 * Q20 -> Q30 */
+ /* energy of code:
+ * ener_code(Q17) = 10 * Log10(energy) / constant
+ * = 1/2 * Log2(energy)
+ * constant = 20*Log10(2)
+ */
+ /* ener_code = 1/2 * Log2(ener_code); Note: Log2=log2+30 */
+ Log2(ener_code, &exp, &frac);
+ ener_code = ((exp - 30) << 16) + (frac << 1);
+
+ /* Q16 for log(), ->Q17 for 1/2 log() */
+ /*
+ * predicted energy:
+ * ener(Q24) = (Emean + sum{pred[i]*pastEn[i]})/constant
+ * = MEAN_ENER + sum(pred[i]*past_qua_en[i])
+ * constant = 20*Log10(2)
+ */
+ ener = 0;
+ i = 0;
+
+ while (i < 4) {
+ ener += st->past_qua_en_MR122[i] * pred_MR122[i];
+ i++;
+ }
+ ener <<= 1;
+ ener += MEAN_ENER_MR122;
+
+ /*
+ * predicted codebook gain
+
+ * gc0 = Pow10( (ener*constant - ener_code*constant) / 20 )
+ * = Pow2(ener-ener_code)
+ * = Pow2(int(d)+frac(d))
+ */
+ ener = (ener - ener_code) >> 1; /* Q16 */
+ *exp_gcode0 = ener >> 16;
+ *frac_gcode0 = (ener >> 1) - (*exp_gcode0 << 15);
+ }
+
+ /* all modes except 12.2 */
+ else {
+ Word32 tmp, gcode0;
+ int exp_code;
+
+
+ /*
+ * Compute: meansEner - 10log10(ener_code/ LSufr)
+ */
+ exp_code = 0;
+ if (ener_code != 0) {
+ while (!(ener_code & 0x40000000)) {
+ exp_code++;
+ ener_code = ener_code << 1;
+ }
+ }
+
+ /* Log2 = log2 + 27 */
+ Log2_norm(ener_code, exp_code, &exp, &frac);
+
+ /* fact = 10/log2(10) = 3.01 = 24660 Q13 */
+ /* Q0.Q15 * Q13 -> Q14 */
+ tmp = (exp * (-49320)) + (((frac * (-24660)) >> 15) << 1);
+
+ /*
+ * tmp = meansEner - 10log10(ener_code/L_SUBFR)
+ * = meansEner - 10log10(ener_code) + 10log10(L_SUBFR)
+ * = K - fact * Log2(ener_code)
+ * = K - fact * log2(ener_code) - fact*27
+ *
+ * ==> K = meansEner + fact*27 + 10log10(L_SUBFR)
+ *
+ * meansEner = 33 = 540672 Q14 (MR475, MR515, MR59)
+ * meansEner = 28.75 = 471040 Q14 (MR67)
+ * meansEner = 30 = 491520 Q14 (MR74)
+ * meansEner = 36 = 589824 Q14 (MR795)
+ * meansEner = 33 = 540672 Q14 (MR102)
+ * 10log10(L_SUBFR) = 16.02 = 262481.51 Q14
+ * fact * 27 = 1331640 Q14
+ * -----------------------------------------
+ * (MR475, MR515, MR59) K = 2134793.51 Q14 ~= 16678 * 64 * 2
+ * (MR67) K = 2065161.51 Q14 ~= 32268 * 32 * 2
+ * (MR74) K = 2085641.51 Q14 ~= 32588 * 32 * 2
+ * (MR795) K = 2183945.51 Q14 ~= 17062 * 64 * 2
+ * (MR102) K = 2134793.51 Q14 ~= 16678 * 64 * 2
+ */
+ if (mode == MR102) {
+ /* mean = 33 dB */
+ tmp += 2134784; /* Q14 */
+ } else if (mode == MR795) {
+ /* mean = 36 dB */
+ tmp += 2183936; /* Q14 */
+
+ /*
+ * ener_code = <xn xn> * 2^27*2^exp_code
+ * frac_en = ener_code / 2^16
+ * = <xn xn> * 2^11*2^exp_code
+ * <xn xn> = <xn xn>*2^11*2^exp * 2^exp_en
+ * := frac_en * 2^exp_en
+ *
+ * ==> exp_en = -11-exp_code;
+ */
+ *frac_en = ener_code >> 16;
+ *exp_en = -11 - exp_code;
+ } else if (mode == MR74) {
+ /* mean = 30 dB */
+ tmp += 2085632; /* Q14 */
+ } else if (mode == MR67) {
+ /* mean = 28.75 dB */
+ tmp += 2065152; /* Q14 */
+ } else { /* MR59, MR515, MR475 */
+ /* mean = 33 dB */
+ tmp += 2134784; /* Q14 */
+ }
+
+ /*
+ * Compute gcode0
+ * = Sum(i=0,3) pred[i]*past_qua_en[i] - ener_code + meanEner
+ */
+ tmp = tmp << 9; /* Q23 */
+
+ /* Q13 * Q10 -> Q23 */
+ i = 0;
+
+ while (i < 4) {
+ tmp += pred[i] * st->past_qua_en[i];
+ i++;
+ }
+ gcode0 = tmp >> 15; /* Q8 */
+
+ /*
+ * gcode0 = pow(10.0, gcode0/20)
+ * = pow(2, 3.3219*gcode0/20)
+ * = pow(2, 0.166*gcode0)
+ */
+ /* 5439 Q15 = 0.165985 */
+ /* (correct: 1/(20*log10(2)) 0.166096 = 5443 Q15) */
+ /* For IS641 bitexactness */
+ if (mode == MR74) {
+ /* Q8 * Q15 -> Q24 */
+ tmp = gcode0 * 10878;
+ } else {
+ /* Q8 * Q15 -> Q24 */
+ tmp = gcode0 * 10886;
+ }
+ tmp = tmp >> 9; /* -> Q15 */
+
+ /* -> Q0.Q15 */
+ *exp_gcode0 = tmp >> 15;
+ *frac_gcode0 = tmp - (*exp_gcode0 * 32768);
+ }
+}
+
+
+/*
+ * gc_pred_update
+ *
+ *
+ * Parameters:
+ * st->past_qua_en B: MA predictor
+ * st->past_qua_en_MR122 B: MA predictor MR122
+ * qua_ener_MR122 I: quantized energy for update (log2(quaErr))
+ * qua_ener I: quantized energy for update (20*log10(quaErr))
+ *
+ * Function:
+ * Update MA predictor with last quantized energy
+ *
+ * Returns:
+ * void
+ */
+static void gc_pred_update(gc_predState *st, Word32 qua_ener_MR122,
+ Word32 qua_ener)
+{
+ Word32 i;
+
+
+ for (i = 3; i > 0; i--) {
+ st->past_qua_en[i] = st->past_qua_en[i - 1];
+ st->past_qua_en_MR122[i] = st->past_qua_en_MR122[i - 1];
+ }
+ st->past_qua_en_MR122[0] = qua_ener_MR122; /* log2 (quaErr), Q10 */
+ st->past_qua_en[0] = qua_ener; /* 20*log10(quaErr), Q10 */
+}
+
+
+/*
+ * Dec_gain
+ *
+ *
+ * Parameters:
+ * pred_state->past_qua_en B: MA predictor
+ * pred_state->past_qua_en_MR122 B: MA predictor MR122
+ * mode I: AMR mode
+ * index I: index of quantization
+ * code I: Innovative vector
+ * evenSubfr I: Flag for even subframes
+ * gain_pit O: Pitch gain
+ * gain_cod O: Code gain
+ *
+ * Function:
+ * Decode the pitch and codebook gains
+ *
+ * Returns:
+ * void
+ */
+static void Dec_gain(gc_predState *pred_state, enum Mode mode, Word32 index,
+ Word32 code[], Word32 evenSubfr, Word32 *gain_pit, Word32 *gain_cod)
+{
+ Word32 frac, gcode0, exp, qua_ener, qua_ener_MR122, g_code, tmp;
+ const Word32 *p;
+
+
+ /* Read the quantized gains (table depends on mode) */
+ index = index << 2;
+
+ if ((mode == MR102) || (mode == MR74) || (mode == MR67)) {
+ p = &table_gain_highrates[index];
+ *gain_pit = *p++;
+ g_code = *p++;
+ qua_ener_MR122 = *p++;
+ qua_ener = *p;
+ } else {
+ if (mode == MR475) {
+ index = index + ((1 - evenSubfr) << 1);
+ p = &table_gain_MR475[index];
+ *gain_pit = *p++;
+ g_code = *p++;
+
+ /*
+ * calculate predictor update values (not stored in 4.75
+ * quantizer table to save space):
+ * qua_ener = log2(g)
+ * qua_ener_MR122 = 20*log10(g)
+ */
+ /* Log2(x Q12) = log2(x) + 12 */
+ Log2(g_code, &exp, &frac);
+ exp = exp - 12;
+ tmp = frac >> 5;
+
+ if ((frac & ((Word16)1 << 4)) != 0) {
+ tmp++;
+ }
+ qua_ener_MR122 = tmp + (exp << 10);
+
+ /* 24660 Q12 ~= 6.0206 = 20*log10(2) */
+ tmp = exp * 49320;
+ tmp += (((frac * 24660) >> 15) << 1);
+
+ /* Q12 * Q0 = Q13 -> Q10 */
+ qua_ener = ((tmp << 13) + 0x00008000L) >> 16;
+ } else {
+ p = &table_gain_lowrates[index];
+ *gain_pit = *p++;
+ g_code = *p++;
+ qua_ener_MR122 = *p++;
+ qua_ener = *p;
+ }
+ }
+
+ /*
+ * predict codebook gain
+ * gc0 = Pow2(int(d)+frac(d))
+ * = 2^exp + 2^frac
+ * gcode0 (Q14) = 2^14*2^frac = gc0 * 2^(14-exp)
+ */
+ gc_pred(pred_state, mode, code, &exp, &frac, NULL, NULL);
+ gcode0 = Pow2(14, frac);
+
+ /*
+ * read quantized gains, update table of past quantized energies
+ * st->past_qua_en(Q10) = 20 * Log10(gFac) / constant
+ * = Log2(gFac)
+ * = qua_ener
+ * constant = 20*Log10(2)
+ */
+ if (exp < 11) {
+ *gain_cod = (g_code * gcode0) >> (25 - exp);
+ } else {
+ tmp = ((g_code * gcode0) << (exp - 9));
+
+ if ((tmp >> (exp - 9)) != (g_code * gcode0)) {
+ *gain_cod = 0x7FFF;
+ } else {
+ *gain_cod = tmp >> 16;
+ }
+ }
+
+ /* update table of past quantized energies */
+ gc_pred_update(pred_state, qua_ener_MR122, qua_ener);
+ return;
+}
+
+
+/*
+ * gc_pred_average_limited
+ *
+ *
+ * Parameters:
+ * st->past_qua_en I: MA predictor
+ * st->past_qua_en_MR122 I: MA predictor MR122
+ * ener_avg_MR122 O: everaged quantized energy (log2(quaErr))
+ * ener_avg O: averaged quantized energy (20*log10(quaErr))
+ *
+ * Function:
+ * Compute average limited quantized energy
+ * Returns:
+ * void
+ */
+static void gc_pred_average_limited(gc_predState *st, Word32 *ener_avg_MR122,
+ Word32 *ener_avg)
+{
+ Word32 av_pred_en, i;
+
+
+ /* do average in MR122 mode (log2() domain) */
+ av_pred_en = 0;
+
+ for (i = 0; i < NPRED; i++) {
+ av_pred_en = (av_pred_en + st->past_qua_en_MR122[i]);
+ }
+
+ /* av_pred_en = 0.25*av_pred_en */
+ av_pred_en = (av_pred_en * 8192) >> 15;
+
+ /* if (av_pred_en < -14/(20Log10(2))) av_pred_en = .. */
+ if (av_pred_en < MIN_ENERGY_MR122) {
+ av_pred_en = MIN_ENERGY_MR122;
+ }
+ *ener_avg_MR122 = (Word16)av_pred_en;
+
+ /* do average for other modes (20*log10() domain) */
+ av_pred_en = 0;
+
+ for (i = 0; i < NPRED; i++) {
+ av_pred_en = (av_pred_en + st->past_qua_en[i]);
+ if (av_pred_en < -32768) {
+ av_pred_en = -32768;
+ } else if (av_pred_en > 32767) {
+ av_pred_en = 32767;
+ }
+ }
+
+ /* av_pred_en = 0.25*av_pred_en */
+ av_pred_en = (av_pred_en * 8192) >> 15;
+
+ *ener_avg = av_pred_en;
+}
+
+
+/*
+ * ec_gain_code
+ *
+ *
+ * Parameters:
+ * st->gbuf I: last five gains
+ * st->past_gain_code I: past gain
+ * pred_state B: MA predictor state
+ * state I: state of the state machine
+ * gain_code O: decoded innovation gain
+ *
+ * Function:
+ * Conceal the codebook gain
+ *
+ * Returns:
+ * void
+ */
+static void ec_gain_code(ec_gain_codeState *st, gc_predState *pred_state,
+ Word16 state, Word32 *gain_code)
+{
+ Word32 tmp, qua_ener_MR122, qua_ener;
+
+
+ /* calculate median of last five gain values */
+ tmp = gmed_n(st->gbuf, 5);
+
+ /* new gain = minimum(median, past_gain) * cdown[state] */
+ if (tmp > st->past_gain_code) {
+ tmp = st->past_gain_code;
+ }
+ tmp = (tmp * cdown[state]) >> 15;
+ *gain_code = tmp;
+
+ /*
+ * update table of past quantized energies with average of
+ * current values
+ */
+ gc_pred_average_limited(pred_state, &qua_ener_MR122, &qua_ener);
+ gc_pred_update(pred_state, qua_ener_MR122, qua_ener);
+}
+
+
+/*
+ * ec_gain_code_update
+ *
+ *
+ * Parameters:
+ * st->gbuf B: last five gains
+ * st->past_gain_code O: past gain
+ * st->prev_gc B previous gain
+ * bfi I: bad indicator
+ * prev_bf I: previous frame bad indicator
+ * gain_code O: decoded innovation gain
+ *
+ * Function:
+ * Update the codebook gain concealment state
+ *
+ * Returns:
+ * void
+ */
+static void ec_gain_code_update(ec_gain_codeState *st, Word16 bfi,
+ Word16 prev_bf, Word32 *gain_code)
+{
+ /* limit gain_code by previous good gain if previous frame was bad */
+ if (bfi == 0) {
+ if (prev_bf != 0) {
+ if (*gain_code > st->prev_gc) {
+ *gain_code = st->prev_gc;
+ }
+ }
+ st->prev_gc = *gain_code;
+ }
+
+ /* update EC states: previous gain, gain buffer */
+ st->past_gain_code = *gain_code;
+ st->gbuf[0] = st->gbuf[1];
+ st->gbuf[1] = st->gbuf[2];
+ st->gbuf[2] = st->gbuf[3];
+ st->gbuf[3] = st->gbuf[4];
+ st->gbuf[4] = *gain_code;
+ return;
+}
+
+
+/*
+ * d_gain_code
+ *
+ *
+ * Parameters:
+ * pred_state B: MA predictor state
+ * mode I: AMR mode (MR795 or MR122)
+ * index I: received quantization index
+ * code I: innovation codevector
+ * gain_code O: decoded innovation gain
+ *
+ * Function:
+ * Decode the fixed codebook gain using the received index
+ *
+ * Returns:
+ * void
+ */
+static void d_gain_code(gc_predState *pred_state, enum Mode mode, Word32 index,
+ Word32 code[], Word32 *gain_code)
+{
+ Word32 g_code0, exp, frac, qua_ener_MR122, qua_ener;
+ Word32 exp_inn_en, frac_inn_en, tmp, tmp2, i;
+ const Word32 *p;
+
+
+ /*
+ * Decode codebook gain
+ */
+ gc_pred(pred_state, mode, code, &exp, &frac, &exp_inn_en, &frac_inn_en);
+ p = &qua_gain_code[((index + index) + index)];
+
+ /* Different scalings between MR122 and the other modes */
+ if (mode == MR122) {
+ /* predicted gain */
+ g_code0 = Pow2(exp, frac);
+
+ if (g_code0 <= 2047) {
+ g_code0 = g_code0 << 4;
+ } else {
+ g_code0 = 32767;
+ }
+ *gain_code = ((g_code0 * *p++) >> 15) << 1;
+ if (*gain_code & 0xFFFF8000) {
+ *gain_code = 32767;
+ }
+
+ } else {
+ g_code0 = Pow2(14, frac);
+ tmp = (*p++ * g_code0) << 1;
+ exp = 9 - exp;
+
+ if (exp > 0) {
+ tmp = tmp >> exp;
+ } else {
+ for (i = exp; i < 0; i++) {
+ tmp2 = tmp << 1;
+ if ((tmp ^ tmp2) & 0x80000000) {
+ tmp = (tmp & 0x80000000) ? 0x80000000 : 0x7FFFFFFF;
+ break;
+ } else {
+ tmp = tmp2;
+ }
+ }
+ }
+ *gain_code = tmp >> 16;
+ if (*gain_code & 0xFFFF8000) {
+ *gain_code = 32767;
+ }
+ }
+
+ /*
+ * update table of past quantized energies
+ */
+ qua_ener_MR122 = *p++;
+ qua_ener = *p++;
+ gc_pred_update(pred_state, qua_ener_MR122, qua_ener);
+ return;
+}
+
+
+/*
+ * Int_lsf
+ *
+ *
+ * Parameters:
+ * lsf_old I: LSF vector at the 4th subframe of past frame
+ * lsf_new I: LSF vector at the 4th subframe of present frame
+ * i_subfr I: current subframe
+ * lsf_out O: interpolated LSF parameters for current subframe
+ *
+ * Function:
+ * Interpolates the LSFs for selected subframe
+ *
+ * The LSFs are interpolated at the 1st, 2nd and 3rd
+ * ubframe and only forwarded at the 4th subframe.
+ *
+ * sf1: 3/4 F0 + 1/4 F1
+ * sf2: 1/2 F0 + 1/2 F1
+ * sf3: 1/4 F0 + 3/4 F1
+ * sf4: F1
+ *
+ * Returns:
+ * void
+ */
+static void Int_lsf(Word32 lsf_old[], Word32 lsf_new[], int i_subfr, Word32
+ lsf_out[])
+{
+ Word32 i;
+
+
+ switch (i_subfr) {
+ case 0:
+ for (i = 0; i < 10; i++) {
+ lsf_out[i] = lsf_old[i] - (lsf_old[i] >> 2) + (lsf_new[i] >> 2);
+ }
+ break;
+
+ case 40:
+ for (i = 0; i < 10; i++) {
+ lsf_out[i] = (lsf_old[i] >> 1) + (lsf_new[i] >> 1);
+ }
+ break;
+
+ case 80:
+ for (i = 0; i < 10; i++) {
+ lsf_out[i] = (lsf_old[i] >> 2) - (lsf_new[i] >> 2) +
+ lsf_new[i];
+ }
+ break;
+
+ case 120:
+ memcpy(lsf_out, lsf_new, M << 2);
+ break;
+ }
+}
+
+
+/*
+ * Cb_gain_average
+ *
+ *
+ * Parameters:
+ * st->cbGainHistory B: codebook gain history
+ * st->hangCount B: hangover counter
+ * mode I: AMR mode
+ * gain_code I: codebook gain
+ * lsp I: The LSP for the current frame
+ * lspAver I: The average of LSP for 8 frames
+ * bfi I: bad frame indication
+ * prev_bf I: previous bad frame indication
+ * pdfi I: potential degraded bad frame indication
+ * prev_pdf I: previous potential degraded bad frame indication
+ * inBackgroundNoise I: background noise decision
+ * voicedHangover I: number of frames after last voiced frame
+ *
+ * Function:
+ * The mixed codebook gain, used to make codebook gain more smooth in background
+ *
+ *
+ * Returns:
+ * void
+ */
+static Word32 Cb_gain_average(Cb_gain_averageState *st, enum Mode mode, Word32
+ gain_code, Word32 lsp[], Word32 lspAver[], Word16 bfi, Word16 prev_bf,
+ Word16 pdfi, Word16 prev_pdf, Word32 inBackgroundNoise, Word32
+ voicedHangover)
+{
+ Word32 tmp[M];
+ Word32 i, cbGainMix, tmp_diff, bgMix, cbGainMean, sum, diff, tmp1, tmp2;
+ int shift1, shift2, shift;
+
+
+ /* set correct cbGainMix for MR74, MR795, MR122 */
+ cbGainMix = gain_code;
+
+ /*
+ * Store list of CB gain needed in the CB gain averaging *
+ */
+ st->cbGainHistory[0] = st->cbGainHistory[1];
+ st->cbGainHistory[1] = st->cbGainHistory[2];
+ st->cbGainHistory[2] = st->cbGainHistory[3];
+ st->cbGainHistory[3] = st->cbGainHistory[4];
+ st->cbGainHistory[4] = st->cbGainHistory[5];
+ st->cbGainHistory[5] = st->cbGainHistory[6];
+ st->cbGainHistory[6] = gain_code;
+
+ /* compute lsp difference */
+ for (i = 0; i < M; i++) {
+ tmp1 = labs(lspAver[i] - lsp[i]);
+ shift1 = 0;
+ if (tmp1 != 0) {
+ while (!(tmp1 & 0x2000)) {
+ shift1++;
+ tmp1 = tmp1 << 1;
+ }
+ }
+ tmp2 = lspAver[i];
+ shift2 = 0;
+ if (tmp2 != 0) {
+ while (!(tmp2 & 0x4000)) {
+ shift2++;
+ tmp2 = tmp2 << 1;
+ }
+ }
+ tmp[i] = (tmp1 << 15) / tmp2;
+ shift = 2 + shift1 - shift2;
+
+ if (shift >= 0) {
+ tmp[i] = tmp[i] >> shift;
+ } else {
+ tmp[i] = tmp[i] << -(shift);
+ }
+ }
+ diff = *tmp + tmp[1] + tmp[2] + tmp[3] + tmp[4] + tmp[5] + tmp[6] + tmp[7] +
+ tmp[8] + tmp[9];
+
+ /* saturate */
+ if (diff > 32767) {
+ diff = 32767;
+ }
+
+ /* Compute hangover */
+ st->hangVar += 1;
+
+ if (diff <= 5325) {
+ st->hangVar = 0;
+ }
+
+ if (st->hangVar > 10) {
+ /* Speech period, reset hangover variable */
+ st->hangCount = 0;
+ }
+
+ /* Compute mix constant (bgMix) */
+ bgMix = 8192;
+
+ /* MR475, MR515, MR59, MR67, MR102 */
+ if ((mode <= MR67) | (mode == MR102)) {
+ /* disable mix if too short time since */
+ if ((st->hangCount >= 40) & (diff <= 5325)) { /* 0.65 in Q13 */
+ /* if errors and presumed noise make smoothing probability stronger */
+ if (((((pdfi != 0) & (prev_pdf != 0)) | (bfi != 0) | (
+ prev_bf != 0)) & ((voicedHangover > 1)) & (
+ inBackgroundNoise != 0) & (mode < MR67))) {
+ /* bgMix = min(0.25, max(0.0, diff-0.55)) / 0.25; */
+ tmp_diff = diff - 4506; /* 0.55 in Q13 */
+
+ /* max(0.0, diff-0.55) */
+ tmp1 = 0;
+
+ if (tmp_diff > 0) {
+ tmp1 = tmp_diff;
+ }
+
+ /* min(0.25, tmp1) */
+ if (2048 >= tmp1) {
+ bgMix = tmp1 << 2;
+ }
+ } else {
+ /* bgMix = min(0.25, max(0.0, diff-0.40)) / 0.25; */
+ tmp_diff = diff - 3277; /* 0.4 in Q13 */
+
+ /* max(0.0, diff-0.40) */
+ tmp1 = 0;
+
+ if (tmp_diff > 0) {
+ tmp1 = tmp_diff;
+ }
+
+ /* min(0.25, tmp1) */
+ if (2048 >= tmp1) {
+ bgMix = tmp1 << 2;
+ }
+ }
+ }
+
+ /*
+ * Smoothen the cb gain trajectory
+ * smoothing depends on mix constant bgMix
+ */
+ sum = st->cbGainHistory[2] + st->cbGainHistory[3] + st->cbGainHistory[4] +
+ st->cbGainHistory[5] + st->cbGainHistory[6];
+
+ if (sum > 163822) {
+ cbGainMean = 32767;
+ } else {
+ cbGainMean = (3277 * sum + 0x00002000L) >> 14; /* Q1 */
+ }
+
+ /* more smoothing in error and bg noise (NB no DFI used here) */
+ if (((bfi != 0) | (prev_bf != 0)) & (inBackgroundNoise != 0) & (
+ mode < MR67)) {
+ sum = 9362 * (st->cbGainHistory[0] + st->cbGainHistory[1] + st->
+ cbGainHistory[2] + st->cbGainHistory[3] + st->cbGainHistory[4] +
+ st->cbGainHistory[5] + st->cbGainHistory[6]);
+ cbGainMean = (sum + 0x00008000L) >> 16; /* Q1 */
+ }
+
+ /* cbGainMix = bgMix*cbGainMix + (1-bgMix)*cbGainMean; */
+ sum = bgMix * cbGainMix; /* sum in Q14 */
+ sum += cbGainMean << 13;
+ sum -= bgMix * cbGainMean;
+ cbGainMix = (sum + 0x00001000L) >> 13;
+
+ /* Q1 */
+ }
+ st->hangCount += 1;
+ if (st->hangCount & 0x80000000) {
+ st->hangCount = 40;
+ }
+ return cbGainMix;
+}
+
+
+/*
+ * ph_disp
+ *
+ *
+ * Parameters:
+ * state->gainMem B: LTP gain memory
+ * state->prevCbGain B: Codebook gain memory
+ * mode I: AMR mode
+ * x B: LTP excitation signal -> total excitation signal
+ * cbGain I: Codebook gain
+ * ltpGain I: LTP gain
+ * inno B: Innovation vector
+ * pitch_fac I: pitch factor used to scale the LTP excitation
+ * tmp_shift I: shift factor applied to sum of scaled LTP ex & innov.
+ * before rounding
+ *
+ * Function:
+ * Adaptive phase dispersion; forming of total excitation
+ *
+ *
+ * Returns:
+ * void
+ */
+static void ph_disp(ph_dispState *state, enum Mode mode, Word32 x[],
+ Word32 cbGain, Word32 ltpGain, Word32 inno[],
+ Word32 pitch_fac, Word32 tmp_shift)
+{
+ Word32 inno_sav[L_SUBFR], ps_poss[L_SUBFR];
+ Word32 i, i1, impNr, temp1, temp2, j, nze, nPulse, ppos;
+ const Word32 *ph_imp; /* Pointer to phase dispersion filter */
+
+
+ /* Update LTP gain memory */
+ state->gainMem[4] = state->gainMem[3];
+ state->gainMem[3] = state->gainMem[2];
+ state->gainMem[2] = state->gainMem[1];
+ state->gainMem[1] = state->gainMem[0];
+ state->gainMem[0] = ltpGain;
+
+ /* basic adaption of phase dispersion */
+ /* no dispersion */
+ impNr = 2;
+
+ /* if (ltpGain < 0.9) */
+ if (ltpGain < PHDTHR2LTP) {
+ /* maximum dispersion */
+ impNr = 0;
+
+ /* if (ltpGain > 0.6 */
+ if (ltpGain > PHDTHR1LTP) {
+ /* medium dispersion */
+ impNr = 1;
+ }
+ }
+
+ /* onset indicator */
+ /* onset = (cbGain > onFact * cbGainMem[0]) */
+ temp1 = ((state->prevCbGain * ONFACTPLUS1) + 0x1000) >> 13;
+
+ if (cbGain > temp1) {
+ state->onset = ONLENGTH;
+ } else {
+ if (state->onset > 0) {
+ state->onset--;
+ }
+ }
+
+ /*
+ * if not onset, check ltpGain buffer and use max phase dispersion if
+ * half or more of the ltpGain-parameters say so
+ */
+ if (state->onset == 0) {
+ /* Check LTP gain memory and set filter accordingly */
+ i1 = 0;
+
+ for (i = 0; i < PHDGAINMEMSIZE; i++) {
+ if (state->gainMem[i] < PHDTHR1LTP) {
+ i1++;
+ }
+ }
+
+ if (i1 > 2) {
+ impNr = 0;
+ }
+ }
+
+ /* Restrict decrease in phase dispersion to one step if not onset */
+ if ((impNr > (state->prevState + 1)) & (state->onset == 0)) {
+ impNr--;
+ }
+
+ /* if onset, use one step less phase dispersion */
+ if ((impNr < 2) & (state->onset > 0)) {
+ impNr++;
+ }
+
+ /* disable for very low levels */
+ if (cbGain < 10) {
+ impNr = 2;
+ }
+
+ if (state->lockFull == 1) {
+ impNr = 0;
+ }
+
+ /* update static memory */
+ state->prevState = impNr;
+ state->prevCbGain = cbGain;
+
+ /*
+ * do phase dispersion for all modes but 12.2 and 7.4;
+ * don't modify the innovation if impNr >=2 (= no phase disp)
+ */
+ if ((mode != MR122) & (mode != MR102) & (mode != MR74) & (impNr < 2)
+ ) {
+ /*
+ * track pulse positions, save innovation,
+ * and initialize new innovation
+ */
+ nze = 0;
+
+ for (i = 0; i < L_SUBFR; i++) {
+ if (inno[i] != 0) {
+ ps_poss[nze] = i;
+ nze++;
+ }
+ }
+ memcpy(inno_sav, inno, L_SUBFR << 2);
+ memset(inno, 0, L_SUBFR << 2);
+
+ /* Choose filter corresponding to codec mode and dispersion criterium */
+ ph_imp = ph_imp_mid;
+
+ if (impNr == 0) {
+ ph_imp = ph_imp_low;
+ }
+
+ if (mode == MR795) {
+ ph_imp = ph_imp_mid_MR795;
+
+ if (impNr == 0) {
+ ph_imp = ph_imp_low_MR795;
+ }
+ }
+
+ /* Do phase dispersion of innovation */
+ for (nPulse = 0; nPulse < nze; nPulse++) {
+ ppos = ps_poss[nPulse];
+
+ /* circular convolution with impulse response */
+ j = 0;
+
+ for (i = ppos; i < L_SUBFR; i++) {
+ /* inno[i1] += inno_sav[ppos] * ph_imp[i1-ppos] */
+ temp1 = (inno_sav[ppos] * ph_imp[j++]) >> 15;
+ inno[i] = inno[i] + temp1;
+ }
+
+ for (i = 0; i < ppos; i++) {
+ /* inno[i] += inno_sav[ppos] * ph_imp[L_SUBFR-ppos+i] */
+ temp1 = (inno_sav[ppos] * ph_imp[j++]) >> 15;
+ inno[i] = inno[i] + temp1;
+ }
+ }
+ }
+
+ /*
+ * compute total excitation for synthesis part of decoder
+ * (using modified innovation if phase dispersion is active)
+ */
+ for (i = 0; i < L_SUBFR; i++) {
+ /* x[i] = gain_pit*x[i] + cbGain*code[i]; */
+ temp1 = x[i] * pitch_fac + inno[i] * cbGain;
+ temp2 = temp1 << tmp_shift;
+ x[i] = (temp2 + 0x4000) >> 15;
+ if (labs(x[i]) > 32767) {
+ if ((temp1 ^ temp2) & 0x80000000) {
+ x[i] = (temp1 & 0x80000000) ? -32768 : 32767;
+ } else {
+ x[i] = (temp2 & 0x80000000) ? -32768 : 32767;
+ }
+ }
+ }
+ return;
+}
+
+
+/*
+ * sqrt_l_exp
+ *
+ *
+ * Parameters:
+ * x I: input value
+ * exp O: right shift to be applied to result
+ *
+ * Function:
+ * Sqrt with exponent value.
+ *
+ * y = sqrt(x)
+ * x = f * 2^-e, 0.5 <= f < 1 (normalization)
+ * y = sqrt(f) * 2^(-e/2)
+ *
+ * a) e = 2k --> y = sqrt(f) * 2^-k
+ * (k = e div 2, 0.707 <= sqrt(f) < 1)
+ * b) e = 2k+1 --> y = sqrt(f/2) * 2^-k
+ * (k = e div 2, 0.5 <= sqrt(f/2) < 0.707)
+ *
+ *
+ * Returns:
+ * y output value
+ */
+static Word32 sqrt_l_exp(Word32 x, Word32 *exp)
+{
+ Word32 y, a, i, tmp;
+ int e;
+
+
+ if (x <= (Word32)0) {
+ *exp = 0;
+ return(Word32)0;
+ }
+ e = 0;
+ if (x != 0) {
+ tmp = x;
+ while (!(tmp & 0x40000000)) {
+ e++;
+ tmp = tmp << 1;
+ }
+ }
+ e = e & 0xFFFE;
+ x = (x << e);
+ *exp = (Word16)e;
+ x = (x >> 9);
+ i = (Word16)(x >> 16);
+ x = (x >> 1);
+ a = x & (Word16)0x7fff;
+ i = (i - 16);
+ y = (sqrt_table[i] << 16);
+ tmp = (sqrt_table[i] - sqrt_table[i + 1]);
+ y -= (tmp * a) << 1;
+ return(y);
+}
+
+
+/*
+ * Ex_ctrl
+ *
+ *
+ * Parameters:
+ * excitation B: Current subframe excitation
+ * excEnergy I: Exc. Energy, sqrt(totEx*totEx)
+ * exEnergyHist I: History of subframe energies
+ * voicedHangover I: number of frames after last voiced frame
+ * prevBFI I: Set i previous bad frame indicators
+ * carefulFlag I: Restrict dymamic in scaling
+ *
+ * Function:
+ * Charaterice synthesis speech and detect background noise
+ *
+ * Returns:
+ * background noise decision; 0 = no bgn, 1 = bgn
+ */
+static Word16 Ex_ctrl(Word32 excitation[], Word32 excEnergy, Word32
+ exEnergyHist[], Word32 voicedHangover, Word16 prevBFI, Word16 carefulFlag
+ )
+{
+ Word32 i, testEnergy, scaleFactor, avgEnergy, prevEnergy, T0;
+ int exp;
+
+
+ /* get target level */
+ avgEnergy = gmed_n(exEnergyHist, 9);
+ prevEnergy = (exEnergyHist[7] + exEnergyHist[8]) >> 1;
+
+ if (exEnergyHist[8] < prevEnergy) {
+ prevEnergy = exEnergyHist[8];
+ }
+
+ /* upscaling to avoid too rapid energy rises for some cases */
+ if ((excEnergy<avgEnergy) & (excEnergy>5)) {
+ /* testEnergy = 4*prevEnergy; */
+ testEnergy = prevEnergy << 2;
+
+ if ((voicedHangover < 7) || prevBFI != 0) {
+ /* testEnergy = 3*prevEnergy */
+ testEnergy = testEnergy - prevEnergy;
+ }
+
+ if (avgEnergy > testEnergy) {
+ avgEnergy = testEnergy;
+ }
+
+ /* scaleFactor=avgEnergy/excEnergy in Q0 */
+ exp = 0;
+ if (excEnergy != 0) {
+ while (!(excEnergy & 0x4000)) {
+ exp++;
+ excEnergy = excEnergy << 1;
+ }
+ }
+ excEnergy = 536838144 / excEnergy;
+ T0 = (avgEnergy * excEnergy) << 1;
+ T0 = (T0 >> (20 - exp));
+
+ if (T0 > 32767) {
+ /* saturate */
+ T0 = 32767;
+ }
+ scaleFactor = T0;
+
+ /* test if scaleFactor > 3.0 */
+ if ((carefulFlag != 0) & (scaleFactor > 3072)) {
+ scaleFactor = 3072;
+ }
+
+ /* scale the excitation by scaleFactor */
+ for (i = 0; i < L_SUBFR; i++) {
+ T0 = (scaleFactor * excitation[i]) << 1;
+ T0 = (T0 >> 11);
+ excitation[i] = T0;
+ }
+ }
+ return 0;
+}
+
+
+/*
+ * Inv_sqrt
+ *
+ *
+ * Parameters:
+ * x I: input value
+ *
+ * Function:
+ * 1/sqrt(x)
+ *
+ * Returns:
+ * y 1/sqrt(x)
+ */
+static Word32 Inv_sqrt(Word32 x)
+{
+ int i, a, tmp, exp;
+ Word32 y;
+
+
+ if (x <= (Word32)0) {
+ return((Word32)0x3fffffffL);
+ }
+ exp = 0;
+ while (!(x & 0x40000000)) {
+ exp++;
+ x = x << 1;
+ }
+
+ /* x is normalized */
+ exp = (30 - exp);
+
+ /* If exponent even -> shift right */
+ if ((exp & 1) == 0) {
+ x = (x >> 1);
+ }
+ exp = (exp >> 1);
+ exp = (exp + 1);
+ x = (x >> 9);
+
+ /* Extract b25-b31 */
+ i = (Word16)(x >> 16);
+
+ /* Extract b10-b24 */
+ x = (x >> 1);
+ a = x & (Word16)0x7fff;
+ i = (i - 16);
+
+ /* table[i] << 16 */
+ y = inv_sqrt_table[i] << 16;
+
+ /* table[i] - table[i+1]) */
+ tmp = (inv_sqrt_table[i] - inv_sqrt_table[i + 1]);
+
+ /* y -= tmp*a*2 */
+ y -= (tmp * a) << 1;
+
+ /* denormalization */
+ y = (y >> exp);
+ return(y);
+}
+
+
+/*
+ * energy_old
+ *
+ *
+ * Parameters:
+ * in I: input value
+ *
+ * Function:
+ * Energy of signal
+ *
+ * Returns:
+ * Energy
+ */
+static Word32 energy_old(Word32 in[])
+{
+ Word32 temp, i, sum = 0;
+
+
+ for (i = 0; i < L_SUBFR; i += 8) {
+ temp = in[i] >> 2;
+ sum += temp * temp;
+ temp = in[i + 1] >> 2;
+ sum += temp * temp;
+ temp = in[i + 2] >> 2;
+ sum += temp * temp;
+ temp = in[i + 3] >> 2;
+ sum += temp * temp;
+ temp = in[i + 4] >> 2;
+ sum += temp * temp;
+ temp = in[i + 5] >> 2;
+ sum += temp * temp;
+ temp = in[i + 6] >> 2;
+ sum += temp * temp;
+ temp = in[i + 7] >> 2;
+ sum += temp * temp;
+ }
+
+ if (sum & 0xC0000000) {
+ return 0x7FFFFFFF;
+ }
+ return(sum << 1);
+}
+
+
+/*
+ * energy_new
+ *
+ *
+ * Parameters:
+ * in I: input value
+ *
+ * Function:
+ * Energy of signal
+ *
+ * Returns:
+ * Energy
+ */
+static Word32 energy_new(Word32 in[])
+{
+ Word32 i, s = 0, overflow = 0;
+
+ s += in[0] * in[0];
+ for (i = 1; i < L_SUBFR; i += 3) {
+ s += in[i] * in[i];
+ s += in[i + 1] * in[i + 1];
+ s += in[i + 2] * in[i + 2];
+
+
+ if (s & 0xC0000000) {
+ overflow = 1;
+ break;
+ }
+ }
+
+ /* check for overflow */
+ if (overflow) {
+ s = energy_old(in);
+ } else {
+ s = (s >> 3);
+ }
+ return s;
+}
+
+
+/*
+ * agc2
+ *
+ *
+ * Parameters:
+ * sig_in I: Post_Filter input signal
+ * sig_out B: Post_Filter output signal
+ *
+ * Function:
+ * Scales the excitation on a subframe basis
+ *
+ * Returns:
+ * Energy
+ */
+static void agc2(Word32 *sig_in, Word32 *sig_out)
+{
+ Word32 s;
+ int i, exp;
+ Word16 gain_in, gain_out, g0;
+
+
+ /* calculate gain_out with exponent */
+ s = energy_new(sig_out);
+
+ if (s == 0) {
+ return;
+ }
+ exp = 0;
+ while (!(s & 0x20000000)) {
+ exp++;
+ s = s << 1;
+ }
+
+ gain_out = (Word16)((s + 0x00008000L) >> 16);
+
+ /* calculate gain_in with exponent */
+ s = energy_new(sig_in);
+
+ if (s == 0) {
+ g0 = 0;
+ } else {
+ i = 0;
+ while (!(s & 0x40000000)) {
+ i++;
+ s = s << 1;
+ }
+
+ if (s < 0x7fff7fff) {
+ gain_in = (Word16)((s + 0x00008000L) >> 16);
+ } else {
+ gain_in = 32767;
+ }
+ exp = (exp - i);
+
+ /*
+ * g0 = sqrt(gain_in/gain_out);
+ */
+ /* s = gain_out / gain_in */
+ s = (gain_out << 15) / gain_in;
+ s = (s << 7);
+
+ if (exp > 0) {
+ s = (s >> exp);
+ } else {
+ s = (s << (-exp));
+ }
+ s = Inv_sqrt(s);
+ g0 = (Word16)(((s << 9) + 0x00008000L) >> 16);
+ }
+
+ /* sig_out(n) = gain(n) * sig_out(n) */
+ for (i = 0; i < L_SUBFR; i++) {
+ sig_out[i] = (sig_out[i] * g0) >> 12;
+ }
+ return;
+}
+
+
+/*
+ * Bgn_scd
+ *
+ *
+ * Parameters:
+ * st->frameEnergyHist B: Frame Energy memory
+ * st->bgHangover B: Background hangover counter
+ * ltpGainHist I: LTP gain history
+ * speech I: synthesis speech frame
+ * voicedHangover O: number of frames after last voiced frame
+ *
+ * Function:
+ * Charaterice synthesis speech and detect background noise
+ *
+ * Returns:
+ * inbgNoise background noise decision; 0 = no bgn, 1 = bgn
+ */
+static Word16 Bgn_scd(Bgn_scdState *st, Word32 ltpGainHist[], Word32 speech[],
+ Word32 *voicedHangover)
+{
+ Word32 temp, ltpLimit, frame_energyMin, currEnergy, noiseFloor, maxEnergy,
+ maxEnergyLastPart, s, i;
+ Word16 prevVoiced, inbgNoise;
+
+
+ /*
+ * Update the inBackgroundNoise flag (valid for use in next frame if BFI)
+ * it now works as a energy detector floating on top
+ * not as good as a VAD.
+ */
+ s = 0;
+
+ for (i = 0; i < L_FRAME; i++) {
+ s += speech[i] * speech[i];
+ }
+
+ if ((s < 0xFFFFFFF) & (s >= 0)) {
+ currEnergy = s >> 13;
+ } else {
+ currEnergy = 32767;
+ }
+ frame_energyMin = 32767;
+
+ for (i = 0; i < L_ENERGYHIST; i++) {
+ if (st->frameEnergyHist[i] < frame_energyMin) {
+ frame_energyMin = st->frameEnergyHist[i];
+ }
+ }
+
+ /* Frame Energy Margin of 16 */
+ noiseFloor = frame_energyMin << 4;
+ maxEnergy = st->frameEnergyHist[0];
+
+ for (i = 1; i < L_ENERGYHIST - 4; i++) {
+ if (maxEnergy < st->frameEnergyHist[i]) {
+ maxEnergy = st->frameEnergyHist[i];
+ }
+ }
+ maxEnergyLastPart = st->frameEnergyHist[2 * L_ENERGYHIST / 3];
+
+ for (i = 2 * L_ENERGYHIST / 3 + 1; i < L_ENERGYHIST; i++) {
+ if (maxEnergyLastPart < st->frameEnergyHist[i]) {
+ maxEnergyLastPart = st->frameEnergyHist[i];
+ }
+ }
+
+ /* false */
+ inbgNoise = 0;
+
+ /*
+ * Do not consider silence as noise
+ * Do not consider continuous high volume as noise
+ * Or if the current noise level is very low
+ * Mark as noise if under current noise limit
+ * OR if the maximum energy is below the upper limit
+ */
+ if ((maxEnergy > LOWERNOISELIMIT) & (currEnergy < FRAMEENERGYLIMIT) & (
+ currEnergy > LOWERNOISELIMIT) & ((currEnergy < noiseFloor) || (
+ maxEnergyLastPart < UPPERNOISELIMIT))) {
+ if ((st->bgHangover + 1) > 30) {
+ st->bgHangover = 30;
+ } else {
+ st->bgHangover += 1;
+ }
+ } else {
+ st->bgHangover = 0;
+ }
+
+ /* make final decision about frame state, act somewhat cautiosly */
+ if (st->bgHangover > 1) {
+ inbgNoise = 1; /* true */
+ }
+
+ for (i = 0; i < L_ENERGYHIST - 1; i++) {
+ st->frameEnergyHist[i] = st->frameEnergyHist[i + 1];
+ }
+ st->frameEnergyHist[L_ENERGYHIST - 1] = currEnergy;
+
+ /*
+ * prepare for voicing decision;
+ * tighten the threshold after some time in noise
+ */
+ ltpLimit = 13926; /* 0.85 Q14 */
+
+ if (st->bgHangover > 8) {
+ ltpLimit = 15565; /* 0.95 Q14 */
+ }
+
+ if (st->bgHangover > 15) {
+ ltpLimit = 16383; /* 1.00 Q14 */
+ }
+
+ /* weak sort of voicing indication. */
+ prevVoiced = 0; /* false */
+
+ if (gmed_n(&ltpGainHist[4], 5) > ltpLimit) {
+ prevVoiced = 1; /* true */
+ }
+
+ if (st->bgHangover > 20) {
+ if (gmed_n(ltpGainHist, 9) > ltpLimit) {
+ prevVoiced = 1; /* true */
+ } else {
+ prevVoiced = 0; /* false */
+ }
+ }
+
+ if (prevVoiced) {
+ *voicedHangover = 0;
+ } else {
+ temp = *voicedHangover + 1;
+
+ if (temp > 10) {
+ *voicedHangover = 10;
+ } else {
+ *voicedHangover = temp;
+ }
+ }
+ return inbgNoise;
+}
+
+
+/*
+ * dtx_dec_activity_update
+ *
+ *
+ * Parameters:
+ * st->lsf_hist_ptr B: LSF history pointer
+ * st->lsf_hist B: LSF history
+ * lsf I: lsf
+ * frame I: noise frame
+ *
+ * Function:
+ * Update lsp history and compute log energy.
+ *
+ * Returns:
+ * void
+ */
+static void dtx_dec_activity_update(dtx_decState *st, Word32 lsf[], Word32
+ frame[])
+{
+ Word32 frame_en;
+ Word32 log_en_e, log_en_m, log_en, i;
+
+
+ /* update lsp history */
+ st->lsf_hist_ptr += M;
+
+ if (st->lsf_hist_ptr == 80) {
+ st->lsf_hist_ptr = 0;
+ }
+ memcpy(&st->lsf_hist[st->lsf_hist_ptr], lsf, M << 2);
+
+ /* compute log energy based on frame energy */
+ frame_en = 0; /* Q0 */
+
+ for (i = 0; (i < L_FRAME); i ++) {
+ frame_en += frame[i] * frame[i];
+ if (frame_en & 0x80000000) {
+ break;
+ }
+ }
+
+ log_en = (frame_en & 0xC0000000) ? 0x7FFFFFFE : (Word32)frame_en << 1;
+
+ Log2(log_en , &log_en_e, &log_en_m);
+
+ /* convert exponent and mantissa to Word16 Q10 */
+ log_en = log_en_e << 10; /* Q10 */
+ log_en = log_en + (log_en_m >> 5);
+
+ /* divide with L_FRAME i.e subtract with log2(L_FRAME) = 7.32193 */
+ log_en = log_en - 8521;
+
+ /*
+ * insert into log energy buffer, no division by two as
+ * log_en in decoder is Q11
+ */
+ st->log_en_hist_ptr += 1;
+
+ if (st->log_en_hist_ptr == DTX_HIST_SIZE) {
+ st->log_en_hist_ptr = 0;
+ }
+ st->log_en_hist[st->log_en_hist_ptr] = log_en; /* Q11 */
+}
+
+
+/*
+ * Decoder_amr
+ *
+ *
+ * Parameters:
+ * st B: State variables
+ * mode I: AMR mode
+ * parm I: vector of synthesis parameters
+ * frame_type I: received frame type
+ * synth O: synthesis speech
+ * A_t O: decoded LP filter in 4 subframes
+ *
+ * Function:
+ * Speech decoder routine
+ *
+ * Returns:
+ * void
+ */
+static void Decoder_amr(Decoder_amrState *st, enum Mode mode, Word16 parm[],
+ enum RXFrameType frame_type, Word32 synth[], Word32 A_t[])
+{
+ /* LSPs */
+ Word32 lsp_new[M];
+ Word32 lsp_mid[M];
+
+
+ /* LSFs */
+ Word32 prev_lsf[M];
+ Word32 lsf_i[M];
+
+
+ /* Algebraic codevector */
+ Word32 code[L_SUBFR];
+
+
+ /* excitation */
+ Word32 excp[L_SUBFR];
+ Word32 exc_enhanced[L_SUBFR];
+
+
+ /* Scalars */
+ Word32 i, i_subfr, overflow, T0_frac, index, temp, temp2, subfrNr, excEnergy;
+ Word32 gain_code, gain_code_mix, pit_sharp, pit_flag, pitch_fac, t0_min, t0_max;
+ Word32 gain_pit = 0, evenSubfr = 0, T0 = 0, index_mr475 = 0;
+ Word32 *Az; /* Pointer on A_t */
+ Word16 flag4, carefulFlag;
+ Word16 delta_frc_low, delta_frc_range, tmp_shift;
+ Word16 bfi = 0, pdfi = 0;
+ /* bad frame indication flag, potential degraded bad frame flag */
+
+
+ enum DTXStateType newDTXState; /* SPEECH , DTX, DTX_MUTE */
+
+ /* find the new DTX state SPEECH OR DTX */
+ newDTXState = rx_dtx_handler(st->dtxDecoderState, frame_type);
+
+ /* DTX actions */
+ if (newDTXState != SPEECH) {
+ Decoder_amr_reset(st, MRDTX);
+ dtx_dec(st->dtxDecoderState, st->mem_syn, st->lsfState, st->pred_state,
+ st->Cb_gain_averState, newDTXState, mode, parm, synth, A_t);
+
+ /* update average lsp */
+ Lsf_lsp(st->lsfState->past_lsf_q, st->lsp_old);
+ lsp_avg(st->lsp_avg_st, st->lsfState->past_lsf_q);
+ goto theEnd;
+ }
+
+ /* SPEECH action state machine */
+ if (table_speech_bad[frame_type]) {
+ bfi = 1;
+
+ if (frame_type != RX_SPEECH_BAD) {
+ Build_CN_param(&st->nodataSeed, mode, parm);
+ }
+ } else if (frame_type == RX_SPEECH_DEGRADED) {
+ pdfi = 1;
+ }
+
+ if (bfi != 0) {
+ st->state += 1;
+ } else if (st->state == 6) {
+ st->state = 5;
+ } else {
+ st->state = 0;
+ }
+
+ if (st->state > 6) {
+ st->state = 6;
+ }
+
+ /*
+ * If this frame is the first speech frame after CNI period,
+ * set the BFH state machine to an appropriate state depending
+ * on whether there was DTX muting before start of speech or not
+ * If there was DTX muting, the first speech frame is muted.
+ * If there was no DTX muting, the first speech frame is not
+ * muted. The BFH state machine starts from state 5, however, to
+ * keep the audible noise resulting from a SID frame which is
+ * erroneously interpreted as a good speech frame as small as
+ * possible (the decoder output in this case is quickly muted)
+ */
+ if (st->dtxDecoderState->dtxGlobalState == DTX) {
+ st->state = 5;
+ st->prev_bf = 0;
+ } else if (st->dtxDecoderState->dtxGlobalState == DTX_MUTE) {
+ st->state = 5;
+ st->prev_bf = 1;
+ }
+
+ /* save old LSFs for CB gain smoothing */
+ memcpy(prev_lsf, st->lsfState->past_lsf_q, M << 2);
+
+ /*
+ * decode LSF parameters and generate interpolated lpc coefficients
+ * for the 4 subframes
+ */
+ if (mode != MR122) {
+ D_plsf_3(st->lsfState, mode, bfi, parm, lsp_new);
+
+ /* Advance synthesis parameters pointer */
+ parm += 3;
+ Int_lpc_1to3(st->lsp_old, lsp_new, A_t);
+ } else {
+ D_plsf_5(st->lsfState, bfi, parm, lsp_mid, lsp_new);
+
+ /* Advance synthesis parameters pointer */
+ parm += 5;
+ Int_lpc_1and3(st->lsp_old, lsp_mid, lsp_new, A_t);
+ }
+
+ /* update the LSPs for the next frame */
+ memcpy(st->lsp_old, lsp_new, M << 2);
+
+ /*
+ * Loop for every subframe in the analysis frame
+ *
+ * The subframe size is L_SUBFR and the loop is repeated
+ * L_FRAME/L_SUBFR times *
+ * - decode the pitch delay
+ * - decode algebraic code
+ * - decode pitch and codebook gains
+ * - find the excitation and compute synthesis speech
+ */
+ /* pointer to interpolated LPC parameters */
+ Az = A_t;
+ evenSubfr = 0;
+ subfrNr = -1;
+
+ for (i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR) {
+ subfrNr += 1;
+ evenSubfr = 1 - evenSubfr;
+
+ /* flag for first and 3th subframe */
+ pit_flag = i_subfr;
+
+ if (i_subfr == L_FRAME_BY2) {
+ if ((mode != MR475) & (mode != MR515)) {
+ pit_flag = 0;
+ }
+ }
+
+ /* pitch index */
+ index = *parm++;
+
+ /*
+ * decode pitch lag and find adaptive codebook vector.
+ */
+ if (mode != MR122) {
+ /*
+ * flag4 indicates encoding with 4 bit resolution;
+ * this is needed for mode MR475, MR515, MR59 and MR67
+ */
+ flag4 = 0;
+
+ if ((mode == MR475) || (mode == MR515) || (mode == MR59) || (
+ mode == MR67)) {
+ flag4 = 1;
+ }
+
+ /*
+ * get ranges for the t0_min and t0_max
+ * only needed in delta decoding
+ */
+ delta_frc_low = 5;
+ delta_frc_range = 9;
+
+ if (mode == MR795) {
+ delta_frc_low = 10;
+ delta_frc_range = 19;
+ }
+ t0_min = st->old_T0 - delta_frc_low;
+
+ if (t0_min < PIT_MIN) {
+ t0_min = PIT_MIN;
+ }
+ t0_max = t0_min + delta_frc_range;
+
+ if (t0_max > PIT_MAX) {
+ t0_max = PIT_MAX;
+ t0_min = t0_max - delta_frc_range;
+ }
+ Dec_lag3(index, t0_min, t0_max, pit_flag, st->old_T0, &T0, &T0_frac,
+ flag4);
+ st->T0_lagBuff = T0;
+
+ if (bfi != 0) {
+ if (st->old_T0 < PIT_MAX) {
+ /* Graceful pitch degradation */
+ st->old_T0 += 1;
+ }
+ T0 = st->old_T0;
+ T0_frac = 0;
+
+ if ((st->inBackgroundNoise != 0) & (st->voicedHangover > 4) & (
+ (mode == MR475) || (mode == MR515) || (mode == MR59))) {
+ T0 = st->T0_lagBuff;
+ }
+ }
+ Pred_lt_3or6_40(st->exc, T0, T0_frac, 1);
+ } else {
+ Dec_lag6(index, PIT_MIN_MR122, PIT_MAX, pit_flag, &T0, &T0_frac);
+
+ if ((bfi != 0) || ((pit_flag != 0) & (index > 60))) {
+ st->T0_lagBuff = T0;
+ T0 = st->old_T0;
+ T0_frac = 0;
+ }
+ Pred_lt_3or6_40(st->exc, T0, T0_frac, 0);
+ }
+
+ /*
+ * (MR122 only: Decode pitch gain.)
+ * Decode innovative codebook.
+ * set pitch sharpening factor
+ */
+ /* MR475, MR515 */
+ if ((mode == MR475) || (mode == MR515)) {
+ /* index of position */
+ index = *parm++;
+
+ /* signs */
+ i = *parm++;
+ decode_2i40_9bits(subfrNr, i, index, code);
+ pit_sharp = st->sharp << 1;
+ }
+
+ /* MR59 */
+ else if (mode == MR59) {
+ /* index of position */
+ index = *parm++;
+
+ /* signs */
+ i = *parm++;
+ decode_2i40_11bits(i, index, code);
+ pit_sharp = st->sharp << 1;
+ }
+
+ /* MR67 */
+ else if (mode == MR67) {
+ /* index of position */
+ index = *parm++;
+
+ /* signs */
+ i = *parm++;
+ decode_3i40_14bits(i, index, code);
+ pit_sharp = st->sharp << 1;
+ }
+
+ /* MR74, MR795 */
+ else if (mode <= MR795) {
+ /* index of position */
+ index = *parm++;
+
+ /* signs */
+ i = *parm++;
+ decode_4i40_17bits(i, index, code);
+ pit_sharp = st->sharp << 1;
+ }
+
+ /* MR102 */
+ else if (mode == MR102) {
+ decode_8i40_31bits(parm, code);
+ parm += 7;
+ pit_sharp = st->sharp << 1;
+ }
+
+ /* MR122 */
+ else {
+ index = *parm++;
+
+ if (bfi != 0) {
+ ec_gain_pitch(st->ec_gain_p_st, st->state, &gain_pit);
+ } else {
+ gain_pit = d_gain_pitch(mode, index);
+ }
+ ec_gain_pitch_update(st->ec_gain_p_st, bfi, st->prev_bf, &gain_pit);
+ decode_10i40_35bits(parm, code);
+ parm += 10;
+
+ /*
+ * pit_sharp = gain_pit;
+ * if (pit_sharp > 1.0) pit_sharp = 1.0;
+ */
+ pit_sharp = gain_pit;
+
+ if (pit_sharp > 16383) {
+ pit_sharp = 32767;
+ } else {
+ pit_sharp *= 2;
+ }
+ }
+
+ /*
+ * Add the pitch contribution to code[].
+ */
+ for (i = T0; i < L_SUBFR; i++) {
+ temp = (code[i - T0] * pit_sharp) >> 15;
+ code[i] = code[i] + temp;
+ }
+
+ /*
+ * Decode codebook gain (MR122) or both pitch
+ * gain and codebook gain (all others)
+ * Update pitch sharpening "sharp" with quantized gain_pit
+ */
+ if (mode == MR475) {
+ /* read and decode pitch and code gain */
+ if (evenSubfr != 0) {
+ /* index of gain(s) */
+ index_mr475 = *parm++;
+ }
+
+ if (bfi == 0) {
+ Dec_gain(st->pred_state, mode, index_mr475, code, evenSubfr, &
+ gain_pit, &gain_code);
+ } else {
+ ec_gain_pitch(st->ec_gain_p_st, st->state, &gain_pit);
+ ec_gain_code(st->ec_gain_c_st, st->pred_state, st->state, &
+ gain_code);
+ }
+ ec_gain_pitch_update(st->ec_gain_p_st, bfi, st->prev_bf, &gain_pit);
+ ec_gain_code_update(st->ec_gain_c_st, bfi, st->prev_bf, &gain_code);
+ pit_sharp = gain_pit;
+
+ if (pit_sharp > SHARPMAX) {
+ pit_sharp = SHARPMAX;
+ }
+ } else if ((mode <= MR74) || (mode == MR102)) {
+ /* read and decode pitch and code gain */
+ /* index of gain(s) */
+ index = *parm++;
+
+ if (bfi == 0) {
+ Dec_gain(st->pred_state, mode, index, code, evenSubfr, &gain_pit, &
+ gain_code);
+ } else {
+ ec_gain_pitch(st->ec_gain_p_st, st->state, &gain_pit);
+ ec_gain_code(st->ec_gain_c_st, st->pred_state, st->state, &
+ gain_code);
+ }
+ ec_gain_pitch_update(st->ec_gain_p_st, bfi, st->prev_bf, &gain_pit);
+ ec_gain_code_update(st->ec_gain_c_st, bfi, st->prev_bf, &gain_code);
+ pit_sharp = gain_pit;
+
+ if (pit_sharp > SHARPMAX) {
+ pit_sharp = SHARPMAX;
+ }
+
+ if (mode == MR102) {
+ if (st->old_T0 > (L_SUBFR + 5)) {
+ pit_sharp = pit_sharp >> 2;
+ }
+ }
+ } else {
+ /* read and decode pitch gain */
+ /* index of gain(s) */
+ index = *parm++;
+
+ if (mode == MR795) {
+ /* decode pitch gain */
+ if (bfi != 0) {
+ ec_gain_pitch(st->ec_gain_p_st, st->state, &gain_pit);
+ } else {
+ gain_pit = d_gain_pitch(mode, index);
+ }
+ ec_gain_pitch_update(st->ec_gain_p_st, bfi, st->prev_bf, &gain_pit
+ );
+
+ /* read and decode code gain */
+ index = *parm++;
+
+ if (bfi == 0) {
+ d_gain_code(st->pred_state, mode, index, code, &gain_code);
+ } else {
+ ec_gain_code(st->ec_gain_c_st, st->pred_state, st->state, &
+ gain_code);
+ }
+ ec_gain_code_update(st->ec_gain_c_st, bfi, st->prev_bf, &gain_code
+ );
+ pit_sharp = gain_pit;
+
+ if (pit_sharp > SHARPMAX) {
+ pit_sharp = SHARPMAX;
+ }
+ } else { /* MR122 */
+
+ if (bfi == 0) {
+ d_gain_code(st->pred_state, mode, index, code, &gain_code);
+ } else {
+ ec_gain_code(st->ec_gain_c_st, st->pred_state, st->state, &
+ gain_code);
+ }
+ ec_gain_code_update(st->ec_gain_c_st, bfi, st->prev_bf, &gain_code
+ );
+ pit_sharp = gain_pit;
+ }
+ }
+
+ /*
+ * store pitch sharpening for next subframe
+ * (for modes which use the previous pitch gain for
+ * pitch sharpening in the search phase)
+ * do not update sharpening in even subframes for MR475
+ */
+ if ((mode != MR475) || evenSubfr == 0) {
+ st->sharp = gain_pit;
+
+ if (st->sharp > SHARPMAX) {
+ st->sharp = SHARPMAX;
+ }
+ }
+
+ if (pit_sharp > 16383) {
+ pit_sharp = 32767;
+ } else {
+ pit_sharp *= 2;
+ }
+
+ if (pit_sharp > 16384) {
+ for (i = 0; i < L_SUBFR; i++) {
+ temp = (st->exc[i] * pit_sharp) >> 15;
+ temp2 = (temp * gain_pit) << 1;
+
+ if (mode == MR122) {
+ temp2 = (temp2 >> 1);
+ }
+ excp[i] = (temp2 + 0x00008000L) >> 16;
+ }
+ }
+
+ /*
+ * Store list of LTP gains needed in the source
+ * characteristic detector (SCD)
+ */
+ if (bfi == 0) {
+ for (i = 0; i < 8; i++) {
+ st->ltpGainHistory[i] = st->ltpGainHistory[i + 1];
+ }
+ st->ltpGainHistory[8] = gain_pit;
+ }
+
+
+ /*
+ * Limit gain_pit if in background noise and BFI
+ * for MR475, MR515, MR59
+ */
+ if ((st->prev_bf != 0 || bfi != 0) & (st->inBackgroundNoise != 0) & (
+ (mode == MR475) || (mode == MR515) || (mode == MR59))) {
+ /* if (gain_pit > 0.75) in Q14*/
+ if (gain_pit > 12288)
+ /* gain_pit = (gain_pit-0.75)/2.0 + 0.75; */
+ {
+ gain_pit = ((gain_pit - 12288) >> 1) + 12288;
+ }
+
+ /* if (gain_pit > 0.90) in Q14*/
+ if (gain_pit > 14745) {
+ gain_pit = 14745;
+ }
+ }
+
+ /*
+ * Calculate CB mixed gain
+ */
+ Int_lsf(prev_lsf, st->lsfState->past_lsf_q, i_subfr, lsf_i);
+ gain_code_mix = Cb_gain_average(st->Cb_gain_averState, mode, gain_code,
+ lsf_i, st->lsp_avg_st->lsp_meanSave, bfi, st->prev_bf, pdfi, st->
+ prev_pdf, st->inBackgroundNoise, st->voicedHangover);
+
+ /* make sure that MR74, MR795, MR122 have original codeGain*/
+ /* MR74, MR795, MR122 */
+ if ((mode > MR67) & (mode != MR102)) {
+ gain_code_mix = gain_code;
+ }
+
+ /*
+ * Find the total excitation.
+ * Find synthesis speech corresponding to st->exc[].
+ */
+ /* MR475, MR515, MR59, MR67, MR74, MR795, MR102*/
+ if (mode <= MR102) {
+ pitch_fac = gain_pit;
+ tmp_shift = 1;
+ }
+
+ /* MR122 */
+ else {
+ pitch_fac = gain_pit >> 1;
+ tmp_shift = 2;
+ }
+
+ /*
+ * copy unscaled LTP excitation to exc_enhanced (used in phase
+ * dispersion below) and compute total excitation for LTP feedback
+ */
+ memcpy(exc_enhanced, st->exc, L_SUBFR << 2);
+
+ for (i = 0; i < L_SUBFR; i++) {
+ /* st->exc[i] = gain_pit*st->exc[i] + gain_code*code[i]; */
+ temp = (st->exc[i] * pitch_fac) + (code[i] * gain_code);
+ temp2 = (temp << tmp_shift);
+ if (((temp2 >> 1) ^ temp2) & 0x40000000) {
+ if ((temp ^ temp2) & 0x80000000) {
+ temp2 = (temp & 0x80000000) ? (-1073741824L) : 1073725439;
+ } else {
+ temp2 = (temp2 & 0x80000000) ? (-1073741824L) : 1073725439;
+ }
+ }
+ st->exc[i] = (temp2 + 0x00004000L) >> 15;
+ }
+ /*
+ * Adaptive phase dispersion
+ */
+
+ /* free phase dispersion adaption */
+ st->ph_disp_st->lockFull = 0;
+
+ if (((mode == MR475) || (mode == MR515) || (mode == MR59)) & (st
+ ->voicedHangover > 3) & (st->inBackgroundNoise != 0) & (bfi != 0
+ )) {
+ /*
+ * Always Use full Phase Disp.
+ * if error in bg noise
+ */
+ st->ph_disp_st->lockFull = 1;
+ }
+
+ /*
+ * apply phase dispersion to innovation (if enabled) and
+ * compute total excitation for synthesis part
+ */
+ ph_disp(st->ph_disp_st, mode, exc_enhanced, gain_code_mix, gain_pit, code
+ , pitch_fac, tmp_shift);
+
+ /*
+ * The Excitation control module are active during BFI.
+ * Conceal drops in signal energy if in bg noise.
+ */
+ temp2 = 0;
+
+ for (i = 0; i < L_SUBFR; i++) {
+ temp2 += (exc_enhanced[i] * exc_enhanced[i]);
+ }
+
+ if (temp2 > 0x3FFFFFFF) {
+ excEnergy = 11584;
+ } else {
+ temp2 = sqrt_l_exp(temp2, &temp);
+ temp2 = (temp2 >> ((temp >> 1) + 15));
+ excEnergy = temp2 >> 2;
+ }
+
+ if (((mode == MR475) || (mode == MR515) || (mode == MR59)) & (st
+ ->voicedHangover > 5) & (st->inBackgroundNoise != 0) & (st->
+ state < 4) & (((pdfi != 0) & (st->prev_pdf != 0)) || bfi !=
+ 0 || st->prev_bf != 0)) {
+ carefulFlag = 0;
+
+ if ((pdfi != 0) & (bfi == 0)) {
+ carefulFlag = 1;
+ }
+ Ex_ctrl(exc_enhanced, excEnergy, st->excEnergyHist, st->voicedHangover
+ , st->prev_bf, carefulFlag);
+ }
+
+ if ((st->inBackgroundNoise != 0) & (bfi != 0 || st->prev_bf != 0) & (
+ st->state < 4)) {
+ ; /* do nothing! */
+ } else {
+ /* Update energy history for all modes */
+ for (i = 0; i < 8; i++) {
+ st->excEnergyHist[i] = st->excEnergyHist[i + 1];
+ }
+ st->excEnergyHist[8] = excEnergy;
+ }
+
+ /*
+ * Excitation control module end.
+ */
+ if (pit_sharp > 16384) {
+ for (i = 0; i < L_SUBFR; i++) {
+ excp[i] = excp[i] + exc_enhanced[i];
+ if (labs(excp[i]) > 32767) {
+ excp[i] = (excp[i] & 0x80000000) ? -32768 : 32767;
+ }
+ }
+ agc2(exc_enhanced, excp);
+ overflow = Syn_filt(Az, excp, &synth[i_subfr], L_SUBFR, st->mem_syn, 0
+ );
+ } else {
+ overflow = Syn_filt(Az, exc_enhanced, &synth[i_subfr], L_SUBFR, st->
+ mem_syn, 0);
+ }
+
+ if (overflow) {
+ for (i = 0; i < PIT_MAX + L_INTERPOL + L_SUBFR; i++) {
+ st->old_exc[i] = st->old_exc[i] >> 2;
+ }
+
+ for (i = 0; i < L_SUBFR; i++) {
+ exc_enhanced[i] = exc_enhanced[i] >> 2;
+ }
+ Syn_filt_overflow(Az, exc_enhanced, &synth[i_subfr], L_SUBFR, st->mem_syn, 1);
+ } else {
+ memcpy(st->mem_syn, &synth[i_subfr + 30], 40);
+ }
+
+ /*
+ * Update signal for next frame.
+ * -> shift to the left by L_SUBFR st->exc[]
+ */
+ memcpy(&st->old_exc[0], &st->old_exc[L_SUBFR], (PIT_MAX + L_INTERPOL) <<
+ 2);
+
+ /* interpolated LPC parameters for next subframe */
+ Az += MP1;
+
+ /* store T0 for next subframe */
+ st->old_T0 = T0;
+ }
+
+ /*
+ * Call the Source Characteristic Detector which updates
+ * st->inBackgroundNoise and st->voicedHangover.
+ */
+ st->inBackgroundNoise = Bgn_scd(st->background_state, &(st->ltpGainHistory[
+ 0]), &(synth[0]), &(st->voicedHangover));
+ dtx_dec_activity_update(st->dtxDecoderState, st->lsfState->past_lsf_q, synth
+ );
+
+ /* store bfi for next subframe */
+ st->prev_bf = bfi;
+ st->prev_pdf = pdfi;
+
+ /*
+ * Calculate the LSF averages on the eight
+ * previous frames
+ */
+ lsp_avg(st->lsp_avg_st, st->lsfState->past_lsf_q);
+theEnd:
+ st->dtxDecoderState->dtxGlobalState = newDTXState;
+ return;
+}
+
+
+/*
+ * Residu40
+ *
+ *
+ * Parameters:
+ * a I: prediction coefficients
+ * x I: speech signal
+ * y O: residual signal
+ *
+ * Function:
+ * The LP residual is computed by filtering the input
+ * speech through the LP inverse filter a(z)
+ *
+ * Returns:
+ * void
+ */
+static void Residu40(Word32 a[], Word32 x[], Word32 y[])
+{
+ Word32 s, i, j;
+
+
+ for (i = 0; i < 40; i++) {
+ s = a[0] * x[i] + a[1] * x[i - 1] + a[2] * x[i - 2] + a[3] * x[i - 3];
+ s += a[4] * x[i - 4] + a[5] * x[i - 5] + a[6] * x[i - 6] + a[7] * x[i - 7]
+ ;
+ s += a[8] * x[i - 8] + a[9] * x[i - 9] + a[10] * x[i - 10];
+ y[i] = (s + 0x800) >> 12;
+ if (abs(y[i]) > 32767) {
+ /* go to safe mode */
+ for (i = 0; i < 40; i++) {
+ s = a[0] * x[i];
+ for (j = 1; j <= 10; j++) {
+ s += a[j] * x[i - j];
+ if (s > 1073741823) {
+ s = 1073741823;
+ } else if (s < -1073741824) {
+ s = -1073741824;
+ }
+ }
+ y[i] = (s + 0x800) >> 12;
+ if (abs(y[i]) > 32767) {
+ y[i] = (y[i] & 0x80000000) ? -32768 : 32767;
+ }
+ }
+ return;
+ }
+
+ }
+ return;
+}
+
+
+/*
+ * agc
+ *
+ *
+ * Parameters:
+ * st->past_gain B: gain memory
+ * sig_in I: Post_Filter input signal
+ * sig_out B: Post_Filter output signal
+ * agc_fac I: AGC factor
+ *
+ * Function:
+ * Scales the Post_Filter output on a subframe basis
+ *
+ * Returns:
+ * void
+ */
+static void agc(agcState *st, Word32 *sig_in, Word32 *sig_out, Word16 agc_fac)
+{
+ Word32 s, gain_in, gain_out, g0, gain;
+ int exp, i;
+
+
+ /* calculate gain_out with exponent */
+ s = energy_new(sig_out);
+
+ if (s == 0) {
+ st->past_gain = 0;
+ return;
+ }
+ exp = 0;
+ i = s;
+ while (!(i & 0x40000000)) {
+ exp++;
+ i = i << 1;
+ }
+ exp -= 1;
+ if (exp & 0x80000000) {
+ s >>= 1;
+ } else {
+ s <<= exp;
+ }
+ gain_out = (s + 0x00008000L) >> 16;
+
+ /* calculate gain_in with exponent */
+ s = energy_new(sig_in);
+
+ if (s == 0) {
+ g0 = 0;
+ } else {
+ i = 0;
+ while (!(s & 0x40000000)) {
+ i++;
+ s = s << 1;
+ }
+ s = s + 0x00008000L;
+
+ if (s >= 0) {
+ gain_in = s >> 16;
+ } else {
+ gain_in = 32767;
+ }
+ exp = (exp - i);
+
+ /*
+ * g0 = (1-agc_fac) * sqrt(gain_in/gain_out);
+ */
+ /* s = gain_out / gain_in */
+ s = (gain_out << 15) / gain_in;
+ exp = 7 - exp;
+
+ if (exp > 0) {
+ if (exp > 31) {
+ if (s) {
+ s = 2147483647;
+ }
+ } else {
+ s = s << exp ;
+ }
+ } else {
+ s = (s >> (-exp));
+ }
+ if (s < 0) {
+ s = 2147483647;
+ }
+ s = Inv_sqrt(s);
+ i = ((s << 9) + 0x00008000L) >> 16;
+ if (i & 0xFFFF8000) {
+ i = 32767;
+ }
+
+ /* g0 = i * (1-agc_fac) */
+ g0 = (i * (32767 - agc_fac)) >> 15;
+ }
+
+ /*
+ * compute gain[n] = agc_fac * gain[n-1] + (1-agc_fac) * sqrt(gain_in/gain_out)
+ * sig_out[n] = gain[n] * sig_out[n]
+ */
+ gain = st->past_gain;
+
+ for (i = 0; i < L_SUBFR; i++) {
+ gain = (gain * agc_fac) >> 15;
+ gain = gain + g0;
+ sig_out[i] = (sig_out[i] * gain) >> 12;
+ if (labs(sig_out[i]) > 32767) {
+ sig_out[i] = (sig_out[i] & 0x8000000) ? -32768 : 32767;
+ }
+ }
+ st->past_gain = gain;
+ return;
+}
+
+
+/*
+ * Post_Filter
+ *
+ *
+ * Parameters:
+ * st B: post filter states
+ * mode I: AMR mode
+ * syn B: synthesis speech
+ * Az_4 I: interpolated LPC parameters in all subfr.
+ *
+ * Function:
+ * Post_Filtering of synthesis speech.
+ *
+ * inverse filtering of syn[] through A(z/0.7) to get res2[]
+ * tilt compensation filtering; 1 - MU*k*z^-1
+ * synthesis filtering through 1/A(z/0.75)
+ * adaptive gain control
+ *
+ * Returns:
+ * void
+ */
+static void Post_Filter(Post_FilterState *st, enum Mode mode, Word32 *syn,
+ Word32 *Az_4)
+{
+ Word32 h[22], Ap3[MP1], Ap4[MP1]; /* bandwidth expanded LP parameters */
+ Word32 tmp, i_subfr, i, temp1, temp2, overflow = 0;
+ Word32 *Az, *p1, *p2, *syn_work = &st->synth_buf[M];
+ const Word32 *pgamma3 = &gamma3[0];
+ const Word32 *pgamma4 = &gamma4_gamma3_MR122[0];
+
+
+ /*
+ * Post filtering
+ */
+ memcpy(syn_work, syn, L_FRAME << 2);
+ Az = Az_4;
+
+ if ((mode == MR122) || (mode == MR102)) {
+ pgamma3 = &gamma4_gamma3_MR122[0];
+ pgamma4 = &gamma4_MR122[0];
+ }
+
+ for (i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR) {
+ /* Find weighted filter coefficients Ap3[] and Ap[4] */
+ Ap3[0] = Az[0];
+ Ap4[0] = Az[0];
+
+ for (i = 1; i <= 10; i++) {
+ Ap3[i] = (Az[i] * pgamma3[i - 1] + 0x4000) >> 15;
+ Ap4[i] = (Az[i] * pgamma4[i - 1] + 0x4000) >> 15;
+ }
+
+ /* filtering of synthesis speech by A(z/0.7) to find res2[] */
+ Residu40(Ap3, &syn_work[i_subfr], st->res2);
+
+ /* tilt compensation filter */
+ /* impulse response of A(z/0.7)/A(z/0.75) */
+ memcpy(h, Ap3, MP1 << 2);
+ memset(&h[M + 1], 0, (22 - M - 1) << 2);
+ Syn_filt(Ap4, h, h, 22, &h[M + 1], 0);
+
+ /* 1st correlation of h[] */
+ tmp = 16777216 + h[1] * h[1];
+
+ for (i = 2; i < 22; i++) {
+ tmp += h[i] * h[i];
+ if (tmp > 0x3FFF8000) {
+ break;
+ }
+ }
+ temp1 = tmp >> 15;
+ if (temp1 & 0xFFFF8000) {
+ temp1 = 32767;
+ }
+
+ tmp = h[0] * h[1];
+
+ for (i = 1; i < 21; i++) {
+ tmp += h[i] * h[i + 1];
+ if (abs(tmp) > 1073741823) {
+ tmp = 1073741823;
+ }
+ }
+ temp2 = tmp >> 15;
+
+ if (temp2 <= 0) {
+ temp2 = 0;
+ } else {
+ tmp = temp2 * 26214;
+ temp2 = (tmp & 0xffff8000) / temp1;
+ }
+
+ /* preemphasis */
+ p1 = st->res2 + 39;
+ p2 = p1 - 1;
+ tmp = *p1;
+
+ do {
+ *p1 = *p1 - ((temp2 * *p2--) >> 15);
+ if (abs(*p1) > 32767) {
+ *p1 = (*p1 & 0x80000000) ? -32768 : 32767;
+ }
+ p1--;
+ *p1 = *p1 - ((temp2 * *p2--) >> 15);
+ if (abs(*p1) > 32767) {
+ *p1 = (*p1 & 0x80000000) ? -32768 : 32767;
+ }
+ p1--;
+ *p1 = *p1 - ((temp2 * *p2--) >> 15);
+ if (abs(*p1) > 32767) {
+ *p1 = (*p1 & 0x80000000) ? -32768 : 32767;
+ }
+ p1--;
+ } while (p1 > st->res2);
+ *p1 = *p1 - ((temp2 * st->preemph_state_mem_pre) >> 15);
+ if (abs(*p1) > 32767) {
+ *p1 = (*p1 & 0x80000000) ? -32768 : 32767;
+ }
+ st->preemph_state_mem_pre = tmp;
+
+ /* filtering through 1/A(z/0.75) */
+ overflow = Syn_filt(Ap4, st->res2, &syn[i_subfr], L_SUBFR, st->mem_syn_pst, 0);
+ if (overflow) {
+ Syn_filt_overflow(Ap4, st->res2, &syn[i_subfr], L_SUBFR, st->mem_syn_pst, 1);
+ overflow = 0;
+ } else {
+ memcpy(st->mem_syn_pst, &syn[i_subfr + 30], 40);
+ }
+
+ /* scale output to input */
+ agc(st->agc_state, &syn_work[i_subfr], &syn[i_subfr], AGC_FAC);
+ Az += MP1;
+ }
+
+ /* update syn_work[] buffer */
+ memcpy(&syn_work[- M], &syn_work[L_FRAME - M], M << 2);
+ return;
+}
+
+
+/*
+ * Post_Process
+ *
+ *
+ * Parameters:
+ * st B: post filter states
+ * signal B: signal
+ *
+ * Function:
+ * Postprocessing of input speech.
+ *
+ * 2nd order high pass filtering with cut off frequency at 60 Hz.
+ * Multiplication of output by two.
+ *
+ *
+ * Returns:
+ * void
+ */
+static void Post_Process(Post_ProcessState *st, Word32 signal[])
+{
+ Word32 x2, tmp, i = 0;
+ Word32 mask = 0x40000000;
+
+ do {
+ x2 = st->x1;
+ st->x1 = st->x0;
+ st->x0 = signal[i];
+
+ /*
+ * y[i] = b[0]*x[i]*2 + b[1]*x[i-1]*2 + b140[2]*x[i-2]/2
+ * + a[1]*y[i-1] + a[2] * y[i-2];
+ */
+ tmp = (st->y1_hi * 15836) + (((st->y1_lo * 15836) & (Word32)0xffff8000) >> 15);
+ tmp += (st->y2_hi * -7667) + (((st->y2_lo * (-7667)) & (Word32)0xffff8000) >> 15);
+ tmp += st->x0 * 7699;
+ tmp += st->x1 * -15398;
+ if (((tmp >> 1) ^ tmp) & mask) {
+ tmp = (tmp & 0x80000000) ? -1073741824 : 1073741823;
+ }
+
+ tmp += x2 * 7699;
+ if (((tmp >> 1) ^ tmp) & mask) {
+ tmp = (tmp & 0x80000000) ? -1073741824 : 1073741823;
+ }
+
+ tmp = tmp << 1;
+ if (((tmp >> 1) ^ tmp) & mask) {
+ tmp = (tmp & 0x80000000) ? -1073741824 : 1073741823;
+ }
+
+ tmp = tmp << 1;
+ if (((tmp >> 1) ^ tmp) & mask) {
+ tmp = (tmp & 0x80000000) ? -1073741824 : 1073741823;
+ }
+
+ if (labs(tmp) < 536862720) {
+ signal[i++] = (tmp + 0x00002000L) >> 14;
+ } else if (tmp > 0) {
+ signal[i++] = 32767;
+ } else {
+ signal[i++] = -32768;
+ }
+ st->y2_hi = st->y1_hi;
+ st->y2_lo = st->y1_lo;
+ st->y1_hi = tmp >> 15;
+ st->y1_lo = ((tmp << 1) - (st->y1_hi << 16)) >> 1;
+ } while (i < 160);
+ return;
+}
+
+
+/*
+ * Speech_Decode_Frame
+ *
+ *
+ * Parameters:
+ * st B: decoder memory
+ * mode I: AMR mode
+ * parm I: speech parameters
+ * frame_type I: Frame type
+ * synth O: synthesis speech
+
+ * Function:
+ * Decode one frame
+ *
+ * Returns:
+ * void
+ */
+void Speech_Decode_Frame(void *st, enum Mode mode, Word16 *parm, enum
+ RXFrameType frame_type, Word16 *synth)
+{
+ Word32 Az_dec[AZ_SIZE]; /* Decoded Az for post-filter in 4 subframes*/
+ Word32 synth_speech[L_FRAME];
+ Word32 i;
+
+ /* Synthesis */
+ Decoder_amr(((Speech_Decode_FrameState *) st)->decoder_amrState, mode,
+ parm, frame_type, synth_speech, Az_dec);
+ Post_Filter(((Speech_Decode_FrameState *) st)->post_state, mode,
+ synth_speech, Az_dec);
+
+ /* post HP filter, and 15->16 bits */
+ Post_Process(((Speech_Decode_FrameState *) st)->postHP_state,
+ synth_speech);
+
+ for (i = 0; i < L_FRAME; i++) {
+#ifndef NO13BIT
+ /* Truncate to 13 bits */
+ synth[i] = (Word16)(synth_speech[i] & 0xfff8);
+#else
+ synth[i] = (Word16)(synth_speech[i]);
+#endif
+ }
+
+
+ return;
+}
+
+
+/*
+ * Decoder_amr_exit
+ *
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+static void Decoder_amr_exit(Decoder_amrState **state)
+{
+ if (state == NULL || *state == NULL) {
+ return;
+ }
+ /* tlsf_free( ( *state )->lsfState );
+ tlsf_free( ( *state )->ec_gain_p_st );
+ tlsf_free( ( *state )->ec_gain_c_st );
+ tlsf_free( ( *state )->pred_state );
+ tlsf_free( ( *state )->background_state );
+ tlsf_free( ( *state )->ph_disp_st );
+ tlsf_free( ( *state )->Cb_gain_averState );
+ tlsf_free( ( *state )->lsp_avg_st );
+ tlsf_free( ( *state )->dtxDecoderState );
+ */
+ /* deallocate memory
+ tlsf_free( *state );*/
+ *state = NULL;
+ return;
+}
+
+
+/*
+ * Post_Filter_exit
+ *
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+static void Post_Filter_exit(Post_FilterState **state)
+{
+ if (state == NULL || *state == NULL) {
+ return;
+ }
+ //tlsf_free( ( *state )->agc_state );
+
+ /* deallocate memory */
+ //tlsf_free( *state );
+ *state = NULL;
+ return;
+}
+
+
+/*
+ * Post_Process_reset
+ *
+ *
+ * Parameters:
+ * state B: state structure
+ *
+ * Function:
+ * Resets state memory
+ *
+ * Returns:
+ * -1 failure
+ */
+static int Post_Process_reset(Post_ProcessState *state)
+{
+ if ((Post_ProcessState *)state == NULL) {
+ //fprintf( stderr, "Post_Process_reset: invalid parameter\n" );
+ return -1;
+ }
+ state->y2_hi = 0;
+ state->y2_lo = 0;
+ state->y1_hi = 0;
+ state->y1_lo = 0;
+ state->x0 = 0;
+ state->x1 = 0;
+ return 0;
+}
+
+
+/*
+ * Post_Process_exit
+ *
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+static void Post_Process_exit(Post_ProcessState **state)
+{
+ if (state == NULL || *state == NULL) {
+ return;
+ }
+
+ /* deallocate memory */
+ //tlsf_free( *state );
+ *state = NULL;
+ return;
+}
+
+
+/*
+ * Decoder_amr_init
+ *
+ *
+ * Parameters:
+ * state O: state structure
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * success = 0
+ */
+static Decoder_amrState g_Decoder_amrState;
+static D_plsfState g_D_plsfState;
+static ec_gain_pitchState g_ec_gain_pitchState;
+static ec_gain_codeState g_ec_gain_codeState;
+static dtx_decState g_dtx_decState;
+static ph_dispState g_ph_dispState;
+static Cb_gain_averageState g_Cb_gain_averageState;
+static lsp_avgState g_lsp_avgState;
+static Bgn_scdState g_Bgn_scdState;
+static gc_predState g_gc_predState;
+static int Decoder_amr_init(Decoder_amrState **state)
+{
+ Decoder_amrState * s;
+
+ if ((Decoder_amrState *)state == NULL) {
+ //fprintf( stderr, "Decoder_amr_init: invalid parameter\n" );
+ return -1;
+ }
+ *state = NULL;
+
+ /* allocate memory
+ if ( ( s = ( Decoder_amrState * ) tlsf_malloc( sizeof( Decoder_amrState ) ) ) ==
+ NULL ) {
+ fprintf( stderr, "Decoder_amr_init: can not malloc state structure\n" );
+ return-1;
+ }*/
+ s = &g_Decoder_amrState;
+
+ /* DPlsf_init */
+ /* allocate memory
+ if ( ( s->lsfState = ( D_plsfState * ) tlsf_malloc( sizeof( D_plsfState ) ) ) ==
+ NULL ) {
+ fprintf( stderr, "DPlsf_init: can not malloc state structure\n" );
+ return-1;
+ }*/
+ s->lsfState = &g_D_plsfState;
+
+ /* ecGainPitchInit */
+ /* allocate memory
+ if ( ( s->ec_gain_p_st = ( ec_gain_pitchState * ) tlsf_malloc( sizeof(
+ ec_gain_pitchState ) ) ) == NULL ) {
+ fprintf( stderr, "ecGainPitchInit: can not malloc state structure\n" );
+ return-1;
+ }*/
+ s->ec_gain_p_st = &g_ec_gain_pitchState;
+
+ /* ecGainCodeInit */
+ /* allocate memory
+ if ( ( s->ec_gain_c_st = ( ec_gain_codeState * ) tlsf_malloc( sizeof(
+ ec_gain_codeState ) ) ) == NULL ) {
+ fprintf( stderr, "ecGainCodeInit: can not malloc state structure\n" );
+ return-1;
+ }*/
+ s->ec_gain_c_st = &g_ec_gain_codeState;
+ /* gcPredInit */
+ /* allocate memory
+ if ( ( s->pred_state = ( gc_predState * ) tlsf_malloc( sizeof( gc_predState ) ) )
+ == NULL ) {
+ fprintf( stderr, "gcPredInit: can not malloc state structure\n" );
+ return-1;
+ }*/
+ s->pred_state = &g_gc_predState;
+ /* Cb_gain_averageInit */
+ /* allocate memory
+ if ( ( s->Cb_gain_averState = ( Cb_gain_averageState * ) tlsf_malloc( sizeof(
+ Cb_gain_averageState ) ) ) == NULL ) {
+ fprintf( stderr, "Cb_gain_averageInit: can not malloc state structure\n" )
+ ;
+ return-1;
+ }*/
+ s->Cb_gain_averState = &g_Cb_gain_averageState;
+ memset(s->Cb_gain_averState->cbGainHistory, 0, L_CBGAINHIST << 2);
+
+ /* Initialize hangover handling */
+ s->Cb_gain_averState->hangVar = 0;
+ s->Cb_gain_averState->hangCount = 0;
+
+ /* lsp_avgInit */
+ /* allocate memory
+ if ( ( s->lsp_avg_st = ( lsp_avgState * ) tlsf_malloc( sizeof( lsp_avgState ) ) )
+ == NULL ) {
+ fprintf( stderr, "lsp_avgInit: can not malloc state structure\n" );
+ return-1;
+ }*/
+ s->lsp_avg_st = &g_lsp_avgState;
+ /* Bgn_scdInit */
+ /* allocate memory
+ if ( ( s->background_state = ( Bgn_scdState * ) tlsf_malloc( sizeof( Bgn_scdState
+ ) ) ) == NULL ) {
+ fprintf( stderr, "Bgn_scdInit: can not malloc state structure\n" );
+ return-1;
+ }*/
+ s->background_state = &g_Bgn_scdState;
+ /* phDispInit */
+ /* allocate memory
+ if ( ( s->ph_disp_st = ( ph_dispState * ) tlsf_malloc( sizeof( ph_dispState ) ) )
+ == NULL ) {
+ fprintf( stderr, "phDispInit: can not malloc state structure\n" );
+ return-1;
+ }*/
+ s->ph_disp_st = &g_ph_dispState;
+ /* dtxDecInit */
+ /* allocate memory
+ if ( ( s->dtxDecoderState = ( dtx_decState * ) tlsf_malloc( sizeof( dtx_decState )
+ ) ) == NULL ) {
+ fprintf( stderr, "dtxDecInit: can not malloc state structure\n" );
+ return-1;
+ }*/
+ s->dtxDecoderState = &g_dtx_decState;
+ Decoder_amr_reset(s, 0);
+ *state = s;
+ return 0;
+}
+
+
+/*
+ * Post_Filter_reset
+ *
+ *
+ * Parameters:
+ * state B: state structure
+ *
+ * Function:
+ * Resets state memory
+ *
+ * Returns:
+ * -1 failure
+ */
+static int Post_Filter_reset(Post_FilterState *state)
+{
+ if ((Post_FilterState *)state == NULL) {
+ //fprintf( stderr, "Post_Filter_reset: invalid parameter\n" );
+ return -1;
+ }
+ state->preemph_state_mem_pre = 0;
+ state->agc_state->past_gain = 4096;
+ memset(state->mem_syn_pst, 0, M << 2);
+ memset(state->res2, 0, L_SUBFR << 2);
+ memset(state->synth_buf, 0, (L_FRAME + M) << 2);
+ return 0;
+}
+
+
+/*
+ * Post_Filter_init
+ *
+ *
+ * Parameters:
+ * state O: state structure
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * success = 0
+ */
+static Post_FilterState g_Post_FilterState;
+static agcState g_agcState;
+static int Post_Filter_init(Post_FilterState **state)
+{
+ Post_FilterState * s;
+
+ if ((Post_FilterState *)state == NULL) {
+ //fprintf( stderr, "F057:invalid parameter\n" );
+ return -1;
+ }
+ *state = NULL;
+
+ /* allocate memory
+ if ( ( s = ( Post_FilterState * ) tlsf_malloc( sizeof( Post_FilterState ) ) ) ==
+ NULL ) {
+ fprintf( stderr, "F057:can not malloc filter structure\n" );
+ return-1;
+ }*/
+ s = &g_Post_FilterState;
+ s->agc_state = NULL;
+
+ /* allocate memory
+ if ( ( s->agc_state = ( agcState * ) tlsf_malloc( sizeof( agcState ) ) ) == NULL )
+ {
+ fprintf( stderr, "agcInit: can not malloc state structure\n" );
+ return-1;
+ }*/
+ s->agc_state = &g_agcState;
+ Post_Filter_reset(s);
+ *state = s;
+ return 0;
+}
+
+
+/*
+ * Post_Process_init
+ *
+ *
+ * Parameters:
+ * state O: state structure
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * success = 0
+ */
+static Post_ProcessState g_Post_ProcessState;
+static int Post_Process_init(Post_ProcessState **state)
+{
+ Post_ProcessState * s;
+
+ if ((Post_ProcessState *)state == NULL) {
+ //fprintf( stderr, "Post_Process_init: invalid parameter\n" );
+ return -1;
+ }
+ *state = NULL;
+
+ /* allocate memory
+ if ( ( s = ( Post_ProcessState * ) tlsf_malloc( sizeof( Post_ProcessState ) ) ) ==
+ NULL ) {
+ fprintf( stderr, "Post_Process_init: can not malloc state structure\n" );
+ return-1;
+ }*/
+ s = &g_Post_ProcessState;
+ Post_Process_reset(s);
+ *state = s;
+ return 0;
+}
+
+
+/*
+ * Speech_Decode_Frame_exit
+ *
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+void Speech_Decode_Frame_exit(void **st)
+{
+ if (((Speech_Decode_FrameState *)(st)) == NULL) {
+ return;
+ }
+ Decoder_amr_exit(&(((Speech_Decode_FrameState *) st)->decoder_amrState
+ ));
+ Post_Filter_exit(&(((Speech_Decode_FrameState *) st)->post_state));
+ Post_Process_exit(&(((Speech_Decode_FrameState *) st)->postHP_state))
+ ;
+
+ /* deallocate memory */
+ //tlsf_free( (( Speech_Decode_FrameState * )st) );
+ return;
+}
+
+
+/*
+ * Speech_Decode_Frame_reset
+ *
+ *
+ * Parameters:
+ * state B: state structure
+ *
+ * Function:
+ * Resets state memory
+ *
+ * Returns:
+ * -1 = failure
+ */
+int Speech_Decode_Frame_reset(void **st)
+{
+ Speech_Decode_FrameState * state;
+
+ if (st == NULL || *st == NULL) {
+ return (-1);
+ }
+ state = (Speech_Decode_FrameState *)st;
+ Decoder_amr_reset(state->decoder_amrState, (enum Mode) 0);
+ Post_Filter_reset(state->post_state);
+ Post_Process_reset(state->postHP_state);
+ return 0;
+}
+
+
+/*
+ * Speech_Decode_Frame_init
+ *
+ *
+ * Parameters:
+ * state O: state structure
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * success = 0
+ */
+static Speech_Decode_FrameState g_Speech_Decode_FrameState;
+
+void * Speech_Decode_Frame_init()
+{
+ Speech_Decode_FrameState * s;
+
+ /* allocate memory
+ if ( ( s = ( Speech_Decode_FrameState * ) tlsf_malloc( sizeof(
+ Speech_Decode_FrameState ) ) ) == NULL ) {
+ fprintf( stderr, "Speech_Decode_Frame_init: can not malloc state "
+ "structure\n" );
+ return NULL;
+ }*/
+ s = &g_Speech_Decode_FrameState;
+ s->decoder_amrState = NULL;
+ s->post_state = NULL;
+ s->postHP_state = NULL;
+
+ if (Decoder_amr_init(&s->decoder_amrState) || Post_Filter_init(&s->
+ post_state) || Post_Process_init(&s->postHP_state)) {
+ Speech_Decode_Frame_exit((void **)(&s));
+ return NULL;
+ }
+ return s;
+}
diff --git a/audio_codec/libamr/sp_dec.h b/audio_codec/libamr/sp_dec.h
new file mode 100644
index 0000000..3739018
--- a/dev/null
+++ b/audio_codec/libamr/sp_dec.h
@@ -0,0 +1,83 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * R99 V3.5.0 2003-03
+ * REL-4 V4.4.0 2003-03
+ * REL-5 V5.1.0 2003-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * sp_enc.h
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * Defines interface to AMR encoder
+ *
+ */
+#ifndef _SP_DEC_H_
+#define _SP_DEC_H_
+
+/*
+ * definition of enumerated types
+ */
+
+/*
+ * definition of modes for decoder
+ */
+enum Mode { MR475 = 0,
+ MR515,
+ MR59,
+ MR67,
+ MR74,
+ MR795,
+ MR102,
+ MR122,
+ MRDTX,
+ N_MODES /* number of (SPC) modes */
+ };
+
+/* Declaration recieved frame types */
+enum RXFrameType { RX_SPEECH_GOOD = 0,
+ RX_SPEECH_DEGRADED,
+ RX_ONSET,
+ RX_SPEECH_BAD,
+ RX_SID_FIRST,
+ RX_SID_UPDATE,
+ RX_SID_BAD,
+ RX_NO_DATA,
+ RX_N_FRAMETYPES /* number of frame types */
+ };
+
+/*
+ * Function prototypes
+ */
+
+/*
+ * initialize one instance of the speech decoder
+ */
+void* Speech_Decode_Frame_init();
+
+/*
+ * free status struct
+ */
+void Speech_Decode_Frame_exit(void **st);
+
+/*
+ * Decodes one frame from encoded parameters
+ */
+void Speech_Decode_Frame(void *st, enum Mode mode, short *serial,
+ enum RXFrameType frame_type, short *synth);
+
+/*
+ * reset speech decoder
+ */
+int Speech_Decode_Frame_reset(void **st);
+
+#endif
+
diff --git a/audio_codec/libamr/typedef.h b/audio_codec/libamr/typedef.h
new file mode 100755
index 0000000..6cea8a4
--- a/dev/null
+++ b/audio_codec/libamr/typedef.h
@@ -0,0 +1,17 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef typedef_h
+#define typedef_h
+/* change these typedef declarations to correspond with your platform */
+typedef char Word8;
+typedef unsigned char UWord8;
+typedef short Word16;
+typedef unsigned short UWord16;
+typedef long Word32;
+typedef double Float64;
+typedef float Float32;
+
+#endif \ No newline at end of file
diff --git a/audio_codec/libape/Android.mk b/audio_codec/libape/Android.mk
new file mode 100755
index 0000000..3628031
--- a/dev/null
+++ b/audio_codec/libape/Android.mk
@@ -0,0 +1,28 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libape
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+LOCAL_ARM_MODE := arm
+LOCAL_C_INCLUDES := $(LOCAL_PATH) \
+
+ifeq ($(ARCH_ARM_HAVE_NEON),true)
+ LOCAL_CFLAGS += -D__ARM_HAVE_NEON -DOPT_NEON
+endif
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_SHARED_LIBRARIES += libutils libmedia libz libbinder libdl libcutils libc
+
+LOCAL_MODULE := libape
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+LOCAL_ARM_MODE := arm
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := $(LOCAL_PATH) \
+LOCAL_PRELINK_MODULE := false
+
+ifeq ($(ARCH_ARM_HAVE_NEON),true)
+ LOCAL_CFLAGS += -D__ARM_HAVE_NEON -DOPT_NEON
+endif
+include $(BUILD_SHARED_LIBRARY)
diff --git a/audio_codec/libape/Ape_decoder.h b/audio_codec/libape/Ape_decoder.h
new file mode 100644
index 0000000..c5dfa10
--- a/dev/null
+++ b/audio_codec/libape/Ape_decoder.h
@@ -0,0 +1,216 @@
+
+/**********************
+***********************/
+#ifndef APE_DECODER_H
+#define APE_DECODER_H
+
+#ifdef ENABLE_CPU2_DECODER
+#include "../TLSF/tlsf.h"
+#endif
+
+
+
+
+#define BLOCKS_PER_LOOP 1024
+#define MAX_CHANNELS 2
+#define MAX_BYTESPERSAMPLE 3
+
+#define APE_FRAMECODE_MONO_SILENCE 1
+#define APE_FRAMECODE_STEREO_SILENCE 3
+#define APE_FRAMECODE_PSEUDO_STEREO 4
+
+#define HISTORY_SIZE 512
+#define PREDICTOR_ORDER 8
+/** Total size of all predictor histories */
+#define PREDICTOR_SIZE 50
+
+#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
+#define APE_FILTER_LEVELS 3
+#define bswap_32(x) \
+ ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+
+/**
+ * Possible compression levels
+ * @{
+ */
+enum APECompressionLevel {
+ COMPRESSION_LEVEL_FAST = 1000,
+ COMPRESSION_LEVEL_NORMAL = 2000,
+ COMPRESSION_LEVEL_HIGH = 3000,
+ COMPRESSION_LEVEL_EXTRA_HIGH = 4000,
+ COMPRESSION_LEVEL_INSANE = 5000
+};
+/** Filters applied to the decoded data */
+typedef struct APEFilter {
+ int16_t *coeffs; ///< actual coefficients used in filtering
+ int16_t *adaptcoeffs; ///< adaptive filter coefficients used for correcting of actual filter coefficients
+ int16_t *historybuffer; ///< filter memory
+ int16_t *delay; ///< filtered values
+
+ int avg;
+} APEFilter;
+
+typedef struct APERice {
+ uint32_t k;
+ uint32_t ksum;
+} APERice;
+
+typedef struct APERangecoder {
+ 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
+} APERangecoder;
+
+/** Filter histories */
+typedef struct APEPredictor {
+ int32_t *buf;
+
+ int32_t lastA[2];
+
+ int32_t filterA[2];
+ int32_t filterB[2];
+
+ int32_t coeffsA[2][4]; ///< adaption coefficients
+ int32_t coeffsB[2][5]; ///< adaption coefficients
+ int32_t historybuffer[HISTORY_SIZE + PREDICTOR_SIZE];
+} APEPredictor;
+
+typedef struct {
+ unsigned current_decoding_frame;
+ unsigned channels;
+ unsigned bits_per_sample;
+ unsigned sample_rate; /* in Hz */
+ unsigned blocksize; /* in samples (per channel) */
+ void *ape_header_context;/*the ape stream info read from the header,should be same as the struct in demuxer*/
+} APE_Codec_Public_t;
+
+typedef struct {
+ void *APE_Decoder;
+ // DSPContext dsp;
+ int channels;
+ int samples; ///< samples left to decode in current frame
+
+ int fileversion; ///< codec version, very important in decoding process
+ int compression_level; ///< compression levels
+ int fset; ///< which filter set to use (calculated from compression level)
+ int flags; ///< global decoder flags
+
+ uint32_t CRC; ///< frame CRC
+ int frameflags; ///< frame flags
+ int currentframeblocks; ///< samples (per channel) in current frame
+ int blocksdecoded; ///< count of decoded samples in current frame
+ APEPredictor predictor; ///< predictor used for final reconstruction
+
+ int32_t decoded0[BLOCKS_PER_LOOP]; ///< decoded data for the first channel
+ int32_t decoded1[BLOCKS_PER_LOOP]; ///< decoded data for the second channel
+
+ int16_t* filterbuf[APE_FILTER_LEVELS]; ///< filter memory
+
+ APERangecoder rc; ///< rangecoder used to decode actual values
+ APERice riceX; ///< rice code parameters for the second channel
+ APERice riceY; ///< rice code parameters for the first channel
+ APEFilter filters[APE_FILTER_LEVELS][2]; ///< filters used for reconstruction
+
+ unsigned char *data; ///< current frame data
+ unsigned char *data_end; ///< frame data end
+ const unsigned char *ptr; ///< current position in frame data
+ const unsigned char *last_ptr; ///< position where last 4608-sample block ended
+
+ int error;
+} APE_COdec_Private_t;
+
+typedef struct {
+ APE_Codec_Public_t *public_data;
+ APE_COdec_Private_t *private_data;
+
+} APE_Decoder_t;
+typedef struct {
+ unsigned pos;
+ int nblocks;
+ int size;
+ int skip;
+ unsigned pts;
+} APEFrame;
+
+typedef struct {
+ /* Derived fields */
+ unsigned junklength;
+ unsigned firstframe;
+ unsigned totalsamples;
+ int currentframe;
+ APEFrame *frames;
+ int sync_flag;
+
+ /* Info from Descriptor Block */
+ char magic[4];
+ int fileversion;
+ int padding1;
+ unsigned descriptorlength;
+ unsigned headerlength;
+ unsigned seektablelength;
+ unsigned wavheaderlength;
+ unsigned audiodatalength;
+ unsigned audiodatalength_high;
+ unsigned wavtaillength;
+ char md5[16];
+
+ /* Info from Header Block */
+ unsigned compressiontype;
+ unsigned formatflags;
+ unsigned blocksperframe;
+ unsigned finalframeblocks;
+ unsigned totalframes;
+ unsigned bps;
+ unsigned channels;
+ unsigned samplerate;
+
+ /* Seektable */
+ unsigned *seektable;
+} APEContext;
+
+typedef enum {
+ APE_DECODE_INIT_FINISH = 0,
+ APE_DECODE_INIT_ERROR,
+ APE_DECODE_ONE_FRAME_FINISH,
+ APE_DECODE_REFILL_FRAME_FINISH,
+ APE_DECODE_CONTINUE,
+ APE_DECODE_END_OF_STREAM,
+ APE_DECODE_ERROR_ABORT,
+ APE_DECODE_MEM_MALLOC_ERROR
+} APE_Decode_status_t;
+
+
+APE_Decoder_t* ape_decoder_new(void* ape_head_context);
+APE_Decode_status_t ape_decode_init(APE_Decoder_t *avctx);
+APE_Decode_status_t ape_decode_frame(APE_Decoder_t * avctx, \
+ void *data, int *data_size, \
+ const unsigned char *buf, int buf_size);
+void ape_decoder_delete(APE_Decoder_t *decoder);
+
+typedef struct _APEIOBuf {
+ int bytesLeft;
+ int thislop_decoded_size;
+ unsigned char *readPtr;
+ unsigned lastframesize;
+ short outBuf[MAX_CHANNELS][BLOCKS_PER_LOOP];
+} APEIOBuf;
+
+typedef struct {
+ unsigned bps;
+ unsigned channels;
+ unsigned samplerate;
+ unsigned compressiontype;
+ unsigned formatflags;
+ int fileversion;
+} ape_extra_data;
+#endif
diff --git a/audio_codec/libape/amlogic_r30813_audio_ape_lib.c b/audio_codec/libape/amlogic_r30813_audio_ape_lib.c
new file mode 100644
index 0000000..8ebca2a
--- a/dev/null
+++ b/audio_codec/libape/amlogic_r30813_audio_ape_lib.c
@@ -0,0 +1 @@
+int audio_ape_lib_revision = 30813;
diff --git a/audio_codec/libape/apedec.c b/audio_codec/libape/apedec.c
new file mode 100644
index 0000000..ce5b4a0
--- a/dev/null
+++ b/audio_codec/libape/apedec.c
@@ -0,0 +1,1120 @@
+/*
+ * Monkey's Audio lossless audio decoder
+ * Copyright (c) 2007 Benjamin Zores <ben@geexbox.org>
+ * based upon libdemac from Dave Chapman.
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <stdint.h>
+#include "Ape_decoder.h"
+#include "../../amadec/adec-armdec-mgt.h"
+#include <android/log.h>
+#ifdef __ARM_HAVE_NEON
+#include <arm_neon.h>
+#endif
+#include <sys/time.h>
+
+#define LOG_TAG "ApeDecoder"
+#define audio_codec_print(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+static APEIOBuf apeiobuf = {0};
+static APE_Decoder_t *apedec;
+static int read_buffersize_per_time = 102400 ; //100k
+ape_extra_data headinfo ;
+
+//#include<
+/**
+ * @file libavcodec/apedec.c
+ * Monkey's Audio lossless audio decoder
+ */
+
+
+/** @} */
+#define ALT_BITSTREAM_READER_LE
+#define APE_FILTER_LEVELS 3
+
+/** Filter orders depending on compression level */
+static const uint16_t ape_filter_orders[5][APE_FILTER_LEVELS] = {
+ { 0, 0, 0 },
+ { 16, 0, 0 },
+ { 64, 0, 0 },
+ { 32, 256, 0 },
+ { 16, 256, 1280 }
+};
+
+/** Filter fraction bits depending on compression level */
+static const uint8_t ape_filter_fracbits[5][APE_FILTER_LEVELS] = {
+ { 0, 0, 0 },
+ { 11, 0, 0 },
+ { 11, 0, 0 },
+ { 10, 13, 0 },
+ { 11, 13, 15 }
+};
+
+static inline uint32_t bytestream_get_be32(const uint8_t** ptr)
+{
+ uint32_t tmp;
+ tmp = (*ptr)[3] | ((*ptr)[2] << 8) | ((*ptr)[1] << 16) | ((*ptr)[0] << 24);
+ *ptr += 4;
+ return tmp;
+}
+static inline uint8_t bytestream_get_byte(const uint8_t** ptr)
+{
+ uint8_t tmp;
+ tmp = **ptr;
+ *ptr += 1;
+ return tmp;
+}
+
+void * dsp_malloc(int size)
+{
+ return malloc(size);
+}
+
+void dsp_free(void * buf)
+{
+ free(buf);
+}
+
+void * dsp_realloc(void *ptr, size_t size)
+
+{
+ return realloc(ptr, size);
+}
+
+
+/***build a new ape decoder instance***/
+APE_Decoder_t* ape_decoder_new(void* ape_head_context)
+{
+ APE_Decoder_t *decoder;
+
+ decoder = (APE_Decoder_t*)dsp_malloc(sizeof(APE_Decoder_t));
+ memset(decoder, 0, sizeof(APE_Decoder_t));
+ if (!decoder) {
+ audio_codec_print("====malloc failed 1\n");
+ return 0;
+ }
+
+ decoder->public_data = (APE_Codec_Public_t*)dsp_malloc(sizeof(APE_Codec_Public_t));
+ if (decoder->public_data == 0) {
+ audio_codec_print("====malloc failed 2\n");
+ dsp_free(decoder);
+ return 0;
+ } else {
+ memset(decoder->public_data, 0, sizeof(APE_Codec_Public_t));
+ }
+
+
+ decoder->private_data = (APE_COdec_Private_t*)dsp_malloc(sizeof(APE_COdec_Private_t));
+ if (decoder->private_data == 0) {
+ audio_codec_print("====malloc failed 3\n");
+ dsp_free(decoder->public_data);
+ dsp_free(decoder);
+ return 0;
+ }
+ memset(decoder->private_data, 0, sizeof(APE_COdec_Private_t));
+
+ decoder->public_data->current_decoding_frame = 0;
+ decoder->public_data->ape_header_context = ape_head_context;
+
+ return decoder;
+}
+
+void ape_decoder_delete(APE_Decoder_t *decoder)
+{
+ APE_COdec_Private_t *s = decoder->private_data;
+ int i = 0;
+ if (decoder->private_data->data) {
+ dsp_free(decoder->private_data->data);
+ decoder->private_data->data = NULL;
+ }
+ if (decoder->private_data->filterbuf[0]) {
+ for (i = 0; i < APE_FILTER_LEVELS; i++) {
+ if (s->filterbuf[i]) {
+ dsp_free(s->filterbuf[i]);
+ }
+ }
+ }
+ if (decoder->private_data) {
+ dsp_free(decoder->private_data);
+ decoder->private_data = NULL;
+ }
+ if (decoder->public_data) {
+ dsp_free(decoder->public_data);
+ decoder->public_data = NULL;
+
+ }
+ dsp_free(decoder);
+ decoder = NULL ;
+ return ;
+}
+// TODO: dsputilize
+
+APE_Decode_status_t ape_decode_init(APE_Decoder_t *avctx)
+{
+ APE_COdec_Private_t *s = avctx->private_data;
+ APE_Codec_Public_t *p = avctx->public_data;
+ ape_extra_data *apecontext = (ape_extra_data *) avctx->public_data->ape_header_context;
+ int i;
+ audio_codec_print("===param==bps:%d channel:%d \n", apecontext->bps, apecontext->channels);
+ if (apecontext->bps != 16) {
+ audio_codec_print("OOnly 16-bit samples are supported\n");
+ return APE_DECODE_INIT_ERROR;
+ }
+ if (apecontext->channels > 2) {
+ audio_codec_print("Only mono and stereo is supported\n");
+ return APE_DECODE_INIT_ERROR;
+ }
+ s->APE_Decoder = avctx;
+ s->channels = apecontext->channels;
+ s->fileversion = apecontext->fileversion;
+ s->compression_level = apecontext->compressiontype;
+ s->flags = apecontext->formatflags;
+ /** some public parameter **/
+ p->bits_per_sample = apecontext->bps;
+ p->sample_rate = apecontext->samplerate;
+ if (s->compression_level % 1000 || s->compression_level > COMPRESSION_LEVEL_INSANE) {
+ audio_codec_print("Incorrect compression level %d\n", s->compression_level);
+ return APE_DECODE_INIT_ERROR;
+ }
+ s->fset = s->compression_level / 1000 - 1;
+ for (i = 0; i < APE_FILTER_LEVELS; i++) {
+ if (!ape_filter_orders[s->fset][i]) {
+ break;
+ }
+ s->filterbuf[i] = (int16_t*)dsp_malloc((ape_filter_orders[s->fset][i] * 3 + HISTORY_SIZE) * 4);
+ if (s->filterbuf[i] == NULL) {
+ audio_codec_print("s->filterbuf[i] malloc error size:%d %d %d \n", (ape_filter_orders[s->fset][i] * 3 + HISTORY_SIZE) * 4, ape_filter_orders[s->fset][i], HISTORY_SIZE);
+ }
+ }
+ return APE_DECODE_INIT_FINISH;
+}
+
+static int ape_decode_close(APE_Decoder_t * avctx)
+{
+ APE_COdec_Private_t *s = avctx->private_data;
+ int i;
+
+ for (i = 0; i < APE_FILTER_LEVELS; i++) {
+ dsp_free(&s->filterbuf[i]);
+ }
+
+ return 0;
+}
+
+/**
+ * @defgroup rangecoder APE range decoder
+ * @{
+ */
+
+#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)
+
+/** Start the decoder */
+static inline void range_start_decoding(APE_COdec_Private_t * ctx)
+{
+ ctx->rc.buffer = bytestream_get_byte(&ctx->ptr);
+ ctx->rc.low = ctx->rc.buffer >> (8 - EXTRA_BITS);
+ ctx->rc.range = (uint32_t) 1 << EXTRA_BITS;
+}
+
+/** Perform normalization */
+static inline void range_dec_normalize(APE_COdec_Private_t * ctx)
+{
+ while (ctx->rc.range <= BOTTOM_VALUE) {
+ ctx->rc.buffer <<= 8;
+ if (ctx->ptr < ctx->data_end) {
+ ctx->rc.buffer += *ctx->ptr;
+ }
+ ctx->ptr++;
+ ctx->rc.low = (ctx->rc.low << 8) | ((ctx->rc.buffer >> 1) & 0xFF);
+ ctx->rc.range <<= 8;
+ if (ctx->rc.range == 0) { //in error condition.if == 0,no chance return,so added
+ return;
+ }
+ }
+}
+
+/**
+ * Calculate culmulative frequency for next symbol. Does NO update!
+ * @param ctx decoder context
+ * @param tot_f is the total frequency or (code_value)1<<shift
+ * @return the culmulative frequency
+ */
+static inline int range_decode_culfreq(APE_COdec_Private_t * ctx, int tot_f)
+{
+ range_dec_normalize(ctx);
+ ctx->rc.help = ctx->rc.range / tot_f;
+ return ctx->rc.low / ctx->rc.help;
+}
+
+/**
+ * Decode value with given size in bits
+ * @param ctx decoder context
+ * @param shift number of bits to decode
+ */
+static inline int range_decode_culshift(APE_COdec_Private_t * ctx, int shift)
+{
+ range_dec_normalize(ctx);
+ ctx->rc.help = ctx->rc.range >> shift;
+ return ctx->rc.low / ctx->rc.help;
+}
+
+
+/**
+ * Update decoding state
+ * @param ctx decoder context
+ * @param sy_f the interval length (frequency of the symbol)
+ * @param lt_f the lower end (frequency sum of < symbols)
+ */
+static inline void range_decode_update(APE_COdec_Private_t * ctx, int sy_f, int lt_f)
+{
+ ctx->rc.low -= ctx->rc.help * lt_f;
+ ctx->rc.range = ctx->rc.help * sy_f;
+}
+
+/** Decode n bits (n <= 16) without modelling */
+static inline int range_decode_bits(APE_COdec_Private_t * ctx, int n)
+{
+ int sym = range_decode_culshift(ctx, n);
+ range_decode_update(ctx, 1, sym);
+ return sym;
+}
+
+
+#define MODEL_ELEMENTS 64
+
+/**
+ * Fixed probabilities for symbols in Monkey Audio version 3.97
+ */
+static const uint16_t counts_3970[22] = {
+ 0, 14824, 28224, 39348, 47855, 53994, 58171, 60926,
+ 62682, 63786, 64463, 64878, 65126, 65276, 65365, 65419,
+ 65450, 65469, 65480, 65487, 65491, 65493,
+};
+
+/**
+ * Probability ranges for symbols in Monkey Audio version 3.97
+ */
+static const uint16_t counts_diff_3970[21] = {
+ 14824, 13400, 11124, 8507, 6139, 4177, 2755, 1756,
+ 1104, 677, 415, 248, 150, 89, 54, 31,
+ 19, 11, 7, 4, 2,
+};
+
+/**
+ * Fixed probabilities for symbols in Monkey Audio version 3.98
+ */
+static const uint16_t counts_3980[22] = {
+ 0, 19578, 36160, 48417, 56323, 60899, 63265, 64435,
+ 64971, 65232, 65351, 65416, 65447, 65466, 65476, 65482,
+ 65485, 65488, 65490, 65491, 65492, 65493,
+};
+
+/**
+ * Probability ranges for symbols in Monkey Audio version 3.98
+ */
+static const uint16_t counts_diff_3980[21] = {
+ 19578, 16582, 12257, 7906, 4576, 2366, 1170, 536,
+ 261, 119, 65, 31, 19, 10, 6, 3,
+ 3, 2, 1, 1, 1,
+};
+
+/**
+ * Decode symbol
+ * @param ctx decoder context
+ * @param counts probability range start position
+ * @param counts_diff probability range widths
+ */
+static inline int range_get_symbol(APE_COdec_Private_t * ctx,
+ const uint16_t counts[],
+ const uint16_t counts_diff[])
+{
+ int symbol, cf;
+
+ cf = range_decode_culshift(ctx, 16);
+
+ if (cf > 65492) {
+ symbol = cf - 65535 + 63;
+ range_decode_update(ctx, 1, cf);
+ if (cf > 65535) {
+ ctx->error = 1;
+ }
+ return symbol;
+ }
+ /* figure out the symbol inefficiently; a binary search would be much better */
+ for (symbol = 0; counts[symbol + 1] <= cf; symbol++) {
+ ;
+ }
+
+ range_decode_update(ctx, counts_diff[symbol], counts[symbol]);
+
+ return symbol;
+}
+/** @} */ // group rangecoder
+
+static inline void update_rice(APERice *rice, int x)
+{
+ int lim = rice->k ? (1 << (rice->k + 4)) : 0;
+ rice->ksum += ((x + 1) / 2) - ((rice->ksum + 16) >> 5);
+
+ if (rice->ksum < lim) {
+ rice->k--;
+ } else if (rice->ksum >= (1 << (rice->k + 5))) {
+ rice->k++;
+ }
+}
+
+static inline int ape_decode_value(APE_COdec_Private_t * ctx, APERice *rice)
+{
+ int x, overflow;
+
+ if (ctx->fileversion < 3990) {
+ int tmpk;
+
+ overflow = range_get_symbol(ctx, counts_3970, counts_diff_3970);
+
+ if (overflow == (MODEL_ELEMENTS - 1)) {
+ tmpk = range_decode_bits(ctx, 5);
+ overflow = 0;
+ } else {
+ tmpk = (rice->k < 1) ? 0 : rice->k - 1;
+ }
+
+ if (tmpk <= 16) {
+ x = range_decode_bits(ctx, tmpk);
+ } else {
+ x = range_decode_bits(ctx, 16);
+ x |= (range_decode_bits(ctx, tmpk - 16) << 16);
+ }
+ x += overflow << tmpk;
+ } else {
+ int base, pivot;
+
+ pivot = rice->ksum >> 5;
+ if (pivot == 0) {
+ pivot = 1;
+ }
+
+ overflow = range_get_symbol(ctx, counts_3980, counts_diff_3980);
+
+ if (overflow == (MODEL_ELEMENTS - 1)) {
+ overflow = range_decode_bits(ctx, 16) << 16;
+ overflow |= range_decode_bits(ctx, 16);
+ }
+
+ base = range_decode_culfreq(ctx, pivot);
+ range_decode_update(ctx, 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 void entropy_decode(APE_COdec_Private_t * ctx, int blockstodecode, int stereo)
+{
+ int32_t *decoded0 = ctx->decoded0;
+ int32_t *decoded1 = ctx->decoded1;
+
+ ctx->blocksdecoded = blockstodecode;
+
+ if (ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) {
+ /* We are pure silence, just memset the output buffer. */
+ memset(decoded0, 0, blockstodecode * sizeof(int32_t));
+ memset(decoded1, 0, blockstodecode * sizeof(int32_t));
+ } else {
+ while (blockstodecode--) {
+ *decoded0++ = ape_decode_value(ctx, &ctx->riceY);
+ if (stereo) {
+ *decoded1++ = ape_decode_value(ctx, &ctx->riceX);
+ }
+ }
+ }
+
+ if (ctx->blocksdecoded == ctx->currentframeblocks) {
+ range_dec_normalize(ctx); /* normalize to use up all bytes */
+ }
+}
+
+static void init_entropy_decoder(APE_COdec_Private_t * ctx)
+{
+ /* Read the CRC */
+ ctx->CRC = bytestream_get_be32(&ctx->ptr);
+
+ /* Read the frame flags if they exist */
+ ctx->frameflags = 0;
+ if ((ctx->fileversion > 3820) && (ctx->CRC & 0x80000000)) {
+ ctx->CRC &= ~0x80000000;
+
+ ctx->frameflags = bytestream_get_be32(&ctx->ptr);
+ }
+
+ /* Keep a count of the blocks decoded in this frame */
+ ctx->blocksdecoded = 0;
+
+ /* Initialize the rice structs */
+ ctx->riceX.k = 10;
+ ctx->riceX.ksum = (1 << ctx->riceX.k) * 16;
+ ctx->riceY.k = 10;
+ ctx->riceY.ksum = (1 << ctx->riceY.k) * 16;
+
+ /* The first 8 bits of input are ignored. */
+ ctx->ptr++;
+
+ range_start_decoding(ctx);
+}
+
+static const int32_t initial_coeffs[4] = {
+ 360, 317, -109, 98
+};
+
+static void init_predictor_decoder(APE_COdec_Private_t * ctx)
+{
+ APEPredictor *p = &ctx->predictor;
+
+ /* Zero the history buffers */
+ memset(p->historybuffer, 0, PREDICTOR_SIZE * sizeof(int32_t));
+ p->buf = p->historybuffer;
+
+ /* Initialize and zero the coefficients */
+ memcpy(p->coeffsA[0], initial_coeffs, sizeof(initial_coeffs));
+ memcpy(p->coeffsA[1], initial_coeffs, sizeof(initial_coeffs));
+ memset(p->coeffsB, 0, sizeof(p->coeffsB));
+
+ p->filterA[0] = p->filterA[1] = 0;
+ p->filterB[0] = p->filterB[1] = 0;
+ p->lastA[0] = p->lastA[1] = 0;
+}
+
+/** Get inverse sign of integer (-1 for positive, 1 for negative and 0 for zero) */
+static inline int APESIGN(int32_t x)
+{
+ return (x < 0) - (x > 0);
+}
+
+static int predictor_update_filter(APEPredictor *p, const int decoded, const int filter, const int delayA, const int delayB, const int adaptA, const int adaptB)
+{
+ int32_t predictionA, predictionB;
+
+ p->buf[delayA] = p->lastA[filter];
+ p->buf[adaptA] = APESIGN(p->buf[delayA]);
+ p->buf[delayA - 1] = p->buf[delayA] - p->buf[delayA - 1];
+ p->buf[adaptA - 1] = APESIGN(p->buf[delayA - 1]);
+
+ predictionA = p->buf[delayA ] * p->coeffsA[filter][0] +
+ p->buf[delayA - 1] * p->coeffsA[filter][1] +
+ p->buf[delayA - 2] * p->coeffsA[filter][2] +
+ p->buf[delayA - 3] * p->coeffsA[filter][3];
+
+ /* Apply a scaled first-order filter compression */
+ p->buf[delayB] = p->filterA[filter ^ 1] - ((p->filterB[filter] * 31) >> 5);
+ p->buf[adaptB] = APESIGN(p->buf[delayB]);
+ p->buf[delayB - 1] = p->buf[delayB] - p->buf[delayB - 1];
+ p->buf[adaptB - 1] = APESIGN(p->buf[delayB - 1]);
+ p->filterB[filter] = p->filterA[filter ^ 1];
+
+ predictionB = p->buf[delayB ] * p->coeffsB[filter][0] +
+ p->buf[delayB - 1] * p->coeffsB[filter][1] +
+ p->buf[delayB - 2] * p->coeffsB[filter][2] +
+ p->buf[delayB - 3] * p->coeffsB[filter][3] +
+ p->buf[delayB - 4] * p->coeffsB[filter][4];
+
+ p->lastA[filter] = decoded + ((predictionA + (predictionB >> 1)) >> 10);
+ p->filterA[filter] = p->lastA[filter] + ((p->filterA[filter] * 31) >> 5);
+
+ if (!decoded) { // no need updating filter coefficients
+ return p->filterA[filter];
+ }
+
+ if (decoded > 0) {
+ p->coeffsA[filter][0] -= p->buf[adaptA ];
+ p->coeffsA[filter][1] -= p->buf[adaptA - 1];
+ p->coeffsA[filter][2] -= p->buf[adaptA - 2];
+ p->coeffsA[filter][3] -= p->buf[adaptA - 3];
+
+ p->coeffsB[filter][0] -= p->buf[adaptB ];
+ p->coeffsB[filter][1] -= p->buf[adaptB - 1];
+ p->coeffsB[filter][2] -= p->buf[adaptB - 2];
+ p->coeffsB[filter][3] -= p->buf[adaptB - 3];
+ p->coeffsB[filter][4] -= p->buf[adaptB - 4];
+ } else {
+ p->coeffsA[filter][0] += p->buf[adaptA ];
+ p->coeffsA[filter][1] += p->buf[adaptA - 1];
+ p->coeffsA[filter][2] += p->buf[adaptA - 2];
+ p->coeffsA[filter][3] += p->buf[adaptA - 3];
+
+ p->coeffsB[filter][0] += p->buf[adaptB ];
+ p->coeffsB[filter][1] += p->buf[adaptB - 1];
+ p->coeffsB[filter][2] += p->buf[adaptB - 2];
+ p->coeffsB[filter][3] += p->buf[adaptB - 3];
+ p->coeffsB[filter][4] += p->buf[adaptB - 4];
+ }
+ return p->filterA[filter];
+}
+
+static void predictor_decode_stereo(APE_COdec_Private_t * ctx, int count)
+{
+ int32_t predictionA, predictionB;
+ APEPredictor *p = &ctx->predictor;
+ int32_t *decoded0 = ctx->decoded0;
+ int32_t *decoded1 = ctx->decoded1;
+
+ while (count--) {
+ /* Predictor Y */
+ predictionA = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB, YADAPTCOEFFSA, YADAPTCOEFFSB);
+ predictionB = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB, XADAPTCOEFFSA, XADAPTCOEFFSB);
+ *(decoded0++) = predictionA;
+ *(decoded1++) = predictionB;
+
+ /* Combined */
+ p->buf++;
+
+ /* Have we filled the history buffer? */
+ if (p->buf == p->historybuffer + HISTORY_SIZE) {
+ memmove(p->historybuffer, p->buf, PREDICTOR_SIZE * sizeof(int32_t));
+ p->buf = p->historybuffer;
+ }
+ }
+}
+
+static void predictor_decode_mono(APE_COdec_Private_t * ctx, int count)
+{
+ APEPredictor *p = &ctx->predictor;
+ int32_t *decoded0 = ctx->decoded0;
+ int32_t predictionA, currentA, A;
+
+ currentA = p->lastA[0];
+
+ while (count--) {
+ A = *decoded0;
+
+ p->buf[YDELAYA] = currentA;
+ p->buf[YDELAYA - 1] = p->buf[YDELAYA] - p->buf[YDELAYA - 1];
+
+ predictionA = p->buf[YDELAYA ] * p->coeffsA[0][0] +
+ p->buf[YDELAYA - 1] * p->coeffsA[0][1] +
+ p->buf[YDELAYA - 2] * p->coeffsA[0][2] +
+ p->buf[YDELAYA - 3] * p->coeffsA[0][3];
+
+ currentA = A + (predictionA >> 10);
+
+ p->buf[YADAPTCOEFFSA] = APESIGN(p->buf[YDELAYA ]);
+ p->buf[YADAPTCOEFFSA - 1] = APESIGN(p->buf[YDELAYA - 1]);
+
+ if (A > 0) {
+ p->coeffsA[0][0] -= p->buf[YADAPTCOEFFSA ];
+ p->coeffsA[0][1] -= p->buf[YADAPTCOEFFSA - 1];
+ p->coeffsA[0][2] -= p->buf[YADAPTCOEFFSA - 2];
+ p->coeffsA[0][3] -= p->buf[YADAPTCOEFFSA - 3];
+ } else if (A < 0) {
+ p->coeffsA[0][0] += p->buf[YADAPTCOEFFSA ];
+ p->coeffsA[0][1] += p->buf[YADAPTCOEFFSA - 1];
+ p->coeffsA[0][2] += p->buf[YADAPTCOEFFSA - 2];
+ p->coeffsA[0][3] += p->buf[YADAPTCOEFFSA - 3];
+ }
+
+ p->buf++;
+
+ /* Have we filled the history buffer? */
+ if (p->buf == p->historybuffer + HISTORY_SIZE) {
+ memmove(p->historybuffer, p->buf, PREDICTOR_SIZE * sizeof(int32_t));
+ p->buf = p->historybuffer;
+ }
+
+ p->filterA[0] = currentA + ((p->filterA[0] * 31) >> 5);
+ *(decoded0++) = p->filterA[0];
+ }
+
+ p->lastA[0] = currentA;
+}
+
+static void do_init_filter(APEFilter *f, int16_t * buf, int order)
+{
+ f->coeffs = buf;
+ f->historybuffer = buf + order;
+ f->delay = f->historybuffer + order * 2;
+ f->adaptcoeffs = f->historybuffer + order;
+
+ memset(f->historybuffer, 0, (order * 2) * sizeof(int16_t));
+ memset(f->coeffs, 0, order * sizeof(int16_t));
+ f->avg = 0;
+}
+
+static void init_filter(APE_COdec_Private_t * ctx, APEFilter *f, int16_t * buf, int order)
+{
+ do_init_filter(&f[0], buf, order);
+ do_init_filter(&f[1], buf + order * 3 + HISTORY_SIZE, order);
+}
+static int32_t scalarproduct_int16_c(int16_t * v1, int16_t * v2, int order, int shift)
+{
+ int res = 0;
+
+#if !(defined __ARM_HAVE_NEON)
+ while (order--) {
+ res += (*v1++ * *v2++)/* >> shift*/;
+ }
+#else
+ int j = order / 4;
+ int k = order % 4;
+ int32x4_t neonres = vdupq_n_s32(0);
+
+ while (j--) {
+ neonres = vmlal_s16(neonres, vld1_s16(v1), vld1_s16(v2));
+ v1 += 4;
+ v2 += 4;
+ }
+
+ while (k--) {
+ res += (*v1++ * *v2++);
+ }
+
+ res += vgetq_lane_s32(neonres, 0) + vgetq_lane_s32(neonres, 1) +
+ vgetq_lane_s32(neonres, 2) + vgetq_lane_s32(neonres, 3);
+#endif
+ return res;
+}
+static void add_int16_c(int16_t * v1, int16_t * v2, int order)
+{
+#if !(defined __ARM_HAVE_NEON)
+ while (order--) {
+ *v1++ += *v2++;
+ }
+#else
+ int j = order / 8;
+ int k = order % 8;
+ int16x8_t neonv1;
+
+ while (j--) {
+ neonv1 = vaddq_s16(vld1q_s16(v1), vld1q_s16(v2));
+ vst1q_s16(v1, neonv1);
+ v1 += 8;
+ v2 += 8;
+ }
+
+ while (k--) {
+ *v1++ += *v2++;
+ }
+#endif
+}
+
+static void sub_int16_c(int16_t * v1, int16_t * v2, int order)
+{
+#if !(defined __ARM_HAVE_NEON)
+ while (order--) {
+ *v1++ -= *v2++;
+ }
+#else
+ int j = order / 8;
+ int k = order % 8;
+ int16x8_t neonv1;
+
+ while (j--) {
+ neonv1 = vsubq_s16(vld1q_s16(v1), vld1q_s16(v2));
+ vst1q_s16(v1, neonv1);
+ v1 += 8;
+ v2 += 8;
+ }
+
+ while (k--) {
+ *v1++ -= *v2++;
+ }
+#endif
+}
+static inline int16_t av_clip_int16(int a)
+{
+ if ((a + 32768) & ~65535) {
+ return (a >> 31) ^ 32767;
+ } else {
+ return a;
+ }
+}
+static inline void do_apply_filter(APE_COdec_Private_t * ctx, int version, APEFilter *f, int32_t *data, int count, int order, int fracbits)
+{
+ int res;
+ int absres;
+
+ while (count--) {
+ /* round fixedpoint scalar product */
+ res = (scalarproduct_int16_c(f->delay - order, f->coeffs, order, 0) + (1 << (fracbits - 1))) >> fracbits;
+
+ if (*data < 0) {
+ add_int16_c(f->coeffs, f->adaptcoeffs - order, order);
+ } else if (*data > 0) {
+ sub_int16_c(f->coeffs, f->adaptcoeffs - order, order);
+ }
+
+ res += *data;
+
+ *data++ = res;
+
+ /* Update the output history */
+ *f->delay++ = av_clip_int16(res);
+
+ if (version < 3980) {
+ /* Version ??? to < 3.98 files (untested) */
+ f->adaptcoeffs[0] = (res == 0) ? 0 : ((res >> 28) & 8) - 4;
+ f->adaptcoeffs[-4] >>= 1;
+ f->adaptcoeffs[-8] >>= 1;
+ } else {
+ /* Version 3.98 and later files */
+
+ /* Update the adaption coefficients */
+ absres = (res < 0 ? -res : res);
+
+ if (absres > (f->avg * 3)) {
+ *f->adaptcoeffs = ((res >> 25) & 64) - 32;
+ } else if (absres > (f->avg * 4) / 3) {
+ *f->adaptcoeffs = ((res >> 26) & 32) - 16;
+ } else if (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 (f->delay == f->historybuffer + HISTORY_SIZE + (order * 2)) {
+ memmove(f->historybuffer, f->delay - (order * 2),
+ (order * 2) * sizeof(int16_t));
+ f->delay = f->historybuffer + order * 2;
+ f->adaptcoeffs = f->historybuffer + order;
+ }
+ }
+}
+
+static void apply_filter(APE_COdec_Private_t * ctx, APEFilter *f,
+ int32_t * data0, int32_t * data1,
+ int count, int order, int fracbits)
+{
+ do_apply_filter(ctx, ctx->fileversion, &f[0], data0, count, order, fracbits);
+ if (data1) {
+ do_apply_filter(ctx, ctx->fileversion, &f[1], data1, count, order, fracbits);
+ }
+}
+
+static void ape_apply_filters(APE_COdec_Private_t * ctx, int32_t * decoded0,
+ int32_t * decoded1, int count)
+{
+ int i;
+
+ for (i = 0; i < APE_FILTER_LEVELS; i++) {
+ if (!ape_filter_orders[ctx->fset][i]) {
+ break;
+ }
+ apply_filter(ctx, ctx->filters[i], decoded0, decoded1, count, ape_filter_orders[ctx->fset][i], ape_filter_fracbits[ctx->fset][i]);
+ }
+}
+
+static void init_frame_decoder(APE_COdec_Private_t * ctx)
+{
+ int i;
+ init_entropy_decoder(ctx);
+ init_predictor_decoder(ctx);
+
+ for (i = 0; i < APE_FILTER_LEVELS; i++) {
+ if (!ape_filter_orders[ctx->fset][i]) {
+ break;
+ }
+ init_filter(ctx, ctx->filters[i], ctx->filterbuf[i], ape_filter_orders[ctx->fset][i]);
+ }
+}
+
+static void ape_unpack_mono(APE_COdec_Private_t * ctx, int count)
+{
+ int32_t left;
+ int32_t *decoded0 = ctx->decoded0;
+ int32_t *decoded1 = ctx->decoded1;
+
+ if (ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) {
+ entropy_decode(ctx, count, 0);
+ /* We are pure silence, so we're done. */
+ printf("pure silence mono\n");
+ return;
+ }
+
+ entropy_decode(ctx, count, 0);
+ ape_apply_filters(ctx, decoded0, NULL, count);
+
+ /* Now apply the predictor decoding */
+ predictor_decode_mono(ctx, count);
+
+ /* Pseudo-stereo - just copy left channel to right channel */
+ if (ctx->channels == 2) {
+ while (count--) {
+ left = *decoded0;
+ *(decoded1++) = *(decoded0++) = left;
+ }
+ }
+}
+
+static void ape_unpack_stereo(APE_COdec_Private_t * ctx, int count)
+{
+ int32_t left, right;
+ int32_t *decoded0 = ctx->decoded0;
+ int32_t *decoded1 = ctx->decoded1;
+
+ if (ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) {
+ /* We are pure silence, so we're done. */
+ printf("Function %s:pure silence stereo\n,""ape_unpack_stereo");
+ return;
+ }
+
+ entropy_decode(ctx, count, 1);
+ ape_apply_filters(ctx, decoded0, decoded1, count);
+
+ /* Now apply the predictor decoding */
+ predictor_decode_stereo(ctx, count);
+
+ /* Decorrelate and scale to output depth */
+ while (count--) {
+ left = *decoded1 - (*decoded0 / 2);
+ right = left + *decoded0;
+
+ *(decoded0++) = left;
+ *(decoded1++) = right;
+ }
+}
+static void bswap_buf(uint32_t *dst, const uint32_t *src, int w)
+{
+ int i;
+
+ for (i = 0; i + 8 <= w; i += 8) {
+ dst[i + 0] = bswap_32(src[i + 0]);
+ dst[i + 1] = bswap_32(src[i + 1]);
+ dst[i + 2] = bswap_32(src[i + 2]);
+ dst[i + 3] = bswap_32(src[i + 3]);
+ dst[i + 4] = bswap_32(src[i + 4]);
+ dst[i + 5] = bswap_32(src[i + 5]);
+ dst[i + 6] = bswap_32(src[i + 6]);
+ dst[i + 7] = bswap_32(src[i + 7]);
+ }
+ for (; i < w; i++) {
+ dst[i + 0] = bswap_32(src[i + 0]);
+ }
+}
+
+APE_Decode_status_t ape_decode_frame(APE_Decoder_t * avctx, \
+ void *data, int *data_size , \
+ const unsigned char * buf, int buf_size)
+{
+
+ APE_COdec_Private_t *s = avctx->private_data;
+ //APEContext *apecontext =(APEContext *) avctx->public_data->ape_header_context;
+ int16_t *samples = data;
+ int nblocks;
+ int i, n;
+ int blockstodecode;
+ // unsigned *inputbuf;
+ if (buf_size == 0 && !s->samples) {
+ *data_size = 0;
+ printf("error parameter in:buf_size:%d\n", buf_size);
+ return APE_DECODE_ERROR_ABORT;
+ }
+ if (!s->samples) { //the new frame decode loop
+ if (s->data) {
+ s->data = dsp_realloc(s->data, (buf_size + 3) & ~3);
+ } else {
+ s->data = dsp_malloc((buf_size + 3) & ~3);
+ }
+ if (!s->data) {
+ printf("malloc for input frame failed,enlarge the mem pool!\r\n");
+ }
+ bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2);
+ s->ptr = s->last_ptr = s->data;//the current data position
+ s->data_end = s->data + buf_size;
+ nblocks = s->samples = bytestream_get_be32(&s->ptr);//the current frame block num
+ n = bytestream_get_be32(&s->ptr);//skip
+ if (n < 0 || n > 3) {
+ audio_codec_print("Incorrect offset passed:%d\n", n);
+ printf("current block num this frame is %d\n", nblocks);
+ s->data = NULL;
+ s->samples = 0;
+ return APE_DECODE_ERROR_ABORT;
+ }
+ s->ptr += n;// the begin of the data read loop
+
+ s->currentframeblocks = nblocks;
+ buf += 4;
+ if (s->samples <= 0) {
+ printf("it seems that the samples num frame<= 0\n");
+ *data_size = 0;
+ return APE_DECODE_ERROR_ABORT;
+ }
+
+ //s->samples = apecontext->frames[apecontext->currentframe]->nblocks;
+ memset(s->decoded0, 0, sizeof(s->decoded0));
+ memset(s->decoded1, 0, sizeof(s->decoded1));
+
+ /* Initialize the frame decoder */
+ init_frame_decoder(s);
+ }
+
+ if (!s->data) {
+ *data_size = 0;
+ printf("it seems that s->data== 0\n");
+ return APE_DECODE_ERROR_ABORT;
+ }
+
+ nblocks = s->samples;
+ blockstodecode = BLOCKS_PER_LOOP > nblocks ? nblocks : BLOCKS_PER_LOOP;
+
+ s->error = 0;
+
+ if ((s->channels == 1) || (s->frameflags & APE_FRAMECODE_PSEUDO_STEREO)) {
+ ape_unpack_mono(s, blockstodecode);
+ } else {
+ ape_unpack_stereo(s, blockstodecode);
+ }
+
+ if (s->error || s->ptr > s->data_end) {
+ s->samples = 0;
+ *data_size = 0;
+ printf("Error decoding frame.error num 0x%x.s->ptr 0x%x bigger s->data_end %x\n", s->error, s->ptr, s->data_end);
+ return APE_DECODE_ERROR_ABORT;
+ }
+
+ for (i = 0; i < blockstodecode; i++) {
+ *samples++ = s->decoded0[i];
+ if (s->channels == 2) {
+ *samples++ = s->decoded1[i];
+ }
+ }
+
+ s->samples -= blockstodecode;
+
+ *data_size = s->samples ? s->ptr - s->last_ptr : buf_size;
+ s->last_ptr = s->ptr;
+ return APE_DECODE_ONE_FRAME_FINISH;
+}
+
+//confirmed one frame
+int audio_dec_decode(audio_decoder_operations_t *adec_ops, char *outbuf, int *outlen, char *inbuf, int inlen)
+{
+ unsigned char buffer[5];
+ unsigned current_framesize = 0;
+ char extra_data = 8;
+ unsigned int first_read = 0;
+ apeiobuf.bytesLeft = 0;
+ int nDecodedSize = 0;
+ if (apeiobuf.bytesLeft == 0) {
+ current_framesize = inlen;//sss
+ apeiobuf.readPtr = inbuf;
+ int buffersize_remain = current_framesize;
+ unsigned char * read_buf_ptr = apeiobuf.readPtr;
+ apeiobuf.bytesLeft += current_framesize;
+ apedec->public_data->current_decoding_frame++;
+ }
+
+ if (apeiobuf.bytesLeft) {
+ int err = 0;
+ if ((err = ape_decode_frame(apedec, apeiobuf.outBuf, \
+ &apeiobuf.thislop_decoded_size, \
+ apeiobuf.readPtr, apeiobuf.bytesLeft)) != APE_DECODE_ONE_FRAME_FINISH) {
+ audio_codec_print("apeiobuf.thislop_decoded_size=%d\n", apeiobuf.thislop_decoded_size);
+ if (apeiobuf.thislop_decoded_size <= 0) {
+ audio_codec_print("error id:%d happened when decoding ape frame\n", err);
+ apeiobuf.bytesLeft = 0;
+ }
+ nDecodedSize = 0;
+ } else {
+ audio_codec_print("decode_one_frame_finished\n");
+ audio_codec_print("Enter into write_buffer operation\n");
+ int size = (apedec->private_data->blocksdecoded) * (apedec->private_data->channels) * 2;
+ *outlen = size;
+ nDecodedSize = apeiobuf.thislop_decoded_size;
+ audio_codec_print("apedec->private_data->blocksdecoded=%d\n", apedec->private_data->blocksdecoded);
+ audio_codec_print("apedec->private_data->channels=%d\n", apedec->private_data->channels);
+ audio_codec_print(">>>>>>>>>>>>>>>>size = %d\n", size);
+ memcpy(outbuf, (unsigned char*)apeiobuf.outBuf, size);
+ }
+ }
+ return nDecodedSize;
+
+}
+
+#define DefaultReadSize 1024*10 //read count from kernel audio buf one time
+#define DefaultOutBufSize 1024*1024*2
+int audio_dec_init(audio_decoder_operations_t *adec_ops)
+{
+ int x = 1;
+ char *p = (char *)&x;
+ //audio_codec_print("\n\n[%s]BuildDate--%s BuildTime--%s", __FUNCTION__, __DATE__, __TIME__);
+ if (*p == 1) {
+ audio_codec_print("Little endian\n");
+ } else {
+ audio_codec_print("Big endian\n");
+ }
+
+ apedec = NULL;
+ if (!apedec) {
+ headinfo.bps = adec_ops->bps;
+ headinfo.channels = adec_ops->channels;
+ headinfo.samplerate = adec_ops->samplerate;
+ headinfo.fileversion = ((*(adec_ops->extradata + 1)) << 8) | (*(adec_ops->extradata)); // the info below 3 row are based on ape.c encodec relatively
+ headinfo.compressiontype = ((*(adec_ops->extradata + 3)) << 8) | (*(adec_ops->extradata + 2));
+ headinfo.formatflags = ((*(adec_ops->extradata + 5)) << 8) | (*(adec_ops->extradata + 4));
+ /*pass the ape header info to the decoder instance**/
+ apedec = ape_decoder_new((void*)&headinfo);
+
+ }
+ if (!apedec) {
+ audio_codec_print("%s: FATAL ERROR creating the decoder instance\n", "ape");
+ return -1;
+ }
+ if (ape_decode_init(apedec) != APE_DECODE_INIT_FINISH) {
+ audio_codec_print("%s: FATAL ERROR inititate the decoder instance\n", "ape");
+ return -1;
+ }
+ adec_ops->nInBufSize = DefaultReadSize;
+ adec_ops->nOutBufSize = DefaultOutBufSize;
+ audio_codec_print("ape_Init.\n");
+ return 0;
+}
+int audio_dec_release(audio_decoder_operations_t *adec_ops)
+{
+ return 0;
+}
+int audio_dec_getinfo(audio_decoder_operations_t *adec_ops, void *pAudioInfo)
+{
+ return 0;
+}
+
+
+
+
diff --git a/audio_codec/libcook/Android.mk b/audio_codec/libcook/Android.mk
new file mode 100644
index 0000000..350ccff
--- a/dev/null
+++ b/audio_codec/libcook/Android.mk
@@ -0,0 +1,28 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libcook
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+LOCAL_ARM_MODE := arm
+LOCAL_C_INCLUDES := $(LOCAL_PATH)
+
+ifeq ($(ARCH_ARM_HAVE_NEON),true)
+ LOCAL_CFLAGS += -D__ARM_HAVE_NEON -DOPT_NEON
+endif
+include $(BUILD_STATIC_LIBRARY)
+
+
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libcook
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+LOCAL_ARM_MODE := arm
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := $(LOCAL_PATH)
+
+LOCAL_SHARED_LIBRARIES += libutils libmedia libz libbinder libdl libcutils libc
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/audio_codec/libcook/aac_bitstream.h b/audio_codec/libcook/aac_bitstream.h
new file mode 100644
index 0000000..845093c
--- a/dev/null
+++ b/audio_codec/libcook/aac_bitstream.h
@@ -0,0 +1,133 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aac_bitstream.h,v 1.1.1.1.2.1 2005/05/04 18:21:58 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/* bitstream reader functions. No checking for end-of-bits included! */
+
+#ifndef _BITSTREAM_H_
+#define _BITSTREAM_H_
+
+#include "rm_memory.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /** The bitstream structure.
+ * The idea of the bitstream reader is to keep a cache word that has the machine's
+ * largest native size. This word keeps the next-to-read bits left-aligned so that
+ * on a read, one shift suffices.
+ * The cache word is only refilled if it does not contain enough bits to satisy a
+ * a read request. Because the refill only happens in multiple of 8 bits, the maximum
+ * read size that is guaranteed to be always fulfilled is the number of bits in a long
+ * minus 8 (or the number of bits in a byte).
+ */
+
+ struct BITSTREAM ;
+
+ /** read nBits bits from bitstream
+ * @param pBitstream the bitstream to read from
+ * @param nBits the number of bits to read. nBits must be <= 32, currently.
+ * @return the bits read, right-justified
+ */
+ unsigned int readBits(struct BITSTREAM *pBitstream, int nBits) ;
+
+ /** push bits back into the bitstream.
+ * This call is here to make look-ahead possible, where after reading the client
+ * may realize it has read too far ahead. It is guaranteed to succeed as long as
+ * you don't push more bits back than have been read in the last readBits() call.
+ * @param pBitstream the bitstream to push back into
+ * @param bits the bits to push back
+ * @param nBits the number of bits to push back.
+ * @return an error code, signalling success or failure.
+ */
+ int unreadBits(struct BITSTREAM *pBitstream, int bits, int nBits) ;
+
+ /** byte-align the bitstream read pointer. */
+ void byteAlign(struct BITSTREAM *pBitstream) ;
+
+ /** allocate memory for a new bitstream structure.
+ * @param ppBitstream a pointer to a bitstream handle, to be initialized on
+ * successfull return
+ * @param nBits the maximum number of bits this bitstream must be able to hold.
+ * nBits must be divisible by 32.
+ * @param pUserMem optional user-defined memory handle
+ * @param fpMalloc user-defined malloc() implementation
+ * @return an error code, signalling success or failure.
+ * @see reverseBitstream
+ */
+ int newBitstream(struct BITSTREAM **ppBitstream, int nBits,
+ void* pUserMem, rm_malloc_func_ptr fpMalloc) ;
+
+ /** free memory associated with a bitstream structure.
+ * @param pBitstream a bitstream handle
+ * @param pUserMem optional user-defined memory handle
+ * @param fpFree user-defined free() implementation
+ */
+ void deleteBitstream(struct BITSTREAM *pBitstream, void *pUserMem,
+ rm_free_func_ptr fpFree) ;
+
+ /** feed nbits bits to the bitstream, byte-wise.
+ * @param pBitstream the bitstream into which to feed the bytes
+ * @param input the input from which to read the bytes
+ * @param nbits the number of bits in the input. nbits must be divisible by 32
+ * for reverseBitstream() to work.
+ * @return an error code, signalling success or failure.
+ * @see reverseBitstream
+ */
+
+ int feedBitstream(struct BITSTREAM *pBitstream, const unsigned char *input, int nbits) ;
+
+ /** set bitstream position, relative to origin defined through feedBitstream().
+ * @param pBitstream the bitstream
+ * @param position the position in bits (must be multiple of 8, currently).
+ * Always measured from beginning, regardless of direction.
+ * @param direction the direction of reading (+1/-1)
+ */
+
+ int setAtBitstream(struct BITSTREAM *pBitstream, int position, int direction) ;
+
+ /** return the number of bits left until end-of-stream.
+ * @param pBitstream the bitstream
+ * @return the number of bits left
+ */
+ int bitsLeftInBitstream(struct BITSTREAM *pBitstream) ;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _BITSTREAM_H_ */
diff --git a/audio_codec/libcook/aac_decode.h b/audio_codec/libcook/aac_decode.h
new file mode 100644
index 0000000..28f77d9
--- a/dev/null
+++ b/audio_codec/libcook/aac_decode.h
@@ -0,0 +1,148 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aac_decode.h,v 1.2.2.1 2005/05/04 18:21:58 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef AAC_DECODE_H
+#define AAC_DECODE_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "ra_decode.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* aac decode struct */
+ typedef struct aac_decode_struct {
+ void* pDecoder;
+ void* pFrameInfo;
+ UINT32 ulNumChannels;
+ UINT32 ulChannelMask;
+ UINT32 ulBlockSize;
+ UINT32 ulFrameSize;
+ UINT32 ulFramesPerBlock;
+ UINT32 ulSamplesPerFrame;
+ UINT32 ulSampleRateCore;
+ UINT32 ulSampleRateOut;
+ UINT32 ulDelayRemaining;
+ UINT32 ulSamplesToConceal;
+ HXBOOL bSBR;
+ } aac_decode;
+
+ /* aac decode interface */
+
+ /*
+ * aac_decode_init
+ */
+ HX_RESULT aac_decode_init(void* pInitParams,
+ UINT32 ulInitParamsSize,
+ ra_format_info* pStreamInfo,
+ void** pDecode,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+
+ /*
+ * aac_decode_reset
+ */
+ HX_RESULT aac_decode_reset(void* pDecode,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut);
+
+ /*
+ * aac_decode_conceal
+ */
+ HX_RESULT aac_decode_conceal(void* pDecode,
+ UINT32 ulNumSamples);
+
+ /*
+ * aac_decode_decode
+ */
+ HX_RESULT aac_decode_decode(void* pDecode,
+ UINT8* pData,
+ UINT32 ulNumBytes,
+ UINT32* pNumBytesConsumed,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut,
+ UINT32 ulFlags,
+ UINT32 ulTimeStamp);
+
+ /*
+ * aac_decode_getmaxsize
+ */
+ HX_RESULT aac_decode_getmaxsize(void* pDecode,
+ UINT32* pNumSamples);
+
+ /*
+ * aac_decode_getchannels
+ */
+ HX_RESULT aac_decode_getchannels(void* pDecode,
+ UINT32* pNumChannels);
+
+ /*
+ * aac_decode_getchannelmask
+ */
+ HX_RESULT aac_decode_getchannelmask(void* pDecode,
+ UINT32* pChannelMask);
+
+ /*
+ * aac_decode_getrate
+ */
+ HX_RESULT aac_decode_getrate(void* pDecode,
+ UINT32* pSampleRate);
+
+ /*
+ * aac_decode_getdelay
+ */
+ HX_RESULT aac_decode_getdelay(void* pDecode,
+ UINT32* pNumSamples);
+
+ /*
+ * aac_decode_close
+ */
+ HX_RESULT aac_decode_close(void* pDecode,
+ void* pUserMem,
+ rm_free_func_ptr fpFree);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef AAC_DECODE_H */
diff --git a/audio_codec/libcook/aac_reorder.h b/audio_codec/libcook/aac_reorder.h
new file mode 100644
index 0000000..008beb0
--- a/dev/null
+++ b/audio_codec/libcook/aac_reorder.h
@@ -0,0 +1,53 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aac_reorder.h,v 1.1.1.1.2.1 2005/05/04 18:21:58 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef AAC_REORDER_H
+#define AAC_REORDER_H
+
+#include "helix_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ void AACReorderPCMChannels(INT16 *pcmBuf, int nSamps, int nChans);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef AAC_REORDER_H */
diff --git a/audio_codec/libcook/assembly.h b/audio_codec/libcook/assembly.h
new file mode 100644
index 0000000..aceb886
--- a/dev/null
+++ b/audio_codec/libcook/assembly.h
@@ -0,0 +1,119 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: assembly.h,v 1.13 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * assembly.h - inline assembly language functions and prototypes
+ *
+ * MULSHIFT32(x, y) signed multiply of two 32-bit integers (x and y),
+ * returns top 32-bits of 64-bit result
+ * CLIPTOSHORT(x) convert 32-bit integer to 16-bit short,
+ * clipping to [-32768, 32767]
+ * FASTABS(x) branchless absolute value of signed integer x
+ * CLZ(x) count leading zeros on signed integer x
+ **************************************************************************************/
+
+#ifndef _ASSEMBLY_H
+#define _ASSEMBLY_H
+
+#include "coder.h"
+
+/* toolchain: ARM gcc
+ * target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier)
+ */
+
+#if defined(__aarch64__)
+static __inline__ int MULSHIFT32(int x, int y)
+{
+ long c;
+ c = (long)x * y;
+ return (int)c;
+}
+#else
+static __inline__ int MULSHIFT32(int x, int y)
+{
+ int zlow;
+ __asm__ volatile("smull %0,%1,%2,%3" : "=&r"(zlow), "=r"(y) : "r"(x), "1"(y));
+ return y;
+}
+#endif
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return (sizeof(int) * 8);
+ }
+
+ numZeros = 0;
+ while (!(x & 0x80000000)) {
+ numZeros++;
+ x <<= 1;
+ }
+
+ return numZeros;
+}
+
+
+#endif /* _ASSEMBLY_H */
diff --git a/audio_codec/libcook/challenge.h b/audio_codec/libcook/challenge.h
new file mode 100644
index 0000000..3f9540f
--- a/dev/null
+++ b/audio_codec/libcook/challenge.h
@@ -0,0 +1,132 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: challenge.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef _CHALLENGE_H_
+#define _CHALLENGE_H_
+
+#include "helix_types.h"
+#include "helix_utils.h"
+#include "rm_memory.h"
+
+
+
+/*
+ * The original Challange structure and methods. Used in the
+ * Old PNA and as the first round in the new RTSP Challenge.
+ */
+struct Challenge {
+ BYTE text[33];
+ BYTE response[33];
+};
+
+struct Challenge* CreateChallenge(INT32 k1,
+ INT32 k2,
+ BYTE* k3,
+ BYTE* k4);
+
+struct Challenge* CreateChallengeFromPool(INT32 k1,
+ INT32 k2,
+ BYTE* k3,
+ BYTE* k4,
+ rm_malloc_func_ptr fpMalloc,
+ void* pMemoryPool);
+
+BYTE* ChallengeResponse1(BYTE* k1, BYTE* k2,
+ INT32 k3, INT32 k4,
+ struct Challenge* ch);
+BYTE* ChallengeResponse2(BYTE* k1, BYTE* k2,
+ INT32 k3, INT32 k4,
+ struct Challenge* ch);
+
+
+
+/*
+ * The new RTSP Challenge structure and methods
+ */
+struct RealChallenge {
+ BYTE challenge[33];
+ BYTE response[41];
+ BYTE trap[9];
+};
+
+
+struct RealChallenge* CreateRealChallenge();
+struct RealChallenge* CreateRealChallengeFromPool(rm_malloc_func_ptr fpMalloc,
+ void* pMemoryPool);
+BYTE* RealChallengeResponse1(BYTE* k1, BYTE* k2,
+ INT32 k3, INT32 k4,
+ struct RealChallenge* rch);
+BYTE* RealChallengeResponse2(BYTE* k1, BYTE* k2,
+ INT32 k3, INT32 k4,
+ struct RealChallenge* rch);
+
+
+void CalcCompanyIDKey(const char* companyID,
+ const char* starttime,
+ const char* guid,
+ const char* challenge,
+ const char* copyright,
+ UCHAR* outputKey);
+
+INT32 BinTo64(const BYTE* pInBuf, INT32 len, char* pOutBuf);
+
+
+/* Support constants and values */
+extern const INT32 G2_BETA_EXPIRATION;
+
+extern const INT32 RC_MAGIC1;
+extern const INT32 RC_MAGIC2;
+extern const INT32 RC_MAGIC3;
+extern const INT32 RC_MAGIC4;
+
+extern const unsigned char pRCMagic1[];
+extern const unsigned char pRCMagic2[];
+
+
+// This UUID was added in the 5.0 player to allow us to identify
+// players from Progressive Networks. Other companies licensing this
+// code must be assigned a different UUID.
+#define HX_COMPANY_ID "92c4d14a-fa51-4bcb-8a67-7ac286f0ff7e"
+#define HX_COMPANY_ID_KEY_SIZE 16
+
+
+extern const unsigned char HX_MAGIC_TXT_1[];
+extern const char pMagic2[];
+
+
+
+#endif /*_CHALLENGE_H_*/
diff --git a/audio_codec/libcook/codec_defines.h b/audio_codec/libcook/codec_defines.h
new file mode 100644
index 0000000..c143a75
--- a/dev/null
+++ b/audio_codec/libcook/codec_defines.h
@@ -0,0 +1,93 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: codec_defines.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef CODEC_DEFINES_H
+#define CODEC_DEFINES_H
+
+/* Audio codec defines */
+#define RA_FORMAT_ID 0x2E7261FD /* RealAudio Stream */
+#define RA_NO_INTERLEAVER 0x496E7430 /* 'Int0' (no interleaver) */
+#define RA_INTERLEAVER_SIPR 0x73697072 /* interleaver used for SIPRO codec ("sipr") */
+#define RA_INTERLEAVER_GENR 0x67656E72 /* interleaver used for ra8lbr and ra8hbr codecs ("genr") */
+#define RA_INTERLEAVER_VBRS 0x76627273 /* Simple VBR interleaver ("vbrs") */
+#define RA_INTERLEAVER_VBRF 0x76627266 /* Simple VBR interleaver (with possibly fragmenting) ("vbrf") */
+
+/* Video codec defines */
+#define HX_MEDIA_AUDIO 0x4155444FL /* 'AUDO' */
+#define HX_MEDIA_VIDEO 0x5649444FL /* 'VIDO' */
+
+#define HX_RVTRVIDEO_ID 0x52565452 /* 'RVTR' (for rv20 codec) */
+#define HX_RVTR_RV30_ID 0x52565432 /* 'RVT2' (for rv30 codec) */
+#define HX_RV20VIDEO_ID 0x52563230 /* 'RV20' */
+#define HX_RV30VIDEO_ID 0x52563330 /* 'RV30' */
+#define HX_RV40VIDEO_ID 0x52563430 /* 'RV40' */
+#define HX_RVG2VIDEO_ID 0x52564732 /* 'RVG2' (raw TCK format) */
+#define HX_RV89COMBO_ID 0x54524F4D /* 'TROM' (raw TCK format) */
+
+#define RV20_MAJOR_BITSTREAM_VERSION 2
+
+#define RV30_MAJOR_BITSTREAM_VERSION 3
+#define RV30_BITSTREAM_VERSION 2
+#define RV30_PRODUCT_RELEASE 0
+#define RV30_FRONTEND_VERSION 2
+
+#define RV40_MAJOR_BITSTREAM_VERSION 4
+#define RV40_BITSTREAM_VERSION 0
+#define RV40_PRODUCT_RELEASE 2
+#define RV40_FRONTEND_VERSION 0
+
+#define RAW_BITSTREAM_MINOR_VERSION 128
+
+#define RAW_RVG2_MAJOR_VERSION 2
+#define RAW_RVG2_BITSTREAM_VERSION RAW_BITSTREAM_MINOR_VERSION
+#define RAW_RVG2_PRODUCT_RELEASE 0
+#define RAW_RVG2_FRONTEND_VERSION 0
+
+#define RAW_RV8_MAJOR_VERSION 3
+#define RAW_RV8_BITSTREAM_VERSION RAW_BITSTREAM_MINOR_VERSION
+#define RAW_RV8_PRODUCT_RELEASE 0
+#define RAW_RV8_FRONTEND_VERSION 0
+
+#define RAW_RV9_MAJOR_VERSION 4
+#define RAW_RV9_BITSTREAM_VERSION RAW_BITSTREAM_MINOR_VERSION
+#define RAW_RV9_PRODUCT_RELEASE 0
+#define RAW_RV9_FRONTEND_VERSION 0
+
+#define WIDTHBYTES(i) ((unsigned long)((i+31)&(~31))/8) /* ULONG aligned ! */
+#define T_YUV420 10
+
+#endif /* #ifndef CODEC_DEFINES_H */
diff --git a/audio_codec/libcook/coder.h b/audio_codec/libcook/coder.h
new file mode 100644
index 0000000..5d6ae27
--- a/dev/null
+++ b/audio_codec/libcook/coder.h
@@ -0,0 +1,287 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: coder.h,v 1.9 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * coder.h - private, implementation-specific header file
+ **************************************************************************************/
+
+#ifndef _CODER_H
+#define _CODER_H
+
+#include "gecko2codec.h" /* contains public API */
+#include "statname.h" /* do name-mangling for static linking */
+
+#if defined _WIN32 && defined _DEBUG && defined FORTIFY
+#include "fortify.h"
+#endif
+
+#define CODINGDELAY 2 /* frames of coding delay */
+
+#ifndef ASSERT
+#if defined (_WIN32) && defined (_M_IX86) && (defined (_DEBUG) || defined (REL_ENABLE_ASSERTS))
+#define ASSERT(x) if (!(x)) __asm int 3;
+#else
+#define ASSERT(x) /* do nothing */
+#endif
+#endif
+
+#ifndef MAX
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+#ifndef MIN
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+/* do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) */
+#define CLIP_2N_SHIFT(y, n) { \
+ int sign = (y) >> 31; \
+ if (sign != (y) >> (30 - (n))) { \
+ (y) = sign ^ (0x3fffffff); \
+ } else { \
+ (y) = (y) << (n); \
+ } \
+}
+
+#define FBITS_OUT_DQ 12 /* number of fraction bits in output of dequant */
+#define FBITS_LOST_IMLT 7 /* number of fraction bits lost (>> out) in IMLT */
+#define GBITS_IN_IMLT 4 /* min guard bits in for IMLT */
+
+/* coder */
+#define NBINS 20 /* transform bins per region */
+#define MAXCATZNS (1 << 7)
+#define NCPLBANDS 20
+
+#define MAXNCHAN 2
+#define MAXNSAMP 1024
+#define MAXREGNS (MAXNSAMP/NBINS)
+
+#define MAXDECBUF 4
+
+/* composite mlt */
+#define MAXCSAMP (2*MAXNSAMP)
+#define MAXCREGN (2*MAXREGNS)
+#define NUM_MLT_SIZES 3
+#define MAXNMLT 1024
+#define MAXCPLQBITS 6
+
+/* gain control */
+#define NPARTS 8 /* parts per half-window */
+#define MAXNATS 8
+#define LOCBITS 3 /* must be log2(NPARTS)! */
+#define GAINBITS 4 /* must match clamping limits! */
+#define GAINMAX 4
+#define GAINMIN (-7) /* clamps to GAINMIN<=gain<=GAINMAX */
+#define GAINDIF (GAINMAX - GAINMIN)
+#define CODE2GAIN(g) ((g) + GAINMIN)
+
+#define NUM_POWTABLES 13 /* number of distinct tables for power envelope coding */
+#define MAX_HUFF_BITS 16 /* max bits in any Huffman codeword (important - make sure this is true!) */
+
+/*
+ * Random bit generator, using a 32-bit linear feedback shift register.
+ * Primitive polynomial is x^32 + x^7 + x^5 + x^3 + x^2 + x^1 + x^0.
+ * lfsr = state variable
+ *
+ * Update step:
+ * sign = (lfsr >> 31);
+ * lfsr = (lfsr << 1) ^ (sign & FEEDBACK);
+ */
+#define FEEDBACK ((1<<7)|(1<<5)|(1<<3)|(1<<2)|(1<<1)|(1<<0))
+
+typedef struct _HuffInfo {
+ int maxBits;
+ unsigned char count[16]; /* number of codes at this length */
+ int offset;
+} HuffInfo;
+
+/* bitstream info */
+typedef struct _BitStreamInfo {
+ unsigned char *buf;
+ int off;
+ int key;
+} BitStreamInfo;
+
+/* gain control info */
+typedef struct _GAINC {
+ short nats; /* number of attacks, [0..8]*/
+ short loc[MAXNATS]; /* location of attack, [0..7] */
+ short gain[MAXNATS]; /* gain code, [-7..8] */
+ short maxExGain; /* max gain after expansion */
+} GAINC;
+
+/* buffers for decoding and reconstructing transform coefficients */
+typedef struct _DecBufs {
+ int decmlt[MAXNCHAN][MAXNSAMP];
+ int overlap[MAXNCHAN][MAXNSAMP];
+
+ /* Categorize() */
+ int maxcat[MAXCREGN];
+ int mincat[MAXCREGN];
+ int changes[2 * MAXCATZNS]; /* grows from middle outward */
+ int maxheap[MAXCREGN + 1]; /* upheap sentinel */
+ int minheap[MAXCREGN + 1]; /* upheap sentinel */
+
+ /* DecodeMLT() */
+ int rmsIndex[MAXCREGN]; /* RMS power quant index */
+ int catbuf[MAXCREGN];
+
+ /* JointDecodeMLT() */
+ int cplindex[NCPLBANDS];
+} DecBufs;
+
+typedef struct _ {
+ short adts_hi;
+ short adts_lo;
+ short lostflag;
+ short jointflag;
+ short nChannels;
+ short nSamples;
+ short sampRate;
+ short xformIdx;
+ short gbMin[MAXNCHAN]; //2
+ short xbits[MAXNCHAN][2]; //4
+ GAINC dgainc[MAXNCHAN][CODINGDELAY]; //18*2*2=72
+ short exgain[2 * NPARTS + 1];
+ int decmlt[MAXNCHAN][MAXNSAMP];
+ int (*overlap)[MAXNCHAN][MAXNSAMP];
+} DecodeInfo;
+
+typedef struct _Gecko2Info {
+ /* general codec params */
+ int nRegions;
+ int nFrameBits;
+ int sampRate;
+ int cplStart;
+ int cplQbits;
+ int rateBits;
+ int cRegions;
+ int nCatzns;
+ int jointStereo;
+
+ /* dither for dequant */
+ int lfsr[MAXNCHAN];
+
+ /* transform info */
+ int rateCode;
+ int rmsMax[MAXNCHAN];
+
+ /* bitstream info */
+ BitStreamInfo bsi;
+
+ short lostflag;
+ short nChannels;
+ short nSamples;
+ short xformIdx;
+ short gbMin[MAXNCHAN];
+ short xbits[MAXNCHAN][2];
+
+ /* gain control info */
+ GAINC dgainc[MAXNCHAN][CODINGDELAY];
+
+ /* data buffers */
+ DecBufs db;
+
+ /* decode info management */
+ int rd;
+ int wr;
+ DecodeInfo block[4];
+} Gecko2Info;
+
+/* memory allocation */
+Gecko2Info *AllocateBuffers(void);
+void FreeBuffers(Gecko2Info *gi);
+
+/* bitstream decoding */
+int DecodeSideInfo(Gecko2Info *gi, unsigned char *buf, int availbits, int ch);
+unsigned int GetBits(BitStreamInfo *bsi, int nBits, int advanceFlag);
+void AdvanceBitstream(BitStreamInfo *bsi, int nBits);
+
+/* huffman decoding */
+int DecodeHuffmanScalar(const unsigned short *huffTab, const HuffInfo *huffTabInfo, int bitBuf, int *val);
+
+/* gain control parameter decoding */
+int DecodeGainInfo(Gecko2Info *gi, GAINC *gainc, int availbits);
+void CopyGainInfo(GAINC *gaincDest, GAINC *gaincSource);
+
+/* joint stereo parameter decoding */
+void JointDecodeMLT(Gecko2Info *gi, int *mltleft, int *mltrght);
+int DecodeCoupleInfo(Gecko2Info *gi, int availbits);
+
+/* transform coefficient decoding */
+int DecodeEnvelope(Gecko2Info *gi, int availbits, int ch);
+void CategorizeAndExpand(Gecko2Info *gi, int availbits);
+int DecodeTransform(Gecko2Info *gi, int *mlt, int availbits, int *lfsrInit, int ch);
+
+/* inverse transform */
+void IMLTNoWindow(int tabidx, int *mlt, int gb);
+void R4FFT(int tabidx, int *x);
+
+/* synthesis window, gain control, overlap-add */
+void DecWindowWithAttacks(int tabidx, int *buf1, int *overlap, short *pcm1, int nChans, GAINC *gainc0, GAINC *gainc1, short fbits[2]);
+void DecWindowNoAttacks(int tabidx, int *buf1, int *overlap, short *pcm1, int nChans);
+
+/* bitpack.c */
+extern const unsigned char pkkey[4];
+
+/* hufftabs.c */
+#define HUFFTAB_COUPLE_OFFSET 2
+
+extern const HuffInfo huffTabCoupleInfo[5];
+extern const unsigned short huffTabCouple[119];
+extern const HuffInfo huffTabPowerInfo[13];
+extern const unsigned short huffTabPower[312];
+extern const HuffInfo huffTabVectorInfo[7];
+extern const unsigned short huffTabVector[1276];
+
+/* trigtabs.c */
+extern const int nmltTab[3];
+extern const int window[256 + 512 + 1024];
+extern const int windowOffset[3];
+extern const int cos4sin4tab[256 + 512 + 1024];
+extern const int cos4sin4tabOffset[3];
+extern const int cos1sin1tab[514];
+extern const unsigned char bitrevtab[33 + 65 + 129];
+extern const int bitrevtabOffset[3];
+extern const int twidTabEven[4 * 6 + 16 * 6 + 64 * 6];
+extern const int twidTabOdd[8 * 6 + 32 * 6 + 128 * 6];
+
+#endif /* _CODER_H */
diff --git a/audio_codec/libcook/cook_codec.h b/audio_codec/libcook/cook_codec.h
new file mode 100644
index 0000000..fc59bd6
--- a/dev/null
+++ b/audio_codec/libcook/cook_codec.h
@@ -0,0 +1,30 @@
+#ifndef COOK_CODEC_HEADERS
+#define COOK_CODEC_HEADERS
+
+
+#define SUB_FMT_VALID (1<<1)
+#define CHANNEL_VALID (1<<2)
+#define SAMPLE_RATE_VALID (1<<3)
+#define DATA_WIDTH_VALID (1<<4)
+
+#define AUDIO_EXTRA_DATA_SIZE (2048*2)
+
+struct audio_info {
+ int valid;
+ int sample_rate;
+ int channels;
+ int bitrate;
+ int codec_id;
+ int block_align;
+ int extradata_size;
+ char extradata[AUDIO_EXTRA_DATA_SIZE];
+};
+#if 0
+typedef enum {
+ DECODE_INIT_ERR,
+ DECODE_FATAL_ERR,
+} err_code_t;
+#endif
+
+#endif
+
diff --git a/audio_codec/libcook/cook_decode.c b/audio_codec/libcook/cook_decode.c
new file mode 100644
index 0000000..49d18ae
--- a/dev/null
+++ b/audio_codec/libcook/cook_decode.c
@@ -0,0 +1,624 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+//#include <cutils/properties.h>
+
+#include "cook_codec.h"
+//#include <asm/cache.h>
+
+#ifndef __MW__
+#include <inttypes.h>
+#else
+#include <core/types.h>
+#endif
+#include "cook_decode.h"
+#include "rm_parse.h"
+#include "ra_depack.h"
+#include "ra_decode.h"
+
+
+
+/********arm decoder header file **********/
+
+#include "../../amadec/adec-armdec-mgt.h"
+
+#include <android/log.h>
+
+#define LOG_TAG "CookDecoder"
+#define libcook_print(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+#define DefaultReadSize 32*1024
+#define DefaultOutBufSize 370*1024
+
+
+typedef struct {
+ rm_parser* pParser;
+ ra_depack* pDepack;
+ ra_decode* pDecode;
+ ra_format_info* pRaInfo;
+ rm_packet* pPacket;
+ ra_block* pBlock;
+ rm_stream_header* pHdr;
+ UINT32 usStreamNum;
+} rm_info_t;
+
+typedef struct {
+ BYTE *buf;
+ int buf_len;
+ int buf_max;
+ int cousume;
+ int all_consume;
+} cook_IObuf;
+
+struct frame_info {
+ int len;
+ unsigned long offset;/*steam start to here*/
+ unsigned long buffered_len;/*data buffer in dsp,pcm datalen*/
+ int reversed[1];/*for cache aligned 32 bytes*/
+};
+
+static cook_IObuf cook_input;
+static cook_IObuf cook_output;
+
+struct frame_info cur_frame;
+static ra_decoder_info_t ra_dec_info ;
+static rm_info_t ra_info ;
+static char file_header[AUDIO_EXTRA_DATA_SIZE];
+#pragma align_to(64,file_header)
+static char *cur_read_ptr = file_header;
+static int reset = 0;
+static void setsysfs(char * path, char * value)
+{
+ int fd = -1;
+ fd = open(path, O_RDWR);
+ if (fd >= 0) {
+ write(fd, value, 2);
+ close(fd);
+ fd = -1;
+ } else {
+ libcook_print("setsysfs: open file failed.\n");
+ }
+}
+
+static void rm_error(void* pError, HX_RESULT result, const char* pszMsg)
+{
+ //dsp_mailbox_send(1,M1B_IRQ7_DECODE_FATAL_ERR, 1, NULL, 0);
+ //trans_err_code(DECODE_FATAL_ERR);
+ //property_set("media.amplayer.noaudio", "1");
+ setsysfs("/sys/class/audiodsp/codec_fatal_err", "2"); //Fatal error
+ libcook_print("rm_error pError=0x%08x result=0x%08x msg=%s\n", pError, result, pszMsg);
+ //while(1);
+}
+
+//static int cook_decode_frame(unsigned char *buf, int maxlen, struct frame_fmt *fmt)
+int audio_dec_decode(audio_decoder_operations_t *adec_ops, char *outbuf, int *outlen, char *inbuf, int inlen)
+{
+ //libcook_print("audio_dec_decode, inlen = %d, cook_input.buf_len = %d\n", inlen, cook_input.buf_len);
+ HX_RESULT retVal = HXR_OK;
+ UINT32 ulBytesConsumed = 0;
+ UINT32 ulTotalConsumed = 0;
+ UINT32 ulBytesLeft = 0;
+ UINT32 ulNumSamplesOut = 0;
+ UINT32 ulMaxSamples = 0;
+ UINT32 out_data_len = 0;
+
+ //ra_dec_info.input_buf = buf;
+ //ra_dec_info.input_buffer_size = maxlen;
+ if (inlen > 0) {
+ int len = inlen - cook_input.buf_len;
+ int read_len;
+ read_len = (inlen > cook_input.buf_max) ? cook_input.buf_max : inlen;
+ if (len > 0) {
+ memcpy(cook_input.buf + cook_input.buf_len,
+ inbuf + cook_input.buf_len, read_len - cook_input.buf_len);
+ cook_input.buf_len += read_len - cook_input.buf_len;
+ }
+ }
+ //libcook_print("audio_dec_decoder cook_input.buf_len = %d\n", cook_input.buf_len);
+ while (cook_output.buf_len <= 0) {
+ retVal = rm_parser_get_packet(ra_info.pParser, &ra_info.pPacket);
+ if (retVal == HXR_OK) {
+ //if (ra_info.pPacket->usStream == ra_info.usStreamNum)
+ {
+ retVal = ra_depack_add_packet(ra_info.pDepack, ra_info.pPacket);
+
+ }
+ rm_parser_destroy_packet(ra_info.pParser, &ra_info.pPacket);
+ }
+ if (retVal != HXR_OK) {
+ libcook_print("cook_decode_frame£º add packet failed\n");
+ break;
+ }
+ if (cook_input.buf_len <= 2048) {
+ break;
+ }
+ }
+
+ *outlen = 0;
+ if (cook_output.buf_len > 0) {
+ memcpy(outbuf, cook_output.buf, cook_output.buf_len);
+ (*outlen) = cook_output.buf_len;
+ cook_output.buf_len = 0;
+ }
+
+ int ret = 0;
+ //ret = ra_dec_info.decoded_size + cook_input.cousume;
+ ret = cook_input.cousume;
+ //libcook_print("ret decoder = %d\n", ret);
+ cook_input.cousume = 0;
+ adec_ops->pts = cur_frame.offset;
+ cur_frame.offset = 0;
+ return ret;
+}
+static UINT32 rm_io_read(void* pUserRead, BYTE* pBuf, UINT32 ulBytesToRead)
+{
+ //memcpy(pBuf,cur_read_ptr,ulBytesToRead);
+ cur_read_ptr = cur_read_ptr + ulBytesToRead;
+ if ((unsigned)(cur_read_ptr - file_header) > AUDIO_EXTRA_DATA_SIZE) {
+ //trans_err_code(DECODE_INIT_ERR);
+ //property_set("media.amplayer.noaudio", "1");
+ setsysfs("/sys/class/audiodsp/codec_fatal_err", "2"); //init err
+ libcook_print("warning :: cook.read byte exceed the the buffer then sent,%d \n", (unsigned)(cur_read_ptr - file_header));
+ //while(1);
+ cur_read_ptr -= ulBytesToRead;
+ return 0;
+
+ }
+ cur_read_ptr -= ulBytesToRead;
+ memcpy(pBuf, cur_read_ptr, ulBytesToRead);
+ cur_read_ptr = cur_read_ptr + ulBytesToRead;
+ return ulBytesToRead;
+
+}
+static void rm_io_seek(void* pUserRead, UINT32 ulOffset, UINT32 ulOrigin)
+{
+ char * tptr = cur_read_ptr;
+ if (ulOrigin == HX_SEEK_ORIGIN_CUR) {
+ cur_read_ptr += ulOffset;
+ } else if (ulOrigin == HX_SEEK_ORIGIN_SET) {
+ cur_read_ptr = (char *)pUserRead + ulOffset;
+ } else if (ulOrigin == HX_SEEK_ORIGIN_END) {
+ cur_read_ptr = sizeof(file_header) + (char *)pUserRead - ulOffset;
+ }
+ if ((unsigned)(cur_read_ptr - file_header) > AUDIO_EXTRA_DATA_SIZE) {
+ //trans_err_code(DECODE_INIT_ERR);
+ //property_set("media.amplayer.noaudio", "1");
+ setsysfs("/sys/class/audiodsp/codec_fatal_err", "2"); //init err
+ libcook_print("warning :: cook.seek buffer pos exceed the the buffer then sent,%d \n", (unsigned)(cur_read_ptr - file_header));
+ cur_read_ptr = tptr;
+ //while(1);
+ }
+
+}
+static unsigned rm_ab_read(void* pUserRead, BYTE* pBuf, UINT32 ulBytesToRead)
+{
+ int ret = 0;
+ //libcook_print("rm_ab_read, ulBytesToRead = %d\n", ulBytesToRead);
+ if (pBuf && ulBytesToRead) {
+ //libcook_print("enter into copy data, buf_len = %d\n",cook_input.buf_len);
+ if (cook_input.buf_len >= ulBytesToRead) { //ret = read_buffer(pBuf,ulBytesToRead);
+ memcpy(pBuf, cook_input.buf, ulBytesToRead);
+ ret = ulBytesToRead;
+ cook_input.buf_len -= ret;
+ //libcook_print("inpoint2 = %d, cook_input.buf_len = %d\n", cook_input.buf, cook_input.buf_len);
+ memcpy(cook_input.buf, cook_input.buf + ret, cook_input.buf_len);
+ } else {
+ libcook_print("rm_ab_read data is not enough \n");
+ }
+ }
+ cook_input.cousume += ret;
+ cook_input.all_consume += ret;
+ return ret;
+}
+static void rm_ab_seek(void* pUserRead, UINT32 ulOffset, UINT32 ulOrigin)
+{
+ //libcook_print("rm_ab_seek, buf_len = %d\n",cook_input.buf_len);
+ int i;
+ if (ulOrigin == HX_SEEK_ORIGIN_CUR) {
+ if (ulOffset <= cook_input.buf_len) {
+ //memcpy(cook_input.buf, cook_input.buf + ulOffset, cook_input.buf_len - ulOffset);
+ cook_input.buf_len -= ulOffset;
+ cook_input.cousume += ulOffset;
+ int i;
+ BYTE * tmpbuf;
+ tmpbuf = cook_input.buf + ulOffset;
+ for (i = 0; i < cook_input.buf_len; i++) {
+ cook_input.buf[i] = tmpbuf[i];
+ }
+ } else {
+ libcook_print("rm_ab_seek failed\n");
+ }
+#if 0
+ for (i = 0; i < ulOffset; i++) {
+ ; //read_byte();
+ }
+#endif
+ } else if (/*ulOrigin == HX_SEEK_ORIGIN_SET*/0) {
+ int offbuf = ulOffset - cook_input.all_consume;
+ if (offbuf > 0) {
+ if (cook_input.buf_len > offbuf) {
+ memcpy(cook_input.buf, cook_input.buf + offbuf,
+ cook_input.buf_len - offbuf);
+ cook_input.buf_len -= offbuf;
+ cook_input.cousume += offbuf;
+ cook_input.all_consume += offbuf;
+ } else {
+ libcook_print("data is not enough\n");
+ }
+ }
+ }
+}
+static HX_RESULT _ra_block_available(void* pAvail, UINT32 ulSubStream, ra_block* pBlock)
+{
+ //libcook_print("[%s,%d] enter into _ra_block_available\n", __FUNCTION__,__LINE__);
+ int len = 0, wlen;
+ int offset = 0;
+ HX_RESULT retVal = HXR_OK;
+ UINT32 ulBytesConsumed = 0;
+ UINT32 ulTotalConsumed = 0;
+ UINT32 ulBytesLeft = 0;
+ UINT32 ulNumSamplesOut = 0;
+ UINT32 ulMaxSamples = 0;
+ UINT32 out_data_len = 0;
+ UINT32 delay_pts = 0;
+ //BYTE* buf = ra_dec_info.input_buf;//passed from the audio dec thread
+ rm_info_t* pInfo = (rm_info_t*) pAvail;
+ if (pAvail && pBlock && pBlock->pData && pBlock->ulDataLen) {
+ ulBytesLeft = pBlock->ulDataLen;
+ if (retVal == HXR_OK && ulBytesLeft) {
+ retVal = ra_decode_decode(ra_dec_info.pDecode,
+ pBlock->pData + ulTotalConsumed,
+ pBlock->ulDataLen - ulTotalConsumed,
+ &ulBytesConsumed,
+ (UINT16*)ra_dec_info.pOutBuf,
+ ra_dec_info.ulOutBufSize / 2,
+ &ulNumSamplesOut,
+ pBlock->ulDataFlags,
+ pBlock->ulTimestamp * 90 + 1);
+
+ if (retVal == HXR_OK) {
+ if (ulBytesConsumed) {
+ ulBytesLeft -= ulBytesConsumed;
+ ulTotalConsumed += ulBytesConsumed;
+ }
+ if (ulNumSamplesOut) {
+ len += ulNumSamplesOut * 2;
+ }
+ } else if (retVal == HXR_NO_DATA) {
+ libcook_print("ra decode not enough data.\n");
+ return 0;
+ } else {
+ libcook_print("ra decode error.\n");
+ return 0;
+ }
+ }
+ //ra_dec_info.decoded_size = out_data_len;
+ ra_dec_info.decoded_size = ulBytesConsumed;
+ }
+#if 0
+ FILE * fp1 = fopen("/data/audio_out", "a+");
+ if (fp1) {
+ int flen = fwrite((char *)ra_dec_info.pOutBuf, 1, len, fp1);
+ libcook_print("flen = %d---outlen=%d ", flen, len);
+ fclose(fp1);
+ } else {
+ libcook_print("could not open file:audio_out");
+ }
+#endif
+ cur_frame.offset = pBlock->ulTimestamp * 90 + 1;
+ cur_frame.buffered_len = 0;
+ cur_frame.len = 0;
+ delay_pts = (ulNumSamplesOut / ra_info.pRaInfo->usNumChannels) * 90 / (ra_info.pRaInfo->ulSampleRate / 1000);
+ cur_frame.offset += delay_pts;
+ //refresh_swap_register1(cur_frame.offset+delay_pts, len);
+ //dsp_mailbox_send(1,M1B_IRQ4_DECODE_FINISH_FRAME,wlen,&cur_frame,sizeof(cur_frame));
+date_trans:
+ //wlen = write_buffer(ra_dec_info.pOutBuf + offset, len);
+ memcpy(cook_output.buf + cook_output.buf_len, ra_dec_info.pOutBuf, len);
+ cook_output.buf_len += len;
+ len = 0;
+#if 0
+ wlen = memcpy(cook_output.buf + cook_output.buf_len, ra_dec_info.pOutBuf + offset, len);
+ if (wlen > 0) {
+ offset += wlen;
+ cook_output.buf_len += wlen;
+ len -= wlen;
+ }
+ if (len > 0) {
+ goto date_trans;
+ }
+#endif
+ //dsp_mailbox_send(1,M1B_IRQ4_DECODE_FINISH_FRAME,wlen,&cur_frame,sizeof(cur_frame));
+ return retVal;
+}
+//static int cook_decode_init(struct frame_fmt * fmt)
+int audio_dec_init(audio_decoder_operations_t *adec_ops)
+{
+ HX_RESULT retVal = HXR_OK;
+ unsigned ulNumStreams = 0;
+ rm_parser* pParser = HXNULL;
+ rm_stream_header *pHdr = HXNULL;
+ ra_depack *pRADpack = HXNULL;
+ ra_format_info *pRAInfo = HXNULL;
+ unsigned ulCodec4CC = 0;
+ int i;
+ struct audio_info real_data;
+ //libcook_print("\n\n[%s]BuildDate--%s BuildTime--%s", __FUNCTION__, __DATE__, __TIME__);
+ real_data.bitrate = adec_ops->bps;
+ real_data.channels = adec_ops->channels;
+ real_data.extradata_size = adec_ops->extradata_size;
+ real_data.sample_rate = adec_ops->samplerate;
+
+ adec_ops->nInBufSize = DefaultReadSize;
+ adec_ops->nOutBufSize = DefaultOutBufSize;
+
+ memset(real_data.extradata, 0, AUDIO_EXTRA_DATA_SIZE);
+ libcook_print("%d,%d\n", real_data.extradata_size, adec_ops->extradata_size);
+ for (i = 0; i < real_data.extradata_size; i++) {
+ real_data.extradata[i] = adec_ops->extradata[i];
+ }
+
+
+ libcook_print("cook audioinfo four data [0x%x], [0x%x],[0x%x],[0x%x],[0x%x],[0x%x],[0x%x],[0x%x],\n", real_data.extradata[0], \
+ real_data.extradata[1], real_data.extradata[2], real_data.extradata[3], \
+ real_data.extradata[4], real_data.extradata[5], real_data.extradata[6], real_data.extradata[7]);
+
+ memcpy(file_header, real_data.extradata, AUDIO_EXTRA_DATA_SIZE);
+ cur_frame.offset = 0;
+ if (cook_input.buf == NULL) {
+ cook_input.buf = (BYTE *)malloc(DefaultReadSize * sizeof(BYTE));
+ if (cook_input.buf != NULL) {
+ memset(cook_input.buf, 0, DefaultReadSize);
+ cook_input.buf_len = 0;
+ cook_input.buf_max = DefaultReadSize;
+ cook_input.cousume = 0;
+ cook_input.all_consume = 0;
+ } else {
+ libcook_print("inbuf malloc failed\n");
+ return -1;
+ }
+ }
+ if (cook_output.buf == NULL) {
+ cook_output.buf = (BYTE *)malloc(DefaultOutBufSize * sizeof(BYTE));
+ if (cook_output.buf != NULL) {
+ memset(cook_output.buf, 0, DefaultOutBufSize);
+ cook_output.buf_len = 0;
+ cook_output.buf_max = DefaultOutBufSize;
+ cook_output.cousume = 0;
+ } else {
+ libcook_print("outbuf malloc failed\n");
+ return -1;
+ }
+ }
+
+ if (cook_input.buf == NULL || cook_output.buf == NULL) {
+ libcook_print("malloc buf failed\n");
+ return -1;
+
+ }
+ /**********wait for implement*******/
+ //dsp_cache_wback((unsigned)file_header,AUDIO_EXTRA_DATA_SIZE);
+
+
+ /*clear up the decoder structure */
+
+ memset(&ra_dec_info, 0, sizeof(ra_decoder_info_t));
+ memset(&ra_info, 0, sizeof(rm_info_t));
+ cur_read_ptr = file_header;
+
+ /* Create the parser struct */
+ pParser = rm_parser_create(NULL, rm_error);
+ if (!pParser) {
+ libcook_print("[cook decode],create parser failed\n");
+ return -1;
+ }
+ /* Set the stream into the parser */
+#if 0
+ for (i = 0; i < AUDIO_EXTRA_DATA_SIZE / 8; i++) {
+ printk("%d header data [0x%x],[0x%x],[0x%x],[0x%x],[0x%x],[0x%x],[0x%x],[0x%x]\n\t", i, \
+ file_header[i * 8 + 0], file_header[i * 8 + 1], file_header[i * 8 + 2], file_header[i * 8 + 3], \
+ file_header[i * 8 + 4], file_header[i * 8 + 5], file_header[i * 8 + 6], file_header[i * 8 + 7]);
+ }
+#endif
+ retVal = rm_parser_init_io(pParser, file_header, rm_io_read, rm_io_seek);
+ if (retVal != HXR_OK) {
+ libcook_print("[cook decode], parser init IO failed\n");
+ rm_parser_destroy(&pParser);
+ return -1;
+ }
+ /* Read all the headers at the beginning of the .rm file */
+ retVal = rm_parser_read_headers(pParser);
+ if (retVal != HXR_OK) {
+ libcook_print("[cook decode], parser read header failed\n");
+ rm_parser_destroy(&pParser);
+ return -1;
+ }
+ libcook_print(" rm_parser_read_headers finished \n");
+
+ /* Get the number of streams */
+ ulNumStreams = rm_parser_get_num_streams(pParser);
+ if (ulNumStreams == 0) {
+ libcook_print("[cook decode], no stream found\n");
+ rm_parser_destroy(&pParser);
+ return -1;
+ }
+ for (i = 0; i < ulNumStreams && retVal == HXR_OK; i++) {
+ retVal = rm_parser_get_stream_header(pParser, i, &pHdr);
+ if (retVal == HXR_OK) {
+ if (rm_stream_is_realaudio(pHdr)) {
+ /* Create the RealAudio depacketizer */
+ pRADpack = ra_depack_create((void*)pParser, _ra_block_available, NULL, rm_error);
+ if (!pRADpack) {
+ libcook_print("[cook decode], create depack failed\n");
+ rm_parser_destroy_stream_header(pParser, &pHdr);
+ rm_parser_destroy(&pParser);
+ return -1;
+ }
+ /* Initialize the RA depacketizer with the stream header */
+ retVal = ra_depack_init(pRADpack, pHdr);
+ if (retVal != HXR_OK) {
+ libcook_print("[cook decode],init depack failed\n");
+ ra_depack_destroy(&pRADpack);
+ rm_parser_destroy_stream_header(pParser, &pHdr);
+ rm_parser_destroy(&pParser);
+ return -1;
+ }
+ /*
+ * Get the codec 4CC of substream 0. We
+ * arbitrarily choose substream 0 here.
+ */
+ ulCodec4CC = ra_depack_get_codec_4cc(pRADpack, 0);
+ if (ulCodec4CC == 0x636F6F6B) { /* cook */
+ retVal = ra_depack_get_codec_init_info(pRADpack, 0, &pRAInfo);
+ ra_info.pRaInfo = pRAInfo;
+
+ } else if ((ulCodec4CC == 0x72616163) || (ulCodec4CC == 0x72616370))
+ /* raac racp */
+ {
+ retVal = ra_depack_get_codec_init_info(pRADpack, 0, &pRAInfo);
+ ra_info.pRaInfo = pRAInfo;
+ }
+ ra_info.pDepack = pRADpack;
+
+ }
+ rm_parser_destroy_stream_header(pParser, &pHdr);
+ }
+ libcook_print("cook rm_parser_get_stream_header finished\n");
+
+ }
+ /* Set the stream into the parser */
+ //retVal = rm_parser_init_io(pParser, 0, rm_ab_read, rm_ab_seek);
+ retVal = rm_parser_init_io(pParser, 0, rm_ab_read, rm_ab_seek);
+ if (retVal != HXR_OK) {
+ if (pRADpack) {
+ ra_depack_destroy(&pRADpack);
+ ra_info.pDepack = NULL;
+ }
+ if (pParser) {
+ rm_parser_destroy(&pParser);
+ }
+ libcook_print("[cook decode],rm_parser_init_io failed,errid %d\n", retVal);
+ return -1;
+ }
+ ra_info.pParser = pParser;
+ rm_parser_set_stream(&pParser, 0);
+ rm_parser_file_seek(pParser, 0);
+ ra_dec_info.pDecode = ra_decode_create(HXNULL, rm_error);
+ if (retVal != HXR_OK) {
+ if (pRADpack) {
+ ra_depack_destroy(&pRADpack);
+ ra_info.pDepack = NULL;
+ }
+ if (pParser) {
+ rm_parser_destroy(&pParser);
+ }
+ libcook_print("[cook decode],ra_decode_create failed,errid %d\n", retVal);
+ return -1;
+ }
+ ra_dec_info.ulStatus = RADEC_PLAY;
+ ra_dec_info.ulTotalSample = 0;
+ ra_dec_info.ulTotalSamplePlayed = 0;
+ UINT32 ulMaxSamples = 0;
+ if (ra_dec_info.pOutBuf) {
+ ra_decode_reset(ra_dec_info.pDecode,
+ (UINT16*)ra_dec_info.pOutBuf,
+ ra_dec_info.ulOutBufSize / 2,
+ &ulMaxSamples);
+ }
+ retVal = ra_decode_init(ra_dec_info.pDecode, ulCodec4CC, HXNULL, 0, ra_info.pRaInfo);
+ if (retVal != HXR_OK) {
+ if (pRADpack) {
+ ra_depack_destroy(&pRADpack);
+ ra_info.pDepack = NULL;
+ }
+ if (pParser) {
+ rm_parser_destroy(&pParser);
+ }
+ libcook_print("[cook decode],ra_decode_init failed,errid %d\n", retVal);
+ return -1;
+ }
+ if (ra_dec_info.pOutBuf) {
+ ra_decode_getmaxsize(ra_dec_info.pDecode, &ulMaxSamples);
+ if (ulMaxSamples * sizeof(UINT16) > ra_dec_info.ulOutBufSize) {
+ free(ra_dec_info.pOutBuf);
+ ra_dec_info.ulOutBufSize = ulMaxSamples * sizeof(UINT16);
+ ra_dec_info.pOutBuf = (BYTE*) malloc(ra_dec_info.ulOutBufSize);
+ }
+ } else {
+ ra_decode_getmaxsize(ra_dec_info.pDecode, &ulMaxSamples);
+ ra_dec_info.ulOutBufSize = ulMaxSamples * sizeof(UINT16);
+ if (ra_dec_info.ulOutBufSize > 0) {
+ ra_dec_info.pOutBuf = (BYTE*) malloc(ra_dec_info.ulOutBufSize);
+ if (ra_dec_info.pOutBuf == NULL) {
+ if (pRADpack) {
+ ra_depack_destroy(&pRADpack);
+ ra_info.pDepack = NULL;
+ }
+ if (pParser) {
+ rm_parser_destroy(&pParser);
+ ra_info.pParser = NULL;
+ }
+ libcook_print("[cook decode],dsp malloc failed,request %s bytes\n", ra_dec_info.ulOutBufSize);
+ return -1;
+ }
+ }
+
+ }
+
+ return 0;
+}
+
+static void ra_depack_cleanup(void)
+{
+ /* Destroy the codec init info */
+ if (ra_info.pRaInfo) {
+ ra_depack_destroy_codec_init_info(ra_info.pDepack, &ra_info.pRaInfo);
+ }
+ /* Destroy the depacketizer */
+ if (ra_info.pDepack) {
+ ra_depack_destroy(&ra_info.pDepack);
+ }
+ /* If we have a packet, destroy it */
+ if (ra_info.pPacket) {
+ rm_parser_destroy_packet(ra_info.pParser, &ra_info.pPacket);
+ }
+ if (ra_info.pParser) {
+ rm_parser_destroy(&ra_info.pParser);
+ }
+ memset(&ra_info, 0, sizeof(ra_info));
+}
+
+
+//static int cook_decode_release(void)
+int audio_dec_release(audio_decoder_operations_t *adec_ops)
+{
+ if (cook_input.buf != NULL) {
+ free(cook_input.buf);
+ cook_input.buf = NULL;
+ }
+ if (cook_output.buf != NULL) {
+ free(cook_output.buf);
+ cook_output.buf = NULL;
+ }
+
+ ra_decode_destroy(ra_dec_info.pDecode);
+ ra_dec_info.pDecode = HXNULL;
+ if (ra_dec_info.pOutBuf) {
+ free(ra_dec_info.pOutBuf);
+ ra_dec_info.pOutBuf = HXNULL;
+ }
+ ra_dec_info.ulStatus = RADEC_IDLE;
+ ra_depack_cleanup();
+ libcook_print(" cook decoder release \n");
+ return 0;
+}
+
+int audio_dec_getinfo(audio_decoder_operations_t *adec_ops, void *pAudioInfo)
+{
+ return 0;
+}
+
+
diff --git a/audio_codec/libcook/cook_decode.h b/audio_codec/libcook/cook_decode.h
new file mode 100644
index 0000000..693a3b7
--- a/dev/null
+++ b/audio_codec/libcook/cook_decode.h
@@ -0,0 +1,35 @@
+#ifndef _AUDIO_CODEC_RA_H
+#define _AUDIO_CODEC_RA_H
+
+#include "rm_parse.h"
+#include "ra_depack.h"
+#include "ra_decode.h"
+
+
+typedef struct {
+ ra_decode* pDecode;
+ ra_format_info* pRaInfo;
+ BYTE* pOutBuf;
+ UINT32 ulOutBufSize;
+ UINT32 ulTotalSample;
+ UINT32 ulTotalSamplePlayed;
+ UINT32 ulStatus;
+ UINT32 input_buffer_size;
+ BYTE* input_buf;
+ UINT32 decoded_size;
+
+} ra_decoder_info_t;
+
+typedef enum {
+ DECODE_INIT_ERR,
+ DECODE_FATAL_ERR,
+} error_code_t;
+
+
+#define RADEC_IDLE 0
+#define RADEC_INIT 1
+#define RADEC_PLAY 2
+#define RADEC_PAUSE 3
+
+#define USE_C_DECODER
+#endif
diff --git a/audio_codec/libcook/ga_config.h b/audio_codec/libcook/ga_config.h
new file mode 100644
index 0000000..8e86923
--- a/dev/null
+++ b/audio_codec/libcook/ga_config.h
@@ -0,0 +1,86 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: ga_config.h,v 1.1.1.1.2.1 2005/05/04 18:21:58 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/* parse an MPEG-4 general audio specific config structure from a bitstream */
+
+#ifndef GA_CONFIG_H
+#define GA_CONFIG_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "aac_bitstream.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ typedef struct ga_config_data_struct {
+ UINT32 audioObjectType;
+ UINT32 samplingFrequency;
+ UINT32 extensionSamplingFrequency;
+ UINT32 frameLength;
+ UINT32 coreCoderDelay;
+ UINT32 numChannels;
+ UINT32 numFrontChannels;
+ UINT32 numSideChannels;
+ UINT32 numBackChannels;
+ UINT32 numFrontElements;
+ UINT32 numSideElements;
+ UINT32 numBackElements;
+ UINT32 numLfeElements;
+ UINT32 numAssocElements;
+ UINT32 numValidCCElements;
+ HXBOOL bSBR;
+ } ga_config_data;
+
+ enum AudioObjectType {
+ AACMAIN = 1,
+ AACLC = 2,
+ AACSSR = 3,
+ AACLTP = 4,
+ AACSBR = 5,
+ AACSCALABLE = 6,
+ TWINVQ = 7
+ };
+
+ UINT32 ga_config_get_data(struct BITSTREAM *bs, ga_config_data *data);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef GA_CONFIG_H */
diff --git a/audio_codec/libcook/gecko2codec.c b/audio_codec/libcook/gecko2codec.c
new file mode 100644
index 0000000..df5d077
--- a/dev/null
+++ b/audio_codec/libcook/gecko2codec.c
@@ -0,0 +1,833 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: gecko2codec.c,v 1.8 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * gecko2codec.c - public C API for Gecko2 decoder
+ **************************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "coder.h"
+//#include "includes.h"
+//#include <amsysdef.h>
+//#include <Drivers/include/mpeg_reg.h>
+#include "cook_decode.h"
+
+#ifndef USE_C_DECODER
+//#define ENABLE_DUMP
+//#define DBG_AMRISC
+#endif
+//#include <core/dsp.h>
+
+#ifdef ENABLE_DUMP
+#define DUMP_GAIN 0x0001
+#define DUMP_CPL 0x0002
+#define DUMP_ENV 0x0004
+#define DUMP_HUFF 0x0008
+#define DUMP_QUANT 0x0010
+#define DUMP_DECODE_INFO 0x0020
+unsigned int DumpMask = 0;
+extern const int cplband[MAXREGNS];
+#endif
+
+FILE *pDumpFile = NULL;
+unsigned int FrameCount = 0;
+
+#ifdef DBG_AMRISC
+
+// copy from ra.h
+
+#define MAXNCHAN 2
+#define NPARTS 8
+#define MAXNATS 8
+#define MAXBUF 4
+
+/*********************************** variables in lmem16 ***************************/
+#define L_DECODEINFO 0
+#define ADTSHI_OFFSET 0
+#define ADTSLO_OFFSET 1
+#define LOSTFLAG_OFFSET 2
+#define NCHANNELS_OFFSET 3
+#define NSAMPLES_OFFSET 4
+#define SAMPLERATE_OFFSET 5
+#define XFORMIDX_OFFSET 6
+#define GBMIN_OFFSET 7
+//[MAXNCHAN]
+#define XBITS_OFFSET 9
+//[MAXNCHAN][2]
+#define DGAINC_OFFSET 13
+//[MAXNCHAN][CODINGDELAY]*sizeof(L_GAINC) = 2*2*18 = 72
+#define NATS_OFFSET 0
+#define LOC_OFFSET 1
+//MAXNATS
+#define GAIN_OFFSET 9
+//MAXNATS
+#define MAXEXGAIN_OFFSET 17
+#define EXGAIN_OFFSET 85
+// 17
+//13+18*4+17 = 102
+#define L_BITREV 128
+//129
+
+/*********************************** variables in lmem24 ***************************/
+
+#define L_DECMLT 0x400
+#define L_COS4SIN4 0x800
+#define L_COS1SIN1 0x800
+#define L_TWIDTAB 0x800
+
+#define L_DECMLT_W 0x400
+//1024
+#define L_OVERLAP_W 0x800
+//256
+#define L_WINDOW 0xa00
+//256
+#define L_POW2NTAB 0xb00
+//128
+#define L_DECODEINFO_SWAP 0xb80
+//11+18*4+17 = 100
+
+/*********************************** variables in sdram ***************************/
+
+#define M_DECODE_INFO 0
+//128*MAXBUF
+//PreMultiply
+#define M_DECMLT (M_DECODE_INFO+128*MAXBUF)
+//1024*2*MAXBUF
+#define M_OVERLAP (M_DECMLT+(1024*2*MAXBUF)*3/2)
+//1024*2
+
+/*********************************** table in sdram ***************************/
+
+//PreMultiply
+#define M_COS4SIN4_1024 (M_OVERLAP+(1024*2)*3/2)
+#define M_COS4SIN4_512 (M_COS4SIN4_1024+1024*3/2)
+#define M_COS4SIN4_256 (M_COS4SIN4_512+512*3/2)
+
+//BitReverse
+#define M_BITREV_1024 (M_COS4SIN4_256+256*3/2)
+//132
+#define M_BITREV_512 (M_BITREV_1024+132)
+//68
+#define M_BITREV_256 (M_BITREV_512+68)
+//36
+
+//PostMultiply
+#define M_COS1SIN1 (M_BITREV_256+36)
+
+//R4FFT
+#define M_TWIDTABEVEN (M_COS1SIN1+(514+2)*3/2)
+//4*6
+//16*6
+//64*6
+#define M_TWIDTABODD (M_TWIDTABEVEN+((4+16+64)*6)*3/2)
+//8*6
+//32*6
+//128*6
+
+//InterpolatePCM & InterpolateOverlap
+#define M_POW2NTAB (M_TWIDTABODD+((8+32+128)*6)*3/2)
+//128
+#define M_WINDOWS_1024 (M_POW2NTAB+128*3/2)
+//1024
+#define M_WINDOWS_512 (M_WINDOWS_1024+1024*3/2)
+//512
+#define M_WINDOWS_256 (M_WINDOWS_512+512*3/2)
+//256
+
+//PCM swap
+#define M_PCM_SWAP (M_WINDOWS_256+256*3/2)
+//2048
+
+#define M_END (M_PCM_SWAP+2048)
+
+// copy from debug.h
+
+#define BP_NEW_FRAME 0x0001
+#define BP_DECODE_INFO 0x0002
+#define BP_BEFORE_INVERSE_TRANSFORM 0x0004
+#define BP_PREMULTIPLY 0x0008
+#define BP_BITREVERSE 0x0010
+#define BP_R8FIRSTPASS 0x0020
+#define BP_R4CORE 0x0040
+#define BP_POSTMULTIPLY 0x0080
+#define BP_GAIN_CHANGES 0x0100
+#define BP_PCM 0x0200
+#define BP_OVERLAP 0x0400
+#define BP_DEBUG 0x1000
+
+#define DBG_MASK 0x1fff
+
+#define BP_DUMP_LMEM16 0x8000
+#define BP_DUMP_LMEM24_1 0x4000
+#define BP_DUMP_LMEM24_2 0x2000
+
+#define TRACE_CMD 0x51c
+#define TRACE_REG0 0x51d
+#define TRACE_REG1 0x51e
+#define TRACE_REG2 0x51f
+#define TRACE_MASK 0x520
+
+#define M_LMEM16_DUMP (0x50000>>1)
+// 2KB
+#define M_LMEM24_1_DUMP (0x50800>>1)
+// 3KB
+#define M_LMEM24_2_DUMP (0x51400>>1)
+// 3KB
+
+void ra_debug_init(void)
+{
+ WRITE_MPEG_REG(TRACE_CMD, 0x0);
+ WRITE_MPEG_REG(TRACE_REG0, 0x0);
+ WRITE_MPEG_REG(TRACE_REG1, 0x0);
+ WRITE_MPEG_REG(TRACE_REG2, 0x0);
+ WRITE_MPEG_REG(TRACE_MASK, BP_NEW_FRAME);
+}
+
+void ra_debug_dump_decmlt(HGecko2Decoder hGecko2Decoder, int gb)
+{
+ Gecko2Info *gi;
+ unsigned rd;
+ unsigned ch, i;
+
+ gi = (Gecko2Info *)hGecko2Decoder;
+ rd = READ_MPEG_REG(MREG_AUDIO_CTRL_REG5);
+ ch = READ_MPEG_REG(TRACE_REG0);
+ read_from_24bit_linear_format((M_LMEM24_1_DUMP << 1), &gi->block[rd].decmlt[ch][0], 1024);
+ for (i = 0; i < gi->nSamples; i++) {
+ if (!(i & 7)) {
+ fprintf(pDumpFile, "\n\t");
+ }
+ if (gb < 8) {
+ fprintf(pDumpFile, "%06x ", ((gi->block[rd].decmlt[ch][i] + (1 << (7 - gb))) >> (8 - gb)) & 0xffffff);
+ } else {
+ fprintf(pDumpFile, "%06x ", (gi->block[rd].decmlt[ch][i] << (gb - 8)) & 0xffffff);
+ }
+ }
+ fprintf(pDumpFile, "\n");
+}
+
+void ra_debug_dump_overlap(HGecko2Decoder hGecko2Decoder, int gb)
+{
+ Gecko2Info *gi;
+ unsigned rd;
+ unsigned ch, i;
+
+ gi = (Gecko2Info *)hGecko2Decoder;
+ rd = READ_MPEG_REG(MREG_AUDIO_CTRL_REG5);
+ ch = READ_MPEG_REG(TRACE_REG0);
+ read_from_24bit_linear_format((M_OVERLAP << 1), gi->db.overlap[ch], 1024);
+ for (i = 0; i < gi->nSamples; i++) {
+ if (!(i & 7)) {
+ fprintf(pDumpFile, "\n\t");
+ }
+ if (gb < 8) {
+ fprintf(pDumpFile, "%06x ", ((gi->db.overlap[ch][i] + (1 << (7 - gb))) >> (8 - gb)) & 0xffffff);
+ } else {
+ fprintf(pDumpFile, "%06x ", (gi->db.overlap[ch][i] << (gb - 8)) & 0xffffff);
+ }
+ }
+ fprintf(pDumpFile, "\n");
+}
+
+unsigned dbg_frame = 0;
+void ra_debug(HGecko2Decoder hGecko2Decoder)
+{
+ static short cur_breakpoint;
+ Gecko2Info *gi;
+ unsigned rd;
+ DecodeInfo *di;
+ unsigned ch, i, j;
+ short *pcm_output;
+
+ if ((READ_MPEG_REG(TRACE_CMD) & 0x8000) == 0) {
+ return;
+ }
+
+ gi = (Gecko2Info *)hGecko2Decoder;
+ rd = READ_MPEG_REG(MREG_AUDIO_CTRL_REG5);
+ di = &gi->block[rd];
+ ch = READ_MPEG_REG(TRACE_REG0);
+
+ cur_breakpoint = READ_MPEG_REG(TRACE_CMD) & 0x7fff;
+ if (cur_breakpoint) {
+ switch (cur_breakpoint) {
+ case BP_NEW_FRAME:
+ fprintf(pDumpFile, "\n----- Frame %d in %d-----\n", ++FrameCount, rd);
+ printf("Frame %d in %d-----\n", FrameCount, rd);
+ if (FrameCount >= dbg_frame) {
+ WRITE_MPEG_REG(TRACE_MASK, BP_NEW_FRAME | BP_DECODE_INFO/*|BP_BEFORE_INVERSE_TRANSFORM|BP_PREMULTIPLY|BP_BITREVERSE|BP_R8FIRSTPASS|BP_R4CORE*/ | BP_POSTMULTIPLY | BP_GAIN_CHANGES | BP_DEBUG);
+ }
+
+ WRITE_MPEG_REG(TRACE_CMD, 0);
+ break;
+ case BP_DECODE_INFO:
+ read_from_16bit_linear_format((M_LMEM16_DUMP << 1), (short*)&gi->block[rd], 128);
+ fprintf(pDumpFile, "decode info: %d\n", rd);
+ fprintf(pDumpFile, "\tlost_flag: %d\n", di->lostflag);
+ fprintf(pDumpFile, "\tChannels: %d\n", di->nChannels);
+ fprintf(pDumpFile, "\tSamples: %d\n", di->nSamples);
+ fprintf(pDumpFile, "\txformIdx: %d\n", di->xformIdx);
+ fprintf(pDumpFile, "\tgbMin: %d %d\n", di->gbMin[0], di->gbMin[1]);
+ fprintf(pDumpFile, "\tgbOverlap: %d %d\n", READ_MPEG_REG(MREG_AUDIO_CTRL_REG2) & 0xff, READ_MPEG_REG(MREG_AUDIO_CTRL_REG2) >> 8);
+ fprintf(pDumpFile, "\txbits: %d %d %d %d\n", di->xbits[0][0], di->xbits[0][1], di->xbits[1][0], di->xbits[1][1]);
+ fprintf(pDumpFile, "\tGain:\n");
+ for (ch = 0; ch < di->nChannels; ch++) {
+ for (j = 0; j < 2; j++) {
+ fprintf(pDumpFile, "\t\tChannel[%d][%d]: nats=%d maxExGain=%d\n", ch, j, di->dgainc[ch][j].nats, di->dgainc[ch][j].maxExGain);
+ if (di->dgainc[ch][j].nats) {
+ fprintf(pDumpFile, "\t\t\tloc: ");
+ for (i = 0; i < di->dgainc[ch][j].nats; i++) {
+ fprintf(pDumpFile, "%04x ", di->dgainc[ch][j].loc[i] & 0xffff);
+ }
+ fprintf(pDumpFile, "\n");
+
+ fprintf(pDumpFile, "\t\t\tgain:");
+ for (i = 0; i < di->dgainc[ch][j].nats; i++) {
+ fprintf(pDumpFile, "%04x ", di->dgainc[ch][j].gain[i] & 0xffff);
+ }
+ fprintf(pDumpFile, "\n");
+ }
+ }
+ }
+ WRITE_MPEG_REG(TRACE_CMD, 0);
+ break;
+ case BP_BEFORE_INVERSE_TRANSFORM:
+ fprintf(pDumpFile, "\nBefore Inverse transform:%d", READ_MPEG_REG(TRACE_REG0));
+ ra_debug_dump_decmlt(gi, 0);
+ WRITE_MPEG_REG(TRACE_CMD, 0);
+ break;
+ case BP_PREMULTIPLY:
+ fprintf(pDumpFile, "\nAfter PreMultiply:");
+ if (di->gbMin[ch] < 4) {
+ ra_debug_dump_decmlt(gi, -1);
+ } else {
+ ra_debug_dump_decmlt(gi, -1);
+ }
+ WRITE_MPEG_REG(TRACE_CMD, 0);
+ break;
+ case BP_BITREVERSE:
+ fprintf(pDumpFile, "\nAfter BitReverse:");
+ if (di->gbMin[ch] < 4) {
+ ra_debug_dump_decmlt(gi, -1);
+ } else {
+ ra_debug_dump_decmlt(gi, -1);
+ }
+ WRITE_MPEG_REG(TRACE_CMD, 0);
+ break;
+ case BP_R8FIRSTPASS:
+ fprintf(pDumpFile, "\nAfter R8FirstPass:");
+ if (di->gbMin[ch] < 4) {
+ ra_debug_dump_decmlt(gi, -1);
+ } else {
+ ra_debug_dump_decmlt(gi, -1);
+ }
+ WRITE_MPEG_REG(TRACE_CMD, 0);
+ break;
+ case BP_R4CORE:
+ fprintf(pDumpFile, "\nAfter R4Core:");
+ if (di->gbMin[ch] < 4) {
+ ra_debug_dump_decmlt(gi, -4);
+ } else {
+ ra_debug_dump_decmlt(gi, -4);
+ }
+ WRITE_MPEG_REG(TRACE_CMD, 0);
+ break;
+ case BP_POSTMULTIPLY:
+ fprintf(pDumpFile, "\nAfter PostMultiply:");
+ ra_debug_dump_decmlt(gi, -7);
+ WRITE_MPEG_REG(TRACE_CMD, 0);
+ break;
+ case BP_GAIN_CHANGES:
+ read_from_16bit_linear_format((M_LMEM16_DUMP << 1), (short*)&gi->block[rd], 128);
+ fprintf(pDumpFile, "\nAfter CalcGainChanges:");
+ fprintf(pDumpFile, "\n\tgainc0->maxExGain=%04x, gainc1->maxExGain=%04x", di->dgainc[ch][0].maxExGain & 0xffff, di->dgainc[ch][1].maxExGain & 0xffff);
+ fprintf(pDumpFile, "\n\texgain:");
+ for (i = 0; i < 2 * NPARTS + 1; i++) {
+ if ((i % NPARTS) == 0) {
+ fprintf(pDumpFile, "\n\t\t");
+ }
+ fprintf(pDumpFile, "%04x ", di->exgain[i] & 0xffff);
+ }
+ fprintf(pDumpFile, "\n");
+ WRITE_MPEG_REG(TRACE_CMD, 0);
+ break;
+ case BP_PCM:
+ pcm_output = AVMem_calloc(1024, sizeof(short));
+ ch = READ_MPEG_REG(TRACE_REG0);
+ read_from_16bit_linear_format((M_LMEM16_DUMP << 1), (short*)pcm_output, di->nSamples);
+ fprintf(pDumpFile, "PCM:\n");
+ for (i = 0; i < di->nSamples; i++) {
+ if (!(i & 31)) {
+ fprintf(pDumpFile, "\n\t");
+ }
+ fprintf(pDumpFile, "%02x ", (*(pcm_output + i) >> 8) & 0xff);
+ }
+ fprintf(pDumpFile, "\n");
+ AVMem_free(pcm_output);
+ WRITE_MPEG_REG(TRACE_CMD, 0);
+ break;
+ case BP_OVERLAP:
+ fprintf(pDumpFile, "\nOverlap:");
+ ra_debug_dump_overlap(gi, READ_MPEG_REG(MREG_AUDIO_CTRL_REG2));
+ WRITE_MPEG_REG(TRACE_CMD, 0);
+ break;
+ case BP_DEBUG:
+ fprintf(pDumpFile, "%06x %06x\n", ((READ_MPEG_REG(TRACE_REG0) << 8) | (READ_MPEG_REG(TRACE_REG1) & 0xff)), (READ_MPEG_REG(TRACE_REG2) << 8) | ((READ_MPEG_REG(TRACE_REG1) >> 8) & 0xff));
+ WRITE_MPEG_REG(TRACE_CMD, 0);
+ break;
+ default:
+ printf("breakpoint not defined\n");
+ break;
+ }
+ }
+}
+#endif
+
+/**************************************************************************************
+ * Function: Gecko2InitDecoder
+ *
+ * Description: initialize the fixed-point Gecko2 audio decoder
+ *
+ * Inputs: number of samples per frame
+ * number of channels
+ * number of frequency regions coded
+ * number of encoded bits per frame
+ * number of samples per second
+ * start region for coupling (joint stereo only)
+ * number of bits for each coupling scalefactor (joint stereo only)
+ * pointer to receive number of frames of coding delay
+ *
+ * Outputs: number of frames of coding delay (i.e. discard the PCM output from
+ * the first *codingDelay calls to Gecko2Decode())
+ *
+ * Return: instance pointer, 0 if error (malloc fails, unsupported mode, etc.)
+ *
+ * Notes: this implementation is fully reentrant and thread-safe - the
+ * HGecko2Decoder instance pointer tracks all the state variables
+ * for each instance
+ **************************************************************************************/
+HGecko2Decoder Gecko2InitDecoder(int nSamples, int nChannels, int nRegions, int nFrameBits, int sampRate,
+ int cplStart, int cplQbits, int *codingDelay)
+{
+ Gecko2Info *gi;
+
+#ifdef ENABLE_DUMP
+ pDumpFile = fopen("ra_dump.txt", "w");
+#endif
+
+ /* check parameters */
+ if (nChannels < 0 || nChannels > MAXNCHAN) {
+ return 0;
+ }
+ if (nRegions < 0 || nRegions > MAXREGNS) {
+ return 0;
+ }
+ if (nFrameBits < 0 || cplStart < 0) {
+ return 0;
+ }
+ if (cplQbits && (cplQbits < 2 || cplQbits > 6)) {
+ return 0;
+ }
+
+ gi = AllocateBuffers();
+ if (!gi) {
+ return 0;
+ }
+
+ /* if stereo, cplQbits == 0 means dual-mono, > 0 means joint stereo */
+ gi->jointStereo = (nChannels == 2) && (cplQbits > 0);
+
+ gi->nSamples = nSamples;
+ gi->nChannels = nChannels;
+ gi->nRegions = nRegions;
+ gi->nFrameBits = nFrameBits;
+ if (gi->nChannels == 2 && !gi->jointStereo) {
+ gi->nFrameBits /= 2;
+ }
+ gi->sampRate = sampRate;
+
+ gi->rd = 0;
+ gi->wr = 0;
+
+ //#ifndef USE_C_DECODER
+ // WRITE_MPEG_REG(MREG_AUDIO_CTRL_REG5, gi->rd);
+ // WRITE_MPEG_REG(MREG_AUDIO_CTRL_REG6, gi->wr);
+ //#endif
+
+ if (gi->jointStereo) {
+ /* joint stereo */
+ gi->cplStart = cplStart;
+ gi->cplQbits = cplQbits;
+ gi->rateBits = 5;
+ if (gi->nSamples > 256) {
+ gi->rateBits++;
+ }
+ if (gi->nSamples > 512) {
+ gi->rateBits++;
+ }
+ } else {
+ /* mono or dual-mono */
+ gi->cplStart = 0;
+ gi->cplQbits = 0;
+ gi->rateBits = 5;
+ }
+
+ gi->cRegions = gi->nRegions + gi->cplStart;
+ gi->nCatzns = (1 << gi->rateBits);
+ gi->lfsr[0] = gi->lfsr[1] = ('k' | 'e' << 8 | 'n' << 16 | 'c' << 24); /* well-chosen seed for dither generator */
+
+ /* validate tranform size */
+ if (gi->nSamples == 256) {
+ gi->xformIdx = 0;
+ } else if (gi->nSamples == 512) {
+ gi->xformIdx = 1;
+ } else if (gi->nSamples == 1024) {
+ gi->xformIdx = 2;
+ } else {
+ Gecko2FreeDecoder(gi);
+ return 0;
+ }
+
+ /* this is now 2, since lookahead MLT has been removed */
+ *codingDelay = CODINGDELAY;
+
+#ifdef DBG_AMRISC
+ ra_debug_init();
+#endif
+
+ return (HGecko2Decoder)gi;
+}
+
+/**************************************************************************************
+ * Function: Gecko2FreeDecoder
+ *
+ * Description: free the fixed-point Gecko2 audio decoder
+ *
+ * Inputs: HGecko2Decoder instance pointer returned by Gecko2InitDecoder()
+ *
+ * Outputs: none
+ *
+ * Return: none
+ **************************************************************************************/
+void Gecko2FreeDecoder(HGecko2Decoder hGecko2Decoder)
+{
+ Gecko2Info *gi = (Gecko2Info *)hGecko2Decoder;
+
+#ifdef ENABLE_DUMP
+ if (pDumpFile) {
+ fclose(pDumpFile);
+ }
+#endif
+
+ if (!gi) {
+ return;
+ }
+
+ FreeBuffers(gi);
+
+ return;
+}
+
+/**************************************************************************************
+ * Function: Gecko2ClearBadFrame
+ *
+ * Description: zero out pcm buffer if error decoding Gecko2 frame
+ *
+ * Inputs: pointer to initialized Gecko2Info struct
+ * pointer to pcm output buffer
+ *
+ * Outputs: zeroed out pcm buffer
+ * zeroed out data buffers (as if codec had been reinitialized)
+ *
+ * Return: none
+ **************************************************************************************/
+static void Gecko2ClearBadFrame(Gecko2Info *gi, short *outbuf)
+{
+ int i, ch;
+
+ if (!gi || gi->nSamples * gi->nChannels > MAXNSAMP * MAXNCHAN || gi->nSamples * gi->nChannels < 0) {
+ return;
+ }
+
+ /* clear PCM buffer */
+ for (i = 0; i < gi->nSamples * gi->nChannels; i++) {
+ outbuf[i] = 0;
+ }
+
+ /* clear internal data buffers */
+ for (ch = 0; ch < gi->nChannels; ch++) {
+ for (i = 0; i < gi->nSamples; i++) {
+ gi->db.decmlt[ch][i] = 0;
+ gi->db.overlap[ch][i] = 0;
+ }
+ gi->xbits[ch][0] = gi->xbits[ch][1] = 0;
+ }
+
+}
+
+void ProduceDecodeInfo(HGecko2Decoder hGecko2Decoder, unsigned timestamp)
+{
+#ifndef USE_C_DECODER
+ Gecko2Info *gi = (Gecko2Info *)hGecko2Decoder;
+ gi->wr = READ_MPEG_REG(MREG_AUDIO_CTRL_REG6);
+ gi->block[gi->wr].adts_hi = timestamp >> 16;
+ gi->block[gi->wr].adts_lo = timestamp & 0xffff;
+ gi->block[gi->wr].lostflag = gi->lostflag;
+ gi->block[gi->wr].jointflag = gi->jointStereo;
+ gi->block[gi->wr].nChannels = gi->nChannels;
+ gi->block[gi->wr].nSamples = gi->nSamples;
+ if (gi->sampRate <= 12000) {
+ gi->block[gi->wr].sampRate = 4;
+ } else if (gi->sampRate <= 24000) {
+ gi->block[gi->wr].sampRate = 2;
+ } else {
+ gi->block[gi->wr].sampRate = 1;
+ }
+ gi->block[gi->wr].xformIdx = gi->xformIdx;
+ memcpy(gi->block[gi->wr].gbMin, gi->gbMin, MAXNCHAN * sizeof(short));
+ memcpy(gi->block[gi->wr].xbits, gi->xbits, 2 * MAXNCHAN * sizeof(short));
+ CopyGainInfo(&gi->block[gi->wr].dgainc[0][0], &gi->dgainc[0][0]);
+ CopyGainInfo(&gi->block[gi->wr].dgainc[0][1], &gi->dgainc[0][1]);
+ CopyGainInfo(&gi->block[gi->wr].dgainc[1][0], &gi->dgainc[1][0]);
+ CopyGainInfo(&gi->block[gi->wr].dgainc[1][1], &gi->dgainc[1][1]);
+ gi->block[gi->wr].overlap = &gi->db.overlap;
+ write_to_16bit_linear_format((gi->wr) * 256, (short*)&gi->block[gi->wr], 128);
+ write_to_24bit_linear_format(MAXDECBUF * 256 + gi->wr * 2 * 1024 * 3, &(gi->db.decmlt[0][0]), 1024, gi->gbMin[0], 1);
+ write_to_24bit_linear_format(MAXDECBUF * 256 + gi->wr * 2 * 1024 * 3 + 1024 * 3, &(gi->db.decmlt[1][0]), 1024, gi->gbMin[1], 1);
+ gi->wr++;
+ gi->wr &= MAXDECBUF - 1;
+ WRITE_MPEG_REG(MREG_AUDIO_CTRL_REG6, gi->wr);
+#endif
+}
+
+int GetDecodeInfo(HGecko2Decoder hGecko2Decoder)
+{
+#ifndef USE_C_DECODER
+ Gecko2Info *gi = (Gecko2Info *)hGecko2Decoder;
+ gi->rd = READ_MPEG_REG(MREG_AUDIO_CTRL_REG5);
+ gi->wr = READ_MPEG_REG(MREG_AUDIO_CTRL_REG6);
+
+ while (((gi->wr + 1) & (MAXDECBUF - 1)) == gi->rd) {
+ gi->rd = READ_MPEG_REG(MREG_AUDIO_CTRL_REG5);
+ AVTimeDly(5);
+ if (AVTaskDelReq(OS_ID_SELF) == OS_TASK_DEL_REQ) {
+ return 0;
+ }
+ }
+#endif
+ return 1;
+}
+
+/**************************************************************************************
+ * Function: Gecko2Decode
+ *
+ * Description: decode one frame of audio data
+ *
+ * Inputs: HGecko2Decoder instance pointer returned by Gecko2InitDecoder()
+ * pointer to one encoded frame
+ * (nFrameBits / 8 bytes of data, byte-aligned)
+ * flag indicating lost frame (lostflag != 0 means lost)
+ * pointer to receive one decoded frame of PCM
+ *
+ * Outputs: one frame (nSamples * nChannels 16-bit samples) of decoded PCM
+ *
+ * Return: 0 if frame decoded okay, error code (< 0) if error
+ *
+ * Notes: to reduce memory and CPU usage, this only implements one-sided
+ * (backwards) interpolation for error concealment (no lookahead)
+ **************************************************************************************/
+int Gecko2Decode(HGecko2Decoder hGecko2Decoder, unsigned char *codebuf, int lostflag, short *outbuf, unsigned timestamp)
+{
+ int i, ch, availbits;
+ Gecko2Info *gi = (Gecko2Info *)hGecko2Decoder;
+
+#ifdef ENABLE_DUMP
+ int j;
+#endif
+
+ if (!gi) {
+ return -1;
+ }
+
+ gi->lostflag = lostflag;
+ if (GetDecodeInfo(hGecko2Decoder)) {
+ if (!gi->lostflag) {
+ /* current frame is valid, decode it */
+ if (gi->jointStereo) {
+ /* decode gain control info, coupling coefficients, and power envlope */
+ availbits = DecodeSideInfo(gi, codebuf, gi->nFrameBits, 0);
+ if (availbits < 0) {
+ Gecko2ClearBadFrame(gi, outbuf);
+ return ERR_GECKO2_INVALID_SIDEINFO;
+ }
+
+ /* reconstruct power envelope */
+ CategorizeAndExpand(gi, availbits);
+
+ /* reconstruct full MLT, including stereo decoupling */
+ gi->gbMin[0] = gi->gbMin[1] = DecodeTransform(gi, gi->db.decmlt[0], availbits, &gi->lfsr[0], 0);
+ JointDecodeMLT(gi, gi->db.decmlt[0], gi->db.decmlt[1]);
+ gi->xbits[1][1] = gi->xbits[0][1];
+ } else {
+ for (ch = 0; ch < gi->nChannels; ch++) {
+ /* decode gain control info and power envlope */
+ availbits = DecodeSideInfo(gi, codebuf + (ch * gi->nFrameBits >> 3), gi->nFrameBits, ch);
+ if (availbits < 0) {
+ Gecko2ClearBadFrame(gi, outbuf);
+ return ERR_GECKO2_INVALID_SIDEINFO;
+ }
+
+ /* reconstruct power envelope */
+ CategorizeAndExpand(gi, availbits);
+
+ /* reconstruct full MLT */
+ gi->gbMin[ch] = DecodeTransform(gi, gi->db.decmlt[ch], availbits, &gi->lfsr[ch], ch);
+
+ /* zero out non-coded regions */
+ for (i = gi->nRegions * NBINS; i < gi->nSamples; i++) {
+ gi->db.decmlt[ch][i] = 0;
+ }
+ }
+ }
+
+#ifdef ENABLE_DUMP
+ if (DumpMask & DUMP_GAIN) {
+ fprintf(pDumpFile, "Gain:\n");
+ for (ch = 0; ch < gi->nChannels; ch++) {
+ for (j = 0; j < 2; j++) {
+ fprintf(pDumpFile, "\tChannel[%d][%d]: nats=%d maxExGain=%d\n", ch, j, gi->dgainc[ch][j].nats, gi->dgainc[ch][j].maxExGain);
+ if (gi->dgainc[ch][j].nats) {
+ fprintf(pDumpFile, "\t\tloc: ");
+ for (i = 0; i < gi->dgainc[ch][j].nats; i++) {
+ fprintf(pDumpFile, "%08x ", gi->dgainc[ch][j].loc[i]);
+ }
+ fprintf(pDumpFile, "\n");
+
+ fprintf(pDumpFile, "\t\tgain:");
+ for (i = 0; i < gi->dgainc[ch][j].nats; i++) {
+ fprintf(pDumpFile, "%08x ", gi->dgainc[ch][j].gain[i]);
+ }
+ fprintf(pDumpFile, "\n");
+ }
+ }
+ }
+ }
+ if ((DumpMask & DUMP_CPL) && (gi->jointStereo)) {
+ fprintf(pDumpFile, "Couple:\n");
+ fprintf(pDumpFile, "\t");
+ for (i = cplband[gi->cplStart]; i <= cplband[gi->nRegions - 1]; i++) {
+ fprintf(pDumpFile, "%08x ", gi->db.cplindex[i]);
+ }
+ fprintf(pDumpFile, "\n");
+ }
+ if (DumpMask & DUMP_ENV) {
+ fprintf(pDumpFile, "Envelope:\n");
+ fprintf(pDumpFile, "\t");
+ for (i = 0; i < gi->cRegions; i++) {
+ fprintf(pDumpFile, "%04x ", gi->db.rmsIndex[i] & 0xffff);
+ if ((i % 10) == 9) {
+ fprintf(pDumpFile, "\n\t");
+ }
+ }
+ fprintf(pDumpFile, "\n");
+
+ for (ch = 0; ch < gi->nChannels; ch++) {
+ fprintf(pDumpFile, "\trmsMax[%d]=%08x\n", ch, gi->rmsMax[ch]);
+ }
+ }
+ if (DumpMask & DUMP_HUFF) {
+ fprintf(pDumpFile, "Huffman:\n");
+ for (ch = 0; ch < gi->nChannels; ch++) {
+ fprintf(pDumpFile, "\tgbMin[%d]=%08x\n", ch, gi->gbMin[ch]);
+ }
+ }
+ if (DumpMask & DUMP_QUANT) {
+ fprintf(pDumpFile, "Dequant:\n");
+ for (ch = 0; ch < gi->nChannels; ch++) {
+ fprintf(pDumpFile, "\tchannel %d:", ch);
+ for (i = 0; i < MAXNSAMP; i++) {
+ if (!(i & 7)) {
+ fprintf(pDumpFile, "\n\t");
+ }
+ fprintf(pDumpFile, "%06x ", ((gi->db.decmlt[ch][i] + 0x80) >> 8) & 0xffffff);
+ }
+ fprintf(pDumpFile, "\n");
+ }
+ }
+#endif // ENABLE_DUMP
+
+#ifdef USE_C_DECODER
+ /* inverse transform, without window or overlap-add */
+ for (ch = 0; ch < gi->nChannels; ch++) {
+ IMLTNoWindow(gi->xformIdx, gi->db.decmlt[ch], gi->gbMin[ch]);
+ }
+#endif
+ }
+
+ ProduceDecodeInfo(hGecko2Decoder, timestamp);
+#ifdef DBG_AMRISC
+ gi->rd = READ_MPEG_REG(MREG_AUDIO_CTRL_REG5);
+ gi->wr = READ_MPEG_REG(MREG_AUDIO_CTRL_REG6);
+ while (gi->rd != gi->wr) {
+ ra_debug(gi);
+ gi->rd = READ_MPEG_REG(MREG_AUDIO_CTRL_REG5);
+ }
+#endif
+#ifdef USE_C_DECODER
+ for (ch = 0; ch < gi->nChannels; ch++) {
+ /* apply synthesis window, gain window, then overlap-add (interleaves stereo PCM LRLR...) */
+ if (gi->dgainc[ch][0].nats || gi->dgainc[ch][1].nats || gi->xbits[ch][0] || gi->xbits[ch][1]) {
+ DecWindowWithAttacks(gi->xformIdx, gi->db.decmlt[ch], gi->db.overlap[ch], outbuf + ch, gi->nChannels, &gi->dgainc[ch][0], &gi->dgainc[ch][1], gi->xbits[ch]);
+ } else {
+ DecWindowNoAttacks(gi->xformIdx, gi->db.decmlt[ch], gi->db.overlap[ch], outbuf + ch, gi->nChannels);
+ }
+
+ /* save gain settings for overlap */
+ CopyGainInfo(&gi->dgainc[ch][0], &gi->dgainc[ch][1]);
+ gi->xbits[ch][0] = gi->xbits[ch][1];
+ }
+#endif
+ }
+
+ return 0;
+}
diff --git a/audio_codec/libcook/gecko2codec.h b/audio_codec/libcook/gecko2codec.h
new file mode 100644
index 0000000..0eda1f0
--- a/dev/null
+++ b/audio_codec/libcook/gecko2codec.h
@@ -0,0 +1,60 @@
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * gecko2codec.h - public C API for Gecko2 decoder
+ **************************************************************************************/
+
+#ifndef _GECKO2CODEC_H
+#define _GECKO2CODEC_H
+
+//#include "includes.h"
+#define _ARC32
+
+#if defined(_WIN32) && !defined(_WIN32_WCE)
+
+#elif defined(_WIN32) && defined(_WIN32_WCE) && defined(ARM)
+
+#elif defined(_WIN32) && defined(WINCE_EMULATOR)
+
+#elif defined(ARM_ADS)
+
+#elif defined(_SYMBIAN) && defined(__WINS__)
+
+#elif defined(__GNUC__) && defined(ARM)
+
+#elif defined(__GNUC__) && defined(__i386__)
+
+#elif defined(_OPENWAVE)
+
+#elif defined(_ARC32)
+
+#else
+#error No platform defined. See valid options in gecko2codec.h.
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef void *HGecko2Decoder;
+
+ enum {
+ ERR_GECKO2_NONE = 0,
+ ERR_GECKO2_INVALID_SIDEINFO = -1,
+
+ ERR_UNKNOWN = -9999
+ };
+
+ /* public API */
+ HGecko2Decoder Gecko2InitDecoder(int nSamples, int nChannels, int nRegions, int nFrameBits, int sampRate, int cplStart, int cplQbits, int *codingDelay);
+ void Gecko2FreeDecoder(HGecko2Decoder hGecko2Decoder);
+ int Gecko2Decode(HGecko2Decoder hGecko2Decoder, unsigned char *codebuf, int lostflag, short *outbuf, unsigned timestamp);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _GECKO2CODEC_H */
+
diff --git a/audio_codec/libcook/helix_config.h b/audio_codec/libcook/helix_config.h
new file mode 100644
index 0000000..2b7b500
--- a/dev/null
+++ b/audio_codec/libcook/helix_config.h
@@ -0,0 +1,92 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: helix_config.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef HELIX_CONFIG_H
+#define HELIX_CONFIG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+
+ /********************************************************************
+ *
+ * This file contains system wide configuration options. Please look
+ * through all the config options below to make sure the SDK is tuned
+ * best for your system.
+ *
+ ********************************************************************
+ */
+
+
+ /*
+ * Endian'ness.
+ *
+ * This package supports both compile-time and run-time determination
+ * of CPU byte ordering. If ARCH_IS_BIG_ENDIAN is defined as 0, the
+ * code will be compiled to run only on little-endian CPUs; if
+ * ARCH_IS_BIG_ENDIAN is defined as non-zero, the code will be
+ * compiled to run only on big-endian CPUs; if ARCH_IS_BIG_ENDIAN is
+ * not defined, the code will be compiled to run on either big- or
+ * little-endian CPUs, but will run slightly less efficiently on
+ * either one than if ARCH_IS_BIG_ENDIAN is defined.
+ *
+ * If you run on a BIG engian box uncomment this:
+ *
+ * #define ARCH_IS_BIG_ENDIAN 1
+ *
+ * If you are on a LITTLE engian box uncomment this:
+ *
+ * #define ARCH_IS_BIG_ENDIAN 0
+ *
+ * Or you can just leave it undefined and have it determined
+ * at runtime.
+ *
+ */
+
+
+
+
+
+
+
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef HELIX_CONFIG_H */
diff --git a/audio_codec/libcook/helix_mime_types.h b/audio_codec/libcook/helix_mime_types.h
new file mode 100644
index 0000000..b848bd6
--- a/dev/null
+++ b/audio_codec/libcook/helix_mime_types.h
@@ -0,0 +1,56 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: helix_mime_types.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef HELIX_MIME_TYPES_H
+#define HELIX_MIME_TYPES_H
+
+#define REALAUDIO_MIME_TYPE "audio/x-pn-realaudio"
+#define REALAUDIO_MULTIRATE_MIME_TYPE "audio/x-pn-multirate-realaudio"
+#define REALAUDIO_ENCRYPTED_MIME_TYPE "audio/x-pn-realaudio-encrypted"
+#define REALVIDEO_MIME_TYPE "video/x-pn-realvideo"
+#define REALVIDEO_MULTIRATE_MIME_TYPE "video/x-pn-multirate-realvideo"
+#define REALVIDEO_ENCRYPTED_MIME_TYPE "video/x-pn-realvideo-encrypted"
+#define REALEVENT_MIME_TYPE "application/x-pn-realevent"
+#define REALEVENT_ENCRYPTED_MIME_TYPE "application/x-pn-realevent-encrypted"
+#define REALIMAGEMAP_MIME_TYPE "application/x-pn-imagemap"
+#define REALIMAGEMAP_ENCRYPTED_MIME_TYPE "application/x-pn-imagemap-encrypted"
+#define IMAGEMAP_MIME_TYPE "image_map/x-pn-realvideo"
+#define IMAGEMAP_ENCRYPTED_MIME_TYPE "image_map/x-pn-realvideo-encrypted"
+#define SYNCMM_MIME_TYPE "syncMM/x-pn-realvideo"
+#define SYNCMM_ENCRYPTED_MIME_TYPE "syncMM/x-pn-realvideo-encrypted"
+
+#endif /* #ifndef HELIX_MIME_TYPES_H */
diff --git a/audio_codec/libcook/helix_result.h b/audio_codec/libcook/helix_result.h
new file mode 100644
index 0000000..6c600b4
--- a/dev/null
+++ b/audio_codec/libcook/helix_result.h
@@ -0,0 +1,107 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: helix_result.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef HELIX_RESULT_H
+#define HELIX_RESULT_H
+
+#include "helix_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* Definition of HX_RESULT */
+#ifndef HX_RESULT
+ typedef INT32 HX_RESULT;
+#endif /* #ifndef HX_RESULT */
+
+ /* FACILITY_ITF defintion */
+#ifndef FACILITY_ITF
+#define FACILITY_ITF 4
+#endif
+
+ /* General error definition macro */
+#ifndef MAKE_HX_FACILITY_RESULT
+#define MAKE_HX_FACILITY_RESULT(sev,fac,code) \
+ ((HX_RESULT) (((UINT32)(sev) << 31) | ((UINT32)(fac)<<16) | ((UINT32)(code))))
+#endif /* #ifndef MAKE_HX_FACILITY_RESULT */
+
+ /* Error definition macros with fac == FACILITY_ITF */
+#ifndef MAKE_HX_RESULT
+#define MAKE_HX_RESULT(sev,fac,code) MAKE_HX_FACILITY_RESULT(sev, FACILITY_ITF, ((fac << 6) | (code)))
+#endif /* #ifndef MAKE_HX_RESULT */
+
+#define SS_GLO 0 /* General errors */
+#define SS_NET 1 /* Networking errors */
+#define SS_FIL 2 /* File errors */
+#define SS_DEC 8 /* Decoder errors */
+#define SS_DPR 63 /* Deprecated errors */
+
+#define HXR_NOTIMPL MAKE_HX_FACILITY_RESULT(1,0,0x4001) /* 80004001 */
+#define HXR_OUTOFMEMORY MAKE_HX_FACILITY_RESULT(1,7,0x000e) /* 8007000e */
+#define HXR_INVALID_PARAMETER MAKE_HX_FACILITY_RESULT(1,7,0x0057) /* 80070057 */
+#define HXR_NOINTERFACE MAKE_HX_FACILITY_RESULT(1,0,0x4002) /* 80004002 */
+#define HXR_POINTER MAKE_HX_FACILITY_RESULT(1,0,0x4003) /* 80004003 */
+#define HXR_FAIL MAKE_HX_FACILITY_RESULT(1,0,0x4005) /* 80004005 */
+#define HXR_ACCESSDENIED MAKE_HX_FACILITY_RESULT(1,7,0x0005) /* 80070005 */
+#define HXR_OK MAKE_HX_FACILITY_RESULT(0,0,0) /* 00000000 */
+
+#define HXR_INVALID_VERSION MAKE_HX_RESULT(1,SS_GLO,5) /* 80040005 */
+#define HXR_UNEXPECTED MAKE_HX_RESULT(1,SS_GLO,9) /* 80040009 */
+#define HXR_UNSUPPORTED_AUDIO MAKE_HX_RESULT(1,SS_GLO,15) /* 8004000f */
+#define HXR_NOT_SUPPORTED MAKE_HX_RESULT(1,SS_GLO,33) /* 80040021 */
+
+#define HXR_NO_DATA MAKE_HX_RESULT(0,SS_NET,2) /* 00040042 */
+
+#define HXR_AT_END MAKE_HX_RESULT(0,SS_FIL,0) /* 00040080 */
+#define HXR_INVALID_FILE MAKE_HX_RESULT(1,SS_FIL,1) /* 80040081 */
+#define HXR_CORRUPT_FILE MAKE_HX_RESULT(1,SS_FIL,17) /* 80040091 */
+#define HXR_READ_ERROR MAKE_HX_RESULT(1,SS_FIL,18) /* 80040092 */
+
+#define HXR_BAD_FORMAT MAKE_HX_RESULT(1,SS_DPR,1) /* 80040fc1 */
+
+#define HXR_DEC_NOT_FOUND MAKE_HX_RESULT(1,SS_DEC,1) /* 80040201 */
+
+ /* Define success and failure macros */
+#define HX_SUCCEEDED(status) (((UINT32) (status) >> 31) == 0)
+#define HX_FAILED(status) (((UINT32) (status) >> 31) != 0)
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef HELIX_RESULT_H */
diff --git a/audio_codec/libcook/helix_types.h b/audio_codec/libcook/helix_types.h
new file mode 100644
index 0000000..fbb7d56
--- a/dev/null
+++ b/audio_codec/libcook/helix_types.h
@@ -0,0 +1,305 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: helix_types.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef HELIX_TYPES_H
+#define HELIX_TYPES_H
+//#include <core/dsp.h>
+#include "string.h"
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /*
+ * INT8 Type definition
+ *
+ * INT8 is a signed 8-bit type
+ */
+#ifndef INT8
+
+#if defined(_SYMBIAN)
+ typedef TInt8 INT8;
+#else /* #if defined(_SYMBIAN) */
+ typedef char INT8;
+#endif /* #if defined(_SYMBIAN) */
+
+#endif /* #ifndef INT8 */
+
+
+ /*
+ * CHAR - signed 8-bit value
+ */
+ typedef INT8 CHAR;
+
+
+ /*
+ * UINT8 Type definition
+ *
+ * UINT8 is an unsigned 8-bit type
+ */
+#ifndef UINT8
+
+#if defined(_SYMBIAN)
+ typedef TUint8 UINT8;
+#else /* #if defined(_SYMBIAN) */
+ typedef unsigned char UINT8;
+#endif /* #if defined(_SYMBIAN) */
+
+#endif /* #ifndef UINT8 */
+
+ /*
+ * BYTE Type definition
+ *
+ * BYTE is another name for a UINT8
+ */
+ typedef UINT8 BYTE;
+
+ /*
+ * UCHAR Unsigned 8 bit value.
+ *
+ */
+ typedef UINT8 UCHAR;
+
+ /*
+ * INT16 Type definition
+ *
+ * INT16 is a signed 16-bit type
+ */
+#ifndef INT16
+
+#if defined(_SYMBIAN)
+ typedef TInt16 INT16;
+#else /* #if defined(_SYMBIAN) */
+ typedef short int INT16;
+#endif /* #if defined(_SYMBIAN) */
+
+#endif /* #ifndef INT16 */
+
+ /*
+ * UINT16 Type definition
+ *
+ * UINT16 is an unsigned 16-bit type
+ */
+#ifndef UINT16
+
+#if defined(_SYMBIAN)
+ typedef TUint16 UINT16;
+#else /* #if defined(_SYMBIAN) */
+ typedef unsigned short int UINT16;
+#endif /* #if defined(_SYMBIAN) */
+
+#endif /* #ifndef UINT16 */
+
+ /*
+ * INT32 Type definition
+ *
+ * INT32 is a signed 32-bit type
+ */
+#ifndef INT32
+
+#if defined(_SYMBIAN)
+ typedef TInt32 INT32;
+#elif defined(_UNIX) && defined(_LONG_IS_64)
+ typedef int INT32;
+#elif defined(_VXWORKS)
+ typedef int INT32;
+#else
+ typedef int INT32;
+#endif
+
+#endif /* #ifndef INT32 */
+
+ /*
+ * LONG32 Type definition
+ *
+ * LONG32 is another name for a INT32
+ */
+ typedef INT32 LONG32;
+
+ /*
+ * UINT32 Type definition
+ *
+ * UINT32 is an unsigned 32-bit type
+ */
+#ifndef UINT32
+
+#if defined(_SYMBIAN)
+ typedef TUint32 UINT32;
+#elif defined(_UNIX) && defined(_LONG_IS_64)
+ typedef unsigned int UINT32;
+#elif defined(_VXWORKS)
+ typedef unsigned int UINT32;
+#else
+ typedef unsigned long UINT32;
+#endif
+
+#endif /* #ifndef UINT32 */
+
+ /*
+ * UFIXED32 Type definition
+ *
+ * UFIXED32 is another name for a UINT32
+ */
+ typedef UINT32 UFIXED32;
+
+ /*
+ * ULONG32 Type definition
+ *
+ * ULONG32 is another name for a UINT32
+ */
+ typedef UINT32 ULONG32;
+
+ /*
+ * HX_MOFTAG Type definition
+ *
+ * HX_MOFTAG is of type UINT32
+ */
+ typedef UINT32 HX_MOFTAG;
+
+ /*
+ * HXBOOL Type definition
+ *
+ * HXBOOL is a boolean type
+ */
+#ifndef HXBOOL
+
+#if defined(_SYMBIAN)
+ typedef TBool HXBOOL;
+#else /* #if defined(_SYMBIAN) */
+ typedef int HXBOOL;
+#endif /* #if defined(_SYMBIAN) */
+
+#endif /* #ifndef HXBOOL */
+
+ /*
+ * BOOL Type definition
+ *
+ * BOOL is another name for a HXBOOL
+ */
+ typedef HXBOOL BOOL;
+
+ /*
+ * TRUE and FALSE definitions
+ */
+#ifdef TRUE
+#undef TRUE
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifdef FALSE
+#undef FALSE
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+ /*
+ * HX_BITFIELD Type definition
+ *
+ * HX_BITFIELD is a bitfield type. It would
+ * be used in conjunction with a field width
+ * parameter like this:
+ *
+ * HX_BITFIELD foo:2;
+ */
+#ifndef HX_BITFIELD
+
+ typedef unsigned char HX_BITFIELD;
+
+#endif
+
+ /*
+ * HXFLOAT Type definition
+ *
+ * HXFLOAT is a single-precision floating-point type
+ */
+#ifndef HXFLOAT
+
+ typedef float HXFLOAT;
+
+#endif /* #ifndef HXFLOAT */
+
+ /*
+ * HXDOUBLE Type definition
+ *
+ * HXDOUBLE is a double-precision floating-point type
+ */
+#ifndef HXDOUBLE
+
+ typedef double HXDOUBLE;
+
+#endif /* #ifndef HXDOUBLE */
+
+ /*
+ * HXNULL definition
+ */
+#ifndef HXNULL
+#define HXNULL ((void *)0)
+#endif
+
+ /*
+ * Helix DATE type.
+ */
+
+#define HX_YEAR_OFFSET 1900
+
+ typedef struct system_time {
+ UINT16 second; /* 0-59 */
+ UINT16 minute; /* 0-59 */
+ UINT16 hour; /* 0-23 */
+ UINT16 dayofweek; /* 0-6 (Sunday = 0) */
+ UINT16 dayofmonth;/* 1-31 */
+ UINT16 dayofyear; /* 1-366 (January 1 = 1) */
+ UINT16 month; /* 1-12 (January = 1) */
+ UINT16 year; /* year - 1900 or (year - HX_YEAR_OFFSET) */
+ INT16 gmtDelta; /* Greenwich Mean Time Delta in +/- hours */
+ } HX_DATETIME;
+
+ HX_DATETIME HX_GET_DATETIME(void);
+
+#define HXEXPORT_PTR *
+#define HXEXPORT
+#define ENTRYPOINT(func) func
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef HELIX_TYPES_H */
diff --git a/audio_codec/libcook/helix_utils.h b/audio_codec/libcook/helix_utils.h
new file mode 100644
index 0000000..40450ca
--- a/dev/null
+++ b/audio_codec/libcook/helix_utils.h
@@ -0,0 +1,106 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: helix_utils.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef HELIX_UTILS_H
+#define HELIX_UTILS_H
+
+#include "helix_config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+
+ /*
+ * General support macros
+ *
+ */
+
+#define HX_MAX(a, b) (((a) > (b)) ? (a) : (b))
+#define HX_MIN(a, b) (((a) < (b)) ? (a) : (b))
+
+ /*
+ * Macro: IS_BIG_ENDIAN()
+ *
+ * Endianness detection macro.
+ * Requires local test_int = 0xFF for correct operation.
+ * Set ARCH_IS_BIG_ENDIAN in helix_config.h for best performance.
+ *
+ */
+
+#if !defined(ARCH_IS_BIG_ENDIAN)
+#define IS_BIG_ENDIAN(test_int) ((*((char*)&test_int)) == 0)
+#else
+#define IS_BIG_ENDIAN(test_int) ARCH_IS_BIG_ENDIAN
+#endif
+
+ /*
+ * Macro: HX_GET_MAJOR_VERSION()
+ *
+ * Given the encoded product version,
+ * returns the major version number.
+ */
+#define HX_GET_MAJOR_VERSION(prodVer) ((prodVer >> 28) & 0xF)
+
+ /*
+ * Macro: HX_GET_MINOR_VERSION()
+ *
+ * Given the encoded product version,
+ * returns the minor version number.
+ */
+#define HX_GET_MINOR_VERSION(prodVer) ((prodVer >> 20) & 0xFF)
+
+ /*
+ * Macro: HX_ENCODE_PROD_VERSION()
+ *
+ * Given the major version, minor version,
+ * release number, and build number,
+ * returns the encoded product version.
+ */
+#define HX_ENCODE_PROD_VERSION(major,minor,release,build) \
+ ((ULONG32)((ULONG32)major << 28) | ((ULONG32)minor << 20) | \
+ ((ULONG32)release << 12) | (ULONG32)build)
+
+#define HX_GET_PRIVATE_FIELD(ulversion)(ulversion & (UINT32)0xFF)
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+
+#endif /* HELIX_UTILS_H */
+
diff --git a/audio_codec/libcook/md5.h b/audio_codec/libcook/md5.h
new file mode 100644
index 0000000..7cec16c
--- a/dev/null
+++ b/audio_codec/libcook/md5.h
@@ -0,0 +1,113 @@
+/*
+ Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved.
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ L. Peter Deutsch
+ ghost@aladdin.com
+
+ */
+
+/*
+ Independent implementation of MD5 (RFC 1321).
+
+ This code implements the MD5 Algorithm defined in RFC 1321, whose
+ text is available at
+ http://www.ietf.org/rfc/rfc1321.txt
+ The code is derived from the text of the RFC, including the test suite
+ (section A.5) but excluding the rest of Appendix A. It does not include
+ any code or documentation that is identified in the RFC as being
+ copyrighted.
+
+ The original and principal author of md5.h is L. Peter Deutsch
+ <ghost@aladdin.com>. Other authors are noted in the change history
+ that follows (in reverse chronological order):
+
+ 2002-04-13 lpd Removed support for non-ANSI compilers; removed
+ references to Ghostscript; clarified derivation from RFC 1321;
+ now handles byte order either statically or dynamically.
+ 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
+ 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
+ added conditionalization for C++ compilation from Martin
+ Purschke <purschke@bnl.gov>.
+ 1999-05-03 lpd Original version.
+ */
+
+#ifndef md5_INCLUDED
+# define md5_INCLUDED
+
+
+#include "helix_types.h"
+/*
+ * These should cause all callers and callees of the md5_
+ * function names to use a unique Helix specific name space
+ * of HX_md5_xxx. This will facilitate the inclusion of our
+ * code into code bases that also use the md5_ functions.
+ */
+
+#define md5_init HX_md5_init
+#define md5_append HX_md5_append
+#define md5_finish HX_md5_finish
+#define MD5End HX_MD5End
+#define MD5Data HX_MD5Data
+
+
+/*
+ * This package supports both compile-time and run-time determination of CPU
+ * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be
+ * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is
+ * defined as non-zero, the code will be compiled to run only on big-endian
+ * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to
+ * run on either big- or little-endian CPUs, but will run slightly less
+ * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined.
+ */
+
+typedef unsigned char md5_byte_t; /* 8-bit byte */
+typedef unsigned int md5_word_t; /* 32-bit word */
+
+/* Define the state of the MD5 Algorithm. */
+typedef struct md5_state_s {
+ md5_word_t count[2]; /* message length in bits, lsw first */
+ md5_word_t abcd[4]; /* digest buffer */
+ md5_byte_t buf[64]; /* accumulate block */
+} md5_state_t;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /* Initialize the algorithm. */
+ void md5_init(md5_state_t *pms);
+
+ /* Append a string to the message. */
+ void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
+
+ /* Finish the message and return the digest. */
+ /* changed order to match expected usage. */
+ void md5_finish(md5_byte_t digest[16], md5_state_t *pms);
+
+
+ char * MD5End(md5_state_t *ctx, char *p);
+ char * MD5Data(char *, const unsigned char *, unsigned int);
+
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif /* md5_INCLUDED */
diff --git a/audio_codec/libcook/memory_utils.c b/audio_codec/libcook/memory_utils.c
new file mode 100644
index 0000000..3d411cb
--- a/dev/null
+++ b/audio_codec/libcook/memory_utils.c
@@ -0,0 +1,100 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: memory_utils.c,v 1.1.1.1.2.1 2005/05/04 18:21:23 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <memory.h>
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+#include "memory_utils.h"
+
+HX_RESULT rm_enforce_buffer_min_size(void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree,
+ BYTE** ppBuf,
+ UINT32* pulCurLen,
+ UINT32 ulReqLen)
+{
+ HX_RESULT retVal = HXR_OUTOFMEMORY;
+
+ if (fpMalloc && fpFree && ppBuf && pulCurLen) {
+ if (ulReqLen > *pulCurLen) {
+ /* Allocate a new buffer */
+ BYTE* pBuf = fpMalloc(pUserMem, ulReqLen);
+ if (pBuf) {
+ /* Was the old buffer allocated? */
+ if (*ppBuf && *pulCurLen > 0) {
+ /* Copy the old buffer into the new one */
+ memcpy(pBuf, *ppBuf, *pulCurLen);
+ /* Free the old buffer */
+ fpFree(pUserMem, *ppBuf);
+ }
+ /* Assign the buffer out parameter */
+ *ppBuf = pBuf;
+ /* Change the current size to the requested size */
+ *pulCurLen = ulReqLen;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ } else {
+ /* Current buffer size is adequate - don't
+ * have to do anything here.
+ */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+BYTE* copy_buffer(void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ BYTE* pBuf,
+ UINT32 ulLen)
+{
+ BYTE* pRet = HXNULL;
+
+ if (fpMalloc && pBuf && ulLen) {
+ /* Allocate a buffer */
+ pRet = (BYTE*) fpMalloc(pUserMem, ulLen);
+ if (pRet) {
+ /* Copy the buffer */
+ memcpy(pRet, pBuf, ulLen);
+ }
+ }
+
+ return pRet;
+}
diff --git a/audio_codec/libcook/memory_utils.h b/audio_codec/libcook/memory_utils.h
new file mode 100644
index 0000000..3c8992c
--- a/dev/null
+++ b/audio_codec/libcook/memory_utils.h
@@ -0,0 +1,58 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: memory_utils.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef MEMORY_UTILS_H
+#define MEMORY_UTILS_H
+
+//#include "includes.h"
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+
+HX_RESULT rm_enforce_buffer_min_size(void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree,
+ BYTE** ppBuf,
+ UINT32* pulCurLen,
+ UINT32 ulReqLen);
+
+BYTE* copy_buffer(void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ BYTE* pBuf,
+ UINT32 ulLen);
+
+#endif /* #ifndef MEMORY_UTILS_H */
diff --git a/audio_codec/libcook/pack_utils.c b/audio_codec/libcook/pack_utils.c
new file mode 100644
index 0000000..23fcc8d
--- a/dev/null
+++ b/audio_codec/libcook/pack_utils.c
@@ -0,0 +1,306 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: pack_utils.c,v 1.2.2.1 2005/05/04 18:21:23 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <memory.h>
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+#include "memory_utils.h"
+#include "pack_utils.h"
+
+void rm_pack32(UINT32 ulValue, BYTE** ppBuf, UINT32* pulLen)
+{
+ if (ppBuf && pulLen && *pulLen >= 4) {
+ BYTE* pBuf = *ppBuf;
+ pBuf[0] = (BYTE)((ulValue & 0xFF000000) >> 24);
+ pBuf[1] = (BYTE)((ulValue & 0x00FF0000) >> 16);
+ pBuf[2] = (BYTE)((ulValue & 0x0000FF00) >> 8);
+ pBuf[3] = (BYTE)(ulValue & 0x000000FF);
+ *ppBuf += 4;
+ *pulLen -= 4;
+ }
+}
+
+void rm_pack32_le(UINT32 ulValue, BYTE** ppBuf, UINT32* pulLen)
+{
+ if (ppBuf && pulLen && *pulLen >= 4) {
+ BYTE* pBuf = *ppBuf;
+ pBuf[0] = (BYTE)(ulValue & 0x000000FF);
+ pBuf[1] = (BYTE)((ulValue & 0x0000FF00) >> 8);
+ pBuf[2] = (BYTE)((ulValue & 0x00FF0000) >> 16);
+ pBuf[3] = (BYTE)((ulValue & 0xFF000000) >> 24);
+ *ppBuf += 4;
+ *pulLen -= 4;
+ }
+}
+
+void rm_pack16(UINT16 usValue, BYTE** ppBuf, UINT32* pulLen)
+{
+ if (ppBuf && pulLen && *pulLen >= 2) {
+ BYTE* pBuf = *ppBuf;
+ pBuf[0] = (BYTE)((usValue & 0x0000FF00) >> 8);
+ pBuf[1] = (BYTE)(usValue & 0x000000FF);
+ *ppBuf += 2;
+ *pulLen -= 2;
+ }
+}
+
+void rm_pack16_le(UINT16 usValue, BYTE** ppBuf, UINT32* pulLen)
+{
+ if (ppBuf && pulLen && *pulLen >= 2) {
+ BYTE* pBuf = *ppBuf;
+ pBuf[0] = (BYTE)(usValue & 0x000000FF);
+ pBuf[1] = (BYTE)((usValue & 0x0000FF00) >> 8);
+ *ppBuf += 2;
+ *pulLen -= 2;
+ }
+}
+
+void rm_pack8(BYTE ucValue, BYTE** ppBuf, UINT32* pulLen)
+{
+ if (ppBuf && pulLen && *pulLen > 0) {
+ BYTE* pBuf = *ppBuf;
+ pBuf[0] = (BYTE) ucValue;
+ *ppBuf += 1;
+ *pulLen -= 1;
+ }
+}
+
+UINT32 rm_unpack32(BYTE** ppBuf, UINT32* pulLen)
+{
+ UINT32 ulRet = 0;
+
+ if (ppBuf && pulLen && *pulLen >= 4) {
+ BYTE* pBuf = *ppBuf;
+ ulRet = (pBuf[0] << 24) | (pBuf[1] << 16) | (pBuf[2] << 8) | pBuf[3];
+ *ppBuf += 4;
+ *pulLen -= 4;
+ }
+
+ return ulRet;
+}
+
+UINT16 rm_unpack16(BYTE** ppBuf, UINT32* pulLen)
+{
+ UINT16 usRet = 0;
+
+ if (ppBuf && pulLen && *pulLen >= 2) {
+ BYTE* pBuf = *ppBuf;
+ usRet = (pBuf[0] << 8) | pBuf[1];
+ *ppBuf += 2;
+ *pulLen -= 2;
+ }
+
+ return usRet;
+}
+
+UINT32 rm_unpack32_nse(BYTE* pBuf, UINT32 ulLen)
+{
+ UINT32 ulRet = 0;
+
+ if (pBuf && ulLen >= 4) {
+ ulRet = (pBuf[0] << 24) | (pBuf[1] << 16) | (pBuf[2] << 8) | pBuf[3];
+ }
+
+ return ulRet;
+}
+
+UINT16 rm_unpack16_nse(BYTE* pBuf, UINT32 ulLen)
+{
+ UINT16 usRet = 0;
+
+ if (pBuf && ulLen >= 2) {
+ usRet = (pBuf[0] << 8) | pBuf[1];
+ }
+
+ return usRet;
+}
+
+BYTE rm_unpack8(BYTE** ppBuf, UINT32* pulLen)
+{
+ BYTE ucRet = 0;
+
+ if (ppBuf && pulLen && *pulLen > 0) {
+ BYTE* pBuf = *ppBuf;
+ ucRet = pBuf[0];
+ *ppBuf += 1;
+ *pulLen -= 1;
+ }
+
+ return ucRet;
+}
+
+HX_RESULT rm_unpack_string(BYTE** ppBuf,
+ UINT32* pulLen,
+ UINT32 ulStrLen,
+ char** ppStr,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (ppBuf && pulLen && *pulLen >= ulStrLen && ppStr && fpMalloc && fpFree) {
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Do we actually have a string to unpack? */
+ if (ulStrLen) {
+ /* If the string is already allocated, free it */
+ if (*ppStr) {
+ fpFree(pUserMem, *ppStr);
+ *ppStr = HXNULL;
+ }
+ /* Allocate a buffer that it one more byte than the length */
+ *ppStr = (char*) fpMalloc(pUserMem, ulStrLen + 1);
+ if (*ppStr) {
+ /* Copy the string buffer in */
+ memcpy(*ppStr, *ppBuf, ulStrLen);
+ /* Put a NULL terminator on the end */
+ (*ppStr)[ulStrLen] = '\0';
+ /* Update the parsing buffer counters */
+ *ppBuf += ulStrLen;
+ *pulLen -= ulStrLen;
+ } else {
+ retVal = HXR_OUTOFMEMORY;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_unpack_buffer(BYTE** ppBuf,
+ UINT32* pulLen,
+ UINT32 ulBufLen,
+ BYTE** ppUnPackBuf,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (ppBuf && pulLen && *pulLen >= ulBufLen && ppUnPackBuf && fpMalloc && fpFree) {
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Do we have a buffer? */
+ if (ulBufLen) {
+ /* If the string is already allocated, free it */
+ if (*ppUnPackBuf) {
+ fpFree(pUserMem, *ppUnPackBuf);
+ *ppUnPackBuf = HXNULL;
+ }
+ /* Allocate a buffer that it one more byte than the length */
+ *ppUnPackBuf = (BYTE*) fpMalloc(pUserMem, ulBufLen);
+ if (*ppUnPackBuf) {
+ /* Copy the string buffer in */
+ memcpy(*ppUnPackBuf, *ppBuf, ulBufLen);
+ /* Update the parsing buffer counters */
+ *ppBuf += ulBufLen;
+ *pulLen -= ulBufLen;
+ } else {
+ retVal = HXR_OUTOFMEMORY;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_unpack_array(BYTE** ppBuf,
+ UINT32* pulLen,
+ UINT32 ulNumElem,
+ UINT32 ulElemSize,
+ void** ppArr,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (ppBuf && pulLen && *pulLen >= ulNumElem * ulElemSize &&
+ ppArr && fpMalloc && fpFree) {
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Do we have any elements? */
+ if (ulNumElem) {
+ /* If the array is already allocated, then free it */
+ if (*ppArr) {
+ fpFree(pUserMem, *ppArr);
+ *ppArr = HXNULL;
+ }
+ /* Allocate space for the array */
+ *ppArr = fpMalloc(pUserMem, ulNumElem * ulElemSize);
+ if (*ppArr) {
+ /* Is this a UINT32 or a UINT16? */
+ UINT32 i = 0;
+ if (ulElemSize == sizeof(UINT32)) {
+ /* Unpack UINT32s */
+ UINT32* pArr32 = (UINT32*) * ppArr;
+ for (i = 0; i < ulNumElem; i++) {
+ pArr32[i] = rm_unpack32(ppBuf, pulLen);
+ }
+ } else if (ulElemSize == sizeof(UINT16)) {
+ /* Unpack UINT16s */
+ UINT16* pArr16 = (UINT16*) * ppArr;
+ for (i = 0; i < ulNumElem; i++) {
+ pArr16[i] = rm_unpack16(ppBuf, pulLen);
+ }
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ } else {
+ retVal = HXR_OUTOFMEMORY;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+UINT32 rm_unpack32_from_byte_string(BYTE** ppBuf, UINT32* pulLen)
+{
+ UINT32 ulRet = 0;
+
+ if (ppBuf && *ppBuf && pulLen && *pulLen) {
+ UINT32 ulStrLen = rm_unpack8(ppBuf, pulLen);
+ if (ulStrLen == 4 && *pulLen >= ulStrLen) {
+ ulRet = rm_unpack32(ppBuf, pulLen);
+ }
+ }
+
+ return ulRet;
+}
diff --git a/audio_codec/libcook/pack_utils.h b/audio_codec/libcook/pack_utils.h
new file mode 100644
index 0000000..d5bf21f
--- a/dev/null
+++ b/audio_codec/libcook/pack_utils.h
@@ -0,0 +1,93 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: pack_utils.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef PACK_UTILS_H
+#define PACK_UTILS_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+
+/* Pack a 32-bit value big-endian */
+void rm_pack32(UINT32 ulValue, BYTE** ppBuf, UINT32* pulLen);
+/* Pack a 32-bit value little-endian */
+void rm_pack32_le(UINT32 ulValue, BYTE** ppBuf, UINT32* pulLen);
+/* Pack a 16-bit value big-endian */
+void rm_pack16(UINT16 usValue, BYTE** ppBuf, UINT32* pulLen);
+/* Pack a 16-bit value little-endian */
+void rm_pack16_le(UINT16 usValue, BYTE** ppBuf, UINT32* pulLen);
+void rm_pack8(BYTE ucValue, BYTE** ppBuf, UINT32* pulLen);
+
+/* Unpacking utilties */
+UINT32 rm_unpack32(BYTE** ppBuf, UINT32* pulLen);
+UINT16 rm_unpack16(BYTE** ppBuf, UINT32* pulLen);
+/* rm_unpack32() and rm_unpack16() have the side
+ * effect of incrementing *ppBuf and decrementing
+ * *pulLen. The functions below (rm_unpack32_nse()
+ * rm_unpack16_nse()) do not change pBuf and ulLen.
+ * That is, they have No Side Effect, hence the suffix
+ * _nse.
+ */
+UINT32 rm_unpack32_nse(BYTE* pBuf, UINT32 ulLen);
+UINT16 rm_unpack16_nse(BYTE* pBuf, UINT32 ulLen);
+BYTE rm_unpack8(BYTE** ppBuf, UINT32* pulLen);
+HX_RESULT rm_unpack_string(BYTE** ppBuf,
+ UINT32* pulLen,
+ UINT32 ulStrLen,
+ char** ppStr,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+HX_RESULT rm_unpack_buffer(BYTE** ppBuf,
+ UINT32* pulLen,
+ UINT32 ulBufLen,
+ BYTE** ppUnPackBuf,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+HX_RESULT rm_unpack_array(BYTE** ppBuf,
+ UINT32* pulLen,
+ UINT32 ulNumElem,
+ UINT32 ulElemSize,
+ void** ppArr,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+
+UINT32 rm_unpack32_from_byte_string(BYTE** ppBuf, UINT32* pulLen);
+
+#endif /* #ifndef PACK_UTILS_H */
diff --git a/audio_codec/libcook/packet_defines.h b/audio_codec/libcook/packet_defines.h
new file mode 100644
index 0000000..5339f36
--- a/dev/null
+++ b/audio_codec/libcook/packet_defines.h
@@ -0,0 +1,48 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: packet_defines.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef PACKET_DEFINES_H
+#define PACKET_DEFINES_H
+
+#define HX_KEYFRAME_FLAG 0x0002
+#define HX_KEYFRAME_RULE 0
+#define HX_NONKEYFRAME_RULE 1
+#define HX_THINNING_RULE 2
+#define HX_ASM_SWITCH_ON 1
+#define HX_ASM_SWITCH_OFF 2
+
+#endif /* #ifndef PACKET_DEFINES_H */
diff --git a/audio_codec/libcook/ra8lbr_decode.c b/audio_codec/libcook/ra8lbr_decode.c
new file mode 100644
index 0000000..729d99c
--- a/dev/null
+++ b/audio_codec/libcook/ra8lbr_decode.c
@@ -0,0 +1,378 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: ra8lbr_decode.c,v 1.2.2.1 2005/05/04 18:21:53 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+//#include <string.h>
+//#include <core/dsp.h>
+#include "helix_types.h"
+#include "helix_result.h"
+#include "ra8lbr_decode.h"
+#include "ra_format_info.h"
+#include "gecko2codec.h"
+#include <stdio.h>
+
+#define GECKO_VERSION ((1L<<24)|(0L<<16)|(0L<<8)|(3L))
+#define GECKO_MC1_VERSION ((2L<<24)|(0L<<16)|(0L<<8)|(0L))
+
+HX_RESULT ra8lbr_unpack_opaque_data(ra8lbr_data* pData,
+ UINT8* pBuf,
+ UINT32 ulLength);
+
+/*
+ * ra8lbr_decode_init
+ */
+HX_RESULT
+ra8lbr_decode_init(void* pInitParams,
+ UINT32 ulInitParamsSize,
+ ra_format_info* pStreamInfo,
+ void** pDecode,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree)
+{
+ HX_RESULT retVal = HXR_FAIL;
+ ra8lbr_decode* pDec;
+ ra8lbr_data unpackedData;
+ UINT32 nChannels, frameSizeInBits;
+
+ pDec = (ra8lbr_decode*) fpMalloc(pUserMem, sizeof(ra8lbr_decode));
+
+ if (pDec) {
+ memset(pDec, 0, sizeof(ra8lbr_decode));
+ *pDecode = (void *)pDec;
+ retVal = ra8lbr_unpack_opaque_data(&unpackedData,
+ pStreamInfo->pOpaqueData,
+ pStreamInfo->ulOpaqueDataSize);
+
+ if (retVal == HXR_OK) {
+ /* save the stream info and init data we'll need later */
+ pDec->ulNumChannels = (UINT32)pStreamInfo->usNumChannels;
+ pDec->ulFrameSize = pStreamInfo->ulBitsPerFrame;
+ pDec->ulFramesPerBlock = pStreamInfo->ulGranularity / pDec->ulFrameSize;
+ pDec->ulSamplesPerFrame = unpackedData.nSamples;
+ pDec->ulSampleRate = pStreamInfo->ulSampleRate;
+
+ /* multichannel not supported, use simple logic for channel mask */
+ if (pDec->ulNumChannels == 1) {
+ pDec->ulChannelMask = 0x00004;
+ } else if (pDec->ulNumChannels == 2) {
+ pDec->ulChannelMask = 0x00003;
+ } else {
+ pDec->ulChannelMask = 0x00003;
+ }
+ if (pDec->ulNumChannels > 2) {
+ pDec->ulNumChannels = 2;
+ }
+ nChannels = pDec->ulNumChannels;
+ frameSizeInBits = pDec->ulFrameSize * 8;
+
+ /* initialize the decoder backend and save a reference to it */
+
+ pDec->pDecoder = Gecko2InitDecoder(pDec->ulSamplesPerFrame / nChannels,
+ nChannels,
+ unpackedData.nRegions,
+ frameSizeInBits,
+ pDec->ulSampleRate,
+ unpackedData.cplStart,
+ unpackedData.cplQBits,
+ (INT32 *)&pDec->ulDelayFrames);
+
+ /* Allocate a dummy input frame for flushing the decoder */
+ pDec->pFlushData = (UCHAR *) fpMalloc(pUserMem, pDec->ulFrameSize);
+
+ if (pDec->pDecoder == HXNULL || pDec->pFlushData == HXNULL) {
+ retVal = HXR_FAIL;
+ } else {
+ /* fill the dummy input frame with zeros */
+ memset(pDec->pFlushData, 0, pDec->ulFrameSize);
+
+ /* Set number of delay samples to discard on decoder start */
+ pDec->ulDelayRemaining = pDec->ulDelayFrames * pDec->ulSamplesPerFrame;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT
+ra8lbr_decode_reset(void* pDecode,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut)
+{
+ HX_RESULT retVal = HXR_FAIL;
+ ra8lbr_decode* pDec = (ra8lbr_decode*) pDecode;
+ UINT32 n, framesToDecode;
+
+ *pNumSamplesOut = 0;
+
+ if (pSamplesOut != HXNULL) {
+ framesToDecode = pDec->ulDelayFrames;
+ if (framesToDecode * pDec->ulSamplesPerFrame > ulNumSamplesAvail) {
+ framesToDecode = ulNumSamplesAvail / pDec->ulSamplesPerFrame;
+ }
+
+ for (n = 0; n < framesToDecode; n++) {
+ retVal = Gecko2Decode(pDec->pDecoder, pDec->pFlushData,
+ 0xFFFFFFFFUL, (INT16 *)pSamplesOut + *pNumSamplesOut, 0);
+ *pNumSamplesOut += pDec->ulSamplesPerFrame;
+ }
+
+ /* reset the delay compensation */
+ pDec->ulDelayRemaining = pDec->ulDelayFrames * pDec->ulSamplesPerFrame;
+ }
+
+ return retVal;
+}
+
+HX_RESULT
+ra8lbr_decode_conceal(void* pDecode,
+ UINT32 ulNumSamples)
+{
+ ra8lbr_decode* pDec = (ra8lbr_decode*) pDecode;
+ pDec->ulFramesToConceal = ulNumSamples / pDec->ulSamplesPerFrame;
+
+ return HXR_OK;
+}
+
+HX_RESULT
+ra8lbr_decode_decode(void* pDecode,
+ UINT8* pData,
+ UINT32 ulNumBytes,
+ UINT32* pNumBytesConsumed,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut,
+ UINT32 ulFlags,
+ UINT32 ulTimeStamp)
+{
+ HX_RESULT retVal = HXR_FAIL;
+ ra8lbr_decode* pDec = (ra8lbr_decode*) pDecode;
+ UINT32 n, framesToDecode, lostFlag;
+ UINT8* inBuf = pData;
+ UINT16* outBuf = pSamplesOut;
+
+ *pNumBytesConsumed = 0;
+ *pNumSamplesOut = 0;
+ framesToDecode = 0;
+
+ if (pDec->ulFramesToConceal != 0) {
+ if (pDec->ulFramesToConceal > ulNumSamplesAvail / pDec->ulSamplesPerFrame) {
+ framesToDecode = ulNumSamplesAvail / pDec->ulSamplesPerFrame;
+ pDec->ulFramesToConceal -= framesToDecode;
+ } else {
+ framesToDecode = pDec->ulFramesToConceal;
+ pDec->ulFramesToConceal = 0;
+ }
+
+ inBuf = pDec->pFlushData;
+
+ for (n = 0; n < framesToDecode; n++) {
+ retVal = Gecko2Decode(pDec->pDecoder, inBuf, 0xFFFFFFFFUL, (INT16 *)outBuf, ulTimeStamp);
+
+ if (retVal != 0) {
+ retVal = HXR_FAIL;
+ break;
+ }
+
+ outBuf += pDec->ulSamplesPerFrame;
+ *pNumSamplesOut += pDec->ulSamplesPerFrame;
+ }
+ } else if (ulNumBytes % pDec->ulFrameSize == 0) {
+ framesToDecode = ulNumBytes / pDec->ulFrameSize;
+
+ if (framesToDecode > ulNumSamplesAvail / pDec->ulSamplesPerFrame) {
+ framesToDecode = ulNumSamplesAvail / pDec->ulSamplesPerFrame;
+ }
+
+ for (n = 0; n < framesToDecode; n++) {
+ lostFlag = !((ulFlags >> n) & 1);
+
+ retVal = Gecko2Decode(pDec->pDecoder, inBuf, lostFlag, (INT16 *)outBuf, ulTimeStamp);
+
+ if (retVal != 0) {
+ retVal = HXR_FAIL;
+ break;
+ }
+
+ inBuf += pDec->ulFrameSize;
+ *pNumBytesConsumed += pDec->ulFrameSize;
+ outBuf += pDec->ulSamplesPerFrame;
+ *pNumSamplesOut += pDec->ulSamplesPerFrame;
+ }
+ }
+
+ /* Discard invalid output samples */
+ if (retVal == HXR_FAIL) { /* decoder error */
+ *pNumSamplesOut = 0;
+ /* protect consumer ears by zeroing the output buffer,
+ just in case the error return code is disregarded. */
+ memset(pSamplesOut, 0, pDec->ulSamplesPerFrame * framesToDecode * sizeof(UINT16));
+ } else if (pDec->ulDelayRemaining > 0) { /* delay samples */
+ if (pDec->ulDelayRemaining >= *pNumSamplesOut) {
+ pDec->ulDelayRemaining -= *pNumSamplesOut;
+ *pNumSamplesOut = 0;
+ } else {
+ *pNumSamplesOut -= pDec->ulDelayRemaining;
+ memmove(pSamplesOut, pSamplesOut + pDec->ulDelayRemaining, *pNumSamplesOut);
+ pDec->ulDelayRemaining = 0;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT
+ra8lbr_decode_getmaxsize(void* pDecode,
+ UINT32* pNumSamples)
+{
+ ra8lbr_decode* pDec = (ra8lbr_decode *)pDecode;
+ *pNumSamples = pDec->ulSamplesPerFrame * pDec->ulFramesPerBlock;
+
+ return HXR_OK;
+}
+
+HX_RESULT
+ra8lbr_decode_getchannels(void* pDecode,
+ UINT32* pNumChannels)
+{
+ ra8lbr_decode* pDec = (ra8lbr_decode *)pDecode;
+ *pNumChannels = pDec->ulNumChannels;
+
+ return HXR_OK;
+}
+
+HX_RESULT
+ra8lbr_decode_getchannelmask(void* pDecode,
+ UINT32* pChannelMask)
+{
+ ra8lbr_decode* pDec = (ra8lbr_decode *)pDecode;
+ *pChannelMask = pDec->ulChannelMask;
+ return HXR_OK;
+}
+
+HX_RESULT
+ra8lbr_decode_getrate(void* pDecode,
+ UINT32* pSampleRate)
+{
+ ra8lbr_decode* pDec = (ra8lbr_decode *)pDecode;
+ *pSampleRate = pDec->ulSampleRate;
+
+ return HXR_OK;
+}
+
+HX_RESULT
+ra8lbr_decode_getdelay(void* pDecode,
+ UINT32* pNumSamples)
+{
+ ra8lbr_decode* pDec = (ra8lbr_decode *)pDecode;
+ /* delay compensation is handled internally */
+ *pNumSamples = 0;
+
+ return HXR_OK;
+}
+
+HX_RESULT
+ra8lbr_decode_close(void* pDecode,
+ void* pUserMem,
+ rm_free_func_ptr fpFree)
+{
+ ra8lbr_decode* pDec = (ra8lbr_decode *)pDecode;
+ /* free the ra8lbr decoder */
+ if (pDec->pDecoder) {
+ Gecko2FreeDecoder(pDec->pDecoder);
+ }
+ /* free the dummy input buffer */
+ if (pDec->pFlushData) {
+ fpFree(pUserMem, pDec->pFlushData);
+ }
+ /* free the ra8lbr backend */
+ fpFree(pUserMem, pDec);
+
+ return HXR_OK;
+}
+
+HX_RESULT
+ra8lbr_unpack_opaque_data(ra8lbr_data* pData,
+ UINT8* pBuf,
+ UINT32 ulLength)
+{
+ HX_RESULT retVal = HXR_FAIL;
+ UINT8* off = pBuf;
+
+ if (pBuf != HXNULL && ulLength != 0) {
+ retVal = HXR_OK;
+
+ pData->version = ((INT32) * off++) << 24;
+ pData->version |= ((INT32) * off++) << 16;
+ pData->version |= ((INT32) * off++) << 8;
+ pData->version |= ((INT32) * off++);
+
+ pData->nSamples = *off++ << 8;
+ pData->nSamples |= *off++;
+
+ pData->nRegions = *off++ << 8;
+ pData->nRegions |= *off++;
+ //printk("version %d, sample per frame %d \n",pData->version,pData->nSamples);
+ if (pData->version >= GECKO_VERSION) {
+ pData->delay = ((INT32) * off++) << 24;
+ pData->delay |= ((INT32) * off++) << 16;
+ pData->delay |= ((INT32) * off++) << 8;
+ pData->delay |= ((INT32) * off++);
+
+ pData->cplStart = *off++ << 8;
+ pData->cplStart |= *off++;
+
+ pData->cplQBits = *off++ << 8;
+ pData->cplQBits |= *off++;
+ } else {
+ /* the fixed point ra8lbr decoder supports dual-mono decoding with
+ a single decoder instance if cplQBits is set to zero. */
+ pData->cplStart = 0;
+ pData->cplQBits = 0;
+ }
+
+ if (pData->version == GECKO_MC1_VERSION) {
+ pData->channelMask = ((INT32) * off++) << 24;
+ pData->channelMask |= ((INT32) * off++) << 16;
+ pData->channelMask |= ((INT32) * off++) << 8;
+ pData->channelMask |= ((INT32) * off++);
+ }
+ }
+
+ return retVal;
+}
diff --git a/audio_codec/libcook/ra8lbr_decode.h b/audio_codec/libcook/ra8lbr_decode.h
new file mode 100644
index 0000000..ef39e6f
--- a/dev/null
+++ b/audio_codec/libcook/ra8lbr_decode.h
@@ -0,0 +1,161 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: ra8lbr_decode.h,v 1.2.2.1 2005/05/04 18:21:53 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RA8LBR_DECODE_H
+#define RA8LBR_DECODE_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "ra_decode.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* ra8lbr decode struct */
+ typedef struct ra8lbr_decode_struct {
+ void* pDecoder;
+ UINT32 ulNumChannels;
+ UINT32 ulChannelMask;
+ UINT32 ulFrameSize;
+ UINT32 ulFramesPerBlock;
+ UINT32 ulSamplesPerFrame;
+ UINT32 ulSampleRate;
+ UINT32 ulDelayFrames;
+ UINT32 ulDelayRemaining;
+ UINT32 ulFramesToConceal;
+ UCHAR* pFlushData;
+ } ra8lbr_decode;
+
+ /* ra8lbr opaque data struct */
+ typedef struct ra8lbr_data_struct {
+ INT32 version;
+ INT16 nSamples;
+ INT16 nRegions;
+ INT32 delay;
+ UINT16 cplStart ;
+ UINT16 cplQBits ;
+ INT32 channelMask ;
+ } ra8lbr_data;
+
+ /* ra8lbr decode interface */
+
+ /*
+ * ra8lbr_decode_init
+ */
+ HX_RESULT ra8lbr_decode_init(void* pInitParams,
+ UINT32 ulInitParamsSize,
+ ra_format_info* pStreamInfo,
+ void** pDecode,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+
+ /*
+ * ra8lbr_decode_reset
+ */
+ HX_RESULT ra8lbr_decode_reset(void* pDecode,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut);
+
+ /*
+ * ra8lbr_decode_conceal
+ */
+ HX_RESULT ra8lbr_decode_conceal(void* pDecode,
+ UINT32 ulNumSamples);
+
+ /*
+ * ra8lbr_decode_decode
+ */
+ HX_RESULT ra8lbr_decode_decode(void* pDecode,
+ UINT8* pData,
+ UINT32 ulNumBytes,
+ UINT32* pNumBytesConsumed,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut,
+ UINT32 ulFlags,
+ UINT32 ulTimeStamp);
+
+ /*
+ * ra8lbr_decode_getmaxsize
+ */
+ HX_RESULT ra8lbr_decode_getmaxsize(void* pDecode,
+ UINT32* pNumSamples);
+
+ /*
+ * ra8lbr_decode_getchannels
+ */
+ HX_RESULT ra8lbr_decode_getchannels(void* pDecode,
+ UINT32* pNumChannels);
+
+ /*
+ * ra8lbr_decode_getchannelmask
+ */
+ HX_RESULT ra8lbr_decode_getchannelmask(void* pDecode,
+ UINT32* pChannelMask);
+
+ /*
+ * ra8lbr_decode_getrate
+ */
+ HX_RESULT ra8lbr_decode_getrate(void* pDecode,
+ UINT32* pSampleRate);
+
+ /*
+ * ra8lbr_decode_getdelay
+ */
+ HX_RESULT ra8lbr_decode_getdelay(void* pDecode,
+ UINT32* pNumSamples);
+
+ /*
+ * ra8lbr_decode_close
+ */
+ HX_RESULT ra8lbr_decode_close(void* pDecode,
+ void* pUserMem,
+ rm_free_func_ptr fpFree);
+
+ HX_RESULT ra8lbr_unpack_opaque_data(ra8lbr_data* pData,
+ UINT8* pBuf,
+ UINT32 ulLength);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RA8LBR_DECODE_H */
diff --git a/audio_codec/libcook/ra_backend.h b/audio_codec/libcook/ra_backend.h
new file mode 100644
index 0000000..d351c5b
--- a/dev/null
+++ b/audio_codec/libcook/ra_backend.h
@@ -0,0 +1,94 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: ra_backend.h,v 1.2.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RA_BACKEND_H__
+#define RA_BACKEND_H__
+
+/* Unified RealAudio decoder backend interface */
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+#include "ra_format_info.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* ra decoder backend interface */
+
+ typedef HX_RESULT(*ra_decode_init_func_ptr)(void* pInitParams,
+ UINT32 ulInitParamsSize,
+ ra_format_info* pStreamInfo,
+ void** pDecode,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+ typedef HX_RESULT(*ra_decode_reset_func_ptr)(void* pDecode,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut);
+ typedef HX_RESULT(*ra_decode_conceal_func_ptr)(void* pDecode,
+ UINT32 ulNumSamples);
+ typedef HX_RESULT(*ra_decode_decode_func_ptr)(void* pDecode,
+ UINT8* pData,
+ UINT32 ulNumBytes,
+ UINT32* pNumBytesConsumed,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut,
+ UINT32 ulFlags,
+ UINT32 ulTimeStamp);
+ typedef HX_RESULT(*ra_decode_getmaxsize_func_ptr)(void* pDecode,
+ UINT32* pNumSamples);
+ typedef HX_RESULT(*ra_decode_getchannels_func_ptr)(void* pDecode,
+ UINT32* pNumChannels);
+ typedef HX_RESULT(*ra_decode_getchannelmask_func_ptr)(void* pDecode,
+ UINT32* pChannelMask);
+ typedef HX_RESULT(*ra_decode_getrate_func_ptr)(void* pDecode,
+ UINT32* pSampleRate);
+ typedef HX_RESULT(*ra_decode_getdelay_func_ptr)(void* pDecode,
+ UINT32* pNumSamples);
+ typedef HX_RESULT(*ra_decode_close_func_ptr)(void* pDecode,
+ void* pUserMem,
+ rm_free_func_ptr fpFree);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RA_BACKEND_H__ */
diff --git a/audio_codec/libcook/ra_bitpack.c b/audio_codec/libcook/ra_bitpack.c
new file mode 100644
index 0000000..d9181db
--- a/dev/null
+++ b/audio_codec/libcook/ra_bitpack.c
@@ -0,0 +1,197 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: bitpack.c,v 1.6 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * bitpack.c - bitstream parsing functions
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+const unsigned char pkkey[4] = { 0x37, 0xc5, 0x11, 0xf2 };
+
+/**************************************************************************************
+ * Function: GetBits
+ *
+ * Description: get bits from bitstream, optionally advance bitstream pointer
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ * number of bits to get from bitstream
+ * flag to indicate whether to advance bitstream pointer or not
+ *
+ * Outputs: updated bitstream info struct (if advanceFlag set)
+ *
+ * Return: the next nBits bits of data from bitstream buffer (right-justified)
+ *
+ * Notes: nBits must be in range [0, 31], nBits outside this range masked by 0x1f
+ * for speed, does not indicate error if you overrun bit buffer
+ * if nBits = 0, returns 0
+ * applies XOR key when reading (rather than using out-of-place buffer)
+ * reads byte-at-a-time (not cached 32-bit ints) so not designed to be
+ * especially fast (i.e. handy for Huffman decoding of a few symbols,
+ * but not optimal for decoding long sequences of codewords)
+ **************************************************************************************/
+unsigned int GetBits(BitStreamInfo *bsi, int nBits, int advanceFlag)
+{
+ int readBits, off, key, nBytes;
+ unsigned int data;
+ unsigned char *buf;
+
+ nBits &= 0x1f;
+ if (!nBits) {
+ return 0;
+ }
+
+ buf = bsi->buf;
+ off = bsi->off;
+ key = bsi->key;
+
+ /* first, partial byte */
+ data = ((unsigned int)(*buf++ ^ pkkey[key++])) << (24 + off);
+ key &= 0x03;
+ readBits = 8 - off;
+
+ /* whole bytes */
+ while (readBits < nBits && readBits <= 24) {
+ data |= ((unsigned int)(*buf++ ^ pkkey[key++])) << (24 - readBits);
+ key &= 0x03;
+ readBits += 8;
+ }
+
+ /* final, partial byte (no need to update local key and readBits) */
+ if (readBits < nBits) {
+ data |= ((unsigned int)(*buf++ ^ pkkey[key])) >> (readBits - 24);
+ }
+
+ if (advanceFlag) {
+ nBytes = (bsi->off + nBits) >> 3;
+ bsi->buf += nBytes;
+ bsi->off = (bsi->off + nBits) & 0x07;
+ bsi->key = (bsi->key + nBytes) & 0x03;
+ }
+
+ return (data >> (32 - nBits));
+}
+
+/**************************************************************************************
+ * Function: AdvanceBitstream
+ *
+ * Description: move bitstream pointer ahead
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ * number of bits to advance bitstream
+ *
+ * Outputs: updated bitstream info struct
+ *
+ * Return: none
+ *
+ * Notes: generally use following a GetBits(bsi, maxBits, 0) (i.e. no advance)
+ **************************************************************************************/
+void AdvanceBitstream(BitStreamInfo *bsi, int nBits)
+{
+ int nBytes;
+
+ nBytes = (bsi->off + nBits) >> 3;
+ bsi->buf += nBytes;
+ bsi->off = (bsi->off + nBits) & 0x07;
+ bsi->key = (bsi->key + nBytes) & 0x03;
+}
+
+/**************************************************************************************
+ * Function: DecodeSideInfo
+ *
+ * Description: parse bitstream and decode gain info, coupling info, power envelope,
+ * and categorization code
+ *
+ * Inputs: pointer to initialized Gecko2Info struct
+ * pointer to bitstream buffer (byte-aligned)
+ * number of bits available in buf
+ * channel index
+ *
+ * Outputs: filled-in dgainc structs, channel coupling indices (if joint stereo),
+ * power envelope index for each region,
+ * and rate code (selected categorization)
+ *
+ * Return: number of bits remaining in bitstream, -1 if out-of-bits
+ *
+ * Notes: encoder guarantees that gain, couple, envelope, and rateCode do
+ * not run out of bits
+ **************************************************************************************/
+int DecodeSideInfo(Gecko2Info *gi, unsigned char *buf, int availbits, int ch)
+{
+ BitStreamInfo *bsi = &(gi->bsi);
+
+ /* init bitstream reader */
+ bsi->buf = buf;
+ bsi->off = 0;
+ bsi->key = 0;
+
+ /* decode gain info */
+ availbits = DecodeGainInfo(gi, &(gi->dgainc[ch][1]), availbits);
+ if (availbits < 0) {
+ return -1;
+ }
+
+ /* replicate gain control and decode coupling info, if joint stereo */
+ if (gi->jointStereo) {
+ ASSERT(ch == 0);
+ CopyGainInfo(&gi->dgainc[1][1], &gi->dgainc[0][1]);
+ availbits = DecodeCoupleInfo(gi, availbits);
+ if (availbits < 0) {
+ return -1;
+ }
+ }
+
+ /* decode power envelope (return error if runs out of bits) */
+ availbits = DecodeEnvelope(gi, availbits, ch);
+ if (availbits < 0) {
+ return -1;
+ }
+
+ /* decode rate code (return error if runs out of bits) */
+ if (availbits < gi->rateBits) {
+ return -1;
+ }
+ gi->rateCode = GetBits(bsi, gi->rateBits, 1);
+ availbits -= gi->rateBits;
+
+ return availbits;
+}
diff --git a/audio_codec/libcook/ra_buffers.c b/audio_codec/libcook/ra_buffers.c
new file mode 100644
index 0000000..28aea79
--- a/dev/null
+++ b/audio_codec/libcook/ra_buffers.c
@@ -0,0 +1,127 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: buffers.c,v 1.2 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * buffers.c - allocation and freeing of internal RA8 decoder buffers
+ *
+ * All memory allocation for the codec is done in this file, so if you want
+ * to use something other the default malloc() and free() this is the only file
+ * you'll need to change.
+ **************************************************************************************/
+
+//#include "includes.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include "coder.h"
+
+/**************************************************************************************
+ * Function: ClearBuffer
+ *
+ * Description: fill buffer with 0's
+ *
+ * Inputs: pointer to buffer
+ * number of bytes to fill with 0
+ *
+ * Outputs: cleared buffer
+ *
+ * Return: none
+ *
+ * Notes: slow, platform-independent equivalent to memset(buf, 0, nBytes)
+ **************************************************************************************/
+static void ClearBuffer(void *buf, int nBytes)
+{
+ int i;
+ unsigned char *cbuf = (unsigned char *)buf;
+
+ //for (i = 0; i < nBytes; i++)
+ // cbuf[i] = 0;
+ memset(cbuf, 0, nBytes);
+ return;
+}
+
+/**************************************************************************************
+ * Function: AllocateBuffers
+ *
+ * Description: allocate all the memory needed for the RA8 decoder
+ *
+ * Inputs: none
+ *
+ * Outputs: none
+ *
+ * Return: pointer to Gecko2Info structure, set to all 0's
+ **************************************************************************************/
+Gecko2Info *AllocateBuffers(void)
+{
+ Gecko2Info *gi;
+
+ /* create new Gecko2Info structure */
+ gi = (Gecko2Info *)malloc(sizeof(Gecko2Info));
+ if (!gi) {
+ return 0;
+ }
+ ClearBuffer(gi, sizeof(Gecko2Info));
+
+ return gi;
+}
+
+#define SAFE_FREE(x) {if (x) free(x); (x) = 0;} /* helper macro */
+
+/**************************************************************************************
+ * Function: FreeBuffers
+ *
+ * Description: free all the memory used by the RA8 decoder
+ *
+ * Inputs: pointer to initialized Gecko2Info structure
+ *
+ * Outputs: none
+ *
+ * Return: none
+ **************************************************************************************/
+void FreeBuffers(Gecko2Info *gi)
+{
+ if (!gi) {
+ return;
+ }
+
+ SAFE_FREE(gi);
+}
diff --git a/audio_codec/libcook/ra_category.c b/audio_codec/libcook/ra_category.c
new file mode 100644
index 0000000..4412eb6
--- a/dev/null
+++ b/audio_codec/libcook/ra_category.c
@@ -0,0 +1,298 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: category.c,v 1.4 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Ken Cooke (kenc@real.com), Jon Recker (jrecker@real.com)
+ * October 2003
+ *
+ * category.c - derivation of categorization (i.e. quantizer settings) for each frame
+ *
+ * This is Ken's super-fast version
+ * - uses incrementally updated heaps
+ * - 3x speedup vs. original
+ *
+ * Discussion of calculating the categories:
+ * This is a symmetrical operation, so the decoder goes through
+ * the same process as the encoder when computing the categorizations.
+ * The decoder first calculates a max bits/fine quantizer initial
+ * categorization based on a perceptual masking model. Then it
+ * builds them all and chooses the one given by rateCode,
+ * which is extracted from the bitstream.
+ *
+ * rmsIndex[i] is the RMS power of region i
+ * NCATZNS = (1 << RATEBITS) = max number of categorizations we can try
+ *
+ * cat runs from 0 to 7. Lower number means finer quantization.
+ * expbits_tab[i] tells us how many bits we should expect to spend
+ * coding a region with cat = i
+ **************************************************************************************/
+
+#include "coder.h"
+
+/* heap indexing, where heap[1] is root */
+#define PARENT(i) ((i) >> 1)
+#define LCHILD(i) ((i) << 1)
+#define RCHILD(i) (LCHILD(i)+1)
+
+static const int expbits_tab[8] = { 52, 47, 43, 37, 29, 22, 16, 0 };
+
+/**************************************************************************************
+ * Function: CategorizeAndExpand
+ *
+ * Description: derive the quantizer setting for each region, based on decoded power
+ * envelope, number of bits available, and rateCode index
+ *
+ * Inputs: pointer to initialized Gecko2Info struct
+ * number of bits remaining in bitstream for this frame
+ *
+ * Outputs: catbuf[], which contains the correct quantizer index (cat) for each
+ * region, based on the rateCode read from bitstream
+ *
+ * Return: none
+ **************************************************************************************/
+void CategorizeAndExpand(Gecko2Info *gi, int availbits)
+{
+ int r, n, k, val;
+ int offset, delta, cat;
+ int expbits, maxbits, minbits;
+ int maxptr, minptr;
+ int nminheap = 0, nmaxheap = 0;
+ int *cp;
+ int *maxcat = gi->db.maxcat;
+ int *mincat = gi->db.mincat;
+ int *changes = gi->db.changes;
+ int *maxheap = gi->db.maxheap;
+ int *minheap = gi->db.minheap;
+ int *rmsIndex = gi->db.rmsIndex;
+ int *catbuf = gi->db.catbuf;
+ int rateCode = gi->rateCode;
+
+ /* it's okay not to zero-init maxheap/minheap[1 ... MAXCREGN]
+ * we don't read maxheap/minheap[1+] without putting something in them first
+ */
+ maxheap[0] = 0x7fffffff; /* upheap sentinel */
+ minheap[0] = 0x80000000; /* upheap sentinel */
+
+ /* Hack to compensate for different statistics at higher bits/sample */
+ if (availbits > gi->nSamples) {
+ availbits = gi->nSamples + ((availbits - gi->nSamples) * 5 / 8);
+ }
+ /*
+ * Initial categorization.
+ *
+ * This attempts to assigns categories to regions using
+ * a simple approximation of perceptual masking.
+ * Offset is chosen via binary search for desired bits.
+ */
+ offset = -32; /* start with minimum offset */
+ for (delta = 32; delta > 0; delta >>= 1) {
+
+ expbits = 0;
+ for (r = 0; r < gi->cRegions; r++) {
+
+ /* Test categorization at (offset+delta) */
+ cat = (offset + delta - rmsIndex[r]) / 2;
+ if (cat < 0) {
+ cat = 0; /* clip */
+ }
+ if (cat > 7) {
+ cat = 7; /* clip */
+ }
+ expbits += expbits_tab[cat]; /* tally expected bits */
+ }
+ /* Find largest offset such that (expbits >= availbits-32) */
+ if (expbits >= availbits - 32) { /* if still over budget, */
+ offset += delta; /* choose increased offset */
+ }
+ }
+
+ /* Use the selected categorization */
+ expbits = 0;
+ for (r = 0; r < gi->cRegions; r++) {
+ cat = (offset - rmsIndex[r]) / 2;
+ if (cat < 0) {
+ cat = 0; /* clip */
+ }
+ if (cat > 7) {
+ cat = 7; /* clip */
+ }
+ expbits += expbits_tab[cat];
+ mincat[r] = cat; /* init */
+ maxcat[r] = cat; /* init */
+
+ val = offset - rmsIndex[r] - 2 * cat;
+ val = (val << 16) | r; /* max favors high r, min favors low r */
+
+ /* build maxheap */
+ if (cat < 7) {
+ /* insert at heap[N+1] */
+ k = ++nmaxheap;
+ maxheap[k] = val;
+ /* upheap */
+ while (val > maxheap[PARENT(k)]) {
+ maxheap[k] = maxheap[PARENT(k)];
+ k = PARENT(k);
+ }
+ maxheap[k] = val;
+ }
+
+ /* build minheap */
+ if (cat > 0) {
+ /* insert at heap[N+1] */
+ k = ++nminheap;
+ minheap[k] = val;
+ /* upheap */
+ while (val < minheap[PARENT(k)]) {
+ minheap[k] = minheap[PARENT(k)];
+ k = PARENT(k);
+ }
+ minheap[k] = val;
+ }
+ }
+
+ /* init */
+ minbits = expbits;
+ maxbits = expbits;
+ minptr = gi->nCatzns; /* grows up, post-increment */
+ maxptr = gi->nCatzns; /* grows down, pre-decrement */
+
+ /*
+ * Derive additional categorizations.
+ *
+ * Each new categorization differs from the last in a single region,
+ * where the categories differ by one, and are ordered by decreasing
+ * expected bits.
+ */
+ for (n = 1; n < gi->nCatzns; n++) {
+ /* Choose whether new cat should have larger/smaller bits */
+
+ if (maxbits + minbits <= 2 * availbits) {
+ /* if average is low, add one with more bits */
+ if (!nminheap) {
+ /* printf("all quants at min\n"); */
+ break;
+ }
+ r = minheap[1] & 0xffff;
+
+ /* bump the chosen region */
+ changes[--maxptr] = r; /* add to change list */
+ maxbits -= expbits_tab[maxcat[r]]; /* sub old bits */
+ maxcat[r] -= 1; /* dec category */
+ maxbits += expbits_tab[maxcat[r]]; /* add new bits */
+
+ /* update heap[1] */
+ k = 1;
+ if (maxcat[r] == 0) {
+ minheap[k] = minheap[nminheap--]; /* remove */
+ } else {
+ minheap[k] += (2 << 16); /* update */
+ }
+
+ /* downheap */
+ val = minheap[k];
+ while (k <= PARENT(nminheap)) {
+ int child = LCHILD(k);
+ int right = RCHILD(k);
+ if ((right <= nminheap) && (minheap[right] < minheap[child])) {
+ child = right;
+ }
+ if (val < minheap[child]) {
+ break;
+ }
+ minheap[k] = minheap[child];
+ k = child;
+ }
+ minheap[k] = val;
+
+ } else {
+ /* average is high, add one with less bits */
+ if (!nmaxheap) {
+ /* printf("all quants at max\n"); */
+ break;
+ }
+ r = maxheap[1] & 0xffff;
+
+ /* bump the chosen region */
+ changes[minptr++] = r; /* add to change list */
+ minbits -= expbits_tab[mincat[r]]; /* sub old bits */
+ mincat[r] += 1; /* inc category */
+ minbits += expbits_tab[mincat[r]]; /* add new bits */
+
+ /* update heap[1] */
+ k = 1;
+ if (mincat[r] == 7) {
+ maxheap[k] = maxheap[nmaxheap--]; /* remove */
+ } else {
+ maxheap[k] -= (2 << 16); /* update */
+ }
+
+ /* downheap */
+ val = maxheap[k];
+ while (k <= PARENT(nmaxheap)) {
+ int child = LCHILD(k);
+ int right = RCHILD(k);
+ if ((right <= nmaxheap) && (maxheap[right] > maxheap[child])) {
+ child = right;
+ }
+ if (val > maxheap[child]) {
+ break;
+ }
+ maxheap[k] = maxheap[child];
+ k = child;
+ }
+ maxheap[k] = val;
+ }
+ }
+
+ /* largest categorization */
+ for (r = 0; r < gi->cRegions; r++) {
+ catbuf[r] = maxcat[r];
+ }
+
+ /* make sure rateCode is not greater than number of changes in list */
+ ASSERT(rateCode <= (minptr - maxptr));
+
+ /* expand categories using change list, starting at max cat
+ * we change one region at a time (cat++ = coarser quantizer)
+ */
+ cp = &changes[maxptr];
+ while (rateCode--) {
+ catbuf[*cp++] += 1;
+ }
+
+}
diff --git a/audio_codec/libcook/ra_couple.c b/audio_codec/libcook/ra_couple.c
new file mode 100644
index 0000000..1f53c45
--- a/dev/null
+++ b/audio_codec/libcook/ra_couple.c
@@ -0,0 +1,224 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: couple.c,v 1.6 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * couple.c - joint stereo processing
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+/* coupling band widths, based on Zwicker critical-bandwidth */
+const int cplband[MAXREGNS] = {
+ 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
+};
+
+/* Lookup tables for reconstructed scaling factors - format = Q31 */
+static const int cplScale[3 + 7 + 15 + 31 + 63] = {
+
+ /* cplScale2[3] */
+ 0x79fc945f, 0x5a82799a, 0x26c59af8,
+
+ /* cplScale3[7] */
+ 0x7d9a93a4, 0x77ef8978, 0x701e9f27, 0x5a82799a,
+ 0x3dc04491, 0x2cb7094c, 0x18a6b4ed,
+
+ /* cplScale4[15] */
+ 0x7ee90962, 0x7c936c4f, 0x79fc9465, 0x770e9d8f,
+ 0x73a45b28, 0x6f749c4e, 0x69c04836, 0x5a82799a,
+ 0x481dac45, 0x3ef11955, 0x36df3415, 0x2f011d16,
+ 0x26c59ae8, 0x1d688afa, 0x10aaa6fd,
+
+ /* cplScale5[31] */
+ 0x7f7a8410, 0x7e66f9cf, 0x7d46e886, 0x7c18c36e,
+ 0x7adaa745, 0x798a3db9, 0x78249362, 0x76a5d7e1,
+ 0x7508f83e, 0x7346f452, 0x7155abbc, 0x6f257fbd,
+ 0x6c9c00f0, 0x6985577e, 0x655acbf3, 0x5a82799a,
+ 0x4e2ca29a, 0x4873cee8, 0x43bc1a9b, 0x3f7c6426,
+ 0x3b7ddcf1, 0x37a26159, 0x33d59802, 0x30072e43,
+ 0x2c27c13f, 0x28266a5d, 0x23edbab6, 0x1f5e6927,
+ 0x1a42fec7, 0x14294028, 0x0b8ab0db,
+
+ /* cplScale6[63] */
+ 0x7fbea8be, 0x7f39f9ab, 0x7eb28121, 0x7e281805,
+ 0x7d9a93a8, 0x7d09c543, 0x7c75796f, 0x7bdd7778,
+ 0x7b418090, 0x7aa14ee1, 0x79fc9466, 0x7952f983,
+ 0x78a41b51, 0x77ef897b, 0x7734c38d, 0x76733593,
+ 0x75aa33b1, 0x74d8f46c, 0x73fe8908, 0x7319d333,
+ 0x722976ad, 0x712bc4eb, 0x701e9f29, 0x6eff48fd,
+ 0x6dca2025, 0x6c7a2377, 0x6b081945, 0x6968e250,
+ 0x6789b6cc, 0x6545d976, 0x623e1923, 0x5a82799a,
+ 0x520d1a91, 0x4e47c3aa, 0x4b4243b5, 0x489d2fc3,
+ 0x46338b6a, 0x43f2498b, 0x41cdfe96, 0x3fbf1c82,
+ 0x3dc0448d, 0x3bcd6c20, 0x39e361f6, 0x37ff83c3,
+ 0x361f8e06, 0x34417ac7, 0x326368ee, 0x3083887b,
+ 0x2ea0091f, 0x2cb70944, 0x2ac683d0, 0x28cc3a99,
+ 0x26c59ae4, 0x24af97f2, 0x22867502, 0x20457311,
+ 0x1de64c41, 0x1b604f6f, 0x18a6b4dc, 0x15a521e0,
+ 0x1237205d, 0x0e0d0479, 0x08144f82
+};
+
+static const int cplScaleOffset[7] = { 0, 0, 0, 3, 10, 25, 56};
+
+
+/**************************************************************************************
+ * Function: DecodeCoupleInfo
+ *
+ * Description: decode indices for joint stereo scale factors
+ *
+ * Inputs: pointer to initialized Gecko2Info struct
+ * number of bits remaining in bitstream for this frame
+ *
+ * Outputs: filled-in cplindex[] buffer, with one index per coupling band
+ *
+ * Return: number of bits remaining in bitstream, -1 if out-of-bits
+ *
+ * Notes: couple index info can either be direct-coded or Huffman-coded
+ **************************************************************************************/
+int DecodeCoupleInfo(Gecko2Info *gi, int availbits)
+{
+ int bandstart = cplband[gi->cplStart];
+ int bandend = cplband[gi->nRegions - 1];
+ int hufmode, nbits, b, cache;
+ int *cplindex = gi->db.cplindex;
+ BitStreamInfo *bsi = &(gi->bsi);
+
+ if (availbits < 1) {
+ return -1;
+ }
+
+ /* one-bit flag indicating Huffman or direct coding */
+ hufmode = GetBits(bsi, 1, 1);
+ availbits--;
+
+ if (hufmode) {
+ /* HUFFMAN */
+ for (b = bandstart; b <= bandend; b++) {
+ cache = GetBits(bsi, MAX_HUFF_BITS, 0);
+ nbits = DecodeHuffmanScalar(huffTabCouple, &huffTabCoupleInfo[gi->cplQbits - HUFFTAB_COUPLE_OFFSET], cache, cplindex + b);
+ if (nbits > availbits) {
+ return -1;
+ }
+ availbits -= nbits;
+ AdvanceBitstream(bsi, nbits);
+ }
+ } else {
+ /* DIRECT */
+ if (availbits < gi->cplQbits * (bandend - bandstart + 1)) {
+ return -1;
+ }
+ for (b = bandstart; b <= bandend; b++) {
+ cplindex[b] = GetBits(bsi, gi->cplQbits, 1);
+ availbits -= gi->cplQbits;
+ }
+ }
+
+ return availbits;
+}
+
+/**************************************************************************************
+ * Function: JointDecodeMLT
+ *
+ * Description: decode the jointly-coded MLT
+ *
+ * Inputs: pointer to initialized Gecko2Info struct
+ * mltleft[0, ... , cplStart-1] has non-coupled coefficients for left
+ * mltrght[0, ... , cplStart-1] has non-coupled coefficients for right
+ * mltleft[cplStart, ... , cRegions] has coupled coefficients
+ *
+ * Outputs: mltleft[0, ... , nRegions-1] has reconstructed coefficients for left
+ * mltrght[0, ... , nRegions-1] has reconstructed coefficients for right
+ *
+ * Return: none
+ **************************************************************************************/
+void JointDecodeMLT(Gecko2Info *gi, int *mltleft, int *mltrght)
+{
+ int scaleleft, scalerght;
+ int i, r, q;
+ int cplquant, cploffset;
+ int *cplindex = gi->db.cplindex;
+
+ cplquant = (1 << gi->cplQbits) - 1; /* quant levels */
+ cploffset = cplScaleOffset[gi->cplQbits];
+
+ /* reconstruct the stereo channels */
+ for (r = gi->cplStart; r < gi->nRegions; r++) {
+
+ /*
+ * dequantize the expanded coupling ratio
+ * expand = (q - (cplquant>>1)) * (2.0f/cplquant);
+ *
+ * square-law compression
+ * ratio = sqrt(fabs(expand));
+ * if (expand < 0.0f) ratio = -ratio;
+ *
+ * reconstruct the scaling factors
+ * scaleleft = sqrt(0.5f - 0.5f * ratio);
+ * scalerght = sqrt(0.5f + 0.5f * ratio);
+ */
+ q = cplindex[cplband[r]];
+ scaleleft = cplScale[cploffset + q];
+ scalerght = cplScale[cploffset + cplquant - 1 - q];
+
+ /* drop extra sign bit (max gain = 0.998) */
+ for (i = 0; i < NBINS; i++) {
+ mltrght[NBINS * r + i] = MULSHIFT32(scalerght, mltleft[NBINS * r + i]) << 1;
+ mltleft[NBINS * r + i] = MULSHIFT32(scaleleft, mltleft[NBINS * r + i]) << 1;
+ }
+ }
+
+ /* set non-coded regions to zero */
+ for (i = gi->nRegions * NBINS; i < gi->nSamples; i++) {
+ mltleft[i] = 0;
+ mltrght[i] = 0;
+ }
+
+ return;
+}
diff --git a/audio_codec/libcook/ra_decode.c b/audio_codec/libcook/ra_decode.c
new file mode 100644
index 0000000..36322b6
--- a/dev/null
+++ b/audio_codec/libcook/ra_decode.c
@@ -0,0 +1,321 @@
+#include <memory.h>
+#include "helix_types.h"
+#include "helix_result.h"
+#include "ra_decode.h"
+#include "rm_memory.h"
+#include "rm_error.h"
+#include "rm_memory_default.h"
+
+//#include "ra8hbr_decode.h"
+#include "ra8lbr_decode.h"
+//#include "sipro_decode.h"
+#include "aac_decode.h"
+#include <stdio.h>
+//#include <core/dsp.h>
+
+/* ra_decode_create()
+ * Creates RA decoder frontend struct, copies memory utilities.
+ * Returns struct pointer on success, NULL on failure. */
+ra_decode*
+ra_decode_create(void* pUserError,
+ rm_error_func_ptr fpError)
+{
+ return ra_decode_create2(pUserError,
+ fpError,
+ HXNULL,
+ rm_memory_default_malloc,
+ rm_memory_default_free);
+}
+
+ra_decode*
+ra_decode_create2(void* pUserError,
+ rm_error_func_ptr fpError,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree)
+{
+ ra_decode* pRet = HXNULL;
+
+ if (fpMalloc && fpFree) {
+ pRet = (ra_decode*) fpMalloc(pUserMem, sizeof(ra_decode));
+
+ if (pRet) {
+ /* Zero out the struct */
+ memset((void*) pRet, 0, sizeof(ra_decode));
+ /* Assign the error function */
+ pRet->fpError = fpError;
+ pRet->pUserError = pUserError;
+ /* Assign the memory functions */
+ pRet->fpMalloc = fpMalloc;
+ pRet->fpFree = fpFree;
+ pRet->pUserMem = pUserMem;
+ }
+ }
+
+ return pRet;
+}
+
+/* ra_decode_destroy()
+ * Deletes the decoder backend and frontend instances. */
+void
+ra_decode_destroy(ra_decode* pFrontEnd)
+{
+ rm_free_func_ptr fpFree;
+ void* pUserMem;
+
+ if (pFrontEnd && pFrontEnd->fpFree) {
+ /* Save a pointer to fpFree and pUserMem */
+ fpFree = pFrontEnd->fpFree;
+ pUserMem = pFrontEnd->pUserMem;
+
+ if (pFrontEnd->pDecode && pFrontEnd->fpClose) {
+ /* Free the decoder instance and backend */
+ pFrontEnd->fpClose(pFrontEnd->pDecode,
+ pUserMem,
+ fpFree);
+ }
+
+ /* Free the ra_decode struct memory */
+ fpFree(pUserMem, pFrontEnd);
+ }
+}
+
+/* ra_decode_init()
+ * Selects decoder backend with fourCC code.
+ * Calls decoder backend init function with init params.
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_init(ra_decode* pFrontEnd,
+ UINT32 ulFourCC,
+ void* pInitParams,
+ UINT32 ulInitParamsSize,
+ ra_format_info* pStreamInfo)
+{
+ HX_RESULT retVal = HXR_OK;
+
+ /* Assign the backend function pointers */
+ if (ulFourCC == 0x636F6F6B) { /* 'cook' */
+ pFrontEnd->fpInit = ra8lbr_decode_init;
+ pFrontEnd->fpReset = ra8lbr_decode_reset;
+ pFrontEnd->fpConceal = ra8lbr_decode_conceal;
+ pFrontEnd->fpDecode = ra8lbr_decode_decode;
+ pFrontEnd->fpGetMaxSize = ra8lbr_decode_getmaxsize;
+ pFrontEnd->fpGetChannels = ra8lbr_decode_getchannels;
+ pFrontEnd->fpGetChannelMask = ra8lbr_decode_getchannelmask;
+ pFrontEnd->fpGetSampleRate = ra8lbr_decode_getrate;
+ pFrontEnd->fpMaxSamp = ra8lbr_decode_getdelay;
+ pFrontEnd->fpClose = ra8lbr_decode_close;
+ }
+#if 0
+ else if (ulFourCC == 0x72616163 || /* 'raac' */
+ ulFourCC == 0x72616370) { /* 'racp' */
+ pFrontEnd->fpInit = aac_decode_init;
+ pFrontEnd->fpReset = aac_decode_reset;
+ pFrontEnd->fpConceal = aac_decode_conceal;
+ pFrontEnd->fpDecode = aac_decode_decode;
+ pFrontEnd->fpGetMaxSize = aac_decode_getmaxsize;
+ pFrontEnd->fpGetChannels = aac_decode_getchannels;
+ pFrontEnd->fpGetChannelMask = aac_decode_getchannelmask;
+ pFrontEnd->fpGetSampleRate = aac_decode_getrate;
+ pFrontEnd->fpMaxSamp = aac_decode_getdelay;
+ pFrontEnd->fpClose = aac_decode_close;
+ }
+#endif
+#if 0
+ else if (ulFourCC == 0x61747263) { /* 'atrc' */
+ pFrontEnd->fpInit = ra8hbr_decode_init;
+ pFrontEnd->fpReset = ra8hbr_decode_reset;
+ pFrontEnd->fpConceal = ra8hbr_decode_conceal;
+ pFrontEnd->fpDecode = ra8hbr_decode_decode;
+ pFrontEnd->fpGetMaxSize = ra8hbr_decode_getmaxsize;
+ pFrontEnd->fpGetChannels = ra8hbr_decode_getchannels;
+ pFrontEnd->fpGetChannelMask = ra8hbr_decode_getchannelmask;
+ pFrontEnd->fpGetSampleRate = ra8hbr_decode_getrate;
+ pFrontEnd->fpMaxSamp = ra8hbr_decode_getdelay;
+ pFrontEnd->fpClose = ra8hbr_decode_close;
+ } else if (ulFourCC == 0x73697072) { /* 'sipr' */
+ pFrontEnd->fpInit = sipro_decode_init;
+ pFrontEnd->fpReset = sipro_decode_reset;
+ pFrontEnd->fpConceal = sipro_decode_conceal;
+ pFrontEnd->fpDecode = sipro_decode_decode;
+ pFrontEnd->fpGetMaxSize = sipro_decode_getmaxsize;
+ pFrontEnd->fpGetChannels = sipro_decode_getchannels;
+ pFrontEnd->fpGetChannelMask = sipro_decode_getchannelmask;
+ pFrontEnd->fpGetSampleRate = sipro_decode_getrate;
+ pFrontEnd->fpMaxSamp = sipro_decode_getdelay;
+ pFrontEnd->fpClose = sipro_decode_close;
+ }
+#endif
+ else {
+ /* error - codec not supported */
+ //printk(" cook decode: not supported fourcc\n");
+ retVal = HXR_DEC_NOT_FOUND;
+ }
+
+ if (retVal == HXR_OK && pFrontEnd && pFrontEnd->fpInit && pStreamInfo) {
+ retVal = pFrontEnd->fpInit(pInitParams, ulInitParamsSize, pStreamInfo,
+ &pFrontEnd->pDecode, pFrontEnd->pUserMem,
+ pFrontEnd->fpMalloc, pFrontEnd->fpFree);
+ }
+
+ return retVal;
+}
+
+/* ra_decode_reset()
+ * Calls decoder backend reset function.
+ * Depending on which codec is in use, *pNumSamplesOut samples may
+ * be flushed. After reset, the decoder returns to its initial state.
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_reset(ra_decode* pFrontEnd,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pFrontEnd && pFrontEnd->fpReset) {
+ retVal = pFrontEnd->fpReset(pFrontEnd->pDecode, pSamplesOut,
+ ulNumSamplesAvail, pNumSamplesOut);
+ }
+
+ return retVal;
+}
+
+/* ra_decode_conceal()
+ * Calls decoder backend conceal function.
+ * On successive calls to ra_decode_decode(), the decoder will attempt
+ * to conceal ulNumSamples. No input data should be sent while concealed
+ * frames are being produced. Once the decoder has exhausted the concealed
+ * samples, it can proceed normally with decoding valid input data.
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_conceal(ra_decode* pFrontEnd,
+ UINT32 ulNumSamples)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pFrontEnd && pFrontEnd->fpConceal) {
+ retVal = pFrontEnd->fpConceal(pFrontEnd->pDecode, ulNumSamples);
+ }
+
+ return retVal;
+}
+
+/* ra_decode_decode()
+ * Calls decoder backend decode function.
+ * pData : input data (compressed frame).
+ * ulNumBytes : input data size in bytes.
+ * pNumBytesConsumed : amount of input data consumed by decoder.
+ * pSamplesOut : output data (uncompressed frame).
+ * ulNumSamplesAvail : size of output buffer.
+ * pNumSamplesOut : amount of ouput data produced by decoder.
+ * ulFlags : control flags for decoder.
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_decode(ra_decode* pFrontEnd,
+ UINT8* pData,
+ UINT32 ulNumBytes,
+ UINT32* pNumBytesConsumed,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut,
+ UINT32 ulFlags,
+ UINT32 ulTimeStamp)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pFrontEnd && pFrontEnd->fpDecode) {
+ retVal = pFrontEnd->fpDecode(pFrontEnd->pDecode, pData, ulNumBytes,
+ pNumBytesConsumed, pSamplesOut,
+ ulNumSamplesAvail, pNumSamplesOut, ulFlags, ulTimeStamp);
+ }
+
+ return retVal;
+}
+
+
+/**************** Accessor Functions *******************/
+/* ra_decode_getmaxsize()
+ * pNumSamples receives the maximum number of samples produced
+ * by the decoder in response to a call to ra_decode_decode().
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_getmaxsize(ra_decode* pFrontEnd,
+ UINT32* pNumSamples)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pFrontEnd && pFrontEnd->fpGetMaxSize) {
+ retVal = pFrontEnd->fpGetMaxSize(pFrontEnd->pDecode, pNumSamples);
+ }
+
+ return retVal;
+}
+
+/* ra_decode_getchannels()
+ * pNumChannels receives the number of audio channels in the bitstream.
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_getchannels(ra_decode* pFrontEnd,
+ UINT32* pNumChannels)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pFrontEnd && pFrontEnd->fpGetChannels) {
+ retVal = pFrontEnd->fpGetChannels(pFrontEnd->pDecode, pNumChannels);
+ }
+
+ return retVal;
+}
+
+/* ra_decode_getchannelmask()
+ * pChannelMask receives the 32-bit mapping of the audio output channels.
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_getchannelmask(ra_decode* pFrontEnd,
+ UINT32* pChannelMask)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pFrontEnd && pFrontEnd->fpGetChannelMask) {
+ retVal = pFrontEnd->fpGetChannelMask(pFrontEnd->pDecode, pChannelMask);
+ }
+
+ return retVal;
+}
+
+/* ra_decode_getrate()
+ * pSampleRate receives the sampling rate of the output samples.
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_getrate(ra_decode* pFrontEnd,
+ UINT32* pSampleRate)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pFrontEnd && pFrontEnd->fpGetSampleRate) {
+ retVal = pFrontEnd->fpGetSampleRate(pFrontEnd->pDecode, pSampleRate);
+ }
+
+ return retVal;
+}
+
+/* ra_decode_getdelay()
+ * pNumSamples receives the number of invalid output samples
+ * produced by the decoder at startup.
+ * If non-zero, it is up to the user to discard these samples.
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_getdelay(ra_decode* pFrontEnd,
+ UINT32* pNumSamples)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pFrontEnd && pFrontEnd->fpMaxSamp) {
+ retVal = pFrontEnd->fpMaxSamp(pFrontEnd->pDecode, pNumSamples);
+ }
+
+ return retVal;
+}
+
diff --git a/audio_codec/libcook/ra_decode.h b/audio_codec/libcook/ra_decode.h
new file mode 100644
index 0000000..b51ec0c
--- a/dev/null
+++ b/audio_codec/libcook/ra_decode.h
@@ -0,0 +1,183 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: ra_decode.h,v 1.2.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RA_DECODE_H
+#define RA_DECODE_H
+
+/* Simple unified decoder frontend for RealAudio */
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+#include "rm_error.h"
+#include "ra_format_info.h"
+#include "ra_backend.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* The ra_decode struct contains the RealAudio decoder frontend
+ * function pointers and pointers to the backend. */
+
+ typedef struct ra_decode_struct {
+ void* pUserError;
+ rm_error_func_ptr fpError;
+ void* pUserMem;
+ rm_malloc_func_ptr fpMalloc;
+ rm_free_func_ptr fpFree;
+
+ ra_decode_init_func_ptr fpInit;
+ ra_decode_reset_func_ptr fpReset;
+ ra_decode_conceal_func_ptr fpConceal;
+ ra_decode_decode_func_ptr fpDecode;
+ ra_decode_getmaxsize_func_ptr fpGetMaxSize;
+ ra_decode_getchannels_func_ptr fpGetChannels;
+ ra_decode_getchannelmask_func_ptr fpGetChannelMask;
+ ra_decode_getrate_func_ptr fpGetSampleRate;
+ ra_decode_getdelay_func_ptr fpMaxSamp;
+ ra_decode_close_func_ptr fpClose;
+
+ void* pDecode;
+ } ra_decode;
+
+ /* ra_decode_create()
+ * Creates RA decoder frontend struct, copies memory utilities.
+ * Returns struct pointer on success, NULL on failure. */
+ ra_decode* ra_decode_create(void* pUserError,
+ rm_error_func_ptr fpError);
+
+ ra_decode* ra_decode_create2(void* pUserError,
+ rm_error_func_ptr fpError,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+
+ /* ra_decode_destroy()
+ * Deletes the decoder backend and frontend instances. */
+ void ra_decode_destroy(ra_decode* pFrontEnd);
+
+ /* ra_decode_init()
+ * Selects decoder backend with fourCC code.
+ * Calls decoder backend init function with init params.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_init(ra_decode* pFrontEnd,
+ UINT32 ulFourCC,
+ void* pInitParams,
+ UINT32 ulInitParamsSize,
+ ra_format_info* pStreamInfo);
+
+ /* ra_decode_reset()
+ * Calls decoder backend reset function.
+ * Depending on which codec is in use, *pNumSamplesOut samples may
+ * be flushed. After reset, the decoder returns to its initial state.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_reset(ra_decode* pFrontEnd,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut);
+
+ /* ra_decode_conceal()
+ * Calls decoder backend conceal function.
+ * On successive calls to ra_decode_decode(), the decoder will attempt
+ * to conceal ulNumSamples. No input data should be sent while concealed
+ * frames are being produced. Once the decoder has exhausted the concealed
+ * samples, it can proceed normally with decoding valid input data.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_conceal(ra_decode* pFrontEnd,
+ UINT32 ulNumSamples);
+
+ /* ra_decode_decode()
+ * Calls decoder backend decode function.
+ * pData : input data (compressed frame).
+ * ulNumBytes : input data size in bytes.
+ * pNumBytesConsumed : amount of input data consumed by decoder.
+ * pSamplesOut : output data (uncompressed frame).
+ * ulNumSamplesAvail : size of output buffer.
+ * pNumSamplesOut : amount of ouput data produced by decoder.
+ * ulFlags : control flags for decoder.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_decode(ra_decode* pFrontEnd,
+ UINT8* pData,
+ UINT32 ulNumBytes,
+ UINT32* pNumBytesConsumed,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut,
+ UINT32 ulFlags,
+ UINT32 ulTimeStamp);
+
+
+ /**************** Accessor Functions *******************/
+ /* ra_decode_getmaxsize()
+ * pNumSamples receives the maximum number of samples produced
+ * by the decoder in response to a call to ra_decode_decode().
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_getmaxsize(ra_decode* pFrontEnd,
+ UINT32* pNumSamples);
+
+ /* ra_decode_getchannels()
+ * pNumChannels receives the number of audio channels in the bitstream.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_getchannels(ra_decode* pFrontEnd,
+ UINT32* pNumChannels);
+
+ /* ra_decode_getchannelmask()
+ * pChannelMask receives the 32-bit mapping of the audio output channels.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_getchannelmask(ra_decode* pFrontEnd,
+ UINT32* pChannelMask);
+
+ /* ra_decode_getrate()
+ * pSampleRate receives the sampling rate of the output samples.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_getrate(ra_decode* pFrontEnd,
+ UINT32* pSampleRate);
+
+ /* ra_decode_getdelay()
+ * pNumSamples receives the number of invalid output samples
+ * produced by the decoder at startup.
+ * If non-zero, it is up to the user to discard these samples.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_getdelay(ra_decode* pFrontEnd,
+ UINT32* pNumSamples);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RA_DECODE_H */
diff --git a/audio_codec/libcook/ra_depack.c b/audio_codec/libcook/ra_depack.c
new file mode 100644
index 0000000..259459e
--- a/dev/null
+++ b/audio_codec/libcook/ra_depack.c
@@ -0,0 +1,230 @@
+#include <memory.h>
+#include "helix_types.h"
+#include "helix_result.h"
+#include "ra_depack.h"
+#include "ra_depack_internal.h"
+#include "rm_memory_default.h"
+#include "rm_error_default.h"
+#include "memory_utils.h"
+#include "stream_hdr_utils.h"
+
+ra_depack* ra_depack_create(void* pAvail,
+ ra_block_avail_func_ptr fpAvail,
+ void* pUserError,
+ rm_error_func_ptr fpError)
+{
+ return ra_depack_create2(pAvail,
+ fpAvail,
+ pUserError,
+ fpError,
+ HXNULL,
+ rm_memory_default_malloc,
+ rm_memory_default_free);
+}
+
+ra_depack* ra_depack_create2(void* pAvail,
+ ra_block_avail_func_ptr fpAvail,
+ void* pUserError,
+ rm_error_func_ptr fpError,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree)
+{
+ ra_depack* pRet = HXNULL;
+
+ if (fpAvail && fpMalloc && fpFree) {
+ /* Allocate space for the ra_depack_internal struct
+ * by using the passed-in malloc function
+ */
+ ra_depack_internal* pInt =
+ (ra_depack_internal*) fpMalloc(pUserMem, sizeof(ra_depack_internal));
+ if (pInt) {
+ /* Zero out the struct */
+ memset((void*) pInt, 0, sizeof(ra_depack_internal));
+ /* Assign the frame callback members */
+ pInt->pAvail = pAvail;
+ pInt->fpAvail = fpAvail;
+ /*
+ * Assign the error members. If the caller did not
+ * provide an error callback, then use the default
+ * rm_error_default().
+ */
+ if (fpError) {
+ pInt->fpError = fpError;
+ pInt->pUserError = pUserError;
+ } else {
+ pInt->fpError = rm_error_default;
+ pInt->pUserError = HXNULL;
+ }
+ /* Assign the memory functions */
+ pInt->fpMalloc = fpMalloc;
+ pInt->fpFree = fpFree;
+ pInt->pUserMem = pUserMem;
+ /* Assign the return value */
+ pRet = (ra_depack*) pInt;
+ }
+ }
+
+ return pRet;
+}
+
+HX_RESULT ra_depack_init(ra_depack* pDepack, rm_stream_header* header)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pDepack && header) {
+ /* Get the internal struct */
+ ra_depack_internal* pInt = (ra_depack_internal*) pDepack;
+ /* Call the internal init */
+ retVal = ra_depacki_init(pInt, header);
+ }
+
+ return retVal;
+}
+
+UINT32 ra_depack_get_num_substreams(ra_depack* pDepack)
+{
+ UINT32 ulRet = 0;
+
+ if (pDepack) {
+ /* Get the internal struct */
+ ra_depack_internal* pInt = (ra_depack_internal*) pDepack;
+ /* Return the number of substreams */
+ ulRet = pInt->multiStreamHdr.ulNumSubStreams;
+ }
+
+ return ulRet;
+}
+
+UINT32 ra_depack_get_codec_4cc(ra_depack* pDepack, UINT32 ulSubStream)
+{
+ UINT32 ulRet = 0;
+
+ if (pDepack) {
+ /* Get the internal struct */
+ ra_depack_internal* pInt = (ra_depack_internal*) pDepack;
+ /* Make sure the substream index is legal */
+ if (pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ ulRet = pInt->pSubStreamHdr[ulSubStream].ulCodecID;
+ }
+ }
+
+ return ulRet;
+}
+
+HX_RESULT ra_depack_get_codec_init_info(ra_depack* pDepack,
+ UINT32 ulSubStream,
+ ra_format_info** ppInfo)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pDepack && ppInfo) {
+ /* Init local variables */
+ UINT32 ulSize = sizeof(ra_format_info);
+ ra_format_info* pInfo = HXNULL;
+ /* Get the internal struct */
+ ra_depack_internal* pInt = (ra_depack_internal*) pDepack;
+ /* Allocate space for the struct */
+ pInfo = ra_depacki_malloc(pInt, ulSize);
+ if (pInfo) {
+ /* NULL out the memory */
+ memset(pInfo, 0, ulSize);
+ /* Fill in the init info struct */
+ retVal = ra_depacki_get_format_info(pInt, ulSubStream, pInfo);
+ if (retVal == HXR_OK) {
+ /* Assign the out parameter */
+ *ppInfo = pInfo;
+ } else {
+ /* We failed so free the memory we allocated */
+ ra_depacki_free(pInt, pInfo);
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void ra_depack_destroy_codec_init_info(ra_depack* pDepack, ra_format_info** ppInfo)
+{
+ if (pDepack && ppInfo && *ppInfo) {
+ /* Get the internal struct */
+ ra_depack_internal* pInt = (ra_depack_internal*) pDepack;
+ /* Clean up the format info struct */
+ ra_depacki_cleanup_format_info(pInt, *ppInfo);
+ /* Delete the memory associated with it */
+ ra_depacki_free(pInt, *ppInfo);
+ /* NULL the pointer out */
+ *ppInfo = HXNULL;
+ }
+}
+
+HX_RESULT ra_depack_add_packet(ra_depack* pDepack, rm_packet* packet)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pDepack && packet) {
+ /* Get the internal struct */
+ ra_depack_internal* pInt = (ra_depack_internal*) pDepack;
+ /* Call the internal function */
+ retVal = ra_depacki_add_packet(pInt, packet);
+ }
+
+ return retVal;
+}
+
+void ra_depack_destroy_block(ra_depack* pDepack, ra_block** ppBlock)
+{
+ if (pDepack && ppBlock && *ppBlock) {
+ /* Get the internal struct */
+ ra_depack_internal* pInt = (ra_depack_internal*) pDepack;
+ /* Free the data */
+ if ((*ppBlock)->pData) {
+ ra_depacki_free(pInt, (*ppBlock)->pData);
+ (*ppBlock)->pData = HXNULL;
+ }
+ /* Free the memory itself */
+ ra_depacki_free(pInt, *ppBlock);
+ /* Null out the pointer */
+ *ppBlock = HXNULL;
+ }
+}
+
+HX_RESULT ra_depack_seek(ra_depack* pDepack, UINT32 ulTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pDepack) {
+ /* Get the internal struct */
+ ra_depack_internal* pInt = (ra_depack_internal*) pDepack;
+ /* Call the internal seek function */
+ retVal = ra_depacki_seek(pInt, ulTime);
+ }
+
+ return retVal;
+}
+
+void ra_depack_destroy(ra_depack** ppDepack)
+{
+ if (ppDepack) {
+ ra_depack_internal* pInt = (ra_depack_internal*) * ppDepack;
+ if (pInt && pInt->fpFree) {
+ /* Save a pointer to fpFree and pUserMem */
+ rm_free_func_ptr fpFree = pInt->fpFree;
+ void* pUserMem = pInt->pUserMem;
+ /* Clean up multistream header */
+ rm_cleanup_multistream_hdr(fpFree, pUserMem, &pInt->multiStreamHdr);
+ /* Clean up rule map */
+ rm_cleanup_rule_map(fpFree, pUserMem, &pInt->rule2Flag);
+ /* Clean up the substream header array */
+ ra_depacki_cleanup_substream_hdr_array(pInt);
+ /* Null everything out */
+ memset(pInt, 0, sizeof(ra_depack_internal));
+ /* Free the rm_parser_internal struct memory */
+ fpFree(pUserMem, pInt);
+ /* NULL out the pointer */
+ *ppDepack = HXNULL;
+ }
+ }
+}
+
diff --git a/audio_codec/libcook/ra_depack.h b/audio_codec/libcook/ra_depack.h
new file mode 100644
index 0000000..aedfd64
--- a/dev/null
+++ b/audio_codec/libcook/ra_depack.h
@@ -0,0 +1,177 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: ra_depack.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RA_DEPACK_H
+#define RA_DEPACK_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_error.h"
+#include "rm_memory.h"
+#include "rm_stream.h"
+#include "rm_packet.h"
+#include "ra_format_info.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* Encoded audio block definition. */
+ typedef struct ra_block_struct {
+ BYTE* pData;
+ UINT32 ulDataLen;
+ UINT32 ulTimestamp;
+ UINT32 ulDataFlags;
+ } ra_block;
+
+ /* Callback functions */
+ typedef HX_RESULT(*ra_block_avail_func_ptr)(void* pAvail,
+ UINT32 ulSubStream,
+ ra_block* block);
+
+ /*
+ * ra_depack definition. Opaque to user.
+ */
+ typedef void ra_depack;
+
+ /*
+ * ra_depack_create
+ *
+ * Users should use this function if they don't need to
+ * customize their memory allocation routines. In this
+ * case, the SDK will use malloc() and free() for
+ * memory allocation.
+ */
+ ra_depack* ra_depack_create(void* pAvail,
+ ra_block_avail_func_ptr fpAvail,
+ void* pUserError,
+ rm_error_func_ptr fpError);
+
+ /*
+ * ra_depack_create2
+ *
+ * Users should use this function if they need to
+ * customize the memory allocation routines.
+ */
+ ra_depack* ra_depack_create2(void* pAvail,
+ ra_block_avail_func_ptr fpAvail,
+ void* pUserError,
+ rm_error_func_ptr fpError,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+
+ /*
+ * ra_depack_init
+ *
+ * The depacketizer will be initialized with a RealAudio stream header.
+ */
+ HX_RESULT ra_depack_init(ra_depack* pDepack, rm_stream_header* pHdr);
+
+ /*
+ * ra_depack_get_num_substreams
+ *
+ * This accessor function tells how many audio substreams there are
+ * in this audio stream. For single-rate files, this will be 1. For
+ * SureStream audio streams, this could be greater than 1.
+ */
+ UINT32 ra_depack_get_num_substreams(ra_depack* pDepack);
+
+ /*
+ * ra_depack_get_codec_4cc
+ *
+ * This accessor function returns the 4cc of the codec. This 4cc
+ * will be used to determine which codec to use for this substream.
+ */
+ UINT32 ra_depack_get_codec_4cc(ra_depack* pDepack, UINT32 ulSubStream);
+
+ /*
+ * ra_depack_get_codec_init_info
+ *
+ * This function fills in the structure which is used to initialize the codec.
+ */
+ HX_RESULT ra_depack_get_codec_init_info(ra_depack* pDepack,
+ UINT32 ulSubStream,
+ ra_format_info** ppInfo);
+
+ /*
+ * ra_depack_destroy_codec_init_info
+ *
+ * This function frees the memory associated with the ra_format_info object
+ * created by ra_depack_get_codec_init_info().
+ */
+ void ra_depack_destroy_codec_init_info(ra_depack* pDepack,
+ ra_format_info** ppInfo);
+
+ /*
+ * ra_depack_add_packet
+ *
+ * Put an audio packet into the depacketizer. When enough data is
+ * present to deinterleave, then the user will be called back
+ * on the rm_block_avail_func_ptr set in ra_depack_create().
+ */
+ HX_RESULT ra_depack_add_packet(ra_depack* pDepack, rm_packet* pPacket);
+
+ /*
+ * ra_depack_destroy_block
+ *
+ * This method cleans up a block received via the
+ * ra_block_avail_func_ptr callback.
+ */
+ void ra_depack_destroy_block(ra_depack* pDepack, ra_block** ppBlock);
+
+ /*
+ * ra_depack_seek
+ *
+ * The user calls this function if the stream is seeked. It
+ * should be called before passing any post-seek packets.
+ */
+ HX_RESULT ra_depack_seek(ra_depack* pDepack, UINT32 ulTime);
+
+ /*
+ * ra_depack_destroy
+ *
+ * This cleans up all memory allocated by the ra_depack_* calls
+ */
+ void ra_depack_destroy(ra_depack** ppDepack);
+
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RA_DEPACK_H */
diff --git a/audio_codec/libcook/ra_depack_internal.c b/audio_codec/libcook/ra_depack_internal.c
new file mode 100644
index 0000000..d889cbc
--- a/dev/null
+++ b/audio_codec/libcook/ra_depack_internal.c
@@ -0,0 +1,1710 @@
+#include <stdio.h>
+#include <string.h>
+
+#include <memory.h>
+#include "helix_types.h"
+#include "helix_result.h"
+#include "pack_utils.h"
+#include "string_utils.h"
+#include "memory_utils.h"
+#include "packet_defines.h"
+#include "codec_defines.h"
+#include "stream_hdr_utils.h"
+#include "ra_depack_internal.h"
+#include "rasl.h"
+
+/* Defines */
+#define TIMESTAMP_GAP_FUDGE_FACTOR 1 /* Maximum non-loss, non-seek gap in ms between packets */
+#define INITIAL_FRAG_BUFFER_SIZE 2048 /* Initial size of frag buffer */
+#define RA_COPY_BUF 0
+
+void* ra_depacki_malloc(ra_depack_internal* pInt, UINT32 ulSize)
+{
+ void* pRet = HXNULL;
+
+ if (pInt && pInt->fpMalloc) {
+ pRet = pInt->fpMalloc(pInt->pUserMem, ulSize);
+ }
+
+ return pRet;
+}
+
+void ra_depacki_free(ra_depack_internal* pInt, void* pMem)
+{
+ if (pInt && pInt->fpFree) {
+ pInt->fpFree(pInt->pUserMem, pMem);
+ }
+}
+
+HX_RESULT ra_depacki_init(ra_depack_internal* pInt, rm_stream_header* hdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && hdr) {
+ /* Initialize local variables */
+ UINT32 ulTmp = 0;
+ BYTE* pTmp = HXNULL;
+ /* Check if we have a "HasRelativeTS" property - OK if we don't */
+ if (HX_SUCCEEDED(rm_stream_get_property_int(hdr, "TrackStartTime", &ulTmp))) {
+ pInt->bForceTrackStartTime = TRUE;
+ pInt->ulTrackStartTime = ulTmp;
+ }
+ /* Check if we have a "ZeroTimeOffset" property - OK if we don't */
+ if (HX_SUCCEEDED(rm_stream_get_property_int(hdr, "TrackEndTime", &ulTmp))) {
+ pInt->bForceTrackEndTime = TRUE;
+ pInt->ulTrackEndTime = ulTmp;
+ }
+ /* Check if we have an EndTime property */
+ if (HX_SUCCEEDED(rm_stream_get_property_int(hdr, "EndTime", &ulTmp))) {
+ pInt->bHasEndTime = TRUE;
+ pInt->ulEndTime = ulTmp;
+ }
+ /* Copy the stream duration */
+ pInt->ulStreamDuration = hdr->ulDuration;
+ /* If we have an end time, then clip the duration */
+ if (pInt->bHasEndTime &&
+ pInt->ulEndTime &&
+ pInt->ulStreamDuration > pInt->ulEndTime) {
+ pInt->ulStreamDuration = pInt->ulEndTime;
+ }
+ if (pInt->ulStreamDuration == 0) {
+ pInt->ulStreamDuration = 0x7fffffff;
+ }
+ /* Check if we have a "RMFF 1.0 Flags" property */
+ retVal = rm_stream_get_property_buf(hdr, "RMFF 1.0 Flags", &pTmp, &ulTmp);
+ if (retVal == HXR_OK) {
+ /* Parse the "RMFF 1.0 Flags" property */
+ retVal = ra_depacki_unpack_rule_map(pInt, &pInt->rule2Flag,
+ &pTmp, &ulTmp);
+ if (retVal == HXR_OK) {
+ /* Get the "OpaqueData" property */
+ retVal = rm_stream_get_property_buf(hdr, "OpaqueData", &pTmp, &ulTmp);
+ if (retVal == HXR_OK) {
+ /* Unpack the opaque data */
+ retVal = ra_depacki_unpack_opaque_data(pInt, pTmp, ulTmp);
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_unpack_rule_map(ra_depack_internal* pInt,
+ rm_rule_map* pMap,
+ BYTE** ppBuf,
+ UINT32* pulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ retVal = rm_unpack_rule_map(ppBuf, pulLen,
+ pInt->fpMalloc,
+ pInt->fpFree,
+ pInt->pUserMem,
+ pMap);
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_unpack_multistream_hdr(ra_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ retVal = rm_unpack_multistream_hdr(ppBuf, pulLen,
+ pInt->fpMalloc,
+ pInt->fpFree,
+ pInt->pUserMem,
+ &pInt->multiStreamHdr);
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_unpack_opaque_data(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pBuf && ulLen >= 4) {
+ /* Initialize local variables */
+ UINT32 ulSize = 0;
+ UINT32 ulID = 0;
+ UINT32 i = 0;
+ UINT32 ulTmp = 0;
+ /*
+ * If the first four bytes are MLTI, then we
+ * know the opaque data contains a multistream header
+ * followed by several normal headers. So first we
+ * need to check the first four bytes.
+ */
+ ulID = rm_unpack32(&pBuf, &ulLen);
+ /* Now back up 4 bytes */
+ pBuf -= 4;
+ ulLen += 4;
+ /* Is this a multistream header? */
+ if (ulID == RM_MULTIHEADER_OBJECT) {
+ /* Unpack the multistream header */
+ retVal = ra_depacki_unpack_multistream_hdr(pInt, &pBuf, &ulLen);
+ if (retVal == HXR_OK) {
+ pInt->bStreamSwitchable = TRUE;
+ }
+ } else if (ulID == RA_FORMAT_ID) {
+ /* Single-rate stream */
+ pInt->multiStreamHdr.ulNumSubStreams = 1;
+ /* Clear the stream switchable flag */
+ pInt->bStreamSwitchable = FALSE;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ /* Clean up any existing substream header array */
+ ra_depacki_cleanup_substream_hdr_array(pInt);
+ /* Set the return value */
+ retVal = HXR_FAIL;
+ /* Allocate space for substream header array */
+ ulSize = pInt->multiStreamHdr.ulNumSubStreams * sizeof(ra_substream_hdr);
+ pInt->pSubStreamHdr = (ra_substream_hdr*) ra_depacki_malloc(pInt, ulSize);
+ if (pInt->pSubStreamHdr) {
+ /* NULL out the memory */
+ memset(pInt->pSubStreamHdr, 0, ulSize);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Loop through and unpack each substream header */
+ for (i = 0; i < pInt->multiStreamHdr.ulNumSubStreams && retVal == HXR_OK; i++) {
+ /* Is this a multiheader? */
+ if (pInt->bStreamSwitchable) {
+ /*
+ * If this is a multistream header, then there
+ * is a 4-byte length in front of every substream header
+ */
+ if (ulLen >= 4) {
+ ulSize = rm_unpack32(&pBuf, &ulLen);
+ } else {
+ retVal = HXR_FAIL;
+ }
+ } else {
+ /*
+ * If this is not a multi-stream header, then
+ * the rest of the buffer is a single substream header
+ */
+ ulSize = ulLen;
+ }
+ /* Make sure we have enough parsing buffer */
+ if (ulLen >= ulSize) {
+ /* Now unpack an substream header */
+ retVal = ra_depacki_unpack_substream_hdr(pInt, pBuf, ulSize,
+ &pInt->pSubStreamHdr[i]);
+ if (retVal == HXR_OK) {
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[i];
+ /*
+ * If the interleaver ID is either VBRS of VBRF,
+ * then this is a VBR stream.
+ */
+ if (pHdr->ulInterleaverID == RA_INTERLEAVER_VBRS ||
+ pHdr->ulInterleaverID == RA_INTERLEAVER_VBRF) {
+ pHdr->bIsVBR = TRUE;
+ }
+ /* Compute the number of codec frames per superblock */
+ if (pHdr->ulCodecFrameSize) {
+ pHdr->ulNumCodecFrames = pHdr->ulInterleaveBlockSize *
+ pHdr->ulInterleaveFactor /
+ pHdr->ulCodecFrameSize;
+ }
+ /* Compute the ms per block */
+ if (pHdr->ulBytesPerMin) {
+ pHdr->dBlockDuration = ((double) pHdr->ulInterleaveBlockSize) *
+ 60000.0 /
+ ((double) pHdr->ulBytesPerMin);
+ }
+ /* Compute the superblock size and time */
+ pHdr->ulSuperBlockSize = pHdr->ulInterleaveBlockSize *
+ pHdr->ulInterleaveFactor;
+ pHdr->ulSuperBlockTime = (UINT32)(pHdr->dBlockDuration *
+ ((double) pHdr->ulInterleaveFactor));
+ /* Is this stream VBR? */
+ if (pHdr->bIsVBR) {
+ /* Init the last sent block end time */
+ pHdr->ulLastSentEndTime = 0;
+ /*
+ * Init the frag buffer members. The frag buffer
+ * willl be set up the first time it is needed.
+ */
+ pHdr->pFragBuffer = HXNULL;
+ pHdr->ulFragBufferSize = 0;
+ pHdr->ulFragBufferOffset = 0;
+ pHdr->ulFragBufferTime = 0;
+ } else {
+ /* Set the return value */
+ retVal = HXR_OUTOFMEMORY;
+ /* Set the superblock keyframe time */
+ pHdr->bHasKeyTime = FALSE;
+ pHdr->ulKeyTime = 0;
+ /* Allocate the interleaved buffer */
+ pHdr->pIBuffer = (BYTE*) ra_depacki_malloc(pInt, pHdr->ulSuperBlockSize);
+ if (pHdr->pIBuffer) {
+ /* Zero out the buffer */
+ memset(pHdr->pIBuffer, 0, pHdr->ulSuperBlockSize);
+ /* Allocate the de-interleaved buffer */
+ pHdr->pDBuffer = (BYTE*) ra_depacki_malloc(pInt, pHdr->ulSuperBlockSize);
+ if (pHdr->pDBuffer) {
+ /* Zero out the buffer */
+ memset(pHdr->pDBuffer, 0, pHdr->ulSuperBlockSize);
+ /* Allocate the interleaved flags */
+ ulTmp = pHdr->ulInterleaveFactor * sizeof(UINT32);
+ pHdr->pIPresentFlags = (UINT32*) ra_depacki_malloc(pInt, ulTmp);
+ if (pHdr->pIPresentFlags) {
+ /* Zero out the flags */
+ memset(pHdr->pIPresentFlags, 0, ulTmp);
+ /* Allocate the de-interleaved flags */
+ pHdr->pDPresentFlags = (UINT32*) ra_depacki_malloc(pInt, ulTmp);
+ if (pHdr->pDPresentFlags) {
+ /* Null out the memory */
+ memset(pHdr->pDPresentFlags, 0, ulTmp);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* If this is GENR interleaving, then init the tables */
+ if (pHdr->ulInterleaverID == RA_INTERLEAVER_GENR) {
+ retVal = ra_depacki_init_genr(pInt, i);
+ }
+ }
+ }
+ }
+ }
+ }
+ /* Update the buffer cursors */
+ pBuf += ulSize;
+ ulLen -= ulSize;
+ }
+ } else {
+ retVal = HXR_FAIL;
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void ra_depacki_cleanup_substream_hdr(ra_depack_internal* pInt,
+ ra_substream_hdr* hdr)
+{
+ if (pInt && hdr) {
+ if (hdr->pulInterleavePattern) {
+ ra_depacki_free(pInt, hdr->pulInterleavePattern);
+ hdr->pulInterleavePattern = HXNULL;
+ }
+ if (hdr->pOpaqueData) {
+ ra_depacki_free(pInt, hdr->pOpaqueData);
+ hdr->pOpaqueData = HXNULL;
+ }
+ if (hdr->pFragBuffer) {
+ ra_depacki_free(pInt, hdr->pFragBuffer);
+ hdr->pFragBuffer = HXNULL;
+ }
+ if (hdr->pIBuffer) {
+ ra_depacki_free(pInt, hdr->pIBuffer);
+ hdr->pIBuffer = HXNULL;
+ }
+ if (hdr->pDBuffer) {
+ ra_depacki_free(pInt, hdr->pDBuffer);
+ hdr->pDBuffer = HXNULL;
+ }
+ if (hdr->pIPresentFlags) {
+ ra_depacki_free(pInt, hdr->pIPresentFlags);
+ hdr->pIPresentFlags = HXNULL;
+ }
+ if (hdr->pDPresentFlags) {
+ ra_depacki_free(pInt, hdr->pDPresentFlags);
+ hdr->pDPresentFlags = HXNULL;
+ }
+ if (hdr->pulGENRPattern) {
+ ra_depacki_free(pInt, hdr->pulGENRPattern);
+ hdr->pulGENRPattern = HXNULL;
+ }
+ if (hdr->pulGENRBlockNum) {
+ ra_depacki_free(pInt, hdr->pulGENRBlockNum);
+ hdr->pulGENRBlockNum = HXNULL;
+ }
+ if (hdr->pulGENRBlockOffset) {
+ ra_depacki_free(pInt, hdr->pulGENRBlockOffset);
+ hdr->pulGENRBlockOffset = HXNULL;
+ }
+ }
+}
+
+void ra_depacki_cleanup_substream_hdr_array(ra_depack_internal* pInt)
+{
+ if (pInt && pInt->pSubStreamHdr) {
+ UINT32 i = 0;
+ for (i = 0; i < pInt->multiStreamHdr.ulNumSubStreams; i++) {
+ ra_depacki_cleanup_substream_hdr(pInt, &pInt->pSubStreamHdr[i]);
+ }
+ /* Free the header array */
+ ra_depacki_free(pInt, pInt->pSubStreamHdr);
+ /* NULL out the pointer */
+ pInt->pSubStreamHdr = HXNULL;
+ }
+}
+
+HX_RESULT ra_depacki_unpack_substream_hdr(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ ra_substream_hdr* pHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pBuf && ulLen >= 6 && pHdr) {
+ UINT32 ulID = 0;
+ UINT16 usVersion = 0;
+ /* Clean up any existing header info */
+ ra_depacki_cleanup_substream_hdr(pInt, pHdr);
+ /* Read the ID and the RAFormat version */
+ ulID = rm_unpack32(&pBuf, &ulLen);
+ usVersion = rm_unpack16(&pBuf, &ulLen);
+ /* Sanity check on ID */
+ if (ulID == RA_FORMAT_ID) {
+ /* Switch based on RAFormat version */
+ switch (usVersion) {
+ case 3:
+ retVal = ra_depacki_unpack_raformat3(pInt, pBuf, ulLen, pHdr);
+ break;
+ case 4:
+ retVal = ra_depacki_unpack_raformat4(pInt, pBuf, ulLen, pHdr);
+ break;
+ case 5:
+ retVal = ra_depacki_unpack_raformat5(pInt, pBuf, ulLen, pHdr);
+ break;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_unpack_raformat3(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ ra_substream_hdr* pHdr)
+{
+ return HXR_NOTIMPL;
+}
+
+HX_RESULT ra_depacki_unpack_raformat4(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ ra_substream_hdr* pHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pBuf && ulLen >= 63 && pHdr) {
+ /* Skip first 10 bytes */
+ pBuf += 10;
+ ulLen -= 10;
+ /* Read the version and revision */
+ pHdr->usRAFormatVersion = rm_unpack16(&pBuf, &ulLen);
+ pHdr->usRAFormatRevision = rm_unpack16(&pBuf, &ulLen);
+ /* Sanity check */
+ if (pHdr->usRAFormatVersion == 4 &&
+ pHdr->usRAFormatRevision == 0) {
+ pHdr->usHeaderBytes = rm_unpack16(&pBuf, &ulLen);
+ pHdr->usFlavorIndex = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulGranularity = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulTotalBytes = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulBytesPerMin = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulBytesPerMin2 = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulInterleaveFactor = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulInterleaveBlockSize = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulUserData = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulSampleRate = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulSampleRate >>= 16;
+ pHdr->ulSampleSize = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulChannels = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulInterleaverID = rm_unpack32_from_byte_string(&pBuf, &ulLen);
+ pHdr->ulCodecID = rm_unpack32_from_byte_string(&pBuf, &ulLen);
+ pHdr->bIsInterleaved = rm_unpack8(&pBuf, &ulLen);
+ pHdr->bCopyByte = rm_unpack8(&pBuf, &ulLen);
+ pHdr->ucStreamType = rm_unpack8(&pBuf, &ulLen);
+ /*
+ * If the bIsInterleaved flag says we are
+ * not interleaved, then make sure the
+ * interleaverID is set to no interleaver.
+ */
+ if (!pHdr->bIsInterleaved) {
+ pHdr->ulInterleaverID = RA_NO_INTERLEAVER;
+ }
+ /* If the interleave factor is 0, make it 1. */
+ if (!pHdr->ulInterleaveFactor) {
+ pHdr->ulInterleaveFactor = 1;
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_unpack_raformat5(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ ra_substream_hdr* pHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pBuf && ulLen >= 68 && pHdr) {
+ /* Init local variables */
+ UINT32 ulSize = 0;
+ UINT32 i = 0;
+ /* Skip first 10 bytes */
+ pBuf += 10;
+ ulLen -= 10;
+ /* Read the version and revision */
+ pHdr->usRAFormatVersion = rm_unpack16(&pBuf, &ulLen);
+ pHdr->usRAFormatRevision = rm_unpack16(&pBuf, &ulLen);
+ /* Sanity check */
+ if (pHdr->usRAFormatVersion == 5 &&
+ pHdr->usRAFormatRevision == 0) {
+ pHdr->usHeaderBytes = rm_unpack16(&pBuf, &ulLen);
+ pHdr->usFlavorIndex = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulGranularity = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulTotalBytes = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulBytesPerMin = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulBytesPerMin2 = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulInterleaveFactor = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulInterleaveBlockSize = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulCodecFrameSize = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulUserData = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulSampleRate = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulSampleRate >>= 16;
+ pHdr->ulActualSampleRate = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulActualSampleRate >>= 16;
+ pHdr->ulSampleSize = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulChannels = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulInterleaverID = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulCodecID = rm_unpack32(&pBuf, &ulLen);
+ pHdr->bIsInterleaved = rm_unpack8(&pBuf, &ulLen);
+ pHdr->bCopyByte = rm_unpack8(&pBuf, &ulLen);
+ pHdr->ucStreamType = rm_unpack8(&pBuf, &ulLen);
+ pHdr->ucScatterType = rm_unpack8(&pBuf, &ulLen);
+ pHdr->ulNumCodecFrames = pHdr->ulInterleaveFactor *
+ pHdr->ulInterleaveBlockSize /
+ pHdr->ulCodecFrameSize;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /*
+ * If ucScatterType is non-zero, then we have
+ * to read in an interleave pattern.
+ */
+ if (pHdr->ucScatterType) {
+ /* Set the return value */
+ retVal = HXR_FAIL;
+ /* Allocate space for the interleave pattern */
+ ulSize = pHdr->ulNumCodecFrames * sizeof(UINT32);
+ pHdr->pulInterleavePattern = ra_depacki_malloc(pInt, ulSize);
+ if (pHdr->pulInterleavePattern) {
+ /* NULL out all the memory */
+ memset(pHdr->pulInterleavePattern, 0, ulSize);
+ /* Make sure we have enough parsing buffer left */
+ if (ulLen >= ulSize) {
+ /* Read in the interleave pattern */
+ for (i = 0; i < pHdr->ulNumCodecFrames; i++) {
+ pHdr->pulInterleavePattern[i] = rm_unpack16(&pBuf, &ulLen);
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ if (retVal == HXR_OK) {
+ /* Set the return value */
+ retVal = HXR_FAIL;
+ /* Make sure we have four bytes */
+ if (ulLen >= 4) {
+ /* Read in the opaque data size */
+ pHdr->ulOpaqueDataSize = rm_unpack32(&pBuf, &ulLen);
+ /* Make sure we have this much parsing space left */
+ if ((ulLen >= pHdr->ulOpaqueDataSize) && (pHdr->ulOpaqueDataSize > 0)) {
+ /* Allocate the buffer */
+ pHdr->pOpaqueData = ra_depacki_malloc(pInt, pHdr->ulOpaqueDataSize);
+ if (pHdr->pOpaqueData) {
+ /* Copy the opaque data */
+ memcpy(pHdr->pOpaqueData, pBuf, pHdr->ulOpaqueDataSize);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /*
+ * If the bIsInterleaved flag says we are
+ * not interleaved, then make sure the
+ * interleaverID is set to no interleaver.
+ */
+ if (!pHdr->bIsInterleaved) {
+ pHdr->ulInterleaverID = RA_NO_INTERLEAVER;
+ }
+ /* If the interleave factor is 0, make it 1. */
+ if (!pHdr->ulInterleaveFactor) {
+ pHdr->ulInterleaveFactor = 1;
+ }
+ }
+ } else if (pHdr->ulOpaqueDataSize == 0) {
+ retVal = HXR_OK;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_get_format_info(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ ra_format_info* pInfo)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInfo && pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Init local variables */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ if (pHdr) {
+ /* Clean up any existing format info */
+ ra_depacki_cleanup_format_info(pInt, pInfo);
+ /* Assign members */
+ pInfo->ulSampleRate = pHdr->ulSampleRate;
+ pInfo->ulActualRate = pHdr->ulActualSampleRate;
+ pInfo->usBitsPerSample = (UINT16) pHdr->ulSampleSize;
+ pInfo->usNumChannels = (UINT16) pHdr->ulChannels;
+ pInfo->usAudioQuality = 100;
+ pInfo->usFlavorIndex = pHdr->usFlavorIndex;
+ pInfo->ulBitsPerFrame = pHdr->ulCodecFrameSize;
+ pInfo->ulGranularity = pHdr->ulGranularity;
+ pInfo->ulOpaqueDataSize = pHdr->ulOpaqueDataSize;
+ /* Copy the opaque data buffer */
+ pInfo->pOpaqueData = copy_buffer(pInt->pUserMem,
+ pInt->fpMalloc,
+ pHdr->pOpaqueData,
+ pHdr->ulOpaqueDataSize);
+ if (!pInfo->ulOpaqueDataSize || pInfo->pOpaqueData) {
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void ra_depacki_cleanup_format_info(ra_depack_internal* pInt,
+ ra_format_info* pInfo)
+{
+ if (pInt && pInfo && pInfo->pOpaqueData) {
+ ra_depacki_free(pInt, pInfo->pOpaqueData);
+ pInfo->pOpaqueData = HXNULL;
+ }
+}
+
+UINT32 ra_depacki_rule_to_flags(ra_depack_internal* pInt, UINT32 ulRule)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt && pInt->rule2Flag.pulMap &&
+ ulRule < pInt->rule2Flag.ulNumRules) {
+ ulRet = pInt->rule2Flag.pulMap[ulRule];
+ }
+
+ return ulRet;
+}
+
+HXBOOL ra_depacki_is_keyframe_rule(ra_depack_internal* pInt, UINT32 ulRule)
+{
+ UINT32 ulFlag = ra_depacki_rule_to_flags(pInt, ulRule);
+ return (ulFlag & HX_KEYFRAME_FLAG ? TRUE : FALSE);
+}
+
+UINT32 ra_depacki_rule_to_substream(ra_depack_internal* pInt, UINT32 ulRule)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt && pInt->multiStreamHdr.rule2SubStream.pulMap &&
+ ulRule < pInt->multiStreamHdr.rule2SubStream.ulNumRules) {
+ ulRet = pInt->multiStreamHdr.rule2SubStream.pulMap[ulRule];
+ }
+
+ return ulRet;
+}
+
+HX_RESULT ra_depacki_add_packet(ra_depack_internal* pInt,
+ rm_packet* pPacket)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pPacket) {
+ /* Init local variables */
+ UINT32 i = 0;
+ /* Was this packet lost? */
+ if (!pPacket->ucLost) {
+ /* This packet was not lost, so we can look up the substream. */
+ UINT32 ulSubStream = ra_depacki_rule_to_substream(pInt, pPacket->ucASMRule);
+ /* Sanity check */
+ if (pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Is this substream VBR? */
+ if (pInt->pSubStreamHdr[ulSubStream].bIsVBR) {
+ /* Add the VBR packet */
+ retVal = ra_depacki_add_vbr_packet(pInt, ulSubStream, pPacket);
+ } else {
+ /* Add the non-VBR packet */
+ retVal = ra_depacki_add_non_vbr_packet(pInt, ulSubStream, pPacket);
+ }
+ }
+ } else {
+ /* Are we multistream or single-stream? */
+ if (pInt->bStreamSwitchable) {
+ /*
+ * We are multi-stream. Therefore, we don't know which
+ * substream this packet came from. So we simply set the
+ * flag saying some loss happened in each substream.
+ */
+ for (i = 0; i < pInt->multiStreamHdr.ulNumSubStreams; i++) {
+ pInt->pSubStreamHdr[i].bLossOccurred = TRUE;
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ } else {
+ /*
+ * We are single substream, so we just pass the
+ * lost packet on. It has to be substream 0, of course.
+ */
+ if (pInt->pSubStreamHdr &&
+ pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Is the single substream VBR? */
+ if (pInt->pSubStreamHdr[0].bIsVBR) {
+ retVal = ra_depacki_add_vbr_packet(pInt, 0, pPacket);
+ } else {
+ retVal = ra_depacki_add_non_vbr_packet(pInt, 0, pPacket);
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_add_vbr_packet(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ rm_packet* pPacket)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pPacket) {
+ /* Is the packet lost? */
+ if (!pPacket->ucLost) {
+ /* Packet was not lost */
+ if (pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /* Init local variables */
+ UINT32 ulNumAU = 0;
+ HXBOOL bFrag = FALSE;
+ UINT32 ulAUSize = 0;
+ UINT32 ulAUFragSize = 0;
+ /* Parse this VBR packet */
+ retVal = ra_depacki_parse_vbr_packet(pInt, pPacket, &ulNumAU, &bFrag,
+ &ulAUSize, &ulAUFragSize);
+ if (retVal == HXR_OK) {
+ /*
+ * Are we within the tolerance? We expect to
+ * be if we didn't seek. Otherwise, we had loss.
+ */
+ if (pPacket->ulTime > pHdr->ulLastSentEndTime + TIMESTAMP_GAP_FUDGE_FACTOR &&
+ !pHdr->bSeeked) {
+ /* We need to send some loss packets */
+ retVal = ra_depacki_generate_and_send_loss(pInt,
+ ulSubStream,
+ pHdr->ulLastSentEndTime,
+ pPacket->ulTime);
+ if (retVal == HXR_OK) {
+ pHdr->ulLastSentEndTime = pPacket->ulTime;
+ }
+ }
+ /* Have we just seeked? */
+ if (pHdr->bSeeked) {
+ /* Clear any remaining fragment */
+ ra_depacki_clear_frag_buffer(pInt, pHdr);
+ /* Set the last sent time to this time */
+ pHdr->ulLastSentEndTime = pPacket->ulTime;
+ /* Clear the seeked flag */
+ pHdr->bSeeked = FALSE;
+ }
+ /* Does this packet hold a fragmented AU? */
+ if (bFrag) {
+ /* Handle the fragmented packet */
+ retVal = ra_depacki_handle_frag_packet(pInt, ulSubStream, pPacket,
+ ulAUSize, ulAUFragSize);
+ } else {
+ /* Handle the non-fragmented packet */
+ retVal = ra_depacki_handle_nonfrag_packet(pInt, ulSubStream,
+ pPacket, ulNumAU);
+ }
+ }
+ }
+ } else {
+ /* Packet is lost - not an error */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_add_non_vbr_packet(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ rm_packet* pPacket)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pPacket && pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Init local variables */
+ HXBOOL bKey = FALSE;
+ HXDOUBLE dTimeDiff = 0.0;
+ HXDOUBLE dBlockNum = 0;
+ UINT32 ulBlockNum = 0;
+ HXDOUBLE dTSOffset = 0.0;
+ UINT32 ulTSOffset = 0;
+ UINT32 ulPacketTime = pPacket->ulTime;
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /* Is the packet lost? */
+ if (!pPacket->ucLost) {
+ /* Is this a keyframe packet? */
+ bKey = ra_depacki_is_keyframe_rule(pInt, pPacket->ucASMRule);
+ /*
+ * We need to determine the index of this block
+ * in this superblock. We will do this by knowing
+ * the timestamp of this packet (block), the timestamp
+ * of the key block in this superblock, and the block
+ * duration. First we make sure we have a key block time.
+ */
+ if (bKey && !pHdr->bHasKeyTime) {
+ /* We note the timestamp of this key block */
+ pHdr->ulKeyTime = pPacket->ulTime;
+ /* Set the flag saying we have a key time */
+ pHdr->bHasKeyTime = TRUE;
+ }
+ /* Now we should have a key time */
+ if (pHdr->bHasKeyTime && ulPacketTime >= pHdr->ulKeyTime) {
+ /*
+ * Have we yet determined whether or
+ * not we need to adjust timestamps?
+ */
+ if (!pHdr->bKnowIfAdjustNeeded) {
+ /*
+ * If the last packet was not lost and was a
+ * keyframe and this packet is not a keyframe
+ * and the timestamps are the same, then we need
+ * to adjust timestamps.
+ */
+ if (pHdr->bHasLastPacket &&
+ !pHdr->lastPacket.ucLost &&
+ !bKey) {
+ /* Is this timestamp the same as the last packets? */
+ if (ulPacketTime == pHdr->lastPacket.ulTime) {
+ pHdr->bAdjustTimestamps = TRUE;
+ } else {
+ pHdr->bAdjustTimestamps = FALSE;
+ }
+ /* Now we know */
+ pHdr->bKnowIfAdjustNeeded = TRUE;
+ }
+ }
+ /* Do we need to adjust timestamps? */
+ if (pHdr->bKnowIfAdjustNeeded &&
+ pHdr->bAdjustTimestamps &&
+ !bKey) {
+ dTSOffset = pHdr->ulBlockCount * pHdr->dBlockDuration;
+ ulTSOffset = (UINT32)(dTSOffset + 0.5);
+ ulPacketTime += ulTSOffset;
+ }
+ /* Compute the index of the block within the superblock */
+ dTimeDiff = (HXDOUBLE)(ulPacketTime - pHdr->ulKeyTime);
+#ifndef __ARC600__
+ if (pHdr->dBlockDuration)
+#else
+ if (pHdr->dBlockDuration == 0.0) {
+ ;
+ } else
+#endif
+
+ {
+ dBlockNum = dTimeDiff / pHdr->dBlockDuration;
+ }
+ ulBlockNum = (UINT32)(dBlockNum + 0.5);
+ /* Is this block beyond our superblock? */
+ if (ulBlockNum >= pHdr->ulInterleaveFactor) {
+ /*
+ * We must have had loss at the end of the
+ * previous superblock, since we have received
+ * a packet in the next superblock without having
+ * sent the current superblock. Therefore, we attempt
+ * to finish out the current superblock and send it.
+ */
+ retVal = ra_depacki_deinterleave_send(pInt, ulSubStream);
+ if (retVal == HXR_OK) {
+ /* Now we need to update the block index */
+ if (bKey) {
+ /*
+ * This packet is a keyframe packet, so
+ * we simply assign the new time and set
+ * the block index to 0.
+ */
+ pHdr->ulKeyTime = pPacket->ulTime;
+ ulBlockNum = 0;
+ } else {
+ /*
+ * This is not a keyframe packet, so we need to
+ * keep adding the superblock time to the key time
+ * and keep subtracting interleave factor to the block
+ * index until we reach the range [0,intereaveFactor-1]
+ * for the index.
+ */
+ do {
+ pHdr->ulKeyTime += pHdr->ulSuperBlockTime;
+ ulBlockNum -= pHdr->ulInterleaveFactor;
+ } while (ulBlockNum < pHdr->ulInterleaveFactor);
+ }
+ }
+ }
+ /* Sanity check on buffer copy parameters */
+ if (ulBlockNum < pHdr->ulInterleaveFactor &&
+ ((UINT32) pPacket->usDataLen) == pHdr->ulInterleaveBlockSize &&
+ pHdr->pIPresentFlags) {
+ /* Copy the data into the interleave buffer */
+ memcpy(pHdr->pIBuffer + ulBlockNum * pHdr->ulInterleaveBlockSize,
+ pPacket->pData,
+ pHdr->ulInterleaveBlockSize);
+ /* Set all the flags to be present for this block */
+ pHdr->pIPresentFlags[ulBlockNum] = 0xFFFFFFFF;
+ /* Increment the block count in this superblock */
+ pHdr->ulBlockCount++;
+ /* Is this the last block in the superblock? */
+ if (ulBlockNum == pHdr->ulInterleaveFactor - 1) {
+ /* Deinterleave and send the blocks */
+ retVal = ra_depacki_deinterleave_send(pInt, ulSubStream);
+ } else {
+ /* Not ready to send yet. Clear the return */
+ retVal = HXR_OK;
+ }
+ }
+ } else {
+ /*
+ * We don't have a key block time or the key block time
+ * that we have is greater than the packet time, so we
+ * can't compute what slot this block should be in. This
+ * probably occurred because of loss at the beginning of the
+ * stream. We have to throw this packet away.
+ */
+ retVal = HXR_OK;
+ }
+ } else {
+ /*
+ * The packet was lost. For now, don't do anything
+ * with the packet. We will deduce loss based entirely
+ * on timestamps for now.
+ */
+ retVal = HXR_OK;
+ }
+ /* Save the information about the last packet */
+ pHdr->lastPacket.ulTime = pPacket->ulTime;
+ pHdr->lastPacket.usStream = pPacket->usStream;
+ pHdr->lastPacket.usASMFlags = pPacket->usASMFlags;
+ pHdr->lastPacket.ucASMRule = pPacket->ucASMRule;
+ pHdr->lastPacket.ucLost = pPacket->ucLost;
+ pHdr->bHasLastPacket = TRUE;
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_parse_vbr_packet(ra_depack_internal* pInt,
+ rm_packet* pPacket,
+ UINT32* pulNumAU,
+ HXBOOL* pbFragmented,
+ UINT32* pulAUSize,
+ UINT32* pulAUFragSize)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pPacket && pulNumAU && pbFragmented &&
+ pulAUSize && pulAUFragSize &&
+ pPacket->pData && pPacket->usDataLen) {
+ /* Init local variables */
+ BYTE* pBuf = pPacket->pData;
+ UINT32 ulSize = pPacket->usDataLen;
+ UINT32 ulPacketSize = ulSize;
+ UINT32 ulAUHeaderSizeBits = 0;
+ UINT32 ulAUHeaderSize = 0;
+ UINT32 ulNumAU = 0;
+ UINT32 ulAUSize = 0;
+ UINT32 ulAUSizeTotal = 0;
+ UINT32 i = 0;
+ UINT32 ulExpectedSize = 0;
+ /* Sanity check on size */
+ if (ulSize >= 2) {
+ /* Get the AU header size in bits */
+ ulAUHeaderSizeBits = rm_unpack16(&pBuf, &ulSize);
+ /* Convert to bytes (rounding up to next byte) */
+ ulAUHeaderSize = (ulAUHeaderSizeBits + 7) >> 3;
+ /*
+ * Sanity check to make sure that the AU header size is
+ * greater than 0 and a multiple of 2 bytes
+ */
+ if (ulAUHeaderSize && !(ulAUHeaderSize & 1)) {
+ /*
+ * Since we know that each AU header is 2 bytes, then
+ * we know that the number of AU's in this packet is
+ * ulAUHeaderSize / 2.
+ */
+ ulNumAU = ulAUHeaderSize >> 1;
+ /*
+ * The audio/mpeg-generic spec says that each packet
+ * can either have a complete AU, a fragment of a single
+ * AU, or multiple complete AUs. Therefore, if the
+ * number of AUs is greater than 1, then we know we
+ * have ulNumAU *complete* AUs. Therefore, for more
+ * than one AU, we know what the exact size of the
+ * packet should be, and that should match up with
+ * the data size of the packet.
+ */
+ retVal = HXR_OK;
+ for (i = 0; i < ulNumAU && retVal == HXR_OK; i++) {
+ if (ulSize >= 2) {
+ ulAUSize = rm_unpack16(&pBuf, &ulSize);
+ ulAUSizeTotal += ulAUSize;
+ } else {
+ retVal = HXR_FAIL;
+ }
+ }
+ if (retVal == HXR_OK) {
+ /* Compute the expected size of the packet */
+ ulExpectedSize = 2 + /* AU header size (16 bits) */
+ ulNumAU * 2 + /* AU sizes */
+ ulAUSizeTotal; /* the AU's themselves */
+ /*
+ * Check this against the actual size. If we have
+ * 1 AU, then the expected size can be greater than
+ * the actual size due to fragmentation. If we have
+ * more than more AU, then the expected size MUST
+ * match the actual size.
+ */
+ if (ulNumAU > 1) {
+ if (ulExpectedSize == ulPacketSize) {
+ /* Multiple AUs, no fragmentation */
+ *pbFragmented = FALSE;
+ } else {
+ /* Something wrong */
+ retVal = HXR_FAIL;
+ }
+ } else if (ulNumAU == 1) {
+ if (ulExpectedSize > ulPacketSize) {
+ /* Fragmented single AU */
+ *pbFragmented = TRUE;
+ } else {
+ /* Single AU, no fragmentation */
+ *pbFragmented = FALSE;
+ }
+ /* Set the AU size */
+ *pulAUSize = ulAUSizeTotal;
+ *pulAUFragSize = ulPacketSize - 4;
+ }
+ /* Assign the number of AU out parameter */
+ if (retVal == HXR_OK) {
+ *pulNumAU = ulNumAU;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_generate_and_send_loss(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ UINT32 ulFirstStartTime,
+ UINT32 ulLastEndTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && ulSubStream < pInt->multiStreamHdr.ulNumSubStreams &&
+ ulLastEndTime > ulFirstStartTime) {
+ HXDOUBLE dAUDuration = pInt->pSubStreamHdr[ulSubStream].dBlockDuration;
+ HXDOUBLE dDiff = ulLastEndTime - ulFirstStartTime;
+ UINT32 ulNumLossPackets = 0;
+ UINT32 i = 0;
+ UINT32 ulTSOffset = 0;
+ UINT32 ulTime = 0;
+ /* Compute the number of packets */
+#ifndef __ARC600__
+ if (dAUDuration != 0.0)
+#else
+ if (dAUDuration == 0.0) {
+ ;
+ } else
+#endif
+ {
+ ulNumLossPackets = (UINT32)(dDiff / dAUDuration);
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Generate loss packets */
+ for (i = 0; i < ulNumLossPackets && HX_SUCCEEDED(retVal); i++) {
+ ulTSOffset = (UINT32)(i * dAUDuration);
+ ulTime = ulFirstStartTime + ulTSOffset;
+ retVal = ra_depacki_send_block(pInt,
+ ulSubStream,
+ HXNULL,
+ 0,
+ ulTime,
+ 0); /* Flags of 0 indicate loss */
+ }
+ }
+
+ return retVal;
+}
+
+#if RA_COPY_BUF
+void ra_depacki_free_block(ra_block* pBlock)
+{
+ /* Free the data */
+ if (pBlock->pData) {
+ AVMem_free(pBlock->pData);
+ pBlock->pData = HXNULL;
+ }
+}
+#endif
+
+HX_RESULT ra_depacki_send_block(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ UINT32 ulTime,
+ UINT32 ulFlags)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->fpAvail) {
+ /* Allocate space for a ra_block structure */
+ ra_block Block;
+ memset(&Block, 0, sizeof(Block));
+ {
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Copy the buffer */
+ if (pBuf && ulLen) {
+#if RA_COPY_BUF
+ Block.pData = copy_buffer(pInt->pUserMem,
+ pInt->fpMalloc,
+ pBuf, ulLen);
+ if (Block.pData) {
+ Block.ulDataLen = ulLen;
+ } else {
+ retVal = HXR_OUTOFMEMORY;
+ }
+#else
+ Block.pData = pBuf;
+ Block.ulDataLen = ulLen;
+#endif
+ }
+ if (retVal == HXR_OK) {
+ /* Assign the timestamp and flags */
+ Block.ulTimestamp = ulTime;
+ Block.ulDataFlags = ulFlags;
+ /* Send the block */
+ retVal = pInt->fpAvail(pInt->pAvail,
+ ulSubStream,
+ &Block);
+ }
+#if RA_COPY_BUF
+ ra_depacki_free_block(&Block);
+#endif
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_handle_frag_packet(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ rm_packet* pPacket,
+ UINT32 ulAUSize,
+ UINT32 ulAUFragSize)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr && pPacket &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ UINT32 ulPacketSize = (UINT32) pPacket->usDataLen;
+ UINT32 ulPacketOffset = (ulPacketSize >= ulAUFragSize ?
+ ulPacketSize - ulAUFragSize : 0);
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Have we allocated the frag buffer yet? */
+ if (!pHdr->pFragBuffer) {
+ retVal = ra_depacki_init_frag_buffer(pInt, pHdr);
+ }
+ if (HX_SUCCEEDED(retVal)) {
+ /*
+ * Do we have a current fragment, and if so, is it
+ * a different timestamp from this fragment?
+ */
+ if (pHdr->bHasFrag && pHdr->ulFragBufferTime != pPacket->ulTime) {
+ /* Clear the frag buffer */
+ ra_depacki_clear_frag_buffer(pInt, pHdr);
+ }
+ /*
+ * Are we currently processing a fragment? If not,
+ * then initialize this fragment, resizing the
+ * buffer if necessary.
+ */
+ if (!pHdr->bHasFrag) {
+ /* Make sure the buffer size is big enough */
+ if (ulAUSize > pHdr->ulFragBufferSize) {
+ retVal = ra_depacki_resize_frag_buffer(pInt, pHdr, ulAUSize);
+ }
+ if (HX_SUCCEEDED(retVal)) {
+ /* Init the members for this fragment */
+ pHdr->ulFragBufferOffset = 0;
+ pHdr->ulFragBufferTime = pPacket->ulTime;
+ pHdr->ulFragBufferAUSize = ulAUSize;
+ pHdr->bHasFrag = TRUE;
+ }
+ }
+ if (HX_SUCCEEDED(retVal)) {
+ /* Make sure we have room for the memcpy */
+ if (pHdr->ulFragBufferOffset + ulAUFragSize <= pHdr->ulFragBufferSize &&
+ ulPacketOffset + ulAUFragSize <= ulPacketSize) {
+ /* Copy this buffer in */
+ memcpy(pHdr->pFragBuffer + pHdr->ulFragBufferOffset,
+ pPacket->pData + ulPacketOffset,
+ ulAUFragSize);
+ /* Update the frag buffer offset */
+ pHdr->ulFragBufferOffset += ulAUFragSize;
+ /* Have we finished the fragmented AU? */
+ if (pHdr->ulFragBufferOffset >= pHdr->ulFragBufferAUSize) {
+ /* Send the frag buffer */
+ retVal = ra_depacki_send_block(pInt, ulSubStream,
+ pHdr->pFragBuffer,
+ pHdr->ulFragBufferAUSize,
+ pHdr->ulFragBufferTime,
+ 0xFFFFFFFF);
+ /* Whether we succeed or not, clear the frag buffer */
+ ra_depacki_clear_frag_buffer(pInt, pHdr);
+ }
+ } else {
+ retVal = HXR_FAIL;
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_handle_nonfrag_packet(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ rm_packet* pPacket,
+ UINT32 ulNumAU)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr && pPacket &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Init the local variables */
+ UINT32 ulAUDataSizeSum = 0;
+ UINT32 i = 0;
+ BYTE* pBuf = pPacket->pData;
+ UINT32 ulLen = pPacket->usDataLen;
+ UINT32 ulTSOffset = 0;
+ UINT32 ulAUSize = 0;
+ UINT32 ulBufOffset = 0;
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /*
+ * We can clear the frag queue. If there was no
+ * loss in the last fragmented AU, then it was
+ * cleared after the packet was created. If there
+ * WAS loss in the last fragmented AU, then we
+ * just handled it by generating loss packets.
+ */
+ ra_depacki_clear_frag_buffer(pInt, pHdr);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Step through the packet sending blocks */
+ for (i = 0; i < ulNumAU && HX_SUCCEEDED(retVal); i++) {
+ /* Set the return value */
+ retVal = HXR_FAIL;
+ /* Compute the time offset for this block */
+ ulTSOffset = (UINT32)(i * pHdr->dBlockDuration);
+ /* Compute the buffer offset for the AU size */
+ ulBufOffset = 2 + (i << 1);
+ /* Sanity check on packet size */
+ if (ulBufOffset + 1 < ulLen) {
+ /* Parse out the size of this AU */
+ ulAUSize = rm_unpack16_nse(pBuf + ulBufOffset,
+ ulLen - ulBufOffset);
+ /* Compute the offset of the AU */
+ ulBufOffset = 2 + ulNumAU * 2 + ulAUDataSizeSum;
+ /* Sanity check on size */
+ if (ulBufOffset + ulAUSize <= ulLen) {
+ /* Send this AU */
+ retVal = ra_depacki_send_block(pInt,
+ ulSubStream,
+ pBuf + ulBufOffset,
+ ulAUSize,
+ pPacket->ulTime + ulTSOffset,
+ 0xFFFFFFFF);
+ if (retVal == HXR_OK) {
+ /* Update the AU data size sum */
+ ulAUDataSizeSum += ulAUSize;
+ }
+ }
+ }
+ }
+ if (HX_SUCCEEDED(retVal)) {
+ /* Update the end time of the last block sent */
+ ulTSOffset = (UINT32)(ulNumAU * pHdr->dBlockDuration);
+ pHdr->ulLastSentEndTime = pPacket->ulTime + ulTSOffset;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_init_frag_buffer(ra_depack_internal* pInt,
+ ra_substream_hdr* pHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pHdr && !pHdr->pFragBuffer) {
+ /* Allocate the frag buffer */
+ pHdr->pFragBuffer = ra_depacki_malloc(pInt, INITIAL_FRAG_BUFFER_SIZE);
+ if (pHdr->pFragBuffer) {
+ /* Zero out the buffer */
+ memset(pHdr->pFragBuffer, 0, INITIAL_FRAG_BUFFER_SIZE);
+ /* Init the members */
+ pHdr->ulFragBufferSize = INITIAL_FRAG_BUFFER_SIZE;
+ pHdr->ulFragBufferTime = 0;
+ pHdr->ulFragBufferOffset = 0;
+ pHdr->ulFragBufferAUSize = 0;
+ pHdr->bHasFrag = FALSE;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_resize_frag_buffer(ra_depack_internal* pInt,
+ ra_substream_hdr* pHdr,
+ UINT32 ulNewSize)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pHdr && pHdr->pFragBuffer) {
+ /* Allocate a new buffer */
+ BYTE* pNewBuf = ra_depacki_malloc(pInt, ulNewSize);
+ if (pNewBuf) {
+ /* Copy the old buffer */
+ if (pHdr->ulFragBufferOffset) {
+ memcpy(pNewBuf, pHdr->pFragBuffer, pHdr->ulFragBufferOffset);
+ }
+ /* NULL out the rest of the buffer */
+ memset(pNewBuf + pHdr->ulFragBufferOffset, 0,
+ ulNewSize - pHdr->ulFragBufferOffset);
+ /* Free the old buffer */
+ ra_depacki_free(pInt, pHdr->pFragBuffer);
+ /* Assign the members. We won't change time or offset */
+ pHdr->pFragBuffer = pNewBuf;
+ pHdr->ulFragBufferSize = ulNewSize;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+void ra_depacki_clear_frag_buffer(ra_depack_internal* pInt,
+ ra_substream_hdr* hdr)
+{
+ if (pInt && hdr && hdr->bHasFrag) {
+ /* Clear the frag buffer members */
+ hdr->bHasFrag = FALSE;
+ hdr->ulFragBufferAUSize = 0;
+ hdr->ulFragBufferOffset = 0;
+ hdr->ulFragBufferTime = 0;
+ }
+}
+
+HX_RESULT ra_depacki_seek(ra_depack_internal* pInt, UINT32 ulTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr) {
+ /*
+ * Loop through all the substream headers
+ * and set the bSeeked flag.
+ */
+ UINT32 i = 0;
+ for (i = 0; i < pInt->multiStreamHdr.ulNumSubStreams; i++) {
+ pInt->pSubStreamHdr[i].bSeeked = TRUE;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_deinterleave_send(ra_depack_internal* pInt, UINT32 ulSubStream)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams &&
+ pInt->fpAvail) {
+ /* Init local variables */
+ UINT32 i = 0;
+ UINT32 ulTimeOffset = 0;
+ UINT32 ulTimestamp = 0;
+ HXDOUBLE dTimeOffset = 0.0;
+ ra_block Block;
+ /* Deinterleave the superblock */
+ retVal = ra_depacki_deinterleave(pInt, ulSubStream);
+ if (retVal == HXR_OK) {
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /* Send the blocks from the deinterleave buffer */
+ for (i = 0; i < pHdr->ulBlockCount&& i < pHdr->ulInterleaveFactor && HX_SUCCEEDED(retVal); i++) {
+ /* Set the return value */
+ retVal = HXR_OUTOFMEMORY;
+ /* Compute the time offset for this block */
+ dTimeOffset = i * pHdr->dBlockDuration;
+ ulTimeOffset = (UINT32) dTimeOffset;
+ ulTimestamp = pHdr->ulKeyTime + ulTimeOffset;
+ /* Make sure the time is less than the stream duration */
+ if (ulTimestamp <= pInt->ulStreamDuration) {
+#if RA_COPY_BUF
+ /* Alloc and copy the buffer */
+ Block.pData = copy_buffer(pInt->pUserMem,
+ pInt->fpMalloc,
+ pHdr->pDBuffer + i * pHdr->ulInterleaveBlockSize,
+ pHdr->ulInterleaveBlockSize);
+#else
+ Block.pData = pHdr->pDBuffer + i * pHdr->ulInterleaveBlockSize;
+#endif
+ if (Block.pData) {
+ Block.ulDataLen = pHdr->ulInterleaveBlockSize;
+ Block.ulTimestamp = ulTimestamp;
+ Block.ulDataFlags = pHdr->pDPresentFlags[i];
+ /* Send the block */
+ retVal = pInt->fpAvail(pInt->pAvail, ulSubStream, &Block);
+ }
+#if RA_COPY_BUF
+ ra_depacki_free_block(&Block);
+#endif
+ } else {
+ /*
+ * Block is after the stream duration, so clear
+ * the return value and break out of the loop.
+ */
+ retVal = HXR_OK;
+ break;
+ }
+ }
+ /* Clear the interleaving buffers */
+ memset(pHdr->pIBuffer, 0, pHdr->ulSuperBlockSize);
+ memset(pHdr->pDBuffer, 0, pHdr->ulSuperBlockSize);
+ memset(pHdr->pIPresentFlags, 0, pHdr->ulInterleaveFactor * sizeof(UINT32));
+ memset(pHdr->pDPresentFlags, 0, pHdr->ulInterleaveFactor * sizeof(UINT32));
+ /* Clear the state */
+ pHdr->bHasKeyTime = FALSE;
+ pHdr->ulKeyTime = 0;
+ pHdr->ulBlockCount = 0;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_deinterleave(ra_depack_internal* pInt, UINT32 ulSubStream)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Get the interleaver ID */
+ UINT32 ulID = pInt->pSubStreamHdr[ulSubStream].ulInterleaverID;
+ /* Switch based on ID */
+ switch (ulID) {
+#if 0
+ case RA_INTERLEAVER_SIPR:
+ retVal = ra_depacki_deinterleave_sipr(pInt, ulSubStream);
+ break;
+#endif
+ case RA_INTERLEAVER_GENR:
+ retVal = ra_depacki_deinterleave_genr(pInt, ulSubStream);
+ break;
+ case RA_NO_INTERLEAVER:
+ retVal = ra_depacki_deinterleave_no(pInt, ulSubStream);
+ break;
+ }
+ }
+
+ return retVal;
+}
+
+#if 0
+HX_RESULT ra_depacki_deinterleave_sipr(ra_depack_internal* pInt, UINT32 ulSubStream)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /* Sanity check */
+ if (pHdr->pIBuffer && pHdr->pDBuffer &&
+ pHdr->pIPresentFlags && pHdr->pDPresentFlags) {
+ /*
+ * This is an in-place interleaving, so copy from
+ * pIBuffer to pDBuffer and then we will do the
+ * de-interleaving in-place in pDBuffer.
+ */
+ memcpy(pHdr->pDBuffer, pHdr->pIBuffer, pHdr->ulSuperBlockSize);
+ /* Copy the flags */
+ memcpy(pHdr->pDPresentFlags, pHdr->pIPresentFlags,
+ pHdr->ulInterleaveFactor * sizeof(UINT32));
+ /* Do the de-interleave */
+ RASL_DeInterleave((char*) pHdr->pDBuffer,
+ pHdr->ulSuperBlockSize,
+ pHdr->usFlavorIndex,
+ pHdr->pDPresentFlags);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+#endif
+
+HX_RESULT ra_depacki_init_genr(ra_depack_internal* pInt, UINT32 ulSubStream)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Init local variables */
+ UINT32 ulFramesPerBlock = 0;
+ UINT32 ulSize = 0;
+ UINT32 ulBlockIndx = 0;
+ UINT32 ulFrameIndx = 0;
+ UINT32 ulIndx = 0;
+ UINT32 i = 0;
+ UINT32 j = 0;
+ UINT32 ulCount = 0;
+ HXBOOL bEven = FALSE;
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /* Sanity check */
+ if (pHdr->ulCodecFrameSize && pHdr->ulNumCodecFrames) {
+ /* Compute the codec frames per block */
+ ulFramesPerBlock = pHdr->ulInterleaveBlockSize / pHdr->ulCodecFrameSize;
+ /* Allocate space for the block num and offset */
+ ulSize = pHdr->ulNumCodecFrames * sizeof(UINT32);
+ pHdr->pulGENRBlockNum = (UINT32*) ra_depacki_malloc(pInt, ulSize);
+ if (pHdr->pulGENRBlockNum) {
+ pHdr->pulGENRBlockOffset = (UINT32*) ra_depacki_malloc(pInt, ulSize);
+ if (pHdr->pulGENRBlockOffset) {
+ pHdr->pulGENRPattern = (UINT32*) ra_depacki_malloc(pInt, ulSize);
+ if (pHdr->pulGENRPattern) {
+ /* Initialize the block num and offset arrays */
+ for (ulBlockIndx = 0; ulBlockIndx < pHdr->ulInterleaveFactor; ulBlockIndx++) {
+ for (ulFrameIndx = 0; ulFrameIndx < ulFramesPerBlock; ulFrameIndx++) {
+ ulIndx = ulBlockIndx * ulFramesPerBlock + ulFrameIndx;
+ pHdr->pulGENRBlockNum[ulIndx] = ulBlockIndx;
+ pHdr->pulGENRBlockOffset[ulIndx] = ulFrameIndx;
+ }
+ }
+ /* Do we have a pattern from the stream header? */
+ if (pHdr->pulInterleavePattern) {
+ /* Copy the pattern from the stream header */
+ memcpy(pHdr->pulGENRPattern,
+ pHdr->pulInterleavePattern,
+ ulSize);
+ /*
+ * Check the pattern for validity by making sure
+ * that each frame index is used once and only
+ * once in the interleave pattern.
+ */
+ retVal = HXR_OK;
+ for (i = 0; i < pHdr->ulNumCodecFrames; i++) {
+ /* Init the count */
+ ulCount = 0;
+ /* Count how many times index i appears in table */
+ for (j = 0; j < pHdr->ulNumCodecFrames; j++) {
+ if (pHdr->pulGENRPattern[j] == i) {
+ ulCount++;
+ }
+ }
+ /* Make sure it's just once */
+ if (ulCount != 1) {
+ retVal = HXR_FAIL;
+ break;
+ }
+ }
+ } else {
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /*
+ * We don't have a stream header pattern, so
+ * we generate the standard interleave pattern.
+ */
+ if (pHdr->ulInterleaveFactor == 1) {
+ for (i = 0; i < pHdr->ulNumCodecFrames; i++) {
+ pHdr->pulGENRPattern[i] = i;
+ }
+ } else {
+ bEven = TRUE;
+ ulCount = 0;
+ ulBlockIndx = 0;
+ ulFrameIndx = 0;
+ while (ulCount < pHdr->ulNumCodecFrames) {
+ pHdr->pulGENRPattern[ulCount] = ulBlockIndx * ulFramesPerBlock + ulFrameIndx;
+ ulCount++;
+ ulBlockIndx += 2;
+ if (ulBlockIndx >= pHdr->ulInterleaveFactor) {
+ if (bEven) {
+ bEven = FALSE;
+ ulBlockIndx = 1;
+ } else {
+ bEven = TRUE;
+ ulBlockIndx = 0;
+ ulFrameIndx++;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_deinterleave_genr(ra_depack_internal* pInt, UINT32 ulSubStream)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Init local variables */
+ UINT32 fi = 0;
+ UINT32 fo = 0;
+ UINT32 ulBlkIndxIn = 0;
+ UINT32 ulBlkIndxOut = 0;
+ UINT32 ulBlkOffset = 0;
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /* Sanity check */
+ if (pHdr->pIBuffer && pHdr->pDBuffer &&
+ pHdr->pIPresentFlags && pHdr->pDPresentFlags) {
+ /* Set all the output flags to present initially */
+ memset(pHdr->pDPresentFlags, 0xFF,
+ pHdr->ulInterleaveFactor * sizeof(UINT32));
+ /* Deinterleave the data */
+ for (fo = 0; fo < pHdr->ulNumCodecFrames; fo++) {
+ /* Copy the data */
+ fi = pHdr->pulGENRPattern[fo];
+ memcpy(pHdr->pDBuffer + fo * pHdr->ulCodecFrameSize,
+ pHdr->pIBuffer + fi * pHdr->ulCodecFrameSize,
+ pHdr->ulCodecFrameSize);
+ /* Look up which block this frame comes from */
+ ulBlkIndxIn = pHdr->pulGENRBlockNum[fi];
+ /* Is this codec frame present? */
+ if (!pHdr->pIPresentFlags[ulBlkIndxIn]) {
+ /*
+ * Frame was part of a lost block. So clear
+ * the bit that says the frame was present.
+ */
+ ulBlkIndxOut = pHdr->pulGENRBlockNum[fo];
+ ulBlkOffset = pHdr->pulGENRBlockOffset[fo];
+ pHdr->pDPresentFlags[ulBlkIndxOut] ^= (1 << ulBlkOffset);
+ }
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_deinterleave_no(ra_depack_internal* pInt, UINT32 ulSubStream)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Init local variables */
+ UINT32 fi = 0;
+ UINT32 fo = 0;
+ UINT32 ulBlkIndxIn = 0;
+ UINT32 ulBlkIndxOut = 0;
+ UINT32 ulBlkOffset = 0;
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /* Sanity check */
+ if (pHdr->pIBuffer && pHdr->pDBuffer &&
+ pHdr->pIPresentFlags && pHdr->pDPresentFlags) {
+ /* Set all the output flags to present initially */
+ memset(pHdr->pDPresentFlags, 0xFF,
+ pHdr->ulInterleaveFactor * sizeof(UINT32));
+ /* Deinterleave the data */
+ for (fo = 0; fo < pHdr->ulNumCodecFrames; fo++) {
+ /* Copy the data */
+ fi = fo;
+ memcpy(pHdr->pDBuffer + fo * pHdr->ulCodecFrameSize,
+ pHdr->pIBuffer + fi * pHdr->ulCodecFrameSize,
+ pHdr->ulCodecFrameSize);
+ /* Look up which block this frame comes from */
+ ulBlkIndxIn = pHdr->pulGENRBlockNum[fi];
+ /* Is this codec frame present? */
+ if (!pHdr->pIPresentFlags[ulBlkIndxIn]) {
+ /*
+ * Frame was part of a lost block. So clear
+ * the bit that says the frame was present.
+ */
+ ulBlkIndxOut = pHdr->pulGENRBlockNum[fo];
+ ulBlkOffset = pHdr->pulGENRBlockOffset[fo];
+ pHdr->pDPresentFlags[ulBlkIndxOut] ^= (1 << ulBlkOffset);
+ }
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
diff --git a/audio_codec/libcook/ra_depack_internal.h b/audio_codec/libcook/ra_depack_internal.h
new file mode 100644
index 0000000..d139598
--- a/dev/null
+++ b/audio_codec/libcook/ra_depack_internal.h
@@ -0,0 +1,232 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: ra_depack_internal.h,v 1.1.1.1.2.1 2005/05/04 18:21:33 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RA_DEPACK_INTERNAL_H
+#define RA_DEPACK_INTERNAL_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+#include "rm_error.h"
+#include "ra_depack.h"
+#include "stream_hdr_structs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /*
+ * Internal substream header struct
+ */
+ typedef struct ra_substream_hdr_struct {
+ UINT16 usRAFormatVersion; /* 3, 4, or 5 */
+ UINT16 usRAFormatRevision; /* should be 0 */
+ UINT16 usHeaderBytes; /* size of raheader info */
+ UINT16 usFlavorIndex; /* compression type */
+ UINT32 ulGranularity; /* size of one block of encoded data */
+ UINT32 ulTotalBytes; /* total bytes of ra data */
+ UINT32 ulBytesPerMin; /* data rate of encoded and interleaved data */
+ UINT32 ulBytesPerMin2; /* data rate of interleaved or non-interleaved data */
+ UINT32 ulInterleaveFactor; /* number of blocks per superblock */
+ UINT32 ulInterleaveBlockSize; /* size of each interleave block */
+ UINT32 ulCodecFrameSize; /* size of each audio frame */
+ UINT32 ulUserData; /* extra field for user data */
+ UINT32 ulSampleRate; /* sample rate of decoded audio */
+ UINT32 ulActualSampleRate; /* sample rate of decoded audio */
+ UINT32 ulSampleSize; /* bits per sample in decoded audio */
+ UINT32 ulChannels; /* number of audio channels in decoded audio */
+ UINT32 ulInterleaverID; /* interleaver 4cc */
+ UINT32 ulCodecID; /* codec 4cc */
+ BYTE bIsInterleaved; /* 1 if file has been interleaved */
+ BYTE bCopyByte; /* copy enable byte, if 1 allow copies (SelectiveRecord) */
+ BYTE ucStreamType; /* i.e. LIVE_STREAM, FILE_STREAM */
+ BYTE ucScatterType; /* the interleave pattern type 0==cyclic,1==pattern */
+ UINT32 ulNumCodecFrames; /* number of codec frames in a superblock */
+ UINT32* pulInterleavePattern; /* the pattern of interleave if not cyclic */
+ UINT32 ulOpaqueDataSize; /* size of the codec specific data */
+ BYTE* pOpaqueData; /* codec specific data */
+ HXDOUBLE dBlockDuration; /* Duration in ms of audio "block" */
+ UINT32 ulLastSentEndTime; /* Ending time of last sent audio frame */
+ BYTE* pFragBuffer; /* Intermediate buffer for reconstructing VBR packets */
+ UINT32 ulFragBufferSize; /* Size of intermediate buffer */
+ UINT32 ulFragBufferAUSize; /* Size of AU being reconstructed */
+ UINT32 ulFragBufferOffset; /* Current offset within AU */
+ UINT32 ulFragBufferTime; /* Timestamp of AU being reconstructed */
+ UINT32 ulSuperBlockSize; /* ulInterleaveBlockSize * ulInterleaveFactor */
+ UINT32 ulSuperBlockTime; /* dBlockDuration * ulInterleaveFactor */
+ UINT32 ulKeyTime; /* Timestamp of keyframe packet */
+ BYTE* pIBuffer; /* Buffer holding interleaved blocks */
+ BYTE* pDBuffer; /* Buffer holding de-interleaved blocks */
+ UINT32* pIPresentFlags; /* number of UINT32s: ulInterleaveBlockSize */
+ UINT32* pDPresentFlags; /* number of UINT32s: ulInterleaveBlockSize */
+ UINT32 ulBlockCount; /* number of blocks currently in superblock */
+ UINT32* pulGENRPattern; /* Interleave pattern for GENR interleaver */
+ UINT32* pulGENRBlockNum;
+ UINT32* pulGENRBlockOffset;
+ rm_packet lastPacket;
+ HX_BITFIELD bIsVBR : 1;
+ HX_BITFIELD bSeeked : 1;
+ HX_BITFIELD bLossOccurred : 1;
+ HX_BITFIELD bHasKeyTime : 1; /* Do we have a time for the key slot? */
+ HX_BITFIELD bHasFrag : 1;
+ HX_BITFIELD bAdjustTimestamps : 1;
+ HX_BITFIELD bKnowIfAdjustNeeded : 1;
+ HX_BITFIELD bHasLastPacket : 1;
+ } ra_substream_hdr;
+
+ /*
+ * Internal ra_depack struct
+ */
+ typedef struct ra_depack_internal_struct {
+ void* pAvail;
+ ra_block_avail_func_ptr fpAvail;
+ rm_error_func_ptr fpError;
+ void* pUserError;
+ rm_malloc_func_ptr fpMalloc;
+ rm_free_func_ptr fpFree;
+ void* pUserMem;
+ rm_rule_map rule2Flag;
+ rm_multistream_hdr multiStreamHdr;
+ ra_substream_hdr* pSubStreamHdr;
+ UINT32 ulTrackStartTime;
+ UINT32 ulTrackEndTime;
+ UINT32 ulEndTime;
+ UINT32 ulStreamDuration;
+ HX_BITFIELD bForceTrackStartTime : 1;
+ HX_BITFIELD bForceTrackEndTime : 1;
+ HX_BITFIELD bStreamSwitchable : 1;
+ HX_BITFIELD bAllVBR : 1;
+ HX_BITFIELD bAllNonVBR : 1;
+ HX_BITFIELD bHasEndTime : 1;
+ } ra_depack_internal;
+
+ /*
+ * Internal ra_depack functions
+ */
+ void* ra_depacki_malloc(ra_depack_internal* pInt, UINT32 ulSize);
+ void ra_depacki_free(ra_depack_internal* pInt, void* pMem);
+ HX_RESULT ra_depacki_init(ra_depack_internal* pInt, rm_stream_header* hdr);
+ HX_RESULT ra_depacki_unpack_rule_map(ra_depack_internal* pInt,
+ rm_rule_map* pMap,
+ BYTE** ppBuf,
+ UINT32* pulLen);
+ HX_RESULT ra_depacki_unpack_multistream_hdr(ra_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen);
+ HX_RESULT ra_depacki_unpack_opaque_data(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen);
+ void ra_depacki_cleanup_substream_hdr(ra_depack_internal* pInt,
+ ra_substream_hdr* hdr);
+ void ra_depacki_cleanup_substream_hdr_array(ra_depack_internal* pInt);
+ HX_RESULT ra_depacki_unpack_substream_hdr(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ ra_substream_hdr* pHdr);
+ HX_RESULT ra_depacki_unpack_raformat3(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ ra_substream_hdr* pHdr);
+ HX_RESULT ra_depacki_unpack_raformat4(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ ra_substream_hdr* pHdr);
+ HX_RESULT ra_depacki_unpack_raformat5(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ ra_substream_hdr* pHdr);
+ HX_RESULT ra_depacki_get_format_info(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ ra_format_info* pInfo);
+ void ra_depacki_cleanup_format_info(ra_depack_internal* pInt,
+ ra_format_info* pInfo);
+ UINT32 ra_depacki_rule_to_flags(ra_depack_internal* pInt, UINT32 ulRule);
+ HXBOOL ra_depacki_is_keyframe_rule(ra_depack_internal* pInt, UINT32 ulRule);
+ UINT32 ra_depacki_rule_to_substream(ra_depack_internal* pInt, UINT32 ulRule);
+ HX_RESULT ra_depacki_add_packet(ra_depack_internal* pInt,
+ rm_packet* pPacket);
+ HX_RESULT ra_depacki_add_vbr_packet(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ rm_packet* pPacket);
+ HX_RESULT ra_depacki_add_non_vbr_packet(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ rm_packet* pPacket);
+ HX_RESULT ra_depacki_parse_vbr_packet(ra_depack_internal* pInt,
+ rm_packet* pPacket,
+ UINT32* pulNumAU,
+ HXBOOL* pbFragmented,
+ UINT32* pulAUSize,
+ UINT32* pulAUFragSize);
+ HX_RESULT ra_depacki_generate_and_send_loss(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ UINT32 ulFirstStartTime,
+ UINT32 ulLastEndTime);
+ HX_RESULT ra_depacki_send_block(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ UINT32 ulTime,
+ UINT32 ulFlags);
+ HX_RESULT ra_depacki_handle_frag_packet(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ rm_packet* pPacket,
+ UINT32 ulAUSize,
+ UINT32 ulAUFragSize);
+ HX_RESULT ra_depacki_handle_nonfrag_packet(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ rm_packet* pPacket,
+ UINT32 ulNumAU);
+ HX_RESULT ra_depacki_init_frag_buffer(ra_depack_internal* pInt,
+ ra_substream_hdr* pHdr);
+ HX_RESULT ra_depacki_resize_frag_buffer(ra_depack_internal* pInt,
+ ra_substream_hdr* pHdr,
+ UINT32 ulNewSize);
+ void ra_depacki_clear_frag_buffer(ra_depack_internal* pInt,
+ ra_substream_hdr* hdr);
+ HX_RESULT ra_depacki_seek(ra_depack_internal* pInt, UINT32 ulTime);
+ HX_RESULT ra_depacki_deinterleave_send(ra_depack_internal* pInt, UINT32 ulSubStream);
+ HX_RESULT ra_depacki_deinterleave(ra_depack_internal* pInt, UINT32 ulSubStream);
+ HX_RESULT ra_depacki_deinterleave_sipr(ra_depack_internal* pInt, UINT32 ulSubStream);
+ HX_RESULT ra_depacki_init_genr(ra_depack_internal* pInt, UINT32 ulSubStream);
+ HX_RESULT ra_depacki_deinterleave_genr(ra_depack_internal* pInt, UINT32 ulSubStream);
+ HX_RESULT ra_depacki_deinterleave_no(ra_depack_internal* pInt, UINT32 ulSubStream);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef RA_DEPACK_INTERNAL_H */
diff --git a/audio_codec/libcook/ra_envelope.c b/audio_codec/libcook/ra_envelope.c
new file mode 100644
index 0000000..87a7f33
--- a/dev/null
+++ b/audio_codec/libcook/ra_envelope.c
@@ -0,0 +1,123 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: envelope.c,v 1.6 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * envelope.c - power envelope reconstruction
+ **************************************************************************************/
+
+#include "coder.h"
+
+/* coding params for rms[0] */
+#define RMS0BITS 6 /* bits for env[0] */
+#define RMS0MIN -6 /* arbitrary! */
+#define CODE2RMS(i) ((i)+(RMS0MIN))
+
+/**************************************************************************************
+ * Function: DecodeEnvelope
+ *
+ * Description: decode the power envelope
+ *
+ * Inputs: pointer to initialized Gecko2Info struct
+ * number of bits remaining in bitstream for this frame
+ * index of current channel
+ *
+ * Outputs: rmsIndex[0, ..., cregsions-1] has power index for each region
+ * updated rmsMax with largest value of rmsImdex for this channel
+ *
+ * Return: number of bits remaining in bitstream, -1 if out-of-bits
+ **************************************************************************************/
+int DecodeEnvelope(Gecko2Info *gi, int availbits, int ch)
+{
+ int r, code, nbits, rprime, cache, rmsMax;
+ int *rmsIndex = gi->db.rmsIndex;
+ BitStreamInfo *bsi = &(gi->bsi);
+
+ if (availbits < RMS0BITS) {
+ return -1;
+ }
+
+ /* unpack first index */
+ code = GetBits(bsi, RMS0BITS, 1);
+ availbits -= RMS0BITS;
+ rmsIndex[0] = CODE2RMS(code);
+
+ /* check for escape code */
+ /* ASSERT(rmsIndex[0] != 0); */
+
+ rmsMax = rmsIndex[0];
+ for (r = 1; r < gi->cRegions; r++) {
+
+ /* for interleaved regions, choose a reasonable table */
+ if (r < 2 * gi->cplStart) {
+ rprime = r >> 1;
+ if (rprime < 1) {
+ rprime = 1;
+ }
+ } else {
+ rprime = r - gi->cplStart;
+ }
+
+ /* above NUM_POWTABLES, always use the same Huffman table */
+ if (rprime > NUM_POWTABLES) {
+ rprime = NUM_POWTABLES;
+ }
+
+ cache = GetBits(bsi, MAX_HUFF_BITS, 0);
+ nbits = DecodeHuffmanScalar(huffTabPower, &huffTabPowerInfo[rprime - 1], cache, &code);
+
+ /* ran out of bits coding power envelope - should not happen (encoder spec) */
+ if (nbits > availbits) {
+ return -1;
+ }
+
+ availbits -= nbits;
+ AdvanceBitstream(bsi, nbits);
+
+ /* encoder uses differential coding with differences constrained to the range [-12, 11] */
+ rmsIndex[r] = rmsIndex[r - 1] + (code - 12);
+ if (rmsIndex[r] > rmsMax) {
+ rmsMax = rmsIndex[r];
+ }
+ }
+ gi->rmsMax[ch] = rmsMax;
+
+ return availbits;
+}
diff --git a/audio_codec/libcook/ra_fft.c b/audio_codec/libcook/ra_fft.c
new file mode 100644
index 0000000..6091de9
--- a/dev/null
+++ b/audio_codec/libcook/ra_fft.c
@@ -0,0 +1,368 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: fft.c,v 1.4 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Ken Cooke (kenc@real.com), Jon Recker(jrecker@real.com)
+ * October 2003
+ *
+ * fft.c - Ken's highly optimized radix-4 DIT FFT, with optional radix-8 first pass
+ * for odd powers of 2
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+#define NUM_FFT_SIZES 3
+static const int nfftTab[NUM_FFT_SIZES] = {128, 256, 512};
+static const int nfftlog2Tab[NUM_FFT_SIZES] = {7, 8, 9};
+
+#define SQRT1_2 1518500250 /* sqrt(1/2) in Q31 */
+
+#define swapcplx(p0,p1) \
+ t = p0; t1 = *(&(p0)+1); p0 = p1; *(&(p0)+1) = *(&(p1)+1); p1 = t; *(&(p1)+1) = t1
+
+/**************************************************************************************
+ * Function: BitReverse
+ *
+ * Description: Ken's fast in-place bit reverse, using super-small table
+ *
+ * Inputs: buffer of samples
+ * table index (for transform size)
+ *
+ * Outputs: bit-reversed samples in same buffer
+ *
+ * Return: none
+ **************************************************************************************/
+static void BitReverse(int *inout, int tabidx)
+{
+ /* 1st part: non-id */
+ int *part0, *part1;
+ int a, b, t, t1;
+ const unsigned char* tab = bitrevtab + bitrevtabOffset[tabidx];
+ int nbits = nfftlog2Tab[tabidx];
+
+ part0 = inout;
+ part1 = inout + (1 << nbits);
+
+ while ((a = *tab++) != 0) {
+ b = *tab++;
+
+ swapcplx(part0[4 * a + 0], part0[4 * b + 0]); /* 0xxx0 <-> 0yyy0 */
+ swapcplx(part0[4 * a + 2], part1[4 * b + 0]); /* 0xxx1 <-> 1yyy0 */
+ swapcplx(part1[4 * a + 0], part0[4 * b + 2]); /* 1xxx0 <-> 0yyy1 */
+ swapcplx(part1[4 * a + 2], part1[4 * b + 2]); /* 1xxx1 <-> 1yyy1 */
+ }
+
+ do {
+ swapcplx(part0[4 * a + 2], part1[4 * a + 0]); /* 0xxx1 <-> 1xxx0 */
+ } while ((a = *tab++) != 0);
+}
+
+/**************************************************************************************
+ * Function: R4FirstPass
+ *
+ * Description: radix-4 trivial pass for decimation-in-time FFT
+ *
+ * Inputs: buffer of (bit-reversed) samples
+ * number of R4 butterflies per group (i.e. nfft / 4)
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 3 guard bits, gains no integer bits,
+ * guard bits out = guard bits in - 3
+ **************************************************************************************/
+static void R4FirstPass(int *x, int bg)
+{
+ int ar, ai, br, bi, cr, ci, dr, di;
+
+ for (; bg != 0; bg--) {
+
+ ar = x[0] + x[2];
+ br = x[0] - x[2];
+ ai = x[1] + x[3];
+ bi = x[1] - x[3];
+ cr = x[4] + x[6];
+ dr = x[4] - x[6];
+ ci = x[5] + x[7];
+ di = x[5] - x[7];
+
+ x[0] = ar + cr;
+ x[4] = ar - cr;
+ x[1] = ai + ci;
+ x[5] = ai - ci;
+ x[2] = br + di;
+ x[6] = br - di;
+ x[3] = bi - dr;
+ x[7] = bi + dr;
+
+ x += 8;
+ }
+}
+
+/**************************************************************************************
+ * Function: R8FirstPass
+ *
+ * Description: radix-8 trivial pass for decimation-in-time FFT
+ *
+ * Inputs: buffer of (bit-reversed) samples
+ * number of R8 butterflies per group (i.e. nfft / 8)
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 3 guard bits, gains 1 integer bit,
+ * guard bits out = guard bits in - 3
+ **************************************************************************************/
+static void R8FirstPass(int *x, int bg)
+{
+ int ar, ai, br, bi, cr, ci, dr, di;
+ int sr, si, tr, ti, ur, ui, vr, vi;
+ int wr, wi, xr, xi, yr, yi, zr, zi;
+
+ for (; bg != 0; bg--) {
+
+ ar = x[0] + x[2];
+ br = x[0] - x[2];
+ ai = x[1] + x[3];
+ bi = x[1] - x[3];
+ cr = x[4] + x[6];
+ dr = x[4] - x[6];
+ ci = x[5] + x[7];
+ di = x[5] - x[7];
+
+ sr = ar + cr;
+ ur = ar - cr;
+ si = ai + ci;
+ ui = ai - ci;
+ tr = br - di;
+ vr = br + di;
+ ti = bi + dr;
+ vi = bi - dr;
+
+ ar = x[ 8] + x[10];
+ br = x[ 8] - x[10];
+ ai = x[ 9] + x[11];
+ bi = x[ 9] - x[11];
+ cr = x[12] + x[14];
+ dr = x[12] - x[14];
+ ci = x[13] + x[15];
+ di = x[13] - x[15];
+
+ wr = (ar + cr) >> 1;
+ yr = (ar - cr) >> 1;
+ wi = (ai + ci) >> 1;
+ yi = (ai - ci) >> 1;
+
+ /* gain 1 bit per R8 pass */
+ x[ 0] = (sr >> 1) + wr;
+ x[ 8] = (sr >> 1) - wr;
+ x[ 1] = (si >> 1) + wi;
+ x[ 9] = (si >> 1) - wi;
+ x[ 4] = (ur >> 1) + yi;
+ x[12] = (ur >> 1) - yi;
+ x[ 5] = (ui >> 1) - yr;
+ x[13] = (ui >> 1) + yr;
+
+ ar = br - di;
+ cr = br + di;
+ ai = bi + dr;
+ ci = bi - dr;
+
+ /* gain 1 bit from mul by Q31 */
+ xr = MULSHIFT32(SQRT1_2, ar - ai);
+ xi = MULSHIFT32(SQRT1_2, ar + ai);
+ zr = MULSHIFT32(SQRT1_2, cr - ci);
+ zi = MULSHIFT32(SQRT1_2, cr + ci);
+
+ x[ 6] = (tr >> 1) - xr;
+ x[14] = (tr >> 1) + xr;
+ x[ 7] = (ti >> 1) - xi;
+ x[15] = (ti >> 1) + xi;
+ x[ 2] = (vr >> 1) + zi;
+ x[10] = (vr >> 1) - zi;
+ x[ 3] = (vi >> 1) - zr;
+ x[11] = (vi >> 1) + zr;
+
+ x += 16;
+ }
+}
+
+/**************************************************************************************
+ * Function: R4Core
+ *
+ * Description: radix-4 pass for decimation-in-time FFT
+ * number of R4 butterflies per group
+ * number of R4 groups per pass
+ * pointer to twiddle factors tables
+ *
+ * Inputs: buffer of samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: gain 2 integer bits per pass (see notes on R4FFT for scaling info)
+ * for final multiply, can use SMLAL (if it pays off - needs extra
+ * mov rLO, #0 before SMLAL if using inline asm from C)
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ **************************************************************************************/
+static void R4Core(int *x, int bg, int gp, int *wtab)
+{
+ int ar, ai, br, bi, cr, ci, dr, di, tr, ti;
+ int wd, ws, wi;
+ int i, j, step;
+ int *xptr, *wptr;
+
+ for (; bg != 0; gp <<= 2, bg >>= 2) {
+
+ step = 2 * gp;
+ xptr = x;
+
+ for (i = bg; i != 0; i--) {
+
+ wptr = wtab;
+
+ for (j = gp; j != 0; j--) {
+
+ ar = xptr[0];
+ ai = xptr[1];
+ xptr += step;
+
+ ws = wptr[0];
+ wi = wptr[1];
+ br = xptr[0];
+ bi = xptr[1];
+ wd = ws + 2 * wi;
+ tr = MULSHIFT32(wi, br + bi);
+ br = MULSHIFT32(wd, br) - tr;
+ bi = MULSHIFT32(ws, bi) + tr;
+ xptr += step;
+
+ ws = wptr[2];
+ wi = wptr[3];
+ cr = xptr[0];
+ ci = xptr[1];
+ wd = ws + 2 * wi;
+ tr = MULSHIFT32(wi, cr + ci);
+ cr = MULSHIFT32(wd, cr) - tr;
+ ci = MULSHIFT32(ws, ci) + tr;
+ xptr += step;
+
+ ws = wptr[4];
+ wi = wptr[5];
+ dr = xptr[0];
+ di = xptr[1];
+ wd = ws + 2 * wi;
+ tr = MULSHIFT32(wi, dr + di);
+ dr = MULSHIFT32(wd, dr) - tr;
+ di = MULSHIFT32(ws, di) + tr;
+ wptr += 6;
+
+ /* have now gained 1 bit for br,bi,cr,ci,dr,di
+ * gain 1 more bit for by skipping 2*br,bi,cr,ci,dr,di in additions
+ * manually >> 2 on ar,ai to normalize (trivial case, no mul)
+ * net gain = 2 int bits per x[i], per R4 pass
+ */
+ tr = ar;
+ ti = ai;
+ ar = (tr >> 2) - br;
+ ai = (ti >> 2) - bi;
+ br = (tr >> 2) + br;
+ bi = (ti >> 2) + bi;
+
+ tr = cr;
+ ti = ci;
+ cr = tr + dr;
+ ci = di - ti;
+ dr = tr - dr;
+ di = di + ti;
+
+ xptr[0] = ar + ci;
+ xptr[1] = ai + dr;
+ xptr -= step;
+ xptr[0] = br - cr;
+ xptr[1] = bi - di;
+ xptr -= step;
+ xptr[0] = ar - ci;
+ xptr[1] = ai - dr;
+ xptr -= step;
+ xptr[0] = br + cr;
+ xptr[1] = bi + di;
+ xptr += 2;
+ }
+ xptr += 3 * step;
+ }
+ wtab += 3 * step;
+ }
+}
+
+
+/**************************************************************************************
+ * Function: R4FFT
+ *
+ * Description: Ken's very fast in-place radix-4 decimation-in-time FFT
+ *
+ * Inputs: table index (for transform size)
+ * buffer of samples (non bit-reversed)
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 4 guard bits in for nfft = [128, 256, 512]
+ * gains log2(nfft) - 2 int bits total
+ **************************************************************************************/
+void R4FFT(int tabidx, int *x)
+{
+ int order = nfftlog2Tab[tabidx];
+ int nfft = nfftTab[tabidx];
+
+ /* decimation in time */
+ BitReverse(x, tabidx);
+
+ if (order & 0x1) {
+ R8FirstPass(x, nfft >> 3);
+ R4Core(x, nfft >> 5, 8, (int *)twidTabOdd);
+ } else {
+ R4FirstPass(x, nfft >> 2);
+ R4Core(x, nfft >> 4, 4, (int *)twidTabEven);
+ }
+}
diff --git a/audio_codec/libcook/ra_format_info.h b/audio_codec/libcook/ra_format_info.h
new file mode 100644
index 0000000..98293ff
--- a/dev/null
+++ b/audio_codec/libcook/ra_format_info.h
@@ -0,0 +1,60 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: ra_format_info.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RA_FORMAT_INFO_H
+#define RA_FORMAT_INFO_H
+
+#include "helix_types.h"
+
+/*
+ * ra_format_info struct
+ *
+ */
+typedef struct ra_format_info_struct {
+ UINT32 ulSampleRate;
+ UINT32 ulActualRate;
+ UINT16 usBitsPerSample;
+ UINT16 usNumChannels;
+ UINT16 usAudioQuality;
+ UINT16 usFlavorIndex;
+ UINT32 ulBitsPerFrame;
+ UINT32 ulGranularity;
+ UINT32 ulOpaqueDataSize;
+ BYTE* pOpaqueData;
+} ra_format_info;
+
+#endif /* #ifndef RA_FORMAT_INFO_H */
diff --git a/audio_codec/libcook/ra_gainctrl.c b/audio_codec/libcook/ra_gainctrl.c
new file mode 100644
index 0000000..9e4d741
--- a/dev/null
+++ b/audio_codec/libcook/ra_gainctrl.c
@@ -0,0 +1,584 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: gainctrl.c,v 1.6 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * gainctrl.c - time-domain gain control processing
+ *
+ * Discussion of interpolating gain control window:
+ * gain ranges from -7 to 4 so window ranges from 2^-7 to 2^4
+ * If gain0 != gain1, we start at 2^gain0 and increase logarithmically
+ * to a final value of gain1
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+#define MAX_NPSAMPS (1024 / NPARTS)
+#define MAX_LOGNPSAMPS 7 /* log2(MAX_NPSAMPS) */
+#define FRAC_MASK (MAX_NPSAMPS - 1)
+
+static const int npsampsTab[NUM_MLT_SIZES] = {256 / NPARTS, 512 / NPARTS, 1024 / NPARTS};
+static const int nplog2Tab[NUM_MLT_SIZES] = {5, 6, 7};
+
+/* 2^(x/128) - format = Q30 */
+static const int POW2NTAB[128] = {
+ 0x40000000, 0x4058f6a8, 0x40b268fa, 0x410c57a2, 0x4166c34c, 0x41c1aca7, 0x421d1462, 0x4278fb2b,
+ 0x42d561b4, 0x433248ae, 0x438fb0cb, 0x43ed9ac0, 0x444c0740, 0x44aaf702, 0x450a6abb, 0x456a6323,
+ 0x45cae0f2, 0x462be4e2, 0x468d6fae, 0x46ef8210, 0x47521cc6, 0x47b5408c, 0x4818ee22, 0x487d2646,
+ 0x48e1e9ba, 0x4947393f, 0x49ad1598, 0x4a137f88, 0x4a7a77d4, 0x4ae1ff43, 0x4b4a169c, 0x4bb2bea5,
+ 0x4c1bf829, 0x4c85c3f1, 0x4cf022ca, 0x4d5b157e, 0x4dc69cdd, 0x4e32b9b4, 0x4e9f6cd4, 0x4f0cb70c,
+ 0x4f7a9930, 0x4fe91413, 0x50582888, 0x50c7d765, 0x51382182, 0x51a907b4, 0x521a8ad7, 0x528cabc3,
+ 0x52ff6b55, 0x5372ca68, 0x53e6c9da, 0x545b6a8b, 0x54d0ad5a, 0x55469329, 0x55bd1cdb, 0x56344b52,
+ 0x56ac1f75, 0x57249a29, 0x579dbc57, 0x581786e6, 0x5891fac1, 0x590d18d3, 0x5988e209, 0x5a055751,
+ 0x5a82799a, 0x5b0049d4, 0x5b7ec8f2, 0x5bfdf7e5, 0x5c7dd7a4, 0x5cfe6923, 0x5d7fad59, 0x5e01a53f,
+ 0x5e8451d0, 0x5f07b405, 0x5f8bccdb, 0x60109d51, 0x60962665, 0x611c6919, 0x61a3666d, 0x622b1f66,
+ 0x62b39509, 0x633cc85b, 0x63c6ba64, 0x64516c2e, 0x64dcdec3, 0x6569132f, 0x65f60a7f, 0x6683c5c3,
+ 0x6712460b, 0x67a18c68, 0x683199ed, 0x68c26fb1, 0x69540ec9, 0x69e6784d, 0x6a79ad56, 0x6b0daeff,
+ 0x6ba27e65, 0x6c381ca6, 0x6cce8ae1, 0x6d65ca38, 0x6dfddbcc, 0x6e96c0c3, 0x6f307a41, 0x6fcb096f,
+ 0x70666f76, 0x7102ad80, 0x719fc4b9, 0x723db650, 0x72dc8374, 0x737c2d55, 0x741cb528, 0x74be1c20,
+ 0x75606374, 0x76038c5b, 0x76a7980f, 0x774c87cc, 0x77f25cce, 0x78991854, 0x7940bb9e, 0x79e947ef,
+ 0x7a92be8b, 0x7b3d20b6, 0x7be86fba, 0x7c94acde, 0x7d41d96e, 0x7deff6b6, 0x7e9f0606, 0x7f4f08ae,
+};
+
+/**************************************************************************************
+ * Function: DecodeGainInfo
+ *
+ * Description: decode the gain window parameters for each frame
+ *
+ * Inputs: pointer to initialized Gecko2Info struct
+ * pointer to uninitialized GAINC struct
+ * number of bits remaining in bitstream for this frame
+ *
+ * Outputs: GAINC struct filled in with number and location of attacks, and gains
+ *
+ * Return: number of bits remaining in bitstream, -1 if out-of-bits
+ **************************************************************************************/
+int DecodeGainInfo(Gecko2Info *gi, GAINC *gainc, int availbits)
+{
+ int i, nbits, code;
+ BitStreamInfo *bsi = &(gi->bsi);
+
+ /* unpack nattacks */
+ nbits = 0;
+ do {
+ code = GetBits(bsi, 1, 1); /* count bits until zero reached */
+ nbits++;
+ } while (code);
+ gainc->nats = nbits - 1; /* nats = number of ones */
+ availbits -= nbits;
+
+ if (availbits < 0) {
+ return -1;
+ }
+
+ ASSERT(gainc->nats <= MAXNATS);
+
+ /* unpack any location/gain pairs */
+ if (gainc->nats > 0) {
+ for (i = 0; i < gainc->nats; i++) {
+ /* location */
+ gainc->loc[i] = GetBits(bsi, LOCBITS, 1);
+ availbits -= LOCBITS;
+
+ /* gain code */
+ code = GetBits(bsi, 1, 1);
+ availbits--;
+
+ if (!code) {
+ gainc->gain[i] = -1;
+ } else {
+ code = GetBits(bsi, GAINBITS, 1);
+ availbits -= GAINBITS;
+ gainc->gain[i] = CODE2GAIN(code);
+ }
+ }
+ }
+ gainc->maxExGain = 0;
+
+ if (availbits < 0) {
+ return -1;
+ }
+
+ return availbits;
+}
+
+/**************************************************************************************
+ * Function: CopyGainInfo
+ *
+ * Description: copy contents of one GAINC struct into another one
+ *
+ * Inputs: pointer to initialized GAINC struct (source)
+ * pointer to uninitialized GAINC struct (destination)
+ *
+ * Outputs: gaincDest which is identical to gaincSource
+ *
+ * Return: none
+ *
+ * Notes: this prevents compiler from generating a memcpy for gainc0 = gainc1
+ * (we want to avoid a CRT lib call, for portability of asm)
+ **************************************************************************************/
+void CopyGainInfo(GAINC *gaincDest, GAINC *gaincSource)
+{
+ int nBytes = sizeof(GAINC);
+ unsigned char *d = (unsigned char *)gaincDest;
+ unsigned char *s = (unsigned char *)gaincSource;
+
+ for (; nBytes != 0; nBytes--) {
+ *d++ = *s++;
+ }
+
+}
+
+/**************************************************************************************
+ * Function: CalcGainChanges
+ *
+ * Description: reconstruct segmented gain window
+ *
+ * Inputs: pointer to uninitialized exgain array
+ * pointer to old (overlap) and current gain info structs
+ *
+ * Outputs: exgain[0, ... 2*NPARTS] with expanded gains at each switch point
+ *
+ * Return: none
+ *
+ * Notes: each frame is divided into NPARTS segments, with
+ * npsamps = nSamples / NPARTS samples in each one
+ * the gain window can only change at these boundaries
+ * if exgain[i] != exgain[i-1] the gain is interpolated logarithmically
+ * between the two points (buf[(i-1)*npsamps to buf[i*npsamps])
+ **************************************************************************************/
+static void CalcGainChanges(short *exgain, GAINC *gainc0, GAINC *gainc1)
+{
+ short i, nats, maxGain, offset;
+
+ /* second half - expand gains, working backwards */
+ exgain[NPARTS + NPARTS] = 0; /* always finish at 1.0 */
+ nats = gainc1->nats; /* gain changes left */
+ for (i = NPARTS - 1; i >= 0; i--) {
+ if (nats && (i == gainc1->loc[nats - 1])) { /* at gain change */
+ exgain[i + NPARTS] = gainc1->gain[--nats]; /* use it */
+ } else {
+ exgain[i + NPARTS] = exgain[i + NPARTS + 1]; /* repeat last gain */
+ }
+ }
+
+ /* pull any discontinuity through first half by offsetting all
+ * gains with starting gain of second half
+ */
+ offset = exgain[NPARTS];
+
+ /* first half - expand gains, working backwards */
+ nats = gainc0->nats; /* gain changes left */
+ for (i = NPARTS - 1; i >= 0; i--) {
+ if (nats && (i == gainc0->loc[nats - 1])) { /* at gain change */
+ exgain[i] = gainc0->gain[--nats] + offset; /* use it */
+ } else {
+ exgain[i] = exgain[i + 1]; /* repeat last gain */
+ }
+ }
+
+ /* find max gain for each half (input and overlap) */
+ maxGain = 0;
+ for (i = 0; i <= NPARTS; i++) {
+ if (exgain[i] > maxGain) {
+ maxGain = exgain[i];
+ }
+ }
+ gainc0->maxExGain = maxGain;
+
+ maxGain = 0;
+ for (i = NPARTS; i <= 2 * NPARTS; i++) {
+ if (exgain[i] > maxGain) {
+ maxGain = exgain[i];
+ }
+ }
+ gainc1->maxExGain = maxGain;
+
+ return;
+}
+
+/**************************************************************************************
+ * Function: InterpolatePCM
+ *
+ * Description: apply gain window to first half of current frame, and overlap-add
+ * with second half of previous frame, to produce PCM output
+ *
+ * Inputs: table index (for transform size)
+ * pointer to initialized exgain array (NPARTS+1 gain values)
+ * first half of IMLT output for current frame (buf),
+ * synthesis window has not yet been applied
+ * overlap from previous frame (buf + MAXNMLT), synthesis and gain
+ * windows were already applied
+ * max exgain for first half of current frame
+ * buffer for output PCM
+ * number of channels
+ * number of fraction bits present in current and overlap data
+ *
+ * Outputs: nSamples samples of 16-bit PCM output
+ *
+ * Return: none
+ *
+ * Notes: this processes one channel at a time, but skips every other sample in
+ * the output buffer (pcm) for stereo interleaving
+ **************************************************************************************/
+static void InterpolatePCM(int tabidx, short *exgain, int *buf, int *overlap, short maxGain, short *pcm, int nChans, int fbitsPCM, int fbitsOver)
+{
+ int in, npsamps, part;
+ int shiftLo, shiftHi, currGainLo, currGainHi, gainDiffLo, gainDiffHi;
+ int gainLo0, gainLo1, gainHi0, gainHi1, w0, w1, f0, f1, oc;
+ int *over0, *over1, shift[2], rndMask;
+ short *pcm0, *pcm1;
+ const int *wnd;
+
+ shift[0] = 0;
+ shift[1] = 0;
+ rndMask = 0;
+ if (fbitsPCM > fbitsOver) {
+ shift[0] = MIN(fbitsPCM - fbitsOver, 31);
+ fbitsPCM = fbitsOver;
+ } else if (fbitsPCM < fbitsOver) {
+ shift[1] = MIN(fbitsOver - fbitsPCM, 31);
+ }
+
+ if (fbitsPCM > 0) {
+ rndMask = (1 << (fbitsPCM - 1));
+ }
+ ASSERT(fbitsPCM >= 0);
+
+ npsamps = npsampsTab[tabidx];
+ over0 = overlap;//buf + MAXNMLT;
+ over1 = over0 + NPARTS * npsamps - 1;
+ buf += (nmltTab[tabidx] >> 1) - 1;
+
+ wnd = window + windowOffset[tabidx];
+ pcm0 = pcm;
+ pcm1 = pcm + (NPARTS * npsamps - 1) * nChans;
+
+ gainLo1 = exgain[0];
+ gainHi0 = exgain[NPARTS];
+
+ for (part = 0; part < NPARTS / 2; part++) {
+ npsamps = npsampsTab[tabidx];
+
+ gainLo0 = gainLo1;
+ gainLo1 = exgain[part + 1];
+ gainHi1 = gainHi0;
+ gainHi0 = exgain[NPARTS - part - 1];
+
+ currGainHi = gainHi1 << MAX_LOGNPSAMPS;
+ gainDiffHi = (gainHi0 - gainHi1) << (MAX_LOGNPSAMPS - nplog2Tab[tabidx]);
+ currGainHi += gainDiffHi;
+
+ currGainLo = gainLo0 << MAX_LOGNPSAMPS;
+ gainDiffLo = (gainLo1 - gainLo0) << (MAX_LOGNPSAMPS - nplog2Tab[tabidx]);
+
+ /* interpolate the gain window: in = in * 2^(gain0) * 2^((gain1 - gain0)*i/npsamps) */
+ if (gainDiffLo || gainDiffHi) {
+ /* slow path - interpolated section of gain window */
+ for (; npsamps != 0; npsamps--) {
+ in = *buf--;
+ w0 = *wnd++;
+ w1 = *wnd++;
+
+ shiftLo = maxGain - (currGainLo >> MAX_LOGNPSAMPS) + shift[0];
+ oc = *over0++;
+ f0 = MULSHIFT32(w0, in);
+ f0 = MULSHIFT32(POW2NTAB[currGainLo & FRAC_MASK], f0) << 2;
+ *pcm0 = CLIPTOSHORT(((f0 >> shiftLo) + (oc >> shift[1]) + rndMask) >> fbitsPCM);
+ pcm0 += nChans;
+ currGainLo += gainDiffLo;
+
+ shiftHi = maxGain - (currGainHi >> MAX_LOGNPSAMPS) + shift[0];
+ oc = *over1--;
+ f1 = MULSHIFT32(w1, in);
+ f1 = MULSHIFT32(POW2NTAB[currGainHi & FRAC_MASK], f1) << 2;
+ *pcm1 = CLIPTOSHORT(((f1 >> shiftHi) + (oc >> shift[1]) + rndMask) >> fbitsPCM);
+ pcm1 -= nChans;
+ currGainHi += gainDiffHi;
+ }
+ } else {
+ /* fast path - constant section of gain window */
+ shiftLo = maxGain - gainLo0 + shift[0];
+ shiftHi = maxGain - gainHi1 + shift[0];
+ for (; npsamps != 0; npsamps--) {
+ in = *buf--;
+ w0 = *wnd++;
+ w1 = *wnd++;
+
+ oc = *over0++;
+ f0 = MULSHIFT32(w0, in);
+ *pcm0 = CLIPTOSHORT(((f0 >> shiftLo) + (oc >> shift[1]) + rndMask) >> fbitsPCM);
+ pcm0 += nChans;
+
+ oc = *over1--;
+ f1 = MULSHIFT32(w1, in);
+ *pcm1 = CLIPTOSHORT(((f1 >> shiftHi) + (oc >> shift[1]) + rndMask) >> fbitsPCM);
+ pcm1 -= nChans;
+ }
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: InterpolateOverlap
+ *
+ * Description: apply gain window to second half of current frame, and save for
+ * overlap-add next frame
+ *
+ * Inputs: table index (for transform size)
+ * pointer to initialized exgain array (NPARTS+1 gain values)
+ * second half of IMLT output for current frame (buf + nmlt/2),
+ * synthesis window has not yet been applied
+ * max exgain for second half of current frame
+ *
+ * Outputs: nSamples samples of gain windowed data for overlap
+ * (stored at buf + MAXNMLT)
+ *
+ * Return: none
+ **************************************************************************************/
+static void InterpolateOverlap(int tabidx, short *exgain, int *buf, int *overlap, short maxGain)
+{
+ int in, npsamps, part;
+ int shiftLo, shiftHi, currGainLo, currGainHi, gainDiffLo, gainDiffHi;
+ int gainLo0, gainLo1, gainHi0, gainHi1, w0, w1;
+ int *over0, *over1;
+ const int *wnd;
+
+ npsamps = npsampsTab[tabidx];
+ over0 = overlap;//buf + MAXNMLT;
+ over1 = over0 + NPARTS * npsamps - 1;
+ buf += (nmltTab[tabidx] >> 1);
+ wnd = window + windowOffset[tabidx];
+
+ gainLo1 = exgain[0];
+ gainHi0 = exgain[NPARTS];
+
+ for (part = 0; part < NPARTS / 2; part++) {
+ npsamps = npsampsTab[tabidx];
+
+ gainLo0 = gainLo1;
+ gainLo1 = exgain[part + 1];
+ gainHi1 = gainHi0;
+ gainHi0 = exgain[NPARTS - part - 1];
+
+ currGainHi = gainHi1 << MAX_LOGNPSAMPS;
+ gainDiffHi = (gainHi0 - gainHi1) << (MAX_LOGNPSAMPS - nplog2Tab[tabidx]);
+ currGainHi += gainDiffHi;
+
+ currGainLo = gainLo0 << MAX_LOGNPSAMPS;
+ gainDiffLo = (gainLo1 - gainLo0) << (MAX_LOGNPSAMPS - nplog2Tab[tabidx]);
+
+ /* interpolate the gain window: in = in * 2^(gain0) * 2^((gain1 - gain0)*i/npsamps) */
+ if (gainDiffLo || gainDiffHi) {
+ /* slow path - interpolated section of gain window */
+ for (; npsamps != 0; npsamps--) {
+ in = *buf++;
+ w0 = *wnd++;
+ w1 = *wnd++;
+
+ shiftLo = maxGain - (currGainLo >> MAX_LOGNPSAMPS);
+ w1 = MULSHIFT32(w1, in) >> shiftLo;
+ *over0++ = MULSHIFT32(POW2NTAB[currGainLo & FRAC_MASK], w1) << 2;
+ currGainLo += gainDiffLo;
+
+ shiftHi = maxGain - (currGainHi >> MAX_LOGNPSAMPS);
+ w0 = -MULSHIFT32(w0, in) >> shiftHi;
+ *over1-- = MULSHIFT32(POW2NTAB[currGainHi & FRAC_MASK], w0) << 2;
+ currGainHi += gainDiffHi;
+ }
+ } else {
+ /* fast path - constant section of gain window */
+ shiftLo = maxGain - gainLo0;
+ shiftHi = maxGain - gainHi1;
+ for (; npsamps != 0; npsamps--) {
+ in = *buf++;
+ w0 = *wnd++;
+ w1 = *wnd++;
+
+ *over0++ = MULSHIFT32(w1, in) >> shiftLo;
+ *over1-- = -MULSHIFT32(w0, in) >> shiftHi;
+ }
+ }
+ }
+}
+
+/* default fraction bits, not counting any extras from dequantizer */
+#define FBITS_OUT_IMLT (FBITS_OUT_DQ - FBITS_LOST_IMLT)
+
+/**************************************************************************************
+ * Function: DecWindowWithAttacks
+ *
+ * Description: apply synthesis window, perform gain windowing of current frame,
+ * do overlap-add, and produce one frame of decoded PCM
+ * (general case - either gain window has attacks or the default Q format
+ * is not being used)
+ *
+ * Inputs: table index (for transform size)
+ * input buffer (output of IMLT, before synthesis window)
+ * buffer for output PCM
+ * number of channels
+ * gain control structs for overlap and current frames
+ * number of extra integer bits present in current and overlap data
+ * (relative to the default format of FBITS_OUT_IMLT)
+ *
+ * Outputs: nSamples samples of 16-bit PCM output
+ *
+ * Return: none
+ *
+ * Notes: this processes one channel at a time, but skips every other sample in
+ * the output buffer (pcm) for stereo interleaving
+ **************************************************************************************/
+void DecWindowWithAttacks(int tabidx, int *buf, int *overlap, short *pcm, int nChans, GAINC *gainc0, GAINC *gainc1, short xbits[2])
+{
+ int i, s, fbitsPCM, fbitsOver;
+ short exgain[2 * NPARTS + 1];
+
+ fbitsOver = FBITS_OUT_IMLT - xbits[0] - gainc0->maxExGain;
+ CalcGainChanges(exgain, gainc0, gainc1);
+ fbitsPCM = FBITS_OUT_IMLT - xbits[1] - gainc0->maxExGain;
+
+ /* this is EXTREMELY unlikely (gain window so high that we would have negative fraction bits)
+ * so just do << and clip whole frame to 0 fraction bits
+ * can think of this as artifically adding fraction bits, or just doing gain window
+ * in 2 stages (first pass = window by constant power of 2, second pass = window
+ * by original gain window / constant power of 2)
+ * whole purpose is so Interpolate functions can be hard-coded to >> only (fast)
+ */
+ s = 0;
+ if (fbitsOver < 0 || fbitsPCM < 0) {
+ s = MAX(-fbitsOver, -fbitsPCM);
+ for (i = 0; i < npsampsTab[tabidx]*NPARTS; i++) {
+ CLIP_2N_SHIFT(buf[i], s);
+ }
+ for (i = 0; i < npsampsTab[tabidx]*NPARTS; i++) {
+ CLIP_2N_SHIFT(overlap[i], s);
+ }
+ //for (i = MAXNSAMP; i < MAXNSAMP + npsampsTab[tabidx]*NPARTS; i++)
+ // CLIP_2N_SHIFT(buf[i], s);
+ fbitsOver += s;
+ fbitsPCM += s;
+ }
+
+ InterpolatePCM(tabidx, exgain, buf, overlap, gainc0->maxExGain, pcm, nChans, fbitsPCM, fbitsOver);
+ InterpolateOverlap(tabidx, exgain + NPARTS, buf, overlap, gainc1->maxExGain);
+
+ /* undo extreme gain window scaling */
+ if (s) {
+ for (i = 0; i < npsampsTab[tabidx]*NPARTS; i++) {
+ buf[i] >>= s;
+ }
+ for (i = 0; i < npsampsTab[tabidx]*NPARTS; i++) {
+ overlap[i] >>= s;
+ }
+ //for (i = MAXNSAMP; i < MAXNSAMP + npsampsTab[tabidx]*NPARTS; i++)
+ // buf[i] >>= s;
+ }
+
+ return;
+}
+
+/**************************************************************************************
+ * Function: DecWindowNoAttacks
+ *
+ * Description: apply synthesis window, perform gain windowing of current frame,
+ * do overlap-add, and produce one frame of decoded PCM
+ * (fast case - no gain window attacks and the data is in the default
+ * Q format with FBITS_OUT_IMLT fraction bits in input)
+ *
+ * Inputs: table index (for transform size)
+ * input buffer (output of IMLT, before synthesis window)
+ * pcm buffer
+ * number of channels
+ *
+ * Outputs: nSamples samples of 16-bit PCM output
+ *
+ * Return: none
+ *
+ * Notes: this processes one channel at a time, but skips every other sample in
+ * the output buffer (pcm) for stereo interleaving
+ * this should fit in registers on ARM - make sure compiler does this
+ * correctly!
+ **************************************************************************************/
+void DecWindowNoAttacks(int tabidx, int *buf0, int *overlap, short *pcm0, int nChans)
+{
+ int nmlt, nmltHalf;
+ int in, oc, w0, w1, f0, f1;
+ int *buf1, *over0, *over1;
+ short *pcm1;
+ const int *wnd;
+
+ nmlt = nmltTab[tabidx];
+ nmltHalf = nmlt >> 1;
+
+ over0 = overlap;//buf0 + MAXNMLT;
+ over1 = over0 + nmlt - 1;
+
+ buf0 += nmltHalf;
+ buf1 = buf0 - 1;
+ wnd = window + windowOffset[tabidx];
+ pcm1 = pcm0 + (nmlt - 1) * nChans;
+
+ for (; nmltHalf != 0; nmltHalf--) {
+ /* load window coefficients */
+ w0 = *wnd++;
+ w1 = *wnd++;
+
+ /* apply window to generate first N samples */
+ in = *buf1--;
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ /* overlap-add with second N samples from last frame */
+ oc = *over0;
+ *pcm0 = CLIPTOSHORT((f0 + oc + (1 << (FBITS_OUT_IMLT - 1))) >> FBITS_OUT_IMLT);
+ pcm0 += nChans;
+ oc = *over1;
+ *pcm1 = CLIPTOSHORT((f1 + oc + (1 << (FBITS_OUT_IMLT - 1))) >> FBITS_OUT_IMLT);
+ pcm1 -= nChans;
+
+ /* apply window to generate second nmlt samples, save for overlap with next frame */
+ in = *buf0++;
+ *over0++ = MULSHIFT32(w1, in);
+ *over1-- = -MULSHIFT32(w0, in);
+ }
+
+ return;
+}
diff --git a/audio_codec/libcook/ra_huffman.c b/audio_codec/libcook/ra_huffman.c
new file mode 100644
index 0000000..ca54770
--- a/dev/null
+++ b/audio_codec/libcook/ra_huffman.c
@@ -0,0 +1,86 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: huffman.c,v 1.6 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * huffman.c - Wolfgang's implementation of Moffat-Turpin style Huffman decoder
+ **************************************************************************************/
+
+#include "coder.h"
+
+/**************************************************************************************
+ * Function: DecodeHuffmanScalar
+ *
+ * Description: decode one Huffman symbol from bitstream
+ *
+ * Inputs: pointers to table and info
+ * right-aligned bit buffer with MAX_HUFF_BITS bits
+ * pointer to receive decoded symbol
+ *
+ * Outputs: decoded symbol
+ *
+ * Return: number of bits in symbol
+ **************************************************************************************/
+int DecodeHuffmanScalar(const unsigned short *huffTab, const HuffInfo *huffTabInfo, int bitBuf, int *val)
+{
+ const unsigned char *countPtr;
+ unsigned int cache, total, count, t;
+ const unsigned short *map;
+
+ map = huffTab + huffTabInfo->offset;
+ countPtr = huffTabInfo->count;
+ cache = (unsigned int)(bitBuf << (17 - MAX_HUFF_BITS));
+
+ total = 0;
+ count = *countPtr++;
+ t = count << 16;
+
+ while (cache >= t) {
+ cache -= t;
+ cache <<= 1;
+ total += count;
+ count = *countPtr++;
+ t = count << 16;
+ }
+ *val = map[total + (cache >> 16)];
+
+ /* return number of bits in symbol */
+ return (countPtr - huffTabInfo->count);
+}
diff --git a/audio_codec/libcook/ra_hufftabs.c b/audio_codec/libcook/ra_hufftabs.c
new file mode 100644
index 0000000..f20eb26
--- a/dev/null
+++ b/audio_codec/libcook/ra_hufftabs.c
@@ -0,0 +1,244 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: hufftabs.c,v 1.2 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * hufftabs.c - Huffman symbol tables
+ **************************************************************************************/
+
+#include "coder.h"
+
+const HuffInfo huffTabCoupleInfo[5] = {
+ /* table 0 = unused */
+ /* table 1 = unused */
+ { 2, {1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0},
+ { 6, {1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 3},
+ { 8, {1, 0, 2, 2, 2, 2, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0}, 10},
+ {10, {1, 0, 2, 0, 4, 4, 4, 4, 4, 8, 0, 0, 0, 0, 0, 0}, 25},
+ {16, {1, 0, 1, 1, 4, 4, 8, 8, 9, 9, 8, 2, 2, 3, 1, 2}, 56},
+};
+
+const unsigned short huffTabCouple[119] = {
+ /* couple table 2 [3] */
+ 1, 0, 2,
+
+ /* couple table 3 [7] */
+ 3, 2, 4, 5, 1, 0, 6,
+
+ /* couple table 4 [15] */
+ 7, 6, 8, 5, 9, 4, 10, 3, 11, 2, 12, 0, 1, 13, 14,
+
+ /* couple table 5 [31] */
+ 15, 14, 16, 12, 13, 17, 18, 10, 11, 19, 20, 8, 9, 21, 22, 6,
+ 7, 23, 24, 4, 5, 25, 26, 0, 1, 2, 3, 27, 28, 29, 30,
+
+ /* couple table 6 [63] */
+ 31, 30, 32, 28, 29, 33, 34, 26, 27, 35, 36, 22, 23, 24, 25, 37,
+ 38, 39, 40, 18, 19, 20, 21, 41, 42, 43, 44, 13, 14, 15, 16, 17,
+ 45, 46, 47, 48, 9, 10, 11, 12, 49, 50, 51, 52, 53, 5, 6, 7,
+ 8, 54, 55, 56, 57, 4, 58, 3, 59, 2, 60, 61, 1, 0, 62
+};
+
+const HuffInfo huffTabPowerInfo[13] = {
+ {12, {0, 0, 3, 8, 3, 1, 1, 1, 1, 0, 2, 4, 0, 0, 0, 0}, 0},
+ {16, {0, 0, 6, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 0, 3, 2}, 24},
+ {14, {0, 0, 3, 8, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0}, 48},
+ {13, {0, 0, 5, 4, 3, 0, 3, 0, 3, 1, 1, 0, 4, 0, 0, 0}, 72},
+ {14, {0, 0, 5, 3, 4, 3, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0}, 96},
+ {14, {0, 0, 5, 4, 3, 0, 2, 3, 1, 1, 1, 1, 1, 2, 0, 0}, 120},
+ {16, {0, 1, 4, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 4}, 144},
+ {15, {0, 1, 4, 2, 3, 0, 3, 0, 3, 1, 1, 1, 0, 3, 2, 0}, 168},
+ {13, {0, 0, 6, 2, 2, 2, 2, 2, 3, 1, 1, 1, 2, 0, 0, 0}, 192},
+ {14, {0, 0, 6, 2, 2, 3, 0, 3, 1, 1, 1, 1, 0, 4, 0, 0}, 216},
+ {14, {0, 1, 3, 4, 2, 3, 0, 2, 3, 1, 1, 1, 1, 2, 0, 0}, 240},
+ {16, {0, 1, 3, 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 4}, 264},
+ {14, {0, 1, 4, 2, 3, 0, 3, 1, 1, 1, 1, 0, 1, 6, 0, 0}, 288},
+};
+
+const unsigned short huffTabPower[312] = {
+ /* power table 0 [24] */
+ 10, 11, 12, 0, 4, 5, 6, 7, 8, 9, 13, 2, 3, 14, 1, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23,
+ /* power table 1 [24] */
+ 6, 7, 8, 9, 10, 11, 5, 12, 3, 4, 13, 2, 14, 1, 15, 0,
+ 16, 17, 18, 19, 20, 21, 22, 23,
+ /* power table 2 [24] */
+ 11, 12, 13, 5, 6, 7, 8, 9, 10, 14, 15, 4, 16, 17, 3, 18,
+ 2, 19, 1, 20, 0, 21, 22, 23,
+ /* power table 3 [24] */
+ 9, 10, 11, 12, 13, 8, 14, 15, 16, 6, 7, 17, 4, 5, 18, 2,
+ 3, 19, 1, 20, 0, 21, 22, 23,
+ /* power table 4 [24] */
+ 10, 11, 12, 13, 14, 8, 9, 15, 6, 7, 16, 17, 4, 5, 18, 19,
+ 3, 20, 2, 21, 0, 1, 22, 23,
+ /* power table 5 [24] */
+ 9, 10, 11, 12, 13, 7, 8, 14, 15, 6, 16, 17, 5, 18, 3, 4,
+ 19, 2, 20, 1, 0, 21, 22, 23,
+ /* power table 6 [24] */
+ 12, 9, 10, 11, 13, 8, 14, 7, 15, 16, 6, 17, 5, 18, 4, 19,
+ 3, 20, 0, 2, 1, 21, 22, 23,
+ /* power table 7 [24] */
+ 12, 10, 11, 13, 14, 9, 15, 7, 8, 16, 5, 6, 17, 4, 18, 19,
+ 3, 2, 20, 0, 1, 21, 22, 23,
+ /* power table 8 [24] */
+ 8, 9, 10, 11, 12, 13, 7, 14, 6, 15, 5, 16, 4, 17, 3, 18,
+ 0, 1, 2, 19, 20, 21, 22, 23,
+ /* power table 9 [24] */
+ 8, 9, 10, 11, 12, 13, 7, 14, 6, 15, 4, 5, 16, 3, 17, 18,
+ 19, 2, 20, 1, 0, 21, 22, 23,
+ /* power table 10 [24] */
+ 12, 10, 11, 13, 7, 8, 9, 14, 6, 15, 4, 5, 16, 3, 17, 2,
+ 18, 19, 1, 20, 21, 0, 22, 23,
+ /* power table 11 [24] */
+ 12, 11, 13, 14, 8, 9, 10, 15, 6, 7, 16, 5, 17, 18, 4, 19,
+ 3, 2, 1, 20, 0, 21, 22, 23,
+ /* power table 12 [24] */
+ 12, 10, 11, 13, 14, 9, 15, 8, 16, 17, 6, 7, 18, 5, 19, 4,
+ 20, 0, 1, 2, 3, 21, 22, 23,
+};
+
+const HuffInfo huffTabVectorInfo[7] = {
+ {16, { 1, 0, 0, 2, 2, 5, 8, 15, 31, 33, 28, 17, 15, 8, 8, 8}, 0},
+ {16, { 1, 0, 0, 2, 4, 5, 7, 16, 18, 12, 11, 7, 3, 5, 1, 2}, 181},
+ {16, { 1, 0, 1, 2, 4, 2, 5, 8, 7, 8, 2, 3, 1, 1, 1, 2}, 275},
+ {16, { 0, 1, 0, 2, 5, 12, 7, 27, 22, 41, 32, 41, 55, 23, 32, 220}, 323},
+ {15, { 0, 1, 0, 5, 7, 4, 8, 9, 17, 10, 13, 17, 12, 14, 92, 0}, 843},
+ {15, { 0, 1, 0, 5, 6, 8, 8, 8, 4, 7, 11, 23, 21, 10, 80, 0}, 1052},
+ {11, { 1, 0, 0, 5, 0, 9, 1, 7, 4, 3, 2, 0, 0, 0, 0, 0}, 1244},
+
+};
+
+const unsigned short huffTabVector[1276] = {
+ /* vector table 0 [181] */
+ 0x0000, 0x1010, 0x1001, 0x2011, 0x1002, 0x1020, 0x1030, 0x2021, 0x2012, 0x1003, 0x1040, 0x1050, 0x2031, 0x2041, 0x2022, 0x2013,
+ 0x1004, 0x2014, 0x1060, 0x1070, 0x1080, 0x2051, 0x2061, 0x2032, 0x2042, 0x2023, 0x2024, 0x1005, 0x2015, 0x1006, 0x2016, 0x1007,
+ 0x2017, 0x1090, 0x10a0, 0x2071, 0x2081, 0x2091, 0x20a1, 0x2052, 0x2062, 0x2072, 0x2082, 0x2033, 0x2043, 0x2053, 0x2063, 0x2034,
+ 0x2044, 0x2054, 0x2025, 0x2035, 0x2045, 0x2026, 0x2036, 0x2027, 0x2037, 0x1008, 0x2018, 0x2028, 0x1009, 0x2019, 0x100a, 0x201a,
+ 0x10b0, 0x20b1, 0x2092, 0x20a2, 0x20b2, 0x2073, 0x2083, 0x2093, 0x20a3, 0x2064, 0x2074, 0x2084, 0x2094, 0x2055, 0x2065, 0x2075,
+ 0x2085, 0x2046, 0x2056, 0x2047, 0x2057, 0x2038, 0x2048, 0x2058, 0x2029, 0x2039, 0x2049, 0x2059, 0x202a, 0x203a, 0x100b, 0x201b,
+ 0x202b, 0x10c0, 0x10d0, 0x20c1, 0x20d1, 0x20c2, 0x20b3, 0x20a4, 0x20b4, 0x2095, 0x20a5, 0x2066, 0x2076, 0x2086, 0x2067, 0x2077,
+ 0x2087, 0x2068, 0x2078, 0x2069, 0x204a, 0x205a, 0x203b, 0x204b, 0x100c, 0x201c, 0x202c, 0x100d, 0x201d, 0x20d2, 0x20c3, 0x20c4,
+ 0x20b5, 0x2096, 0x20a6, 0x2097, 0x20a7, 0x2088, 0x20a8, 0x2079, 0x2089, 0x206a, 0x205b, 0x206b, 0x203c, 0x202d, 0x20d3, 0x20d4,
+ 0x20c5, 0x20b6, 0x20c6, 0x20b7, 0x2098, 0x207a, 0x208a, 0x207b, 0x204c, 0x205c, 0x206c, 0x203d, 0x204d, 0x20d5, 0x20c7, 0x20b8,
+ 0x2099, 0x20a9, 0x209a, 0x20aa, 0x205d, 0x20d6, 0x20d7, 0x20c8, 0x20ba, 0x208b, 0x209b, 0x207c, 0x206d, 0x20d8, 0x20b9, 0x20c9,
+ 0x20ab, 0x208c, 0x209c, 0x207d, 0x208d,
+
+ /* vector table 1 [94] */
+ 0x0000, 0x1010, 0x1001, 0x1020, 0x2011, 0x1002, 0x2012, 0x1030, 0x2021, 0x2022, 0x1003, 0x2013, 0x1040, 0x2031, 0x2041, 0x2032,
+ 0x2023, 0x1004, 0x2014, 0x1050, 0x1060, 0x2051, 0x2061, 0x2042, 0x2052, 0x2033, 0x2043, 0x2024, 0x2034, 0x1005, 0x2015, 0x2025,
+ 0x1006, 0x2016, 0x2026, 0x1070, 0x2071, 0x2081, 0x2062, 0x2072, 0x2053, 0x2063, 0x2044, 0x2054, 0x2035, 0x2045, 0x2036, 0x1007,
+ 0x2017, 0x2027, 0x1008, 0x2018, 0x2028, 0x1080, 0x1090, 0x2082, 0x2073, 0x2064, 0x2055, 0x2065, 0x2046, 0x2037, 0x2038, 0x1009,
+ 0x2019, 0x2091, 0x2092, 0x2083, 0x2074, 0x2084, 0x2075, 0x2056, 0x2066, 0x2047, 0x2048, 0x2029, 0x2093, 0x2085, 0x2076, 0x2057,
+ 0x2067, 0x2058, 0x2039, 0x2094, 0x2086, 0x2049, 0x2095, 0x2077, 0x2087, 0x2068, 0x2059, 0x2096, 0x2078, 0x2069,
+
+ /* vector table 2 [48] */
+ 0x0000, 0x1001, 0x1010, 0x2011, 0x1020, 0x2021, 0x1002, 0x2012, 0x2022, 0x2013, 0x1030, 0x2031, 0x2032, 0x1003, 0x2023, 0x1040,
+ 0x2041, 0x2042, 0x2033, 0x1004, 0x2014, 0x2024, 0x1005, 0x1050, 0x2051, 0x2043, 0x2034, 0x2015, 0x2025, 0x1006, 0x1060, 0x2061,
+ 0x2052, 0x2062, 0x2053, 0x2044, 0x2035, 0x2016, 0x2045, 0x2026, 0x2063, 0x2054, 0x2036, 0x2046, 0x2064, 0x2055, 0x2065, 0x2056,
+
+ /* vector table 3 [520] */
+ 0x0000, 0x1200, 0x1001, 0x1040, 0x2240, 0x1008, 0x2048, 0x2009, 0x1400, 0x2440, 0x2208, 0x3248, 0x2201, 0x2041, 0x3241, 0x3209,
+ 0x3049, 0x4249, 0x1002, 0x200a, 0x1080, 0x2088, 0x3288, 0x1010, 0x2050, 0x2011, 0x3051, 0x1600, 0x2640, 0x2280, 0x2480, 0x2408,
+ 0x3448, 0x3488, 0x3250, 0x2401, 0x3441, 0x3281, 0x3409, 0x4449, 0x3089, 0x4289, 0x3211, 0x4251, 0x2202, 0x2042, 0x3242, 0x320a,
+ 0x304a, 0x424a, 0x2012, 0x3052, 0x1003, 0x200b, 0x10c0, 0x22c0, 0x20c8, 0x32c8, 0x2210, 0x2090, 0x3290, 0x1018, 0x2058, 0x2081,
+ 0x4489, 0x3411, 0x3091, 0x4291, 0x2019, 0x3059, 0x3212, 0x4252, 0x304b, 0x2013, 0x1004, 0x200c, 0x1800, 0x2840, 0x2680, 0x24c0,
+ 0x1100, 0x2608, 0x3648, 0x3688, 0x34c8, 0x2410, 0x3450, 0x3258, 0x2098, 0x2601, 0x3641, 0x3481, 0x20c1, 0x32c1, 0x4649, 0x30c9,
+ 0x42c9, 0x4451, 0x4491, 0x42d1, 0x4259, 0x3099, 0x3442, 0x3282, 0x340a, 0x444a, 0x308a, 0x428a, 0x3092, 0x4292, 0x201a, 0x305a,
+ 0x2203, 0x2043, 0x320b, 0x424b, 0x3053, 0x2300, 0x2808, 0x3308, 0x3490, 0x20d0, 0x32d0, 0x2218, 0x3298, 0x1020, 0x2060, 0x34c1,
+ 0x3609, 0x4689, 0x30d1, 0x3219, 0x4299, 0x2021, 0x3061, 0x2402, 0x2082, 0x3482, 0x448a, 0x3412, 0x4452, 0x3243, 0x340b, 0x3213,
+ 0x4253, 0x201b, 0x305b, 0x2044, 0x2014, 0x2880, 0x26c0, 0x3848, 0x36c8, 0x2108, 0x2610, 0x3650, 0x34d0, 0x2110, 0x3310, 0x2418,
+ 0x3498, 0x3681, 0x3301, 0x44c9, 0x46c9, 0x4309, 0x3611, 0x4651, 0x44d1, 0x4459, 0x42d9, 0x30a1, 0x3642, 0x20c2, 0x464a, 0x42ca,
+ 0x4492, 0x30d2, 0x42d2, 0x321a, 0x425a, 0x445a, 0x309a, 0x429a, 0x2022, 0x444b, 0x308b, 0x428b, 0x304c, 0x3054, 0x2500, 0x3888,
+ 0x3508, 0x3850, 0x3690, 0x3458, 0x20d8, 0x32d8, 0x2220, 0x3260, 0x20a0, 0x32a0, 0x2801, 0x3841, 0x2101, 0x3809, 0x4849, 0x3109,
+ 0x4509, 0x4691, 0x3111, 0x4311, 0x3419, 0x4499, 0x30d9, 0x3221, 0x4261, 0x42a1, 0x2602, 0x3682, 0x32c2, 0x34c2, 0x360a, 0x468a,
+ 0x30ca, 0x44ca, 0x3612, 0x44d2, 0x449a, 0x3062, 0x4262, 0x2403, 0x3443, 0x2083, 0x3283, 0x4453, 0x4293, 0x321b, 0x425b, 0x309b,
+ 0x2204, 0x3244, 0x320c, 0x424c, 0x3214, 0x36d0, 0x3510, 0x20e0, 0x3501, 0x4889, 0x4851, 0x3502, 0x310a, 0x430a, 0x450a, 0x4852,
+ 0x465a, 0x30da, 0x30a2, 0x3483, 0x42cb, 0x3413, 0x3093, 0x4493, 0x3063, 0x2084, 0x444c, 0x4254, 0x28c0, 0x38c8, 0x2810, 0x3658,
+ 0x3518, 0x2820, 0x3460, 0x36c1, 0x4709, 0x46d1, 0x4659, 0x44a1, 0x36c2, 0x4692, 0x3112, 0x341a, 0x42da, 0x3222, 0x3422, 0x2603,
+ 0x360b, 0x448b, 0x42d3, 0x44d3, 0x445b, 0x2023, 0x3284, 0x20c4, 0x340c, 0x360c, 0x428c, 0x3414, 0x2700, 0x2900, 0x3708, 0x3908,
+ 0x3890, 0x38d0, 0x3710, 0x2618, 0x2818, 0x3858, 0x3698, 0x3898, 0x34d8, 0x36d8, 0x38d8, 0x2118, 0x3318, 0x3718, 0x2420, 0x2620,
+ 0x3660, 0x3860, 0x34a0, 0x36a0, 0x32e0, 0x34e0, 0x36e0, 0x2120, 0x3320, 0x3881, 0x38c1, 0x3701, 0x3901, 0x48c9, 0x4909, 0x3811,
+ 0x4891, 0x48d1, 0x4511, 0x4711, 0x3619, 0x3819, 0x4859, 0x4699, 0x4899, 0x44d9, 0x46d9, 0x48d9, 0x3119, 0x4319, 0x4519, 0x4719,
+ 0x3421, 0x3621, 0x3821, 0x4461, 0x4661, 0x4861, 0x46a1, 0x30e1, 0x42e1, 0x44e1, 0x46e1, 0x3121, 0x4321, 0x2802, 0x3842, 0x3882,
+ 0x38c2, 0x2102, 0x3302, 0x3702, 0x380a, 0x484a, 0x488a, 0x46ca, 0x48ca, 0x470a, 0x3812, 0x4652, 0x4892, 0x46d2, 0x48d2, 0x4312,
+ 0x4512, 0x4712, 0x361a, 0x381a, 0x485a, 0x469a, 0x489a, 0x44da, 0x46da, 0x311a, 0x431a, 0x451a, 0x3622, 0x4462, 0x4662, 0x42a2,
+ 0x44a2, 0x46a2, 0x30e2, 0x42e2, 0x44e2, 0x2803, 0x3643, 0x3843, 0x3683, 0x3883, 0x20c3, 0x32c3, 0x34c3, 0x36c3, 0x38c3, 0x2103,
+ 0x3303, 0x3503, 0x3703, 0x380b, 0x464b, 0x484b, 0x468b, 0x488b, 0x30cb, 0x44cb, 0x46cb, 0x48cb, 0x310b, 0x430b, 0x450b, 0x470b,
+ 0x3613, 0x3813, 0x4653, 0x4853, 0x4693, 0x4893, 0x30d3, 0x46d3, 0x3113, 0x4313, 0x4513, 0x341b, 0x361b, 0x381b, 0x465b, 0x485b,
+ 0x429b, 0x449b, 0x469b, 0x30db, 0x42db, 0x44db, 0x46db, 0x311b, 0x431b, 0x3223, 0x3423, 0x3623, 0x4263, 0x4463, 0x4663, 0x30a3,
+ 0x42a3, 0x44a3, 0x30e3, 0x42e3, 0x2404, 0x2604, 0x2804, 0x3444, 0x3644, 0x3844, 0x3484, 0x3684, 0x32c4, 0x34c4, 0x36c4, 0x2104,
+ 0x3304, 0x380c, 0x464c, 0x484c, 0x308c, 0x448c, 0x468c, 0x30cc, 0x42cc, 0x44cc, 0x46cc, 0x310c, 0x430c, 0x3614, 0x4454, 0x4654,
+ 0x3094, 0x4294, 0x4494, 0x4694, 0x30d4, 0x42d4, 0x44d4, 0x201c, 0x321c, 0x341c, 0x361c, 0x305c, 0x425c, 0x445c, 0x465c, 0x309c,
+ 0x429c, 0x449c, 0x30dc, 0x42dc, 0x2024, 0x3224, 0x3064, 0x4264,
+
+ /* vector table 4 [209] */
+ 0x0000, 0x1200, 0x1040, 0x1008, 0x1001, 0x2009, 0x2240, 0x2208, 0x2048, 0x3248, 0x2201, 0x2041, 0x3049, 0x3241, 0x3209, 0x4249,
+ 0x1002, 0x1400, 0x2440, 0x1080, 0x3288, 0x1010, 0x2011, 0x3051, 0x200a, 0x2280, 0x3448, 0x2088, 0x2050, 0x3250, 0x4289, 0x4251,
+ 0x2042, 0x304a, 0x2408, 0x2210, 0x2401, 0x3441, 0x2081, 0x3281, 0x3409, 0x4449, 0x3089, 0x3211, 0x2202, 0x3242, 0x320a, 0x424a,
+ 0x2012, 0x3052, 0x1003, 0x1600, 0x2640, 0x2480, 0x3488, 0x2090, 0x3290, 0x3091, 0x4291, 0x2019, 0x200b, 0x10c0, 0x22c0, 0x20c8,
+ 0x32c8, 0x1018, 0x2058, 0x3481, 0x4489, 0x4451, 0x3059, 0x308a, 0x3212, 0x4252, 0x2608, 0x3648, 0x2410, 0x3450, 0x3609, 0x42c9,
+ 0x3411, 0x3219, 0x3442, 0x2082, 0x3282, 0x444a, 0x428a, 0x2203, 0x2043, 0x320b, 0x304b, 0x3490, 0x2218, 0x3258, 0x2601, 0x3641,
+ 0x32c1, 0x4649, 0x30c9, 0x4259, 0x2402, 0x340a, 0x3243, 0x2680, 0x20d0, 0x32d0, 0x2098, 0x20c1, 0x4491, 0x30d1, 0x2602, 0x3092,
+ 0x4292, 0x201a, 0x305a, 0x424b, 0x2013, 0x24c0, 0x26c0, 0x3688, 0x34c8, 0x36c8, 0x2610, 0x3650, 0x3690, 0x34d0, 0x2418, 0x2618,
+ 0x3458, 0x3658, 0x3298, 0x3498, 0x20d8, 0x32d8, 0x3681, 0x34c1, 0x36c1, 0x4689, 0x44c9, 0x46c9, 0x3611, 0x4651, 0x4691, 0x42d1,
+ 0x44d1, 0x3419, 0x3619, 0x4459, 0x4659, 0x3099, 0x4299, 0x4499, 0x30d9, 0x42d9, 0x3642, 0x3482, 0x3682, 0x20c2, 0x32c2, 0x34c2,
+ 0x360a, 0x464a, 0x448a, 0x468a, 0x30ca, 0x42ca, 0x44ca, 0x3412, 0x3612, 0x4452, 0x4652, 0x4492, 0x30d2, 0x42d2, 0x321a, 0x341a,
+ 0x425a, 0x445a, 0x309a, 0x429a, 0x2403, 0x2603, 0x3443, 0x3643, 0x2083, 0x3283, 0x3483, 0x20c3, 0x32c3, 0x340b, 0x360b, 0x444b,
+ 0x464b, 0x308b, 0x428b, 0x448b, 0x30cb, 0x42cb, 0x3213, 0x3413, 0x3053, 0x4253, 0x4453, 0x3093, 0x4293, 0x201b, 0x321b, 0x305b,
+ 0x425b,
+
+ /* vector table 5 [192] */
+ 0x0000, 0x1100, 0x1040, 0x1010, 0x1004, 0x1001, 0x2140, 0x2050, 0x2014, 0x2101, 0x2041, 0x2005, 0x2110, 0x3150, 0x2104, 0x2044,
+ 0x3054, 0x2011, 0x3105, 0x3015, 0x3144, 0x3114, 0x4154, 0x3141, 0x3111, 0x3051, 0x3045, 0x4055, 0x1200, 0x1008, 0x4151, 0x4145,
+ 0x4115, 0x5155, 0x1002, 0x2006, 0x2240, 0x1080, 0x1020, 0x2009, 0x2180, 0x2090, 0x2060, 0x2024, 0x2018, 0x2102, 0x2012, 0x2210,
+ 0x3190, 0x2120, 0x3064, 0x2048, 0x2201, 0x2081, 0x2021, 0x3019, 0x2042, 0x3016, 0x3250, 0x2204, 0x3244, 0x2084, 0x3184, 0x3094,
+ 0x3124, 0x3148, 0x3058, 0x3241, 0x3181, 0x3091, 0x3061, 0x3085, 0x3025, 0x4125, 0x4065, 0x3049, 0x3142, 0x3112, 0x3052, 0x3106,
+ 0x3046, 0x3160, 0x3214, 0x4254, 0x4194, 0x4164, 0x2108, 0x3118, 0x3211, 0x3121, 0x4161, 0x3205, 0x5165, 0x3109, 0x4149, 0x4119,
+ 0x4059, 0x5159, 0x4152, 0x4146, 0x4116, 0x4056, 0x2280, 0x20a0, 0x4251, 0x4191, 0x4185, 0x4215, 0x4095, 0x3029, 0x2022, 0x200a,
+ 0x3290, 0x2220, 0x3260, 0x31a0, 0x3284, 0x4294, 0x3224, 0x4264, 0x30a4, 0x41a4, 0x2208, 0x3248, 0x2088, 0x3188, 0x3218, 0x4158,
+ 0x4258, 0x3098, 0x4198, 0x2028, 0x3128, 0x3068, 0x4168, 0x3281, 0x4291, 0x3221, 0x4261, 0x30a1, 0x41a1, 0x4245, 0x4285, 0x5255,
+ 0x5195, 0x5295, 0x4225, 0x5265, 0x40a5, 0x51a5, 0x3209, 0x4249, 0x3089, 0x4189, 0x4219, 0x5259, 0x4099, 0x5199, 0x4129, 0x4069,
+ 0x5169, 0x2202, 0x3242, 0x2082, 0x3182, 0x3212, 0x4252, 0x3092, 0x4192, 0x3122, 0x3062, 0x4162, 0x3206, 0x4246, 0x3086, 0x4186,
+ 0x4216, 0x5156, 0x5256, 0x4096, 0x5196, 0x3026, 0x4126, 0x4066, 0x5166, 0x310a, 0x304a, 0x414a, 0x301a, 0x411a, 0x405a, 0x515a,
+
+ /* vector table 6 [32] */
+ 0x0000, 0x1100, 0x1040, 0x1010, 0x1004, 0x1001, 0x2140, 0x2110, 0x2050, 0x2104, 0x2044, 0x2014, 0x2101, 0x2011, 0x2005, 0x2041,
+ 0x3150, 0x3144, 0x3054, 0x3141, 0x3051, 0x3045, 0x3015, 0x3114, 0x3111, 0x3105, 0x4055, 0x4154, 0x4145, 0x4115, 0x4151, 0x5155,
+};
diff --git a/audio_codec/libcook/ra_mlt.c b/audio_codec/libcook/ra_mlt.c
new file mode 100644
index 0000000..6947ca1
--- a/dev/null
+++ b/audio_codec/libcook/ra_mlt.c
@@ -0,0 +1,357 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: mlt.c,v 1.5 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * mlt.c - fast MLT/IMLT functions
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+static const int postSkip[NUM_MLT_SIZES] = {7, 3, 1};
+
+/**************************************************************************************
+ * Function: PreMultiply
+ *
+ * Description: pre-twiddle stage of MDCT
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmlt samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: minimum 1 GB in, 2 GB out - loses (1+tabidx) int bits
+ * normalization by 2/sqrt(N) is rolled into tables here
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ * should asm code (compiler not doing free pointer updates, etc.)
+ **************************************************************************************/
+static void PreMultiply(int tabidx, int *zbuf1)
+{
+ int i, nmlt, ar1, ai1, ar2, ai2, z1, z2;
+ int t, cms2, cps2a, sin2a, cps2b, sin2b;
+ int *zbuf2;
+ const int *csptr;
+
+ nmlt = nmltTab[tabidx];
+ zbuf2 = zbuf1 + nmlt - 1;
+ csptr = cos4sin4tab + cos4sin4tabOffset[tabidx];
+
+ /* whole thing should fit in registers - verify that compiler does this */
+ for (i = nmlt >> 2; i != 0; i--) {
+ /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */
+ cps2a = *csptr++;
+ sin2a = *csptr++;
+ cps2b = *csptr++;
+ sin2b = *csptr++;
+
+ ar1 = *(zbuf1 + 0);
+ ai2 = *(zbuf1 + 1);
+ ai1 = *(zbuf2 + 0);
+ ar2 = *(zbuf2 - 1);
+
+ /* gain 1 int bit from MULSHIFT32, but drop 2, 3, or 4 int bits from table scaling */
+ t = MULSHIFT32(sin2a, ar1 + ai1);
+ z2 = MULSHIFT32(cps2a, ai1) - t;
+ cms2 = cps2a - 2 * sin2a;
+ z1 = MULSHIFT32(cms2, ar1) + t;
+ *zbuf1++ = z1;
+ *zbuf1++ = z2;
+
+ t = MULSHIFT32(sin2b, ar2 + ai2);
+ z2 = MULSHIFT32(cps2b, ai2) - t;
+ cms2 = cps2b - 2 * sin2b;
+ z1 = MULSHIFT32(cms2, ar2) + t;
+ *zbuf2-- = z2;
+ *zbuf2-- = z1;
+
+ }
+
+ /* Note on scaling...
+ * assumes 1 guard bit in, gains (1 + tabidx) fraction bits
+ * i.e. gain 1, 2, or 3 fraction bits, for nSamps = 256, 512, 1024
+ * (left-shifting, since table scaled by 2 / sqrt(nSamps))
+ * this offsets the fact that each extra pass in FFT gains one more int bit
+ */
+ return;
+}
+
+/**************************************************************************************
+ * Function: PostMultiply
+ *
+ * Description: post-twiddle stage of MDCT
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmlt samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: minimum 1 GB in, 2 GB out - gains 1 int bit
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ * should asm code (compiler not doing free pointer updates, etc.)
+ **************************************************************************************/
+static void PostMultiply(int tabidx, int *fft1)
+{
+ int i, nmlt, ar1, ai1, ar2, ai2, skipFactor;
+ int t, cms2, cps2, sin2;
+ int *fft2;
+ const int *csptr;
+
+ nmlt = nmltTab[tabidx];
+ csptr = cos1sin1tab;
+ skipFactor = postSkip[tabidx];
+ fft2 = fft1 + nmlt - 1;
+
+ /* load coeffs for first pass
+ * cps2 = (cos+sin)/2, sin2 = sin/2, cms2 = (cos-sin)/2
+ */
+ cps2 = *csptr++;
+ sin2 = *csptr;
+ csptr += skipFactor;
+ cms2 = cps2 - 2 * sin2;
+
+ for (i = nmlt >> 2; i != 0; i--) {
+ ar1 = *(fft1 + 0);
+ ai1 = *(fft1 + 1);
+ ar2 = *(fft2 - 1);
+ ai2 = *(fft2 + 0);
+
+ /* gain 1 int bit from MULSHIFT32, and one since coeffs are stored as 0.5 * (cos+sin), 0.5*sin */
+ t = MULSHIFT32(sin2, ar1 + ai1);
+ *fft2-- = t - MULSHIFT32(cps2, ai1);
+ *fft1++ = t + MULSHIFT32(cms2, ar1);
+
+ cps2 = *csptr++;
+ sin2 = *csptr;
+ csptr += skipFactor;
+
+ ai2 = -ai2;
+ t = MULSHIFT32(sin2, ar2 + ai2);
+ *fft2-- = t - MULSHIFT32(cps2, ai2);
+ cms2 = cps2 - 2 * sin2;
+ *fft1++ = t + MULSHIFT32(cms2, ar2);
+
+ }
+
+ /* Note on scaling...
+ * assumes 1 guard bit in, gains 2 int bits
+ * max gain of abs(cos) + abs(sin) = sqrt(2) = 1.414, so current format
+ * guarantees 1 guard bit in output
+ */
+ return;
+}
+
+/**************************************************************************************
+ * Function: PreMultiplyRescale
+ *
+ * Description: pre-twiddle stage of MDCT, with rescaling for extra guard bits
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmlt samples
+ * number of guard bits to add to input before processing
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: see notes on PreMultiply(), above
+ **************************************************************************************/
+static void PreMultiplyRescale(int tabidx, int *zbuf1, int es)
+{
+ int i, nmlt, ar1, ai1, ar2, ai2, z1, z2;
+ int t, cms2, cps2a, sin2a, cps2b, sin2b;
+ int *zbuf2;
+ const int *csptr;
+
+ nmlt = nmltTab[tabidx];
+ zbuf2 = zbuf1 + nmlt - 1;
+ csptr = cos4sin4tab + cos4sin4tabOffset[tabidx];
+
+ /* whole thing should fit in registers - verify that compiler does this */
+ for (i = nmlt >> 2; i != 0; i--) {
+ /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */
+ cps2a = *csptr++;
+ sin2a = *csptr++;
+ cps2b = *csptr++;
+ sin2b = *csptr++;
+
+ ar1 = *(zbuf1 + 0) >> es;
+ ai1 = *(zbuf2 + 0) >> es;
+ ai2 = *(zbuf1 + 1) >> es;
+
+ /* gain 1 int bit from MULSHIFT32, but drop 2, 3, or 4 int bits from table scaling */
+ t = MULSHIFT32(sin2a, ar1 + ai1);
+ z2 = MULSHIFT32(cps2a, ai1) - t;
+ cms2 = cps2a - 2 * sin2a;
+ z1 = MULSHIFT32(cms2, ar1) + t;
+ *zbuf1++ = z1;
+ *zbuf1++ = z2;
+
+ ar2 = *(zbuf2 - 1) >> es; /* do here to free up register used for es */
+
+ t = MULSHIFT32(sin2b, ar2 + ai2);
+ z2 = MULSHIFT32(cps2b, ai2) - t;
+ cms2 = cps2b - 2 * sin2b;
+ z1 = MULSHIFT32(cms2, ar2) + t;
+ *zbuf2-- = z2;
+ *zbuf2-- = z1;
+
+ }
+
+ /* see comments in PreMultiply() for notes on scaling */
+ return;
+}
+
+/**************************************************************************************
+ * Function: PostMultiplyRescale
+ *
+ * Description: post-twiddle stage of MDCT, with rescaling for extra guard bits
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmlt samples
+ * number of guard bits to remove from output
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: clips output to [-2^30, 2^30 - 1], guaranteeing at least 1 guard bit
+ * see notes on PostMultiply(), above
+ **************************************************************************************/
+static void PostMultiplyRescale(int tabidx, int *fft1, int es)
+{
+ int i, nmlt, ar1, ai1, ar2, ai2, skipFactor, z;
+ int t, cs2, sin2;
+ int *fft2;
+ const int *csptr;
+
+ nmlt = nmltTab[tabidx];
+ csptr = cos1sin1tab;
+ skipFactor = postSkip[tabidx];
+ fft2 = fft1 + nmlt - 1;
+
+ /* load coeffs for first pass
+ * cps2 = (cos+sin)/2, sin2 = sin/2, cms2 = (cos-sin)/2
+ */
+ cs2 = *csptr++;
+ sin2 = *csptr;
+ csptr += skipFactor;
+
+ for (i = nmlt >> 2; i != 0; i--) {
+ ar1 = *(fft1 + 0);
+ ai1 = *(fft1 + 1);
+ ai2 = *(fft2 + 0);
+
+ /* gain 1 int bit from MULSHIFT32, and one since coeffs are stored as 0.5 * (cos+sin), 0.5*sin */
+ t = MULSHIFT32(sin2, ar1 + ai1);
+ z = t - MULSHIFT32(cs2, ai1);
+ CLIP_2N_SHIFT(z, es);
+ *fft2-- = z;
+ cs2 -= 2 * sin2;
+ z = t + MULSHIFT32(cs2, ar1);
+ CLIP_2N_SHIFT(z, es);
+ *fft1++ = z;
+
+ cs2 = *csptr++;
+ sin2 = *csptr;
+ csptr += skipFactor;
+
+ ar2 = *fft2;
+ ai2 = -ai2;
+ t = MULSHIFT32(sin2, ar2 + ai2);
+ z = t - MULSHIFT32(cs2, ai2);
+ CLIP_2N_SHIFT(z, es);
+ *fft2-- = z;
+ cs2 -= 2 * sin2;
+ z = t + MULSHIFT32(cs2, ar2);
+ CLIP_2N_SHIFT(z, es);
+ *fft1++ = z;
+ cs2 += 2 * sin2;
+
+ }
+
+ /* see comments in PostMultiply() for notes on scaling */
+ return;
+}
+
+/**************************************************************************************
+ * Function: IMLTNoWindow
+ *
+ * Description: inverse MLT without window or overlap-add
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmlt samples
+ * number of guard bits in the input buffer
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: operates in-place, and generates nmlt output samples from nmlt input
+ * samples (doesn't do synthesis window which expands to 2*nmlt samples)
+ * if number of guard bits in input is < GBITS_IN_IMLT, the input is
+ * scaled (>>) before the IMLT and rescaled (<<, with clipping) after
+ * the IMLT (rare)
+ * the output has FBITS_LOST_IMLT fewer fraction bits than the input
+ * the output will always have at least 1 guard bit
+ **************************************************************************************/
+void IMLTNoWindow(int tabidx, int *mlt, int gb)
+{
+ int es;
+
+ /* fast in-place DCT-IV - adds guard bits if necessary */
+ if (gb < GBITS_IN_IMLT) {
+ es = GBITS_IN_IMLT - gb;
+ PreMultiplyRescale(tabidx, mlt, es);
+ R4FFT(tabidx, mlt);
+ PostMultiplyRescale(tabidx, mlt, es);
+ } else {
+ PreMultiply(tabidx, mlt);
+ R4FFT(tabidx, mlt);
+ PostMultiply(tabidx, mlt);
+ }
+
+ return;
+}
+
diff --git a/audio_codec/libcook/ra_sqvh.c b/audio_codec/libcook/ra_sqvh.c
new file mode 100644
index 0000000..6528185
--- a/dev/null
+++ b/audio_codec/libcook/ra_sqvh.c
@@ -0,0 +1,431 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sqvh.c,v 1.6 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * sqvh.c - Huffman decoding, unpacking, and dequantization of MLT coefficients
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+static const int vpr_tab[7] = {10, 10, 10, 5, 5, 4, 4}; /* number of vectors in one region (20 bins) */
+
+/**************************************************************************************
+ * Function: DecodeHuffmanVectors
+ *
+ * Description: decode vector Huffman symbols from bitstream for one region
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ * cat for this region
+ * buffer to receive decoded symbols
+ * number of bits remaining in bitstream
+ *
+ * Outputs: NBINS decoded symbols
+ *
+ * Return: number of bits left in bitstream, -1 if ran out of bits
+ *
+ * Notes: the alphabet of decoded symbols has been remapped from the
+ * floating-pt reference, to replace the Horner-method polynomial
+ * evaluation with shift-and-mask (i.e. change of basis to replace
+ * 1/(kmax+1) with 1/(2^n) for unpacking vectorized codes)
+ * uses byte-cache Huffman decoder and conditional logic which is
+ * ARM-friendly
+ * this has been carefully arranged to compile well with ADS, so if you
+ * change anything, make sure you study the assembly code carefully!
+ * consider fusing with loop over all nRegions (rather than function call
+ * per loop) to avoid refilling cache each call
+ **************************************************************************************/
+static int DecodeHuffmanVectors(BitStreamInfo *bsi, int cat, int *k, int bitsLeft)
+{
+ int nBits, startBits, vpr, v, vPacked;
+ int off, key, cachedBits, padBits;
+ unsigned int cache, count, t, total, cw;
+ unsigned char *buf, *countCurr;
+ const unsigned char *countBase;
+ const unsigned short *map;
+
+ buf = bsi->buf;
+ off = bsi->off;
+ key = bsi->key;
+
+ countBase = huffTabVectorInfo[cat].count;
+ map = huffTabVector + huffTabVectorInfo[cat].offset;
+ startBits = bitsLeft;
+ vpr = vpr_tab[cat];
+
+ /* initially fill cache with any partial byte */
+ cache = 0;
+ cachedBits = (8 - off) & 0x07;
+ if (cachedBits) {
+ cache = (unsigned int)((*buf++) ^ pkkey[key++]) << (32 - cachedBits);
+ }
+ key &= 0x03;
+ bitsLeft -= cachedBits;
+
+ padBits = 0;
+ while (vpr > 0) {
+ /* refill cache - assumes cachedBits <= 24 */
+ if (bitsLeft >= 8) {
+ /* load 1 new byte into left-justified cache */
+ cache |= (unsigned int)((*buf++) ^ pkkey[key++]) << (24 - cachedBits);
+ key &= 0x03;
+ cachedBits += 8;
+ bitsLeft -= 8;
+ } else {
+ /* last time through, pad cache with zeros and drain cache */
+ if (cachedBits + bitsLeft <= 0) {
+ return -1;
+ }
+ if (bitsLeft > 0) {
+ cache |= (unsigned int)((*buf++) ^ pkkey[key++]) << (24 - cachedBits);
+ }
+ key &= 0x03;
+ cachedBits += bitsLeft;
+ bitsLeft = 0;
+
+ cache &= (signed int)0x80000000 >> (cachedBits - 1);
+ padBits = 21;
+ cachedBits += padBits; /* okay if this is > 32 (0's automatically shifted in from right) */
+ }
+
+ /* max bits per Huffman symbol = 16, max sign bits = 5, so 21 bits will do */
+ while (vpr > 0 && cachedBits >= 21) {
+ /* left-justify to bit 16 */
+ cw = cache >> (32 - 17);
+ countCurr = (unsigned char *)countBase;
+ count = *countCurr++;
+ t = count << 16;
+ total = 0;
+
+ while (cw >= t) {
+ cw -= t;
+ cw <<= 1;
+ total += count;
+ count = *countCurr++;
+ t = count << 16;
+ }
+
+ nBits = countCurr - countBase;
+ cachedBits -= nBits;
+ cache <<= nBits;
+
+ vPacked = (int)map[total + (cw >> 16)];
+
+ /* sign bits */
+ nBits = (vPacked >> 12) & 0x0f;
+ cachedBits -= nBits;
+ if (cachedBits < padBits) {
+ return -1;
+ }
+
+ /* should create good asm with conditional instruction execution on ARM
+ * format of vPacked:
+ * bits 12-15 = number of sign bits
+ * 4 bits/coef for cat = 0, 1, 2 (bits 0-3, 4-7)
+ * 3 bits/coef for cat = 3, 4 (bits 0-2, 3-5, 6-8. 9-11)
+ * 2 bits/coef for cat = 5, 6 (bits 0-1, 2-3, 4-5. 6-7, 8-9)
+ */
+ if (cat < 3) {
+ v = (vPacked >> 0) & 0x0f;
+ if (v) {
+ v |= (cache & 0x80000000);
+ cache <<= 1;
+ } *k++ = v;
+ v = (vPacked >> 4) & 0x0f;
+ if (v) {
+ v |= (cache & 0x80000000);
+ cache <<= 1;
+ } *k++ = v;
+ } else if (cat < 5) {
+ v = (vPacked >> 0) & 0x07;
+ if (v) {
+ v |= (cache & 0x80000000);
+ cache <<= 1;
+ } *k++ = v;
+ v = (vPacked >> 3) & 0x07;
+ if (v) {
+ v |= (cache & 0x80000000);
+ cache <<= 1;
+ } *k++ = v;
+ v = (vPacked >> 6) & 0x07;
+ if (v) {
+ v |= (cache & 0x80000000);
+ cache <<= 1;
+ } *k++ = v;
+ v = (vPacked >> 9) & 0x07;
+ if (v) {
+ v |= (cache & 0x80000000);
+ cache <<= 1;
+ } *k++ = v;
+ } else {
+ v = (vPacked >> 0) & 0x03;
+ if (v) {
+ v |= (cache & 0x80000000);
+ cache <<= 1;
+ } *k++ = v;
+ v = (vPacked >> 2) & 0x03;
+ if (v) {
+ v |= (cache & 0x80000000);
+ cache <<= 1;
+ } *k++ = v;
+ v = (vPacked >> 4) & 0x03;
+ if (v) {
+ v |= (cache & 0x80000000);
+ cache <<= 1;
+ } *k++ = v;
+ v = (vPacked >> 6) & 0x03;
+ if (v) {
+ v |= (cache & 0x80000000);
+ cache <<= 1;
+ } *k++ = v;
+ v = (vPacked >> 8) & 0x03;
+ if (v) {
+ v |= (cache & 0x80000000);
+ cache <<= 1;
+ } *k++ = v;
+ }
+ vpr--;
+ }
+ }
+
+ return startBits - bitsLeft - (cachedBits - padBits);
+}
+
+/* Q28 - first column (0's) are dither
+ * rows ..... cat = [0, 7]
+ * columns .. k = [0, kmax_tab[cat]]
+ * qcOffset[cat] is starting index for k = 0
+ *
+ * qcTab[0] scaled by 1.0
+ * qcTab[1] scaled by sqrt(2)
+ *
+ * lower cat = shorter vectors = finer Q = higher expected bits
+ * higher cat = longer vectors = coarser Q = lower expected bits
+ *
+ * kmax_tab[8] = { 13, 9, 6, 4, 3, 2, 1, 0 };
+ */
+static const int qcTab[2][14 + 10 + 7 + 5 + 4 + 3 + 2 + 1] = {
+ {
+ /* quant_centroid_tab * 1.0 */
+ 0x00000000, 0x0645a1c8, 0x0c2d0e50, 0x11eb8520, 0x17a1cac0, 0x1d4fdf40, 0x22ed9180, 0x28a7ef80, 0x2e49ba40, 0x33eb8500, 0x39916880, 0x3f126e80, 0x449ba600, 0x4b958100,
+ 0x00000000, 0x08b43960, 0x10f5c280, 0x19020c40, 0x21168740, 0x2922d100, 0x3126e980, 0x38fdf3c0, 0x411eb880, 0x49eb8500,
+ 0x00000000, 0x0bef9db0, 0x176c8b40, 0x22e147c0, 0x2e1cac00, 0x39581080, 0x450e5600,
+ 0x00000000, 0x10189380, 0x20000000, 0x2fe35400, 0x3fc28f40,
+ 0x00000000, 0x1522d0e0, 0x2b3f7d00, 0x3fba5e40,
+ 0x02d413cc, 0x1a831260, 0x37db22c0,
+ 0x04000000, 0x1f6c8b40,
+ 0x0b504f33
+ },
+ {
+ /* quant_centroid_tab * sqrt(2) */
+ 0x00000000, 0x08deb4dc, 0x11382ec8, 0x1957bba7, 0x216bb2a8, 0x297413e1, 0x31654988, 0x397f0b29, 0x41760b9f, 0x496d0c14, 0x5169d7b1, 0x593280ab, 0x6106bff4, 0x6ae454b2,
+ 0x00000000, 0x0c4f2f4d, 0x17fc2cf0, 0x235ddce6, 0x2ecb22d2, 0x3a2cd2c9, 0x4582ecca, 0x50994ee6, 0x5c17f595, 0x6889e5e1,
+ 0x00000000, 0x10e14b25, 0x212064ce, 0x3153e8c5, 0x413653ba, 0x5118bf09, 0x61a8f143,
+ 0x00000000, 0x16c35fec, 0x2d413ccc, 0x43b94edf, 0x5a2b95ca,
+ 0x00000000, 0x1de40c9b, 0x3d2972e9, 0x5a20002f,
+ 0x04000000, 0x257e5e73, 0x4efe081d,
+ 0x05a82799, 0x2c70b401,
+ 0x10000000
+ },
+};
+
+static const int qcOffset[8] = { 0, 14, 24, 31, 36, 40, 43, 45 };
+
+/**************************************************************************************
+ * Function: ScalarDequant
+ *
+ * Description: dequantize transform coefficients (in-place)
+ *
+ * Inputs: buffer of decoded/un-vectorized symbols with sign in bit 31
+ * cat (quantizer) for this region
+ * pointer to dequantizer table (either scaled by 1.0 or sqrt(2.0))
+ * right-shift amount (i.e. 2^-n for normalizing to correct Q format)
+ * pointer to current contents of dither lfsr
+ * current guard bit mask
+ *
+ * Outputs: NBINS dequantized coefficients
+ * updated dither generator
+ *
+ * Return: updated guard bit mask
+ *
+ * Notes: assumes that shift is in range [0, 31]
+ **************************************************************************************/
+static int ScalarDequant(int *buf, int cat, const int *dqTab, int shift, int *lfsrInit, int gbMask)
+{
+ int i, k;
+ int dq, sign, lfsr;
+
+ lfsr = *lfsrInit;
+
+ /* multiply dequantized value (from centroid table) or the dither value (if quantized coeff == 0)
+ * with the power in this region (from envelope)
+ *
+ * implements:
+ * buf[i] = quant_centroid_tab[cat][buf[i]] * pow(2, DQ_FRACBITS_OUT + scale / 2.0)
+ *
+ * example (for testing with Q28 qcTab):
+ * fixdeqnt = (int)((double)qcTab[0][qcOffset[cat] + k] / (double)(1 << 28) * pow(2, DQ_FRACBITS_OUT + scale / 2.0));
+ * *buf++ = fixdeqnt * (sign ? -1 : 1);
+ *
+ * output format = Q(FBITS_OUT_DQ) = Q12 (currently)
+ */
+ for (i = NBINS; i != 0; i--) {
+ k = *buf;
+ if (k == 0 || cat == 7) {
+ /* update the LFSR, producing a random sign */
+ sign = (lfsr >> 31);
+ lfsr = (lfsr << 1) ^(sign & FEEDBACK);
+ dq = dqTab[0] >> shift;
+ gbMask |= dq;
+ *buf++ = (dq ^ sign) - sign; /* inflict the sign */
+ } else {
+ /* for stepsize[cat]*buf[i], use centroid[cat][buf[i]] */
+ sign = k >> 31;
+ k &= 0x7fffffff;
+ dq = dqTab[k] >> shift;
+ gbMask |= dq;
+ *buf++ = (dq ^ sign) - sign; /* inflict the sign */
+ }
+ }
+ *lfsrInit = lfsr;
+
+ /* fast way to bound min guard bits is just to return shift (smallest shift = min number of GB's)
+ * tighter bound is OR'ing all the dequantized values together before applying sign (done here)
+ */
+ return gbMask;
+}
+
+/**************************************************************************************
+ * Function: DecodeTransform
+ *
+ * Description: recover MLT coefficients from scalar-quantized, vector Huffman codes
+ *
+ * Inputs: pointer to initialized Gecko2Info struct
+ * buffer to receive dequantized coefficients
+ * number of bits remaining in bitstream
+ * pointer to current contents of dither lfsr
+ * channel index
+ *
+ * Outputs: nRegions*NBINS dequantized coefficients per channel
+ * updated dither generator
+ *
+ * Return: minimum number of guard bits in coefficients
+ *
+ * Notes: for joint stereo, does in-place deinterleaving into left and right
+ * halves of mlt buffer
+ * (left starts at mlt[0], right starts at mlt[MAXNSAMP])
+ **************************************************************************************/
+int DecodeTransform(Gecko2Info *gi, int *mlt, int availbits, int *lfsrInit, int ch)
+{
+ int r, gbMask, gbMin, bitsUsed, shift, fbits, rmsMax;
+ int *dest, *catbuf, *rmsIndex;
+ const int *dqTab;
+ BitStreamInfo *bsi = &(gi->bsi);
+
+ catbuf = gi->db.catbuf;
+ rmsIndex = gi->db.rmsIndex;
+
+ /* huffman decode - does joint stereo deinterleaving if necessary */
+ for (r = 0; r < gi->cRegions; r++) {
+ if (r < 2 * gi->cplStart) {
+ dest = mlt + NBINS * (r >> 1) + MAXNSAMP * (r & 0x01);
+ } else {
+ dest = mlt + NBINS * (r - gi->cplStart);
+ }
+
+ if (catbuf[r] < 7) {
+ /* cat == 7 means region was not coded, and dequantizer will just add power-normalized dither */
+ bitsUsed = DecodeHuffmanVectors(bsi, catbuf[r], dest, availbits);
+ if (bitsUsed < 0 || bitsUsed > availbits) {
+ break;
+ }
+ AdvanceBitstream(bsi, bitsUsed);
+ availbits -= bitsUsed;
+ }
+ }
+
+ /* if ran out of bits, use dither in rest of regions (zero scalars) */
+ for (; r < gi->cRegions; r++) {
+ catbuf[r] = 7;
+ }
+
+ /* for very large coefficients, we override the default format with fewer fraction bits, to avoid saturation
+ * range of rmsIndex = [-31, 63] (from encoder)
+ */
+ fbits = FBITS_OUT_DQ;
+ rmsMax = gi->rmsMax[ch];
+ if ((rmsMax >> 1) > (28 - fbits)) {
+ fbits = 28 - (rmsMax >> 1);
+ if (fbits < 0) {
+ fbits = 0;
+ }
+ }
+
+ /* dequantize - stops at cRegions*NBINS (doesn't zero out above this) */
+ gbMask = 0;
+ for (r = 0; r < gi->cRegions; r++) {
+ if (r < 2 * gi->cplStart) {
+ dest = mlt + NBINS * (r >> 1) + MAXNSAMP * (r & 0x01);
+ } else {
+ dest = mlt + NBINS * (r - gi->cplStart);
+ }
+
+ /* qcTab = Q28 */
+ dqTab = qcTab[rmsIndex[r] & 0x01] + qcOffset[catbuf[r]];
+ shift = (28 - fbits - (rmsIndex[r] >> 1));
+ shift = MIN(shift, 31); /* underflow to +/- 0 */
+ shift = MAX(shift, 0); /* saturate exponent, could only happen for gigantic rmsMax (never seen in practice) */
+
+ gbMask = ScalarDequant(dest, catbuf[r], dqTab, shift, lfsrInit, gbMask);
+ }
+
+ /* save the number of extra fraction bits we needed, if any */
+ gi->xbits[ch][1] = FBITS_OUT_DQ - fbits;
+
+ /* calculate minimum number of guard bits in mlt[] */
+ gbMin = CLZ(gbMask) - 1;
+ if (gbMin < 0) {
+ gbMin = 0;
+ }
+
+ /* mlt[] values are Q31 * 2^bExp (i.e. Q(31-bExp) = Q(DQ_FRACBITS_OUT)) */
+ return gbMin;
+}
diff --git a/audio_codec/libcook/ra_trigtabs.c b/audio_codec/libcook/ra_trigtabs.c
new file mode 100644
index 0000000..c31bc37
--- a/dev/null
+++ b/audio_codec/libcook/ra_trigtabs.c
@@ -0,0 +1,932 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: trigtabs.c,v 1.5 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * trigtabs.c - tables of sin, cos, etc. for MLT
+ **************************************************************************************/
+
+#include "coder.h"
+
+const int nmltTab[NUM_MLT_SIZES] = {256, 512, 1024};
+
+const int cos4sin4tabOffset[3] = {0, 256, 768};
+
+/* PreMultiply() tables
+ * format = Q31 * 2^[-2, -3, -4] for nmlt = [256, 512, 1024]
+ * reordered for sequential access
+ *
+ * sqrt2divn = sqrt(2.0 / nmlt);
+ * for (i = 0; i < nmlt/4; i++) {
+ * angle = (i + 0.25) * M_PI / nmlt;
+ * x = sqrt2divn * (cos(angle) + sin(angle));
+ * x = sqrt2divn * sin(angle);
+ *
+ * angle = (nmlt/2 - 1 - i + 0.25) * M_PI / nmlt;
+ * x = sqrt2divn * (cos(angle) + sin(angle));
+ * x = sqrt2divn * sin(angle);
+ * }
+ */
+const int cos4sin4tab[256 + 512 + 1024] = {
+ /* 256 */
+ 0x2d64b9da, 0x00238b03, 0x2dab5fdf, 0x2d40bf2f, 0x2df19534, 0x00b1b556, 0x2e37592c, 0x2d3e90e6,
+ 0x2e7cab1c, 0x013fd8d0, 0x2ec18a58, 0x2d3aa413, 0x2f05f637, 0x01cdeff5, 0x2f49ee0f, 0x2d34f8de,
+ 0x2f8d713a, 0x025bf54b, 0x2fd07f0f, 0x2d2d8f7d, 0x301316eb, 0x02e9e359, 0x30553828, 0x2d24683a,
+ 0x3096e223, 0x0377b4a4, 0x30d8143b, 0x2d19836f, 0x3118cdcf, 0x040563b7, 0x31590e3e, 0x2d0ce188,
+ 0x3198d4ea, 0x0492eb1a, 0x31d82137, 0x2cfe8302, 0x3216f287, 0x05204559, 0x32554840, 0x2cee6869,
+ 0x329321c7, 0x05ad6d00, 0x32d07e85, 0x2cdc925e, 0x330d5de3, 0x063a5c9f, 0x3349bf48, 0x2cc90190,
+ 0x3385a222, 0x06c70ec6, 0x33c105db, 0x2cb3b6c1, 0x33fbe9e2, 0x07537e09, 0x34364da6, 0x2c9cb2c2,
+ 0x34703095, 0x07dfa4fe, 0x34a99221, 0x2c83f677, 0x34e271bd, 0x086b7e3d, 0x351acedd, 0x2c6982d3,
+ 0x3552a8f4, 0x08f70463, 0x3589ff7a, 0x2c4d58dc, 0x35c0d1e7, 0x0982320e, 0x35f71fb1, 0x2c2f79a9,
+ 0x362ce855, 0x0a0d01e1, 0x36622b4c, 0x2c0fe65e, 0x3696e814, 0x0a976e82, 0x36cb1e2a, 0x2beea035,
+ 0x36fecd0e, 0x0b21729b, 0x3731f440, 0x2bcba876, 0x37649341, 0x0bab08d9, 0x3796a996, 0x2ba70079,
+ 0x37c836c2, 0x0c342bee, 0x37f93a4b, 0x2b80a9a9, 0x3829b3b9, 0x0cbcd691, 0x3859a292, 0x2b58a580,
+ 0x38890663, 0x0d45037e, 0x38b7deb4, 0x2b2ef588, 0x38e62b13, 0x0dccad74, 0x3913eb0e, 0x2b039b5e,
+ 0x39411e33, 0x0e53cf38, 0x396dc414, 0x2ad698ae, 0x3999dc42, 0x0eda6395, 0x39c5664f, 0x2aa7ef32,
+ 0x39f061d2, 0x0f60655a, 0x3a1ace5f, 0x2a77a0b9, 0x3a44ab8e, 0x0fe5cf5d, 0x3a6df8f8, 0x2a45af1e,
+ 0x3a96b636, 0x106a9c79, 0x3abee2e5, 0x2a121c4e, 0x3ae67ea1, 0x10eec790, 0x3b0d8909, 0x29dcea48,
+ 0x3b3401bb, 0x11724b88, 0x3b59e85a, 0x29a61b17, 0x3b7f3c87, 0x11f52351, 0x3ba3fde7, 0x296db0d8,
+ 0x3bc82c1f, 0x127749de, 0x3bebc6d5, 0x2933adb9, 0x3c0ecdb2, 0x12f8ba2b, 0x3c314060, 0x28f813f6,
+ 0x3c531e88, 0x13796f3b, 0x3c7467d9, 0x28bae5db, 0x3c951bff, 0x13f96417, 0x3cb53aaa, 0x287c25c3,
+ 0x3cd4c38b, 0x147893d1, 0x3cf3b653, 0x283bd61b, 0x3d1212b7, 0x14f6f981, 0x3d2fd86c, 0x27f9f95d,
+ 0x3d4d0728, 0x15749047, 0x3d699ea3, 0x27b69213, 0x3d859e96, 0x15f1534d, 0x3da106bd, 0x2771a2d6,
+ 0x3dbbd6d4, 0x166d3dc3, 0x3dd60e99, 0x272b2e4f, 0x3defadca, 0x16e84ae2, 0x3e08b42a, 0x26e33735,
+ 0x3e212179, 0x176275eb, 0x3e38f57c, 0x2699c04e, 0x3e502ff9, 0x17dbba29, 0x3e66d0b4, 0x264ecc6f,
+ 0x3e7cd778, 0x185412ef, 0x3e92440d, 0x26025e7c, 0x3ea7163f, 0x18cb7b99, 0x3ebb4ddb, 0x25b47968,
+ 0x3eceeaad, 0x1941ef8d, 0x3ee1ec87, 0x25652032, 0x3ef45338, 0x19b76a39, 0x3f061e95, 0x251455eb,
+ 0x3f174e70, 0x1a2be716, 0x3f27e29f, 0x24c21daf, 0x3f37dafa, 0x1a9f61a7, 0x3f473759, 0x246e7aab,
+ 0x3f55f796, 0x1b11d578, 0x3f641b8d, 0x24197017, 0x3f71a31b, 0x1b833e1e, 0x3f7e8e1e, 0x23c3013a,
+ 0x3f8adc77, 0x1bf3973c, 0x3f968e07, 0x236b316b, 0x3fa1a2b2, 0x1c62dc7b, 0x3fac1a5b, 0x2312040b,
+ 0x3fb5f4ea, 0x1cd10993, 0x3fbf3246, 0x22b77c8b, 0x3fc7d258, 0x1d3e1a43, 0x3fcfd50b, 0x225b9e68,
+ 0x3fd73a4a, 0x1daa0a57, 0x3fde0205, 0x21fe6d2c, 0x3fe42c2a, 0x1e14d5a5, 0x3fe9b8a9, 0x219fec71,
+ 0x3feea776, 0x1e7e7811, 0x3ff2f884, 0x21401fd9, 0x3ff6abc8, 0x1ee6ed86, 0x3ff9c13a, 0x20df0b17,
+ 0x3ffc38d1, 0x1f4e31ff, 0x3ffe1288, 0x207cb1e9, 0x3fff4e59, 0x1fb44180, 0x3fffec43, 0x2019181a,
+
+ /* 512 */
+ 0x40191d0b, 0x001921fb, 0x404b3977, 0x3fffd396, 0x407d2e39, 0x007da998, 0x40aefb34, 0x3fff0e32,
+ 0x40e0a049, 0x00e22fff, 0x41121d58, 0x3ffdaae7, 0x41437244, 0x0146b438, 0x41749eee, 0x3ffba9b8,
+ 0x41a5a337, 0x01ab354b, 0x41d67f02, 0x3ff90aaa, 0x42073231, 0x020fb240, 0x4237bca4, 0x3ff5cdc3,
+ 0x42681e3f, 0x02742a1f, 0x429856e4, 0x3ff1f30b, 0x42c86674, 0x02d89bf0, 0x42f84cd2, 0x3fed7a8c,
+ 0x432809e1, 0x033d06bb, 0x43579d83, 0x3fe86452, 0x4387079a, 0x03a16988, 0x43b6480a, 0x3fe2b067,
+ 0x43e55eb6, 0x0405c361, 0x44144b7f, 0x3fdc5edc, 0x44430e4b, 0x046a134c, 0x4471a6fa, 0x3fd56fbe,
+ 0x44a01572, 0x04ce5854, 0x44ce5994, 0x3fcde320, 0x44fc7345, 0x0532917f, 0x452a6269, 0x3fc5b913,
+ 0x455826e2, 0x0596bdd7, 0x4585c094, 0x3fbcf1ad, 0x45b32f64, 0x05fadc66, 0x45e07336, 0x3fb38d02,
+ 0x460d8bed, 0x065eec33, 0x463a796e, 0x3fa98b2a, 0x46673b9d, 0x06c2ec48, 0x4693d25e, 0x3f9eec3e,
+ 0x46c03d96, 0x0726dbae, 0x46ec7d29, 0x3f93b058, 0x471890fd, 0x078ab96e, 0x474478f6, 0x3f87d792,
+ 0x477034f8, 0x07ee8493, 0x479bc4ea, 0x3f7b620c, 0x47c728af, 0x08523c25, 0x47f2602e, 0x3f6e4fe3,
+ 0x481d6b4b, 0x08b5df30, 0x484849ed, 0x3f60a138, 0x4872fbf8, 0x09196cbc, 0x489d8153, 0x3f52562c,
+ 0x48c7d9e2, 0x097ce3d5, 0x48f2058d, 0x3f436ee3, 0x491c0438, 0x09e04385, 0x4945d5ca, 0x3f33eb81,
+ 0x496f7a2a, 0x0a438ad7, 0x4998f13d, 0x3f23cc2e, 0x49c23aea, 0x0aa6b8d5, 0x49eb5718, 0x3f13110f,
+ 0x4a1445ad, 0x0b09cc8c, 0x4a3d0690, 0x3f01ba50, 0x4a6599a7, 0x0b6cc506, 0x4a8dfeda, 0x3eefc81a,
+ 0x4ab63610, 0x0bcfa150, 0x4ade3f30, 0x3edd3a9a, 0x4b061a21, 0x0c326075, 0x4b2dc6cc, 0x3eca11fe,
+ 0x4b554516, 0x0c950182, 0x4b7c94e8, 0x3eb64e75, 0x4ba3b62a, 0x0cf78383, 0x4bcaa8c3, 0x3ea1f02f,
+ 0x4bf16c9c, 0x0d59e586, 0x4c18019c, 0x3e8cf75f, 0x4c3e67ac, 0x0dbc2698, 0x4c649eb4, 0x3e77643a,
+ 0x4c8aa69d, 0x0e1e45c6, 0x4cb07f4f, 0x3e6136f3, 0x4cd628b2, 0x0e80421e, 0x4cfba2b0, 0x3e4a6fc1,
+ 0x4d20ed31, 0x0ee21aaf, 0x4d46081f, 0x3e330ede, 0x4d6af362, 0x0f43ce86, 0x4d8faee3, 0x3e1b1482,
+ 0x4db43a8d, 0x0fa55cb4, 0x4dd89648, 0x3e0280e9, 0x4dfcc1ff, 0x1006c446, 0x4e20bd9a, 0x3de9544f,
+ 0x4e448903, 0x1068044e, 0x4e682425, 0x3dcf8ef3, 0x4e8b8eea, 0x10c91bda, 0x4eaec93b, 0x3db53113,
+ 0x4ed1d303, 0x112a09fc, 0x4ef4ac2d, 0x3d9a3af2, 0x4f1754a2, 0x118acdc4, 0x4f39cc4d, 0x3d7eacd2,
+ 0x4f5c131a, 0x11eb6643, 0x4f7e28f3, 0x3d6286f6, 0x4fa00dc3, 0x124bd28c, 0x4fc1c175, 0x3d45c9a4,
+ 0x4fe343f4, 0x12ac11af, 0x5004952c, 0x3d287523, 0x5025b508, 0x130c22c1, 0x5046a374, 0x3d0a89bc,
+ 0x5067605b, 0x136c04d2, 0x5087eba9, 0x3cec07b8, 0x50a8454b, 0x13cbb6f8, 0x50c86d2b, 0x3cccef62,
+ 0x50e86337, 0x142b3846, 0x5108275a, 0x3cad4107, 0x5127b981, 0x148a87d1, 0x51471999, 0x3c8cfcf6,
+ 0x5166478e, 0x14e9a4ac, 0x5185434c, 0x3c6c237e, 0x51a40cc2, 0x15488dee, 0x51c2a3db, 0x3c4ab4ef,
+ 0x51e10886, 0x15a742ac, 0x51ff3aae, 0x3c28b19e, 0x521d3a42, 0x1605c1fd, 0x523b072f, 0x3c0619dc,
+ 0x5258a163, 0x16640af7, 0x527608cb, 0x3be2ee01, 0x52933d56, 0x16c21cb2, 0x52b03ef1, 0x3bbf2e62,
+ 0x52cd0d8a, 0x171ff646, 0x52e9a910, 0x3b9adb57, 0x53061170, 0x177d96ca, 0x5322469a, 0x3b75f53c,
+ 0x533e487d, 0x17dafd59, 0x535a1705, 0x3b507c69, 0x5375b224, 0x1838290c, 0x539119c7, 0x3b2a713d,
+ 0x53ac4dde, 0x189518fc, 0x53c74e58, 0x3b03d414, 0x53e21b23, 0x18f1cc45, 0x53fcb431, 0x3adca54e,
+ 0x54171970, 0x194e4201, 0x54314ad0, 0x3ab4e54c, 0x544b4841, 0x19aa794d, 0x546511b2, 0x3a8c9470,
+ 0x547ea715, 0x1a067145, 0x54980858, 0x3a63b31d, 0x54b1356d, 0x1a622907, 0x54ca2e44, 0x3a3a41b9,
+ 0x54e2f2ce, 0x1abd9faf, 0x54fb82fb, 0x3a1040a8, 0x5513debc, 0x1b18d45c, 0x552c0602, 0x39e5b054,
+ 0x5543f8be, 0x1b73c62d, 0x555bb6e2, 0x39ba9125, 0x5573405f, 0x1bce7442, 0x558a9525, 0x398ee385,
+ 0x55a1b528, 0x1c28ddbb, 0x55b8a058, 0x3962a7e0, 0x55cf56a8, 0x1c8301b9, 0x55e5d809, 0x3935dea4,
+ 0x55fc246e, 0x1cdcdf5e, 0x56123bc8, 0x3908883f, 0x56281e0b, 0x1d3675cb, 0x563dcb28, 0x38daa520,
+ 0x56534313, 0x1d8fc424, 0x566885be, 0x38ac35ba, 0x567d931b, 0x1de8c98c, 0x56926b1f, 0x387d3a7e,
+ 0x56a70dbc, 0x1e418528, 0x56bb7ae5, 0x384db3e0, 0x56cfb28e, 0x1e99f61d, 0x56e3b4aa, 0x381da256,
+ 0x56f7812e, 0x1ef21b90, 0x570b180c, 0x37ed0657, 0x571e7938, 0x1f49f4a8, 0x5731a4a8, 0x37bbe05a,
+ 0x57449a4e, 0x1fa1808c, 0x57575a20, 0x378a30d8, 0x5769e411, 0x1ff8be65, 0x577c3816, 0x3757f84c,
+ 0x578e5625, 0x204fad5b, 0x57a03e31, 0x37253733, 0x57b1f02f, 0x20a64c97, 0x57c36c16, 0x36f1ee09,
+ 0x57d4b1d9, 0x20fc9b44, 0x57e5c16f, 0x36be1d4c, 0x57f69acc, 0x2152988d, 0x58073de7, 0x3689c57d,
+ 0x5817aab5, 0x21a8439e, 0x5827e12d, 0x3654e71d, 0x5837e143, 0x21fd9ba3, 0x5847aaee, 0x361f82af,
+ 0x58573e25, 0x22529fca, 0x58669add, 0x35e998b5, 0x5875c10e, 0x22a74f40, 0x5884b0ad, 0x35b329b5,
+ 0x589369b3, 0x22fba936, 0x58a1ec15, 0x357c3636, 0x58b037cb, 0x234facda, 0x58be4ccc, 0x3544bebf,
+ 0x58cc2b0f, 0x23a3595e, 0x58d9d28b, 0x350cc3d8, 0x58e74339, 0x23f6adf3, 0x58f47d10, 0x34d4460c,
+ 0x59018008, 0x2449a9cc, 0x590e4c18, 0x349b45e7, 0x591ae13a, 0x249c4c1b, 0x59273f64, 0x3461c3f5,
+ 0x59336690, 0x24ee9415, 0x593f56b6, 0x3427c0c3, 0x594b0fce, 0x254080ef, 0x595691d2, 0x33ed3ce1,
+ 0x5961dcba, 0x259211df, 0x596cf080, 0x33b238e0, 0x5977cd1c, 0x25e3461b, 0x59827288, 0x3376b551,
+ 0x598ce0bd, 0x26341cdb, 0x599717b5, 0x333ab2c6, 0x59a11769, 0x26849558, 0x59aadfd4, 0x32fe31d5,
+ 0x59b470ef, 0x26d4aecb, 0x59bdcab4, 0x32c13311, 0x59c6ed1e, 0x2724686e, 0x59cfd827, 0x3283b712,
+ 0x59d88bc9, 0x2773c17d, 0x59e10800, 0x3245be70, 0x59e94cc5, 0x27c2b934, 0x59f15a15, 0x320749c3,
+ 0x59f92fe9, 0x28114ed0, 0x5a00ce3d, 0x31c859a5, 0x5a08350c, 0x285f8190, 0x5a0f6452, 0x3188eeb2,
+ 0x5a165c0a, 0x28ad50b1, 0x5a1d1c31, 0x31490986, 0x5a23a4c1, 0x28fabb75, 0x5a29f5b7, 0x3108aabf,
+ 0x5a300f0f, 0x2947c11c, 0x5a35f0c5, 0x30c7d2fb, 0x5a3b9ad5, 0x299460e8, 0x5a410d3c, 0x308682dc,
+ 0x5a4647f8, 0x29e09a1c, 0x5a4b4b03, 0x3044bb00, 0x5a50165c, 0x2a2c6bfd, 0x5a54a9ff, 0x30027c0c,
+ 0x5a5905ea, 0x2a77d5ce, 0x5a5d2a1a, 0x2fbfc6a3, 0x5a61168c, 0x2ac2d6d6, 0x5a64cb3e, 0x2f7c9b69,
+ 0x5a68482d, 0x2b0d6e5c, 0x5a6b8d58, 0x2f38fb03, 0x5a6e9abd, 0x2b579ba8, 0x5a717059, 0x2ef4e619,
+ 0x5a740e2a, 0x2ba15e03, 0x5a767430, 0x2eb05d53, 0x5a78a269, 0x2beab4b6, 0x5a7a98d3, 0x2e6b615a,
+ 0x5a7c576d, 0x2c339f0e, 0x5a7dde36, 0x2e25f2d8, 0x5a7f2d2e, 0x2c7c1c55, 0x5a804453, 0x2de01278,
+ 0x5a8123a4, 0x2cc42bd9, 0x5a81cb21, 0x2d99c0e7, 0x5a823acb, 0x2d0bcce8, 0x5a82729f, 0x2d52fed2,
+
+ /* 1024 */
+ 0x5a943d5e, 0x0011c583, 0x5ab7ba6c, 0x5a8269e6, 0x5adb297d, 0x0058db81, 0x5afe8a8b, 0x5a82241c,
+ 0x5b21dd90, 0x009ff149, 0x5b452288, 0x5a81a67e, 0x5b68596d, 0x00e706ad, 0x5b8b8239, 0x5a80f10b,
+ 0x5bae9ce7, 0x012e1b84, 0x5bd1a971, 0x5a8003c5, 0x5bf4a7d2, 0x01752fa0, 0x5c179806, 0x5a7edeac,
+ 0x5c3a7a05, 0x01bc42d5, 0x5c5d4dcc, 0x5a7d81c0, 0x5c801354, 0x020354f9, 0x5ca2ca99, 0x5a7bed02,
+ 0x5cc57394, 0x024a65df, 0x5ce80e41, 0x5a7a2074, 0x5d0a9a9a, 0x0291755b, 0x5d2d189a, 0x5a781c16,
+ 0x5d4f883b, 0x02d88342, 0x5d71e979, 0x5a75dfea, 0x5d943c4e, 0x031f8f67, 0x5db680b4, 0x5a736bf1,
+ 0x5dd8b6a7, 0x0366999f, 0x5dfade20, 0x5a70c02c, 0x5e1cf71c, 0x03ada1bd, 0x5e3f0194, 0x5a6ddc9e,
+ 0x5e60fd84, 0x03f4a798, 0x5e82eae5, 0x5a6ac148, 0x5ea4c9b3, 0x043bab01, 0x5ec699e9, 0x5a676e2c,
+ 0x5ee85b82, 0x0482abce, 0x5f0a0e77, 0x5a63e34b, 0x5f2bb2c5, 0x04c9a9d3, 0x5f4d4865, 0x5a6020a9,
+ 0x5f6ecf53, 0x0510a4e3, 0x5f90478a, 0x5a5c2648, 0x5fb1b104, 0x05579cd4, 0x5fd30bbc, 0x5a57f429,
+ 0x5ff457ad, 0x059e9179, 0x601594d1, 0x5a538a50, 0x6036c325, 0x05e582a7, 0x6057e2a2, 0x5a4ee8bf,
+ 0x6078f344, 0x062c7032, 0x6099f505, 0x5a4a0f79, 0x60bae7e1, 0x067359ed, 0x60dbcbd1, 0x5a44fe81,
+ 0x60fca0d2, 0x06ba3faf, 0x611d66de, 0x5a3fb5db, 0x613e1df0, 0x07012149, 0x615ec603, 0x5a3a3589,
+ 0x617f5f12, 0x0747fe92, 0x619fe918, 0x5a347d8e, 0x61c06410, 0x078ed75d, 0x61e0cff5, 0x5a2e8df0,
+ 0x62012cc2, 0x07d5ab7e, 0x62217a72, 0x5a2866b0, 0x6241b8ff, 0x081c7aca, 0x6261e866, 0x5a2207d3,
+ 0x628208a1, 0x08634516, 0x62a219aa, 0x5a1b715d, 0x62c21b7e, 0x08aa0a35, 0x62e20e17, 0x5a14a352,
+ 0x6301f171, 0x08f0c9fb, 0x6321c585, 0x5a0d9db6, 0x63418a50, 0x0937843e, 0x63613fcd, 0x5a06608d,
+ 0x6380e5f6, 0x097e38d1, 0x63a07cc7, 0x59feebdc, 0x63c0043b, 0x09c4e789, 0x63df7c4d, 0x59f73fa8,
+ 0x63fee4f8, 0x0a0b903b, 0x641e3e38, 0x59ef5bf4, 0x643d8806, 0x0a5232ba, 0x645cc260, 0x59e740c7,
+ 0x647bed3f, 0x0a98cedb, 0x649b08a0, 0x59deee25, 0x64ba147d, 0x0adf6473, 0x64d910d1, 0x59d66413,
+ 0x64f7fd98, 0x0b25f356, 0x6516dacd, 0x59cda296, 0x6535a86b, 0x0b6c7b59, 0x6554666d, 0x59c4a9b4,
+ 0x657314cf, 0x0bb2fc50, 0x6591b38c, 0x59bb7973, 0x65b0429f, 0x0bf9760f, 0x65cec204, 0x59b211d8,
+ 0x65ed31b5, 0x0c3fe86b, 0x660b91af, 0x59a872e8, 0x6629e1ec, 0x0c865339, 0x66482267, 0x599e9cab,
+ 0x6666531d, 0x0cccb64d, 0x66847408, 0x59948f25, 0x66a28524, 0x0d13117c, 0x66c0866d, 0x598a4a5d,
+ 0x66de77dc, 0x0d59649a, 0x66fc596f, 0x597fce5a, 0x671a2b20, 0x0d9faf7c, 0x6737ecea, 0x59751b21,
+ 0x67559eca, 0x0de5f1f7, 0x677340ba, 0x596a30ba, 0x6790d2b6, 0x0e2c2bdf, 0x67ae54ba, 0x595f0f2b,
+ 0x67cbc6c0, 0x0e725d09, 0x67e928c5, 0x5953b67c, 0x68067ac3, 0x0eb88549, 0x6823bcb7, 0x594826b2,
+ 0x6840ee9b, 0x0efea475, 0x685e106c, 0x593c5fd5, 0x687b2224, 0x0f44ba62, 0x689823bf, 0x593061ed,
+ 0x68b5153a, 0x0f8ac6e3, 0x68d1f68f, 0x59242d01, 0x68eec7b9, 0x0fd0c9cd, 0x690b88b5, 0x5917c118,
+ 0x6928397e, 0x1016c2f7, 0x6944da10, 0x590b1e3a, 0x69616a65, 0x105cb233, 0x697dea7b, 0x58fe446f,
+ 0x699a5a4c, 0x10a29758, 0x69b6b9d3, 0x58f133bf, 0x69d3090e, 0x10e8723a, 0x69ef47f6, 0x58e3ec32,
+ 0x6a0b7689, 0x112e42ae, 0x6a2794c1, 0x58d66dcf, 0x6a43a29a, 0x11740889, 0x6a5fa010, 0x58c8b8a0,
+ 0x6a7b8d1e, 0x11b9c3a0, 0x6a9769c1, 0x58baccad, 0x6ab335f4, 0x11ff73c7, 0x6acef1b2, 0x58aca9fe,
+ 0x6aea9cf8, 0x124518d5, 0x6b0637c1, 0x589e509c, 0x6b21c208, 0x128ab29d, 0x6b3d3bcb, 0x588fc090,
+ 0x6b58a503, 0x12d040f6, 0x6b73fdae, 0x5880f9e4, 0x6b8f45c7, 0x1315c3b3, 0x6baa7d49, 0x5871fc9f,
+ 0x6bc5a431, 0x135b3aab, 0x6be0ba7b, 0x5862c8cb, 0x6bfbc021, 0x13a0a5b2, 0x6c16b521, 0x58535e72,
+ 0x6c319975, 0x13e6049e, 0x6c4c6d1a, 0x5843bd9e, 0x6c67300b, 0x142b5743, 0x6c81e245, 0x5833e657,
+ 0x6c9c83c3, 0x14709d78, 0x6cb71482, 0x5823d8a7, 0x6cd1947c, 0x14b5d711, 0x6cec03af, 0x5813949a,
+ 0x6d066215, 0x14fb03e3, 0x6d20afac, 0x58031a37, 0x6d3aec6e, 0x154023c4, 0x6d551858, 0x57f2698b,
+ 0x6d6f3365, 0x15853689, 0x6d893d93, 0x57e1829e, 0x6da336dc, 0x15ca3c08, 0x6dbd1f3c, 0x57d0657c,
+ 0x6dd6f6b1, 0x160f3417, 0x6df0bd35, 0x57bf122f, 0x6e0a72c5, 0x16541e89, 0x6e24175c, 0x57ad88c1,
+ 0x6e3daaf8, 0x1698fb36, 0x6e572d93, 0x579bc93e, 0x6e709f2a, 0x16ddc9f2, 0x6e89ffb9, 0x5789d3b1,
+ 0x6ea34f3d, 0x17228a93, 0x6ebc8db0, 0x5777a824, 0x6ed5bb10, 0x17673cef, 0x6eeed758, 0x576546a2,
+ 0x6f07e285, 0x17abe0dc, 0x6f20dc92, 0x5752af38, 0x6f39c57d, 0x17f0762e, 0x6f529d40, 0x573fe1f0,
+ 0x6f6b63d8, 0x1834fcbc, 0x6f841942, 0x572cded6, 0x6f9cbd79, 0x1879745b, 0x6fb5507a, 0x5719a5f6,
+ 0x6fcdd241, 0x18bddce1, 0x6fe642ca, 0x5706375c, 0x6ffea212, 0x19023625, 0x7016f014, 0x56f29314,
+ 0x702f2ccd, 0x19467ffb, 0x70475839, 0x56deb929, 0x705f7255, 0x198aba3a, 0x70777b1c, 0x56caa9a8,
+ 0x708f728b, 0x19cee4b7, 0x70a7589f, 0x56b6649e, 0x70bf2d53, 0x1a12ff49, 0x70d6f0a4, 0x56a1ea17,
+ 0x70eea28e, 0x1a5709c6, 0x7106430e, 0x568d3a1f, 0x711dd220, 0x1a9b0403, 0x71354fc0, 0x567854c4,
+ 0x714cbbeb, 0x1adeedd7, 0x7164169d, 0x56633a12, 0x717b5fd3, 0x1b22c717, 0x71929789, 0x564dea16,
+ 0x71a9bdba, 0x1b668f9a, 0x71c0d265, 0x563864dd, 0x71d7d585, 0x1baa4737, 0x71eec716, 0x5622aa75,
+ 0x7205a716, 0x1bededc2, 0x721c7580, 0x560cbaeb, 0x72333251, 0x1c318314, 0x7249dd86, 0x55f6964d,
+ 0x7260771b, 0x1c750701, 0x7276ff0d, 0x55e03ca8, 0x728d7557, 0x1cb87960, 0x72a3d9f7, 0x55c9ae0a,
+ 0x72ba2cea, 0x1cfbda08, 0x72d06e2b, 0x55b2ea81, 0x72e69db7, 0x1d3f28cf, 0x72fcbb8c, 0x559bf21a,
+ 0x7312c7a5, 0x1d82658c, 0x7328c1ff, 0x5584c4e5, 0x733eaa96, 0x1dc59015, 0x73548168, 0x556d62f0,
+ 0x736a4671, 0x1e08a840, 0x737ff9ae, 0x5555cc48, 0x73959b1b, 0x1e4bade4, 0x73ab2ab4, 0x553e00fd,
+ 0x73c0a878, 0x1e8ea0d9, 0x73d61461, 0x5526011d, 0x73eb6e6e, 0x1ed180f4, 0x7400b69a, 0x550dccb7,
+ 0x7415ece2, 0x1f144e0d, 0x742b1144, 0x54f563d9, 0x744023bc, 0x1f5707f9, 0x74552446, 0x54dcc694,
+ 0x746a12df, 0x1f99ae91, 0x747eef85, 0x54c3f4f5, 0x7493ba34, 0x1fdc41aa, 0x74a872e8, 0x54aaef0d,
+ 0x74bd199f, 0x201ec11d, 0x74d1ae55, 0x5491b4eb, 0x74e63108, 0x20612cbf, 0x74faa1b3, 0x5478469e,
+ 0x750f0054, 0x20a38468, 0x75234ce8, 0x545ea437, 0x7537876c, 0x20e5c7ee, 0x754bafdc, 0x5444cdc4,
+ 0x755fc635, 0x2127f72a, 0x7573ca75, 0x542ac356, 0x7587bc98, 0x216a11f2, 0x759b9c9b, 0x541084fc,
+ 0x75af6a7b, 0x21ac181e, 0x75c32634, 0x53f612c8, 0x75d6cfc5, 0x21ee0984, 0x75ea672a, 0x53db6cca,
+ 0x75fdec60, 0x222fe5fc, 0x76115f63, 0x53c09311, 0x7624c031, 0x2271ad5e, 0x76380ec8, 0x53a585ae,
+ 0x764b4b23, 0x22b35f80, 0x765e7540, 0x538a44b3, 0x76718d1c, 0x22f4fc3b, 0x768492b4, 0x536ed02f,
+ 0x76978605, 0x23368365, 0x76aa670d, 0x53532835, 0x76bd35c7, 0x2377f4d7, 0x76cff232, 0x53374cd4,
+ 0x76e29c4b, 0x23b95068, 0x76f5340e, 0x531b3e1e, 0x7707b979, 0x23fa95f0, 0x771a2c88, 0x52fefc25,
+ 0x772c8d3a, 0x243bc546, 0x773edb8b, 0x52e286f9, 0x77511778, 0x247cde42, 0x776340ff, 0x52c5dead,
+ 0x7775581d, 0x24bde0bd, 0x77875cce, 0x52a90351, 0x77994f11, 0x24fecc8d, 0x77ab2ee2, 0x528bf4f9,
+ 0x77bcfc3f, 0x253fa18c, 0x77ceb725, 0x526eb3b5, 0x77e05f91, 0x25805f90, 0x77f1f581, 0x52513f99,
+ 0x780378f1, 0x25c10672, 0x7814e9df, 0x523398b5, 0x78264849, 0x2601960b, 0x7837942b, 0x5215bf1c,
+ 0x7848cd83, 0x26420e32, 0x7859f44f, 0x51f7b2e1, 0x786b088c, 0x26826ebf, 0x787c0a36, 0x51d97417,
+ 0x788cf94c, 0x26c2b78b, 0x789dd5cb, 0x51bb02cf, 0x78ae9fb0, 0x2702e86e, 0x78bf56f9, 0x519c5f1d,
+ 0x78cffba3, 0x27430141, 0x78e08dab, 0x517d8913, 0x78f10d0f, 0x278301dc, 0x790179cd, 0x515e80c5,
+ 0x7911d3e2, 0x27c2ea18, 0x79221b4b, 0x513f4645, 0x79325006, 0x2802b9cc, 0x79427210, 0x511fd9a8,
+ 0x79528167, 0x284270d3, 0x79627e08, 0x51003b00, 0x797267f2, 0x28820f04, 0x79823f20, 0x50e06a61,
+ 0x79920392, 0x28c19438, 0x79a1b545, 0x50c067de, 0x79b15435, 0x29010048, 0x79c0e062, 0x50a0338c,
+ 0x79d059c8, 0x2940530d, 0x79dfc064, 0x507fcd7d, 0x79ef1436, 0x297f8c60, 0x79fe5539, 0x505f35c7,
+ 0x7a0d836d, 0x29beac1a, 0x7a1c9ece, 0x503e6c7d, 0x7a2ba75a, 0x29fdb213, 0x7a3a9d0f, 0x501d71b3,
+ 0x7a497feb, 0x2a3c9e26, 0x7a584feb, 0x4ffc457e, 0x7a670d0d, 0x2a7b702b, 0x7a75b74f, 0x4fdae7f2,
+ 0x7a844eae, 0x2aba27fc, 0x7a92d329, 0x4fb95925, 0x7aa144bc, 0x2af8c571, 0x7aafa367, 0x4f979929,
+ 0x7abdef25, 0x2b374865, 0x7acc27f7, 0x4f75a815, 0x7ada4dd8, 0x2b75b0b0, 0x7ae860c7, 0x4f5385fd,
+ 0x7af660c2, 0x2bb3fe2c, 0x7b044dc7, 0x4f3132f7, 0x7b1227d3, 0x2bf230b3, 0x7b1feee5, 0x4f0eaf17,
+ 0x7b2da2fa, 0x2c30481e, 0x7b3b4410, 0x4eebfa72, 0x7b48d225, 0x2c6e4447, 0x7b564d36, 0x4ec9151f,
+ 0x7b63b543, 0x2cac2509, 0x7b710a49, 0x4ea5ff33, 0x7b7e4c45, 0x2ce9ea3b, 0x7b8b7b36, 0x4e82b8c3,
+ 0x7b989719, 0x2d2793b9, 0x7ba59fee, 0x4e5f41e5, 0x7bb295b0, 0x2d65215d, 0x7bbf7860, 0x4e3b9aaf,
+ 0x7bcc47fa, 0x2da29300, 0x7bd9047c, 0x4e17c337, 0x7be5ade6, 0x2ddfe87d, 0x7bf24434, 0x4df3bb93,
+ 0x7bfec765, 0x2e1d21ae, 0x7c0b3777, 0x4dcf83d9, 0x7c179467, 0x2e5a3e6c, 0x7c23de35, 0x4dab1c20,
+ 0x7c3014de, 0x2e973e93, 0x7c3c3860, 0x4d86847e, 0x7c4848ba, 0x2ed421fd, 0x7c5445e9, 0x4d61bd0a,
+ 0x7c602fec, 0x2f10e883, 0x7c6c06c0, 0x4d3cc5da, 0x7c77ca65, 0x2f4d9202, 0x7c837ad8, 0x4d179f06,
+ 0x7c8f1817, 0x2f8a1e52, 0x7c9aa221, 0x4cf248a3, 0x7ca618f3, 0x2fc68d4f, 0x7cb17c8d, 0x4cccc2ca,
+ 0x7cbcccec, 0x3002ded4, 0x7cc80a0f, 0x4ca70d91, 0x7cd333f3, 0x303f12bc, 0x7cde4a98, 0x4c81290f,
+ 0x7ce94dfb, 0x307b28e0, 0x7cf43e1a, 0x4c5b155c, 0x7cff1af5, 0x30b7211d, 0x7d09e489, 0x4c34d290,
+ 0x7d149ad5, 0x30f2fb4d, 0x7d1f3dd6, 0x4c0e60c2, 0x7d29cd8c, 0x312eb74b, 0x7d3449f5, 0x4be7c009,
+ 0x7d3eb30f, 0x316a54f3, 0x7d4908d9, 0x4bc0f07e, 0x7d534b50, 0x31a5d41f, 0x7d5d7a74, 0x4b99f238,
+ 0x7d679642, 0x31e134ac, 0x7d719eba, 0x4b72c550, 0x7d7b93da, 0x321c7673, 0x7d85759f, 0x4b4b69de,
+ 0x7d8f4409, 0x32579951, 0x7d98ff17, 0x4b23dff9, 0x7da2a6c6, 0x32929d22, 0x7dac3b15, 0x4afc27bb,
+ 0x7db5bc02, 0x32cd81c1, 0x7dbf298d, 0x4ad4413c, 0x7dc883b4, 0x33084709, 0x7dd1ca75, 0x4aac2c94,
+ 0x7ddafdce, 0x3342ecd6, 0x7de41dc0, 0x4a83e9dc, 0x7ded2a47, 0x337d7304, 0x7df62362, 0x4a5b792e,
+ 0x7dff0911, 0x33b7d970, 0x7e07db52, 0x4a32daa1, 0x7e109a24, 0x33f21ff4, 0x7e194584, 0x4a0a0e4f,
+ 0x7e21dd73, 0x342c466e, 0x7e2a61ed, 0x49e11452, 0x7e32d2f4, 0x34664cb9, 0x7e3b3083, 0x49b7ecc2,
+ 0x7e437a9c, 0x34a032b1, 0x7e4bb13c, 0x498e97b9, 0x7e53d462, 0x34d9f833, 0x7e5be40c, 0x49651550,
+ 0x7e63e03b, 0x35139d1b, 0x7e6bc8eb, 0x493b65a2, 0x7e739e1d, 0x354d2145, 0x7e7b5fce, 0x491188c6,
+ 0x7e830dff, 0x3586848e, 0x7e8aa8ac, 0x48e77ed9, 0x7e922fd6, 0x35bfc6d3, 0x7e99a37c, 0x48bd47f3,
+ 0x7ea1039b, 0x35f8e7f0, 0x7ea85033, 0x4892e42e, 0x7eaf8943, 0x3631e7c3, 0x7eb6aeca, 0x486853a5,
+ 0x7ebdc0c6, 0x366ac627, 0x7ec4bf36, 0x483d9672, 0x7ecbaa1a, 0x36a382fa, 0x7ed28171, 0x4812acaf,
+ 0x7ed94538, 0x36dc1e19, 0x7edff570, 0x47e79676, 0x7ee69217, 0x37149760, 0x7eed1b2c, 0x47bc53e3,
+ 0x7ef390ae, 0x374ceeae, 0x7ef9f29d, 0x4790e510, 0x7f0040f6, 0x378523df, 0x7f067bba, 0x47654a18,
+ 0x7f0ca2e7, 0x37bd36d1, 0x7f12b67c, 0x47398316, 0x7f18b679, 0x37f52760, 0x7f1ea2dc, 0x470d9024,
+ 0x7f247ba5, 0x382cf56c, 0x7f2a40d2, 0x46e1715d, 0x7f2ff263, 0x3864a0d0, 0x7f359057, 0x46b526de,
+ 0x7f3b1aad, 0x389c296b, 0x7f409164, 0x4688b0c1, 0x7f45f47b, 0x38d38f1b, 0x7f4b43f2, 0x465c0f22,
+ 0x7f507fc7, 0x390ad1bd, 0x7f55a7fa, 0x462f421c, 0x7f5abc8a, 0x3941f12f, 0x7f5fbd77, 0x460249cb,
+ 0x7f64aabf, 0x3978ed4f, 0x7f698461, 0x45d5264b, 0x7f6e4a5e, 0x39afc5fc, 0x7f72fcb4, 0x45a7d7b7,
+ 0x7f779b62, 0x39e67b13, 0x7f7c2668, 0x457a5e2c, 0x7f809dc5, 0x3a1d0c73, 0x7f850179, 0x454cb9c5,
+ 0x7f895182, 0x3a5379fa, 0x7f8d8de1, 0x451eea9f, 0x7f91b694, 0x3a89c387, 0x7f95cb9a, 0x44f0f0d5,
+ 0x7f99ccf4, 0x3abfe8f8, 0x7f9dbaa0, 0x44c2cc85, 0x7fa1949e, 0x3af5ea2b, 0x7fa55aee, 0x44947dcb,
+ 0x7fa90d8e, 0x3b2bc700, 0x7facac7f, 0x446604c2, 0x7fb037bf, 0x3b617f55, 0x7fb3af4e, 0x44376189,
+ 0x7fb7132b, 0x3b971308, 0x7fba6357, 0x4408943c, 0x7fbd9fd0, 0x3bcc81fa, 0x7fc0c896, 0x43d99cf7,
+ 0x7fc3dda9, 0x3c01cc08, 0x7fc6df08, 0x43aa7bd8, 0x7fc9ccb2, 0x3c36f113, 0x7fcca6a7, 0x437b30fb,
+ 0x7fcf6ce8, 0x3c6bf0f9, 0x7fd21f72, 0x434bbc7e, 0x7fd4be46, 0x3ca0cb9a, 0x7fd74964, 0x431c1e7e,
+ 0x7fd9c0ca, 0x3cd580d4, 0x7fdc247a, 0x42ec5719, 0x7fde7471, 0x3d0a1088, 0x7fe0b0b1, 0x42bc666b,
+ 0x7fe2d938, 0x3d3e7a95, 0x7fe4ee06, 0x428c4c93, 0x7fe6ef1c, 0x3d72bedb, 0x7fe8dc78, 0x425c09ae,
+ 0x7feab61a, 0x3da6dd39, 0x7fec7c02, 0x422b9ddb, 0x7fee2e30, 0x3ddad590, 0x7fefcca4, 0x41fb0935,
+ 0x7ff1575d, 0x3e0ea7bf, 0x7ff2ce5b, 0x41ca4bdd, 0x7ff4319d, 0x3e4253a6, 0x7ff58125, 0x419965f0,
+ 0x7ff6bcf0, 0x3e75d926, 0x7ff7e500, 0x4168578b, 0x7ff8f954, 0x3ea9381e, 0x7ff9f9ec, 0x413720ce,
+ 0x7ffae6c7, 0x3edc7070, 0x7ffbbfe6, 0x4105c1d6, 0x7ffc8549, 0x3f0f81fb, 0x7ffd36ee, 0x40d43ac3,
+ 0x7ffdd4d7, 0x3f426c9f, 0x7ffe5f03, 0x40a28bb2, 0x7ffed572, 0x3f75303e, 0x7fff3824, 0x4070b4c2,
+ 0x7fff8719, 0x3fa7ccb9, 0x7fffc251, 0x403eb613, 0x7fffe9cb, 0x3fda41ef, 0x7ffffd88, 0x400c8fc2,
+};
+
+/* PostMultiply() tables
+ * format = Q31
+ * reordered for sequential access
+ * decimate (skip by 4 or 8) for smaller transforms (512, 256)
+ *
+ * for (i = 0; i <= (512/2); i++) {
+ * angle = i * M_PI / 1024;
+ * x = 0.5*(cos(angle) + sin(angle));
+ * x = 0.5*sin(angle);
+ * }
+ */
+const int cos1sin1tab[514] = {
+ 0x40000000, 0x00000000, 0x40323034, 0x003243f1, 0x406438cf, 0x006487c4, 0x409619b2, 0x0096cb58,
+ 0x40c7d2bd, 0x00c90e90, 0x40f963d3, 0x00fb514b, 0x412accd4, 0x012d936c, 0x415c0da3, 0x015fd4d2,
+ 0x418d2621, 0x0192155f, 0x41be162f, 0x01c454f5, 0x41eeddaf, 0x01f69373, 0x421f7c84, 0x0228d0bb,
+ 0x424ff28f, 0x025b0caf, 0x42803fb2, 0x028d472e, 0x42b063d0, 0x02bf801a, 0x42e05ecb, 0x02f1b755,
+ 0x43103085, 0x0323ecbe, 0x433fd8e1, 0x03562038, 0x436f57c1, 0x038851a2, 0x439ead09, 0x03ba80df,
+ 0x43cdd89a, 0x03ecadcf, 0x43fcda59, 0x041ed854, 0x442bb227, 0x0451004d, 0x445a5fe8, 0x0483259d,
+ 0x4488e37f, 0x04b54825, 0x44b73ccf, 0x04e767c5, 0x44e56bbd, 0x0519845e, 0x4513702a, 0x054b9dd3,
+ 0x454149fc, 0x057db403, 0x456ef916, 0x05afc6d0, 0x459c7d5a, 0x05e1d61b, 0x45c9d6af, 0x0613e1c5,
+ 0x45f704f7, 0x0645e9af, 0x46240816, 0x0677edbb, 0x4650dff1, 0x06a9edc9, 0x467d8c6d, 0x06dbe9bb,
+ 0x46aa0d6d, 0x070de172, 0x46d662d6, 0x073fd4cf, 0x47028c8d, 0x0771c3b3, 0x472e8a76, 0x07a3adff,
+ 0x475a5c77, 0x07d59396, 0x47860275, 0x08077457, 0x47b17c54, 0x08395024, 0x47dcc9f9, 0x086b26de,
+ 0x4807eb4b, 0x089cf867, 0x4832e02d, 0x08cec4a0, 0x485da887, 0x09008b6a, 0x4888443d, 0x09324ca7,
+ 0x48b2b335, 0x09640837, 0x48dcf556, 0x0995bdfd, 0x49070a84, 0x09c76dd8, 0x4930f2a6, 0x09f917ac,
+ 0x495aada2, 0x0a2abb59, 0x49843b5f, 0x0a5c58c0, 0x49ad9bc2, 0x0a8defc3, 0x49d6ceb3, 0x0abf8043,
+ 0x49ffd417, 0x0af10a22, 0x4a28abd6, 0x0b228d42, 0x4a5155d6, 0x0b540982, 0x4a79d1ff, 0x0b857ec7,
+ 0x4aa22036, 0x0bb6ecef, 0x4aca4065, 0x0be853de, 0x4af23270, 0x0c19b374, 0x4b19f641, 0x0c4b0b94,
+ 0x4b418bbe, 0x0c7c5c1e, 0x4b68f2cf, 0x0cada4f5, 0x4b902b5c, 0x0cdee5f9, 0x4bb7354d, 0x0d101f0e,
+ 0x4bde1089, 0x0d415013, 0x4c04bcf8, 0x0d7278eb, 0x4c2b3a84, 0x0da39978, 0x4c518913, 0x0dd4b19a,
+ 0x4c77a88e, 0x0e05c135, 0x4c9d98de, 0x0e36c82a, 0x4cc359ec, 0x0e67c65a, 0x4ce8eb9f, 0x0e98bba7,
+ 0x4d0e4de2, 0x0ec9a7f3, 0x4d33809c, 0x0efa8b20, 0x4d5883b7, 0x0f2b650f, 0x4d7d571c, 0x0f5c35a3,
+ 0x4da1fab5, 0x0f8cfcbe, 0x4dc66e6a, 0x0fbdba40, 0x4deab226, 0x0fee6e0d, 0x4e0ec5d1, 0x101f1807,
+ 0x4e32a956, 0x104fb80e, 0x4e565c9f, 0x10804e06, 0x4e79df95, 0x10b0d9d0, 0x4e9d3222, 0x10e15b4e,
+ 0x4ec05432, 0x1111d263, 0x4ee345ad, 0x11423ef0, 0x4f06067f, 0x1172a0d7, 0x4f289692, 0x11a2f7fc,
+ 0x4f4af5d1, 0x11d3443f, 0x4f6d2427, 0x12038584, 0x4f8f217e, 0x1233bbac, 0x4fb0edc1, 0x1263e699,
+ 0x4fd288dc, 0x1294062f, 0x4ff3f2bb, 0x12c41a4f, 0x50152b47, 0x12f422db, 0x5036326e, 0x13241fb6,
+ 0x50570819, 0x135410c3, 0x5077ac37, 0x1383f5e3, 0x50981eb1, 0x13b3cefa, 0x50b85f74, 0x13e39be9,
+ 0x50d86e6d, 0x14135c94, 0x50f84b87, 0x144310dd, 0x5117f6ae, 0x1472b8a5, 0x51376fd0, 0x14a253d1,
+ 0x5156b6d9, 0x14d1e242, 0x5175cbb5, 0x150163dc, 0x5194ae52, 0x1530d881, 0x51b35e9b, 0x15604013,
+ 0x51d1dc80, 0x158f9a76, 0x51f027eb, 0x15bee78c, 0x520e40cc, 0x15ee2738, 0x522c270f, 0x161d595d,
+ 0x5249daa2, 0x164c7ddd, 0x52675b72, 0x167b949d, 0x5284a96e, 0x16aa9d7e, 0x52a1c482, 0x16d99864,
+ 0x52beac9f, 0x17088531, 0x52db61b0, 0x173763c9, 0x52f7e3a6, 0x1766340f, 0x5314326d, 0x1794f5e6,
+ 0x53304df6, 0x17c3a931, 0x534c362d, 0x17f24dd3, 0x5367eb03, 0x1820e3b0, 0x53836c66, 0x184f6aab,
+ 0x539eba45, 0x187de2a7, 0x53b9d48f, 0x18ac4b87, 0x53d4bb34, 0x18daa52f, 0x53ef6e23, 0x1908ef82,
+ 0x5409ed4b, 0x19372a64, 0x5424389d, 0x196555b8, 0x543e5007, 0x19937161, 0x5458337a, 0x19c17d44,
+ 0x5471e2e6, 0x19ef7944, 0x548b5e3b, 0x1a1d6544, 0x54a4a56a, 0x1a4b4128, 0x54bdb862, 0x1a790cd4,
+ 0x54d69714, 0x1aa6c82b, 0x54ef4171, 0x1ad47312, 0x5507b76a, 0x1b020d6c, 0x551ff8ef, 0x1b2f971e,
+ 0x553805f2, 0x1b5d100a, 0x554fde64, 0x1b8a7815, 0x55678236, 0x1bb7cf23, 0x557ef15a, 0x1be51518,
+ 0x55962bc0, 0x1c1249d8, 0x55ad315b, 0x1c3f6d47, 0x55c4021d, 0x1c6c7f4a, 0x55da9df7, 0x1c997fc4,
+ 0x55f104dc, 0x1cc66e99, 0x560736bd, 0x1cf34baf, 0x561d338d, 0x1d2016e9, 0x5632fb3f, 0x1d4cd02c,
+ 0x56488dc5, 0x1d79775c, 0x565deb11, 0x1da60c5d, 0x56731317, 0x1dd28f15, 0x568805c9, 0x1dfeff67,
+ 0x569cc31b, 0x1e2b5d38, 0x56b14b00, 0x1e57a86d, 0x56c59d6a, 0x1e83e0eb, 0x56d9ba4e, 0x1eb00696,
+ 0x56eda1a0, 0x1edc1953, 0x57015352, 0x1f081907, 0x5714cf59, 0x1f340596, 0x572815a8, 0x1f5fdee6,
+ 0x573b2635, 0x1f8ba4dc, 0x574e00f2, 0x1fb7575c, 0x5760a5d5, 0x1fe2f64c, 0x577314d2, 0x200e8190,
+ 0x57854ddd, 0x2039f90f, 0x579750ec, 0x20655cac, 0x57a91df2, 0x2090ac4d, 0x57bab4e6, 0x20bbe7d8,
+ 0x57cc15bc, 0x20e70f32, 0x57dd406a, 0x21122240, 0x57ee34e5, 0x213d20e8, 0x57fef323, 0x21680b0f,
+ 0x580f7b19, 0x2192e09b, 0x581fccbc, 0x21bda171, 0x582fe804, 0x21e84d76, 0x583fcce6, 0x2212e492,
+ 0x584f7b58, 0x223d66a8, 0x585ef351, 0x2267d3a0, 0x586e34c7, 0x22922b5e, 0x587d3fb0, 0x22bc6dca,
+ 0x588c1404, 0x22e69ac8, 0x589ab1b9, 0x2310b23e, 0x58a918c6, 0x233ab414, 0x58b74923, 0x2364a02e,
+ 0x58c542c5, 0x238e7673, 0x58d305a6, 0x23b836ca, 0x58e091bd, 0x23e1e117, 0x58ede700, 0x240b7543,
+ 0x58fb0568, 0x2434f332, 0x5907eced, 0x245e5acc, 0x59149d87, 0x2487abf7, 0x5921172e, 0x24b0e699,
+ 0x592d59da, 0x24da0a9a, 0x59396584, 0x250317df, 0x59453a24, 0x252c0e4f, 0x5950d7b3, 0x2554edd1,
+ 0x595c3e2a, 0x257db64c, 0x59676d82, 0x25a667a7, 0x597265b4, 0x25cf01c8, 0x597d26b8, 0x25f78497,
+ 0x5987b08a, 0x261feffa, 0x59920321, 0x264843d9, 0x599c1e78, 0x2670801a, 0x59a60288, 0x2698a4a6,
+ 0x59afaf4c, 0x26c0b162, 0x59b924bc, 0x26e8a637, 0x59c262d5, 0x2710830c, 0x59cb698f, 0x273847c8,
+ 0x59d438e5, 0x275ff452, 0x59dcd0d3, 0x27878893, 0x59e53151, 0x27af0472, 0x59ed5a5c, 0x27d667d5,
+ 0x59f54bee, 0x27fdb2a7, 0x59fd0603, 0x2824e4cc, 0x5a048895, 0x284bfe2f, 0x5a0bd3a1, 0x2872feb6,
+ 0x5a12e720, 0x2899e64a, 0x5a19c310, 0x28c0b4d2, 0x5a20676c, 0x28e76a37, 0x5a26d42f, 0x290e0661,
+ 0x5a2d0957, 0x29348937, 0x5a3306de, 0x295af2a3, 0x5a38ccc2, 0x2981428c, 0x5a3e5afe, 0x29a778db,
+ 0x5a43b190, 0x29cd9578, 0x5a48d074, 0x29f3984c, 0x5a4db7a6, 0x2a19813f, 0x5a526725, 0x2a3f503a,
+ 0x5a56deec, 0x2a650525, 0x5a5b1efa, 0x2a8a9fea, 0x5a5f274b, 0x2ab02071, 0x5a62f7dd, 0x2ad586a3,
+ 0x5a6690ae, 0x2afad269, 0x5a69f1bb, 0x2b2003ac, 0x5a6d1b03, 0x2b451a55, 0x5a700c84, 0x2b6a164d,
+ 0x5a72c63b, 0x2b8ef77d, 0x5a754827, 0x2bb3bdce, 0x5a779246, 0x2bd8692b, 0x5a79a498, 0x2bfcf97c,
+ 0x5a7b7f1a, 0x2c216eaa, 0x5a7d21cc, 0x2c45c8a0, 0x5a7e8cac, 0x2c6a0746, 0x5a7fbfbb, 0x2c8e2a87,
+ 0x5a80baf6, 0x2cb2324c, 0x5a817e5d, 0x2cd61e7f, 0x5a8209f1, 0x2cf9ef09, 0x5a825db0, 0x2d1da3d5,
+ 0x5a82799a, 0x2d413ccd,
+};
+
+const int windowOffset[3] = {0, 256, 768};
+
+/* Synthesis window
+ * format = Q31
+ * reordered for sequential access
+ *
+ * for (i = 0; i < nmlt / 2; i++) {
+ * angle = (i + 0.5) * M_PI / (2.0 * nmlt);
+ * x = sin(angle);
+ *
+ * angle = (nmlt - 1 - i + 0.5) * M_PI / (2.0 * nmlt);
+ * x = sin(angle);
+ * }
+ */
+const int window[256 + 512 + 1024] = {
+ /* 256 point window */
+ 0x006487e3, 0x7fffd886, 0x012d96b1, 0x7ffe9cb2, 0x01f6a297, 0x7ffc250f, 0x02bfa9a4, 0x7ff871a2,
+ 0x0388a9ea, 0x7ff38274, 0x0451a177, 0x7fed5791, 0x051a8e5c, 0x7fe5f108, 0x05e36ea9, 0x7fdd4eec,
+ 0x06ac406f, 0x7fd37153, 0x077501be, 0x7fc85854, 0x083db0a7, 0x7fbc040a, 0x09064b3a, 0x7fae7495,
+ 0x09cecf89, 0x7f9faa15, 0x0a973ba5, 0x7f8fa4b0, 0x0b5f8d9f, 0x7f7e648c, 0x0c27c389, 0x7f6be9d4,
+ 0x0cefdb76, 0x7f5834b7, 0x0db7d376, 0x7f434563, 0x0e7fa99e, 0x7f2d1c0e, 0x0f475bff, 0x7f15b8ee,
+ 0x100ee8ad, 0x7efd1c3c, 0x10d64dbd, 0x7ee34636, 0x119d8941, 0x7ec8371a, 0x1264994e, 0x7eabef2c,
+ 0x132b7bf9, 0x7e8e6eb2, 0x13f22f58, 0x7e6fb5f4, 0x14b8b17f, 0x7e4fc53e, 0x157f0086, 0x7e2e9cdf,
+ 0x16451a83, 0x7e0c3d29, 0x170afd8d, 0x7de8a670, 0x17d0a7bc, 0x7dc3d90d, 0x18961728, 0x7d9dd55a,
+ 0x195b49ea, 0x7d769bb5, 0x1a203e1b, 0x7d4e2c7f, 0x1ae4f1d6, 0x7d24881b, 0x1ba96335, 0x7cf9aef0,
+ 0x1c6d9053, 0x7ccda169, 0x1d31774d, 0x7ca05ff1, 0x1df5163f, 0x7c71eaf9, 0x1eb86b46, 0x7c4242f2,
+ 0x1f7b7481, 0x7c116853, 0x203e300d, 0x7bdf5b94, 0x21009c0c, 0x7bac1d31, 0x21c2b69c, 0x7b77ada8,
+ 0x22847de0, 0x7b420d7a, 0x2345eff8, 0x7b0b3d2c, 0x24070b08, 0x7ad33d45, 0x24c7cd33, 0x7a9a0e50,
+ 0x2588349d, 0x7a5fb0d8, 0x26483f6c, 0x7a24256f, 0x2707ebc7, 0x79e76ca7, 0x27c737d3, 0x79a98715,
+ 0x288621b9, 0x796a7554, 0x2944a7a2, 0x792a37fe, 0x2a02c7b8, 0x78e8cfb2, 0x2ac08026, 0x78a63d11,
+ 0x2b7dcf17, 0x786280bf, 0x2c3ab2b9, 0x781d9b65, 0x2cf72939, 0x77d78daa, 0x2db330c7, 0x7790583e,
+ 0x2e6ec792, 0x7747fbce, 0x2f29ebcc, 0x76fe790e, 0x2fe49ba7, 0x76b3d0b4, 0x309ed556, 0x76680376,
+ 0x3158970e, 0x761b1211, 0x3211df04, 0x75ccfd42, 0x32caab6f, 0x757dc5ca, 0x3382fa88, 0x752d6c6c,
+ 0x343aca87, 0x74dbf1ef, 0x34f219a8, 0x7489571c, 0x35a8e625, 0x74359cbd, 0x365f2e3b, 0x73e0c3a3,
+ 0x3714f02a, 0x738acc9e, 0x37ca2a30, 0x7333b883, 0x387eda8e, 0x72db8828, 0x3932ff87, 0x72823c67,
+ 0x39e6975e, 0x7227d61c, 0x3a99a057, 0x71cc5626, 0x3b4c18ba, 0x716fbd68, 0x3bfdfecd, 0x71120cc5,
+ 0x3caf50da, 0x70b34525, 0x3d600d2c, 0x70536771, 0x3e10320d, 0x6ff27497, 0x3ebfbdcd, 0x6f906d84,
+ 0x3f6eaeb8, 0x6f2d532c, 0x401d0321, 0x6ec92683, 0x40cab958, 0x6e63e87f, 0x4177cfb1, 0x6dfd9a1c,
+ 0x42244481, 0x6d963c54, 0x42d0161e, 0x6d2dd027, 0x437b42e1, 0x6cc45698, 0x4425c923, 0x6c59d0a9,
+ 0x44cfa740, 0x6bee3f62, 0x4578db93, 0x6b81a3cd, 0x4621647d, 0x6b13fef5, 0x46c9405c, 0x6aa551e9,
+ 0x47706d93, 0x6a359db9, 0x4816ea86, 0x69c4e37a, 0x48bcb599, 0x69532442, 0x4961cd33, 0x68e06129,
+ 0x4a062fbd, 0x686c9b4b, 0x4aa9dba2, 0x67f7d3c5, 0x4b4ccf4d, 0x67820bb7, 0x4bef092d, 0x670b4444,
+ 0x4c9087b1, 0x66937e91, 0x4d31494b, 0x661abbc5, 0x4dd14c6e, 0x65a0fd0b, 0x4e708f8f, 0x6526438f,
+ 0x4f0f1126, 0x64aa907f, 0x4faccfab, 0x642de50d, 0x5049c999, 0x63b0426d, 0x50e5fd6d, 0x6331a9d4,
+ 0x518169a5, 0x62b21c7b, 0x521c0cc2, 0x62319b9d, 0x52b5e546, 0x61b02876, 0x534ef1b5, 0x612dc447,
+ 0x53e73097, 0x60aa7050, 0x547ea073, 0x60262dd6, 0x55153fd4, 0x5fa0fe1f, 0x55ab0d46, 0x5f1ae274,
+ 0x56400758, 0x5e93dc1f, 0x56d42c99, 0x5e0bec6e, 0x57677b9d, 0x5d8314b1, 0x57f9f2f8, 0x5cf95638,
+ 0x588b9140, 0x5c6eb258, 0x591c550e, 0x5be32a67, 0x59ac3cfd, 0x5b56bfbd, 0x5a3b47ab, 0x5ac973b5,
+
+ /* 512 point window */
+ 0x003243f5, 0x7ffff621, 0x0096cbc1, 0x7fffa72c, 0x00fb5330, 0x7fff0943, 0x015fda03, 0x7ffe1c65,
+ 0x01c45ffe, 0x7ffce093, 0x0228e4e2, 0x7ffb55ce, 0x028d6870, 0x7ff97c18, 0x02f1ea6c, 0x7ff75370,
+ 0x03566a96, 0x7ff4dbd9, 0x03bae8b2, 0x7ff21553, 0x041f6480, 0x7feeffe1, 0x0483ddc3, 0x7feb9b85,
+ 0x04e8543e, 0x7fe7e841, 0x054cc7b1, 0x7fe3e616, 0x05b137df, 0x7fdf9508, 0x0615a48b, 0x7fdaf519,
+ 0x067a0d76, 0x7fd6064c, 0x06de7262, 0x7fd0c8a3, 0x0742d311, 0x7fcb3c23, 0x07a72f45, 0x7fc560cf,
+ 0x080b86c2, 0x7fbf36aa, 0x086fd947, 0x7fb8bdb8, 0x08d42699, 0x7fb1f5fc, 0x09386e78, 0x7faadf7c,
+ 0x099cb0a7, 0x7fa37a3c, 0x0a00ece8, 0x7f9bc640, 0x0a6522fe, 0x7f93c38c, 0x0ac952aa, 0x7f8b7227,
+ 0x0b2d7baf, 0x7f82d214, 0x0b919dcf, 0x7f79e35a, 0x0bf5b8cb, 0x7f70a5fe, 0x0c59cc68, 0x7f671a05,
+ 0x0cbdd865, 0x7f5d3f75, 0x0d21dc87, 0x7f531655, 0x0d85d88f, 0x7f489eaa, 0x0de9cc40, 0x7f3dd87c,
+ 0x0e4db75b, 0x7f32c3d1, 0x0eb199a4, 0x7f2760af, 0x0f1572dc, 0x7f1baf1e, 0x0f7942c7, 0x7f0faf25,
+ 0x0fdd0926, 0x7f0360cb, 0x1040c5bb, 0x7ef6c418, 0x10a4784b, 0x7ee9d914, 0x11082096, 0x7edc9fc6,
+ 0x116bbe60, 0x7ecf1837, 0x11cf516a, 0x7ec14270, 0x1232d979, 0x7eb31e78, 0x1296564d, 0x7ea4ac58,
+ 0x12f9c7aa, 0x7e95ec1a, 0x135d2d53, 0x7e86ddc6, 0x13c0870a, 0x7e778166, 0x1423d492, 0x7e67d703,
+ 0x148715ae, 0x7e57dea7, 0x14ea4a1f, 0x7e47985b, 0x154d71aa, 0x7e37042a, 0x15b08c12, 0x7e26221f,
+ 0x16139918, 0x7e14f242, 0x1676987f, 0x7e0374a0, 0x16d98a0c, 0x7df1a942, 0x173c6d80, 0x7ddf9034,
+ 0x179f429f, 0x7dcd2981, 0x1802092c, 0x7dba7534, 0x1864c0ea, 0x7da77359, 0x18c7699b, 0x7d9423fc,
+ 0x192a0304, 0x7d808728, 0x198c8ce7, 0x7d6c9ce9, 0x19ef0707, 0x7d58654d, 0x1a517128, 0x7d43e05e,
+ 0x1ab3cb0d, 0x7d2f0e2b, 0x1b161479, 0x7d19eebf, 0x1b784d30, 0x7d048228, 0x1bda74f6, 0x7ceec873,
+ 0x1c3c8b8c, 0x7cd8c1ae, 0x1c9e90b8, 0x7cc26de5, 0x1d00843d, 0x7cabcd28, 0x1d6265dd, 0x7c94df83,
+ 0x1dc4355e, 0x7c7da505, 0x1e25f282, 0x7c661dbc, 0x1e879d0d, 0x7c4e49b7, 0x1ee934c3, 0x7c362904,
+ 0x1f4ab968, 0x7c1dbbb3, 0x1fac2abf, 0x7c0501d2, 0x200d888d, 0x7bebfb70, 0x206ed295, 0x7bd2a89e,
+ 0x20d0089c, 0x7bb9096b, 0x21312a65, 0x7b9f1de6, 0x219237b5, 0x7b84e61f, 0x21f3304f, 0x7b6a6227,
+ 0x225413f8, 0x7b4f920e, 0x22b4e274, 0x7b3475e5, 0x23159b88, 0x7b190dbc, 0x23763ef7, 0x7afd59a4,
+ 0x23d6cc87, 0x7ae159ae, 0x243743fa, 0x7ac50dec, 0x2497a517, 0x7aa8766f, 0x24f7efa2, 0x7a8b9348,
+ 0x2558235f, 0x7a6e648a, 0x25b84012, 0x7a50ea47, 0x26184581, 0x7a332490, 0x26783370, 0x7a151378,
+ 0x26d809a5, 0x79f6b711, 0x2737c7e3, 0x79d80f6f, 0x27976df1, 0x79b91ca4, 0x27f6fb92, 0x7999dec4,
+ 0x2856708d, 0x797a55e0, 0x28b5cca5, 0x795a820e, 0x29150fa1, 0x793a6361, 0x29743946, 0x7919f9ec,
+ 0x29d34958, 0x78f945c3, 0x2a323f9e, 0x78d846fb, 0x2a911bdc, 0x78b6fda8, 0x2aefddd8, 0x789569df,
+ 0x2b4e8558, 0x78738bb3, 0x2bad1221, 0x7851633b, 0x2c0b83fa, 0x782ef08b, 0x2c69daa6, 0x780c33b8,
+ 0x2cc815ee, 0x77e92cd9, 0x2d263596, 0x77c5dc01, 0x2d843964, 0x77a24148, 0x2de2211e, 0x777e5cc3,
+ 0x2e3fec8b, 0x775a2e89, 0x2e9d9b70, 0x7735b6af, 0x2efb2d95, 0x7710f54c, 0x2f58a2be, 0x76ebea77,
+ 0x2fb5fab2, 0x76c69647, 0x30133539, 0x76a0f8d2, 0x30705217, 0x767b1231, 0x30cd5115, 0x7654e279,
+ 0x312a31f8, 0x762e69c4, 0x3186f487, 0x7607a828, 0x31e39889, 0x75e09dbd, 0x32401dc6, 0x75b94a9c,
+ 0x329c8402, 0x7591aedd, 0x32f8cb07, 0x7569ca99, 0x3354f29b, 0x75419de7, 0x33b0fa84, 0x751928e0,
+ 0x340ce28b, 0x74f06b9e, 0x3468aa76, 0x74c7663a, 0x34c4520d, 0x749e18cd, 0x351fd918, 0x74748371,
+ 0x357b3f5d, 0x744aa63f, 0x35d684a6, 0x74208150, 0x3631a8b8, 0x73f614c0, 0x368cab5c, 0x73cb60a8,
+ 0x36e78c5b, 0x73a06522, 0x37424b7b, 0x73752249, 0x379ce885, 0x73499838, 0x37f76341, 0x731dc70a,
+ 0x3851bb77, 0x72f1aed9, 0x38abf0ef, 0x72c54fc1, 0x39060373, 0x7298a9dd, 0x395ff2c9, 0x726bbd48,
+ 0x39b9bebc, 0x723e8a20, 0x3a136712, 0x7211107e, 0x3a6ceb96, 0x71e35080, 0x3ac64c0f, 0x71b54a41,
+ 0x3b1f8848, 0x7186fdde, 0x3b78a007, 0x71586b74, 0x3bd19318, 0x7129931f, 0x3c2a6142, 0x70fa74fc,
+ 0x3c830a50, 0x70cb1128, 0x3cdb8e09, 0x709b67c0, 0x3d33ec39, 0x706b78e3, 0x3d8c24a8, 0x703b44ad,
+ 0x3de4371f, 0x700acb3c, 0x3e3c2369, 0x6fda0cae, 0x3e93e950, 0x6fa90921, 0x3eeb889c, 0x6f77c0b3,
+ 0x3f430119, 0x6f463383, 0x3f9a5290, 0x6f1461b0, 0x3ff17cca, 0x6ee24b57, 0x40487f94, 0x6eaff099,
+ 0x409f5ab6, 0x6e7d5193, 0x40f60dfb, 0x6e4a6e66, 0x414c992f, 0x6e174730, 0x41a2fc1a, 0x6de3dc11,
+ 0x41f93689, 0x6db02d29, 0x424f4845, 0x6d7c3a98, 0x42a5311b, 0x6d48047e, 0x42faf0d4, 0x6d138afb,
+ 0x4350873c, 0x6cdece2f, 0x43a5f41e, 0x6ca9ce3b, 0x43fb3746, 0x6c748b3f, 0x4450507e, 0x6c3f055d,
+ 0x44a53f93, 0x6c093cb6, 0x44fa0450, 0x6bd3316a, 0x454e9e80, 0x6b9ce39b, 0x45a30df0, 0x6b66536b,
+ 0x45f7526b, 0x6b2f80fb, 0x464b6bbe, 0x6af86c6c, 0x469f59b4, 0x6ac115e2, 0x46f31c1a, 0x6a897d7d,
+ 0x4746b2bc, 0x6a51a361, 0x479a1d67, 0x6a1987b0, 0x47ed5be6, 0x69e12a8c, 0x48406e08, 0x69a88c19,
+ 0x48935397, 0x696fac78, 0x48e60c62, 0x69368bce, 0x49389836, 0x68fd2a3d, 0x498af6df, 0x68c387e9,
+ 0x49dd282a, 0x6889a4f6, 0x4a2f2be6, 0x684f8186, 0x4a8101de, 0x68151dbe, 0x4ad2a9e2, 0x67da79c3,
+ 0x4b2423be, 0x679f95b7, 0x4b756f40, 0x676471c0, 0x4bc68c36, 0x67290e02, 0x4c177a6e, 0x66ed6aa1,
+ 0x4c6839b7, 0x66b187c3, 0x4cb8c9dd, 0x6675658c, 0x4d092ab0, 0x66390422, 0x4d595bfe, 0x65fc63a9,
+ 0x4da95d96, 0x65bf8447, 0x4df92f46, 0x65826622, 0x4e48d0dd, 0x6545095f, 0x4e984229, 0x65076e25,
+ 0x4ee782fb, 0x64c99498, 0x4f369320, 0x648b7ce0, 0x4f857269, 0x644d2722, 0x4fd420a4, 0x640e9386,
+ 0x50229da1, 0x63cfc231, 0x5070e92f, 0x6390b34a, 0x50bf031f, 0x635166f9, 0x510ceb40, 0x6311dd64,
+ 0x515aa162, 0x62d216b3, 0x51a82555, 0x6292130c, 0x51f576ea, 0x6251d298, 0x524295f0, 0x6211557e,
+ 0x528f8238, 0x61d09be5, 0x52dc3b92, 0x618fa5f7, 0x5328c1d0, 0x614e73da, 0x537514c2, 0x610d05b7,
+ 0x53c13439, 0x60cb5bb7, 0x540d2005, 0x60897601, 0x5458d7f9, 0x604754bf, 0x54a45be6, 0x6004f819,
+ 0x54efab9c, 0x5fc26038, 0x553ac6ee, 0x5f7f8d46, 0x5585adad, 0x5f3c7f6b, 0x55d05faa, 0x5ef936d1,
+ 0x561adcb9, 0x5eb5b3a2, 0x566524aa, 0x5e71f606, 0x56af3750, 0x5e2dfe29, 0x56f9147e, 0x5de9cc33,
+ 0x5742bc06, 0x5da5604f, 0x578c2dba, 0x5d60baa7, 0x57d5696d, 0x5d1bdb65, 0x581e6ef1, 0x5cd6c2b5,
+ 0x58673e1b, 0x5c9170bf, 0x58afd6bd, 0x5c4be5b0, 0x58f838a9, 0x5c0621b2, 0x594063b5, 0x5bc024f0,
+ 0x598857b2, 0x5b79ef96, 0x59d01475, 0x5b3381ce, 0x5a1799d1, 0x5aecdbc5, 0x5a5ee79a, 0x5aa5fda5,
+
+ /* 1024 point window */
+ 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,
+};
+
+/* bit reverse tables for FFT */
+
+const int bitrevtabOffset[3] = {0, 33, 98};
+
+const unsigned char bitrevtab[33 + 65 + 129] = {
+ /* bitrevtab0[33] */
+ 0x1, 0x10, 0x2, 0x8, 0x3, 0x18, 0x5, 0x14, 0x6, 0xc, 0x7, 0x1c, 0x9, 0x12, 0xb, 0x1a,
+ 0xd, 0x16, 0xf, 0x1e, 0x13, 0x19, 0x17, 0x1d, 0x0, 0x4, 0xa, 0xe, 0x11, 0x15, 0x1b, 0x1f, 0x0,
+
+ /* bitrevtab1[65] */
+ 0x1, 0x20, 0x2, 0x10, 0x3, 0x30, 0x4, 0x8, 0x5, 0x28, 0x6, 0x18, 0x7, 0x38, 0x9, 0x24,
+ 0xa, 0x14, 0xb, 0x34, 0xd, 0x2c, 0xe, 0x1c, 0xf, 0x3c, 0x11, 0x22, 0x13, 0x32, 0x15, 0x2a,
+ 0x16, 0x1a, 0x17, 0x3a, 0x19, 0x26, 0x1b, 0x36, 0x1d, 0x2e, 0x1f, 0x3e, 0x23, 0x31, 0x25, 0x29,
+ 0x27, 0x39, 0x2b, 0x35, 0x2f, 0x3d, 0x37, 0x3b, 0x0, 0xc, 0x12, 0x1e, 0x21, 0x2d, 0x33, 0x3f, 0x0,
+
+ /* bitrevtab2[129] */
+ 0x1, 0x40, 0x2, 0x20, 0x3, 0x60, 0x4, 0x10, 0x5, 0x50, 0x6, 0x30, 0x7, 0x70, 0x9, 0x48,
+ 0xa, 0x28, 0xb, 0x68, 0xc, 0x18, 0xd, 0x58, 0xe, 0x38, 0xf, 0x78, 0x11, 0x44, 0x12, 0x24,
+ 0x13, 0x64, 0x15, 0x54, 0x16, 0x34, 0x17, 0x74, 0x19, 0x4c, 0x1a, 0x2c, 0x1b, 0x6c, 0x1d, 0x5c,
+ 0x1e, 0x3c, 0x1f, 0x7c, 0x21, 0x42, 0x23, 0x62, 0x25, 0x52, 0x26, 0x32, 0x27, 0x72, 0x29, 0x4a,
+ 0x2b, 0x6a, 0x2d, 0x5a, 0x2e, 0x3a, 0x2f, 0x7a, 0x31, 0x46, 0x33, 0x66, 0x35, 0x56, 0x37, 0x76,
+ 0x39, 0x4e, 0x3b, 0x6e, 0x3d, 0x5e, 0x3f, 0x7e, 0x43, 0x61, 0x45, 0x51, 0x47, 0x71, 0x4b, 0x69,
+ 0x4d, 0x59, 0x4f, 0x79, 0x53, 0x65, 0x57, 0x75, 0x5b, 0x6d, 0x5f, 0x7d, 0x67, 0x73, 0x6f, 0x7b,
+ 0x0, 0x8, 0x14, 0x1c, 0x22, 0x2a, 0x36, 0x3e, 0x41, 0x49, 0x55, 0x5d, 0x63, 0x6b, 0x77, 0x7f, 0x0,
+};
+
+const unsigned char uniqueIDTab[8] = {0x5f, 0x4b, 0x43, 0x5f, 0x5f, 0x4a, 0x52, 0x5f};
+
+/* Twiddle tables for FFT
+ * format = Q31
+ *
+ * for (k = 4; k <= N/4; k <<= 1) {
+ * for (j = 0; j < k; j++) {
+ * double wr1, wi1, wr2, wi2, wr3, wi3;
+ *
+ * wr1 = cos(1.0 * M_PI * j / (2*k));
+ * wi1 = sin(1.0 * M_PI * j / (2*k));
+ * wr1 = 0.5 * (wr1 + wi1);
+ * wi1 = 0.5 * -wi1;
+ *
+ * wr2 = cos(2.0 * M_PI * j / (2*k));
+ * wi2 = sin(2.0 * M_PI * j / (2*k));
+ * wr2 = 0.5 * (wr2 + wi2);
+ * wi2 = 0.5 * -wi2;
+ *
+ * wr3 = cos(3.0 * M_PI * j / (2*k));
+ * wi3 = sin(3.0 * M_PI * j / (2*k));
+ * wr3 = 0.5 * (wr3 + wi3);
+ * wi3 = 0.5 * -wi3;
+ *
+ * if (k & 0xaaaaaaaa) {
+ * w_odd[iodd++] = (float)wr2;
+ * w_odd[iodd++] = (float)wi2;
+ * w_odd[iodd++] = (float)wr1;
+ * w_odd[iodd++] = (float)wi1;
+ * w_odd[iodd++] = (float)wr3;
+ * w_odd[iodd++] = (float)wi3;
+ * } else {
+ * w_even[ieven++] = (float)wr2;
+ * w_even[ieven++] = (float)wi2;
+ * w_even[ieven++] = (float)wr1;
+ * w_even[ieven++] = (float)wi1;
+ * w_even[ieven++] = (float)wr3;
+ * w_even[ieven++] = (float)wi3;
+ * }
+ * }
+ * }
+ */
+const int twidTabOdd[8 * 6 + 32 * 6 + 128 * 6] = {
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x539eba45, 0xe7821d59,
+ 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59,
+ 0x539eba45, 0xc4df2862, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x22a2f4f8, 0xc4df2862,
+ 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862,
+ 0xac6145bb, 0x187de2a7, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52,
+
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x45f704f7, 0xf9ba1651,
+ 0x43103085, 0xfcdc1342, 0x48b2b335, 0xf69bf7c9, 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651,
+ 0x4fd288dc, 0xed6bf9d1, 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9, 0x553805f2, 0xe4a2eff6,
+ 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x569cc31b, 0xe1d4a2c8,
+ 0x4da1fab5, 0xf0730342, 0x5a6690ae, 0xd5052d97, 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1,
+ 0x5a12e720, 0xce86ff2a, 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a, 0x57cc15bc, 0xc91af976,
+ 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a12e720, 0xce86ff2a,
+ 0x553805f2, 0xe4a2eff6, 0x4da1fab5, 0xc1eb0209, 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8,
+ 0x45f704f7, 0xc04ee4b8, 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce, 0x3cc85709, 0xc013bc39,
+ 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x4fd288dc, 0xc2c17d52,
+ 0x5987b08a, 0xd9e01006, 0x26b2a794, 0xc3bdbdf6, 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6,
+ 0x1a4608ab, 0xc78e9a1d, 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97, 0x0d47d096, 0xcc983f70,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x396b3199, 0xc04ee4b8,
+ 0x5a6690ae, 0xd09441bb, 0xf2b82f6a, 0xd9e01006, 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a,
+ 0xe5b9f755, 0xe1d4a2c8, 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70, 0xd94d586c, 0xea70658a,
+ 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x1a4608ab, 0xc78e9a1d,
+ 0x57cc15bc, 0xc91af976, 0xc337a8f7, 0xfcdc1342, 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d,
+ 0xba08fb09, 0x0645e9af, 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18, 0xb25e054b, 0x0f8cfcbe,
+ 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xf720e574, 0xd76619b6,
+ 0x51d1dc80, 0xc3bdbdf6, 0xa833ea44, 0x20e70f32, 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52,
+ 0xa5ed18e0, 0x2899e64a, 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209, 0xa5996f52, 0x2f6bbe45,
+ 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xd5558381, 0xed6bf9d1,
+ 0x48b2b335, 0xc0b15502, 0xaac7fa0e, 0x39daf5e8, 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8,
+ 0xb02d7724, 0x3d3e82ae, 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39, 0xb74d4ccb, 0x3f4eaafe,
+
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x418d2621, 0xfe6deaa1,
+ 0x40c7d2bd, 0xff36f170, 0x424ff28f, 0xfda4f351, 0x43103085, 0xfcdc1342, 0x418d2621, 0xfe6deaa1,
+ 0x4488e37f, 0xfb4ab7db, 0x4488e37f, 0xfb4ab7db, 0x424ff28f, 0xfda4f351, 0x46aa0d6d, 0xf8f21e8e,
+ 0x45f704f7, 0xf9ba1651, 0x43103085, 0xfcdc1342, 0x48b2b335, 0xf69bf7c9, 0x475a5c77, 0xf82a6c6a,
+ 0x43cdd89a, 0xfc135231, 0x4aa22036, 0xf4491311, 0x48b2b335, 0xf69bf7c9, 0x4488e37f, 0xfb4ab7db,
+ 0x4c77a88e, 0xf1fa3ecb, 0x49ffd417, 0xf50ef5de, 0x454149fc, 0xfa824bfd, 0x4e32a956, 0xefb047f2,
+ 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x4c77a88e, 0xf1fa3ecb,
+ 0x46aa0d6d, 0xf8f21e8e, 0x5156b6d9, 0xeb2e1dbe, 0x4da1fab5, 0xf0730342, 0x475a5c77, 0xf82a6c6a,
+ 0x52beac9f, 0xe8f77acf, 0x4ec05432, 0xeeee2d9d, 0x4807eb4b, 0xf7630799, 0x5409ed4b, 0xe6c8d59c,
+ 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9, 0x553805f2, 0xe4a2eff6, 0x50d86e6d, 0xebeca36c,
+ 0x495aada2, 0xf5d544a7, 0x56488dc5, 0xe28688a4, 0x51d1dc80, 0xea70658a, 0x49ffd417, 0xf50ef5de,
+ 0x573b2635, 0xe0745b24, 0x52beac9f, 0xe8f77acf, 0x4aa22036, 0xf4491311, 0x580f7b19, 0xde6d1f65,
+ 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5471e2e6, 0xe61086bc,
+ 0x4bde1089, 0xf2beafed, 0x595c3e2a, 0xda8249b4, 0x553805f2, 0xe4a2eff6, 0x4c77a88e, 0xf1fa3ecb,
+ 0x59d438e5, 0xd8a00bae, 0x55f104dc, 0xe3399167, 0x4d0e4de2, 0xf136580d, 0x5a2d0957, 0xd6cb76c9,
+ 0x569cc31b, 0xe1d4a2c8, 0x4da1fab5, 0xf0730342, 0x5a6690ae, 0xd5052d97, 0x573b2635, 0xe0745b24,
+ 0x4e32a956, 0xefb047f2, 0x5a80baf6, 0xd34dcdb4, 0x57cc15bc, 0xdf18f0ce, 0x4ec05432, 0xeeee2d9d,
+ 0x5a7b7f1a, 0xd1a5ef90, 0x584f7b58, 0xddc29958, 0x4f4af5d1, 0xee2cbbc1, 0x5a56deec, 0xd00e2639,
+ 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a, 0x592d59da, 0xdb25f566,
+ 0x50570819, 0xecabef3d, 0x59afaf4c, 0xcd110216, 0x5987b08a, 0xd9e01006, 0x50d86e6d, 0xebeca36c,
+ 0x592d59da, 0xcbacb0bf, 0x59d438e5, 0xd8a00bae, 0x5156b6d9, 0xeb2e1dbe, 0x588c1404, 0xca5a86c4,
+ 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a, 0x57cc15bc, 0xc91af976, 0x5a43b190, 0xd6326a88,
+ 0x5249daa2, 0xe9b38223, 0x56eda1a0, 0xc7ee77b3, 0x5a6690ae, 0xd5052d97, 0x52beac9f, 0xe8f77acf,
+ 0x55f104dc, 0xc6d569be, 0x5a7b7f1a, 0xd3de9156, 0x53304df6, 0xe83c56cf, 0x54d69714, 0xc5d03118,
+ 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a7b7f1a, 0xd1a5ef90,
+ 0x5409ed4b, 0xe6c8d59c, 0x5249daa2, 0xc402a33c, 0x5a6690ae, 0xd09441bb, 0x5471e2e6, 0xe61086bc,
+ 0x50d86e6d, 0xc33aee27, 0x5a43b190, 0xcf89e3e8, 0x54d69714, 0xe55937d5, 0x4f4af5d1, 0xc2884e6e,
+ 0x5a12e720, 0xce86ff2a, 0x553805f2, 0xe4a2eff6, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xcd8bbb6d,
+ 0x55962bc0, 0xe3edb628, 0x4bde1089, 0xc1633f8a, 0x5987b08a, 0xcc983f70, 0x55f104dc, 0xe3399167,
+ 0x49ffd417, 0xc0f1360b, 0x592d59da, 0xcbacb0bf, 0x56488dc5, 0xe28688a4, 0x4807eb4b, 0xc0950d1d,
+ 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x584f7b58, 0xc9edeb50,
+ 0x56eda1a0, 0xe123e6ad, 0x43cdd89a, 0xc01ed535, 0x57cc15bc, 0xc91af976, 0x573b2635, 0xe0745b24,
+ 0x418d2621, 0xc004ef3f, 0x573b2635, 0xc8507ea7, 0x57854ddd, 0xdfc606f1, 0x3f35b59d, 0xc0013bd3,
+ 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce, 0x3cc85709, 0xc013bc39, 0x55f104dc, 0xc6d569be,
+ 0x580f7b19, 0xde6d1f65, 0x3a45e1f7, 0xc03c6a07, 0x553805f2, 0xc6250a18, 0x584f7b58, 0xddc29958,
+ 0x37af354c, 0xc07b371e, 0x5471e2e6, 0xc57d965d, 0x588c1404, 0xdd196538, 0x350536f1, 0xc0d00db6,
+ 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x52beac9f, 0xc449d892,
+ 0x58fb0568, 0xdbcb0cce, 0x2f7afdfc, 0xc1bb5a11, 0x51d1dc80, 0xc3bdbdf6, 0x592d59da, 0xdb25f566,
+ 0x2c9caf6c, 0xc2517e31, 0x50d86e6d, 0xc33aee27, 0x595c3e2a, 0xda8249b4, 0x29aee694, 0xc2fd08a9,
+ 0x4fd288dc, 0xc2c17d52, 0x5987b08a, 0xd9e01006, 0x26b2a794, 0xc3bdbdf6, 0x4ec05432, 0xc2517e31,
+ 0x59afaf4c, 0xd93f4e9e, 0x23a8fb93, 0xc4935b3c, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xd8a00bae,
+ 0x2092f05f, 0xc57d965d, 0x4c77a88e, 0xc18e18a7, 0x59f54bee, 0xd8024d59, 0x1d719810, 0xc67c1e18,
+ 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d, 0x49ffd417, 0xc0f1360b,
+ 0x5a2d0957, 0xd6cb76c9, 0x17115bc0, 0xc8b4ab32, 0x48b2b335, 0xc0b15502, 0x5a43b190, 0xd6326a88,
+ 0x13d4ae08, 0xc9edeb50, 0x475a5c77, 0xc07b371e, 0x5a56deec, 0xd59afadb, 0x10911f04, 0xcb39edca,
+ 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97, 0x0d47d096, 0xcc983f70, 0x4488e37f, 0xc02c64a6,
+ 0x5a72c63b, 0xd4710883, 0x09f9e6a1, 0xce0866b8, 0x43103085, 0xc013bc39, 0x5a7b7f1a, 0xd3de9156,
+ 0x06a886a0, 0xcf89e3e8, 0x418d2621, 0xc004ef3f, 0x5a80baf6, 0xd34dcdb4, 0x0354d741, 0xd11c3142,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3e68fb62, 0xc004ef3f,
+ 0x5a80baf6, 0xd2317756, 0xfcab28bf, 0xd4710883, 0x3cc85709, 0xc013bc39, 0x5a7b7f1a, 0xd1a5ef90,
+ 0xf9577960, 0xd6326a88, 0x3b1e5335, 0xc02c64a6, 0x5a72c63b, 0xd11c3142, 0xf606195f, 0xd8024d59,
+ 0x396b3199, 0xc04ee4b8, 0x5a6690ae, 0xd09441bb, 0xf2b82f6a, 0xd9e01006, 0x37af354c, 0xc07b371e,
+ 0x5a56deec, 0xd00e2639, 0xef6ee0fc, 0xdbcb0cce, 0x35eaa2c7, 0xc0b15502, 0x5a43b190, 0xcf89e3e8,
+ 0xec2b51f8, 0xddc29958, 0x341dbfd3, 0xc0f1360b, 0x5a2d0957, 0xcf077fe1, 0xe8eea440, 0xdfc606f1,
+ 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x306c2624, 0xc18e18a7,
+ 0x59f54bee, 0xce0866b8, 0xe28e67f0, 0xe3edb628, 0x2e88013a, 0xc1eb0209, 0x59d438e5, 0xcd8bbb6d,
+ 0xdf6d0fa1, 0xe61086bc, 0x2c9caf6c, 0xc2517e31, 0x59afaf4c, 0xcd110216, 0xdc57046d, 0xe83c56cf,
+ 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70, 0xd94d586c, 0xea70658a, 0x28b1b544, 0xc33aee27,
+ 0x595c3e2a, 0xcc217822, 0xd651196c, 0xecabef3d, 0x26b2a794, 0xc3bdbdf6, 0x592d59da, 0xcbacb0bf,
+ 0xd3635094, 0xeeee2d9d, 0x24ada23d, 0xc449d892, 0x58fb0568, 0xcb39edca, 0xd0850204, 0xf136580d,
+ 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x2092f05f, 0xc57d965d,
+ 0x588c1404, 0xca5a86c4, 0xcafac90f, 0xf5d544a7, 0x1e7de5df, 0xc6250a18, 0x584f7b58, 0xc9edeb50,
+ 0xc850cab4, 0xf82a6c6a, 0x1c6427a9, 0xc6d569be, 0x580f7b19, 0xc9836582, 0xc5ba1e09, 0xfa824bfd,
+ 0x1a4608ab, 0xc78e9a1d, 0x57cc15bc, 0xc91af976, 0xc337a8f7, 0xfcdc1342, 0x1823dc7d, 0xc8507ea7,
+ 0x57854ddd, 0xc8b4ab32, 0xc0ca4a63, 0xff36f170, 0x15fdf758, 0xc91af976, 0x573b2635, 0xc8507ea7,
+ 0xbe72d9df, 0x0192155f, 0x13d4ae08, 0xc9edeb50, 0x56eda1a0, 0xc7ee77b3, 0xbc322766, 0x03ecadcf,
+ 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af, 0x0f7944a7, 0xcbacb0bf,
+ 0x56488dc5, 0xc730e997, 0xb7f814b5, 0x089cf867, 0x0d47d096, 0xcc983f70, 0x55f104dc, 0xc6d569be,
+ 0xb6002be9, 0x0af10a22, 0x0b145041, 0xcd8bbb6d, 0x55962bc0, 0xc67c1e18, 0xb421ef77, 0x0d415013,
+ 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18, 0xb25e054b, 0x0f8cfcbe, 0x06a886a0, 0xcf89e3e8,
+ 0x54d69714, 0xc5d03118, 0xb0b50a2f, 0x11d3443f, 0x0470ebdc, 0xd09441bb, 0x5471e2e6, 0xc57d965d,
+ 0xaf279193, 0x14135c94, 0x0238a1c6, 0xd1a5ef90, 0x5409ed4b, 0xc52d3d18, 0xadb6255e, 0x164c7ddd,
+ 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xfdc75e3a, 0xd3de9156,
+ 0x53304df6, 0xc4935b3c, 0xab2968ec, 0x1aa6c82b, 0xfb8f1424, 0xd5052d97, 0x52beac9f, 0xc449d892,
+ 0xaa0efb24, 0x1cc66e99, 0xf9577960, 0xd6326a88, 0x5249daa2, 0xc402a33c, 0xa9125e60, 0x1edc1953,
+ 0xf720e574, 0xd76619b6, 0x51d1dc80, 0xc3bdbdf6, 0xa833ea44, 0x20e70f32, 0xf4ebafbf, 0xd8a00bae,
+ 0x5156b6d9, 0xc37b2b6a, 0xa773ebfc, 0x22e69ac8, 0xf2b82f6a, 0xd9e01006, 0x50d86e6d, 0xc33aee27,
+ 0xa6d2a626, 0x24da0a9a, 0xf086bb59, 0xdb25f566, 0x50570819, 0xc2fd08a9, 0xa65050b4, 0x26c0b162,
+ 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xec2b51f8, 0xddc29958,
+ 0x4f4af5d1, 0xc2884e6e, 0xa5a92114, 0x2a650525, 0xea0208a8, 0xdf18f0ce, 0x4ec05432, 0xc2517e31,
+ 0xa58480e6, 0x2c216eaa, 0xe7dc2383, 0xe0745b24, 0x4e32a956, 0xc21d0eb8, 0xa57f450a, 0x2dce88aa,
+ 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209, 0xa5996f52, 0x2f6bbe45, 0xe39bd857, 0xe3399167,
+ 0x4d0e4de2, 0xc1bb5a11, 0xa5d2f6a9, 0x30f8801f, 0xe1821a21, 0xe4a2eff6, 0x4c77a88e, 0xc18e18a7,
+ 0xa62bc71b, 0x32744493, 0xdf6d0fa1, 0xe61086bc, 0x4bde1089, 0xc1633f8a, 0xa6a3c1d6, 0x33de87de,
+ 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xdb525dc3, 0xe8f77acf,
+ 0x4aa22036, 0xc114ccb9, 0xa7f084e7, 0x367c9a7e, 0xd94d586c, 0xea70658a, 0x49ffd417, 0xc0f1360b,
+ 0xa8c4d9cb, 0x37af8159, 0xd74e4abc, 0xebeca36c, 0x495aada2, 0xc0d00db6, 0xa9b7723b, 0x38cf1669,
+ 0xd5558381, 0xed6bf9d1, 0x48b2b335, 0xc0b15502, 0xaac7fa0e, 0x39daf5e8, 0xd3635094, 0xeeee2d9d,
+ 0x4807eb4b, 0xc0950d1d, 0xabf612b5, 0x3ad2c2e8, 0xd177fec6, 0xf0730342, 0x475a5c77, 0xc07b371e,
+ 0xad415361, 0x3bb6276e, 0xcf93d9dc, 0xf1fa3ecb, 0x46aa0d6d, 0xc063d405, 0xaea94927, 0x3c84d496,
+ 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae, 0xcbe2402d, 0xf50ef5de,
+ 0x454149fc, 0xc03c6a07, 0xb1cd56aa, 0x3de2f148, 0xca155d39, 0xf69bf7c9, 0x4488e37f, 0xc02c64a6,
+ 0xb3885772, 0x3e71e759, 0xc850cab4, 0xf82a6c6a, 0x43cdd89a, 0xc01ed535, 0xb55ddfca, 0x3eeb3347,
+ 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39, 0xb74d4ccb, 0x3f4eaafe, 0xc4e1accb, 0xfb4ab7db,
+ 0x424ff28f, 0xc00b1a20, 0xb955f293, 0x3f9c2bfb, 0xc337a8f7, 0xfcdc1342, 0x418d2621, 0xc004ef3f,
+ 0xbb771c81, 0x3fd39b5a, 0xc197049e, 0xfe6deaa1, 0x40c7d2bd, 0xc0013bd3, 0xbdb00d71, 0x3ff4e5e0,
+};
+
+const int twidTabEven[4 * 6 + 16 * 6 + 64 * 6] = {
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x5a82799a, 0xd2bec333,
+ 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333,
+ 0x00000000, 0xd2bec333, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7,
+
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x4b418bbe, 0xf383a3e2,
+ 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2,
+ 0x58c542c5, 0xdc71898d, 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a,
+ 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xcac933ae,
+ 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d,
+ 0x3248d382, 0xc13ad060, 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3248d382, 0xc13ad060,
+ 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae,
+ 0xcdb72c7e, 0xf383a3e2, 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af,
+ 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xee57aa21, 0xdc71898d,
+ 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060,
+ 0xa73abd3b, 0x3536cc52, 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae,
+
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x43103085, 0xfcdc1342,
+ 0x418d2621, 0xfe6deaa1, 0x4488e37f, 0xfb4ab7db, 0x45f704f7, 0xf9ba1651, 0x43103085, 0xfcdc1342,
+ 0x48b2b335, 0xf69bf7c9, 0x48b2b335, 0xf69bf7c9, 0x4488e37f, 0xfb4ab7db, 0x4c77a88e, 0xf1fa3ecb,
+ 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x4da1fab5, 0xf0730342,
+ 0x475a5c77, 0xf82a6c6a, 0x52beac9f, 0xe8f77acf, 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9,
+ 0x553805f2, 0xe4a2eff6, 0x51d1dc80, 0xea70658a, 0x49ffd417, 0xf50ef5de, 0x573b2635, 0xe0745b24,
+ 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x553805f2, 0xe4a2eff6,
+ 0x4c77a88e, 0xf1fa3ecb, 0x59d438e5, 0xd8a00bae, 0x569cc31b, 0xe1d4a2c8, 0x4da1fab5, 0xf0730342,
+ 0x5a6690ae, 0xd5052d97, 0x57cc15bc, 0xdf18f0ce, 0x4ec05432, 0xeeee2d9d, 0x5a7b7f1a, 0xd1a5ef90,
+ 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a, 0x5987b08a, 0xd9e01006,
+ 0x50d86e6d, 0xebeca36c, 0x592d59da, 0xcbacb0bf, 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a,
+ 0x57cc15bc, 0xc91af976, 0x5a6690ae, 0xd5052d97, 0x52beac9f, 0xe8f77acf, 0x55f104dc, 0xc6d569be,
+ 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a6690ae, 0xd09441bb,
+ 0x5471e2e6, 0xe61086bc, 0x50d86e6d, 0xc33aee27, 0x5a12e720, 0xce86ff2a, 0x553805f2, 0xe4a2eff6,
+ 0x4da1fab5, 0xc1eb0209, 0x5987b08a, 0xcc983f70, 0x55f104dc, 0xe3399167, 0x49ffd417, 0xc0f1360b,
+ 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x57cc15bc, 0xc91af976,
+ 0x573b2635, 0xe0745b24, 0x418d2621, 0xc004ef3f, 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce,
+ 0x3cc85709, 0xc013bc39, 0x553805f2, 0xc6250a18, 0x584f7b58, 0xddc29958, 0x37af354c, 0xc07b371e,
+ 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x51d1dc80, 0xc3bdbdf6,
+ 0x592d59da, 0xdb25f566, 0x2c9caf6c, 0xc2517e31, 0x4fd288dc, 0xc2c17d52, 0x5987b08a, 0xd9e01006,
+ 0x26b2a794, 0xc3bdbdf6, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xd8a00bae, 0x2092f05f, 0xc57d965d,
+ 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d, 0x48b2b335, 0xc0b15502,
+ 0x5a43b190, 0xd6326a88, 0x13d4ae08, 0xc9edeb50, 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97,
+ 0x0d47d096, 0xcc983f70, 0x43103085, 0xc013bc39, 0x5a7b7f1a, 0xd3de9156, 0x06a886a0, 0xcf89e3e8,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3cc85709, 0xc013bc39,
+ 0x5a7b7f1a, 0xd1a5ef90, 0xf9577960, 0xd6326a88, 0x396b3199, 0xc04ee4b8, 0x5a6690ae, 0xd09441bb,
+ 0xf2b82f6a, 0xd9e01006, 0x35eaa2c7, 0xc0b15502, 0x5a43b190, 0xcf89e3e8, 0xec2b51f8, 0xddc29958,
+ 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x2e88013a, 0xc1eb0209,
+ 0x59d438e5, 0xcd8bbb6d, 0xdf6d0fa1, 0xe61086bc, 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70,
+ 0xd94d586c, 0xea70658a, 0x26b2a794, 0xc3bdbdf6, 0x592d59da, 0xcbacb0bf, 0xd3635094, 0xeeee2d9d,
+ 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x1e7de5df, 0xc6250a18,
+ 0x584f7b58, 0xc9edeb50, 0xc850cab4, 0xf82a6c6a, 0x1a4608ab, 0xc78e9a1d, 0x57cc15bc, 0xc91af976,
+ 0xc337a8f7, 0xfcdc1342, 0x15fdf758, 0xc91af976, 0x573b2635, 0xc8507ea7, 0xbe72d9df, 0x0192155f,
+ 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af, 0x0d47d096, 0xcc983f70,
+ 0x55f104dc, 0xc6d569be, 0xb6002be9, 0x0af10a22, 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18,
+ 0xb25e054b, 0x0f8cfcbe, 0x0470ebdc, 0xd09441bb, 0x5471e2e6, 0xc57d965d, 0xaf279193, 0x14135c94,
+ 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xfb8f1424, 0xd5052d97,
+ 0x52beac9f, 0xc449d892, 0xaa0efb24, 0x1cc66e99, 0xf720e574, 0xd76619b6, 0x51d1dc80, 0xc3bdbdf6,
+ 0xa833ea44, 0x20e70f32, 0xf2b82f6a, 0xd9e01006, 0x50d86e6d, 0xc33aee27, 0xa6d2a626, 0x24da0a9a,
+ 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xea0208a8, 0xdf18f0ce,
+ 0x4ec05432, 0xc2517e31, 0xa58480e6, 0x2c216eaa, 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209,
+ 0xa5996f52, 0x2f6bbe45, 0xe1821a21, 0xe4a2eff6, 0x4c77a88e, 0xc18e18a7, 0xa62bc71b, 0x32744493,
+ 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xd94d586c, 0xea70658a,
+ 0x49ffd417, 0xc0f1360b, 0xa8c4d9cb, 0x37af8159, 0xd5558381, 0xed6bf9d1, 0x48b2b335, 0xc0b15502,
+ 0xaac7fa0e, 0x39daf5e8, 0xd177fec6, 0xf0730342, 0x475a5c77, 0xc07b371e, 0xad415361, 0x3bb6276e,
+ 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae, 0xca155d39, 0xf69bf7c9,
+ 0x4488e37f, 0xc02c64a6, 0xb3885772, 0x3e71e759, 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39,
+ 0xb74d4ccb, 0x3f4eaafe, 0xc337a8f7, 0xfcdc1342, 0x418d2621, 0xc004ef3f, 0xbb771c81, 0x3fd39b5a,
+};
+
+/* for reference, here's the code to generate the bitreverse tables
+
+static int bitrev(int n, int nbits)
+{
+ int r, i;
+
+ r = 0;
+ for (i = 0; i < nbits; i++) {
+ r <<= 1;
+ r |= (n & 1);
+ n >>= 1;
+ }
+
+ return r;
+}
+
+static void InitBitrevTable(unsigned char *out, int nbits)
+{
+ int i, t;
+
+ for (i = 0; i < (1<<nbits); i++) {
+ / *** do not register the same transposition twice *** /
+ t = bitrev(i,nbits);
+ if (i < t) {
+ *out++ = (unsigned char)i;
+ *out++ = (unsigned char)t;
+ }
+ }
+
+ / *** no need to write a sentinel (or rather, the first entry in the
+ * table for symetric codes will be 0, which serves as the sentinel)
+ *** /
+ for (i = 0; i < (1<<nbits); i++) {
+ t = bitrev(i,nbits);
+ if (i == t) / *** symmetric codes get special treatment *** /
+ *out++ = (unsigned char)t;
+ }
+ *out++ = 0; / *** second sentinel is 0, again *** /
+}
+
+*/
+
diff --git a/audio_codec/libcook/rasl.c b/audio_codec/libcook/rasl.c
new file mode 100644
index 0000000..63ca73e
--- a/dev/null
+++ b/audio_codec/libcook/rasl.c
@@ -0,0 +1,376 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rasl.c,v 1.1.1.1.2.1 2005/05/04 18:21:33 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <memory.h>
+#include "helix_types.h"
+#include "rasl.h"
+
+/*
+ * The interleave table was created with the following properties:
+ * -equal contributions from each block
+ * -symmetric (if table[i] = j, then table[j] = i), allows in-place interleave
+ * -random spacing between lost frames, except
+ * -no double losses
+ * Solution was generated by a random-walk optimization loop.
+ *
+ */
+/* Loss patterns for a five-block solution:
+...X..X....X.X.....X.X.X........X..........X...X.X....X........X..X..X..X.......
+.X..X....X........X...X..X.....X.X........X...X....X...X..X......X....X.......X.
+..X..X.X.........X..........X.X...X...X..X...X.......X.....X.X.....X......X.X...
+..........X.X..X....X......X.X......X...X...X...X.X.....X.....X.X......X.X......
+X.......X.....X.X.......X.X........X.X.X............X....X..X.......X......X.X.X
+*/
+/*
+static int RASL_InterleaveTable[RASL_NFRAMES * RASL_NBLOCKS] = {
+ 66, 21, 43, 3, 23, 47, 6, 32, 72, 19, 49, 11, 54, 13, 69, 63,
+ 65, 42, 18, 9, 58, 1, 22, 4, 78, 25, 70, 51, 33, 55, 46, 31,
+ 7, 28, 34, 74, 61, 76, 38, 67, 59, 41, 17, 2, 53, 45, 30, 5,
+ 48, 10, 50, 27, 71, 44, 12, 29, 56, 73, 20, 40, 64, 36, 62, 15,
+ 60, 16, 0, 39, 68, 14, 26, 52, 8, 57, 35, 75, 37, 77, 24, 79
+};
+*/
+
+/* Loss pattern for a six-block solution
+....X.X....X..........X........X....X..X....X........X....X....X....X....X.......X....X...X.....
+.X.....X..........X....X...X..X...X...........X...X...X..X...........X.X...X............X.....X.
+..X.......X..X......X...X............X...X.....X........X..X.....X....X...X..........X.X....X...
+X........X.....X.X........X..X..........X....X......X.......X.X.............X..X.........X...X.X
+............X.X.X....X......X...X..X.......X....X............X..X.X.....X.....X.X..X............
+...X.X..X..........X.....X.......X....X...X......X.X...X...........X.........X....X.X......X....
+*/
+static const int RASL_InterleaveTable[RASL_NFRAMES * RASL_NBLOCKS] = {
+ 63, 22, 44, 90, 4, 81, 6, 31, 86, 58, 36, 11, 68, 39, 73, 53,
+ 69, 57, 18, 88, 34, 71, 1, 23, 46, 94, 54, 27, 75, 50, 30, 7,
+ 70, 92, 20, 74, 10, 37, 85, 13, 56, 41, 87, 65, 2, 59, 24, 47,
+ 79, 93, 29, 89, 52, 15, 26, 95, 40, 17, 9, 45, 60, 76, 62, 0,
+ 64, 43, 66, 83, 12, 16, 32, 21, 72, 14, 35, 28, 61, 80, 78, 48,
+ 77, 5, 82, 67, 84, 38, 8, 42, 19, 51, 3, 91, 33, 49, 25, 55
+};
+
+/*
+ * DeInterleave operates in-place!.
+ *
+ * Entry:
+ * buf points to NCODEBYTES * NFRAMES * NBLOCKS bytes of interleaved data.
+ * If an input block is bad, flag[block] should be set.
+ *
+ * Exit:
+ * data in buf is deinterleaved.
+ * flags[block] stores a bit array for each output block,
+ * where (flags[block] & (1 << F)) is set if Fth frame is bad.
+ */
+void
+RASL_DeInterleave(char *buf, unsigned long ulBufSize, int type, ULONG32 * pFlags)
+{
+ char temp[RASL_MAXCODEBYTES]; /* space for swapping */ /* Flawfinder: ignore */
+ INT32 inFlags[RASL_NBLOCKS]; /* save input flags */
+ int nCodeBytes, nCodeBits;
+ int fi, fo; /* frame in/out */
+ int blk;
+ int bitOffsetTo, bitOffsetFrom; /* for bit maniputlations */
+ char *toPtr, *fromPtr; /* for bit maniputlations */
+ unsigned long ulToBufSize;
+ unsigned long ulFromBufSize;
+
+ nCodeBits = 0;
+ if (type == 0) {
+ nCodeBits = RA65_NCODEBITS;
+ }
+ if (type == 1) {
+ nCodeBits = RA85_NCODEBITS;
+ }
+ if (type == 2) {
+ nCodeBits = RA50_NCODEBITS;
+ }
+ if (type == 3) {
+ nCodeBits = RA160_NCODEBITS;
+ } else {
+ // wrong nCodeBits
+ while (1) {
+ ;
+ }
+ }
+
+
+ /* Save input flags, and initialize output flags */
+ if (pFlags)
+ for (blk = 0; blk < RASL_NBLOCKS; blk++) {
+ inFlags[blk] = pFlags[blk]; /* save input */
+ pFlags[blk] = 0; /* init output to no error */
+ }
+
+
+ if (nCodeBits % 8 == 0) {
+ nCodeBytes = nCodeBits >> 3;
+ for (fi = 0; fi < RASL_NFRAMES * RASL_NBLOCKS; fi++) {
+
+ fo = RASL_InterleaveTable[fi]; /* frame to swap with */
+ /*
+ * Note that when (fo == fi), the frame doesn't move,
+ * and if (fo < fi), we have swapped it already.
+ */
+ if (fo > fi) { /* do the swap if needed */
+ memcpy(temp, buf + fo * nCodeBytes, nCodeBytes); /* Flawfinder: ignore */
+ memcpy(buf + fo * nCodeBytes, buf + fi * nCodeBytes, nCodeBytes); /* Flawfinder: ignore */
+ memcpy(buf + fi * nCodeBytes, temp, nCodeBytes); /* Flawfinder: ignore */
+ }
+
+ /*
+ * If frame came from bad block, set bit corresponding to new position.
+ * Only check one of the swapped pair, since other will be done when
+ * fi gets there.
+ */
+ if (pFlags && inFlags[RASL_BLOCK_NUM(fi)]) {
+ pFlags[RASL_BLOCK_NUM(fo)] |= (1 << RASL_BLOCK_OFF(fo));
+ }
+ }
+ } else {
+ for (fi = 0; fi < RASL_NFRAMES * RASL_NBLOCKS; fi++) {
+
+ fo = RASL_InterleaveTable[fi]; /* frame to swap with */
+ /*
+ * Note that when (fo == fi), the frame doesn't move,
+ * and if (fo < fi), we have swapped it already.
+ */
+ if (fo > fi) { /* do the swap if needed */
+ toPtr = temp;
+ ulToBufSize = RASL_MAXCODEBYTES;
+ fromPtr = buf;
+ ulFromBufSize = ulBufSize;
+ bitOffsetTo = 0;
+ bitOffsetFrom = fo * nCodeBits;
+ ra_bitcopy((unsigned char *)toPtr, ulToBufSize, (unsigned char *)fromPtr, ulFromBufSize, bitOffsetTo, bitOffsetFrom, nCodeBits);
+
+ toPtr = buf;
+ ulToBufSize = ulBufSize;
+ fromPtr = buf;
+ ulFromBufSize = ulBufSize;
+ bitOffsetTo = fo * nCodeBits;
+ bitOffsetFrom = fi * nCodeBits;
+ ra_bitcopy((unsigned char *)toPtr, ulToBufSize, (unsigned char *)fromPtr, ulFromBufSize, bitOffsetTo, bitOffsetFrom, nCodeBits);
+
+ toPtr = buf;
+ ulToBufSize = ulBufSize;
+ fromPtr = temp;
+ ulFromBufSize = RASL_MAXCODEBYTES;
+ bitOffsetTo = fi * nCodeBits;
+ bitOffsetFrom = 0;
+ ra_bitcopy((unsigned char *)toPtr, ulToBufSize, (unsigned char *)fromPtr, ulFromBufSize, bitOffsetTo, bitOffsetFrom, nCodeBits);
+ }
+
+ /*
+ * If frame came from bad block, set bit corresponding to new position.
+ * Only check one of the swapped pair, since other will be done when
+ * fi gets there.
+ */
+ if (pFlags && inFlags[RASL_BLOCK_NUM(fi)]) {
+ pFlags[RASL_BLOCK_NUM(fo)] |= (1 << RASL_BLOCK_OFF(fo));
+ }
+ }
+ }
+}
+
+void ra_bitcopy(unsigned char* toPtr,
+ unsigned long ulToBufSize,
+ unsigned char* fromPtr,
+ unsigned long ulFromBufSize,
+ int bitOffsetTo,
+ int bitOffsetFrom,
+ int numBits)
+{
+ unsigned char* pToLimit = toPtr + ulToBufSize;
+ unsigned char* pFromLimit = fromPtr + ulFromBufSize;
+ int bofMod8, botMod8, nbMod8, eightMinusBotMod8, eightMinusBofMod8, i, iMax;
+ unsigned char rightInword, leftInword, *byteOffsetFrom, *byteOffsetTo,
+ alignWord, endWord;
+ unsigned char lmask[9] = {0, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff}; /* Flawfinder: ignore */
+ unsigned char rmask[9] = {0, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff}; /* Flawfinder: ignore */
+
+ int nibbleAlignFrom, nibbleAlignTo, alignCase = 30; // special case variables
+ unsigned char mask[2] = {0x0f, 0xf0}; /* Flawfinder: ignore */
+
+ bofMod8 = bitOffsetFrom & 0x07; // same as %8
+ botMod8 = bitOffsetTo & 0x07;
+ nbMod8 = numBits & 0x07;
+ eightMinusBofMod8 = 8 - bofMod8; // don't want these evaluated every loop
+ eightMinusBotMod8 = 8 - botMod8;
+ byteOffsetFrom = fromPtr + (bitOffsetFrom >> 3);
+ byteOffsetTo = toPtr + (bitOffsetTo >> 3);
+ iMax = (numBits >> 3) - 1; // last output byte not handled inside a loop
+
+ if (numBits >> 3 == 0)
+ // quick and easy if we have fewer than 8 bits to align
+
+ {
+ leftInword = *(byteOffsetFrom++);
+ rightInword = *(byteOffsetFrom);
+ alignWord = (leftInword >> bofMod8) + (rightInword << (eightMinusBofMod8));
+ alignWord &= rmask[nbMod8];
+
+ if (nbMod8 >= eightMinusBotMod8) // have more extra input bits than
+ // free space in current output byte
+ {
+ *(byteOffsetTo) &= rmask[botMod8];
+ *(byteOffsetTo++) += (alignWord << botMod8);
+ *(byteOffsetTo) = ((*byteOffsetTo) & lmask[8 - (nbMod8 - eightMinusBotMod8)])
+ + (alignWord >> eightMinusBotMod8);
+ }
+
+ else // have fewer input bits than free space in current output byte
+ // be careful not to overwrite extra bits already in output byte
+ {
+ endWord = *(byteOffsetTo) & lmask[8 - (nbMod8 + botMod8)];
+ *(byteOffsetTo) &= rmask[botMod8];
+ *(byteOffsetTo) += ((alignWord << botMod8) + endWord);
+ }
+ return; // finished, return to calling function
+ }
+
+ if (bitOffsetFrom % 4 == 0 && bitOffsetTo % 4 == 0)
+ // byte-packing done here is optimized for the common case of nibble-alignment
+
+ {
+ nibbleAlignFrom = (bitOffsetFrom & 0x04) >> 2; // 0 implies whole-byte alignment
+ nibbleAlignTo = (bitOffsetTo & 0x04) >> 2; // 1 implies half-byte alignment
+
+
+ if (nibbleAlignFrom == nibbleAlignTo) // either src and dest both byte-aligned
+ // or both half byte-aligned
+ if (nibbleAlignFrom == 0) {
+ alignCase = 0;
+ } else {
+ alignCase = 3;
+ }
+
+
+ if (nibbleAlignFrom != nibbleAlignTo)
+ if (nibbleAlignFrom == 0) {
+ alignCase = 1; // src aligned, dest half aligned
+ } else {
+ alignCase = 2; // src half aligned, dest aligned
+ }
+
+ switch (alignCase) {
+ case 0:
+ for (i = 0; i < iMax; i++) {
+ *byteOffsetTo++ = *byteOffsetFrom++; // copy byte-by-byte directly
+ }
+ break;
+
+ case 1:
+ for (i = 0; i < iMax; i++) { // move two nibbles from src to dest each loop
+ // shift bits as necessary
+ *byteOffsetTo = (*byteOffsetTo & mask[0]) +
+ ((*byteOffsetFrom & mask[0]) << 4);
+ *++byteOffsetTo = ((*byteOffsetFrom++ & mask[1]) >> 4);
+ }
+ break;
+
+ case 2:
+ for (i = 0; i < iMax; i++) { // same as case 1, but shift other direction
+ *byteOffsetTo = ((*byteOffsetFrom & mask[1]) >> 4);
+ *byteOffsetTo++ += ((*++byteOffsetFrom & mask[0]) << 4);
+ }
+ break;
+
+ case 3: {
+ *byteOffsetTo &= mask[0]; // align first nibble, thereafter this is
+ *byteOffsetTo += (*byteOffsetFrom & mask[1]); // just like case 0
+ for (i = 0; i < iMax; i++) {
+ *++byteOffsetTo = *++byteOffsetFrom; // copy byte-by-byte directly
+ }
+ }
+ break;
+ }
+ }
+
+ else
+ // this code can handle all source and destination buffer offsets
+
+ {
+ // take the first 8 desired bits from the input buffer, store them
+ // in alignWord, then break up alignWord into two pieces to
+ // fit in the free space in two consecutive output buffer bytes
+
+ for (i = 0; i < iMax; i++) {
+ leftInword = *(byteOffsetFrom++);
+ rightInword = *(byteOffsetFrom);
+ alignWord = (leftInword >> bofMod8) + (rightInword << (eightMinusBofMod8));
+ *(byteOffsetTo) = (*(byteOffsetTo) & rmask[botMod8]) +
+ (alignWord << (botMod8));
+ *(++byteOffsetTo) = alignWord >> (eightMinusBotMod8);
+ }
+ }
+ // special section to set last byte in fromBuf correctly
+
+ // even if byte packing was done with the code optimized for nibble-alignment,
+ // the tricky job of setting the last output byte is still done here
+
+ leftInword = *(byteOffsetFrom++);
+ rightInword = *(byteOffsetFrom);
+ alignWord = (leftInword >> bofMod8) + (rightInword << (eightMinusBofMod8));
+ *(byteOffsetTo) = (*(byteOffsetTo) & rmask[botMod8]) +
+ (alignWord << (botMod8));
+
+ if (nbMod8 >= eightMinusBotMod8) {
+ *(++byteOffsetTo) = alignWord >> (eightMinusBotMod8);
+
+ leftInword = *(byteOffsetFrom++);
+ rightInword = *(byteOffsetFrom);
+ alignWord = (leftInword >> bofMod8) + (rightInword << (eightMinusBofMod8));
+ alignWord &= rmask[nbMod8];
+ *(byteOffsetTo++) += (alignWord << botMod8);
+ if (byteOffsetTo >= toPtr && byteOffsetTo < pToLimit) {
+ *(byteOffsetTo) = ((*byteOffsetTo) & lmask[8 - (nbMod8 - eightMinusBotMod8)])
+ + (alignWord >> eightMinusBotMod8);
+ }
+ }
+
+ else {
+ endWord = *(++byteOffsetTo) & lmask[8 - (nbMod8 + botMod8)];
+ *(byteOffsetTo) = alignWord >> (eightMinusBotMod8);
+ leftInword = *(byteOffsetFrom++);
+ rightInword = *(byteOffsetFrom);
+ alignWord = (leftInword >> bofMod8) + (rightInword << (eightMinusBofMod8));
+ alignWord &= rmask[nbMod8];
+ *(byteOffsetTo) += ((alignWord << botMod8) + endWord);
+ }
+
+
+}
+
diff --git a/audio_codec/libcook/rasl.h b/audio_codec/libcook/rasl.h
new file mode 100644
index 0000000..9eff866
--- a/dev/null
+++ b/audio_codec/libcook/rasl.h
@@ -0,0 +1,71 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rasl.h,v 1.1.1.1.2.1 2005/05/04 18:21:33 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RASL_H
+#define RASL_H
+
+#include "helix_types.h"
+
+/* Must regenerate table if these are changed! */
+#define RA50_NCODEBYTES 18.5 /* bytes per 5.0kbps sl frame */
+#define RA65_NCODEBYTES 14.5 /* bytes per 6.5kbps sl frame */
+#define RA85_NCODEBYTES 19 /* bytes per 8.5kbps sl frame */
+#define RA160_NCODEBYTES 20 /* bytes per 16.0kbps sl frame */
+
+#define RA50_NCODEBITS 148 /* bits per 5.0kbps sl frame */
+#define RA65_NCODEBITS 116 /* bits per 6.5kbps sl frame */
+#define RA85_NCODEBITS 152 /* bits per 8.5kbps sl frame */
+#define RA160_NCODEBITS 160 /* bits per 16.0kbps sl frame */
+
+#define RASL_MAXCODEBYTES 20 /* max bytes per sl frame */
+#define RASL_NFRAMES 16 /* frames per block - must match codec */
+#define RASL_NBLOCKS 6 /* blocks to interleave across */
+#define RASL_BLOCK_NUM(i) ((i) >> 4) /* assumes RASL_NFRAMES = 16 */
+#define RASL_BLOCK_OFF(i) ((i) & 0xf) /* assumes RASL_NFRAMES = 16 */
+
+
+void RASL_DeInterleave(char *buf, unsigned long ulBufSize, int type, ULONG32 * pFlags);
+
+void ra_bitcopy(unsigned char* toPtr,
+ unsigned long ulToBufSize,
+ unsigned char* fromPtr,
+ unsigned long ulFromBufSize,
+ int bitOffsetTo,
+ int bitOffsetFrom,
+ int numBits);
+
+#endif /* #ifndef RASL_H */
diff --git a/audio_codec/libcook/rdtpck.h b/audio_codec/libcook/rdtpck.h
new file mode 100644
index 0000000..68251cd
--- a/dev/null
+++ b/audio_codec/libcook/rdtpck.h
@@ -0,0 +1,153 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rdtpck.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RDTPACKET_H
+#define RDTPACKET_H
+
+#include <string.h>
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+ /*
+ *
+ * Packet util functions and types
+ *
+ */
+
+#define RDT_ASM_ACTION_PKT 0xFF00
+#define RDT_BW_REPORT_PKT 0xFF01
+#define RDT_ACK_PKT 0xFF02
+#define RDT_RTT_REQUEST_PKT 0xFF03
+#define RDT_RTT_RESPONSE_PKT 0xFF04
+#define RDT_CONGESTION_PKT 0xFF05
+#define RDT_STREAM_END_PKT 0xFF06
+#define RDT_REPORT_PKT 0xFF07
+#define RDT_LATENCY_REPORT_PKT 0xFF08
+#define RDT_TRANS_INFO_RQST_PKT 0xFF09
+#define RDT_TRANS_INFO_RESP_PKT 0xFF0A
+#define RDT_BANDWIDTH_PROBE_PKT 0xFF0B
+
+#define RDT_DATA_PACKET 0xFFFE
+#define RDT_UNKNOWN_TYPE 0xFFFF
+
+
+
+ /*
+ *
+ * The tngpkt.h file included below is auto-generated from the master
+ * header file which contains the bit by bit definitions of the packet
+ * structures(tngpkt.pm). The structures defined in tngpkt.h are
+ * easier to use compared to the actual packet definitions in
+ * tngpkt.pm. tngpkt.h also includes pack and unpack functions that
+ * can convert these structures to and from the binary wire format of
+ * the different packet types.
+ *
+ */
+#include "tngpkt.h"
+
+
+ /* All seq numbers will be marked as lost [beg, end]. */
+ /* Caller is responsible for free'ing the bit-field that is allocated
+ * ( "pkt->data.data").
+ */
+ void createNAKPacket(struct TNGACKPacket* pkt,
+ UINT16 unStreamNum,
+ UINT16 unBegSeqNum,
+ UINT16 unEndSeqNum
+ );
+
+ void createNAKPacketFromPool(struct TNGACKPacket* pkt,
+ UINT16 unStreamNum,
+ UINT16 unBegSeqNum,
+ UINT16 unEndSeqNum,
+ rm_malloc_func_ptr fpMalloc,
+ void* pMemoryPool
+ );
+
+
+
+ /* All seq numbers will be marked as received [beg, end]. The caller
+ * must free the 'pkt->data.data' malloc'ed memory.
+ */
+ void createACKPacket(struct TNGACKPacket* pkt,
+ UINT16 unStreamNum,
+ UINT16 unBegSeqNum,
+ UINT16 unEndSeqNum
+ );
+
+ void createACKPacketFromPool(struct TNGACKPacket* pkt,
+ UINT16 unStreamNum,
+ UINT16 unBegSeqNum,
+ UINT16 unEndSeqNum,
+ rm_malloc_func_ptr fpMalloc,
+ void* pMemoryPool
+ );
+
+ /*
+ * Returns the packet type of the packet in the buffer that was just
+ * read off of the wire
+ */
+ UINT16 GetRDTPacketType(UINT8* pBuf, UINT32 nLen);
+
+
+
+ /*
+ * Marshalling inline funcs.
+ */
+
+ UINT8 getbyte(UINT8* data);
+ UINT16 getshort(UINT8* data);
+ INT32 getlong(UINT8* data);
+ void putbyte(UINT8* data, INT8 v);
+ void putshort(UINT8* data, UINT16 v);
+ void putlong(UINT8* data, UINT32 v);
+ UINT8* addbyte(UINT8* cp, UINT8 data);
+ UINT8* addshort(UINT8* cp, UINT16 data);
+ UINT8* addlong(UINT8* cp, UINT32 data);
+ UINT8* addstring(UINT8* cp, const UINT8* string, int len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RDTPACKET_H */
diff --git a/audio_codec/libcook/rm_error.h b/audio_codec/libcook/rm_error.h
new file mode 100644
index 0000000..b052baf
--- a/dev/null
+++ b/audio_codec/libcook/rm_error.h
@@ -0,0 +1,54 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_error.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_ERROR_H
+#define RM_ERROR_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ typedef void (*rm_error_func_ptr)(void* pUserError, HX_RESULT err, const char* msg);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RM_ERROR_H */
diff --git a/audio_codec/libcook/rm_error_default.c b/audio_codec/libcook/rm_error_default.c
new file mode 100644
index 0000000..096650d
--- a/dev/null
+++ b/audio_codec/libcook/rm_error_default.c
@@ -0,0 +1,58 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_error_default.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <stdio.h>
+//#include "includes.h"
+#include "rm_error.h"
+#include "rm_error_default.h"
+
+void rm_error_default(void* pUserError, HX_RESULT err, const char* msg)
+{
+ if (msg) {
+#if 0
+ printk(
+ "rm_error_default(pUserError=0x%08x,err=0x%08x,msg=%s\n",
+ pUserError, err, msg);
+#endif
+ } else {
+#if 0
+ printk(
+ "rm_error_default(pUserError=0x%08x,err=0x%08x\n",
+ pUserError, err);
+#endif
+ }
+}
diff --git a/audio_codec/libcook/rm_error_default.h b/audio_codec/libcook/rm_error_default.h
new file mode 100644
index 0000000..2d6da08
--- a/dev/null
+++ b/audio_codec/libcook/rm_error_default.h
@@ -0,0 +1,53 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_error_default.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_ERROR_DEFAULT_H
+#define RM_ERROR_DEFAULT_H
+
+#include "helix_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ void rm_error_default(void* pUserError, HX_RESULT err, const char* msg);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RM_ERROR_DEFAULT_H */
diff --git a/audio_codec/libcook/rm_io_default.c b/audio_codec/libcook/rm_io_default.c
new file mode 100644
index 0000000..b84f994
--- a/dev/null
+++ b/audio_codec/libcook/rm_io_default.c
@@ -0,0 +1,101 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_io_default.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+//#include "includes.h"
+//#include "avtimer.h"
+//#include "aw_windows.h"
+//#include "datasrc.h"
+
+#include "helix_types.h"
+#include "rm_io_default.h"
+#include "rm_parse.h"
+
+UINT32 rm_io_default_read(void* pUserRead, BYTE* pBuf, UINT32 ulBytesToRead)
+{
+ UINT32 ulRet = 0;
+#if 0
+ if (pBuf && ulBytesToRead) {
+ /* For default, the void* is a FILE* */
+ INT32 fp = (INT32) pUserRead;
+ /* Read the number of bytes requested */
+ ulRet = (UINT32) read(fp, pBuf, ulBytesToRead);
+ }
+#endif
+ return ulRet;
+}
+
+void rm_io_default_seek(void* pUserRead, UINT32 ulOffset, UINT32 ulOrigin)
+{
+#if 0
+ {
+ /* For default, the void* is a FILE* */
+ INT32 fp = (INT32) pUserRead;
+ /* Do the seek */
+ lseek(fp, ulOffset, ulOrigin);
+ }
+#endif
+}
+
+UINT32 rm_io_datasrc_read(void* pUserRead, BYTE* pBuf, UINT32 ulBytesToRead)
+{
+ UINT32 ulRet = 0;
+#if 0
+ DataSrc_t *ds = (DataSrc_t*)pUserRead;
+
+ if (ds && pBuf && ulBytesToRead) {
+ ulRet = DataSrcRead(ds, pBuf, ulBytesToRead);
+ }
+#endif
+ return ulRet;
+}
+
+void rm_io_datasrc_seek(void* pUserRead, UINT32 ulOffset, UINT32 ulOrigin)
+{
+#if 0
+ DataSrc_t *ds = (DataSrc_t*)pUserRead;
+
+ if (ds) {
+ if (ulOrigin == HX_SEEK_ORIGIN_CUR) {
+ DataSrcSeek(ds, ulOffset, SEEK_CUR);
+ } else if (ulOrigin == HX_SEEK_ORIGIN_SET) {
+ DataSrcSeek(ds, ulOffset, SEEK_SET);
+ } else if (ulOrigin == HX_SEEK_ORIGIN_END) {
+ DataSrcSeek(ds, ulOffset, SEEK_END);
+ }
+ }
+#endif
+}
diff --git a/audio_codec/libcook/rm_io_default.h b/audio_codec/libcook/rm_io_default.h
new file mode 100644
index 0000000..d1e3323
--- a/dev/null
+++ b/audio_codec/libcook/rm_io_default.h
@@ -0,0 +1,49 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_io_default.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_IO_DEFAULT_H
+#define RM_IO_DEFAULT_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+
+UINT32 rm_io_default_read(void* pUserRead, BYTE* pBuf, UINT32 ulBytesToRead);
+void rm_io_default_seek(void* pUserRead, UINT32 ulOffset, UINT32 ulOrigin);
+UINT32 rm_io_datasrc_read(void* pUserRead, BYTE* pBuf, UINT32 ulBytesToRead);
+void rm_io_datasrc_seek(void* pUserRead, UINT32 ulOffset, UINT32 ulOrigin);
+
+#endif /* #ifndef RM_IO_DEFAULT_H */
diff --git a/audio_codec/libcook/rm_memory.h b/audio_codec/libcook/rm_memory.h
new file mode 100644
index 0000000..81e2919
--- a/dev/null
+++ b/audio_codec/libcook/rm_memory.h
@@ -0,0 +1,54 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_memory.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_MEMORY_H
+#define RM_MEMORY_H
+
+#include "helix_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ typedef void* (*rm_malloc_func_ptr)(void* pUserMem, UINT32 ulSize);
+ typedef void (*rm_free_func_ptr)(void* pUserMem, void* ptr);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RM_MEMORY_H */
diff --git a/audio_codec/libcook/rm_memory_default.c b/audio_codec/libcook/rm_memory_default.c
new file mode 100644
index 0000000..742574e
--- a/dev/null
+++ b/audio_codec/libcook/rm_memory_default.c
@@ -0,0 +1,54 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_memory_default.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+//#include "includes.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include "rm_memory.h"
+#include "rm_memory_default.h"
+
+void* rm_memory_default_malloc(void* pUserMem, UINT32 ulSize)
+{
+ return (void *)malloc(ulSize);
+}
+
+void rm_memory_default_free(void* pUserMem, void* ptr)
+{
+ free(ptr);
+}
diff --git a/audio_codec/libcook/rm_memory_default.h b/audio_codec/libcook/rm_memory_default.h
new file mode 100644
index 0000000..297e441
--- a/dev/null
+++ b/audio_codec/libcook/rm_memory_default.h
@@ -0,0 +1,46 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_memory_default.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_MEMORY_DEFAULT_H
+#define RM_MEMORY_DEFAULT_H
+
+#include "helix_types.h"
+
+void* rm_memory_default_malloc(void* pUserMem, UINT32 ulSize);
+void rm_memory_default_free(void* pUserMem, void* ptr);
+
+#endif /* RM_MEMORY_DEFAULT_H */
diff --git a/audio_codec/libcook/rm_packet.c b/audio_codec/libcook/rm_packet.c
new file mode 100644
index 0000000..47f172a
--- a/dev/null
+++ b/audio_codec/libcook/rm_packet.c
@@ -0,0 +1,117 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_packet.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "helix_types.h"
+#include "rm_packet.h"
+
+UINT32 rm_packet_get_timestamp(rm_packet* packet)
+{
+ UINT32 ulRet = 0;
+
+ if (packet) {
+ ulRet = packet->ulTime;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_packet_get_stream_number(rm_packet* packet)
+{
+ UINT32 ulRet = 0;
+
+ if (packet) {
+ ulRet = packet->usStream;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_packet_get_asm_flags(rm_packet* packet)
+{
+ UINT32 ulRet = 0;
+
+ if (packet) {
+ ulRet = packet->usASMFlags;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_packet_get_asm_rule_number(rm_packet* packet)
+{
+ UINT32 ulRet = 0;
+
+ if (packet) {
+ ulRet = packet->ucASMRule;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_packet_get_data_length(rm_packet* packet)
+{
+ UINT32 ulRet = 0;
+
+ if (packet) {
+ ulRet = packet->usDataLen;
+ }
+
+ return ulRet;
+}
+
+BYTE* rm_packet_get_data(rm_packet* packet)
+{
+ BYTE* pRet = HXNULL;
+
+ if (packet) {
+ pRet = packet->pData;
+ }
+
+ return pRet;
+}
+
+HXBOOL rm_packet_is_lost(rm_packet* packet)
+{
+ HXBOOL bRet = FALSE;
+
+ if (packet) {
+ bRet = (packet->ucLost ? TRUE : FALSE);
+ }
+
+ return bRet;
+}
+
diff --git a/audio_codec/libcook/rm_packet.h b/audio_codec/libcook/rm_packet.h
new file mode 100644
index 0000000..e9c47ee
--- a/dev/null
+++ b/audio_codec/libcook/rm_packet.h
@@ -0,0 +1,80 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_packet.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_PACKET_H
+#define RM_PACKET_H
+
+#include "helix_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /*
+ * Packet struct
+ *
+ * Users are strongly encouraged to use the
+ * accessor functions below to retrieve information
+ * from the packet, since the definition of this
+ * struct may change in the future.
+ */
+ typedef struct rm_packet_struct {
+ UINT32 ulTime;
+ UINT16 usStream;
+ UINT16 usASMFlags;
+ BYTE ucASMRule;
+ BYTE ucLost;
+ UINT16 usDataLen;
+ BYTE* pData;
+ } rm_packet;
+
+ /*
+ * Packet Accessor functions
+ */
+ UINT32 rm_packet_get_timestamp(rm_packet* packet);
+ UINT32 rm_packet_get_stream_number(rm_packet* packet);
+ UINT32 rm_packet_get_asm_flags(rm_packet* packet);
+ UINT32 rm_packet_get_asm_rule_number(rm_packet* packet);
+ UINT32 rm_packet_get_data_length(rm_packet* packet);
+ BYTE* rm_packet_get_data(rm_packet* packet);
+ HXBOOL rm_packet_is_lost(rm_packet* packet);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RM_PACKET_H */
diff --git a/audio_codec/libcook/rm_parse.h b/audio_codec/libcook/rm_parse.h
new file mode 100644
index 0000000..6bec67b
--- a/dev/null
+++ b/audio_codec/libcook/rm_parse.h
@@ -0,0 +1,302 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_parse.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_PARSE_H
+#define RM_PARSE_H
+
+#include <stdio.h>
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+#include "rm_error.h"
+#include "rm_property.h"
+#include "rm_stream.h"
+#include "rm_packet.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /*
+ * Seek origin definitions - these are
+ * exactly the same as the respective
+ * definitions in <stdio.h>
+ */
+#define HX_SEEK_ORIGIN_SET 0
+#define HX_SEEK_ORIGIN_CUR 1
+#define HX_SEEK_ORIGIN_END 2
+
+ /* Function pointer definitions */
+ typedef UINT32(*rm_read_func_ptr)(void* pUserRead,
+ BYTE* pBuf, /* Must be at least ulBytesToRead long */
+ UINT32 ulBytesToRead);
+ typedef void (*rm_seek_func_ptr)(void* pUserRead,
+ UINT32 ulOffset,
+ UINT32 ulOrigin);
+
+ /*
+ * rm_parser definition. This is opaque to the user.
+ */
+ typedef void rm_parser;
+
+ /*
+ * rm_parser_is_rm_file()
+ *
+ * Function which examines pBuf[0] up through pBuf[ulSize-1] and
+ * tries to determine if the buffer contains the beginning of an .rm file
+ */
+ HXBOOL rm_parser_is_rm_file(BYTE* pBuf, UINT32 ulSize);
+
+ /*
+ * rm_parser_create
+ *
+ * This creates an rm_parser object. The user may provide an
+ * optional error reporting function as well as a void*
+ * which will be passed into fpError. If fpError is NULL, then
+ * the parser will not print out any error messages by default
+ * and the user will have to interpret the error by the
+ * return value.
+ */
+ rm_parser* rm_parser_create(void* pError,
+ rm_error_func_ptr fpError);
+
+ /*
+ * rm_parser_create2
+ *
+ * This creates an rm_parser object, using custom memory
+ * allocation and free functions that the user provides.
+ * If fpMalloc or fpFree are NULL, then the default
+ * allocation and free functions will be used.
+ */
+ rm_parser* rm_parser_create2(void* pError,
+ rm_error_func_ptr fpError,
+ void* pMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+
+ /*
+ * rm_parser_init_stdio
+ *
+ * Users would call this is they wanted to use stdio. This file
+ * would need to already be fopen()'d and would need to be fclose()'d
+ * after the library was finished. The parsing library would only
+ * call fread(), fseek(), and perhaps ftell() on it.
+ */
+ HX_RESULT rm_parser_init_stdio(rm_parser* pParser,
+ FILE* fp);
+
+ /*
+ * rm_parser_init_io
+ *
+ * If the user didn't want to use stdio, they would call
+ * this function to set up their own I/O.
+ */
+ HX_RESULT rm_parser_init_io(rm_parser* pParser,
+ void* pUserRead,
+ rm_read_func_ptr fpRead,
+ rm_seek_func_ptr fpSeek);
+
+ /*
+ * rm_parser_read_headers
+ *
+ * This function reads all the headers at the beginning
+ * of an .rm file. After this function is called,
+ * then the rm_get_xxx accessor functions can be
+ * called to get information about the file as a whole.
+ */
+ HX_RESULT rm_parser_read_headers(rm_parser* pParser);
+
+ /*
+ * File Info Accessor functions
+ *
+ * The most commonly-used properties of an .rm file can
+ * be accessed via the rm_parser_get_xxx accessor functions
+ * below. These functions return information about the .rm file as
+ * a whole, as opposed to stream header properties, which give
+ * information about a particular stream (i.e. - audio stream
+ * or video stream).
+ *
+ * For the title meta-data, the user can determine if this information
+ * is present by calling rm_parser_get_title_length(). This length
+ * is the length in bytes of the string INCLUDING the null
+ * terminator. If the title meta-data IS present, then the user
+ * can get read-only access to the title by calling rm_parser_get_title().
+ * The user must not alter the memory that is returned; otherwise undefined
+ * behavior will result.
+ *
+ * The same applies for author, copyright, and comment meta-data.
+ */
+ UINT32 rm_parser_get_max_bit_rate(rm_parser* pParser);
+ UINT32 rm_parser_get_avg_bit_rate(rm_parser* pParser);
+ UINT32 rm_parser_get_max_packet_size(rm_parser* pParser);
+ UINT32 rm_parser_get_avg_packet_size(rm_parser* pParser);
+ UINT32 rm_parser_get_num_packets(rm_parser* pParser);
+ UINT32 rm_parser_get_duration(rm_parser* pParser);
+ UINT32 rm_parser_get_preroll(rm_parser* pParser);
+ const char* rm_parser_get_title(rm_parser* pParser);
+ const char* rm_parser_get_author(rm_parser* pParser);
+ const char* rm_parser_get_copyright(rm_parser* pParser);
+ const char* rm_parser_get_comment(rm_parser* pParser);
+ UINT32 rm_parser_get_num_streams(rm_parser* pParser);
+ UINT32 rm_parser_get_stream_number(rm_parser* pParser, UINT32 ulStreamNum);
+
+ /*
+ * General file property accessors
+ *
+ * The most commonly-used properties of an .rm file
+ * can be obtained with the rm_parser_get_xxx accessors above.
+ * Alternatively, all of the file-level properties may
+ * be obtained as an array of rm_property structs. This
+ * array will include all of the common-used properties
+ * above as well as any other properties that may be
+ * present in the file.
+ */
+ HX_RESULT rm_parser_get_file_properties(rm_parser* pParser,
+ rm_property** ppProp,
+ UINT32* pulNumProps);
+
+ /*
+ * This function destroys an array of properties created
+ * by either rm_parser_get_file_properties or
+ * by rm_parser_get_stream_properties.
+ */
+ void rm_parser_destroy_properties(rm_parser* pParser,
+ rm_property** ppProp,
+ UINT32* pulNumProps);
+
+ /*
+ * rm_parser_get_stream_header
+ *
+ * This retrieves a stream header from the file. The number
+ * of stream headers in the file can be found by calling
+ * rm_get_num_streams(). Stream header properties may
+ * be obtained by using the accessor functions found
+ * in rm_stream.h. These accessors cover the most
+ * commonly used properties. The entire set of properties
+ * may be retrieved using rm_parser_get_stream_properties().
+ */
+ HX_RESULT rm_parser_get_stream_header(rm_parser* pParser,
+ UINT32 ulStreamNum,
+ rm_stream_header** ppHdr);
+
+ /*
+ * rm_parser_destroy_stream_header
+ *
+ * This function frees any memory associated with
+ * a stream header obtained by calling rm_parser_get_stream_header().
+ */
+ void rm_parser_destroy_stream_header(rm_parser* pParser,
+ rm_stream_header** ppHdr);
+
+ /*
+ * rm_parser_get_packet
+ *
+ * After the headers had been read, the user can repeatedly
+ * call this function to retrieve packets from the .rm file.
+ */
+ HX_RESULT rm_parser_get_packet(rm_parser* pParser,
+ rm_packet** ppPacket);
+
+ /*
+ * rm_parser_destroy_packet
+ *
+ * This is called to clean up packets created by
+ * calls to rm_parser_get_packet().
+ */
+ void rm_parser_destroy_packet(rm_parser* pParser,
+ rm_packet** ppPacket);
+
+ /*
+ * rm_parser_seek
+ *
+ * The user can call this function to seek to a
+ * certain time in the .rm file
+ */
+ HX_RESULT rm_parser_seek(rm_parser* pParser,
+ UINT32 ulTime);
+
+ /*
+ * rm_parser_seek
+ *
+ * The user can call this function to seek to a
+ * certain offset in the .rm file
+ */
+ void rm_parser_file_seek(rm_parser* pParser, UINT32 ulOffset);
+
+ /*
+ * rm_parser_skip
+ *
+ * The user can call this function to skip to a
+ * certain offset from current position
+ */
+ void rm_parser_file_skip(rm_parser* pParser, UINT32 ulOffset);
+
+ /*
+ * rm_parser_build_seek_table
+ *
+ * The user can call this function to build a seek table
+ * by index in the .rm file
+ */
+ HX_RESULT rm_parser_build_seek_table(rm_parser* pParser);
+
+ /*
+ * rm_parser_seek_in_seek_table
+ *
+ * The user can call this function to seek in the seek table
+ * to find a certain time in the .rm file
+ */
+ HX_RESULT rm_parser_seek_in_seek_table(rm_parser* pParser, INT32 lStreamNumber, UINT32 ulSeekTime, INT32 lDirection, UINT32* pulFoundTime, UINT32* pulDataOffset, UINT32* pulIndex);
+
+ /*
+ * rm_parser_destroy
+ *
+ * The user calls this to clean up
+ */
+ void rm_parser_destroy(rm_parser** ppParser);
+
+ UINT32 rm_parser_get_data_size(rm_parser* pParser);
+ UINT32 rm_parser_get_data_offset(rm_parser* pParser);
+ UINT32 rm_parser_get_index_offset(rm_parser* pParser);
+ void rm_parser_set_index_offset(rm_parser* pParser, UINT32 offset);
+ void rm_parser_set_stream(rm_parser** ppParser, UINT32 ulStreamNum);
+ void rm_parser_set_stream_size(rm_parser* pParser, UINT32 ulStreamSize);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RM_PARSE_H */
diff --git a/audio_codec/libcook/rm_parser.c b/audio_codec/libcook/rm_parser.c
new file mode 100644
index 0000000..67a3982
--- a/dev/null
+++ b/audio_codec/libcook/rm_parser.c
@@ -0,0 +1,649 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_parser.c,v 1.1.1.1.2.1 2005/05/04 18:21:36 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <stdio.h>
+#include <memory.h>
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_parse.h"
+#include "rm_parser_internal.h"
+#include "rm_memory_default.h"
+#include "rm_error_default.h"
+#include "rm_io_default.h"
+#include "memory_utils.h"
+#include "pack_utils.h"
+
+/*
+ * We will create a buffer of this size to handle
+ * reading of headers. The buffer will get increased
+ * in size if we encounter a header bigger than this
+ * size. Therefore, we would like to pick a reasonable
+ * size so that the we don't have lots of little
+ * allocations. This size should be the maximum
+ * of the expected size of the headers in the .rm file.
+ *
+ * XXXMEH - run lots of .rm files to see what a good
+ * size to pick.
+ */
+#define RM_PARSER_INITIAL_READ_BUFFER_SIZE 256
+
+HXBOOL rm_parser_is_rm_file(BYTE* pBuf, UINT32 ulSize)
+{
+ HXBOOL bRet = FALSE;
+
+ /* Look for magic number ".RMF" at the beginning */
+ if (ulSize >= 4) {
+ UINT32 ulID = rm_unpack32(&pBuf, &ulSize);
+ if (ulID == RM_HEADER_OBJECT) {
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+rm_parser* rm_parser_create(void* pError,
+ rm_error_func_ptr fpError)
+{
+ return rm_parser_create2(pError,
+ fpError,
+ HXNULL,
+ rm_memory_default_malloc,
+ rm_memory_default_free);
+}
+
+rm_parser* rm_parser_create2(void* pError,
+ rm_error_func_ptr fpError,
+ void* pMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree)
+{
+ rm_parser* pRet = HXNULL;
+
+ if (fpMalloc) {
+ /* Allocate space for the rm_parser_internal struct
+ * by using the passed-in malloc function
+ */
+ rm_parser_internal* pInt = (rm_parser_internal*) fpMalloc(pMem, sizeof(rm_parser_internal));
+ if (pInt) {
+ /* Zero out the struct */
+ memset((void*) pInt, 0, sizeof(rm_parser_internal));
+ /*
+ * Assign the error members. If the user did not
+ * provide an error callback, then use the default
+ * rm_error_default().
+ */
+ if (fpError) {
+ pInt->fpError = fpError;
+ pInt->pUserError = pError;
+ } else {
+ pInt->fpError = rm_error_default;
+ pInt->pUserError = HXNULL;
+ }
+ /* Assign the memory functions */
+ pInt->fpMalloc = fpMalloc;
+ pInt->fpFree = fpFree;
+ pInt->pUserMem = pMem;
+ /* Assign the return value */
+ pRet = (rm_parser*) pInt;
+ }
+ }
+
+ return pRet;
+}
+
+HX_RESULT rm_parser_init_stdio(rm_parser* pParser,
+ FILE* fp)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser && fp) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Assign the default io functions */
+ pInt->fpRead = rm_io_default_read;
+ pInt->fpSeek = rm_io_default_seek;
+ pInt->pUserRead = (void*) fp;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parser_init_io(rm_parser* pParser,
+ void* pUserRead,
+ rm_read_func_ptr fpRead,
+ rm_seek_func_ptr fpSeek)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser && fpRead && fpSeek) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Assign the default io functions */
+ pInt->fpRead = fpRead;
+ pInt->fpSeek = fpSeek;
+ pInt->pUserRead = pUserRead;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parser_read_headers(rm_parser* pParser)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Allocate the read buffer if necessary */
+ if (!pInt->pReadBuffer) {
+ retVal = rm_enforce_buffer_min_size(pInt->pUserMem,
+ pInt->fpMalloc,
+ pInt->fpFree,
+ &pInt->pReadBuffer,
+ &pInt->ulReadBufferSize,
+ RM_PARSER_INITIAL_READ_BUFFER_SIZE);
+ if (retVal == HXR_OK) {
+ /* Set the number of bytes read to zero */
+ pInt->ulNumBytesRead = 0;
+ }
+ }
+ if (retVal == HXR_OK) {
+ retVal = rm_parseri_read_all_headers(pInt);
+ }
+ }
+
+ return retVal;
+}
+
+
+UINT32 rm_parser_get_max_bit_rate(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.max_bit_rate;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_avg_bit_rate(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.avg_bit_rate;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_max_packet_size(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.max_pkt_size;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_avg_packet_size(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.avg_pkt_size;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_num_packets(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.num_pkts;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_duration(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.duration;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_preroll(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.preroll;
+ }
+
+ return ulRet;
+}
+
+void rm_parser_set_index_offset(rm_parser* pParser, UINT32 offset)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ((rm_parser_internal*) pParser)->propHdr.index_offset = offset;
+ }
+}
+
+UINT32 rm_parser_get_index_offset(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.index_offset;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_data_offset(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.data_offset;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_data_size(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->pDataHdr[0].size;
+ }
+
+ return ulRet;
+}
+
+const char* rm_parser_get_title(rm_parser* pParser)
+{
+ const char* pRet = HXNULL;
+
+ if (pParser) {
+ pRet = (const char*)((rm_parser_internal*) pParser)->contHdr.title;
+ }
+
+ return pRet;
+}
+
+const char* rm_parser_get_author(rm_parser* pParser)
+{
+ const char* pRet = HXNULL;
+
+ if (pParser) {
+ pRet = (const char*)((rm_parser_internal*) pParser)->contHdr.author;
+ }
+
+ return pRet;
+}
+
+const char* rm_parser_get_copyright(rm_parser* pParser)
+{
+ const char* pRet = HXNULL;
+
+ if (pParser) {
+ pRet = (const char*)((rm_parser_internal*) pParser)->contHdr.copyright;
+ }
+
+ return pRet;
+}
+
+const char* rm_parser_get_comment(rm_parser* pParser)
+{
+ const char* pRet = HXNULL;
+
+ if (pParser) {
+ pRet = (const char*)((rm_parser_internal*) pParser)->contHdr.comment;
+ }
+
+ return pRet;
+}
+
+UINT32 rm_parser_get_num_streams(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->ulNumStreams;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_stream_number(rm_parser* pParser, UINT32 ulStreamNum)
+{
+ UINT32 ulRet = 0xffffffff;
+
+ if (pParser) {
+ ulRet = rm_parseri_get_stream_number((rm_parser_internal*) pParser, ulStreamNum);
+ }
+ return ulRet;
+}
+
+void rm_parser_set_stream_size(rm_parser* pParser, UINT32 ulStreamSize)
+{
+ if (pParser) {
+ rm_parseri_set_stream_size((rm_parser_internal*) pParser, ulStreamSize);
+ }
+}
+
+HX_RESULT rm_parser_get_file_properties(rm_parser* pParser,
+ rm_property** ppProp,
+ UINT32* pulNumProps)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser && ppProp && pulNumProps) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ if (pInt->fpMalloc && pInt->fpFree) {
+ /* Get the number of file properties */
+ UINT32 ulNum = rm_parseri_get_num_file_properties(pInt);
+ if (ulNum) {
+ /* Compute the size of the rm_property array */
+ UINT32 ulSize = ulNum * sizeof(rm_property);
+ /* Allocate an array of this size */
+ rm_property* pPropArr = pInt->fpMalloc(pInt->pUserMem, ulSize);
+ if (pPropArr) {
+ /* NULL out the memory */
+ memset(pPropArr, 0, ulSize);
+ /* Collect the properties */
+ retVal = rm_parseri_get_file_properties(pInt, pPropArr, ulNum);
+ if (retVal == HXR_OK) {
+ /* Assign the out parameters */
+ *ppProp = pPropArr;
+ *pulNumProps = ulNum;
+ } else {
+ /* Free the array */
+ pInt->fpFree(pInt->pUserMem, pPropArr);
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rm_parser_destroy_properties(rm_parser* pParser,
+ rm_property** ppProp,
+ UINT32* pulNumProps)
+{
+ if (pParser && ppProp && pulNumProps && *ppProp && *pulNumProps) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ if (pInt->fpFree) {
+ /* Get the pointer to the array */
+ rm_property* pProp = *ppProp;
+ /* Clean up the properties */
+ UINT32 i = 0;
+ for (i = 0; i < *pulNumProps; i++) {
+ rm_parseri_cleanup_rm_property(pInt, &pProp[i]);
+ }
+ /* Free the memory */
+ pInt->fpFree(pInt->pUserMem, pProp);
+ /* NULL out the pointer */
+ *ppProp = HXNULL;
+ /* Zero out the number of properties */
+ *pulNumProps = 0;
+ }
+ }
+}
+
+HX_RESULT rm_parser_get_stream_header(rm_parser* pParser,
+ UINT32 ulStreamNum,
+ rm_stream_header** ppHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser && ppHdr) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ if (pInt->fpMalloc) {
+ rm_stream_header* pHdr = (rm_stream_header*) pInt->fpMalloc(pInt->pUserMem,
+ sizeof(rm_stream_header));
+ if (pHdr) {
+ /* NULL out the memory */
+ memset(pHdr, 0, sizeof(rm_stream_header));
+ /* Copy the stream header */
+ retVal = rm_parseri_copy_stream_header(pInt, ulStreamNum, pHdr);
+ if (retVal == HXR_OK) {
+ /* Assign the out parameter */
+ *ppHdr = pHdr;
+ } else {
+ /* Clean up the stream header */
+ rm_parseri_cleanup_stream_header(pInt, pHdr);
+ /* Free the memory we allocated */
+ pInt->fpFree(pInt->pUserMem, pHdr);
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rm_parser_destroy_stream_header(rm_parser* pParser,
+ rm_stream_header** ppHdr)
+{
+ if (pParser && ppHdr && *ppHdr) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Cleanup the stream header */
+ rm_parseri_cleanup_stream_header(pInt, *ppHdr);
+ /* Free the memory associated with this header */
+ pInt->fpFree(pInt->pUserMem, *ppHdr);
+ /* NULL out the pointer */
+ *ppHdr = HXNULL;
+ }
+}
+
+HX_RESULT rm_parser_get_packet(rm_parser* pParser,
+ rm_packet** ppPacket)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser && ppPacket) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Read the next packet */
+ retVal = rm_parseri_read_next_packet(pInt, ppPacket);
+ }
+
+ return retVal;
+}
+
+void rm_parser_destroy_packet(rm_parser* pParser,
+ rm_packet** ppPacket)
+{
+ if (pParser && ppPacket && *ppPacket) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ if (pInt->fpFree) {
+ /* Free the packet data */
+ if ((*ppPacket)->pData) {
+ pInt->fpFree(pInt->pUserMem, (*ppPacket)->pData);
+ (*ppPacket)->pData = HXNULL;
+ }
+ /* Free the packet */
+ pInt->fpFree(pInt->pUserMem, *ppPacket);
+ *ppPacket = HXNULL;
+ }
+ }
+}
+
+HX_RESULT rm_parser_seek(rm_parser* pParser,
+ UINT32 ulTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Read the next packet */
+ retVal = rm_parseri_seek(pInt, ulTime);
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parser_build_seek_table(rm_parser* pParser)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Read the next packet */
+ retVal = rm_parseri_build_seek_table(pInt);
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parser_seek_in_seek_table(rm_parser* pParser, INT32 lStreamNumber, UINT32 ulSeekTime, INT32 lDirection, UINT32* pulFoundTime, UINT32* pulDataOffset, UINT32* pulIndex)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Read the next packet */
+ retVal = rm_parseri_search_seek_tables(pInt, lStreamNumber, ulSeekTime, lDirection, pulFoundTime, pulDataOffset, pulIndex);
+ }
+
+ return retVal;
+}
+
+void rm_parser_file_seek(rm_parser* pParser, UINT32 ulOffset)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Read the next packet */
+ rm_parseri_file_seek(pInt, ulOffset, HX_SEEK_ORIGIN_SET);
+ }
+}
+
+void rm_parser_file_skip(rm_parser* pParser, UINT32 ulOffset)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Read the next packet */
+ rm_parseri_file_seek(pInt, ulOffset, HX_SEEK_ORIGIN_CUR);
+ }
+}
+
+void rm_parser_destroy(rm_parser** ppParser)
+{
+ if (ppParser) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) * ppParser;
+ if (pInt && pInt->fpFree) {
+ /* Save a pointer to fpFree and pUserMem */
+ rm_free_func_ptr fpFree = pInt->fpFree;
+ void* pUserMem = pInt->pUserMem;
+ /* Clean up the content header */
+ rm_parseri_cleanup_content_hdr(pInt);
+ /* Clean up the media props headers */
+ rm_parseri_cleanup_all_media_props_hdrs(pInt);
+ /* Clean up all logical stream headers */
+ rm_parseri_cleanup_all_logical_stream_hdrs(pInt);
+ /* Clean up the logical fileinfo header */
+ rm_parseri_cleanup_logical_fileinfo_hdr(pInt);
+ //rm_parseri_cleanup_logical_stream_hdr(pInt, pInt->pLogicalFileInfo);
+ /* Clean up the read buffer */
+ rm_parseri_cleanup_read_buffer(pInt);
+ /* Free the stream num map */
+ rm_parseri_cleanup_stream_num_map(pInt);
+ /* Clean up the stream info array */
+ rm_parseri_cleanup_stream_info_array(pInt);
+ /* Clean up the stream header array */
+ rm_parseri_cleanup_all_stream_headers(pInt);
+ /* Clean up the data header */
+ rm_parseri_cleanup_all_data_headers(pInt);
+ /* Null everything out */
+ memset(pInt, 0, sizeof(rm_parser_internal));
+ /* Free the rm_parser_internal struct memory */
+ fpFree(pUserMem, pInt);
+ /* NULL out the pointer */
+ *ppParser = HXNULL;
+ }
+ }
+}
+
+void rm_parser_set_stream(rm_parser** ppParser, UINT32 ulStreamNum)
+{
+ if (ppParser) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) * ppParser;
+ pInt->ulCurrentStream = ulStreamNum;
+ rm_parseri_file_seek(pInt, pInt->pMediaPropsHdr[pInt->ulCurrentStream].start_offset, HX_SEEK_ORIGIN_SET);
+ }
+} \ No newline at end of file
diff --git a/audio_codec/libcook/rm_parser_internal.c b/audio_codec/libcook/rm_parser_internal.c
new file mode 100644
index 0000000..e492864
--- a/dev/null
+++ b/audio_codec/libcook/rm_parser_internal.c
@@ -0,0 +1,3342 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_parser_internal.c,v 1.2.2.1 2005/05/04 18:21:36 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <memory.h>
+//#include "includes.h"
+//#include "ioapi.h"
+//#include "datasrc.h"
+#include "helix_types.h"
+#include "helix_result.h"
+#include "helix_utils.h"
+#include "rm_parser_internal.h"
+#include "rm_memory_default.h"
+#include "memory_utils.h"
+#include "pack_utils.h"
+#include "string_utils.h"
+#include "rm_stream.h"
+#include "packet_defines.h"
+#include "rv_format_info.h"
+
+#define RM_PARSER_LOGICAL_PREFIX "logical-"
+#define RM_PARSER_LOGICAL_FILEINFO "logical-fileinfo"
+#define RM_PARSER_NUM_RULE_BOOKS 9
+#define RM_PARSER_RULE_BOOK_BUFFER_SIZE 320 /* Big enough for format string and args */
+
+#define RM_PARSER_LOGICAL_MULTIRATE_VIDEO "logical-video/x-pn-multirate-realvideo"
+#define RM_PARSER_LOGICAL_MULTIRATE_AUDIO "logical-audio/x-pn-multirate-realaudio"
+
+static const char* g_pszRuleBook[] = {
+ /* VBR Real streams when max_bit_rate != 0 */
+ "priority=%lu,AverageBandwidth=%lu,MaximumBandwidth=%lu,"
+ "TimeStampDelivery=TRUE,PNMKeyFrameRule=T;"
+ "OnDepend=\"0\",priority=%lu,AverageBandwidth=0,MaximumBandwidth=0,"
+ "TimeStampDelivery=TRUE,PNMNonKeyFrameRule=T;",
+ /* VBR Real streams when max_bit_rate == 0 */
+ "priority=%lu,AverageBandwidth=%lu,TimeStampDelivery=TRUE,PNMKeyFrameRule=T;"
+ "OnDepend=\"0\",priority=%lu,AverageBandwidth=0,TimeStampDelivery=TRUE,PNMNonKeyFrameRule=T;",
+ /* Non-real-datatype VBR streams when max_bit_rate != 0 */
+ "Marker=0,AverageBandwidth=%lu,MaximumBandwidth=%lu,TimeStampDelivery=TRUE;"
+ "Marker=1,AverageBandwidth=0,MaximumBandwidth=0,TimeStampDelivery=TRUE;",
+ /* Non-real-datatype VBR streams when max_bit_rate == 0 && avg_bit_rate != 0 */
+ "Marker=0,AverageBandwidth=%lu,TimeStampDelivery=TRUE;"
+ "Marker=1,AverageBandwidth=0,TimeStampDelivery=TRUE;",
+ /* Non-real-datatype VBR streams when max_bit_rate == 0 && avg_bit_rate == 0 */
+ "Marker=0,TimeStampDelivery=TRUE;"
+ "Marker=1,TimeStampDelivery=TRUE;",
+ /* CBR RealVideo */
+ "#($Bandwidth >= %lu),priority=9,averagebandwidth=%lu,PNMKeyFrameRule=T;"
+ "#($Bandwidth >= %lu),OnDepend=\"0\",priority=5,averagebandwidth=0,PNMNonKeyFrameRule=T;"
+ "#($Bandwidth < %lu),priority=9,timestampdelivery=T,DropByN=T,PNMThinningRule=T;",
+ /* RealEvent streams */
+ "TimeStampDelivery=T,priority=10,PNMKeyFrameRule=T;"
+ "TimeStampDelivery=T,priority=10,PNMNonKeyFrameRule=T;",
+ /* CBR RealAudio streams */
+ "priority=5,averagebandwidth=%lu,PNMKeyFrameRule=T;"
+ "priority=5,averagebandwidth=0,PNMNonKeyFrameRule=T,OnDepend=\"0\",OffDepend=\"0\";",
+ /* CBR non-real-datatype streams */
+ "Marker=0,priority=5,averagebandwidth=%lu;"
+ "Marker=1,priority=5,averagebandwidth=0;"
+};
+
+HX_RESULT rm_parseri_unpack_generic_hdr(rm_parser_internal* pInt, struct rm_generic_hdr* h)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && h) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ if (ulLen >= 10) {
+ /* Unpack the rm_generic_hdr */
+ h->id = rm_unpack32(&pBuf, &ulLen);
+ h->size = rm_unpack32(&pBuf, &ulLen);
+ h->version = rm_unpack16(&pBuf, &ulLen);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+
+HX_RESULT rm_parseri_unpack_file_hdr(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ if (ulLen >= 18) {
+ /* Unpack the rm_file_hdr */
+ pInt->fileHdr.id = rm_unpack32(&pBuf, &ulLen);
+ pInt->fileHdr.size = rm_unpack32(&pBuf, &ulLen);
+ pInt->fileHdr.version = rm_unpack16(&pBuf, &ulLen);
+ pInt->fileHdr.file_version = rm_unpack32(&pBuf, &ulLen);
+ pInt->fileHdr.num_headers = rm_unpack32(&pBuf, &ulLen);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ } else if (ulLen == 16) {
+ /* Unpack the rm_file_hdr */
+ pInt->fileHdr.id = rm_unpack32(&pBuf, &ulLen);
+ pInt->fileHdr.size = rm_unpack32(&pBuf, &ulLen);
+ pInt->fileHdr.version = rm_unpack16(&pBuf, &ulLen);
+ if (pInt->fileHdr.version == 0) {
+ pInt->fileHdr.file_version = rm_unpack16(&pBuf, &ulLen);
+ pInt->fileHdr.num_headers = rm_unpack32(&pBuf, &ulLen);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_unpack_properties_hdr(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ if (ulLen >= 50) {
+ /* Unpack the rm_properties_hdr */
+ pInt->propHdr.id = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.size = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.version = rm_unpack16(&pBuf, &ulLen);
+ pInt->propHdr.max_bit_rate = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.avg_bit_rate = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.max_pkt_size = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.avg_pkt_size = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.num_pkts = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.duration = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.preroll = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.index_offset = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.data_offset = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.num_streams = rm_unpack16(&pBuf, &ulLen);
+ pInt->propHdr.flags = rm_unpack16(&pBuf, &ulLen);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_unpack_content_hdr(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ if (ulLen >= 12) {
+ /* Unpack the rm_content_hdr */
+ pInt->contHdr.id = rm_unpack32(&pBuf, &ulLen);
+ pInt->contHdr.size = rm_unpack32(&pBuf, &ulLen);
+ pInt->contHdr.version = rm_unpack16(&pBuf, &ulLen);
+ pInt->contHdr.title_sz = rm_unpack16(&pBuf, &ulLen);
+ if (ulLen >= (UINT32) pInt->contHdr.title_sz + 2) {
+ rm_unpack_string(&pBuf, &ulLen, pInt->contHdr.title_sz,
+ &pInt->contHdr.title, pInt->pUserMem,
+ pInt->fpMalloc, pInt->fpFree);
+ pInt->contHdr.author_sz = rm_unpack16(&pBuf, &ulLen);
+ if (ulLen >= (UINT32) pInt->contHdr.author_sz + 2) {
+ rm_unpack_string(&pBuf, &ulLen, pInt->contHdr.author_sz,
+ &pInt->contHdr.author, pInt->pUserMem,
+ pInt->fpMalloc, pInt->fpFree);
+ pInt->contHdr.copyright_sz = rm_unpack16(&pBuf, &ulLen);
+ if (ulLen >= (UINT32) pInt->contHdr.copyright_sz + 2) {
+ rm_unpack_string(&pBuf, &ulLen, pInt->contHdr.copyright_sz,
+ &pInt->contHdr.copyright, pInt->pUserMem,
+ pInt->fpMalloc, pInt->fpFree);
+ pInt->contHdr.comment_sz = rm_unpack16(&pBuf, &ulLen);
+ if (ulLen >= pInt->contHdr.comment_sz) {
+ rm_unpack_string(&pBuf, &ulLen, pInt->contHdr.comment_sz,
+ &pInt->contHdr.comment, pInt->pUserMem,
+ pInt->fpMalloc, pInt->fpFree);
+ if (ulLen >= 4) {
+ if (RM_DATA_OBJECT == rm_unpack32_nse(pBuf, ulLen)) {
+ rm_parseri_file_seek(pInt, pInt->ulCurFileOffset - ulLen, HX_SEEK_ORIGIN_SET);
+ }
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rm_parseri_cleanup_content_hdr(rm_parser_internal* pInt)
+{
+ if (pInt) {
+ /* Delete the title string */
+ if (pInt->contHdr.title) {
+ rm_parseri_free(pInt, pInt->contHdr.title);
+ pInt->contHdr.title = HXNULL;
+ }
+ /* Delete the author string */
+ if (pInt->contHdr.author) {
+ rm_parseri_free(pInt, pInt->contHdr.author);
+ pInt->contHdr.author = HXNULL;
+ }
+ /* Delete the copyright string */
+ if (pInt->contHdr.copyright) {
+ rm_parseri_free(pInt, pInt->contHdr.copyright);
+ pInt->contHdr.copyright = HXNULL;
+ }
+ /* Delete the comment string */
+ if (pInt->contHdr.comment) {
+ rm_parseri_free(pInt, pInt->contHdr.comment);
+ pInt->contHdr.comment = HXNULL;
+ }
+ }
+}
+
+HX_RESULT rm_parseri_unpack_media_props_hdr(rm_parser_internal* pInt,
+ struct rm_media_props_hdr* h)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && h) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ /* Unpack the rm_media_props_hdr */
+ if (ulLen >= 41) {
+ h->id = rm_unpack32(&pBuf, &ulLen);
+ h->size = rm_unpack32(&pBuf, &ulLen);
+ h->version = rm_unpack16(&pBuf, &ulLen);
+ h->stream_num = rm_unpack16(&pBuf, &ulLen);
+ h->max_bit_rate = rm_unpack32(&pBuf, &ulLen);
+ h->avg_bit_rate = rm_unpack32(&pBuf, &ulLen);
+ h->max_pkt_size = rm_unpack32(&pBuf, &ulLen);
+ h->avg_pkt_size = rm_unpack32(&pBuf, &ulLen);
+ h->start_time = rm_unpack32(&pBuf, &ulLen);
+ h->preroll = rm_unpack32(&pBuf, &ulLen);
+ h->duration = rm_unpack32(&pBuf, &ulLen);
+ h->stream_name_sz = rm_unpack8(&pBuf, &ulLen);
+ if (ulLen >= (UINT32) h->stream_name_sz + 1) {
+ rm_unpack_string(&pBuf, &ulLen, h->stream_name_sz, &h->stream_name,
+ pInt->pUserMem, pInt->fpMalloc, pInt->fpFree);
+ h->mime_type_sz = rm_unpack8(&pBuf, &ulLen);
+ if (ulLen >= (UINT32) h->mime_type_sz + 4) {
+ rm_unpack_string(&pBuf, &ulLen, h->mime_type_sz, &h->mime_type,
+ pInt->pUserMem, pInt->fpMalloc, pInt->fpFree);
+ h->type_spec_sz = rm_unpack32(&pBuf, &ulLen);
+ if (ulLen >= (UINT32) h->type_spec_sz) {
+ rm_unpack_buffer(&pBuf, &ulLen, h->type_spec_sz, &h->type_spec,
+ pInt->pUserMem, pInt->fpMalloc, pInt->fpFree);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rm_parseri_cleanup_media_props_hdr(rm_parser_internal* pInt,
+ struct rm_media_props_hdr* h)
+{
+ if (pInt && h) {
+ /* Delete the stream name string */
+ if (h->stream_name) {
+ rm_parseri_free(pInt, h->stream_name);
+ h->stream_name = HXNULL;
+ }
+ /* Delete the mime type string */
+ if (h->mime_type) {
+ rm_parseri_free(pInt, h->mime_type);
+ h->mime_type = HXNULL;
+ }
+ /* Delete the type specific data buffer */
+ if (h->type_spec) {
+ rm_parseri_free(pInt, h->type_spec);
+ h->type_spec = HXNULL;
+ }
+ }
+}
+
+void rm_parseri_cleanup_all_media_props_hdrs(rm_parser_internal* pInt)
+{
+ if (pInt && pInt->pMediaPropsHdr) {
+ /* Clean up each individual media properties header */
+ UINT32 i = 0;
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ rm_parseri_cleanup_media_props_hdr(pInt, &pInt->pMediaPropsHdr[i]);
+ }
+ /* Free the memory for the array */
+ rm_parseri_free(pInt, pInt->pMediaPropsHdr);
+ /* Zero out the number of media props headers */
+ pInt->ulNumMediaPropsHdrs = 0;
+ pInt->ulNumMediaPropsHdrsAlloc = 0;
+ /* Null out the pointer */
+ pInt->pMediaPropsHdr = HXNULL;
+ }
+}
+
+HX_RESULT rm_parseri_unpack_name_value_map(rm_parser_internal* pInt,
+ struct rm_name_value_map* pMap,
+ BYTE** ppBuf, UINT32* pulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pMap && ppBuf && pulLen && *pulLen >= 7) {
+ /* Unpack the name-value map struct */
+ pMap->size = rm_unpack32(ppBuf, pulLen);
+ pMap->version = rm_unpack16(ppBuf, pulLen);
+ pMap->name_sz = rm_unpack8(ppBuf, pulLen);
+ if (*pulLen >= (UINT32) pMap->name_sz + 6) {
+ rm_unpack_string(ppBuf, pulLen, pMap->name_sz, &pMap->name,
+ pInt->pUserMem, pInt->fpMalloc, pInt->fpFree);
+ pMap->type = rm_unpack32(ppBuf, pulLen);
+ pMap->value_sz = rm_unpack16(ppBuf, pulLen);
+ if (*pulLen >= pMap->value_sz) {
+ rm_unpack_buffer(ppBuf, pulLen, pMap->value_sz, &pMap->value,
+ pInt->pUserMem, pInt->fpMalloc, pInt->fpFree);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rm_parseri_cleanup_name_value_map(rm_parser_internal* pInt,
+ struct rm_name_value_map* h)
+{
+ if (pInt && h) {
+ /* Delete the name string */
+ if (h->name) {
+ rm_parseri_free(pInt, h->name);
+ h->name = HXNULL;
+ }
+ /* Delete the value buffer */
+ if (h->value) {
+ rm_parseri_free(pInt, h->value);
+ h->value = HXNULL;
+ }
+ }
+}
+
+void rm_parseri_cleanup_all_name_value_maps(rm_parser_internal* pInt,
+ struct rm_logical_stream_hdr* h)
+{
+ if (pInt && h && h->props) {
+ /* Clean up each name-value pair */
+ UINT16 i = 0;
+ for (i = 0; i < h->num_props; i++) {
+ rm_parseri_cleanup_name_value_map(pInt, &h->props[i]);
+ }
+ /* Free the array of props */
+ rm_parseri_free(pInt, h->props);
+ /* Zero out the number of props */
+ h->num_props = 0;
+ /* NULL out the pointer */
+ h->props = HXNULL;
+ }
+}
+
+HX_RESULT rm_parseri_unpack_logical_stream_hdr(rm_parser_internal* pInt,
+ struct rm_media_props_hdr* mh,
+ struct rm_logical_stream_hdr* h)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && mh && mh->type_spec && mh->type_spec_sz > 0 && h) {
+ /* Assign temporary variables */
+ BYTE* pBuf = mh->type_spec;
+ UINT32 ulLen = mh->type_spec_sz;
+ UINT32 ulSize = 0;
+ UINT16 i = 0;
+ /* Parse the logical stream header */
+ if (ulLen >= 8) {
+ h->size = rm_unpack32(&pBuf, &ulLen);
+ h->version = rm_unpack16(&pBuf, &ulLen);
+ h->num_physical_streams = rm_unpack16(&pBuf, &ulLen);
+ if (ulLen >= (UINT32) 6 * h->num_physical_streams + 2) {
+ rm_unpack_array(&pBuf, &ulLen, h->num_physical_streams, sizeof(UINT16),
+ (void**) &h->physical_stream_num, pInt->pUserMem,
+ pInt->fpMalloc, pInt->fpFree);
+ rm_unpack_array(&pBuf, &ulLen, h->num_physical_streams, sizeof(UINT32),
+ (void**) &h->data_offsets, pInt->pUserMem,
+ pInt->fpMalloc, pInt->fpFree);
+ h->num_rules = rm_unpack16(&pBuf, &ulLen);
+ if (ulLen >= (UINT32) h->num_rules * 2 + 2) {
+ rm_unpack_array(&pBuf, &ulLen, h->num_rules, sizeof(UINT16),
+ (void**) &h->rule_stream_map, pInt->pUserMem,
+ pInt->fpMalloc, pInt->fpFree);
+ h->num_props = rm_unpack16(&pBuf, &ulLen);
+ /* Clean up any existing name-value pairs */
+ rm_parseri_cleanup_all_name_value_maps(pInt, h);
+ /* Allocate an array of name value pairs */
+ ulSize = h->num_props * sizeof(struct rm_name_value_map);
+ if (ulSize) {
+ h->props = (struct rm_name_value_map*) rm_parseri_malloc(pInt, ulSize);
+ if (h->props) {
+ /* NULL out the memory */
+ memset(h->props, 0, ulSize);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Unpack each of the name-value pairs */
+ for (i = 0; i < h->num_props && retVal == HXR_OK; i++) {
+ retVal = rm_parseri_unpack_name_value_map(pInt, &h->props[i],
+ &pBuf, &ulLen);
+ }
+ }
+ } else {
+ /* No properties - not an error */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+UINT32 rm_parseri_get_num_logical_streams(rm_parser_internal* pInt)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt && pInt->pMediaPropsHdr) {
+ UINT32 i = 0;
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ const char* pszMimeType = (const char*) pInt->pMediaPropsHdr[i].mime_type;
+ if (rm_parseri_is_logical_stream_mime_type(pszMimeType)) {
+ ulRet++;
+ }
+ }
+ }
+
+ return ulRet;
+}
+
+HXBOOL rm_parseri_is_logical_fileinfo_present(rm_parser_internal* pInt, UINT32* pulIndx)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pInt && pInt->pMediaPropsHdr && pulIndx) {
+ UINT32 i = 0;
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ const char* pszMimeType = (const char*) pInt->pMediaPropsHdr[i].mime_type;
+ if (rm_parseri_is_logical_fileinfo_mime_type(pszMimeType)) {
+ bRet = TRUE;
+ *pulIndx = i;
+ break;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+void rm_parseri_cleanup_logical_fileinfo_hdr(rm_parser_internal* pInt)
+{
+ if (pInt && pInt->pLogicalFileInfo) {
+ /* Clean up the struct */
+ rm_parseri_cleanup_logical_stream_hdr(pInt, pInt->pLogicalFileInfo);
+ /* Free the struct memory */
+ rm_parseri_free(pInt, pInt->pLogicalFileInfo);
+ /* NULL out the pointer */
+ pInt->pLogicalFileInfo = HXNULL;
+ }
+}
+
+HX_RESULT rm_parseri_unpack_all_logical_stream_hdrs(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ /* Declare some local variables we need later */
+ UINT32 ulSize = 0;
+ UINT32 ulIndx = 0;
+ UINT32 i = 0;
+ /* Get the number of media props headers that are logical streams */
+ UINT32 ulNumLogical = rm_parseri_get_num_logical_streams(pInt);
+ if (ulNumLogical) {
+ /* Free any existing logical stream array */
+ rm_parseri_cleanup_all_logical_stream_hdrs(pInt);
+ /* Compute the size of the logical stream header array */
+ ulSize = ulNumLogical * sizeof(struct rm_logical_stream_hdr);
+ /* Allocate the array of logical stream headers */
+ pInt->pLogicalStreamHdr =
+ (struct rm_logical_stream_hdr*) rm_parseri_malloc(pInt, ulSize);
+ if (pInt->pLogicalStreamHdr) {
+ /* Zero out the memory */
+ memset(pInt->pLogicalStreamHdr, 0, ulSize);
+ /* Assign the number of logical stream headers */
+ pInt->ulNumLogicalStreamHdrs = ulNumLogical;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /*
+ * Loop through all the media properties headers, and
+ * if a header is a logical stream, then unpack it
+ */
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs && retVal == HXR_OK; i++) {
+ const char* pszMimeType = (const char*) pInt->pMediaPropsHdr[i].mime_type;
+ if (rm_parseri_is_logical_stream_mime_type(pszMimeType)) {
+ /*
+ * Unpack the logical stream. We don't have
+ * to worry about ulIndx being less than
+ * ulNumLogicalStreamHdrs since we already
+ * guaranteed above that ulNumLogicalStreamHdrs
+ * was correct.
+ */
+ retVal = rm_parseri_unpack_logical_stream_hdr(pInt,
+ &pInt->pMediaPropsHdr[i],
+ &pInt->pLogicalStreamHdr[ulIndx]);
+ if (retVal == HXR_OK) {
+ ulIndx++;
+ } else {
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal, "Failed to parse logical stream header.");
+ }
+ }
+ }
+ }
+ } else {
+ /* No logical streams - single-rate file */
+ retVal = HXR_OK;
+ }
+ if (retVal == HXR_OK) {
+ /* Clean up any existing logical-fileinfo header */
+ rm_parseri_cleanup_logical_fileinfo_hdr(pInt);
+ /* Do we have a logical-fileinfo header? */
+ if (rm_parseri_is_logical_fileinfo_present(pInt, &ulIndx)) {
+ /* Compute the size of the logical fileinfo */
+ ulSize = sizeof(struct rm_logical_stream_hdr);
+ /* Allocate space for the struct */
+ pInt->pLogicalFileInfo =
+ (struct rm_logical_stream_hdr*) rm_parseri_malloc(pInt, ulSize);
+ if (pInt->pLogicalFileInfo) {
+ /* Zero out the memory */
+ memset(pInt->pLogicalFileInfo, 0, ulSize);
+ /* Unpack the logical-fileinfo struct */
+ retVal = rm_parseri_unpack_logical_stream_hdr(pInt,
+ &pInt->pMediaPropsHdr[ulIndx],
+ pInt->pLogicalFileInfo);
+ if (retVal != HXR_OK) {
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal, "Failed to parse logical-fileinfo header.");
+ }
+ } else {
+ retVal = HXR_OUTOFMEMORY;
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rm_parseri_cleanup_logical_stream_hdr(rm_parser_internal* pInt,
+ struct rm_logical_stream_hdr* h)
+{
+ if (pInt && h) {
+ /* Delete the stream number array */
+ if (h->physical_stream_num) {
+ rm_parseri_free(pInt, h->physical_stream_num);
+ h->physical_stream_num = HXNULL;
+ }
+ /* Delete the data offsets array */
+ if (h->data_offsets) {
+ rm_parseri_free(pInt, h->data_offsets);
+ h->data_offsets = HXNULL;
+ }
+ /* Delete the rule-to-stream map */
+ if (h->rule_stream_map) {
+ rm_parseri_free(pInt, h->rule_stream_map);
+ h->rule_stream_map = HXNULL;
+ }
+ /* Clean up the logical stream props */
+ rm_parseri_cleanup_all_name_value_maps(pInt, h);
+ }
+}
+
+void rm_parseri_cleanup_all_logical_stream_hdrs(rm_parser_internal* pInt)
+{
+ if (pInt && pInt->pLogicalStreamHdr) {
+ /* Clean up the individual logical stream headers */
+ UINT32 i = 0;
+ for (i = 0; i < pInt->ulNumLogicalStreamHdrs; i++) {
+ rm_parseri_cleanup_logical_stream_hdr(pInt, &pInt->pLogicalStreamHdr[i]);
+ }
+ /* Free the memory of the array */
+ rm_parseri_free(pInt, pInt->pLogicalStreamHdr);
+ /* NULL out the array pointer */
+ pInt->pLogicalStreamHdr = HXNULL;
+ /* Zero out the array size and number of headers */
+ pInt->ulNumLogicalStreamHdrs = 0;
+ }
+}
+
+HX_RESULT rm_parseri_allocate_media_props_hdrs(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_OUTOFMEMORY;
+
+ if (pInt) {
+ UINT32 ulSize = 0;
+ /* Clean up any existing media properties header array */
+ rm_parseri_cleanup_all_media_props_hdrs(pInt);
+ /*
+ * Compute the number of stream properties headers
+ * we need to allocate. Normally this is propHdr.num_streams,
+ * but for file version > 0, it is possible to have file-info
+ * header for each stream but not all of them may be present.
+ */
+ pInt->ulNumMediaPropsHdrsAlloc = pInt->propHdr.num_streams;
+ if (pInt->fileHdr.file_version != 0) {
+ if (pInt->ulNumMediaPropsHdrsAlloc > 2) {
+ pInt->ulNumMediaPropsHdrsAlloc = (pInt->ulNumMediaPropsHdrsAlloc - 1) * 2;
+ }
+ }
+ /* Calculate the size of the stream property header array */
+ ulSize = pInt->ulNumMediaPropsHdrsAlloc * sizeof(struct rm_media_props_hdr);
+ /* Allocate the number of media properties headers */
+ pInt->pMediaPropsHdr =
+ (struct rm_media_props_hdr*) rm_parseri_malloc(pInt, ulSize);
+ if (pInt->pMediaPropsHdr) {
+ /* NULL out the memory */
+ memset((void*) pInt->pMediaPropsHdr, 0, ulSize);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+void rm_parseri_cleanup_read_buffer(rm_parser_internal* pInt)
+{
+ if (pInt && pInt->pReadBuffer) {
+ rm_parseri_free(pInt, pInt->pReadBuffer);
+ pInt->pReadBuffer = HXNULL;
+ pInt->ulReadBufferSize = 0;
+ pInt->ulNumBytesRead = 0;
+ }
+}
+
+UINT32 rm_parseri_get_media_props_hdr_stream_num(rm_parser_internal* pInt)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt && pInt->pReadBuffer && pInt->ulNumBytesRead >= 12) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ /* Skip directly to the stream_num */
+ pBuf += 10;
+ ulLen -= 10;
+ /* Unpack the stream_num. */
+ ulRet = (UINT32) rm_unpack16(&pBuf, &ulLen);
+ }
+
+ return ulRet;
+}
+
+HXBOOL rm_parseri_is_logical_stream_mime_type(const char* pszMimeType)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pszMimeType) {
+ if (!rm_parseri_is_logical_fileinfo_mime_type(pszMimeType)) {
+ if (!strncmp(pszMimeType, RM_PARSER_LOGICAL_PREFIX,
+ strlen(RM_PARSER_LOGICAL_PREFIX))) {
+ bRet = TRUE;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+HXBOOL rm_parseri_is_logical_fileinfo_mime_type(const char* pszMimeType)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pszMimeType) {
+ if (!strcmp(pszMimeType, RM_PARSER_LOGICAL_FILEINFO)) {
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+HX_RESULT rm_parseri_read_next_header(rm_parser_internal* pInt, UINT32* pulID)
+{
+ HX_RESULT retVal = HXR_UNEXPECTED;
+ if (pInt && pulID) {
+ struct rm_generic_hdr genHdr;
+ UINT32 ulHeaderSize = 0;
+ UINT32 ulBytesToRead = 0;
+ UINT32 ulNumBytesRead = 0;
+ /* Set the return value */
+ retVal = HXR_READ_ERROR;
+ /* Read a generic header into the read buffer */
+ ulBytesToRead = RM_PARSER_GENERIC_HDR_SIZE;
+ ulNumBytesRead = rm_parseri_file_read(pInt, ulBytesToRead, 0);
+ /* Make sure we read enough */
+ if (ulNumBytesRead == ulBytesToRead) {
+ /* Unpack a generic header */
+ rm_parseri_unpack_generic_hdr(pInt, &genHdr);
+ /*
+ * Compute the size of the header. For
+ * most header types, this will be the size specified
+ * in the "size" field. However, for data chunk headers and
+ * index chunk headers, the "size" also includes the CONTENTS
+ * of the chunk (all the packets or all the index records).
+ * So for those chunks we must special case them.
+ */
+ ulHeaderSize = genHdr.size;
+ if (genHdr.id == RM_DATA_OBJECT) {
+ ulHeaderSize = RM_PARSER_DATA_CHUNK_HEADER_SIZE;
+ } else if (genHdr.id == RM_INDEX_OBJECT) {
+ ulHeaderSize = RM_PARSER_INDEX_HEADER_SIZE;
+ }
+ /* Now compute how many bytes we still need to read */
+ if (ulHeaderSize > RM_PARSER_GENERIC_HDR_SIZE) {
+ /* some incomplete downloaded file filled with 0xffffffff by downloader */
+ if (ulHeaderSize != 0xffffffff) {
+ ulBytesToRead = ulHeaderSize - RM_PARSER_GENERIC_HDR_SIZE;
+ /* Read the rest of the chunk */
+ ulNumBytesRead = rm_parseri_file_read(pInt, ulBytesToRead, RM_PARSER_GENERIC_HDR_SIZE);
+ if (ulNumBytesRead == ulBytesToRead) {
+ /* Assign the header id to the out parameter */
+ *pulID = genHdr.id;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ } else {
+ /* Call back to error interface */
+ rm_parseri_error(pInt, retVal, "Could not read chunk data.");
+ }
+ } else {
+ /* Call back to error interface */
+ rm_parseri_error(pInt, retVal, "Could not read chunk data.");
+ }
+ }
+ } else {
+ /* Call back to error interface */
+ rm_parseri_error(pInt, retVal, "Could not read chunk header.");
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_read_next_packet_header(rm_parser_internal* pInt,
+ struct rm_pkt_hdr* pPktHdr)
+{
+ HX_RESULT retVal = HXR_UNEXPECTED;
+
+ if (pInt) {
+ UINT32 ulNumBytesRead = 0;
+ /* Change the error return */
+ retVal = HXR_READ_ERROR;
+ /* Read the packet header into the read buffer */
+ ulNumBytesRead = rm_parseri_file_read(pInt, RM_PARSER_PACKET_HEADER_SIZE, 0);
+ if (ulNumBytesRead == RM_PARSER_PACKET_HEADER_SIZE) {
+ /* Unpack the packet header */
+ retVal = rm_parseri_unpack_pkt_hdr(pInt, pPktHdr);
+ } else {
+ /* Call back to error interface */
+ rm_parseri_error(pInt, retVal, "Could not read packet header.");
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_setup_interleaved_streams(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_NOT_SUPPORTED;
+
+ if (pInt && pInt->pMediaPropsHdr && pInt->ulNumMediaPropsHdrs) {
+ /* Declare some locals we'll need later */
+ struct rm_media_props_hdr* pTmp = HXNULL;
+ UINT32 ulNumInterleaved = 0;
+ /* Allocate a temporary array of HXBOOLs */
+ UINT32 ulSize = pInt->ulNumMediaPropsHdrs * sizeof(HXBOOL);
+ HXBOOL* pInterleaved = (HXBOOL*) rm_parseri_malloc(pInt, ulSize);
+ if (pInterleaved) {
+ /* Init them all the TRUE */
+ UINT32 i = 0;
+ UINT32 j = 0;
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ pInterleaved[i] = TRUE;
+ }
+ /*
+ * Now run through the all the logical streams
+ * and remove the physical streams
+ */
+ for (i = 0; i < pInt->ulNumLogicalStreamHdrs; i++) {
+ for (j = 0; j < (UINT32) pInt->pLogicalStreamHdr[i].num_physical_streams; j++) {
+ pInterleaved[pInt->pLogicalStreamHdr[i].physical_stream_num[j]] = FALSE;
+ }
+ }
+ /*
+ * Now remove the media props headers that
+ * are actually logical stream and logical fileinfo headers.
+ */
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ const char* pszMimeType = (const char*) pInt->pMediaPropsHdr[i].mime_type;
+ if (rm_parseri_is_logical_stream_mime_type(pszMimeType) ||
+ rm_parseri_is_logical_fileinfo_mime_type(pszMimeType)) {
+ pInterleaved[i] = FALSE;
+ }
+ }
+ /* Now count the interleaved streams */
+ ulNumInterleaved = 0;
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ if (pInterleaved[i]) {
+ ulNumInterleaved++;
+ }
+ }
+ /* Do we have any interleaved streams? */
+ if (ulNumInterleaved) {
+ /* Allocate a new array of media props headers */
+ retVal = HXR_OUTOFMEMORY;
+ ulSize = ulNumInterleaved * sizeof(struct rm_media_props_hdr);
+ pTmp = (struct rm_media_props_hdr*) rm_parseri_malloc(pInt, ulSize);
+ if (pTmp) {
+ /* Copy the media props headers which are interleaved */
+ j = 0;
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ if (pInterleaved[i]) {
+ pInt->pMediaPropsHdr[i].start_offset = pInt->propHdr.data_offset;
+ pTmp[j++] = pInt->pMediaPropsHdr[i];
+ } else {
+ rm_parseri_cleanup_media_props_hdr(pInt, &pInt->pMediaPropsHdr[i]);
+ }
+ }
+ /* Free the logical stream array. */
+ rm_parseri_cleanup_all_logical_stream_hdrs(pInt);
+ /* Delete the memory associated with the old media props array */
+ rm_parseri_free(pInt, pInt->pMediaPropsHdr);
+ /* Replace the old media props array with the new one */
+ pInt->pMediaPropsHdr = pTmp;
+ /* Update the number of media props headers */
+ pInt->ulNumMediaPropsHdrs = ulNumInterleaved;
+ pInt->ulNumMediaPropsHdrsAlloc = ulNumInterleaved;
+ /* Update the number of streams */
+ pInt->ulNumStreams = ulNumInterleaved;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ /* Free the temporary array */
+ rm_parseri_free(pInt, pInterleaved);
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_unpack_logical_multirate_type_spec(rm_parser_internal* pInt, UINT32 index)
+{
+ HX_RESULT retVal = HXR_NOT_SUPPORTED;
+ UINT16 *pStreamNum;
+ unsigned char *pOffset;
+ UINT16 num_stream = 0;
+ int w = 0xFF; /* For run-time endianness detection */
+ int i, j;
+ UINT16 stream_num;
+ UINT32 start_offset;
+
+ if (pInt->pMediaPropsHdr[index].type_spec) {
+ memcpy(&num_stream, pInt->pMediaPropsHdr[index].type_spec + 6, sizeof(UINT16));
+ num_stream = IS_BIG_ENDIAN(w) ? num_stream : BYTE_SWAP_UINT16(num_stream);
+ if (num_stream) {
+ pStreamNum = (UINT16*)(pInt->pMediaPropsHdr[index].type_spec + 8);
+ pOffset = (unsigned char*)(pInt->pMediaPropsHdr[index].type_spec + 8 + num_stream * sizeof(UINT16));
+ for (i = 0; i < num_stream; i++) {
+ memcpy(&stream_num, pStreamNum, sizeof(UINT16));
+ stream_num = IS_BIG_ENDIAN(w) ? stream_num : BYTE_SWAP_UINT16(stream_num);
+ for (j = 0; j < pInt->ulNumMediaPropsHdrs; j++) {
+ if (pInt->pMediaPropsHdr[j].stream_num == stream_num) {
+ memcpy((char*)&start_offset, (char*)pOffset, sizeof(UINT32));
+ pInt->pMediaPropsHdr[j].start_offset = IS_BIG_ENDIAN(w) ? start_offset : BYTE_SWAP_UINT32(start_offset);
+ break;
+ }
+ }
+ pStreamNum++;
+ pOffset += 4;
+ }
+ retVal = HXR_OK;
+ }
+ }
+ return retVal;
+}
+
+HX_RESULT rm_parseri_setup_multirate_streams(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_NOT_SUPPORTED;
+
+ if (pInt && pInt->pMediaPropsHdr && pInt->ulNumMediaPropsHdrs) {
+ /* Declare some locals we'll need later */
+ struct rm_media_props_hdr* pTmp = HXNULL;
+ UINT32 ulNumInterleaved = 0;
+ /* Allocate a temporary array of HXBOOLs */
+ UINT32 ulSize = pInt->ulNumMediaPropsHdrs * sizeof(HXBOOL);
+ HXBOOL* pInterleaved = (HXBOOL*) rm_parseri_malloc(pInt, ulSize);
+ if (pInterleaved) {
+ UINT32 i = 0;
+ UINT32 j = 0;
+ /*
+ * Now get info from logical headers.
+ */
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ const char* pszMimeType = (const char*) pInt->pMediaPropsHdr[i].mime_type;
+ if ((!strcmp(pszMimeType, RM_PARSER_LOGICAL_MULTIRATE_VIDEO)) ||
+ (!strcmp(pszMimeType, RM_PARSER_LOGICAL_MULTIRATE_AUDIO))) {
+ rm_parseri_unpack_logical_multirate_type_spec(pInt, i);
+ }
+ }
+ /*
+ * Now remove the media props headers that
+ * are actually logical stream and logical fileinfo headers.
+ */
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ const char* pszMimeType = (const char*) pInt->pMediaPropsHdr[i].mime_type;
+ if (rm_stream_is_realaudio_mimetype(pszMimeType) ||
+ rm_stream_is_realvideo_mimetype(pszMimeType)) {
+ pInterleaved[i] = TRUE;
+ ulNumInterleaved++;
+ } else {
+ pInterleaved[i] = FALSE;
+ }
+ }
+
+ /* Do we have any streams? */
+ if (ulNumInterleaved > 0) {
+ /* Allocate a new array of media props headers */
+ retVal = HXR_OUTOFMEMORY;
+ ulSize = ulNumInterleaved * sizeof(struct rm_media_props_hdr);
+ pTmp = (struct rm_media_props_hdr*) rm_parseri_malloc(pInt, ulSize);
+ if (pTmp) {
+ /* Copy the media props headers which are interleaved */
+ j = 0;
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ if (pInterleaved[i]) {
+ pTmp[j++] = pInt->pMediaPropsHdr[i];
+ } else {
+ rm_parseri_cleanup_media_props_hdr(pInt, &pInt->pMediaPropsHdr[i]);
+ }
+ }
+ /* Free the logical stream array. */
+ rm_parseri_cleanup_all_logical_stream_hdrs(pInt);
+ /* Delete the memory associated with the old media props array */
+ rm_parseri_free(pInt, pInt->pMediaPropsHdr);
+ /* Replace the old media props array with the new one */
+ pInt->pMediaPropsHdr = pTmp;
+ /* Update the number of media props headers */
+ pInt->ulNumMediaPropsHdrs = ulNumInterleaved;
+ pInt->ulNumMediaPropsHdrsAlloc = ulNumInterleaved;
+ /* Update the number of streams */
+ pInt->ulNumStreams = ulNumInterleaved;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ /* Free the temporary array */
+ rm_parseri_free(pInt, pInterleaved);
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_read_all_headers(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ /* Declare the chunk id local variable */
+ UINT32 ulID = 0;
+ /* Seek back to the beginning of the file */
+ rm_parseri_file_seek(pInt, 0, HX_SEEK_ORIGIN_SET);
+ /* Read the first header */
+ retVal = rm_parseri_read_next_header(pInt, &ulID);
+ if (retVal == HXR_OK) {
+ /*
+ * If we don't encounter a RM_HEADER_OBJECT at the
+ * beginning of the file, then that's a problem.
+ */
+ if (ulID == RM_HEADER_OBJECT) {
+ /* Unpack the .rm file header */
+ retVal = rm_parseri_unpack_file_hdr(pInt);
+ if (retVal == HXR_OK) {
+ /*
+ * Check the version of this file header struct
+ * as well as the file_version to make sure we
+ * support this version of the .rm file.
+ */
+ if ((pInt->fileHdr.version == 0 || pInt->fileHdr.version == 1) &&
+ (pInt->fileHdr.file_version == 0 || pInt->fileHdr.file_version == 1)) {
+ /*
+ * Now loop and unpack until we have either unpacked
+ * the number of headers specified in the file header
+ * or we reach the first data chunk.
+ */
+ HXBOOL bDone = FALSE;
+ UINT32 i = 0;
+ for (i = 0; i < pInt->fileHdr.num_headers && !bDone && retVal == HXR_OK; i++) {
+ /* Read the next header into the read buffer */
+ retVal = rm_parseri_read_next_header(pInt, &ulID);
+ if (retVal == HXR_OK) {
+ /* Switch based on chunk 4cc */
+ switch (ulID) {
+ case RM_PROPERTIES_OBJECT: {
+ /* Unpack the clip properties header */
+ retVal = rm_parseri_unpack_properties_hdr(pInt);
+ if (retVal == HXR_OK) {
+ /* Allocate the media props array */
+ retVal = rm_parseri_allocate_media_props_hdrs(pInt);
+ if (retVal == HXR_OK) {
+ /* Init the number of media props headers we've seen */
+ pInt->ulNumMediaPropsHdrs = 0;
+ }
+ }
+ }
+ break;
+ case RM_MEDIA_PROPERTIES_OBJECT: {
+ /*
+ * Media properties headers aren't necessarily
+ * ordered in the file by stream_num. However, we would like
+ * be able to index them by stream_num. Therefore, we will
+ * first parse out the stream_num member and then place
+ * it in the array at that index.
+ */
+ UINT32 ulStreamNum = rm_parseri_get_media_props_hdr_stream_num(pInt);
+ if (ulStreamNum < pInt->ulNumMediaPropsHdrsAlloc) {
+ /* Unpack the media properties header */
+ retVal = rm_parseri_unpack_media_props_hdr(pInt, &pInt->pMediaPropsHdr[ulStreamNum]);
+ /* Increment the number of properties we've read */
+ if (retVal == HXR_OK) {
+ /* Increment the number of media props headers we've seen */
+ pInt->ulNumMediaPropsHdrs++;
+ } else {
+ /* Parsing of media props header failed. */
+ retVal = HXR_CORRUPT_FILE;
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal, "Failed to parse media props header - possibly a corrupt file.");
+ }
+ } else {
+ /* Illegal stream number */
+ retVal = HXR_CORRUPT_FILE;
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal, "Illegal stream number - possibly a corrupt file.");
+ }
+ }
+ break;
+ case RM_CONTENT_OBJECT: {
+ retVal = rm_parseri_unpack_content_hdr(pInt);
+ if (retVal != HXR_OK) {
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal,
+ "Failed to parse content header - possibly a corrupt file.");
+ }
+ }
+ break;
+ case RM_DATA_OBJECT: {
+ bDone = TRUE;
+ }
+ break;
+ }
+ }
+ }
+ if (retVal == HXR_OK) {
+ /* Parse all the logical stream headers */
+ retVal = rm_parseri_unpack_all_logical_stream_hdrs(pInt);
+ if (retVal == HXR_OK) {
+ /*
+ * Currently we only support single-rate files and
+ * SureStream files who have a backward-compatible
+ * single-rate section. So know we must determine
+ * if we can play this file.
+ */
+ retVal = rm_parseri_setup_interleaved_streams(pInt);
+ if (retVal == HXR_OK) {
+ pInt->ulInterleavedStreamsFlag = 1;
+ /* Create some structures to hold stream info */
+ retVal = rm_parseri_create_stream_structures(pInt);
+ if (retVal == HXR_OK) {
+ /*
+ * We will examine the first few packets
+ * of each stream to determine if there is
+ * a packet time offset.
+ */
+ pInt->pDataHdr = rm_parseri_malloc(pInt, sizeof(struct rm_data_hdr));
+ if (pInt->pDataHdr) {
+ retVal = rm_parseri_examine_initial_packets(pInt, 0);
+ if (retVal == HXR_OK) {
+ /* Create the stream headers */
+ retVal = rm_parseri_create_all_stream_headers(pInt);
+ }
+ } else {
+ retVal = HXR_OUTOFMEMORY;
+ }
+ }
+ } else {
+ pInt->ulInterleavedStreamsFlag = 0;
+ retVal = rm_parseri_setup_multirate_streams(pInt);
+ if (retVal == HXR_OK) {
+ /* Create some structures to hold stream info */
+ retVal = rm_parseri_create_stream_structures(pInt);
+ if (retVal == HXR_OK) {
+ /*
+ * We will examine the first few packets
+ * of each stream to determine if there is
+ * a packet time offset.
+ */
+ pInt->pDataHdr = rm_parseri_malloc(pInt, pInt->ulNumStreams * sizeof(struct rm_data_hdr));
+ if (pInt->pDataHdr) {
+ UINT32 j = 0;
+ for (j = 0; j < pInt->ulNumStreams; j++) {
+ retVal = rm_parseri_examine_initial_packets(pInt, j);
+ if (retVal != HXR_OK) {
+ break;
+ }
+ }
+ if (retVal == HXR_OK) {
+ /* Create the stream headers */
+ retVal = rm_parseri_create_all_stream_headers(pInt);
+ }
+ } else {
+ retVal = HXR_OUTOFMEMORY;
+ }
+ } else {
+ /*
+ * This is a surestream file which has not backwards-compatible
+ * streams, which we do not support.
+ */
+ retVal = HXR_NOT_SUPPORTED;
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal,
+ "Unsupported file (SureStream file with no "
+ "compatible streams)");
+ }
+ } else {
+ retVal = HXR_NOT_SUPPORTED;
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal,
+ "Unsupported file (SureStream file with no "
+ "compatible streams)");
+ }
+ }
+ }
+ }
+ } else {
+ /*
+ * This is a later version than we support */
+ retVal = HXR_NOT_SUPPORTED;
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal, "Unsupported file header version.");
+ }
+ }
+ } else {
+ /*
+ * The first four bytes of the file were
+ * not what we expected. This is likely not
+ * an .rm file.
+ * XXXMEH: is there a better error code for this?
+ */
+ retVal = HXR_NOT_SUPPORTED;
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal,
+ "First four bytes are are not \".RMF\" - this is not an .rm file");
+ }
+ }
+ }
+
+ return retVal;
+}
+
+UINT32 rm_parseri_get_num_file_properties(rm_parser_internal* pInt)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt) {
+ /*
+ * We always put the "StreamCount" and "Flags" properties.
+ */
+ ulRet += 2;
+ /* If we have a real datatype, then we will add "IsRealDataType" */
+ if (rm_parseri_has_real_data_type(pInt)) {
+ ulRet++;
+ }
+ /*
+ * If we have a logical-fileinfo header, we will put in
+ * all the properties in it.
+ */
+ if (pInt->pLogicalFileInfo) {
+ ulRet += pInt->pLogicalFileInfo->num_props;
+ }
+ /* Add "Title", "Author", "Copyright" if present */
+ if (pInt->contHdr.title) {
+ ulRet++;
+ }
+ if (pInt->contHdr.author) {
+ ulRet++;
+ }
+ if (pInt->contHdr.copyright) {
+ ulRet++;
+ }
+ }
+
+ return ulRet;
+}
+
+HX_RESULT rm_parseri_get_file_properties(rm_parser_internal* pInt,
+ rm_property* pProp, UINT32 ulNumProp)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pProp && ulNumProp) {
+ /* Init the counter */
+ UINT32 ulIndex = 0;
+ /* "StreamCount" property */
+ retVal = rm_parseri_set_rm_property(pInt, &pProp[ulIndex++], "StreamCount",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) pInt->ulNumStreams, 0);
+
+ if (retVal == HXR_OK) {
+ retVal = rm_parseri_set_rm_property(pInt, &pProp[ulIndex++], "Flags",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) pInt->propHdr.flags, 0);
+ }
+ if (retVal == HXR_OK &&
+ rm_parseri_has_real_data_type(pInt)) {
+ retVal = rm_parseri_set_rm_property(pInt, &pProp[ulIndex++], "IsRealDataType",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) 1, 0);
+ }
+ if (retVal == HXR_OK && pInt->contHdr.title) {
+ retVal = rm_parseri_set_rm_property(pInt, &pProp[ulIndex++], "Title",
+ RM_PROPERTY_TYPE_BUFFER,
+ (void*) pInt->contHdr.title,
+ strlen(pInt->contHdr.title) + 1);
+ }
+ if (retVal == HXR_OK && pInt->contHdr.author) {
+ retVal = rm_parseri_set_rm_property(pInt, &pProp[ulIndex++], "Author",
+ RM_PROPERTY_TYPE_BUFFER,
+ (void*) pInt->contHdr.author,
+ strlen(pInt->contHdr.author) + 1);
+ }
+ if (retVal == HXR_OK && pInt->contHdr.copyright) {
+ retVal = rm_parseri_set_rm_property(pInt, &pProp[ulIndex++], "Copyright",
+ RM_PROPERTY_TYPE_BUFFER,
+ (void*) pInt->contHdr.copyright,
+ strlen(pInt->contHdr.copyright) + 1);
+ }
+ if (pInt->pLogicalFileInfo) {
+ UINT32 i = 0;
+ for (i = 0; i < (UINT32) pInt->pLogicalFileInfo->num_props && retVal == HXR_OK; i++) {
+ struct rm_name_value_map* pMap = &pInt->pLogicalFileInfo->props[i];
+ UINT32 ulLength = pMap->value_sz;
+ if (pMap->type != RM_PROPERTY_TYPE_BUFFER) {
+ ulLength = 0;
+ }
+ retVal = rm_parseri_set_rm_property(pInt, &pProp[ulIndex++],
+ (const char*) pMap->name,
+ pMap->type, pMap->value, ulLength);
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HXBOOL rm_parseri_has_real_data_type(rm_parser_internal* pInt)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pInt) {
+ bRet = pInt->bIsRealDataType;
+ }
+
+ return bRet;
+}
+
+HX_RESULT rm_parseri_set_rm_property(rm_parser_internal* pInt, rm_property* pProp,
+ const char* pszName, UINT32 ulType,
+ void* pValue, UINT32 ulValueLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pProp && pszName) {
+ /* Cleanup the existing property */
+ rm_parseri_cleanup_rm_property(pInt, pProp);
+ /* Allocate space for the name */
+ pProp->pName = (char*) rm_parseri_malloc(pInt, strlen(pszName) + 1);
+ if (pProp->pName) {
+ /* Copy the string */
+ strcpy(pProp->pName, pszName);
+ /* Copy the type */
+ pProp->ulType = ulType;
+ /* What type is this property? */
+ switch (ulType) {
+ case RM_PROPERTY_TYPE_UINT32: {
+ pProp->pValue = pValue;
+ pProp->ulValueLen = 0;
+ retVal = HXR_OK;
+ }
+ break;
+ case RM_PROPERTY_TYPE_BUFFER: {
+ pProp->pValue = (BYTE*) rm_parseri_malloc(pInt, ulValueLen);
+ if (pProp->pValue) {
+ /* Copy the string */
+ memcpy(pProp->pValue, pValue, ulValueLen);
+ /* Assign the length */
+ pProp->ulValueLen = ulValueLen;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ break;
+ case RM_PROPERTY_TYPE_CSTRING: {
+ const char* pszValue = (const char*) pValue;
+ UINT32 ulLen = (UINT32) strlen(pszValue) + 1;
+ pProp->pValue = (BYTE*) rm_parseri_malloc(pInt, ulLen);
+ if (pProp->pValue) {
+ /* Copy the string */
+ strcpy((char*) pProp->pValue, pszValue);
+ /* Assign the length */
+ pProp->ulValueLen = ulLen;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rm_parseri_cleanup_rm_property(rm_parser_internal* pInt, rm_property* pProp)
+{
+ if (pInt && pProp) {
+ /* Free the name string */
+ if (pProp->pName) {
+ rm_parseri_free(pInt, pProp->pName);
+ pProp->pName = HXNULL;
+ }
+ /*
+ * If this is a RM_PROPERTY_TYPE_BUFFER or RM_PROPERTY_TYPE_CSTRING
+ * property, then the pValue is an allocated buffer. If this
+ * is an RM_PROPERTY_TYPE_UINT32 property, then pValue doesn't
+ * have any buffer associated with it.
+ */
+ if (pProp->pValue && pProp->ulType != RM_PROPERTY_TYPE_UINT32) {
+ rm_parseri_free(pInt, pProp->pValue);
+ pProp->pValue = HXNULL;
+ }
+ }
+}
+
+void rm_parseri_cleanup_stream_num_map(rm_parser_internal* pInt)
+{
+ if (pInt && pInt->pulStreamNumMap) {
+ rm_parseri_free(pInt, pInt->pulStreamNumMap);
+ pInt->pulStreamNumMap = HXNULL;
+ pInt->ulStreamNumMapSize = 0;
+ }
+}
+
+void rm_parseri_cleanup_stream_info(rm_parser_internal* pInt, struct rm_stream_info* pInfo)
+{
+ if (pInt) {
+ /* Free the index entry array */
+ if (pInfo->seekTable.pEntry) {
+ rm_parseri_free(pInt, pInfo->seekTable.pEntry);
+ pInfo->seekTable.pEntry = HXNULL;
+ }
+ }
+}
+
+void rm_parseri_cleanup_stream_info_array(rm_parser_internal* pInt)
+{
+ if (pInt && pInt->pStreamInfo) {
+ /* Clean up each individual stream info */
+ UINT32 i = 0;
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ rm_parseri_cleanup_stream_info(pInt, &pInt->pStreamInfo[i]);
+ }
+ /* Clean up the array */
+ rm_parseri_free(pInt, pInt->pStreamInfo);
+ pInt->pStreamInfo = HXNULL;
+ }
+}
+
+HX_RESULT rm_parseri_create_stream_structures(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->ulNumStreams) {
+ /*
+ * Compute the max stream number and the
+ * max duration across all streams.
+ */
+ UINT32 i = 0;
+ UINT32 ulSize = 0;
+ UINT32 ulMaxStreamNum = pInt->pMediaPropsHdr[0].stream_num;
+ UINT32 ulMaxDuration = pInt->pMediaPropsHdr[0].duration;
+ UINT32 ulIndexMaxEntries = RM_INDEX_MAX_ENTRIES;
+ UINT32 ulIndexTimeGranularity = ulMaxDuration / ulIndexMaxEntries;
+ for (i = 1; i < pInt->ulNumStreams; i++) {
+ if (pInt->pMediaPropsHdr[i].stream_num > ulMaxStreamNum) {
+ ulMaxStreamNum = pInt->pMediaPropsHdr[i].stream_num;
+ }
+ if (pInt->pMediaPropsHdr[i].duration > ulMaxDuration) {
+ ulMaxDuration = pInt->pMediaPropsHdr[i].duration;
+ }
+ }
+ /* Assign the max duration */
+ pInt->ulMaxDuration = ulMaxDuration;
+ /* Free any existing stream number map */
+ rm_parseri_cleanup_stream_num_map(pInt);
+ /* Allocate the stream number map */
+ pInt->ulStreamNumMapSize = ulMaxStreamNum + 1;
+ ulSize = pInt->ulStreamNumMapSize * sizeof(UINT32);
+ pInt->pulStreamNumMap = (UINT32*) rm_parseri_malloc(pInt, ulSize);
+ if (pInt->pulStreamNumMap) {
+ /* Initialize all the stream numbers in the map */
+ for (i = 0; i < pInt->ulStreamNumMapSize; i++) {
+ pInt->pulStreamNumMap[i] = RM_NO_STREAM_SET;
+ }
+ /*
+ * The stream number maps maps stream number to
+ * the index in the pMediaPropsHdr array.
+ */
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ pInt->pulStreamNumMap[pInt->pMediaPropsHdr[i].stream_num] = i;
+ }
+ /* Clean up any existing stream info array */
+ rm_parseri_cleanup_stream_info_array(pInt);
+ /* Allocate a stream info array */
+ ulSize = pInt->ulNumStreams * sizeof(struct rm_stream_info);
+ pInt->pStreamInfo = (struct rm_stream_info*) rm_parseri_malloc(pInt, ulSize);
+ if (pInt->pStreamInfo) {
+ /* Zero out the array */
+ memset(pInt->pStreamInfo, 0, ulSize);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Compute the index table parameters */
+ if (ulIndexTimeGranularity > RM_INDEX_MAX_TIME_GRANULARITY) {
+ ulIndexTimeGranularity = RM_INDEX_MAX_TIME_GRANULARITY;
+ ulIndexMaxEntries = ulMaxDuration / ulIndexTimeGranularity;
+ if (ulIndexMaxEntries > RM_INDEX_MAX_ENTRIES) {
+ ulIndexMaxEntries = RM_INDEX_MAX_ENTRIES;
+ }
+ } else if (ulIndexTimeGranularity < RM_INDEX_MIN_TIME_GRANULARITY) {
+ ulIndexTimeGranularity = RM_INDEX_MIN_TIME_GRANULARITY;
+ ulIndexMaxEntries = ulMaxDuration / ulIndexTimeGranularity;
+ if (ulIndexMaxEntries < RM_INDEX_MIN_ENTRIES) {
+ ulIndexMaxEntries = RM_INDEX_MIN_ENTRIES;
+ }
+ }
+ ulSize = ulIndexMaxEntries * sizeof(struct rm_seek_table_entry);
+ /* Initialize the stream info */
+ for (i = 0; i < pInt->ulNumStreams && retVal == HXR_OK; i++) {
+ /* Initialize the type flag */
+ if (pInt->pMediaPropsHdr[i].mime_type) {
+ const char* pszStr = (const char*) pInt->pMediaPropsHdr[i].mime_type;
+ if (rm_stream_is_realaudio_mimetype(pszStr)) {
+ pInt->pStreamInfo[i].bIsRealAudio = TRUE;
+ pInt->bIsRealDataType = TRUE;
+ } else if (rm_stream_is_realvideo_mimetype(pszStr)) {
+ pInt->pStreamInfo[i].bIsRealVideo = TRUE;
+ pInt->bIsRealDataType = TRUE;
+ } else if (rm_stream_is_realevent_mimetype(pszStr)) {
+ pInt->pStreamInfo[i].bIsRealEvent = TRUE;
+ pInt->bIsRealDataType = TRUE;
+ }
+ }
+ /* Initialize the index table */
+ pInt->pStreamInfo[i].seekTable.pEntry =
+ (struct rm_seek_table_entry*) rm_parseri_malloc(pInt, ulSize);
+ if (pInt->pStreamInfo[i].seekTable.pEntry) {
+ /* Zero out the memory */
+ memset(pInt->pStreamInfo[i].seekTable.pEntry, 0, ulSize);
+ /* Init the parameters */
+ pInt->pStreamInfo[i].seekTable.ulMaxEntries = ulIndexMaxEntries;
+ pInt->pStreamInfo[i].seekTable.ulTimeGranularity = ulIndexTimeGranularity;
+ pInt->pStreamInfo[i].seekTable.ulNumEntries = 0;
+ pInt->pStreamInfo[i].seekTable.ulLastTime = 0;
+ pInt->pStreamInfo[i].seekTable.ulRangeTime = 0;
+ } else {
+ retVal = HXR_OUTOFMEMORY;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_examine_initial_packets(rm_parser_internal* pInt, UINT32 ulStreamNum)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ struct rm_pkt_hdr hdr;
+ UINT32 ulID = 0;
+ UINT32 i = 0;
+ UINT32 j = 0;
+ /* Seek to the data offset mentioned in the properties header */
+ rm_parseri_file_seek(pInt, pInt->pMediaPropsHdr[ulStreamNum].start_offset, HX_SEEK_ORIGIN_SET);
+ /*
+ * Read the next header into the read buffer,
+ * which should be a data chunk
+ */
+ retVal = rm_parseri_read_next_header(pInt, &ulID);
+ if (retVal == HXR_OK) {
+ /* Make sure it's a data chunk */
+ if (ulID == RM_DATA_OBJECT) {
+ /* Parse the data chunk header */
+ retVal = rm_parseri_unpack_data_hdr(pInt, ulStreamNum);
+ if (retVal == HXR_OK) {
+ /* Initialize the minimum first packet timestamp */
+ pInt->ulMinFirstPacketTime = 0xFFFFFFFF;
+ /*
+ * Now we will look at the first few packet headers
+ * until either we have seen at least one packet
+ * of each stream or we have verified that the
+ * minimum timestamp across all streams is 0.
+ * We will loop as though we will look at all
+ * packets, but we will break out long before that.
+ */
+ for (i = 0; i < pInt->pDataHdr[ulStreamNum].num_pkts && retVal == HXR_OK; i++) {
+ retVal = rm_parseri_read_next_packet_header(pInt, &hdr);
+ if (retVal == HXR_OK) {
+ /* Translate the stream number */
+ UINT32 ulStreamNum = rm_parseri_translate_stream_number(pInt, hdr.stream_num);
+ if (ulStreamNum != RM_NO_STREAM_SET) {
+ /* Save the first timestamp of each stream */
+ if (!pInt->pStreamInfo[ulStreamNum].bSeenFirstPacketTimeStamp) {
+ pInt->pStreamInfo[ulStreamNum].ulLastTimeStamp = hdr.timestamp;
+ pInt->pStreamInfo[ulStreamNum].bSeenFirstPacketTimeStamp = TRUE;
+ /* Update the min first timestamp */
+ if (hdr.timestamp < pInt->ulMinFirstPacketTime) {
+ pInt->ulMinFirstPacketTime = hdr.timestamp;
+ }
+ }
+ /* Check if we've seen the first timestamp of all streams */
+ for (j = 0; j < pInt->ulNumStreams; j++) {
+ if (!pInt->pStreamInfo[ulStreamNum].bSeenFirstPacketTimeStamp) {
+ break;
+ }
+ }
+ /*
+ * Stop if we've seen a packet from each stream
+ * or if we've already seen a timestamp of 0.
+ */
+ if (j == pInt->ulNumStreams || pInt->ulMinFirstPacketTime == 0) {
+ /* Re-init the last timestamp for each stream */
+ for (j = 0; j < pInt->ulNumStreams; j++) {
+ pInt->pStreamInfo[j].ulLastTimeStamp = 0xFFFFFFFF;
+ pInt->pStreamInfo[j].ulLastRule = 0;
+ }
+ /* Seek back to right after the data chunk header */
+ rm_parseri_file_seek(pInt,
+ pInt->pMediaPropsHdr[ulStreamNum].start_offset +
+ RM_PARSER_DATA_CHUNK_HEADER_SIZE,
+ HX_SEEK_ORIGIN_SET);
+ /* Break out of the packet loop */
+ break;
+ } else {
+ /*
+ * We need to keep reading packets, so
+ * seek past the data of this packet.
+ */
+ rm_parseri_file_seek(pInt,
+ hdr.length - hdr.header_len,
+ HX_SEEK_ORIGIN_CUR);
+ }
+ } else {
+ retVal = HXR_INVALID_FILE;
+ }
+ }
+ }
+ }
+ } else {
+ retVal = HXR_INVALID_FILE;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_unpack_data_hdr(rm_parser_internal* pInt, UINT32 DataNum)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ if (ulLen >= RM_PARSER_DATA_CHUNK_HEADER_SIZE) {
+ /* Unpack the rm_data_hdr */
+ pInt->pDataHdr[DataNum].id = rm_unpack32(&pBuf, &ulLen);
+ pInt->pDataHdr[DataNum].size = rm_unpack32(&pBuf, &ulLen);
+ pInt->pDataHdr[DataNum].version = rm_unpack16(&pBuf, &ulLen);
+ pInt->pDataHdr[DataNum].num_pkts = rm_unpack32(&pBuf, &ulLen);
+ pInt->pDataHdr[DataNum].next_data_hdr = rm_unpack32(&pBuf, &ulLen);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_unpack_pkt_hdr(rm_parser_internal* pInt,
+ struct rm_pkt_hdr* pPktHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ if (ulLen >= RM_PARSER_PACKET_HEADER_SIZE) {
+ /* Unpack the rm_pkt_hdr */
+ pPktHdr->version = rm_unpack16(&pBuf, &ulLen);
+ pPktHdr->length = rm_unpack16(&pBuf, &ulLen);
+ pPktHdr->stream_num = rm_unpack16(&pBuf, &ulLen);
+ pPktHdr->timestamp = rm_unpack32(&pBuf, &ulLen);
+ pPktHdr->flags = rm_unpack16(&pBuf, &ulLen);
+ if (pPktHdr->version == 1) {
+ rm_parseri_file_read(pInt, 1, 0);
+ pPktHdr->header_len = 13;
+ if (pPktHdr->flags == 0) {
+ pPktHdr->flags = 2;
+ }
+ } else {
+ pPktHdr->header_len = 12;
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_unpack_index_hdr(rm_parser_internal* pInt,
+ struct rm_index_hdr* hdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && hdr) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ if (ulLen >= RM_PARSER_INDEX_HEADER_SIZE) {
+ /* Unpack the rm_index_hdr */
+ hdr->id = rm_unpack32(&pBuf, &ulLen);
+ hdr->size = rm_unpack32(&pBuf, &ulLen);
+ hdr->version = rm_unpack16(&pBuf, &ulLen);
+ hdr->num_recs = rm_unpack32(&pBuf, &ulLen);
+ hdr->stream_num = rm_unpack16(&pBuf, &ulLen);
+ hdr->next_index_hdr = rm_unpack32(&pBuf, &ulLen);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_unpack_index_rec(rm_parser_internal* pInt,
+ struct rm_index_rec* rec)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && rec) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ if (ulLen >= RM_PARSER_INDEX_RECORD_SIZE) {
+ /* Unpack the rm_index_rec */
+ rec->version = rm_unpack16(&pBuf, &ulLen);
+ rec->timestamp = rm_unpack32(&pBuf, &ulLen);
+ rec->offset = rm_unpack32(&pBuf, &ulLen);
+ rec->num_pkts = rm_unpack32(&pBuf, &ulLen);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_read_next_index_rec(rm_parser_internal* pInt,
+ struct rm_index_rec* rec)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && rec) {
+ UINT32 ulNumBytesRead = 0;
+ /* Change the error return */
+ retVal = HXR_READ_ERROR;
+ /* Read the packet header into the read buffer */
+ ulNumBytesRead = rm_parseri_file_read(pInt, RM_PARSER_INDEX_RECORD_SIZE, 0);
+ if (ulNumBytesRead == RM_PARSER_INDEX_RECORD_SIZE) {
+ /* Unpack the packet header */
+ retVal = rm_parseri_unpack_index_rec(pInt, rec);
+ }
+ }
+
+ return retVal;
+}
+
+UINT32 rm_parseri_translate_stream_number(rm_parser_internal* pInt, UINT32 ulNum)
+{
+ UINT32 ulRet = RM_NO_STREAM_SET;
+
+ if (pInt && pInt->pulStreamNumMap && ulNum < pInt->ulStreamNumMapSize) {
+ ulRet = pInt->pulStreamNumMap[ulNum];
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parseri_get_stream_number(rm_parser_internal* pInt, UINT32 ulNum)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt && pInt->pulStreamNumMap) {
+ for (ulRet = 0; ulRet < pInt->ulStreamNumMapSize; ulRet++) {
+ if (pInt->pulStreamNumMap[ulRet] == ulNum) {
+ return ulRet;
+ }
+ }
+ }
+ ulRet = RM_NO_STREAM_SET;
+ return ulRet;
+}
+
+HX_RESULT rm_parseri_create_all_stream_headers(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->ulNumStreams) {
+ UINT32 i = 0;
+ UINT32 ulSize = 0;
+ /* Clean up any existing stream headers */
+ rm_parseri_cleanup_all_stream_headers(pInt);
+ /* Allocate memory for the stream header array */
+ ulSize = pInt->ulNumStreams * sizeof(rm_stream_header);
+ pInt->pStreamHdr = (rm_stream_header*) rm_parseri_malloc(pInt, ulSize);
+ if (pInt->pStreamHdr) {
+ /* NULL out the memory */
+ memset(pInt->pStreamHdr, 0, ulSize);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Create all stream headers */
+ for (i = 0; i < pInt->ulNumStreams && retVal == HXR_OK; i++) {
+ retVal = rm_parseri_create_stream_header(pInt, i, &pInt->pStreamHdr[i]);
+ }
+ }
+ }
+ return retVal;
+}
+
+HX_RESULT rm_parseri_create_stream_header(rm_parser_internal* pInt, UINT32 i, rm_stream_header* hdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pMediaPropsHdr && i < pInt->ulNumStreams && hdr) {
+ UINT32 ulNumProps = 0;
+ UINT32 ulSize = 0;
+ /*
+ * Count the number of properties. Passing in
+ * HXNULL and 0 means just count and don't set
+ * the properties
+ */
+ ulNumProps = rm_parseri_count_set_stream_header_props(pInt, i, hdr,
+ HXNULL, 0);
+ if (ulNumProps) {
+ /* Compute the size of the array */
+ ulSize = ulNumProps * sizeof(rm_property);
+ /* Allocate the array */
+ hdr->pProperty = (rm_property*) rm_parseri_malloc(pInt, ulSize);
+ if (hdr->pProperty) {
+ /* NULL out the array */
+ memset(hdr->pProperty, 0, ulSize);
+ /* Set the number of properties */
+ hdr->ulNumProperties = ulNumProps;
+ /* Call again, but this time pass in array */
+ rm_parseri_count_set_stream_header_props(pInt, i, hdr,
+ hdr->pProperty,
+ hdr->ulNumProperties);
+ /*
+ * Now set the properties for which we
+ * have dedicated convenience members. These
+ * are also duplicated in the rm_property array.
+ */
+ hdr->ulStreamNumber = i;
+ hdr->ulMaxBitRate = pInt->pMediaPropsHdr[i].max_bit_rate;
+ hdr->ulAvgBitRate = pInt->pMediaPropsHdr[i].avg_bit_rate;
+ hdr->ulMaxPacketSize = pInt->pMediaPropsHdr[i].max_pkt_size;
+ hdr->ulAvgPacketSize = pInt->pMediaPropsHdr[i].avg_pkt_size;
+ hdr->ulDuration = pInt->pMediaPropsHdr[i].duration;
+ hdr->ulPreroll = pInt->pMediaPropsHdr[i].preroll;
+ hdr->ulStartTime = pInt->pMediaPropsHdr[i].start_time;
+ hdr->ulStartOffset = pInt->pMediaPropsHdr[i].start_offset;
+ if (pInt->ulInterleavedStreamsFlag) {
+ hdr->ulStreamSize = pInt->pDataHdr->size;
+ } else {
+ hdr->ulStreamSize = pInt->pDataHdr[i].size;
+ }
+ hdr->pMimeType = copy_string(pInt->pUserMem, pInt->fpMalloc,
+ (const char*) pInt->pMediaPropsHdr[i].mime_type);
+ hdr->pStreamName = copy_string(pInt->pUserMem, pInt->fpMalloc,
+ (const char*) pInt->pMediaPropsHdr[i].stream_name);
+ hdr->pOpaqueData = copy_buffer(pInt->pUserMem, pInt->fpMalloc,
+ pInt->pMediaPropsHdr[i].type_spec,
+ pInt->pMediaPropsHdr[i].type_spec_sz);
+ hdr->ulOpaqueDataLen = pInt->pMediaPropsHdr[i].type_spec_sz;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ return retVal;
+}
+
+void rm_parseri_cleanup_all_stream_headers(rm_parser_internal* pInt)
+{
+ if (pInt && pInt->pStreamHdr) {
+ /* Free the memory associated with each stream header */
+ UINT32 i = 0;
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ rm_parseri_cleanup_stream_header(pInt, &pInt->pStreamHdr[i]);
+ }
+ /* Free the memory for the array */
+ rm_parseri_free(pInt, pInt->pStreamHdr);
+ /* NULL out the pointer */
+ pInt->pStreamHdr = HXNULL;
+ }
+}
+
+void rm_parseri_cleanup_stream_header(rm_parser_internal* pInt, rm_stream_header* hdr)
+{
+ if (pInt && hdr) {
+ /* Free the mime type string */
+ if (hdr->pMimeType) {
+ rm_parseri_free(pInt, hdr->pMimeType);
+ hdr->pMimeType = HXNULL;
+ }
+ /* Free the stream name string */
+ if (hdr->pStreamName) {
+ rm_parseri_free(pInt, hdr->pStreamName);
+ hdr->pStreamName = HXNULL;
+ }
+ /* Free the opaque data buffer */
+ if (hdr->pOpaqueData) {
+ rm_parseri_free(pInt, hdr->pOpaqueData);
+ hdr->pOpaqueData = HXNULL;
+ hdr->ulOpaqueDataLen = 0;
+ }
+ /* Do we have any properties? */
+ if (hdr->pProperty) {
+ /* Clean up each individual rm_property */
+ UINT32 i = 0;
+ for (i = 0; i < hdr->ulNumProperties; i++) {
+ rm_parseri_cleanup_rm_property(pInt, &hdr->pProperty[i]);
+ }
+ /* Free the memory for the property array */
+ rm_parseri_free(pInt, hdr->pProperty);
+ /* Null out the pointer */
+ hdr->pProperty = HXNULL;
+ hdr->ulNumProperties = 0;
+ }
+ }
+}
+
+void rm_parseri_cleanup_all_data_headers(rm_parser_internal* pInt)
+{
+ if (pInt && pInt->pDataHdr) {
+ rm_parseri_free(pInt, pInt->pDataHdr);
+ pInt->pDataHdr = HXNULL;
+ }
+}
+
+UINT32 rm_parseri_count_set_stream_header_props(rm_parser_internal* pInt, UINT32 i,
+ rm_stream_header* hdr,
+ rm_property* pProp, UINT32 ulNumProps)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt && i < pInt->ulNumStreams && hdr) {
+ /* Initialize some local variables used later */
+ UINT32 ulDuration = pInt->pMediaPropsHdr[i].duration;
+ UINT32 ulPreroll = pInt->pMediaPropsHdr[i].preroll;
+ UINT32 ulStreamingPreroll = 0;
+ UINT32 ulOldPreroll = 0;
+ UINT32 ulPreDecBufSize = 0;
+ UINT32 ulPreDecBufTime = 0;
+ HXDOUBLE dPreDecBufSize = 0.0;
+ HXBOOL bIsVBR = (pInt->pMediaPropsHdr[i].max_bit_rate !=
+ pInt->pMediaPropsHdr[i].avg_bit_rate ? TRUE : FALSE);
+ HXBOOL bHasPreDataProps = FALSE;
+ HXDOUBLE dPreData = 0.0;
+ UINT32 ulPreData = 0;
+ char* pASMRuleBook = HXNULL;
+ BYTE* pBuf = HXNULL;
+ UINT32 ulLen = 0;
+ BYTE ucRuleToFlag[8];
+ /* Set/count the "StreamNumber" property */
+
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "StreamNumber",
+ RM_PROPERTY_TYPE_UINT32, (void*) i, 0);
+ }
+ ulRet++;
+ /* Set/count the "MaxBitRate" property */
+ if (pInt->pMediaPropsHdr[i].max_bit_rate) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "MaxBitRate",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) pInt->pMediaPropsHdr[i].max_bit_rate, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "AvgBitRate" property */
+ if (pInt->pMediaPropsHdr[i].avg_bit_rate) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "AvgBitRate",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) pInt->pMediaPropsHdr[i].avg_bit_rate, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "MaxPacketSize" property */
+ if (pInt->pMediaPropsHdr[i].max_pkt_size) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "MaxPacketSize",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) pInt->pMediaPropsHdr[i].max_pkt_size, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "AvgPacketSize" property */
+ if (pInt->pMediaPropsHdr[i].avg_pkt_size) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "AvgPacketSize",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) pInt->pMediaPropsHdr[i].avg_pkt_size, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "StartTime" property */
+ if (pInt->pMediaPropsHdr[i].start_time) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "StartTime",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) pInt->pMediaPropsHdr[i].start_time, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "MimeType" property */
+ if (pInt->pMediaPropsHdr[i].mime_type) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "MimeType",
+ RM_PROPERTY_TYPE_CSTRING,
+ (void*) pInt->pMediaPropsHdr[i].mime_type, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "StreamName" property */
+ if (pInt->pMediaPropsHdr[i].stream_name) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "StreamName",
+ RM_PROPERTY_TYPE_CSTRING,
+ (void*) pInt->pMediaPropsHdr[i].stream_name, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "OpaqueData" property */
+ if (pInt->pMediaPropsHdr[i].type_spec) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "OpaqueData",
+ RM_PROPERTY_TYPE_BUFFER,
+ (void*) pInt->pMediaPropsHdr[i].type_spec,
+ pInt->pMediaPropsHdr[i].type_spec_sz);
+ }
+ ulRet++;
+ }
+ /* Set/count the "intrinsicDurationType" property */
+ if (pInt->pStreamInfo[i].bIsRealAudio ||
+ pInt->pStreamInfo[i].bIsRealVideo ||
+ pInt->pStreamInfo[i].bIsRealEvent) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "intrinsicDurationType",
+ RM_PROPERTY_TYPE_CSTRING,
+ (void*) "intrinsicDurationContinuous", 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "EndTime" property */
+ if (pInt->pMediaPropsHdr[i].duration > pInt->propHdr.duration) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "EndTime",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) pInt->propHdr.duration, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "EndOneRuleEndAll" property */
+ if (pInt->pStreamInfo[i].bIsRealAudio ||
+ pInt->pStreamInfo[i].bIsRealVideo) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "EndOneRuleEndAll",
+ RM_PROPERTY_TYPE_UINT32, (void*) 1, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "CanBeStoppedAnyTime" property */
+ if (pInt->pStreamInfo[i].bIsRealEvent) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "CanBeStoppedAnyTime",
+ RM_PROPERTY_TYPE_UINT32, (void*) 1, 0);
+ }
+ ulRet++;
+ }
+ /* Do some adjustments to duration */
+ if (pInt->pStreamInfo[i].bIsRealEvent) {
+ /*
+ * If this is an event stream, then set the stream duration
+ * to the maximum duration across all streams.
+ */
+ ulDuration = pInt->ulMaxDuration;
+ }
+ /* Subtract off the min first packet time */
+ if (ulDuration > pInt->ulMinFirstPacketTime) {
+ ulDuration -= pInt->ulMinFirstPacketTime;
+ }
+ /* Set/count the "Duration" property */
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "Duration",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) ulDuration, 0);
+ }
+ ulRet++;
+ /* Do some adjustments to preroll values */
+ if (pInt->pStreamInfo[i].bIsRealAudio) {
+ /* Save the preroll */
+ ulOldPreroll = ulPreroll;
+ /*
+ * RealAudio streams need to have 2 superblocks as the preroll value.
+ * Encoders put one superblock duration as the preroll.
+ */
+ ulPreroll = (ulPreroll ? ulPreroll * 2 : 6000);
+ }
+ if (pInt->pStreamInfo[i].bIsRealVideo ||
+ pInt->pStreamInfo[i].bIsRealAudio) {
+ /* Compute the pre-decode buffer size */
+ if (pInt->pStreamInfo[i].bIsRealVideo) {
+ /* For VBR stream, the PreDecBufTime is the same as the actual preroll */
+ if (bIsVBR) {
+ ulPreDecBufTime = ulPreroll;
+ }
+ /*
+ * If actual preroll is less than 1 sec, set preroll
+ * and PreDecBufTime to 1 sec more than ActualPreroll
+ */
+ if (ulPreroll < 1000) {
+ if (ulOldPreroll == 0) {
+ ulOldPreroll = ulPreroll;
+ }
+ ulPreroll += 1000;
+ if (!bIsVBR) {
+ ulPreDecBufTime = ulPreroll;
+ }
+ } else if (!bIsVBR) {
+ /*
+ * Otherwise for CBR set the PreDecBufTime to
+ * twice the actual preroll
+ */
+ ulPreDecBufTime = ulPreroll * 2;
+ }
+ /* Now compute pre-decode buffer size, rounding up */
+ dPreDecBufSize = (((HXDOUBLE) ulPreDecBufTime) *
+ ((HXDOUBLE) pInt->pMediaPropsHdr[i].max_bit_rate) +
+ 7999.0) / 8000.0;
+ ulPreDecBufSize = (UINT32) dPreDecBufSize;
+ }
+ /*
+ * Cap the preroll at 5000 ms.
+ * XXXMEH - this assumes local playback
+ */
+ if (ulPreroll > 5000) {
+ if (!ulOldPreroll) {
+ ulOldPreroll = ulPreroll;
+ }
+ ulStreamingPreroll = ulPreroll;
+ ulPreroll = 5000;
+ }
+ }
+ /* Set/count the "Preroll" property */
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "Preroll",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) ulPreroll, 0);
+ }
+ ulRet++;
+ /* Set/count the "ActualPreroll" property */
+ if (ulOldPreroll) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "ActualPreroll",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) ulOldPreroll, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "StreamingPreroll" property */
+ if (ulStreamingPreroll) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "StreamingPreroll",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) ulStreamingPreroll, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "X-PreDecBufSize" property */
+ if (ulPreDecBufSize) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "X-PreDecBufSize",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) ulPreDecBufSize, 0);
+ }
+ ulRet++;
+ }
+ /* Create the ASM rule book string */
+ pASMRuleBook = rm_parseri_create_asm_rulebook(pInt,
+ pInt->pStreamInfo[i].bIsRealVideo,
+ pInt->pStreamInfo[i].bIsRealEvent,
+ (pInt->pMediaPropsHdr[i].type_spec_sz ? TRUE : FALSE),
+ pInt->pMediaPropsHdr[i].max_bit_rate,
+ pInt->pMediaPropsHdr[i].avg_bit_rate,
+ &bHasPreDataProps);
+ if (pASMRuleBook) {
+ /* Set/count the "ASMRuleBook" property */
+ if (pProp) {
+ /* Set it into the property */
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "ASMRuleBook",
+ RM_PROPERTY_TYPE_CSTRING,
+ (void*) pASMRuleBook, 0);
+ }
+ ulRet++;
+ }
+ /* Free the string */
+ free_string(pInt->pUserMem, pInt->fpFree, &pASMRuleBook);
+ /* Set/count the pre-data related properties */
+ if (bHasPreDataProps) {
+ dPreData = ((HXDOUBLE) ulPreroll) *
+ ((HXDOUBLE) pInt->pMediaPropsHdr[i].max_bit_rate) /
+ 8000.0;
+ ulPreData = (UINT32)(dPreData + 0.5);
+ if (ulPreData) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "PreData",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) ulPreData, 0);
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet + 1], "PreDataAtStart",
+ RM_PROPERTY_TYPE_UINT32, (void*) 1, 0);
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet + 2], "PreDataAfterSeek",
+ RM_PROPERTY_TYPE_UINT32, (void*) 1, 0);
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet + 3], "PrerollAfterSeek",
+ RM_PROPERTY_TYPE_UINT32, (void*) 1, 0);
+ }
+ ulRet += 4;
+ }
+ }
+ /* Set/count the "RMFF 1.0 Flags" property */
+ if (pInt->pStreamInfo[i].bIsRealVideo ||
+ pInt->pStreamInfo[i].bIsRealEvent ||
+ pInt->pMediaPropsHdr[i].type_spec_sz) {
+ if (pProp) {
+ if (pInt->pStreamInfo[i].bIsRealVideo) {
+ /*
+ * For video streams, we will set 3 rules. Rule 0
+ * is a keyframe rule, rule 1 is a non-keyframe rule,
+ * and rule 2 is a keyframe (thinning) rule.
+ */
+ BYTE* pBuf = &ucRuleToFlag[0];
+ UINT32 ulLen = 8;
+ rm_pack16(3, &pBuf, &ulLen);
+ rm_pack16(HX_KEYFRAME_FLAG, &pBuf, &ulLen);
+ rm_pack16(0, &pBuf, &ulLen);
+ rm_pack16(HX_KEYFRAME_FLAG, &pBuf, &ulLen);
+ /* Set the property */
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "RMFF 1.0 Flags",
+ RM_PROPERTY_TYPE_BUFFER,
+ (void*) &ucRuleToFlag[0], 8);
+ } else if (pInt->pStreamInfo[i].bIsRealEvent ||
+ pInt->pMediaPropsHdr[i].type_spec_sz) {
+ /*
+ * For non-video streams, we will set 2 rules. Rule 0
+ * is a keyframe rule, rule 1 is a non-keyframe rule.
+ */
+ BYTE* pBuf = &ucRuleToFlag[0];
+ UINT32 ulLen = 8;
+ rm_pack16(2, &pBuf, &ulLen);
+ rm_pack16(HX_KEYFRAME_FLAG, &pBuf, &ulLen);
+ rm_pack16(0, &pBuf, &ulLen);
+ /* Set the property */
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "RMFF 1.0 Flags",
+ RM_PROPERTY_TYPE_BUFFER,
+ (void*) &ucRuleToFlag[0], 6);
+ }
+ }
+ ulRet++;
+ }
+ }
+ return ulRet;
+}
+
+char* rm_parseri_create_asm_rulebook(rm_parser_internal* pInt, HXBOOL bIsRealVideo,
+ HXBOOL bIsRealEvent, HXBOOL bHasOpaqueData,
+ UINT32 ulMaxBitRate, UINT32 ulAvgBitRate,
+ HXBOOL* pbHasPreDataProps)
+{
+ char* pRet = HXNULL;
+
+ if (pInt && pbHasPreDataProps) {
+ HXBOOL bIsVBR = (ulMaxBitRate != ulAvgBitRate ? TRUE : FALSE);
+ /* Allocate the output buffer */
+ pRet = (char*) rm_parseri_malloc(pInt, RM_PARSER_RULE_BOOK_BUFFER_SIZE);
+ if (pRet) {
+ /* Is this a RealVideo stream? */
+ if (bIsRealVideo) {
+ /* Is this VBR? */
+ if (bIsVBR) {
+ if (ulMaxBitRate) {
+ /* VBR RealVideo with max_bit_rate != 0 */
+ strcpy(pRet, g_pszRuleBook[0]);//, 9, ulAvgBitRate, ulMaxBitRate, 5);
+ } else {
+ /* VBR RealVideo with max_bit_rate == 0 */
+ strcpy(pRet, g_pszRuleBook[1]);//, 9, ulAvgBitRate, 5);
+ }
+ /* Set the PreData flag */
+ *pbHasPreDataProps = TRUE;
+ } else {
+ /* CBR video */
+ strcpy(pRet, g_pszRuleBook[5]);//, ulAvgBitRate, ulAvgBitRate,
+ // ulAvgBitRate, ulAvgBitRate);
+ }
+ } else if (bIsRealEvent || bHasOpaqueData) {
+ /* This is most likely an event or audio stream */
+ if (bIsRealEvent) {
+ /* RealEvent stream */
+ strcpy(pRet, g_pszRuleBook[6]);
+ } else if (bIsVBR) {
+ /* Most likely an audio stream */
+ if (ulMaxBitRate) {
+ /* VBR RealAudio with max_bit_rate != 0 */
+ strcpy(pRet, g_pszRuleBook[0]);//, 5, ulAvgBitRate, ulMaxBitRate, 5);
+ } else {
+ /* VBR RealAudio with max_bit_rate == 0 */
+ strcpy(pRet, g_pszRuleBook[1]);//, 5, ulAvgBitRate, 5);
+ }
+ /* Set the PreData flag */
+ *pbHasPreDataProps = TRUE;
+ } else {
+ /* CBR RealAudio */
+ strcpy(pRet, g_pszRuleBook[7]);//, ulAvgBitRate);
+ }
+ } else {
+ /* Non-RealAudio/RealVideo/RealEvent streams */
+ if (bIsVBR) {
+ if (ulMaxBitRate) {
+ strcpy(pRet, g_pszRuleBook[2]);//, ulAvgBitRate, ulMaxBitRate);
+ } else if (ulAvgBitRate) {
+ strcpy(pRet, g_pszRuleBook[3]);//, ulAvgBitRate);
+ } else {
+ strcpy(pRet, g_pszRuleBook[4]);
+ }
+ } else {
+ /* CBR Non-RealAudio/RealVideo/RealEvent streams */
+ strcpy(pRet, g_pszRuleBook[8]);//, ulAvgBitRate);
+ }
+ }
+ }
+ }
+
+ return pRet;
+}
+
+HX_RESULT rm_parseri_read_next_packet(rm_parser_internal* pInt, rm_packet** ppPacket)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && ppPacket) {
+ /* Make sure we're still in the range of the data chunk */
+ if (pInt->ulCurFileOffset < pInt->pMediaPropsHdr[pInt->ulCurrentStream].start_offset + pInt->pDataHdr[pInt->ulCurrentStream].size) {
+ /* More packets to go - read the next one */
+ struct rm_pkt_hdr hdr;
+ rm_packet* pPacket = HXNULL;
+ UINT32 ulStreamNum = 0;
+ UINT32 ulASMRule = 0;
+ UINT32 ulASMFlags = 0;
+ UINT32 ulLastPacketTime = 0;
+ UINT32 ulLastRule = 0;
+ UINT32 ulBytesRead = 0;
+ UINT32 ulDataSize = 0;
+ UINT32 ulPacketOffset = 0;
+ HXBOOL bSkipPacket = FALSE;
+ do {
+ retVal = rm_parseri_read_next_packet_header(pInt, &hdr);
+ if (retVal == HXR_OK) {
+ /* Assume the worst */
+ retVal = HXR_FAIL;
+ /* Translate the stream number */
+ ulStreamNum = rm_parseri_translate_stream_number(pInt, hdr.stream_num);
+ if (ulStreamNum != RM_NO_STREAM_SET) {
+ /* Get the rm_stream_info for this stream */
+ struct rm_stream_info* pInfo = &pInt->pStreamInfo[ulStreamNum];
+ if (pInfo) {
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Are we currently looking for keyframes? */
+ if (pInt->ulKeyframesNeeded) {
+ /*
+ * Is this a keyframe, and do we need a keyframe
+ * for this stream?
+ */
+ if (!pInfo->bNeedKeyframe ||
+ ((hdr.flags & HX_KEYFRAME_FLAG) &&
+ (!pInfo->keyFramePacket.bValid ||
+ hdr.timestamp >= pInfo->keyFramePacket.ulTimestamp))) {
+ if (pInfo->bNeedKeyframe) {
+ pInfo->bNeedKeyframe = FALSE;
+ pInt->ulKeyframesNeeded--;
+ }
+ bSkipPacket = FALSE;
+ } else {
+ /*
+ * We need keyframes for this stream and
+ * this is not a keyframe.
+ */
+ bSkipPacket = TRUE;
+ /* Seek past the data of this packet */
+ rm_parseri_file_seek(pInt,
+ hdr.length - hdr.header_len,
+ HX_SEEK_ORIGIN_CUR);
+ }
+ } else {
+ bSkipPacket = FALSE;
+ }
+ }
+ } else {
+ /* Got a stream number we didn't expect */
+ retVal = HXR_CORRUPT_FILE;
+ /* Call back to error interface */
+ rm_parseri_error(pInt, retVal, "Unexpected stream number in packet.");
+ }
+ }
+ } while (HX_SUCCEEDED(retVal) && bSkipPacket);
+ /* Have we found a packet? */
+ if (HX_SUCCEEDED(retVal)) {
+ /* Get the last packet time and rule for this stream */
+ ulLastPacketTime = pInt->pStreamInfo[ulStreamNum].ulLastTimeStamp;
+ ulLastRule = pInt->pStreamInfo[ulStreamNum].ulLastRule;
+ /* Determine the ASM rules and flags */
+ if (pInt->pStreamInfo[ulStreamNum].bIsRealVideo) {
+ /*
+ * If the time stamp for this packet is different from
+ * the timestamp of the next packet and either this packet
+ * is a keyframe or the last packet was a keyframe we can
+ * switch on this packet
+ */
+ if (hdr.timestamp != ulLastPacketTime &&
+ (hdr.flags & HX_KEYFRAME_FLAG ||
+ ulLastRule == HX_KEYFRAME_RULE ||
+ ulLastRule == HX_THINNING_RULE)) {
+ ulASMFlags = HX_ASM_SWITCH_ON | HX_ASM_SWITCH_OFF;
+ } else if (hdr.timestamp != ulLastPacketTime) {
+ /* If this is part of a different frame, we can switch off */
+ ulASMFlags = HX_ASM_SWITCH_OFF;
+ } else {
+ /*
+ * If this packet has the same timestamp as the previous
+ * packet we cannot switch on or switch off here.
+ */
+ ulASMFlags = 0;
+ }
+ /* Assign the ASM rule */
+ ulASMRule = (hdr.flags & HX_KEYFRAME_FLAG ? HX_KEYFRAME_RULE : HX_NONKEYFRAME_RULE);
+ } else if (pInt->pStreamInfo[ulStreamNum].bIsRealAudio) {
+ /*
+ * For audio, the first block of the super block and the second block
+ * of the super block are ON since the first block and the second block
+ * are the first packets on their respective rule numbers
+ */
+ if (hdr.flags & HX_KEYFRAME_FLAG || ulLastRule == HX_KEYFRAME_RULE) {
+ ulASMFlags = HX_ASM_SWITCH_ON | HX_ASM_SWITCH_OFF;
+ } else {
+ ulASMFlags = HX_ASM_SWITCH_OFF;
+ }
+ /* Assign the ASM rule */
+ ulASMRule = (hdr.flags & HX_KEYFRAME_FLAG ? HX_KEYFRAME_RULE : HX_NONKEYFRAME_RULE);
+ } else {
+ /* Assign the ASM flags */
+ ulASMFlags = HX_ASM_SWITCH_OFF;
+ ulASMFlags |= (hdr.flags & HX_KEYFRAME_FLAG ? HX_ASM_SWITCH_ON : 0);
+ /* Is this an event stream or file version 0? */
+ if (pInt->pStreamInfo[ulStreamNum].bIsRealEvent ||
+ pInt->fileHdr.file_version == 0) {
+ ulASMRule = (hdr.flags & HX_KEYFRAME_FLAG ? HX_KEYFRAME_RULE : HX_NONKEYFRAME_RULE);
+ } else {
+ /*
+ * In case of non-RM streams version 1 or later, the rule
+ * number is recorded directly into the upper 8 bits of the
+ * flags field (packet_group)
+ */
+ ulASMRule = (UINT32)((hdr.flags >> 8) & 0x00FF);
+ }
+ }
+ /* Set the return value */
+ retVal = HXR_OUTOFMEMORY;
+ /* Allocate space for the rm_packet */
+ pPacket = (rm_packet*) rm_parseri_malloc(pInt, sizeof(rm_packet));
+ if (pPacket) {
+ /* NULL out the packet */
+ memset(pPacket, 0, sizeof(rm_packet));
+ /* Compute the data size */
+ ulDataSize = hdr.length - hdr.header_len;
+ /* Allocate space for the data */
+ pPacket->pData = (BYTE*) rm_parseri_malloc(pInt, ulDataSize);
+ if (pPacket->pData) {
+ /* Read the data into the buffer */
+ ulBytesRead = rm_parseri_file_read_buffer(pInt, pPacket->pData, ulDataSize);
+ if (ulBytesRead == ulDataSize) {
+ /* Assign the packet parameters */
+ pPacket->ulTime = hdr.timestamp;
+ pPacket->usStream = (UINT16) ulStreamNum;
+ pPacket->usASMFlags = (UINT16) ulASMFlags;
+ pPacket->ucASMRule = (BYTE) ulASMRule;
+ pPacket->ucLost = FALSE;
+ pPacket->usDataLen = (UINT16) ulDataSize;
+ /* Update the last timestamp and rule */
+ pInt->pStreamInfo[ulStreamNum].ulLastTimeStamp = hdr.timestamp;
+ pInt->pStreamInfo[ulStreamNum].ulLastRule = ulASMRule;
+ /* Compute the file offset of this packet */
+ ulPacketOffset = pInt->ulCurFileOffset -
+ ulDataSize - hdr.header_len;
+ /* Update the seek table */
+ rm_parseri_update_seek_table(pInt,
+ ulStreamNum,
+ hdr.timestamp,
+ ulPacketOffset,
+ hdr.flags);
+ /* Assign the out parameter */
+ *ppPacket = pPacket;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ } else {
+ /* Could not read packet data */
+ retVal = HXR_READ_ERROR;
+ /* Call back to error interface */
+ rm_parseri_error(pInt, retVal, "Could not read packet data.");
+ }
+ }
+ if (retVal != HXR_OK) {
+ /* Free the packet data */
+ if (pPacket->pData) {
+ rm_parseri_free(pInt, pPacket->pData);
+ pPacket->pData = HXNULL;
+ }
+ /* Free the packet */
+ rm_parseri_free(pInt, pPacket);
+ pPacket = HXNULL;
+ }
+ }
+ }
+ } else {
+ /* We are finished reading packets from this chunk */
+ retVal = HXR_AT_END;
+ }
+ }
+
+ return retVal;
+}
+
+UINT32 rm_parseri_file_read(rm_parser_internal* pInt, UINT32 ulBytesToRead, UINT32 ulReadBufferOffset)
+{
+ UINT32 ulRet = 0;
+ // DataSrc_t *ds = pInt->pUserRead;
+ UINT8 err;
+
+ if (pInt && pInt->fpRead) {
+ /* Make sure our read buffer is big enough */
+ HX_RESULT rv = rm_enforce_buffer_min_size(pInt->pUserMem,
+ pInt->fpMalloc,
+ pInt->fpFree,
+ &pInt->pReadBuffer,
+ &pInt->ulReadBufferSize,
+ ulReadBufferOffset + ulBytesToRead);
+ if (rv == HXR_OK) {
+ // if (ds&&ds->streaming_sem)
+ // AVMutexPend(ds->streaming_sem, 0, &err);
+ /* Seek the file */
+ pInt->fpSeek(pInt->pUserRead, pInt->ulCurFileOffset, HX_SEEK_ORIGIN_SET);
+ /* Read in ulBytesToRead bytes */
+ ulRet = pInt->fpRead(pInt->pUserRead,
+ pInt->pReadBuffer + ulReadBufferOffset,
+ ulBytesToRead);
+ /* Save the number of bytes in read buffer */
+ pInt->ulNumBytesRead = ulRet + ulReadBufferOffset;
+ /* Advance the current file offset */
+ pInt->ulCurFileOffset += ulRet;
+ // if (ds&&ds->streaming_sem)
+ // AVMutexPost(ds->streaming_sem);
+ }
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parseri_file_read_buffer(rm_parser_internal* pInt, BYTE* pBuf, UINT32 ulBytesToRead)
+{
+ UINT32 ulRet = 0;
+ // DataSrc_t *ds = pInt->pUserRead;
+ UINT8 err;
+
+ if (pInt && pInt->fpRead) {
+ // if (ds&&ds->streaming_sem)
+ // AVMutexPend(ds->streaming_sem, 0, &err);
+ /* Seek the file */
+ pInt->fpSeek(pInt->pUserRead, pInt->ulCurFileOffset, HX_SEEK_ORIGIN_SET);
+ /* Read in ulBytesToRead bytes */
+ ulRet = pInt->fpRead(pInt->pUserRead, pBuf, ulBytesToRead);
+ /* Advance the current file offset */
+ pInt->ulCurFileOffset += ulRet;
+ // if (ds&&ds->streaming_sem)
+ // AVMutexPost(ds->streaming_sem);
+ }
+
+ return ulRet;
+}
+
+void rm_parseri_file_seek(rm_parser_internal* pInt, UINT32 ulOffset, UINT32 ulOrigin)
+{
+ if (pInt && pInt->fpSeek) {
+ /* Seek the file */
+ pInt->fpSeek(pInt->pUserRead, ulOffset, ulOrigin);
+ /* Update the current file offset */
+ if (ulOrigin == HX_SEEK_ORIGIN_SET) {
+ pInt->ulCurFileOffset = ulOffset;
+ } else if (ulOrigin == HX_SEEK_ORIGIN_CUR) {
+ pInt->ulCurFileOffset += ulOffset;
+ } else if (ulOrigin == HX_SEEK_ORIGIN_END) {
+ /*
+ * XXXMEH - don't know file size, so not sure what to do here.
+ * We could require ftell-like functionality, or we could
+ * require some type of fstat-like functionality.
+ */
+ rm_parseri_error(pInt, HXR_NOT_SUPPORTED, "File seek with end origin attempted - not suported.");
+ }
+ }
+}
+
+void rm_parseri_set_stream_size(rm_parser_internal* pInt, UINT32 stream_size)
+{
+ if (pInt) {
+ UINT32 i = 0;
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ if (pInt->pStreamHdr[i].ulStreamSize == RM_PARSER_DATA_CHUNK_HEADER_SIZE) {
+ pInt->pStreamHdr[i].ulStreamSize = stream_size;
+ }
+ if (pInt->pDataHdr[i].size == RM_PARSER_DATA_CHUNK_HEADER_SIZE) {
+ pInt->pDataHdr[i].size = stream_size;
+ }
+ }
+ }
+}
+
+HX_RESULT rm_parseri_copy_stream_header(rm_parser_internal* pInt, UINT32 i, rm_stream_header* pHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pHdr && i < pInt->ulNumStreams && pInt->pStreamHdr) {
+ UINT32 j = 0;
+ UINT32 ulSize = 0;
+ /* Clean up any existing header */
+ rm_parseri_cleanup_stream_header(pInt, pHdr);
+ /* Copy the hard-coded members */
+ pHdr->ulStreamNumber = pInt->pStreamHdr[i].ulStreamNumber;
+ pHdr->ulMaxBitRate = pInt->pStreamHdr[i].ulMaxBitRate;
+ pHdr->ulAvgBitRate = pInt->pStreamHdr[i].ulAvgBitRate;
+ pHdr->ulMaxPacketSize = pInt->pStreamHdr[i].ulMaxPacketSize;
+ pHdr->ulAvgPacketSize = pInt->pStreamHdr[i].ulAvgPacketSize;
+ pHdr->ulDuration = pInt->pStreamHdr[i].ulDuration;
+ pHdr->ulPreroll = pInt->pStreamHdr[i].ulPreroll;
+ pHdr->ulStartTime = pInt->pStreamHdr[i].ulStartTime;
+ pHdr->ulStartOffset = pInt->pStreamHdr[i].ulStartOffset;
+ pHdr->ulStreamSize = pInt->pStreamHdr[i].ulStreamSize;
+ pHdr->pMimeType = copy_string(pInt->pUserMem, pInt->fpMalloc,
+ pInt->pStreamHdr[i].pMimeType);
+ pHdr->pStreamName = copy_string(pInt->pUserMem, pInt->fpMalloc,
+ pInt->pStreamHdr[i].pStreamName);
+ pHdr->pOpaqueData = copy_buffer(pInt->pUserMem, pInt->fpMalloc,
+ pInt->pStreamHdr[i].pOpaqueData,
+ pInt->pStreamHdr[i].ulOpaqueDataLen);
+ if ((!pInt->pStreamHdr[i].pMimeType || pHdr->pMimeType) &&
+ (!pInt->pStreamHdr[i].pStreamName || pHdr->pStreamName) &&
+ (!pInt->pStreamHdr[i].pOpaqueData || pHdr->pOpaqueData)) {
+ /* Copy the properties array */
+ if (pInt->pStreamHdr[i].ulNumProperties &&
+ pInt->pStreamHdr[i].pProperty) {
+ /* Allocate space for the property array */
+ ulSize = pInt->pStreamHdr[i].ulNumProperties * sizeof(rm_property);
+ pHdr->pProperty = (rm_property*) rm_parseri_malloc(pInt, ulSize);
+ if (pHdr->pProperty) {
+ /* NULL out the array */
+ memset(pHdr->pProperty, 0, ulSize);
+ /* Copy each of the properties */
+ retVal = HXR_OK;
+ for (j = 0; j < pInt->pStreamHdr[i].ulNumProperties && retVal == HXR_OK; j++) {
+ retVal = rm_parseri_set_rm_property(pInt, &pHdr->pProperty[j],
+ pInt->pStreamHdr[i].pProperty[j].pName,
+ pInt->pStreamHdr[i].pProperty[j].ulType,
+ (void*) pInt->pStreamHdr[i].pProperty[j].pValue,
+ pInt->pStreamHdr[i].pProperty[j].ulValueLen);
+ }
+ if (retVal == HXR_OK) {
+ /* Assign the number of properties */
+ pHdr->ulNumProperties = pInt->pStreamHdr[i].ulNumProperties;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_update_seek_table(rm_parser_internal* pInt, UINT32 ulStreamNum,
+ UINT32 ulTime, UINT32 ulOffset, UINT32 ulFlags)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pStreamInfo && ulStreamNum < pInt->ulNumStreams) {
+ struct rm_seek_table* pTable = &pInt->pStreamInfo[ulStreamNum].seekTable;
+ if (pTable) {
+ /* Was this a keyframe packet? */
+ if (ulFlags & HX_KEYFRAME_FLAG) {
+ /* Do we have space left in the table? */
+ if (pTable->pEntry && pTable->ulNumEntries < pTable->ulMaxEntries) {
+ /*
+ * If this is the first entry; or if this
+ * time is at least ulTimeGranularity greater
+ * than the last time added, then make an entry.
+ */
+ if (!pTable->ulNumEntries ||
+ (ulTime > pTable->ulLastTime &&
+ ulTime - pTable->ulLastTime > pTable->ulTimeGranularity)) {
+ /* Update the last time */
+ pTable->ulLastTime = ulTime;
+ /* Update the time range this table covers */
+ if (ulTime > pTable->ulRangeTime) {
+ pTable->ulRangeTime = ulTime;
+ }
+ /* Make the new entry */
+ pTable->pEntry[pTable->ulNumEntries].ulTime = ulTime;
+ pTable->pEntry[pTable->ulNumEntries].ulOffset = ulOffset;
+ /* Increment the number of entries */
+ pTable->ulNumEntries++;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ } else {
+ /*
+ * This is not a keyframe, so we don't have to
+ * make an entry in the table, but we do need to
+ * update the time range that it covers.
+ */
+ if (ulTime > pTable->ulRangeTime) {
+ pTable->ulRangeTime = ulTime;
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_update_time_range(rm_parser_internal* pInt, UINT32 ulStreamNum,
+ UINT32 ulTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pStreamInfo && ulStreamNum < pInt->ulNumStreams) {
+ /* Get the seek table for this stream */
+ struct rm_seek_table* pTable = &pInt->pStreamInfo[ulStreamNum].seekTable;
+ if (pTable) {
+ /* Update the time range this table covers */
+ if (ulTime > pTable->ulRangeTime) {
+ pTable->ulRangeTime = ulTime;
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_search_all_seek_tables(rm_parser_internal* pInt, UINT32 ulSeekTime,
+ UINT32* pulFoundTime, UINT32* pulFoundOffset)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pulFoundTime && pulFoundOffset &&
+ pInt->ulNumStreams && pInt->pStreamInfo) {
+ /* Initialize local variables */
+ UINT32 ulMaxTime = 0;
+ UINT32 ulMaxOffset = 0;
+ UINT32 i = 0;
+ UINT32 pulFoundIndex;
+ HX_RESULT status = HXR_FAIL;
+ /* Search the streams */
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ /* Get the stream info struct */
+ struct rm_stream_info* pInfo = &pInt->pStreamInfo[i];
+ if (pInfo) {
+ status = rm_parseri_search_seek_table(&pInfo->seekTable,
+ ulSeekTime,
+ 0,
+ &pInfo->keyFramePacket.ulTimestamp,
+ &pInfo->keyFramePacket.ulFileOffset,
+ &pulFoundIndex);
+ if (status == HXR_OK) {
+ pInfo->keyFramePacket.bValid = TRUE;
+ if (pInfo->keyFramePacket.ulTimestamp > ulMaxTime) {
+ ulMaxTime = pInfo->keyFramePacket.ulTimestamp;
+ }
+ if (pInfo->keyFramePacket.ulFileOffset > ulMaxOffset) {
+ ulMaxOffset = pInfo->keyFramePacket.ulFileOffset;
+ }
+ }
+ /*
+ * If at least one stream succeeds, the overall search
+ * succeeds. Note that rm_parseri_search_seek_table() can
+ * return either HXR_AT_END or HXR_OK, both of which
+ * return HX_SUCCEEDED() == TRUE. That's why we have to
+ * specifically check for status == HXR_OK, as opposed
+ * to just HX_SUCCEEDED(status).
+ */
+ if (HX_FAILED(retVal) ||
+ (HX_SUCCEEDED(retVal) && status == HXR_OK)) {
+ retVal = status;
+ }
+ }
+ }
+ if (HX_SUCCEEDED(retVal)) {
+ *pulFoundTime = ulMaxTime;
+ *pulFoundOffset = ulMaxOffset;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_search_seek_tables(rm_parser_internal* pInt, INT32 lStreamNumber, UINT32 ulSeekTime, INT32 lDirection,
+ UINT32* pulFoundTime, UINT32* pulFoundOffset, UINT32* pulFoundIndex)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pulFoundTime && pulFoundOffset &&
+ pInt->ulNumStreams && pInt->pStreamInfo) {
+ /* Initialize local variables */
+ UINT32 ulMinTime = 0xffffffff;
+ UINT32 ulMinOffset = 0xffffffff;
+ UINT32 i = 0;
+ HX_RESULT status = HXR_FAIL;
+ struct rm_stream_info* pInfo = &pInt->pStreamInfo[lStreamNumber];
+ /* Search the streams */
+ {
+ /* Get the stream info struct */
+ if (pInfo) {
+ retVal = rm_parseri_search_seek_table(&pInfo->seekTable,
+ ulSeekTime,
+ lDirection,
+ &pInfo->keyFramePacket.ulTimestamp,
+ &pInfo->keyFramePacket.ulFileOffset,
+ pulFoundIndex);
+ if (retVal == HXR_OK) {
+ pInfo->keyFramePacket.bValid = TRUE;
+ }
+ }
+ }
+ if (retVal == HXR_OK) {
+ *pulFoundTime = pInfo->keyFramePacket.ulTimestamp;
+ *pulFoundOffset = pInfo->keyFramePacket.ulFileOffset;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_search_seek_table(struct rm_seek_table* pTable, UINT32 ulSeekTime, INT32 lDirection,
+ UINT32* pulFoundTime, UINT32* pulFoundOffset, UINT32 *pulFoundIndex)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pTable && pulFoundTime && pulFoundOffset && pTable->ulNumEntries) {
+ /* Estimate index to seek from */
+ UINT32 ulTableIdx = ulSeekTime / pTable->ulTimeGranularity;
+ /*
+ * If we've over-estimated, set the index at the
+ * last entry in the table.
+ */
+ if (ulTableIdx >= pTable->ulNumEntries) {
+ ulTableIdx = pTable->ulNumEntries - 1;
+ }
+ /* Scan forward in the table */
+ while (((ulTableIdx + 1) < (pTable->ulNumEntries - 1)) &&
+ (pTable->pEntry[ulTableIdx + 1].ulTime < ulSeekTime)) {
+ ulTableIdx++;
+ }
+ /* Scan backwards in the table */
+ while ((ulTableIdx > 0) &&
+ (pTable->pEntry[ulTableIdx].ulTime > ulSeekTime)) {
+ ulTableIdx--;
+ }
+ if (lDirection) {
+ if ((lDirection > 0) && (ulTableIdx < pTable->ulNumEntries - 1)) {
+ ulTableIdx++;
+ } else if ((lDirection < 0) && (ulTableIdx > 0)) {
+ ulTableIdx--;
+ }
+ }
+ /* Report results */
+ *pulFoundTime = pTable->pEntry[ulTableIdx].ulTime;
+ *pulFoundOffset = pTable->pEntry[ulTableIdx].ulOffset;
+ /* Set the return value */
+ retVal = (ulSeekTime > pTable->ulRangeTime ? HXR_AT_END : HXR_OK);
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_search_index_chunk(rm_parser_internal* pInt, UINT32 ulSeekTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->propHdr.index_offset && pInt->pStreamInfo &&
+ pInt->ulNumStreams) {
+ /* Initialize local variables */
+ struct rm_index_hdr hdr;
+ struct rm_index_rec rec;
+ UINT32 ulChunkID = 0;
+ UINT32 ulStreamNum = 0;
+ UINT32 i = 0;
+ UINT32 ulIndexOffset = pInt->propHdr.index_offset;
+ /* Mark all keyframe packets as invalid */
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ pInt->pStreamInfo[i].keyFramePacket.bValid = FALSE;
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Loop through all the index chunks */
+ while (HX_SUCCEEDED(retVal) &&
+ ulIndexOffset &&
+ !rm_parseri_is_all_keyframes_found(pInt)) {
+ /* Seek the file to the next index chunk */
+ rm_parseri_file_seek(pInt, ulIndexOffset, HX_SEEK_ORIGIN_SET);
+ /* Read the index header */
+ retVal = rm_parseri_read_next_header(pInt, &ulChunkID);
+ if (retVal == HXR_OK) {
+ /* Assume the worst */
+ retVal = HXR_FAIL;
+ /* Make sure this is an INDX header */
+ if (ulChunkID == RM_INDEX_OBJECT) {
+ /* Parse the index header */
+ retVal = rm_parseri_unpack_index_hdr(pInt, &hdr);
+ if (retVal == HXR_OK) {
+ /*
+ * Translate the stream number. If the
+ * stream number doesn't translate, then
+ * we will not consider it an error - we'll
+ * just go on to the next index chunk.
+ */
+ ulStreamNum = rm_parseri_translate_stream_number(pInt, hdr.stream_num);
+ if (ulStreamNum != RM_NO_STREAM_SET) {
+ /* Get the rm_keyframe_packet struct */
+ struct rm_keyframe_packet* pKey =
+ &pInt->pStreamInfo[ulStreamNum].keyFramePacket;
+ /* Read all the index records in this chunk */
+ for (i = 0; i < hdr.num_recs && retVal == HXR_OK; i++) {
+ retVal = rm_parseri_read_next_index_rec(pInt, &rec);
+ if (retVal == HXR_OK) {
+ /*
+ * Set this record into the on-the-fly
+ * seek table.
+ */
+ rm_parseri_update_seek_table(pInt,
+ ulStreamNum,
+ rec.timestamp,
+ rec.offset,
+ HX_KEYFRAME_FLAG);
+ /*
+ * Is the timestamp of the record
+ * greater than or equal to the seek time?
+ */
+ if (rec.timestamp >= ulSeekTime) {
+ /* Do we have a valid keyframe for this stream? */
+ if (!pKey->bValid) {
+ pKey->bValid = TRUE;
+ pKey->ulFileOffset = rec.offset;
+ pKey->ulTimestamp = rec.timestamp;
+ }
+ /*
+ * Now we can stop looking at index records
+ * for this stream
+ */
+ break;
+ } else {
+ /* Save the keyframe info */
+ pKey->bValid = TRUE;
+ pKey->ulFileOffset = rec.offset;
+ pKey->ulTimestamp = rec.timestamp;
+ }
+ }
+ }
+ }
+ /*
+ * Set the next index header. If there are
+ * no more index chunks, next_index_hdr will
+ * be zero.
+ */
+ ulIndexOffset = hdr.next_index_hdr;
+ }
+ }
+ }
+ }
+ /* Find the first keyframe */
+ if (HX_SUCCEEDED(retVal)) {
+ retVal = rm_parseri_find_first_keyframe(pInt);
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_build_seek_table(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ // not support seek without Interleaved Streams now
+ if (pInt->ulInterleavedStreamsFlag == 0) {
+ return HXR_FAIL;
+ }
+
+ if (pInt && pInt->propHdr.index_offset && pInt->pStreamInfo &&
+ pInt->ulNumStreams) {
+ /* Initialize local variables */
+ struct rm_index_hdr hdr;
+ struct rm_index_rec rec;
+ UINT32 ulChunkID = 0;
+ UINT32 ulStreamNum = 0;
+ UINT32 i = 0;
+ UINT32 ulIndexOffset = pInt->propHdr.index_offset;
+ /* Mark all keyframe packets as invalid */
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ pInt->pStreamInfo[i].keyFramePacket.bValid = FALSE;
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Loop through all the index chunks */
+ while (HX_SUCCEEDED(retVal) &&
+ ulIndexOffset &&
+ !rm_parseri_is_all_keyframes_found(pInt)) {
+ /* Seek the file to the next index chunk */
+ rm_parseri_file_seek(pInt, ulIndexOffset, HX_SEEK_ORIGIN_SET);
+ /* Read the index header */
+ retVal = rm_parseri_read_next_header(pInt, &ulChunkID);
+ if (retVal == HXR_OK) {
+ /* Assume the worst */
+ retVal = HXR_FAIL;
+ /* Make sure this is an INDX header */
+ if (ulChunkID == RM_INDEX_OBJECT) {
+ /* Parse the index header */
+ retVal = rm_parseri_unpack_index_hdr(pInt, &hdr);
+ if (retVal == HXR_OK) {
+ /*
+ * Translate the stream number. If the
+ * stream number doesn't translate, then
+ * we will not consider it an error - we'll
+ * just go on to the next index chunk.
+ */
+ ulStreamNum = rm_parseri_translate_stream_number(pInt, hdr.stream_num);
+ if (ulStreamNum != RM_NO_STREAM_SET) {
+ /* Get the rm_keyframe_packet struct */
+ struct rm_keyframe_packet* pKey =
+ &pInt->pStreamInfo[ulStreamNum].keyFramePacket;
+ /* Read all the index records in this chunk */
+ for (i = 0; i < hdr.num_recs && retVal == HXR_OK; i++) {
+ retVal = rm_parseri_read_next_index_rec(pInt, &rec);
+ if (retVal == HXR_OK) {
+ /*
+ * Set this record into the on-the-fly
+ * seek table.
+ */
+ rm_parseri_update_seek_table(pInt,
+ ulStreamNum,
+ rec.timestamp,
+ rec.offset,
+ HX_KEYFRAME_FLAG);
+ {
+ /* Save the keyframe info */
+ pKey->bValid = TRUE;
+ pKey->ulFileOffset = rec.offset;
+ pKey->ulTimestamp = rec.timestamp;
+ }
+ }
+ }
+ }
+ /*
+ * Set the next index header. If there are
+ * no more index chunks, next_index_hdr will
+ * be zero.
+ */
+ ulIndexOffset = hdr.next_index_hdr;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_seek(rm_parser_internal* pInt, UINT32 ulSeekTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->ulNumStreams && pInt->pStreamInfo) {
+ /* Initialize local variables */
+ UINT32 i = 0;
+ HX_RESULT status = HXR_OK;
+ UINT32 ulFoundTime = 0;
+ UINT32 ulDataOffset = 0;
+ /* Clear out stream state */
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ pInt->pStreamInfo[i].bStreamDone = FALSE;
+ pInt->pStreamInfo[i].ulLastTimeStamp = 0xFFFFFFFF;
+ pInt->pStreamInfo[i].keyFramePacket.bValid = FALSE;
+ }
+ /* First we try to search the on-the-fly seek table */
+ status = rm_parseri_search_all_seek_tables(pInt, ulSeekTime,
+ &ulFoundTime, &ulDataOffset);
+ if (status == HXR_OK) {
+ retVal = rm_parseri_find_first_packet_after_seek_time(pInt,
+ ulSeekTime,
+ ulDataOffset);
+ } else if (pInt->propHdr.index_offset && ulSeekTime) {
+ /*
+ * Try to find the offset via the index chunks
+ * at the end of the file
+ */
+ retVal = rm_parseri_search_index_chunk(pInt, ulSeekTime);
+ } else if (status == HXR_AT_END) {
+ /*
+ * The on-the-fly seek table returned HXR_AT_END,
+ * which means the seek time was past it's range,
+ * so it returned the last entry it had in the table.
+ * If we can't use the index table at the end of the
+ * file, then we'll use this - it's better than starting
+ * at the beginning of the data chunk.
+ */
+ retVal = rm_parseri_find_first_packet_after_seek_time(pInt,
+ ulSeekTime,
+ ulDataOffset);
+ } else {
+ /*
+ * Compute the offset of the first packet
+ * after the data chunk.
+ */
+ ulDataOffset = pInt->propHdr.data_offset +
+ RM_PARSER_DATA_CHUNK_HEADER_SIZE;
+ /* Seek from the beginning of the data chunk */
+ retVal = rm_parseri_find_first_packet_after_seek_time(pInt,
+ ulSeekTime,
+ ulDataOffset);
+ }
+ }
+
+ return retVal;
+}
+
+HXBOOL rm_parseri_is_all_keyframes_found(rm_parser_internal* pInt)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pInt && pInt->ulNumStreams && pInt->pStreamInfo) {
+ /* Init local variables */
+ UINT32 i = 0;
+ /* Assume we have found all of them */
+ bRet = TRUE;
+ /* Look through all streams */
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ if (!pInt->pStreamInfo[i].keyFramePacket.bValid) {
+ bRet = FALSE;
+ break;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+HXBOOL rm_parseri_is_a_keyframe_found(rm_parser_internal* pInt)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pInt && pInt->ulNumStreams && pInt->pStreamInfo) {
+ /* Init local variables */
+ UINT32 i = 0;
+ /* Look through all streams */
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ if (pInt->pStreamInfo[i].keyFramePacket.bValid) {
+ bRet = TRUE;
+ break;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+HX_RESULT rm_parseri_find_first_packet_after_seek_time(rm_parser_internal* pInt,
+ UINT32 ulSeekTime,
+ UINT32 ulInitialOffset)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ UINT32 ulStreamNum = 0;
+ UINT32 ulOffset = 0;
+ struct rm_pkt_hdr hdr;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Seek to the initial offset */
+ rm_parseri_file_seek(pInt, ulInitialOffset, HX_SEEK_ORIGIN_SET);
+ /*
+ * Read packet headers until we find one
+ * which is greater than or equal to the seek time.
+ */
+ while (HX_SUCCEEDED(retVal)) {
+ /* Read the next packet header */
+ retVal = rm_parseri_read_next_packet_header(pInt, &hdr);
+ if (HX_SUCCEEDED(retVal)) {
+ /* Compute the offset of this packet */
+ ulOffset = pInt->ulCurFileOffset - hdr.header_len;
+ /*
+ * Is the timestamp of this packet greater
+ * than or equal to the seek time?
+ */
+ if (hdr.timestamp >= ulSeekTime) {
+ /* We're finished. */
+ retVal = rm_parseri_find_first_keyframe(pInt);
+ break;
+ } else {
+ /* Assume the worst */
+ retVal = HXR_FAIL;
+ /* Get the stream num */
+ ulStreamNum = rm_parseri_translate_stream_number(pInt, hdr.stream_num);
+ if (ulStreamNum != RM_NO_STREAM_SET) {
+ /* Get the rm_keyframe_packet struct for this stream */
+ struct rm_keyframe_packet* pKey = &pInt->pStreamInfo[ulStreamNum].keyFramePacket;
+ if (pKey) {
+ if (hdr.flags & HX_KEYFRAME_FLAG) {
+ if (!pKey->bValid || hdr.timestamp > pKey->ulTimestamp) {
+ /* Save the keyframe info */
+ pKey->ulTimestamp = hdr.timestamp;
+ pKey->ulFileOffset = ulOffset;
+ pKey->bValid = TRUE;
+ /* Update the on-the-fly index table */
+ rm_parseri_update_seek_table(pInt,
+ ulStreamNum,
+ hdr.timestamp,
+ ulOffset,
+ hdr.flags);
+ }
+ } else {
+ rm_parseri_update_time_range(pInt,
+ ulStreamNum,
+ hdr.timestamp);
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ /*
+ * If we've succeeded and we're not done,
+ * then seek to the next packet header.
+ */
+ if (HX_SUCCEEDED(retVal)) {
+ rm_parseri_file_seek(pInt,
+ hdr.length - hdr.header_len,
+ HX_SEEK_ORIGIN_CUR);
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_find_first_keyframe(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pStreamInfo && pInt->ulNumStreams) {
+ UINT32 ulLowOffset = 0;
+ UINT32 ulLowStream = 0;
+ UINT32 ulNumValid = 0;
+ UINT32 i = 0;
+ /*
+ * Mark the number of keyframes needed as
+ * the number of streams.
+ */
+ pInt->ulKeyframesNeeded = pInt->ulNumStreams;
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ pInt->pStreamInfo[i].bNeedKeyframe = TRUE;
+ }
+ /* Find the lowest offset of the valid keyframes */
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ if (pInt->pStreamInfo[i].bNeedKeyframe &&
+ pInt->pStreamInfo[i].keyFramePacket.bValid) {
+ /* Increment the number of valid keyframes */
+ ulNumValid++;
+ /* Find the lowest keyframe time and stream */
+ if (!ulLowOffset ||
+ pInt->pStreamInfo[i].keyFramePacket.ulFileOffset < ulLowOffset) {
+ ulLowOffset = pInt->pStreamInfo[i].keyFramePacket.ulFileOffset;
+ ulLowStream = i;
+ }
+ }
+ }
+ /* Did we find any valid keyframes? */
+ if (ulNumValid) {
+ /* Seek to the lowest offset */
+ rm_parseri_file_seek(pInt, ulLowOffset, HX_SEEK_ORIGIN_SET);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ } else {
+ /* Clear the number of keyframes needed */
+ pInt->ulKeyframesNeeded = 0;
+ }
+ }
+
+ return retVal;
+}
+
+void* rm_parseri_malloc(rm_parser_internal* pInt, UINT32 ulSize)
+{
+ void* pRet = HXNULL;
+ if (pInt && pInt->fpMalloc) {
+ pRet = pInt->fpMalloc(pInt->pUserMem, ulSize);
+ }
+ return pRet;
+}
+
+void rm_parseri_free(rm_parser_internal* pInt, void* pMem)
+{
+ if (pInt && pInt->fpFree) {
+ pInt->fpFree(pInt->pUserMem, pMem);
+ }
+}
+
+void rm_parseri_error(rm_parser_internal* pInt, HX_RESULT err, const char* pszMsg)
+{
+ if (pInt && pInt->fpError) {
+ pInt->fpError(pInt->pUserError, err, pszMsg);
+ }
+}
diff --git a/audio_codec/libcook/rm_parser_internal.h b/audio_codec/libcook/rm_parser_internal.h
new file mode 100644
index 0000000..df76def
--- a/dev/null
+++ b/audio_codec/libcook/rm_parser_internal.h
@@ -0,0 +1,420 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_parser_internal.h,v 1.2.2.1 2005/05/04 18:21:36 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_PARSER_INTERNAL_H
+#define RM_PARSER_INTERNAL_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+#include "rm_error.h"
+#include "rm_parse.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* Defines */
+#define RM_HEADER_OBJECT 0x2E524D46 /* '.RMF' */
+#define RM_PROPERTIES_OBJECT 0x50524F50 /* 'PROP' */
+#define RM_MEDIA_PROPERTIES_OBJECT 0x4D445052 /* 'MDPR' */
+#define RM_CONTENT_OBJECT 0x434F4E54 /* 'CONT' */
+#define RM_DATA_OBJECT 0x44415441 /* 'DATA' */
+#define RM_INDEX_OBJECT 0x494E4458 /* 'INDX' */
+#define RM_MULTIHEADER_OBJECT 0x4D4C5449 /* 'MLTI' */
+
+#define RM_NO_STREAM_SET 0xFFFFFFFF
+#define RM_INDEX_MIN_ENTRIES 32
+#define RM_INDEX_MAX_ENTRIES 2048
+#define RM_INDEX_MIN_TIME_GRANULARITY 50 /* in milliseconds */
+#define RM_INDEX_MAX_TIME_GRANULARITY 15000 /* in milliseconds */
+
+ /*
+ * We explicitly define the size for structs
+ * to be read. That's because we can't use sizeof()
+ * to determine how much to read since struct
+ * alignment will make that value different.
+ */
+#define RM_PARSER_GENERIC_HDR_SIZE 10
+#define RM_PARSER_INDEX_HEADER_SIZE 20
+#define RM_PARSER_INDEX_RECORD_SIZE 14
+#define RM_PARSER_PACKET_HEADER_SIZE 12
+#define RM_PARSER_DATA_CHUNK_HEADER_SIZE 18
+
+ /* generic header -- most headers start like this */
+ struct rm_generic_hdr {
+ UINT32 id; /* unique identifier for this header */
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ };
+
+ /* rm file header -- all real media files start with this header */
+ struct rm_file_hdr {
+ UINT32 id; /* unique identifier for this header */
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ UINT32 file_version; /* revision number for realmedia file */
+ UINT32 num_headers; /* num headers in file (including this one) */
+ };
+
+ /* rm properties header -- summarizes data for entire clip */
+ struct rm_properties_hdr {
+ UINT32 id; /* unique identifier for this header */
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ UINT32 max_bit_rate; /* maximum bit rate of clip */
+ UINT32 avg_bit_rate; /* average bit rate of clip */
+ UINT32 max_pkt_size; /* max length of packet in clip (bytes) */
+ UINT32 avg_pkt_size; /* averge length of packet in clip (bytes) */
+ UINT32 num_pkts; /* total packets in clip (all streams) */
+ UINT32 duration; /* duration of clip (milliseconds) */
+ UINT32 preroll; /* preroll time (milliseconds) */
+ UINT32 index_offset; /* offset to beginning of index data */
+ UINT32 data_offset; /* offset to beginning of packet data */
+ UINT16 num_streams; /* total number of streams in clip */
+ UINT32 flags; /* various and sundry */
+ };
+
+ /* rm content header -- title, author, copyright */
+ struct rm_content_hdr {
+ UINT32 id; /* unique identifier for this header */
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ UINT16 title_sz; /* length of title field */
+ char* title; /* title of clip */
+ UINT16 author_sz; /* length of author field */
+ char* author; /* author of clip */
+ UINT16 copyright_sz; /* length of copyright field */
+ char* copyright; /* copyright of clip */
+ UINT16 comment_sz; /* length of comment field */
+ char* comment; /* comment */
+ };
+
+ /* rm media properties header -- stream info, one for each stream */
+ struct rm_media_props_hdr {
+ UINT32 id; /* unique identifier for this header */
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ UINT16 stream_num; /* stream number */
+ UINT32 max_bit_rate; /* maximum bit rate of stream */
+ UINT32 avg_bit_rate; /* average bit rate of stream */
+ UINT32 max_pkt_size; /* max length of packet in stream (bytes) */
+ UINT32 avg_pkt_size; /* averge length of packet in stream (bytes) */
+ UINT32 start_time; /* start time of stream -- clip relative */
+ UINT32 preroll; /* preroll time (milliseconds) */
+ UINT32 duration; /* duration of stream (milliseconds) */
+ BYTE stream_name_sz; /* length of stream_name field */
+ char* stream_name; /* string name of stream */
+ BYTE mime_type_sz; /* length of mime_type field */
+ char* mime_type; /* MIME type of stream */
+ UINT32 type_spec_sz; /* length of type_spec field */
+ BYTE* type_spec; /* type specific data buffer */
+ UINT32 start_offset; /* for non-interleaved stream only */
+ };
+
+ /* rm name value header -- implements name/value pairs */
+ struct rm_name_value_map {
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ BYTE name_sz; /* length of name field */
+ char* name; /* name of property */
+ UINT32 type; /* type of property */
+ UINT16 value_sz; /* length of value field */
+ BYTE* value; /* value of property */
+ };
+
+ /* rm logical stream header -- used for surestream */
+ struct rm_logical_stream_hdr {
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ UINT16 num_physical_streams; /* number of actual streams */
+ UINT16* physical_stream_num; /* array of stream numbers */
+ UINT32* data_offsets; /* array of offsets to stream packets */
+ UINT16 num_rules; /* number of ASM rules */
+ UINT16* rule_stream_map; /* maps rules to streams */
+ UINT16 num_props; /* number of name value properties */
+ struct rm_name_value_map* props; /* array of name value properties */
+ };
+
+ /* rm meta information -- clip meta data */
+ struct rm_meta_data_hdr {
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ UINT16 num_props; /* number of name value properties */
+ struct rm_name_value_map* props; /* array of name value properties */
+ };
+
+ /* rm data header -- this occurs before the start of packet data */
+ struct rm_data_hdr {
+ UINT32 id; /* unique identifier for this header */
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ UINT32 num_pkts; /* total number of packets in segment */
+ UINT32 next_data_hdr; /* offset of next segment */
+ };
+
+ /* rm index header -- this occurs before the start of index data */
+ struct rm_index_hdr {
+ UINT32 id; /* unique identifier for this header */
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ UINT32 num_recs; /* number of index records */
+ UINT16 stream_num; /* stream number being indexed */
+ UINT32 next_index_hdr; /* offset of next header */
+ };
+
+ /* rm index record -- describes an index entry */
+ struct rm_index_rec {
+ UINT16 version; /* record version */
+ UINT32 timestamp; /* packet timestamp */
+ UINT32 offset; /* offset of packet in file */
+ UINT32 num_pkts; /* number of packets before this one in clip */
+ };
+
+ /* rm packet header */
+ struct rm_pkt_hdr_base {
+ UINT16 version; /* struct version */
+ UINT16 length; /* length of header */
+ };
+
+ struct rm_pkt_hdr {
+ UINT16 version; /* struct version */
+ UINT16 length; /* length of header */
+ UINT16 stream_num; /* stream number */
+ UINT32 timestamp; /* packet timestamp */
+ UINT16 flags; /* keyframe, etc. */
+ BYTE header_len;
+ };
+
+ struct rm_pkt_hdr1 {
+ UINT16 version; /* struct version */
+ UINT16 length; /* length of header */
+ UINT16 stream_num; /* stream number */
+ UINT32 timestamp; /* packet timestamp */
+ UINT16 asm_rule; /* for surestream */
+ BYTE asm_flags;
+ };
+
+ /*
+ * Internal struct which tracks stream info
+ */
+ struct rm_seek_table_entry {
+ UINT32 ulTime;
+ UINT32 ulOffset;
+ };
+
+ struct rm_seek_table {
+ struct rm_seek_table_entry* pEntry;
+ UINT32 ulMaxEntries;
+ UINT32 ulNumEntries;
+ UINT32 ulLastTime;
+ UINT32 ulRangeTime;
+ UINT32 ulTimeGranularity;
+ };
+
+ struct rm_keyframe_packet {
+ UINT32 ulTimestamp;
+ UINT32 ulFileOffset;
+ HXBOOL bValid;
+ };
+
+ struct rm_stream_info {
+ UINT32 ulLastTimeStamp;
+ UINT32 ulLastRule;
+ struct rm_keyframe_packet keyFramePacket;
+ struct rm_seek_table seekTable;
+ HX_BITFIELD bIsRealAudio : 1;
+ HX_BITFIELD bIsRealVideo : 1;
+ HX_BITFIELD bIsRealEvent : 1;
+ HX_BITFIELD bStreamDone : 1;
+ HX_BITFIELD bNeedKeyframe : 1;
+ HX_BITFIELD bSeenFirstPacketTimeStamp : 1;
+ };
+
+ /*
+ * Parser struct
+ */
+ typedef struct rm_parser_internal_struct {
+ rm_error_func_ptr fpError;
+ void* pUserError;
+ rm_malloc_func_ptr fpMalloc;
+ rm_free_func_ptr fpFree;
+ void* pUserMem;
+ rm_read_func_ptr fpRead;
+ rm_seek_func_ptr fpSeek;
+ void* pUserRead;
+ struct rm_file_hdr fileHdr;
+ struct rm_properties_hdr propHdr;
+ struct rm_content_hdr contHdr;
+ UINT32 ulNumStreams;
+ UINT32 ulNumMediaPropsHdrs;
+ UINT32 ulNumMediaPropsHdrsAlloc;
+ struct rm_media_props_hdr* pMediaPropsHdr;
+ UINT32 ulNumLogicalStreamHdrs;
+ struct rm_logical_stream_hdr* pLogicalStreamHdr;
+ struct rm_logical_stream_hdr* pLogicalFileInfo;
+ BYTE* pReadBuffer; /* Read buffer */
+ UINT32 ulReadBufferSize; /* Allocated size of the read buffer */
+ UINT32 ulNumBytesRead; /* Current number of bytes read into the buffer */
+ UINT32 ulCurFileOffset; /* Current read offset into the file */
+ UINT32 ulStreamNumMapSize;
+ UINT32* pulStreamNumMap;
+ UINT32 ulMaxDuration;
+ struct rm_stream_info* pStreamInfo;
+ struct rm_data_hdr* pDataHdr;
+ HXBOOL bIsRealDataType;
+ UINT32 ulMinFirstPacketTime;
+ rm_stream_header* pStreamHdr;
+ UINT32 ulKeyframesNeeded;
+ UINT32 ulInterleavedStreamsFlag;
+ UINT32 ulCurrentStream;
+ } rm_parser_internal;
+
+ /*
+ * Internal parser functions
+ */
+ HX_RESULT rm_parseri_unpack_generic_hdr(rm_parser_internal* pInt, struct rm_generic_hdr* h);
+ HX_RESULT rm_parseri_unpack_file_hdr(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_unpack_properties_hdr(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_unpack_content_hdr(rm_parser_internal* pInt);
+ void rm_parseri_cleanup_content_hdr(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_unpack_media_props_hdr(rm_parser_internal* pInt,
+ struct rm_media_props_hdr* h);
+ void rm_parseri_cleanup_media_props_hdr(rm_parser_internal* pInt,
+ struct rm_media_props_hdr* h);
+ void rm_parseri_cleanup_all_media_props_hdrs(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_unpack_name_value_map(rm_parser_internal* pInt,
+ struct rm_name_value_map* pMap,
+ BYTE** ppBuf, UINT32* pulLen);
+ void rm_parseri_cleanup_name_value_map(rm_parser_internal* pInt,
+ struct rm_name_value_map* h);
+ void rm_parseri_cleanup_all_name_value_maps(rm_parser_internal* pInt,
+ struct rm_logical_stream_hdr* h);
+ HX_RESULT rm_parseri_unpack_logical_stream_hdr(rm_parser_internal* pInt,
+ struct rm_media_props_hdr* mh,
+ struct rm_logical_stream_hdr* h);
+ UINT32 rm_parseri_get_num_logical_streams(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_unpack_all_logical_stream_hdrs(rm_parser_internal* pInt);
+ void rm_parseri_cleanup_logical_stream_hdr(rm_parser_internal* pInt,
+ struct rm_logical_stream_hdr* h);
+ void rm_parseri_cleanup_all_logical_stream_hdrs(rm_parser_internal* pInt);
+ HXBOOL rm_parseri_is_logical_fileinfo_present(rm_parser_internal* pInt, UINT32* pulIndx);
+ void rm_parseri_cleanup_logical_fileinfo_hdr(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_allocate_media_props_hdrs(rm_parser_internal* pInt);
+ void rm_parseri_cleanup_read_buffer(rm_parser_internal* pInt);
+ UINT32 rm_parseri_get_media_props_hdr_stream_num(rm_parser_internal* pInt);
+ HXBOOL rm_parseri_is_logical_stream_mime_type(const char* pszMimeType);
+ HXBOOL rm_parseri_is_logical_fileinfo_mime_type(const char* pszMimeType);
+ HX_RESULT rm_parseri_read_next_header(rm_parser_internal* pInt, UINT32* pulID);
+ HX_RESULT rm_parseri_setup_interleaved_streams(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_read_all_headers(rm_parser_internal* pInt);
+ UINT32 rm_parseri_get_num_file_properties(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_get_file_properties(rm_parser_internal* pInt,
+ rm_property* pProp, UINT32 ulNumProp);
+ HXBOOL rm_parseri_has_real_data_type(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_set_rm_property(rm_parser_internal* pInt, rm_property* pProp,
+ const char* pszName, UINT32 ulType,
+ void* pValue, UINT32 ulValueLen);
+ void rm_parseri_cleanup_rm_property(rm_parser_internal* pInt, rm_property* pProp);
+ void rm_parseri_cleanup_stream_num_map(rm_parser_internal* pInt);
+ void rm_parseri_cleanup_stream_info(rm_parser_internal* pInt, struct rm_stream_info* pInfo);
+ void rm_parseri_cleanup_stream_info_array(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_create_stream_structures(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_examine_initial_packets(rm_parser_internal* pInt, UINT32 StreamNum);
+ HX_RESULT rm_parseri_unpack_data_hdr(rm_parser_internal* pInt, UINT32 StreamNum);
+ HX_RESULT rm_parseri_unpack_pkt_hdr(rm_parser_internal* pInt,
+ struct rm_pkt_hdr* pPktHdr);
+ HX_RESULT rm_parseri_unpack_index_hdr(rm_parser_internal* pInt,
+ struct rm_index_hdr* hdr);
+ HX_RESULT rm_parseri_unpack_index_rec(rm_parser_internal* pInt,
+ struct rm_index_rec* rec);
+ HX_RESULT rm_parseri_read_next_index_rec(rm_parser_internal* pInt,
+ struct rm_index_rec* rec);
+ UINT32 rm_parseri_translate_stream_number(rm_parser_internal* pInt, UINT32 ulNum);
+ HX_RESULT rm_parseri_create_all_stream_headers(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_create_stream_header(rm_parser_internal* pInt, UINT32 i,
+ rm_stream_header* hdr);
+ void rm_parseri_cleanup_all_stream_headers(rm_parser_internal* pInt);
+ void rm_parseri_cleanup_stream_header(rm_parser_internal* pInt, rm_stream_header* hdr);
+ UINT32 rm_parseri_count_set_stream_header_props(rm_parser_internal* pInt, UINT32 i,
+ rm_stream_header* hdr,
+ rm_property* pProp, UINT32 ulNumProps);
+ char* rm_parseri_create_asm_rulebook(rm_parser_internal* pInt, HXBOOL bIsVideo,
+ HXBOOL bIsEvent, HXBOOL bHasOpaqueData,
+ UINT32 ulMaxBitRate, UINT32 ulAvgBitRate,
+ HXBOOL* pbHasPreDataProps);
+ HX_RESULT rm_parseri_read_next_packet(rm_parser_internal* pInt, rm_packet** ppPacket);
+ UINT32 rm_parseri_file_read(rm_parser_internal* pInt, UINT32 ulBytesToRead, UINT32 ulReadBufferOffset);
+ UINT32 rm_parseri_file_read_buffer(rm_parser_internal* pInt, BYTE* pBuf, UINT32 ulBytesToRead);
+ void rm_parseri_file_seek(rm_parser_internal* pInt, UINT32 ulOffset, UINT32 ulOrigin);
+ void rm_parseri_set_stream_size(rm_parser_internal* pInt, UINT32 stream_size);
+ HX_RESULT rm_parseri_copy_stream_header(rm_parser_internal* pInt, UINT32 i, rm_stream_header* pHdr);
+ HX_RESULT rm_parseri_update_seek_table(rm_parser_internal* pInt, UINT32 ulStreamNum,
+ UINT32 ulTime, UINT32 ulOffset, UINT32 ulFlags);
+ HX_RESULT rm_parseri_update_time_range(rm_parser_internal* pInt, UINT32 ulStreamNum,
+ UINT32 ulTime);
+ HX_RESULT rm_parseri_search_all_seek_tables(rm_parser_internal* pInt, UINT32 ulSeekTime,
+ UINT32* pulFoundTime, UINT32* pulFoundOffset);
+ HX_RESULT rm_parseri_search_seek_table(struct rm_seek_table* pTable, UINT32 ulSeekTime, INT32 lDirection,
+ UINT32* pulFoundTime, UINT32* pulFoundOffset, UINT32* pulFoundIndex);
+ HX_RESULT rm_parseri_search_index_chunk(rm_parser_internal* pInt, UINT32 ulSeekTime);
+ HX_RESULT rm_parseri_seek(rm_parser_internal* pInt, UINT32 ulSeekTime);
+ HXBOOL rm_parseri_is_all_keyframes_found(rm_parser_internal* pInt);
+ HXBOOL rm_parseri_is_a_keyframe_found(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_find_first_packet_after_seek_time(rm_parser_internal* pInt,
+ UINT32 ulSeekTime,
+ UINT32 ulInitialOffset);
+ HX_RESULT rm_parseri_find_first_keyframe(rm_parser_internal* pInt);
+ void* rm_parseri_malloc(rm_parser_internal* pInt, UINT32 ulSize);
+ void rm_parseri_free(rm_parser_internal* pInt, void* pMem);
+ void rm_parseri_error(rm_parser_internal* pInt, HX_RESULT err, const char* pszMsg);
+
+ HX_RESULT rm_parseri_build_seek_table(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_search_seek_tables(rm_parser_internal* pInt,
+ INT32 lStreamNumber,
+ UINT32 ulSeekTime,
+ INT32 lDirection,
+ UINT32* pulFoundTime,
+ UINT32* pulFoundOffset,
+ UINT32* pulFoundIndex);
+ UINT32 rm_parseri_get_stream_number(rm_parser_internal* pInt, UINT32 ulNum);
+ void rm_parseri_cleanup_all_data_headers(rm_parser_internal* pInt);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef RM_PARSER_INTERNAL_H */
diff --git a/audio_codec/libcook/rm_property.c b/audio_codec/libcook/rm_property.c
new file mode 100644
index 0000000..85fbfb2
--- a/dev/null
+++ b/audio_codec/libcook/rm_property.c
@@ -0,0 +1,105 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_property.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "helix_types.h"
+#include "rm_property.h"
+
+const char* rm_property_get_name(rm_property* prop)
+{
+ const char* pRet = HXNULL;
+
+ if (prop) {
+ pRet = (const char*) prop->pName;
+ }
+
+ return pRet;
+}
+
+UINT32 rm_property_get_type(rm_property* prop)
+{
+ UINT32 ulRet = 0;
+
+ if (prop) {
+ ulRet = prop->ulType;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_property_get_value_uint32(rm_property* prop)
+{
+ UINT32 ulRet = 0;
+
+ if (prop) {
+ ulRet = (UINT32) prop->pValue;
+ }
+
+ return ulRet;
+}
+
+const char* rm_property_get_value_cstring(rm_property* prop)
+{
+ const char* pRet = HXNULL;
+
+ if (prop) {
+ pRet = (const char*) prop->pValue;
+ }
+
+ return pRet;
+}
+
+UINT32 rm_property_get_value_buffer_length(rm_property* prop)
+{
+ UINT32 ulRet = 0;
+
+ if (prop) {
+ ulRet = prop->ulValueLen;
+ }
+
+ return ulRet;
+}
+
+BYTE* rm_property_get_value_buffer(rm_property* prop)
+{
+ BYTE* pRet = HXNULL;
+
+ if (prop) {
+ pRet = prop->pValue;
+ }
+
+ return pRet;
+}
diff --git a/audio_codec/libcook/rm_property.h b/audio_codec/libcook/rm_property.h
new file mode 100644
index 0000000..f27c557
--- a/dev/null
+++ b/audio_codec/libcook/rm_property.h
@@ -0,0 +1,107 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_property.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_PROPERTY_H
+#define RM_PROPERTY_H
+
+#include "helix_types.h"
+
+#define RM_PROPERTY_TYPE_UINT32 0
+#define RM_PROPERTY_TYPE_BUFFER 1
+#define RM_PROPERTY_TYPE_CSTRING 2
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /*
+ * Property struct
+ *
+ * This struct can hold a UINT32 property, a CString
+ * property, or a buffer property. The members
+ * of this struct are as follows:
+ *
+ * pName: NULL-terminated string which holds the name
+ * ulType: This can be either RM_PROPERTY_TYPE_UINT32,
+ * RM_PROPERTY_TYPE_BUFFER, or RM_PROPERTY_TYPE_CSTRING.
+ * pValue and ulValueLen:
+ * 1) For type RM_PROPERTY_TYPE_UINT32, the value is held in
+ * the pValue pointer itself and ulValueLen is 0.
+ * 2) For type RM_PROPERTY_TYPE_BUFFER, the value is held in
+ * the buffer pointed to by pValue and the length of
+ * the buffer is ulValueLen.
+ * 3) For type RM_PROPERTY_TYPE_CSTRING, the value is a
+ * NULL terminated string in pValue. Therefore the pValue
+ * pointer can be re-cast as a (const char*) and the value
+ * string read from it. ulValueLen holds a length that
+ * is AT LEAST strlen((const char*) pValue) + 1. It may
+ * be more than that, so do not rely on ulValueLen being
+ * equal to strlen((const char*) pValue) + 1.
+ */
+
+ typedef struct rm_property_struct {
+ char* pName;
+ UINT32 ulType;
+ BYTE* pValue;
+ UINT32 ulValueLen;
+ } rm_property;
+
+ /*
+ * rm_property Accessor Functions
+ *
+ * Users are strongly encouraged to use these accessor
+ * functions to retrieve information from the
+ * rm_property struct, since the definition of rm_property
+ * may change in the future.
+ *
+ * When retrieving the property name, the user should first
+ * call rm_property_get_name_length() to see that the name
+ * length is greater than 0. After that, the user can get
+ * read-only access to the name by calling rm_property_get_name().
+ */
+ const char* rm_property_get_name(rm_property* prop);
+ UINT32 rm_property_get_type(rm_property* prop);
+ UINT32 rm_property_get_value_uint32(rm_property* prop);
+ const char* rm_property_get_value_cstring(rm_property* prop);
+ UINT32 rm_property_get_value_buffer_length(rm_property* prop);
+ BYTE* rm_property_get_value_buffer(rm_property* prop);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RM_PROPERTY_H */
diff --git a/audio_codec/libcook/rm_stream.c b/audio_codec/libcook/rm_stream.c
new file mode 100644
index 0000000..7ac99d0
--- a/dev/null
+++ b/audio_codec/libcook/rm_stream.c
@@ -0,0 +1,356 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_stream.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <string.h>
+#include "helix_types.h"
+#include "helix_mime_types.h"
+#include "rm_property.h"
+#include "rm_stream.h"
+
+UINT32 rm_stream_get_number(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulStreamNumber;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_max_bit_rate(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulMaxBitRate;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_avg_bit_rate(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulAvgBitRate;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_max_packet_size(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulMaxPacketSize;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_avg_packet_size(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulAvgPacketSize;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_start_time(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulStartTime;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_preroll(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulPreroll;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_duration(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulDuration;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_data_offset(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulStartOffset;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_data_size(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulStreamSize;
+ }
+
+ return ulRet;
+}
+
+const char* rm_stream_get_name(rm_stream_header* hdr)
+{
+ const char* pRet = HXNULL;
+
+ if (hdr) {
+ pRet = (const char*) hdr->pStreamName;
+ }
+
+ return pRet;
+}
+
+const char* rm_stream_get_mime_type(rm_stream_header* hdr)
+{
+ const char* pRet = HXNULL;
+
+ if (hdr) {
+ pRet = (const char*) hdr->pMimeType;
+ }
+
+ return pRet;
+}
+
+UINT32 rm_stream_get_properties(rm_stream_header* hdr, rm_property** ppProp)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr && ppProp) {
+ *ppProp = hdr->pProperty;
+ ulRet = hdr->ulNumProperties;
+ }
+
+ return ulRet;
+}
+
+HXBOOL rm_stream_is_realaudio(rm_stream_header* hdr)
+{
+ HXBOOL bRet = FALSE;
+
+ if (hdr) {
+ bRet = rm_stream_is_realaudio_mimetype((const char*) hdr->pMimeType);
+ }
+
+ return bRet;
+}
+
+HXBOOL rm_stream_is_realvideo(rm_stream_header* hdr)
+{
+ HXBOOL bRet = FALSE;
+
+ if (hdr) {
+ bRet = rm_stream_is_realvideo_mimetype((const char*) hdr->pMimeType);
+ }
+
+ return bRet;
+}
+
+HXBOOL rm_stream_is_realevent(rm_stream_header* hdr)
+{
+ HXBOOL bRet = FALSE;
+
+ if (hdr) {
+ bRet = rm_stream_is_realevent_mimetype((const char*) hdr->pMimeType);
+ }
+
+ return bRet;
+}
+
+HXBOOL rm_stream_is_realaudio_mimetype(const char* pszStr)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pszStr) {
+ if (!strcmp(pszStr, REALAUDIO_MIME_TYPE) ||
+ !strcmp(pszStr, REALAUDIO_MULTIRATE_MIME_TYPE) ||
+ !strcmp(pszStr, REALAUDIO_ENCRYPTED_MIME_TYPE)) {
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+HXBOOL rm_stream_is_realvideo_mimetype(const char* pszStr)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pszStr) {
+ if (!strcmp(pszStr, REALVIDEO_MIME_TYPE) ||
+ !strcmp(pszStr, REALVIDEO_MULTIRATE_MIME_TYPE) ||
+ !strcmp(pszStr, REALVIDEO_ENCRYPTED_MIME_TYPE)) {
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+HXBOOL rm_stream_is_realevent_mimetype(const char* pszStr)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pszStr) {
+ if (!strcmp(pszStr, REALEVENT_MIME_TYPE) ||
+ !strcmp(pszStr, REALEVENT_ENCRYPTED_MIME_TYPE) ||
+ !strcmp(pszStr, REALIMAGEMAP_MIME_TYPE) ||
+ !strcmp(pszStr, REALIMAGEMAP_ENCRYPTED_MIME_TYPE) ||
+ !strcmp(pszStr, IMAGEMAP_MIME_TYPE) ||
+ !strcmp(pszStr, IMAGEMAP_ENCRYPTED_MIME_TYPE) ||
+ !strcmp(pszStr, SYNCMM_MIME_TYPE) ||
+ !strcmp(pszStr, SYNCMM_ENCRYPTED_MIME_TYPE)) {
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+HXBOOL rm_stream_is_real_mimetype(const char* pszStr)
+{
+ return rm_stream_is_realaudio_mimetype(pszStr) ||
+ rm_stream_is_realvideo_mimetype(pszStr) ||
+ rm_stream_is_realevent_mimetype(pszStr);
+}
+
+HX_RESULT rm_stream_get_property_int(rm_stream_header* hdr,
+ const char* pszStr,
+ UINT32* pulVal)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (hdr && pszStr && pulVal &&
+ hdr->pProperty && hdr->ulNumProperties) {
+ UINT32 i = 0;
+ for (i = 0; i < hdr->ulNumProperties; i++) {
+ rm_property* pProp = &hdr->pProperty[i];
+ if (pProp->ulType == RM_PROPERTY_TYPE_UINT32 &&
+ pProp->pName &&
+ !strcmp(pszStr, (const char*) pProp->pName)) {
+ /* Assign the out parameter */
+ *pulVal = (UINT32) pProp->pValue;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ break;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_stream_get_property_buf(rm_stream_header* hdr,
+ const char* pszStr,
+ BYTE** ppBuf,
+ UINT32* pulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (hdr && pszStr && ppBuf && pulLen &&
+ hdr->pProperty && hdr->ulNumProperties) {
+ UINT32 i = 0;
+ for (i = 0; i < hdr->ulNumProperties; i++) {
+ rm_property* pProp = &hdr->pProperty[i];
+ if (pProp->ulType == RM_PROPERTY_TYPE_BUFFER &&
+ pProp->pName &&
+ !strcmp(pszStr, (const char*) pProp->pName)) {
+ /* Assign the out parameters */
+ *ppBuf = pProp->pValue;
+ *pulLen = pProp->ulValueLen;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ break;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_stream_get_property_str(rm_stream_header* hdr,
+ const char* pszStr,
+ char** ppszStr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (hdr && pszStr && ppszStr &&
+ hdr->pProperty && hdr->ulNumProperties) {
+ UINT32 i = 0;
+ for (i = 0; i < hdr->ulNumProperties; i++) {
+ rm_property* pProp = &hdr->pProperty[i];
+ if (pProp->ulType == RM_PROPERTY_TYPE_CSTRING &&
+ pProp->pName &&
+ !strcmp(pszStr, (const char*) pProp->pName)) {
+ /* Assign the out parameter */
+ *ppszStr = (char*) pProp->pValue;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ break;
+ }
+ }
+ }
+
+ return retVal;
+}
diff --git a/audio_codec/libcook/rm_stream.h b/audio_codec/libcook/rm_stream.h
new file mode 100644
index 0000000..4728070
--- a/dev/null
+++ b/audio_codec/libcook/rm_stream.h
@@ -0,0 +1,115 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_stream.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_STREAM_H
+#define RM_STREAM_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_property.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /*
+ * Stream header definition.
+ *
+ * Users are strongly encouraged to use the accessor
+ * functions below to retrieve information from the
+ * rm_stream_header struct, since the definition
+ * may change in the future.
+ */
+ typedef struct rm_stream_header_struct {
+ char* pMimeType;
+ char* pStreamName;
+ UINT32 ulStreamNumber;
+ UINT32 ulMaxBitRate;
+ UINT32 ulAvgBitRate;
+ UINT32 ulMaxPacketSize;
+ UINT32 ulAvgPacketSize;
+ UINT32 ulDuration;
+ UINT32 ulPreroll;
+ UINT32 ulStartTime;
+ UINT32 ulStartOffset;
+ UINT32 ulStreamSize;
+ UINT32 ulOpaqueDataLen;
+ BYTE* pOpaqueData;
+ UINT32 ulNumProperties;
+ rm_property* pProperty;
+ } rm_stream_header;
+
+ /*
+ * These are the accessor functions used to retrieve
+ * information from the stream header
+ */
+ UINT32 rm_stream_get_number(rm_stream_header* hdr);
+ UINT32 rm_stream_get_max_bit_rate(rm_stream_header* hdr);
+ UINT32 rm_stream_get_avg_bit_rate(rm_stream_header* hdr);
+ UINT32 rm_stream_get_max_packet_size(rm_stream_header* hdr);
+ UINT32 rm_stream_get_avg_packet_size(rm_stream_header* hdr);
+ UINT32 rm_stream_get_start_time(rm_stream_header* hdr);
+ UINT32 rm_stream_get_preroll(rm_stream_header* hdr);
+ UINT32 rm_stream_get_duration(rm_stream_header* hdr);
+ UINT32 rm_stream_get_data_offset(rm_stream_header* hdr);
+ UINT32 rm_stream_get_data_size(rm_stream_header* hdr);
+ const char* rm_stream_get_name(rm_stream_header* hdr);
+ const char* rm_stream_get_mime_type(rm_stream_header* hdr);
+ UINT32 rm_stream_get_properties(rm_stream_header* hdr, rm_property** ppProp);
+ HXBOOL rm_stream_is_realaudio(rm_stream_header* hdr);
+ HXBOOL rm_stream_is_realvideo(rm_stream_header* hdr);
+ HXBOOL rm_stream_is_realevent(rm_stream_header* hdr);
+ HXBOOL rm_stream_is_realaudio_mimetype(const char* pszStr);
+ HXBOOL rm_stream_is_realvideo_mimetype(const char* pszStr);
+ HXBOOL rm_stream_is_realevent_mimetype(const char* pszStr);
+ HXBOOL rm_stream_is_real_mimetype(const char* pszStr);
+ HX_RESULT rm_stream_get_property_int(rm_stream_header* hdr,
+ const char* pszStr,
+ UINT32* pulVal);
+ HX_RESULT rm_stream_get_property_buf(rm_stream_header* hdr,
+ const char* pszStr,
+ BYTE** ppBuf,
+ UINT32* pulLen);
+ HX_RESULT rm_stream_get_property_str(rm_stream_header* hdr,
+ const char* pszStr,
+ char** ppszStr);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RM_STREAM_H */
diff --git a/audio_codec/libcook/rm_stream_internal.h b/audio_codec/libcook/rm_stream_internal.h
new file mode 100644
index 0000000..52c26aa
--- a/dev/null
+++ b/audio_codec/libcook/rm_stream_internal.h
@@ -0,0 +1,77 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_stream_internal.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_STREAM_INTERNAL_H
+#define RM_STREAM_INTERNAL_H
+
+#include "helix_types.h"
+#include "rm_property.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /*
+ * Internal stream header struct
+ *
+ * The public definition of rm_stream_header
+ * is void - opaque to the user. Properties of the
+ * stream header are accessed via accessor functions
+ * by the user.
+ */
+ typedef struct rm_stream_header_internal_struct {
+ char* pMimeType;
+ char* pStreamName;
+ UINT32 ulStreamNumber;
+ UINT32 ulMaxBitRate;
+ UINT32 ulAvgBitRate;
+ UINT32 ulMaxPacketSize;
+ UINT32 ulAvgPacketSize;
+ UINT32 ulDuration;
+ UINT32 ulPreroll;
+ UINT32 ulStartTime;
+ UINT32 ulOpaqueDataLen;
+ BYTE* pOpaqueData;
+ UINT32 ulNumProperties;
+ rm_property* pProperty;
+ } rm_stream_header_internal;
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RM_STREAM_INTERNAL_H */
diff --git a/audio_codec/libcook/rv20backend.h b/audio_codec/libcook/rv20backend.h
new file mode 100644
index 0000000..34afdef
--- a/dev/null
+++ b/audio_codec/libcook/rv20backend.h
@@ -0,0 +1,69 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv20backend.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV20BACKEND_H__
+#define RV20BACKEND_H__
+
+#include "helix_types.h"
+#include "helix_result.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ //HX_RESULT _RV20toYUV420CustomMessage(UINT32 *msg_id, void *global);
+ HX_RESULT _RV20toYUV420CustomMessage(void *msg_id, void *global);
+
+ HX_RESULT _RV20toYUV420HiveMessage(UINT32 *msg_id, void *global);
+
+ HX_RESULT _RV20toYUV420Transform(
+ UCHAR *pRV10Packets,
+ UCHAR *pDecodedFrameBuffer,
+ void *pInputParams,
+ void *pOutputParams,
+ void *global
+ );
+
+ HX_RESULT _RV20toYUV420Free(void *global);
+
+ HX_RESULT _RV20toYUV420Init(void *prv10Init, void **decoderState);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RV20BACKEND_H__ */
diff --git a/audio_codec/libcook/rv30backend.h b/audio_codec/libcook/rv30backend.h
new file mode 100644
index 0000000..a882ba0
--- a/dev/null
+++ b/audio_codec/libcook/rv30backend.h
@@ -0,0 +1,68 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv30backend.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV30BACKEND_H__
+#define RV30BACKEND_H__
+
+#include "helix_types.h"
+#include "helix_result.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ HX_RESULT _RV40toYUV420CustomMessage(UINT32 *msg_id, void *global);
+
+ HX_RESULT _RV40toYUV420HiveMessage(UINT32 *msg_id, void *global);
+
+ HX_RESULT _RV40toYUV420Transform(
+ UCHAR *pRV20Packets,
+ UCHAR *pDecodedFrameBuffer,
+ void *pInputParams,
+ void *pOutputParams,
+ void *global
+ );
+
+ HX_RESULT _RV40toYUV420Free(void *global);
+
+ HX_RESULT _RV40toYUV420Init(void *prv10Init, void **decoderState);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RV30BACKEND_H__ */
diff --git a/audio_codec/libcook/rv_backend.h b/audio_codec/libcook/rv_backend.h
new file mode 100644
index 0000000..992306a
--- a/dev/null
+++ b/audio_codec/libcook/rv_backend.h
@@ -0,0 +1,84 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_backend.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV_BACKEND_H__
+#define RV_BACKEND_H__
+
+/* Unified RealVideo decoder backend interface */
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rv_format_info.h"
+#include "rv_backend_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* rv decoder backend interface */
+
+ typedef HX_RESULT(*rv_backend_init_fp)(void *prv10Init,
+ void **global);
+ typedef HX_RESULT(*rv_backend_decode_fp)(UCHAR *pRV10Packets,
+ UCHAR *pDecodedFrameBuffer,
+ void *pInputParams,
+ void *pOutputParams,
+ void *global);
+ typedef HX_RESULT(*rv_backend_custom_message_fp)(UINT32 *msg_id,
+ void *global);
+ typedef HX_RESULT(*rv_backend_hive_message_fp)(UINT32 *msg,
+ void *global);
+ typedef HX_RESULT(*rv_backend_free_fp)(void* global);
+
+
+ /* The rv_backend struct contains the RealVideo decoder backend
+ * function pointers. */
+
+ typedef struct rv_backend_struct {
+ rv_backend_init_fp fpInit;
+ rv_backend_decode_fp fpDecode;
+ rv_backend_custom_message_fp fpCustomMessage;
+ rv_backend_hive_message_fp fpHiveMessage;
+ rv_backend_free_fp fpFree;
+ } rv_backend;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RV_BACKEND_H__ */
diff --git a/audio_codec/libcook/rv_backend_types.h b/audio_codec/libcook/rv_backend_types.h
new file mode 100644
index 0000000..0655d15
--- a/dev/null
+++ b/audio_codec/libcook/rv_backend_types.h
@@ -0,0 +1,198 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_backend_types.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV_BACKEND_TYPES_H
+#define RV_BACKEND_TYPES_H
+
+#include "rv_format_info.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ typedef struct rv_backend_init_params_struct {
+ UINT16 usOuttype;
+ UINT16 usPels;
+ UINT16 usLines;
+ UINT16 usPadWidth; /* number of columns of padding on right to get 16 x 16 block*/
+ UINT16 usPadHeight; /* number of rows of padding on bottom to get 16 x 16 block*/
+
+ UINT16 pad_to_32; /* to keep struct member alignment independent of */
+ /* compiler options */
+ UINT32 ulInvariants;
+ /* ulInvariants specifies the invariant picture header bits */
+ INT32 bPacketization;
+ UINT32 ulStreamVersion;
+ } rv_backend_init_params;
+
+ typedef struct rv_backend_in_params_struct {
+ UINT32 dataLength;
+ INT32 bInterpolateImage;
+ UINT32 numDataSegments;
+ rv_segment *pDataSegments;
+ UINT32 flags;
+ /* 'flags' should be initialized by the front-end before each */
+ /* invocation to decompress a frame. It is not updated by the decoder. */
+ /* */
+ /* If it contains RV_DECODE_MORE_FRAMES, it informs the decoder */
+ /* that it is being called to extract the second or subsequent */
+ /* frame that the decoder is emitting for a given input frame. */
+ /* The front-end should set this only in response to seeing */
+ /* an RV_DECODE_MORE_FRAMES indication in H263DecoderOutParams. */
+ /* */
+ /* If it contains RV_DECODE_DONT_DRAW, it informs the decoder */
+ /* that it should decode the image (in order to produce a valid */
+ /* reference frame for subsequent decoding), but that no image */
+ /* should be returned. This provides a "hurry-up" mechanism. */
+ UINT32 timestamp;
+ } rv_backend_in_params;
+
+ typedef struct rv_backend_out_params_struct {
+ UINT32 numFrames;
+ UINT32 notes;
+ /* 'notes' is assigned by the transform function during each call to */
+ /* decompress a frame. If upon return the notes parameter contains */
+ /* the indication RV_DECODE_MORE_FRAMES, then the front-end */
+ /* should invoke the decoder again to decompress the same image. */
+ /* For this additional invocation, the front-end should first set */
+ /* the RV_DECODE_MORE_FRAMES bit in the 'H263DecoderInParams.flags' */
+ /* member, to indicate to the decoder that it is being invoked to */
+ /* extract the next frame. */
+ /* The front-end should continue invoking the decoder until the */
+ /* RV_DECODE_MORE_FRAMES bit is not set in the 'notes' member. */
+ /* For each invocation to decompress a frame in the same "MORE_FRAMES" */
+ /* loop, the front-end should send in the same input image. */
+ /* */
+ /* If the decoder has no frames to return for display, 'numFrames' will */
+ /* be set to zero. To avoid redundancy, the decoder does *not* set */
+ /* the RV_DECODE_DONT_DRAW bit in 'notes' in this case. */
+
+
+ UINT32 timestamp;
+ /* The 'temporal_offset' parameter is used in conjunction with the */
+ /* RV_DECODE_MORE_FRAMES note, to assist the front-end in */
+ /* determining when to display each returned frame. */
+ /* If the decoder sets this to T upon return, the front-end should */
+ /* attempt to display the returned image T milliseconds relative to */
+ /* the front-end's idea of the presentation time corresponding to */
+ /* the input image. */
+ /* Be aware that this is a signed value, and will typically be */
+ /* negative. */
+
+ UINT32 width;
+ UINT32 height;
+ /* Width and height of the returned frame. */
+ /* This is the width and the height as signalled in the bitstream. */
+
+ } rv_backend_out_params;
+
+
+ /* definitions for output parameter notes */
+
+#define RV_DECODE_MORE_FRAMES 0x00000001
+#define RV_DECODE_DONT_DRAW 0x00000002
+#define RV_DECODE_KEY_FRAME 0x00000004
+ /* Indicates that the decompressed image is a key frame. */
+ /* Note that enhancement layer EI frames are not key frames, in the */
+ /* traditional sense, because they have dependencies on lower layer */
+ /* frames. */
+
+#define RV_DECODE_B_FRAME 0x00000008
+ /* Indicates that the decompressed image is a B frame. */
+ /* At most one of PIA_DDN_KEY_FRAME and PIA_DDN_B_FRAME will be set. */
+
+#define RV_DECODE_DEBLOCKING_FILTER 0x00000010
+ /* Indicates that the returned frame has gone through the */
+ /* deblocking filter. */
+
+#define RV_DECODE_FRU_FRAME 0x00000020
+ /* Indicates that the decompressed image is a B frame. */
+ /* At most one of PIA_DDN_KEY_FRAME and PIA_DDN_B_FRAME will be set. */
+
+#define RV_DECODE_SCRAMBLED_BUFFER 0x00000040
+ /* Indicates that the input buffer is scrambled for security */
+ /* decoder should de-scramble the buffer before use it */
+
+#define RV_DECODE_LAST_FRAME 0x00000200
+ /* Indicates that the accompanying input frame is the last in the */
+ /* current sequence. If input frame is a dummy frame, the decoder */
+ /* flushes the latency frame to the output. */
+
+ /* definitions for decoding opaque data in bitstream header */
+ /* Defines match ilvcmsg.h so that ulSPOExtra == rv10init.invariants */
+#define RV40_SPO_FLAG_UNRESTRICTEDMV 0x00000001 /* ANNEX D */
+#define RV40_SPO_FLAG_EXTENDMVRANGE 0x00000002 /* IMPLIES NEW VLC TABLES */
+#define RV40_SPO_FLAG_ADVMOTIONPRED 0x00000004 /* ANNEX F */
+#define RV40_SPO_FLAG_ADVINTRA 0x00000008 /* ANNEX I */
+#define RV40_SPO_FLAG_INLOOPDEBLOCK 0x00000010 /* ANNEX J */
+#define RV40_SPO_FLAG_SLICEMODE 0x00000020 /* ANNEX K */
+#define RV40_SPO_FLAG_SLICESHAPE 0x00000040 /* 0: free running; 1: rect */
+#define RV40_SPO_FLAG_SLICEORDER 0x00000080 /* 0: sequential; 1: arbitrary */
+#define RV40_SPO_FLAG_REFPICTSELECTION 0x00000100 /* ANNEX N */
+#define RV40_SPO_FLAG_INDEPENDSEGMENT 0x00000200 /* ANNEX R */
+#define RV40_SPO_FLAG_ALTVLCTAB 0x00000400 /* ANNEX S */
+#define RV40_SPO_FLAG_MODCHROMAQUANT 0x00000800 /* ANNEX T */
+#define RV40_SPO_FLAG_BFRAMES 0x00001000 /* SETS DECODE PHASE */
+#define RV40_SPO_BITS_DEBLOCK_STRENGTH 0x0000e000 /* deblocking strength */
+#define RV40_SPO_BITS_NUMRESAMPLE_IMAGES 0x00070000 /* max of 8 RPR images sizes */
+#define RV40_SPO_FLAG_FRUFLAG 0x00080000 /* FRU BOOL: if 1 then OFF; */
+#define RV40_SPO_FLAG_FLIP_FLIP_INTL 0x00100000 /* FLIP-FLOP interlacing; */
+#define RV40_SPO_FLAG_INTERLACE 0x00200000 /* de-interlacing prefilter has been applied; */
+#define RV40_SPO_FLAG_MULTIPASS 0x00400000 /* encoded with multipass; */
+#define RV40_SPO_FLAG_INV_TELECINE 0x00800000 /* inverse-telecine prefilter has been applied; */
+#define RV40_SPO_FLAG_VBR_ENCODE 0x01000000 /* encoded using VBR; */
+#define RV40_SPO_BITS_DEBLOCK_SHIFT 13
+#define RV40_SPO_BITS_NUMRESAMPLE_IMAGES_SHIFT 16
+
+#define OUT_OF_DATE_DECODER 0x00000001
+#define OK_VERSION 0x00000000
+
+#define CORRUPTED_BITSTREAM 0x00
+#define OK_DECODE 0x0f
+#define INCOMPLETE_FRAME 0xffff
+#define MALLOC_FAILURE 0x1111
+
+#define RV10_DITHER_PARAMS 0x00001001
+#define RV10_POSTFILTER_PARAMS 0x00001002
+#define RV10_ADVANCED_MP_PARAMS 0x0001003
+#define RV10_TEMPORALINTERP_PARAMS 0x00001004
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* RV_BACKEND_TYPES_H */
diff --git a/audio_codec/libcook/rv_decode.h b/audio_codec/libcook/rv_decode.h
new file mode 100644
index 0000000..6d9c0d9
--- a/dev/null
+++ b/audio_codec/libcook/rv_decode.h
@@ -0,0 +1,208 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_decode.h,v 1.1.1.1.2.2 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV_DECODE_H__
+#define RV_DECODE_H__
+
+/* Simple unified decoder frontend for RealVideo */
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+#include "rm_error.h"
+#include "rv_format_info.h"
+#include "rv_decode_message.h"
+#include "rv_backend.h"
+#include "rv_backend_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* The rv_decode struct contains the RealVideo decoder frontend
+ * state variables and backend instance pointer. */
+
+ typedef struct rv_decode_struct {
+ rm_error_func_ptr fpError;
+ /* User defined error function. */
+
+ void* pUserError;
+ /* User defined parameter for error function. */
+
+ rm_malloc_func_ptr fpMalloc;
+ /* User defined malloc function. */
+
+ rm_free_func_ptr fpFree;
+ /* User defined free function. */
+
+ void* pUserMem;
+ /* User defined parameter for malloc and free functions. */
+
+ UINT32 ulSPOExtra;
+ /* The SPO Extra bits. Opaque data appended to bitstream header. */
+
+ UINT32 ulStreamVersion;
+ /* The stream version. Opaque data following the SPO Extra bits. */
+
+ UINT32 ulMajorBitstreamVersion;
+ /* The major bitstream version. Indicates RV7, RV8, RV9, etc. */
+
+ UINT32 ulMinorBitstreamVersion;
+ /* The minor bitstream version. Indicates minor revision or RAW. */
+
+ UINT32 ulNumResampledImageSizes;
+ /* The number of RPR sizes. Optional RV7 and RV8 opaque data. */
+
+ UINT32 ulEncodeSize;
+ /* The maximum encoded frame dimensions. Optional RV9 opaque data.*/
+
+ UINT32 ulLargestPels;
+ /* The maximum encoded frame width. */
+
+ UINT32 ulLargestLines;
+ /* The maximum encoded frame height. */
+
+ UINT32 pDimensions[2 * (8 + 1)];
+ /* Table of encoded dimensions, including RPR sizes. */
+
+ UINT32 ulOutSize;
+ /* The maximum size of the output frame in bytes. */
+
+ UINT32 ulECCMask;
+ /* Mask for identifying ECC packets. */
+
+ UINT32 bInputFrameIsReference;
+ /* Identifies whether input frame is a key frame or not. */
+
+ UINT32 ulInputFrameQuant;
+ /* The input frame quantization parameter. */
+
+ rv_format_info *pBitstreamHeader;
+ /* The bitstream header. */
+
+ rv_frame *pInputFrame;
+ /* Pointer to the input frame struct. */
+
+ void *pDecodeState;
+ /* Pointer to decoder backend state. */
+
+ rv_backend *pDecode;
+ /* Decoder backend function pointers. */
+
+ rv_backend_init_params pInitParams;
+ /* Initialization parameters for the decoder backend. */
+
+ rv_backend_in_params pInputParams;
+ /* The decoder backend input parameter struct. */
+
+ rv_backend_out_params pOutputParams;
+ /* The decoder backend output parameter struct. */
+
+ } rv_decode;
+
+ /* rv_decode_create()
+ * Creates RV decoder frontend struct, copies memory utilities.
+ * Returns struct pointer on success, NULL on failure. */
+ rv_decode* rv_decode_create(void* pUserError, rm_error_func_ptr fpError);
+
+ rv_decode* rv_decode_create2(void* pUserError, rm_error_func_ptr fpError,
+ void* pUserMem, rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+
+ /* rv_decode_destroy()
+ * Deletes decoder backend instance, followed by frontend. */
+ void rv_decode_destroy(rv_decode* pFrontEnd);
+
+ /* rv_decode_init()
+ * Reads bitstream header, selects and initializes decoder backend.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT rv_decode_init(rv_decode* pFrontEnd, rv_format_info* pHeader);
+
+ /* rv_decode_stream_input()
+ * Reads frame header and fills decoder input parameters struct. If there
+ * is packet loss and ECC packets exist, error correction is attempted.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT rv_decode_stream_input(rv_decode* pFrontEnd, rv_frame* pFrame);
+
+ /* rv_decode_stream_decode()
+ * Calls decoder backend to decode issued frame and produce an output frame.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT rv_decode_stream_decode(rv_decode* pFrontEnd, UINT8* pOutput);
+
+ /* rv_decode_stream_flush()
+ * Flushes the latency frame from the decoder backend after the last frame
+ * is delivered and decoded before a pause or the end-of-file.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT rv_decode_stream_flush(rv_decode* pFrontEnd, UINT8* pOutput);
+
+ /* rv_decode_custom_message()
+ * Sends a custom message to the decoder backend.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT rv_decode_custom_message(rv_decode* pFrontEnd, RV_Custom_Message_ID *pMsg_id);
+
+
+ /**************** Accessor Functions *******************/
+ /* rv_decode_max_output_size()
+ * Returns maximum size of YUV 4:2:0 output buffer in bytes. */
+ UINT32 rv_decode_max_output_size(rv_decode* pFrontEnd);
+
+ /* rv_decode_get_output_size()
+ * Returns size of most recent YUV 4:2:0 output buffer in bytes. */
+ UINT32 rv_decode_get_output_size(rv_decode* pFrontEnd);
+
+ /* rv_decode_get_output_dimensions()
+ * Returns width and height of most recent YUV output buffer. */
+ HX_RESULT rv_decode_get_output_dimensions(rv_decode* pFrontEnd, UINT32* pWidth,
+ UINT32* pHeight);
+
+ /* rv_decode_frame_valid()
+ * Checks decoder output parameters to see there is a valid output frame.
+ * Returns non-zero value if a valid output frame exists, else zero. */
+ UINT32 rv_decode_frame_valid(rv_decode* pFrontEnd);
+
+ /* rv_decode_more_frames()
+ * Checks decoder output parameters to see if more output frames can be
+ * produced without additional input frames.
+ * Returns non-zero value if more frames can be
+ * produced without additional input, else zero. */
+ UINT32 rv_decode_more_frames(rv_decode* pFrontEnd);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RV_DECODE_H__ */
diff --git a/audio_codec/libcook/rv_decode_message.h b/audio_codec/libcook/rv_decode_message.h
new file mode 100644
index 0000000..63d5e6e
--- a/dev/null
+++ b/audio_codec/libcook/rv_decode_message.h
@@ -0,0 +1,492 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_decode_message.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV_DECODE_MESSAGE_H
+#define RV_DECODE_MESSAGE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* Define CPU scalability constants. Though these values range from */
+ /* 0 to 100, they are *not* intended to indicate a CPU utilization percentage. */
+
+#define CPU_Scalability_Maximum 100
+ /* Maximum value for CPU usage setting: */
+ /* no shortcuts taken, best possible quality at the cost of higher */
+ /* CPU usage. This value is typically used for "off-line" compression. */
+
+#define CPU_Scalability_Minimum 0
+ /* Minimum value for CPU usage setting: */
+ /* all implemented shortcuts taken, reduced CPU usage at the cost */
+ /* of reduced video quality. */
+
+#define CPU_Scalability_Default 50
+ /* Default value for CPU usage setting: */
+ /* this represents the normal mode of operation and is equivalent */
+ /* to previously not choosing a CPU usage setting. */
+
+#define RV89COMBO_MSG_ID_Decoder_CPU_Scalability 2002
+ /* Allows for the setting and getting of the decoders CPU scalability parameter */
+
+ /* */
+ /* Define formats for representing custom codec messages. */
+ /* Custom codec messages have semantics unknown to the HIVE/RV layer. */
+ /* The messages are defined by the underlying codec, and typically documented */
+ /* for use by applications. */
+ /* */
+
+ /* RV_Custom_Message_ID identifies a specific custom message. These */
+ /* identifiers are not guaranteed to be unique among different codecs. */
+ /* Thus an application using such messages, must have knowledge regarding */
+ /* which codec is being used, and what custom messages it supports. */
+ /* A codec will typically distribute a header file that defines its */
+ /* custom messages. */
+ /* */
+ /* Specific custom messages will be passed into a codec via a structure whose */
+ /* first member is a RV_Custom_Message_ID, and additional parameters */
+ /* understood by the application and the codec. The size of each such */
+ /* custom message structure is variable, depending on the specific message id. */
+ /* Messages that require no values other than a message id, can be indicated */
+ /* by using the RV_Custom_Message_ID as is. For such messages, there is no */
+ /* need to wrap the message id within another structure. */
+
+ typedef UINT32 RV_Custom_Message_ID;
+
+ /* RV_MSG_Simple is a structure used to pass custom messages which */
+ /* take one or two 32-bit values. The "message_id" member identifies a */
+ /* particular message, and the "value1" and "value2" members specify the */
+ /* 32-bit values. The interpretation of the values depends on the message id. */
+ /* They could be simple booleans (zero or non-zero), or arbitrary integers. */
+ /* Some messages will use only value1, and not value2. */
+
+ typedef struct {
+
+ RV_Custom_Message_ID message_id;
+
+ INT32 value1;
+ INT32 value2;
+
+ } RV_MSG_Simple;
+
+
+ /* The RV_MSG_DISABLE, RV_MSG_ENABLE and RV_MSG_GET values may be used as */
+ /* controls when manipulating boolean-valued custom messages. Typically, */
+ /* such messages will employ the RV_MSG_Simple structure. The message_id */
+ /* will identify a boolean-valued option being manipulated. The "value1" */
+ /* member will be set to one of RV_MSG_DISABLE, RV_MSG_ENABLE or RV_MSG_GET. */
+ /* Depending on the message id, "value2" may specify additional information */
+ /* such as a layer number for scalable video sequences. */
+ /* */
+ /* When value1 is RV_MSG_DISABLE or RV_MSG_ENABLE, the specified option */
+ /* will be disabled or enabled, respectively. */
+ /* When value1 is RV_MSG_GET, the current setting for the option (zero for */
+ /* disabled and non-zero for enabled) will be returned in "value2". */
+
+#define RV_MSG_DISABLE 0
+#define RV_MSG_ENABLE 1
+#define RV_MSG_GET 2
+
+ /* The RV_MSG_SET control, along with RV_MSG_GET, provide an alternative */
+ /* way in which custom messages might use the RV_MSG_Simple structure. */
+ /* When value1 is RV_MSG_SET, value2 indicates the value which is being */
+ /* applied. The message_id provides the context to which value2 applies. */
+ /* Again, refer to the documentation describing each custom message to see */
+ /* if it uses RV_MSG_GET and RV_MSG_SET, or if it uses RV_MSG_DISABLE, */
+ /* RV_MSG_ENABLE and RV_MSG_GET. */
+
+#define RV_MSG_SET 3
+
+
+
+
+
+ /* Decoder postfilters: */
+ /* - the smoothing postfilter is designed to remove general compression */
+ /* artifacts, mosquito noise, and ringing noise. */
+ /* - the annex J deblocking filter when used as a postfilter (annex J */
+ /* not encoded in bitstream), removes blocking artifacts (block */
+ /* edges) almost as efficiently as when used in-the-loop, i.e. encoded */
+ /* in bitstream. */
+ /* For the most video quality improvement, both filters should be used. */
+ /* However, each filter takes up a certain amount of CPU cycles, and */
+ /* for large formats, it may be too computationally expensive to use */
+ /* both. */
+ /* These filters are more effective, the lower the bitrate. */
+
+ /* */
+ /* Define a custom decoder message for enabling the smoothing postfilter. */
+ /* */
+ /* This message must be sent with the RV_MSG_Simple structure. */
+ /* Its value1 member should be RV_MSG_DISABLE, RV_MSG_ENABLE or RV_MSG_GET. */
+ /* Its value2 is only used for RV_MSG_GET, in which case it is used to */
+ /* return the current setting. */
+ /* */
+#define RV_MSG_ID_Smoothing_Postfilter 17
+
+ /* Define a decoder message that helps the decoder determine when to display */
+ /* frames. */
+ /* */
+ /* The SNR, spatial and temporal scalability features of H.263+ Annex O */
+ /* have the property that frames are received at the decoder out of order, */
+ /* or that multiple frames (enhancement layers) are received at the decoder */
+ /* yet only one of these frames should be displayed. */
+ /* */
+ /* In the absence of apriori knowledge regarding the video sequence it is */
+ /* going to receive, an H.263+ decoder might not know when it is okay to */
+ /* go ahead and display a picture it has just decoded. */
+ /* */
+ /* To help solve this problem, the ILVC decoder can operate in two modes. */
+ /* The first and default mode is termed "no latency". In this scenario, */
+ /* the decoder assumes it will not be receiving B frames nor enhancement */
+ /* layers. The decoder will decode and display the very first frame it sees. */
+ /* If the decoder encounters any B frames or enhancement layers, it then */
+ /* goes into latency mode (described below). When B frames or enhancement */
+ /* layers are present under latency mode, some of these frame types will */
+ /* not be displayed by the decoder at the beginning of a video sequence. */
+ /* This is because the decoder either already displayed a frame for the */
+ /* same temporal reference point, or because the decoder no longer has */
+ /* the appropriate reference frames from which to decode a B frame. */
+ /* */
+ /* Under latency mode, the decoder will generally not display a decoded frame, */
+ /* until it has detected that no enhancement layer frames or dependent */
+ /* B frames will be coming. This detection usually occurs when a subsequent */
+ /* non-B frame is encountered. This mode has the advantage that no frames */
+ /* will be dropped at the beginning of a sequence. The disadvantage is that */
+ /* a latency of one or more temporal references is introduced before a frame */
+ /* is displayed. */
+ /* */
+ /* This message must be sent with the RV_MSG_Simple structure. */
+ /* Its value1 member should be RV_MSG_DISABLE, RV_MSG_ENABLE or RV_MSG_GET. */
+ /* For RV_MSG_GET, the current setting is returned in value2. */
+
+#define RV_MSG_ID_Latency_Display_Mode 21
+
+
+
+ /* */
+ /* Define a custom decoder message that enables/disables the error */
+ /* concealment in the decoder. */
+ /* */
+ /* This message must be sent with the RV_MSG_Simple structure. */
+ /* Its value1 member should be RV_MSG_DISABLE, RV_MSG_ENABLE or RV_MSG_GET. */
+ /* Its value2 is only used for RV_MSG_GET, in which case it is used to */
+ /* return the current setting. */
+ /* */
+#define RV_MSG_ID_Error_Concealment 23
+
+
+ /* #define RV_MSG_ID_* = 24; */
+ /* // Obsolete, do not use 24. */
+ /* #define RV_MSG_ID_* = 25; */
+ /* // Obsolete, do not use 25. */
+
+ /* */
+ /* Define a custom decoder message to be used when decoding a non-compliant */
+ /* H.263+ bitstream, that informs the decoder about information which is */
+ /* normally gleaned from parsing the picture header. In this scenario, the */
+ /* encoder is generating a bitstream having a lean and mean picture header. */
+ /* The invariant picture header contents are sent over the wire only once, */
+ /* prior to streaming any bitstreams. */
+ /* */
+#define RV_MSG_ID_Set_Picture_Header_Invariants 26
+ /* */
+ /* This message must be sent with the RV_MSG_Simple structure. */
+ /* Its value1 member is interpreted as a bit mask, described below. */
+ /* Its value2 member is not used. */
+ /* */
+ /* The following bits should be set or cleared, as appropriate, to indicate */
+ /* which codec options will be enabled or disabled for the video sequence. */
+ /* If any of these change, then the changes should be communicated to the */
+ /* decoder via this custom message prior to it seeing any input frames */
+ /* having the new state. */
+ /* */
+
+
+#define RV_MSG_SPHI_Slice_Structured_Mode 0x20
+
+
+ /* */
+ /* Define messages that are used with the RealVideo bitstream, */
+ /* to communicate the locations of slice boundaries between the front-end */
+ /* codec and the back-end encoder or decoder. */
+ /* */
+
+ typedef struct {
+ UINT32 is_valid;
+ UINT32 offset;
+ } RV_Segment_Info;
+ /* The RV_Segment_Info structure *MUST* be structurally equivalent */
+ /* to the PNCODEC_SEGMENTINFO structure defined in the RealVideo */
+ /* front-end. Typically an array of these structures is allocated, */
+ /* with each element describing one slice in a compressed bit stream. */
+ /* For the output of an encoder, is_valid is always true. 'offset' */
+ /* indicates the offset of a slice within an associated bitstream. */
+ /* The first slice is at offset 0. */
+
+ typedef struct {
+ RV_Custom_Message_ID message_id;
+ /* message_id must be RV_MSG_ID_Get_Encode_Segment_Info */
+ /* or RV_MSG_ID_Set_Decode_Segment_Info. */
+
+ UINT32 number_of_segments;
+
+ RV_Segment_Info *segment_info;
+ } RV_Segment_Info_MSG;
+
+
+#define RV_MSG_ID_Set_Decode_Segment_Info 28
+ /* This message, sent with the RV_Segment_Info_MSG structure, is used */
+ /* to specify slice information to the decoder just prior to decoding */
+ /* a bitstream. */
+ /* number_of_segments should be set to one less than the number of */
+ /* slices in the frame about to be decoded. */
+ /* segment_info should point to an array of RV_Segment_Info */
+ /* structures, which point to the slice offsets of the bitstream */
+ /* that will be decoded next. */
+
+
+
+ /* */
+ /* Define a custom decoder message for setting the smoothing postfilter's */
+ /* strength. The strength ranges from 0 to RV_Maximum_Smoothing_Strength, */
+ /* inclusive. */
+ /* */
+ /* This message must be sent with the RV_MSG_Simple structure. */
+ /* Its value1 member should be RV_MSG_SET or RV_MSG_GET. */
+ /* For RV_MSG_SET, value2 should be assigned the desired strength setting. */
+ /* For RV_MSG_GET, value2 is assigned upon return to the current strength */
+ /* setting. */
+ /* */
+#define RV_MSG_ID_Smoothing_Strength 30
+
+#define RV_Maximum_Smoothing_Strength 3
+#define RV_Default_Smoothing_Strength 1
+
+
+
+ /* Define a message to set the number of sizes, as well as the list of sizes */
+ /* that are to be used for RealVideo-style RPR */
+ /* This information is transmitted in the SPO (once). The front-end uses */
+ /* the RV_MSG_ID_Set_RVDecoder_RPR_Data to communicate this information */
+ /* to the back-end. Then, if num_sizes != 0, the back-end will read the */
+ /* following information from the slice header: */
+ /* .. */
+ /* [TR (as before)] */
+ /* if num_sizes != 0 */
+ /* PCTSZ = getbits(log2(num_sizes)) */
+ /* [MBA (as before)] */
+ /* .. */
+
+
+#define RV_MSG_ID_Set_RVDecoder_RPR_Sizes 36
+
+ typedef struct {
+
+ RV_Custom_Message_ID message_id;
+ /* message_id must be RV_MSG_ID_Set_RVDecoder_RPR_Sizes. */
+
+ UINT32 num_sizes;
+ /* The number of sizes to be used (switched between). */
+ /* This number should include the original image size. */
+ /* The maximum number of sizes is currently limited to 8. */
+
+
+ UINT32 *sizes;
+ /* Pointer to array of image sizes. The array should have the */
+ /* following format: */
+ /* for (i = 0; i < num_sizes; i++) { */
+ /* UINT32 horizontal_size[i] */
+ /* UINT32 vertical_size[i] */
+ /* } */
+ /* This array should include the original image size */
+ /* The order of sizes is not important. The decoder will */
+ /* use PCTSZ as an index to look up in the array: */
+ /* new_width = horizontal_size[PCTSZ] */
+ /* new_height = vertical_size[PCTSZ] */
+
+ } RV_MSG_RVDecoder_RPR_Sizes;
+
+
+
+
+ /* Define a custom message to obtain timings for parts of the decode */
+ /* For now, only the smoothing filte is interesting. */
+ /* More could be added later */
+
+#define RV_MSG_ID_Get_Decoder_Timings 42
+ typedef struct {
+
+ RV_Custom_Message_ID message_id;
+
+ double smoothing_time;
+ double fru_time;
+ } RV_MSG_Get_Decoder_Timings;
+
+
+ /* */
+ /* Define a custom message to set the video surface hardware */
+ /* allocator and its properties */
+
+#define RV_MSG_ID_Hw_Video_Memory 43
+ /* */
+ /* This message must be sent with the RV_MSG_Simple structure. */
+ /* Its value1 member should be RV_MSG_DISABLE, RV_MSG_ENABLE or RV_MSG_GET. */
+ /* For RV_MSG_GET, the current number of frame buffers is returned in value2, */
+ /* and RV_MSG_ENABLE or RV_MSG_DISABLE returned in value1 */
+
+
+ /* */
+ /* Define a custom message to perform postfiltering into video */
+ /* memory */
+ /* */
+#define RV_MSG_ID_PostfilterFrame 44
+ typedef struct {
+
+ RV_Custom_Message_ID message_id;
+ UINT8 * data;
+ UINT8 * dest_buffer;
+ UINT32 dest_pitch;
+ INT32 cid_dest_color_format;
+ UINT32 flags;
+ } RV_MSG_PostfilterFrame;
+
+
+
+ /* */
+ /* Define a custom message to release frame from video */
+ /* memory. */
+ /* 'data' is a pointer to a DecodedFrame structure */
+ /* */
+
+#define RV_MSG_ID_ReleaseFrame 45
+ typedef struct {
+
+ RV_Custom_Message_ID message_id;
+ UINT8 * data;
+ } RV_MSG_ReleaseFrame;
+
+
+ /* */
+ /* Define a custom message to retrieve latest DecodedFrame data */
+ /* */
+#define RV_MSG_ID_RetrieveFrame 46
+ typedef struct {
+
+ RV_Custom_Message_ID message_id;
+ void * frame;
+ } RV_MSG_RetrieveFrame;
+
+
+ /* */
+ /* Define a custom message to set the relied callback function */
+ /* that is the function to be called in the renderer in case */
+ /* it needs to blit (flip) a frame */
+ /* */
+
+#define RV_MSG_ID_SetReliefCallback 48
+ typedef struct {
+
+ RV_Custom_Message_ID message_id;
+ void * cmtm;
+ /* pointer to PN_CMTM struct (pncodec.h) */
+ } RV_MSG_SetReliefCallback;
+
+ /* */
+ /* Define a custom message that enables/disables FRU */
+ /* */
+#define RV_MSG_ID_Frame_Rate_Upsampling 49
+
+
+
+ /* */
+ /* Define a custom message to get CPU performance counters from the decoder. */
+ /* */
+#define RV_MSG_ID_Get_Decoder_Performance_Counters 52
+
+ typedef struct {
+ RV_Custom_Message_ID message_id;
+ UINT32 uNumCounters;
+ UINT32 *pCounters;
+ } RV_MSG_Get_Decoder_Performance_Counters;
+
+
+ /* */
+ /* Define a custom message to enable and disable multithreading in the decoder */
+ /* */
+#define RV_MSG_ID_Decoder_Multi_Threading 54
+
+ /* */
+ /* Define a custom message to enable decoding of beta streams with multiple threads */
+ /* */
+#define RV_MSG_ID_Decoder_Beta_Stream 55
+
+ /* */
+ /* Define a custom message to signal RV8 bitstream */
+ /* */
+#define RV_MSG_ID_RealVideo8 56
+
+ /* */
+ /* Define a custom message to retrieve latest DecodedFrame data */
+ /* */
+#define RV_MSG_ID_RetrieveFrameData 57
+ typedef struct {
+
+ RV_Custom_Message_ID message_id;
+ void * m_data;
+ UINT8 * m_pYPlane;
+ UINT8 * m_pUPlane;
+ UINT8 * m_pVPlane;
+ UINT32 m_pitch;
+ UINT32 m_width;
+ UINT32 m_height;
+ } RV_MSG_RetrieveFrameData;
+
+
+
+ /* */
+ /* Note to developers: */
+ /* */
+ /* Next available message ID is 58. */
+ /* But 100 and above might already be in use, in "ccustmsg.h", so be careful. */
+ /* */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RV_DECODE_MESSAGE_H */
diff --git a/audio_codec/libcook/rv_depack.c b/audio_codec/libcook/rv_depack.c
new file mode 100644
index 0000000..72da4d3
--- a/dev/null
+++ b/audio_codec/libcook/rv_depack.c
@@ -0,0 +1,271 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_depack.c,v 1.1.1.1.2.1 2005/05/04 18:21:20 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <memory.h>
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rv_depack.h"
+#include "rv_depack_internal.h"
+#include "rm_memory_default.h"
+#include "rm_error_default.h"
+#include "memory_utils.h"
+
+rv_depack* rv_depack_create(void* pAvail,
+ rv_frame_avail_func_ptr fpAvail,
+ void* pUserError,
+ rm_error_func_ptr fpError)
+{
+ return rv_depack_create2(pAvail,
+ fpAvail,
+ pUserError,
+ fpError,
+ HXNULL,
+ rm_memory_default_malloc,
+ rm_memory_default_free);
+}
+
+rv_depack* rv_depack_create2(void* pAvail,
+ rv_frame_avail_func_ptr fpAvail,
+ void* pUserError,
+ rm_error_func_ptr fpError,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree)
+{
+ rv_depack* pRet = HXNULL;
+
+ if (fpAvail && fpMalloc && fpFree) {
+ /* Allocate space for the rv_depack_internal struct
+ * by using the passed-in malloc function
+ */
+ rv_depack_internal* pInt =
+ (rv_depack_internal*) fpMalloc(pUserMem, sizeof(rv_depack_internal));
+ if (pInt) {
+ /* Zero out the struct */
+ memset((void*) pInt, 0, sizeof(rv_depack_internal));
+ /* Assign the frame callback members */
+ pInt->pAvail = pAvail;
+ pInt->fpAvail = fpAvail;
+ /*
+ * Assign the error members. If the caller did not
+ * provide an error callback, then use the default
+ * rm_error_default().
+ */
+ if (fpError) {
+ pInt->fpError = fpError;
+ pInt->pUserError = pUserError;
+ } else {
+ pInt->fpError = rm_error_default;
+ pInt->pUserError = HXNULL;
+ }
+ /* Assign the memory functions */
+ pInt->fpMalloc = fpMalloc;
+ pInt->fpFree = fpFree;
+ pInt->pUserMem = pUserMem;
+ /* Assign the return value */
+ pRet = (rv_depack*) pInt;
+ }
+ }
+
+ return pRet;
+}
+
+HX_RESULT rv_depack_init(rv_depack* pDepack, rm_stream_header* header)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pDepack && header) {
+ /* Get the internal struct */
+ rv_depack_internal* pInt = (rv_depack_internal*) pDepack;
+ /* Call the internal init */
+ retVal = rv_depacki_init(pInt, header);
+ }
+
+ return retVal;
+}
+
+UINT32 rv_depack_get_num_substreams(rv_depack* pDepack)
+{
+ UINT32 ulRet = 0;
+
+ if (pDepack) {
+ /* Get the internal struct */
+ rv_depack_internal* pInt = (rv_depack_internal*) pDepack;
+ /* Return the number of substreams */
+ ulRet = pInt->multiStreamHdr.ulNumSubStreams;
+ }
+
+ return ulRet;
+}
+
+UINT32 rv_depack_get_codec_4cc(rv_depack* pDepack)
+{
+ UINT32 ulRet = 0;
+
+ if (pDepack) {
+ /* Get the internal struct */
+ rv_depack_internal* pInt = (rv_depack_internal*) pDepack;
+ if (pInt->pSubStreamHdr &&
+ pInt->ulActiveSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Copy the subMOF tag */
+ ulRet = pInt->pSubStreamHdr[pInt->ulActiveSubStream].ulSubMOFTag;
+ }
+ }
+
+ return ulRet;
+}
+
+HX_RESULT rv_depack_get_codec_init_info(rv_depack* pDepack, rv_format_info** ppInfo)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pDepack && ppInfo) {
+ /* Get the internal struct */
+ rv_depack_internal* pInt = (rv_depack_internal*) pDepack;
+ if (pInt->pSubStreamHdr &&
+ pInt->ulActiveSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Clean up any existing format info */
+ rv_depacki_cleanup_format_info(pInt, *ppInfo);
+ /* Allocate memory for the format info */
+ *ppInfo = rv_depacki_malloc(pInt, sizeof(rv_format_info));
+ if (*ppInfo) {
+ /* NULL out the memory */
+ memset(*ppInfo, 0, sizeof(rv_format_info));
+ /* Make a deep copy of the format info */
+ retVal = rv_depacki_copy_format_info(pInt,
+ &pInt->pSubStreamHdr[pInt->ulActiveSubStream],
+ *ppInfo);
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rv_depack_destroy_codec_init_info(rv_depack* pDepack, rv_format_info** ppInfo)
+{
+ if (pDepack && ppInfo && *ppInfo) {
+ /* Get the internal struct */
+ rv_depack_internal* pInt = (rv_depack_internal*) pDepack;
+ /* Clean up the format info's internal allocs */
+ rv_depacki_cleanup_format_info(pInt, *ppInfo);
+ /* NULL it out */
+ memset(*ppInfo, 0, sizeof(rv_format_info));
+ /* Delete the memory associated with it */
+ rv_depacki_free(pInt, *ppInfo);
+ /* NULL the pointer out */
+ *ppInfo = HXNULL;
+ }
+}
+
+HX_RESULT rv_depack_add_packet(rv_depack* pDepack, rm_packet* packet)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pDepack && packet) {
+ /* Get the internal struct */
+ rv_depack_internal* pInt = (rv_depack_internal*) pDepack;
+ /* Call the internal function */
+ retVal = rv_depacki_add_packet(pInt, packet);
+ }
+
+ return retVal;
+}
+
+void rv_depack_destroy_frame(rv_depack* pDepack, rv_frame** ppFrame)
+{
+ if (pDepack && ppFrame && *ppFrame) {
+ /* Get the internal struct */
+ rv_depack_internal* pInt = (rv_depack_internal*) pDepack;
+ /* Call the internal function */
+ rv_depacki_cleanup_frame(pInt, ppFrame);
+ }
+}
+
+HX_RESULT rv_depack_seek(rv_depack* pDepack, UINT32 ulTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pDepack) {
+ /* Get the internal struct */
+ rv_depack_internal* pInt = (rv_depack_internal*) pDepack;
+ /* Call the internal function */
+ retVal = rv_depacki_seek(pInt, ulTime);
+ }
+
+ return retVal;
+}
+
+void rv_depack_destroy(rv_depack** ppDepack)
+{
+ if (ppDepack) {
+ rv_depack_internal* pInt = (rv_depack_internal*) * ppDepack;
+ if (pInt && pInt->fpFree) {
+ /* Save a pointer to fpFree and pUserMem */
+ rm_free_func_ptr fpFree = pInt->fpFree;
+ void* pUserMem = pInt->pUserMem;
+ /* Clean up the rule to flag map */
+ if (pInt->rule2Flag.pulMap) {
+ rv_depacki_free(pInt, pInt->rule2Flag.pulMap);
+ pInt->rule2Flag.pulMap = HXNULL;
+ pInt->rule2Flag.ulNumRules = 0;
+ }
+ /* Clean up the rule to header map */
+ if (pInt->multiStreamHdr.rule2SubStream.pulMap) {
+ rv_depacki_free(pInt, pInt->multiStreamHdr.rule2SubStream.pulMap);
+ pInt->multiStreamHdr.rule2SubStream.pulMap = HXNULL;
+ pInt->multiStreamHdr.rule2SubStream.ulNumRules = 0;
+ }
+ /* Clean up the format info array */
+ rv_depacki_cleanup_format_info_array(pInt);
+ /* Clean up ignore header array */
+ if (pInt->bIgnoreSubStream) {
+ rv_depacki_free(pInt, pInt->bIgnoreSubStream);
+ pInt->bIgnoreSubStream = HXNULL;
+ }
+ /* Clean up any current frame */
+ rv_depacki_cleanup_frame(pInt, &pInt->pCurFrame);
+ /* Null everything out */
+ memset(pInt, 0, sizeof(rv_depack_internal));
+ /* Free the rm_parser_internal struct memory */
+ fpFree(pUserMem, pInt);
+ /* NULL out the pointer */
+ *ppDepack = HXNULL;
+ }
+ }
+}
+
diff --git a/audio_codec/libcook/rv_depack.h b/audio_codec/libcook/rv_depack.h
new file mode 100644
index 0000000..f5a2878
--- a/dev/null
+++ b/audio_codec/libcook/rv_depack.h
@@ -0,0 +1,162 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_depack.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV_DEPACK_H
+#define RV_DEPACK_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_error.h"
+#include "rm_memory.h"
+#include "rm_stream.h"
+#include "rm_packet.h"
+#include "rv_format_info.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* Callback functions */
+ typedef HX_RESULT(*rv_frame_avail_func_ptr)(void* pAvail, UINT32 ulSubStreamNum, rv_frame* frame);
+
+ /*
+ * rv_depack definition. Opaque to user.
+ */
+ typedef void rv_depack;
+
+ /*
+ * rv_depack_create
+ */
+ rv_depack* rv_depack_create(void* pAvail,
+ rv_frame_avail_func_ptr fpAvail,
+ void* pUserError,
+ rm_error_func_ptr fpError);
+
+ /*
+ * rv_depack_create2
+ *
+ * This is the same as rv_depack_create(), but it allows
+ * the user to use custom memory allocation and free functions.
+ */
+ rv_depack* rv_depack_create2(void* pAvail,
+ rv_frame_avail_func_ptr fpAvail,
+ void* pUserError,
+ rm_error_func_ptr fpError,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+
+ /*
+ * rv_depack_init
+ *
+ * This is initialized with a RealVideo rm_stream_header struct.
+ */
+ HX_RESULT rv_depack_init(rv_depack* pDepack, rm_stream_header* header);
+
+ /*
+ * rv_depack_get_num_substreams
+ *
+ * This accessor function tells how many video substreams there are
+ * in this video stream. For single-rate video streams, this will be 1. For
+ * SureStream video streams, this could be greater than 1.
+ */
+ UINT32 rv_depack_get_num_substreams(rv_depack* pDepack);
+
+ /*
+ * rv_depack_get_codec_4cc
+ *
+ * This accessor function returns the 4cc of the codec. This 4cc
+ * will be used to determine which codec to use. RealVideo always
+ * uses the same codec for all substreams.
+ */
+ UINT32 rv_depack_get_codec_4cc(rv_depack* pDepack);
+
+ /*
+ * rv_depack_get_codec_init_info
+ *
+ * This function fills in the structure which is used to initialize the codec.
+ */
+ HX_RESULT rv_depack_get_codec_init_info(rv_depack* pDepack, rv_format_info** ppInfo);
+
+ /*
+ * rv_depack_destroy_codec_init_info
+ *
+ * This function frees the memory associated with the rv_format_info object
+ * created by rv_depack_get_codec_init_info().
+ */
+ void rv_depack_destroy_codec_init_info(rv_depack* pDepack, rv_format_info** ppInfo);
+
+ /*
+ * rv_depack_add_packet
+ *
+ * Put a video packet into the depacketizer. When enough data is
+ * present to depacketize, then the user will be called back
+ * on the rv_frame_avail_func_ptr set in rv_depack_create().
+ */
+ HX_RESULT rv_depack_add_packet(rv_depack* pDepack, rm_packet* packet);
+
+ /*
+ * rv_depack_destroy_frame
+ *
+ * This cleans up a frame that was returned via
+ * the rv_frame_avail_func_ptr.
+ */
+ void rv_depack_destroy_frame(rv_depack* pDepack, rv_frame** ppFrame);
+
+ /*
+ * rv_depack_seek
+ *
+ * The user calls this function if the stream is seeked. It
+ * should be called before passing any post-seek packets. After calling
+ * rv_depack_seek(), no more pre-seek packets should be
+ * passed into rv_depack_add_packet().
+ */
+ HX_RESULT rv_depack_seek(rv_depack* pDepack, UINT32 ulTime);
+
+ /*
+ * rv_depack_destroy
+ *
+ * This cleans up all memory allocated by the rv_depack_* calls
+ */
+ void rv_depack_destroy(rv_depack** ppDepack);
+
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RV_DEPACK_H */
diff --git a/audio_codec/libcook/rv_depack_internal.c b/audio_codec/libcook/rv_depack_internal.c
new file mode 100644
index 0000000..951d7db
--- a/dev/null
+++ b/audio_codec/libcook/rv_depack_internal.c
@@ -0,0 +1,1071 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_depack_internal.c,v 1.1.1.1.2.1 2005/05/04 18:21:20 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <stdio.h>
+#include <string.h>
+#include <memory.h>
+//#include "includes.h"
+#include "helix_types.h"
+#include "helix_result.h"
+#include "pack_utils.h"
+#include "string_utils.h"
+#include "memory_utils.h"
+#include "packet_defines.h"
+#include "codec_defines.h"
+#include "stream_hdr_structs.h"
+#include "stream_hdr_utils.h"
+#include "rv_depack_internal.h"
+
+#define RM_MAX_UINT14 0x00003FFF
+#define RM_MAX_UINT30 0x3FFFFFFF
+#define MAX_INTERNAL_TIMESTAMP_DELTA 60000
+
+void* rv_depacki_malloc(rv_depack_internal* pInt, UINT32 ulSize)
+{
+ void* pRet = HXNULL;
+
+ if (pInt && pInt->fpMalloc) {
+ pRet = pInt->fpMalloc(pInt->pUserMem, ulSize);
+ }
+
+ return pRet;
+}
+
+void rv_depacki_free(rv_depack_internal* pInt, void* pMem)
+{
+ if (pInt && pInt->fpFree) {
+ pInt->fpFree(pInt->pUserMem, pMem);
+ }
+}
+
+HX_RESULT rv_depacki_init(rv_depack_internal* pInt, rm_stream_header* hdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && hdr) {
+ /* Initialize local variables */
+ UINT32 ulTmp = 0;
+ BYTE* pTmp = HXNULL;
+ UINT32 i = 0;
+ /* Check if we have a "HasRelativeTS" property - OK if we don't */
+ if (HX_SUCCEEDED(rm_stream_get_property_int(hdr, "HasRelativeTS", &ulTmp))) {
+ pInt->bHasRelativeTimeStamps = (ulTmp ? TRUE : FALSE);
+ }
+ /* Check if we have a "ZeroTimeOffset" property - OK if we don't */
+ if (HX_SUCCEEDED(rm_stream_get_property_int(hdr, "ZeroTimeOffset", &ulTmp))) {
+ pInt->ulZeroTimeOffset = ulTmp;
+ }
+ /* Check if we have a "RMFF 1.0 Flags" property */
+ retVal = rm_stream_get_property_buf(hdr, "RMFF 1.0 Flags", &pTmp, &ulTmp);
+ if (retVal == HXR_OK) {
+ /* Unpack the rule2Flag map */
+ rv_depacki_unpack_rule_map(pInt, &pInt->rule2Flag, &pTmp, &ulTmp);
+ /* Check if we have an "OpaqueData" property */
+ retVal = rm_stream_get_property_buf(hdr, "OpaqueData", &pTmp, &ulTmp);
+ if (retVal == HXR_OK) {
+ /* Unpack the opaque data */
+ retVal = rv_depacki_unpack_opaque_data(pInt, pTmp, ulTmp);
+ if (retVal == HXR_OK) {
+ /*
+ * Now that we've parsed all the headers, we need
+ * to see if there are any that need to be ignored.
+ * To do this, we parse the rules in the ASMRuleBook,
+ * and any rules that have "$OldPNMPlayer" as an expression,
+ * we will ignore.
+ */
+ retVal = rv_depacki_check_rule_book(pInt, hdr);
+ if (retVal == HXR_OK) {
+ /*
+ * Now select the first non-ignored substream. If
+ * we are not surestream, this of course will be zero.
+ */
+ pInt->ulActiveSubStream = 0;
+ if (pInt->bStreamSwitchable) {
+ for (i = 0; i < pInt->multiStreamHdr.ulNumSubStreams; i++) {
+ if (!pInt->bIgnoreSubStream[i]) {
+ pInt->ulActiveSubStream = i;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_unpack_rule_map(rv_depack_internal* pInt,
+ rm_rule_map* pMap,
+ BYTE** ppBuf,
+ UINT32* pulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ retVal = rm_unpack_rule_map(ppBuf, pulLen,
+ pInt->fpMalloc,
+ pInt->fpFree,
+ pInt->pUserMem,
+ pMap);
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_unpack_multistream_hdr(rv_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ retVal = rm_unpack_multistream_hdr(ppBuf, pulLen,
+ pInt->fpMalloc,
+ pInt->fpFree,
+ pInt->pUserMem,
+ &pInt->multiStreamHdr);
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_unpack_opaque_data(rv_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pBuf && ulLen >= 4) {
+ /* Initialize local variables */
+ UINT32 ulSize = 0;
+ UINT32 ulID = 0;
+ UINT32 i = 0;
+ /*
+ * If the first four bytes are MLTI, then we
+ * know the opaque data contains a multistream header
+ * followed by several normal headers. So first we
+ * need to check the first four bytes.
+ */
+ ulID = rm_unpack32(&pBuf, &ulLen);
+ /* Now back up 4 bytes */
+ pBuf -= 4;
+ ulLen += 4;
+ /* Is this a multistream header? */
+ if (ulID == RM_MULTIHEADER_OBJECT) {
+ /* Unpack the multistream header */
+ retVal = rv_depacki_unpack_multistream_hdr(pInt, &pBuf, &ulLen);
+ if (retVal == HXR_OK) {
+ pInt->bStreamSwitchable = TRUE;
+ }
+ } else {
+ /* Single-rate stream */
+ pInt->multiStreamHdr.ulNumSubStreams = 1;
+ /* Clear the stream switchable flag */
+ pInt->bStreamSwitchable = FALSE;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ /* Clean up any existing substream header array */
+ rv_depacki_cleanup_format_info_array(pInt);
+ /* Set the return value */
+ retVal = HXR_FAIL;
+ /* Allocate space for substream header array */
+ ulSize = pInt->multiStreamHdr.ulNumSubStreams * sizeof(rv_format_info);
+ pInt->pSubStreamHdr = (rv_format_info*) rv_depacki_malloc(pInt, ulSize);
+ if (pInt->pSubStreamHdr) {
+ /* NULL out the memory */
+ memset(pInt->pSubStreamHdr, 0, ulSize);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Loop through and unpack each substream header */
+ for (i = 0; i < pInt->multiStreamHdr.ulNumSubStreams && retVal == HXR_OK; i++) {
+ /* Is this a multiheader? */
+ if (pInt->bStreamSwitchable) {
+ /*
+ * If this is a multistream header, then there
+ * is a 4-byte length in front of every substream header
+ */
+ if (ulLen >= 4) {
+ ulSize = rm_unpack32(&pBuf, &ulLen);
+ } else {
+ retVal = HXR_FAIL;
+ }
+ }
+ /* Now unpack an substream header */
+ retVal = rv_depacki_unpack_format_info(pInt,
+ &pInt->pSubStreamHdr[i],
+ &pBuf, &ulLen);
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rv_depacki_cleanup_format_info(rv_depack_internal* pInt,
+ rv_format_info* pInfo)
+{
+ if (pInt && pInfo && pInfo->pOpaqueData) {
+ rv_depacki_free(pInt, pInfo->pOpaqueData);
+ pInfo->pOpaqueData = HXNULL;
+ pInfo->ulOpaqueDataSize = 0;
+ }
+}
+
+void rv_depacki_cleanup_format_info_array(rv_depack_internal* pInt)
+{
+ if (pInt && pInt->pSubStreamHdr) {
+ /* Clean up each individual rv_format_info */
+ UINT32 i = 0;
+ for (i = 0; i < pInt->multiStreamHdr.ulNumSubStreams; i++) {
+ rv_depacki_cleanup_format_info(pInt, &pInt->pSubStreamHdr[i]);
+ }
+ /* Clean up the array */
+ rv_depacki_free(pInt, pInt->pSubStreamHdr);
+ pInt->pSubStreamHdr = HXNULL;
+ }
+}
+
+HX_RESULT rv_depacki_unpack_format_info(rv_depack_internal* pInt,
+ rv_format_info* pInfo,
+ BYTE** ppBuf,
+ UINT32* pulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInfo && ppBuf && *ppBuf && pulLen && *pulLen >= 26) {
+ /* Clean up any existing opaque data */
+ rv_depacki_cleanup_format_info(pInt, pInfo);
+ /* Unpack the format info struct */
+ pInfo->ulLength = rm_unpack32(ppBuf, pulLen);
+ pInfo->ulMOFTag = rm_unpack32(ppBuf, pulLen);
+ pInfo->ulSubMOFTag = rm_unpack32(ppBuf, pulLen);
+ pInfo->usWidth = rm_unpack16(ppBuf, pulLen);
+ pInfo->usHeight = rm_unpack16(ppBuf, pulLen);
+ pInfo->usBitCount = rm_unpack16(ppBuf, pulLen);
+ pInfo->usPadWidth = rm_unpack16(ppBuf, pulLen);
+ pInfo->usPadHeight = rm_unpack16(ppBuf, pulLen);
+ pInfo->ufFramesPerSecond = rm_unpack32(ppBuf, pulLen);
+ /* Fix up the subMOF tag */
+ if (pInfo->ulSubMOFTag == HX_RVTRVIDEO_ID) {
+ pInfo->ulSubMOFTag = HX_RV20VIDEO_ID;
+ } else if (pInfo->ulSubMOFTag == HX_RVTR_RV30_ID) {
+ pInfo->ulSubMOFTag = HX_RV30VIDEO_ID;
+ }
+ /* Compute the size of the opaque data */
+ pInfo->ulOpaqueDataSize = pInfo->ulLength - 26;
+ /* Make sure we have enough left in the parsing buffer */
+ if (*pulLen >= pInfo->ulOpaqueDataSize) {
+ /* Allocate a buffer of this size */
+ pInfo->pOpaqueData = (BYTE*) rv_depacki_malloc(pInt, pInfo->ulOpaqueDataSize);
+ if (pInfo->pOpaqueData) {
+ /* Copy the buffer */
+ memcpy(pInfo->pOpaqueData, *ppBuf, pInfo->ulOpaqueDataSize);
+ /* Advance the buffer */
+ *ppBuf += pInfo->ulOpaqueDataSize;
+ *pulLen -= pInfo->ulOpaqueDataSize;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_check_rule_book(rv_depack_internal* pInt, rm_stream_header* hdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && hdr) {
+ UINT32 ulSize = 0;
+ HXBOOL* pTmp = HXNULL;
+ char* pszRuleBook = HXNULL;
+ char* pStr = HXNULL;
+ char* pStrLimit = HXNULL;
+ UINT32 ulRule = 0;
+ UINT32 ulSubStream = 0;
+ const char* pszPNMStr = "$OldPNMPlayer";
+ UINT32 ulPNMStrLen = strlen(pszPNMStr);
+ UINT32 ulNumRules = pInt->multiStreamHdr.rule2SubStream.ulNumRules;
+ UINT32 ulNumSubStreams = pInt->multiStreamHdr.ulNumSubStreams;
+ /* Is this SureStream? */
+ if (pInt->bStreamSwitchable) {
+ /* Get the ASM Rule book */
+ retVal = rm_stream_get_property_str(hdr, "ASMRuleBook", &pszRuleBook);
+ if (retVal == HXR_OK) {
+ /* Allocate space for the ignore header flags */
+ ulSize = ulNumSubStreams * sizeof(HXBOOL);
+ pInt->bIgnoreSubStream = (HXBOOL*) rv_depacki_malloc(pInt, ulSize);
+ if (pInt->bIgnoreSubStream) {
+ /* NULL out the memory */
+ memset(pInt->bIgnoreSubStream, 0, ulSize);
+ /* Allocate space for temporary boolean array */
+ ulSize = ulNumRules * sizeof(HXBOOL);
+ pTmp = (HXBOOL*) rv_depacki_malloc(pInt, ulSize);
+ if (pTmp) {
+ /* NULL out the array */
+ memset(pTmp, 0, ulSize);
+ /* Parse the string */
+ pStr = pszRuleBook;
+ pStrLimit = pszRuleBook + strlen(pszRuleBook);
+ ulRule = 0;
+ while (pStr < pStrLimit && *pStr) {
+ while (pStr < pStrLimit && *pStr != ';') {
+ /* ignore quoted strings */
+ if (*pStr == '"') {
+ /* step past open quote */
+ pStr++;
+ /* ignore the string */
+ while (pStr < pStrLimit && *pStr != '"') {
+ pStr++;
+ }
+ /* step past end quote occurs at bottom of while !';' loop. */
+ }
+
+ if (pStr + ulPNMStrLen < pStrLimit && *pStr == '$') {
+ /* check to see if we have a $OldPNMPlayer variable */
+ if (!strncasecmp(pszPNMStr, pStr, ulPNMStrLen)) {
+ pStr += ulPNMStrLen;
+ pTmp[ulRule] = TRUE;
+ }
+ }
+ pStr++;
+ }
+ /* step past the ';' */
+ pStr++;
+ /* next rule */
+ ulRule++;
+ }
+ /*
+ * Now if pTmp[i] == TRUE, then we should ignore the
+ * substreams which correspond to rule i
+ */
+ for (ulRule = 0; ulRule < ulNumRules; ulRule++) {
+ ulSubStream = rv_depacki_rule_to_substream(pInt, ulRule);
+ if (ulSubStream < ulNumSubStreams) {
+ pInt->bIgnoreSubStream[ulSubStream] = pTmp[ulRule];
+ }
+ }
+ }
+ }
+ }
+ } else {
+ /* Not an error */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_copy_format_info(rv_depack_internal* pInt,
+ rv_format_info* pSrc,
+ rv_format_info* pDst)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pSrc && pDst) {
+ /* Clean up any existing format info */
+ rv_depacki_cleanup_format_info(pInt, pDst);
+ /* Copy the members */
+ pDst->ulLength = pSrc->ulLength;
+ pDst->ulMOFTag = pSrc->ulMOFTag;
+ pDst->ulSubMOFTag = pSrc->ulSubMOFTag;
+ pDst->usWidth = pSrc->usWidth;
+ pDst->usHeight = pSrc->usHeight;
+ pDst->usBitCount = pSrc->usBitCount;
+ pDst->usPadWidth = pSrc->usPadWidth;
+ pDst->usPadHeight = pSrc->usPadHeight;
+ pDst->ufFramesPerSecond = pSrc->ufFramesPerSecond;
+ pDst->ulOpaqueDataSize = pSrc->ulOpaqueDataSize;
+ /* Copy the opaque data buffer */
+ pDst->pOpaqueData = copy_buffer(pInt->pUserMem,
+ pInt->fpMalloc,
+ pSrc->pOpaqueData,
+ pSrc->ulOpaqueDataSize);
+ if (pDst->pOpaqueData) {
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_add_packet(rv_depack_internal* pInt,
+ rm_packet* pPacket)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pPacket) {
+ /* Init local variables */
+ BYTE* pBuf = pPacket->pData;
+ UINT32 ulLen = (UINT32) pPacket->usDataLen;
+ UINT32 ulSubStream = 0;
+ rv_frame_hdr hdr;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Make sure we are not ignoring this substream */
+ ulSubStream = rv_depacki_rule_to_substream(pInt, pPacket->ucASMRule);
+ if (!pInt->bStreamSwitchable ||
+ !pInt->bIgnoreSubStream[ulSubStream]) {
+ /* Loop through the packet buffer */
+ while (ulLen && retVal == HXR_OK) {
+ /* Parse the current point in the packet buffer */
+ retVal = rv_depacki_parse_frame_header(pInt, &pBuf, &ulLen, pPacket, &hdr);
+ if (retVal == HXR_OK) {
+ /* Switch based on frame header type */
+ switch (hdr.eType) {
+ case RVFrameTypePartial:
+ case RVFrameTypeLastPartial:
+ retVal = rv_depacki_handle_partial(pInt, &pBuf, &ulLen, pPacket, &hdr);
+ break;
+ case RVFrameTypeMultiple:
+ case RVFrameTypeWhole:
+ retVal = rv_depacki_handle_one_frame(pInt, &pBuf, &ulLen, pPacket, &hdr);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+UINT32 rv_depacki_rule_to_flags(rv_depack_internal* pInt, UINT32 ulRule)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt &&
+ pInt->rule2Flag.pulMap &&
+ ulRule < pInt->rule2Flag.ulNumRules) {
+ ulRet = pInt->rule2Flag.pulMap[ulRule];
+ }
+
+ return ulRet;
+}
+
+UINT32 rv_depacki_rule_to_substream(rv_depack_internal* pInt, UINT32 ulRule)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt &&
+ pInt->multiStreamHdr.rule2SubStream.pulMap &&
+ ulRule < pInt->multiStreamHdr.rule2SubStream.ulNumRules) {
+ ulRet = pInt->multiStreamHdr.rule2SubStream.pulMap[ulRule];
+ }
+
+ return ulRet;
+}
+
+HX_RESULT rv_depacki_parse_frame_header(rv_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_packet* pPacket,
+ rv_frame_hdr* pFrameHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && ppBuf && pulLen && pFrameHdr && *pulLen >= 2 &&
+ *ppBuf >= pPacket->pData &&
+ *ppBuf < pPacket->pData + pPacket->usDataLen) {
+ /* Initialize local variables */
+ UINT32 ulTmp = 0;
+ HXBOOL bTmp = FALSE;
+ UINT32 ulOrigPacketTimeStamp = 0;
+ UINT32 ulClippedPacketTS = 0;
+ UINT32 ulDelta = 0;
+ BYTE* pBufAtStart = *ppBuf;
+ /* Set the offset of the header in the packet */
+ pFrameHdr->ulHeaderOffset = pBufAtStart - pPacket->pData;
+ /* Parse the RVFrameType */
+ pFrameHdr->eType = (RVFrameType)((pBufAtStart[0] & 0xC0) >> 6);
+ /* Switch based on frame type */
+ switch (pFrameHdr->eType) {
+ case RVFrameTypePartial:
+ case RVFrameTypeLastPartial:
+ /* Unpack the bit field */
+ ulTmp = rm_unpack16(ppBuf, pulLen);
+ pFrameHdr->ulNumPackets = ((ulTmp & 0x00003F80) >> 7);
+ pFrameHdr->ulPacketNum = (ulTmp & 0x0000007F);
+ /* Read the frame size */
+ retVal = rv_depacki_read_14_or_30(ppBuf, pulLen,
+ &pFrameHdr->bBrokenUpByUs,
+ &pFrameHdr->ulFrameSize);
+ if (retVal == HXR_OK) {
+ /* Read the partial size or offset */
+ ulTmp = 0;
+ retVal = rv_depacki_read_14_or_30(ppBuf, pulLen, &bTmp, &ulTmp);
+ if (retVal == HXR_OK) {
+ /* Make sure we have one byte */
+ if (*pulLen >= 1) {
+ /* Get the sequence number */
+ pFrameHdr->ulSeqNum = rm_unpack8(ppBuf, pulLen);
+ /* Assign the timestamp */
+ pFrameHdr->ulTimestamp = pPacket->ulTime;
+ /* Compute the header size */
+ pFrameHdr->ulHeaderSize = *ppBuf - pBufAtStart;
+ /* Assign the partial frame size and the partial frame offset. */
+ if (pFrameHdr->eType == RVFrameTypePartial) {
+ /*
+ * For partial frames the partial_size_or_offset
+ * member contains the offset into the frame. The size
+ * of the partial frame is just the amount of data
+ * in the packet minus the header size.
+ */
+ pFrameHdr->ulPartialFrameOffset = ulTmp;
+ pFrameHdr->ulPartialFrameSize = ((UINT32) pPacket->usDataLen) -
+ pFrameHdr->ulHeaderSize;
+ } else {
+ /*
+ * For last-partial frames, there could be other frame
+ * data after this, so the partial_size_or_offset field
+ * contains the partial frame size, not offset. We then
+ * compute the offset by subtracting the overall frame
+ * size from the partial frame size.
+ */
+ pFrameHdr->ulPartialFrameSize = ulTmp;
+ pFrameHdr->ulPartialFrameOffset = pFrameHdr->ulFrameSize - ulTmp;
+ }
+ } else {
+ retVal = HXR_FAIL;
+ }
+ }
+ }
+ break;
+ case RVFrameTypeWhole:
+ /* Skip the one-byte frame type */
+ rm_unpack8(ppBuf, pulLen);
+ /* Unpack the sequence number */
+ pFrameHdr->ulSeqNum = rm_unpack8(ppBuf, pulLen);
+ /* Compute the header size */
+ pFrameHdr->ulHeaderSize = *ppBuf - pBufAtStart;
+ /* Assign the frame header members */
+ pFrameHdr->ulNumPackets = 1;
+ pFrameHdr->ulPacketNum = 1;
+ pFrameHdr->ulFrameSize = ((UINT32) pPacket->usDataLen) -
+ pFrameHdr->ulHeaderSize;
+ pFrameHdr->ulTimestamp = pPacket->ulTime;
+ pFrameHdr->bBrokenUpByUs = FALSE;
+ pFrameHdr->ulPartialFrameOffset = 0;
+ pFrameHdr->ulPartialFrameSize = 0;
+ /* Clear return value */
+ retVal = HXR_OK;
+ break;
+ case RVFrameTypeMultiple:
+ /*
+ * For multiple frames, we still set ulNumPackets
+ * and ulPacketNum to 1, even though we know
+ * there are multiple packets.
+ */
+ pFrameHdr->ulNumPackets = 1;
+ pFrameHdr->ulPacketNum = 1;
+ /* Skip the frame type */
+ rm_unpack8(ppBuf, pulLen);
+ /* Unpack the frame size */
+ retVal = rv_depacki_read_14_or_30(ppBuf, pulLen, &bTmp,
+ &pFrameHdr->ulFrameSize);
+ if (retVal == HXR_OK) {
+ /* For multiple frames, there is no partial size or offset */
+ pFrameHdr->ulPartialFrameOffset = 0;
+ pFrameHdr->ulPartialFrameSize = 0;
+ /* Unpack the timestamp */
+ retVal = rv_depacki_read_14_or_30(ppBuf, pulLen, &bTmp,
+ &pFrameHdr->ulTimestamp);
+ if (retVal == HXR_OK) {
+ /* Does this stream have relative timestamps? */
+ if (pInt->bHasRelativeTimeStamps) {
+ /*
+ * Yes, we have relative timestamps so offset
+ * the timestamp in the frame header by the
+ * packet timestamp.
+ */
+ pFrameHdr->ulTimestamp += pPacket->ulTime;
+ } else {
+ /* No relative timestamps */
+ ulOrigPacketTimeStamp = pPacket->ulTime + pInt->ulZeroTimeOffset;
+ /*
+ * Because of a bug in the original Write14or30() which didn't mask
+ * the high bytes of the timestamp before |ing them with the flags,
+ * it's possible to read frame headers that are screwed up. If the
+ * application using this class sets the timestamp of the network packet
+ * before unpacking the header, we can determine if this header is
+ * screwed up and fix it.
+ */
+ /*
+ * If the time stamp returned is less than the packet timestamp
+ * something is screwed up. If the packet timestamp is > 14 bits,
+ * the frame timestamp is < the packet timestamp and the packet
+ * timestamp is < 14 bits then the Write14or30 bug described above
+ * may have occured. It's possible for rollover to occur and trigger
+ * this so we check for that too. If the bug occured, we want to read 30 bits.
+ */
+ if (ulOrigPacketTimeStamp > RM_MAX_UINT14 &&
+ ulOrigPacketTimeStamp > pFrameHdr->ulTimestamp &&
+ pFrameHdr->ulTimestamp < RM_MAX_UINT14 &&
+ /*
+ * check for rollover. If we assume ulOrigPacketTimeStamp is from before
+ * rollover and m_ulTimeStamp is from after, the left hand expression below
+ * should be a small number because m_ulPacketTimeSamp will be close to
+ * MAX_UINT30 and m_ulTimeStamp will be close to 0. I chose 60 seconds
+ * since two frames 60 seconds appart shouldn't be in the same packet
+ * due to latency considerations in the encoder. JEFFA 4/28/99
+ */
+ !(((RM_MAX_UINT30 - ulOrigPacketTimeStamp) + pFrameHdr->ulTimestamp) <= 60000UL)) {
+ /* We should have read 14 bits, so back up 2 bytes */
+ *ppBuf -= 2;
+ *pulLen += 2;
+ /* Now read 32 bits instead */
+ pFrameHdr->ulTimestamp = rm_unpack32(ppBuf, pulLen);
+ }
+
+ /* Clip the timestamp at 30 bits */
+ ulClippedPacketTS = (ulOrigPacketTimeStamp & RM_MAX_UINT30);
+ /*
+ * Much code in the system assumes full 32 bit typestamps; reconstruct
+ * them here. We assume child timestamps are no more than 2^30 - 1 away
+ */
+ ulDelta = (pFrameHdr->ulTimestamp >= ulClippedPacketTS ?
+ pFrameHdr->ulTimestamp - ulClippedPacketTS :
+ RM_MAX_UINT30 - ulClippedPacketTS + pFrameHdr->ulTimestamp);
+ pFrameHdr->ulTimestamp = ulOrigPacketTimeStamp + ulDelta;
+ /* If we have a zero time offset, we need to offset this timestamp */
+ pFrameHdr->ulTimestamp -= pInt->ulZeroTimeOffset;
+
+ /*
+ * Ensure that we have not caused the timestamp to fall behind
+ * the packet timestamp when we have subtracted zero time offset
+ */
+ if (pInt->ulZeroTimeOffset &&
+ (((INT32) pFrameHdr->ulTimestamp) - ((INT32) pPacket->ulTime) < 0)) {
+ pFrameHdr->ulTimestamp = pPacket->ulTime;
+ }
+
+ /*
+ * If older rmffplin is serving this slta stream and internal
+ * frame timestamp is much larger than pkt timestamp, then
+ * we are dealing with un-translated-for-slta-live internal
+ * frame timestamps (the above calculation w/ ulDelta made
+ * super-small timestamps into super-large ones). Here, we
+ * adjust and make the internal timestamp equal to the pkt timestamp
+ */
+ if (pFrameHdr->ulTimestamp - pPacket->ulTime > MAX_INTERNAL_TIMESTAMP_DELTA) {
+ pFrameHdr->ulTimestamp = pPacket->ulTime;
+ }
+ }
+ /* Read the sequence number */
+ pFrameHdr->ulSeqNum = rm_unpack8(ppBuf, pulLen);
+ }
+ }
+ break;
+ }
+ if (retVal == HXR_OK) {
+ /* Compute the number of bytes in the frame header we just parsed. */
+ pFrameHdr->ulHeaderSize = *ppBuf - pBufAtStart;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_read_14_or_30(BYTE** ppBuf,
+ UINT32* pulLen,
+ HXBOOL* pbHiBit,
+ UINT32* pulValue)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (ppBuf && pulLen && pbHiBit && pulValue && *ppBuf && *pulLen >= 2) {
+ /* Init local variables */
+ UINT32 ulTmp = (*ppBuf)[0];
+ /* Assign the high bit */
+ *pbHiBit = ((ulTmp & 0x80) ? TRUE : FALSE);
+ /*
+ * Check the length bit. If it's 1, then
+ * this is a 14-bit value. If it's 0, then
+ * this is a 30-bit value.
+ */
+ if (ulTmp & 0x40) {
+ /*
+ * This is a 14-bit value, so unpack 16 bits.
+ * We don't need to check the buffer size, since
+ * we already checked for a minimum of 2 bytes above.
+ */
+ ulTmp = rm_unpack16(ppBuf, pulLen);
+ /* Mask out the upper two bits */
+ *pulValue = (ulTmp & 0x00003FFF);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ } else {
+ /* This is a 30-bit value, so check size */
+ if (*pulLen >= 4) {
+ /* Unpack 32 bits */
+ ulTmp = rm_unpack32(ppBuf, pulLen);
+ /* Mask out the upper 2 bits */
+ *pulValue = (ulTmp & 0x3FFFFFFF);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_handle_partial(rv_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_packet* pPacket,
+ rv_frame_hdr* pFrameHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && ppBuf && pulLen && pPacket && pFrameHdr && *ppBuf) {
+ /* Init local variables */
+ UINT32 i = 0;
+ UINT32 ulOffset = 0;
+ HXBOOL bAllThere = FALSE;
+ /* Clear the reutrn value */
+ retVal = HXR_OK;
+ /*
+ * If we have a current frame and its timestamp
+ * is different from the packet timestamp,
+ * then we will send it.
+ */
+ if (pInt->pCurFrame &&
+ pInt->pCurFrame->ulTimestamp != pPacket->ulTime) {
+ /* Send the current frame */
+ retVal = rv_depacki_send_current_frame(pInt);
+ }
+ /* Do we have a current frame? */
+ if (retVal == HXR_OK && !pInt->pCurFrame) {
+ /* We don't have a current frame, so create one */
+ retVal = rv_depacki_create_frame(pInt, pPacket, pFrameHdr,
+ &pInt->pCurFrame);
+ }
+ if (retVal == HXR_OK) {
+ /* Set the return value */
+ retVal = HXR_FAIL;
+ /* Sanity check */
+ ulOffset = pFrameHdr->ulPartialFrameOffset + pFrameHdr->ulPartialFrameSize;
+ if (ulOffset <= pInt->pCurFrame->ulDataLen &&
+ *pulLen >= pFrameHdr->ulPartialFrameSize &&
+ pFrameHdr->ulPacketNum - 1 < pInt->pCurFrame->ulNumSegments) {
+ /* Copy the data into the frame data buffer */
+ memcpy(pInt->pCurFrame->pData + pFrameHdr->ulPartialFrameOffset,
+ *ppBuf,
+ pFrameHdr->ulPartialFrameSize);
+ /* The segment indices in the frame header are 1-based */
+ i = pFrameHdr->ulPacketNum - 1;
+ /* Update the segment information */
+ pInt->pCurFrame->pSegment[i].bIsValid = TRUE;
+ pInt->pCurFrame->pSegment[i].ulOffset = pFrameHdr->ulPartialFrameOffset;
+ /*
+ * Set the offset for the segment after this one and all other
+ * segments until we find a valid one or we run out of segments.
+ * This allows a codec to know where missing data would go for
+ * single loss. For multiple loss in a row the offset is set
+ * to the same offset since the size of the missing segments
+ * isn't known.
+ */
+ for (i = pFrameHdr->ulPacketNum;
+ i < pInt->pCurFrame->ulNumSegments &&
+ !pInt->pCurFrame->pSegment[i].bIsValid;
+ i++) {
+ pInt->pCurFrame->pSegment[i].ulOffset = ulOffset;
+ }
+ /* Check to see if all segments are present */
+ bAllThere = TRUE;
+ for (i = 0; i < pInt->pCurFrame->ulNumSegments && bAllThere; i++) {
+ bAllThere = pInt->pCurFrame->pSegment[i].bIsValid;
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Are all segments present? */
+ if (bAllThere) {
+ /* We've got the entire packet, so send it */
+ retVal = rv_depacki_send_current_frame(pInt);
+ }
+ if (retVal == HXR_OK) {
+ /* Advance the buffer */
+ *ppBuf += pFrameHdr->ulPartialFrameSize;
+ *pulLen -= pFrameHdr->ulPartialFrameSize;
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_handle_one_frame(rv_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_packet* pPacket,
+ rv_frame_hdr* pFrameHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && ppBuf && pulLen && pPacket && pFrameHdr && *ppBuf) {
+ /* If we have a current frame, send it */
+ retVal = rv_depacki_send_current_frame(pInt);
+ if (retVal == HXR_OK) {
+ /* Create a current frame */
+ retVal = rv_depacki_create_frame(pInt, pPacket, pFrameHdr,
+ &pInt->pCurFrame);
+ if (retVal == HXR_OK) {
+ /* Set the return value */
+ retVal = HXR_FAIL;
+ /* Sanity check on parsed values */
+ if (*pulLen >= pInt->pCurFrame->ulDataLen) {
+ /* Copy the data */
+ memcpy(pInt->pCurFrame->pData, *ppBuf,
+ pInt->pCurFrame->ulDataLen);
+ /* Set the one and only segment */
+ pInt->pCurFrame->pSegment[0].bIsValid = TRUE;
+ pInt->pCurFrame->pSegment[0].ulOffset = 0;
+ /* Send the frame we just created */
+ retVal = rv_depacki_send_current_frame(pInt);
+ if (retVal == HXR_OK) {
+ /* Advance the buffer */
+ *ppBuf += pFrameHdr->ulFrameSize;
+ *pulLen -= pFrameHdr->ulFrameSize;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_send_current_frame(rv_depack_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->fpAvail) {
+ /* Init local variables */
+ HXBOOL bDoSend = TRUE;
+ UINT32 i = 0;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Do we have a current frame? Not an error if we don't. */
+ if (pInt->pCurFrame) {
+ /* Was the packet broken up by us? */
+ if (pInt->bBrokenUpByUs) {
+ /*
+ * Make sure all the segments are there;
+ * otherwise, don't send it. After leaving
+ * the for loop below, bDoSend will only
+ * be TRUE if all the segments are valid.
+ */
+ for (i = 0; i < pInt->pCurFrame->ulNumSegments && bDoSend; i++) {
+ bDoSend = pInt->pCurFrame->pSegment[i].bIsValid;
+ }
+ /* Are we going to send this frame? */
+ if (bDoSend && pInt->pCurFrame->ulNumSegments) {
+ /* Collapse all the segment info into 1 segment */
+ pInt->pCurFrame->pSegment[0].bIsValid = TRUE;
+ pInt->pCurFrame->pSegment[0].ulOffset = 0;
+ /* Reset the number of segments to 1 */
+ pInt->pCurFrame->ulNumSegments = 1;
+ }
+ }
+ /* Are we going to send this frame? */
+ if (bDoSend) {
+ /* Call the frame available function pointer */
+ retVal = pInt->fpAvail(pInt->pAvail,
+ pInt->ulActiveSubStream,
+ pInt->pCurFrame);
+
+ } else {
+ /* Free the frame */
+ rv_depacki_cleanup_frame(pInt, &pInt->pCurFrame);
+ }
+ /* NULL out the pointer */
+ pInt->pCurFrame = HXNULL;
+ }
+ }
+
+ return retVal;
+}
+
+void rv_depacki_cleanup_frame(rv_depack_internal* pInt,
+ rv_frame** ppFrame)
+{
+ if (pInt && ppFrame && *ppFrame) {
+ /* Free the encoded frame buffer */
+ if ((*ppFrame)->pData) {
+ rv_depacki_free(pInt, (*ppFrame)->pData);
+ (*ppFrame)->pData = HXNULL;
+ }
+ /* Free the segment array */
+ if ((*ppFrame)->pSegment) {
+ rv_depacki_free(pInt, (*ppFrame)->pSegment);
+ (*ppFrame)->pSegment = HXNULL;
+ }
+ /* NULL out the frame */
+ memset(*ppFrame, 0, sizeof(rv_frame));
+ /* Delete the space for the frame struct itself */
+ rv_depacki_free(pInt, *ppFrame);
+ /* NULL out the pointer */
+ *ppFrame = HXNULL;
+ }
+}
+
+HX_RESULT rv_depacki_create_frame(rv_depack_internal* pInt,
+ rm_packet* pPacket,
+ rv_frame_hdr* pFrameHdr,
+ rv_frame** ppFrame)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pPacket && pFrameHdr && ppFrame &&
+ pFrameHdr->ulFrameSize && pFrameHdr->ulNumPackets) {
+ /* Init local variables */
+ rv_frame* pFrame = HXNULL;
+ UINT32 ulSize = 0;
+ UINT32 ulSeqNum = 0;
+ UINT32 ulFlags = 0;
+ /* Clean out any existing frame */
+ rv_depacki_cleanup_frame(pInt, ppFrame);
+ /* Allocate space rv_frame struct */
+ pFrame = rv_depacki_malloc(pInt, sizeof(rv_frame));
+ if (pFrame) {
+ /* NULL out the memory */
+ memset(pFrame, 0, sizeof(rv_frame));
+ /* Allocate enough space for the data */
+ pFrame->pData = rv_depacki_malloc(pInt, pFrameHdr->ulFrameSize);
+ if (pFrame->pData) {
+ /* NULL out the memory */
+ memset(pFrame->pData, 0, pFrameHdr->ulFrameSize);
+ /* Assign the data size */
+ pFrame->ulDataLen = pFrameHdr->ulFrameSize;
+ /* Allocate space for segment array */
+ ulSize = pFrameHdr->ulNumPackets * sizeof(rv_segment);
+ pFrame->pSegment = rv_depacki_malloc(pInt, ulSize);
+ if (pFrame->pSegment) {
+ /*
+ * NULL out the memory. This effectively sets
+ * all the bIsValid flags to FALSE and ulOffset
+ * values to zero.
+ */
+ memset(pFrame->pSegment, 0, ulSize);
+ /* Assign the rest of the members of the frame struct */
+ pFrame->ulNumSegments = pFrameHdr->ulNumPackets;
+ pFrame->ulTimestamp = pFrameHdr->ulTimestamp;
+ pFrame->bLastPacket = FALSE;
+ /* Look up the flags from the packet ASM rule */
+ ulFlags = rv_depacki_rule_to_flags(pInt, pPacket->ucASMRule);
+ /*
+ * If this is a packet with only multiple frames and the
+ * packet is a keyframe packet, then we only want the FIRST frame
+ * to be labelled as a keyframe. If this packet has a
+ * last-partial frame followed by multiple frames, then
+ * we don't want ANY of the multiple frames to be labelled
+ * as a keyframe. To implement this logic, we can do
+ * the following check: if this is a multiple frames header
+ * AND that header did not start at the beginning of the packet,
+ * then we need to clear the keyframe flag.
+ */
+ if (pFrameHdr->eType == RVFrameTypeMultiple &&
+ pFrameHdr->ulHeaderOffset) {
+ ulFlags &= ~HX_KEYFRAME_FLAG;
+ }
+ /* Assign the frame flags */
+ pFrame->usFlags = (UINT16) ulFlags;
+ /* Compute the output sequence number */
+ if (pInt->bCreatedFirstFrame) {
+ /*
+ * The sequence number in the RV frame is only
+ * one byte, so every 256 frames, it rolls over
+ * from 255 back to 0. Check to see if we've
+ * rolled over with this frame.
+ */
+ if (pFrameHdr->ulSeqNum < pInt->ulLastSeqNumIn) {
+ /* We rolled over */
+ pInt->ulLastSeqNumOut += pFrameHdr->ulSeqNum + 256 - pInt->ulLastSeqNumIn;
+ } else {
+ pInt->ulLastSeqNumOut += pFrameHdr->ulSeqNum - pInt->ulLastSeqNumIn;
+ }
+ /* Save the last input sequence number */
+ pInt->ulLastSeqNumIn = pFrameHdr->ulSeqNum;
+ } else {
+ /*
+ * Always start the output sequence number at 0, even
+ * if we lost a few packets and the actual input sequence
+ * number in the RV frame my not be 0.
+ */
+ pInt->ulLastSeqNumOut = 0;
+ pInt->ulLastSeqNumIn = pFrameHdr->ulSeqNum;
+ pInt->bCreatedFirstFrame = TRUE;
+ }
+ /* Assign the sequence number */
+ pFrame->usSequenceNum = (UINT16)(pInt->ulLastSeqNumOut & 0x0000FFFF);
+ /* Assign the broken-up-by-us flag */
+ pInt->bBrokenUpByUs = pFrameHdr->bBrokenUpByUs;
+ /* Assign the out parameter */
+ *ppFrame = pFrame;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_seek(rv_depack_internal* pInt, UINT32 ulTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ /* Clean up any existing partial frame */
+ rv_depacki_cleanup_frame(pInt, &pInt->pCurFrame);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+
+ return retVal;
+}
+
diff --git a/audio_codec/libcook/rv_depack_internal.h b/audio_codec/libcook/rv_depack_internal.h
new file mode 100644
index 0000000..b0ebdea
--- a/dev/null
+++ b/audio_codec/libcook/rv_depack_internal.h
@@ -0,0 +1,171 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_depack_internal.h,v 1.1.1.1.2.1 2005/05/04 18:21:20 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV_DEPACK_INTERNAL_H
+#define RV_DEPACK_INTERNAL_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+#include "rm_error.h"
+#include "rv_depack.h"
+#include "stream_hdr_structs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* Frame type enum */
+ typedef enum
+ {
+ RVFrameTypePartial,
+ RVFrameTypeWhole,
+ RVFrameTypeLastPartial,
+ RVFrameTypeMultiple
+ }
+ RVFrameType;
+
+ /* Struct which holds frame header info */
+ typedef struct rv_frame_hdr_struct {
+ RVFrameType eType;
+ UINT32 ulPacketNum;
+ UINT32 ulNumPackets;
+ UINT32 ulFrameSize;
+ UINT32 ulPartialFrameSize;
+ UINT32 ulPartialFrameOffset;
+ UINT32 ulTimestamp;
+ UINT32 ulSeqNum;
+ UINT32 ulHeaderSize;
+ UINT32 ulHeaderOffset;
+ HXBOOL bBrokenUpByUs;
+ } rv_frame_hdr;
+
+ /*
+ * Internal rv_depack struct
+ */
+ typedef struct rv_depack_internal_struct {
+ void* pAvail;
+ rv_frame_avail_func_ptr fpAvail;
+ rm_error_func_ptr fpError;
+ void* pUserError;
+ rm_malloc_func_ptr fpMalloc;
+ rm_free_func_ptr fpFree;
+ void* pUserMem;
+ UINT32 ulZeroTimeOffset;
+ HX_BITFIELD bHasRelativeTimeStamps;
+ rm_rule_map rule2Flag;
+ rm_multistream_hdr multiStreamHdr;
+ rv_format_info* pSubStreamHdr;
+ HXBOOL* bIgnoreSubStream;
+ HXBOOL bStreamSwitchable;
+ UINT32 ulActiveSubStream;
+ rv_frame* pCurFrame;
+ HXBOOL bBrokenUpByUs;
+ HXBOOL bCreatedFirstFrame;
+ UINT32 ulLastSeqNumIn;
+ UINT32 ulLastSeqNumOut;
+ } rv_depack_internal;
+
+ /*
+ * Internal rv_depack functions
+ */
+ void* rv_depacki_malloc(rv_depack_internal* pInt, UINT32 ulSize);
+ void rv_depacki_free(rv_depack_internal* pInt, void* pMem);
+ HX_RESULT rv_depacki_init(rv_depack_internal* pInt, rm_stream_header* hdr);
+ HX_RESULT rv_depacki_unpack_rule_map(rv_depack_internal* pInt,
+ rm_rule_map* pMap,
+ BYTE** ppBuf,
+ UINT32* pulLen);
+ HX_RESULT rv_depacki_unpack_multistream_hdr(rv_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen);
+ HX_RESULT rv_depacki_unpack_opaque_data(rv_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen);
+ void rv_depacki_cleanup_format_info(rv_depack_internal* pInt,
+ rv_format_info* pInfo);
+ void rv_depacki_cleanup_format_info_array(rv_depack_internal* pInt);
+ HX_RESULT rv_depacki_unpack_format_info(rv_depack_internal* pInt,
+ rv_format_info* pInfo,
+ BYTE** ppBuf,
+ UINT32* pulLen);
+ HX_RESULT rv_depacki_check_rule_book(rv_depack_internal* pInt,
+ rm_stream_header* hdr);
+ HX_RESULT rv_depacki_copy_format_info(rv_depack_internal* pInt,
+ rv_format_info* pSrc,
+ rv_format_info* pDst);
+ HX_RESULT rv_depacki_add_packet(rv_depack_internal* pInt,
+ rm_packet* pPacket);
+ UINT32 rv_depacki_rule_to_flags(rv_depack_internal* pInt, UINT32 ulRule);
+ UINT32 rv_depacki_rule_to_substream(rv_depack_internal* pInt, UINT32 ulRule);
+ HX_RESULT rv_depacki_parse_frame_header(rv_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_packet* pPacket,
+ rv_frame_hdr* pFrameHdr);
+ HX_RESULT rv_depacki_read_14_or_30(BYTE** ppBuf,
+ UINT32* pulLen,
+ HXBOOL* pbHiBit,
+ UINT32* pulValue);
+ HX_RESULT rv_depacki_handle_partial(rv_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_packet* pPacket,
+ rv_frame_hdr* pFrameHdr);
+ HX_RESULT rv_depacki_handle_one_frame(rv_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_packet* pPacket,
+ rv_frame_hdr* pFrameHdr);
+ HX_RESULT rv_depacki_send_current_frame(rv_depack_internal* pInt);
+ void rv_depacki_cleanup_frame(rv_depack_internal* pInt,
+ rv_frame** ppFrame);
+ HX_RESULT rv_depacki_create_frame(rv_depack_internal* pInt,
+ rm_packet* pPacket,
+ rv_frame_hdr* pFrameHdr,
+ rv_frame** ppFrame);
+ void rv_depacki_check_to_clear_keyframe_flag(BYTE* pBuf,
+ UINT32 ulLen,
+ rm_packet* pkt,
+ rv_frame_hdr* hdr);
+ HX_RESULT rv_depacki_seek(rv_depack_internal* pInt, UINT32 ulTime);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef RV_DEPACK_INTERNAL_H */
diff --git a/audio_codec/libcook/rv_format_info.h b/audio_codec/libcook/rv_format_info.h
new file mode 100644
index 0000000..29554fe
--- a/dev/null
+++ b/audio_codec/libcook/rv_format_info.h
@@ -0,0 +1,91 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_format_info.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV_FORMAT_INFO_H
+#define RV_FORMAT_INFO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+#include "helix_types.h"
+
+ typedef struct rv_format_info_struct {
+ UINT32 ulLength;
+ UINT32 ulMOFTag;
+ UINT32 ulSubMOFTag;
+ UINT16 usWidth;
+ UINT16 usHeight;
+ UINT16 usBitCount;
+ UINT16 usPadWidth;
+ UINT16 usPadHeight;
+ UFIXED32 ufFramesPerSecond;
+ UINT32 ulOpaqueDataSize;
+ BYTE* pOpaqueData;
+ } rv_format_info;
+
+ /*
+ * RV frame struct.
+ */
+ typedef struct rv_segment_struct {
+ HXBOOL bIsValid;
+ UINT32 ulOffset;
+ } rv_segment;
+
+ typedef struct rv_frame_struct {
+ UINT32 ulDataLen;
+ BYTE* pData;
+ UINT32 ulTimestamp;
+ UINT16 usSequenceNum;
+ UINT16 usFlags;
+ HXBOOL bLastPacket;
+ UINT32 ulNumSegments;
+ rv_segment* pSegment;
+ } rv_frame;
+
+#define BYTE_SWAP_UINT16(A) ((((UINT16)(A) & 0xff00) >> 8) | \
+ (((UINT16)(A) & 0x00ff) << 8))
+#define BYTE_SWAP_UINT32(A) ((((UINT32)(A) & 0xff000000) >> 24) | \
+ (((UINT32)(A) & 0x00ff0000) >> 8) | \
+ (((UINT32)(A) & 0x0000ff00) << 8) | \
+ (((UINT32)(A) & 0x000000ff) << 24))
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RV_FORMAT_INFO_H */
diff --git a/audio_codec/libcook/statname.h b/audio_codec/libcook/statname.h
new file mode 100644
index 0000000..9ceacce
--- a/dev/null
+++ b/audio_codec/libcook/statname.h
@@ -0,0 +1,118 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: statname.h,v 1.6 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * statname.h - name mangling macros for static linking
+ **************************************************************************************/
+
+#ifndef _STATNAME_H
+#define _STATNAME_H
+
+/* define STAT_PREFIX to a unique name for static linking
+ * all the C functions and global variables will be mangled by the preprocessor
+ * e.g. void FFT(int *fftbuf) becomes void cook_FFT(int *fftbuf)
+ */
+#define STAT_PREFIX cook
+
+#define STATCC1(x,y,z) STATCC2(x,y,z)
+#define STATCC2(x,y,z) x##y##z
+
+#ifdef STAT_PREFIX
+#define STATNAME(func) STATCC1(STAT_PREFIX, _, func)
+#else
+#define STATNAME(func) func
+#endif
+
+/* global functions */
+#define AllocateBuffers STATNAME(AllocateBuffers)
+#define FreeBuffers STATNAME(FreeBuffers)
+
+#define DecodeSideInfo STATNAME(DecodeSideInfo)
+#define GetBits STATNAME(GetBits)
+#define AdvanceBitstream STATNAME(AdvanceBitstream)
+
+#define DecodeHuffmanScalar STATNAME(DecodeHuffmanScalar)
+
+#define DecodeGainInfo STATNAME(DecodeGainInfo)
+#define CopyGainInfo STATNAME(CopyGainInfo)
+
+#define JointDecodeMLT STATNAME(JointDecodeMLT)
+#define DecodeCoupleInfo STATNAME(DecodeCoupleInfo)
+
+#define DecodeEnvelope STATNAME(DecodeEnvelope)
+#define CategorizeAndExpand STATNAME(CategorizeAndExpand)
+#define DecodeTransform STATNAME(DecodeTransform)
+
+#define IMLTNoWindow STATNAME(IMLTNoWindow)
+#define R4FFT STATNAME(R4FFT)
+
+#define DecWindowWithAttacks STATNAME(DecWindowWithAttacks)
+#define DecWindowNoAttacks STATNAME(DecWindowNoAttacks)
+
+/* global (const) data */
+#define pkkey STATNAME(pkkey)
+
+#define huffTabCoupleInfo STATNAME(huffTabCoupleInfo)
+#define huffTabCouple STATNAME(huffTabCouple)
+#define huffTabPowerInfo STATNAME(huffTabPowerInfo)
+#define huffTabPower STATNAME(huffTabPower)
+#define huffTabVectorInfo STATNAME(huffTabVectorInfo)
+#define huffTabVector STATNAME(huffTabVector)
+
+#define nmltTab STATNAME(nmltTab)
+#define window STATNAME(window)
+#define windowOffset STATNAME(windowOffset)
+#define cos4sin4tab STATNAME(cos4sin4tab)
+#define cos4sin4tabOffset STATNAME(cos4sin4tabOffset)
+#define cos1sin1tab STATNAME(cos1sin1tab)
+#define uniqueIDTab STATNAME(uniqueIDTab)
+#define bitrevtab STATNAME(bitrevtab)
+#define bitrevtabOffset STATNAME(bitrevtabOffset)
+#define twidTabEven STATNAME(twidTabEven)
+#define twidTabOdd STATNAME(twidTabOdd)
+
+/* assembly functions - either inline or in separate asm file */
+#define MULSHIFT32 STATNAME(MULSHIFT32)
+#define CLIPTOSHORT STATNAME(CLIPTOSHORT)
+#define FASTABS STATNAME(FASTABS)
+#define CLZ STATNAME(CLZ)
+
+#endif /* _STATNAME_H */
diff --git a/audio_codec/libcook/stream_hdr_structs.h b/audio_codec/libcook/stream_hdr_structs.h
new file mode 100644
index 0000000..433270f
--- a/dev/null
+++ b/audio_codec/libcook/stream_hdr_structs.h
@@ -0,0 +1,66 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: stream_hdr_structs.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef STREAM_HDR_STRUCTS_H
+#define STREAM_HDR_STRUCTS_H
+
+#include "helix_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* map an ASM rule to some other property */
+ typedef struct rm_rule_map_struct {
+ UINT32 ulNumRules;
+ UINT32* pulMap;
+ } rm_rule_map;
+
+ /* rm multistream header -- surestream */
+ typedef struct rm_multistream_hdr_struct {
+ UINT32 ulID; /* unique identifier for this header */
+ rm_rule_map rule2SubStream; /* mapping of ASM rule number to substream */
+ UINT32 ulNumSubStreams; /* number of substreams */
+ } rm_multistream_hdr;
+
+#define RM_MULTIHEADER_OBJECT 0x4D4C5449 /* 'MLTI' */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef STREAM_HDR_STRUCTS_H */
diff --git a/audio_codec/libcook/stream_hdr_utils.c b/audio_codec/libcook/stream_hdr_utils.c
new file mode 100644
index 0000000..386e043
--- a/dev/null
+++ b/audio_codec/libcook/stream_hdr_utils.c
@@ -0,0 +1,136 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: stream_hdr_utils.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <memory.h>
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+#include "pack_utils.h"
+#include "memory_utils.h"
+#include "stream_hdr_structs.h"
+#include "stream_hdr_utils.h"
+
+HX_RESULT rm_unpack_rule_map(BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree,
+ void* pUserMem,
+ rm_rule_map* pMap)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (ppBuf && pulLen && fpMalloc && fpFree && pMap &&
+ *ppBuf && *pulLen >= 2) {
+ /* Initialize local variables */
+ UINT32 ulSize = 0;
+ UINT32 i = 0;
+ /* Clean up any existing rule to flag map */
+ rm_cleanup_rule_map(fpFree, pUserMem, pMap);
+ /* Unpack the number of rules */
+ pMap->ulNumRules = rm_unpack16(ppBuf, pulLen);
+ if (pMap->ulNumRules && *pulLen >= pMap->ulNumRules * 2) {
+ /* Allocate the map array */
+ ulSize = pMap->ulNumRules * sizeof(UINT32);
+ pMap->pulMap = (UINT32*) fpMalloc(pUserMem, ulSize);
+ if (pMap->pulMap) {
+ /* Zero out the memory */
+ memset(pMap->pulMap, 0, ulSize);
+ /* Unpack each of the flags */
+ for (i = 0; i < pMap->ulNumRules; i++) {
+ pMap->pulMap[i] = rm_unpack16(ppBuf, pulLen);
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ } else {
+ /* No rules - not an error */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+void rm_cleanup_rule_map(rm_free_func_ptr fpFree,
+ void* pUserMem,
+ rm_rule_map* pMap)
+{
+ if (fpFree && pMap && pMap->pulMap) {
+ fpFree(pUserMem, pMap->pulMap);
+ pMap->pulMap = HXNULL;
+ pMap->ulNumRules = 0;
+ }
+}
+
+HX_RESULT rm_unpack_multistream_hdr(BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree,
+ void* pUserMem,
+ rm_multistream_hdr* hdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (ppBuf && pulLen && fpMalloc && fpFree && hdr &&
+ *ppBuf && *pulLen >= 4) {
+ /* Unpack the multistream members */
+ hdr->ulID = rm_unpack32(ppBuf, pulLen);
+ /* Unpack the rule to substream map */
+ retVal = rm_unpack_rule_map(ppBuf, pulLen,
+ fpMalloc, fpFree, pUserMem,
+ &hdr->rule2SubStream);
+ if (retVal == HXR_OK) {
+ if (*pulLen >= 2) {
+ /* Unpack the number of substreams */
+ hdr->ulNumSubStreams = rm_unpack16(ppBuf, pulLen);
+ } else {
+ retVal = HXR_FAIL;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rm_cleanup_multistream_hdr(rm_free_func_ptr fpFree,
+ void* pUserMem,
+ rm_multistream_hdr* hdr)
+{
+ if (hdr) {
+ rm_cleanup_rule_map(fpFree, pUserMem, &hdr->rule2SubStream);
+ }
+}
diff --git a/audio_codec/libcook/stream_hdr_utils.h b/audio_codec/libcook/stream_hdr_utils.h
new file mode 100644
index 0000000..2f5d4d3
--- a/dev/null
+++ b/audio_codec/libcook/stream_hdr_utils.h
@@ -0,0 +1,77 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: stream_hdr_utils.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef STREAM_HDR_UTILS_H
+#define STREAM_HDR_UTILS_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+#include "stream_hdr_structs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ HX_RESULT rm_unpack_rule_map(BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree,
+ void* pUserMem,
+ rm_rule_map* pMap);
+
+ void rm_cleanup_rule_map(rm_free_func_ptr fpFree,
+ void* pUserMem,
+ rm_rule_map* pMap);
+
+ HX_RESULT rm_unpack_multistream_hdr(BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree,
+ void* pUserMem,
+ rm_multistream_hdr* hdr);
+
+ void rm_cleanup_multistream_hdr(rm_free_func_ptr fpFree,
+ void* pUserMem,
+ rm_multistream_hdr* hdr);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef STREAM_HDR_UTILS_H */
diff --git a/audio_codec/libcook/string_utils.c b/audio_codec/libcook/string_utils.c
new file mode 100644
index 0000000..45b3759
--- a/dev/null
+++ b/audio_codec/libcook/string_utils.c
@@ -0,0 +1,87 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: string_utils.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <string.h>
+#include "string_utils.h"
+#include "memory_utils.h"
+
+char* copy_string(void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ const char* pszStr)
+{
+ char* pRet = HXNULL;
+
+ if (fpMalloc && pszStr) {
+ /* Allocate space for string */
+ pRet = (char*) fpMalloc(pUserMem, strlen(pszStr) + 1);
+ if (pRet) {
+ /* Copy the string */
+ strcpy(pRet, pszStr);
+ }
+ }
+
+ return pRet;
+}
+
+void free_string(void* pUserMem,
+ rm_free_func_ptr fpFree,
+ char** ppszStr)
+{
+ if (fpFree && ppszStr && *ppszStr) {
+ fpFree(pUserMem, *ppszStr);
+ *ppszStr = HXNULL;
+ }
+}
+
+#if defined(_WINDOWS)
+
+#if !defined(_WINCE)
+
+int strcasecmp(const char* pszStr1, const char* pszStr2)
+{
+ return _stricmp(pszStr1, pszStr2);
+}
+
+#endif /* #if !defined(_WINCE) */
+
+int strncasecmp(const char* pszStr1, const char* pszStr2, int len)
+{
+ return _strnicmp(pszStr1, pszStr2, (size_t) len);
+}
+
+#endif /* #if defined(_WINDOWS) */
+
diff --git a/audio_codec/libcook/string_utils.h b/audio_codec/libcook/string_utils.h
new file mode 100644
index 0000000..5337f52
--- a/dev/null
+++ b/audio_codec/libcook/string_utils.h
@@ -0,0 +1,62 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: string_utils.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef STRING_UTILS_H
+#define STRING_UTILS_H
+
+#include "helix_types.h"
+#include "rm_memory.h"
+/* Create and copy a string */
+char* copy_string(void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ const char* pszStr);
+
+/* Free a string */
+void free_string(void* pUserMem,
+ rm_free_func_ptr fpFree,
+ char** ppszStr);
+
+#if defined(_WINDOWS)
+
+int strcasecmp(const char* pszStr1, const char* pszStr2);
+int strncasecmp(const char* pszStr1, const char* pszStr2, int len);
+
+#elif defined(_UNIX)
+#include <strings.h>
+#endif
+
+#endif /* #ifndef STRING_UTILS_H */
diff --git a/audio_codec/libcook/tngpkt.h b/audio_codec/libcook/tngpkt.h
new file mode 100644
index 0000000..3e2d0af
--- a/dev/null
+++ b/audio_codec/libcook/tngpkt.h
@@ -0,0 +1,400 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: tngpkt.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+ * This is generated code, do not modify. Look in
+ * /home/gregory/helix/protocol/transport/rdt/pub/tngpkt.pm to make
+ * modifications
+ */
+
+#include "helix_types.h"
+#include "rm_memory.h"
+
+#ifndef PMC_PREDEFINED_TYPES
+#define PMC_PREDEFINED_TYPES
+
+typedef char* pmc_string;
+
+typedef struct _buffer {
+ UINT32 len;
+ INT8* data;
+} buffer;
+#endif/*PMC_PREDEFINED_TYPES*/
+
+
+#ifndef _TNGPKT_H_
+#define _TNGPKT_H_
+
+struct TNGDataPacket {
+ UINT8 length_included_flag;
+ UINT8 need_reliable_flag;
+ UINT8 stream_id;
+ UINT8 is_reliable;
+ UINT16 seq_no;
+ UINT16 _packlenwhendone;
+ UINT8 back_to_back_packet;
+ UINT8 slow_data;
+ UINT8 asm_rule_number;
+ UINT32 timestamp;
+ UINT16 stream_id_expansion;
+ UINT16 total_reliable;
+ UINT16 asm_rule_number_expansion;
+ buffer data;
+};
+
+const UINT32 TNGDataPacket_static_size();
+UINT8* TNGDataPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGDataPacket* pkt);
+UINT8* TNGDataPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGDataPacket* pkt);
+
+struct TNGMultiCastDataPacket {
+ UINT8 length_included_flag;
+ UINT8 need_reliable_flag;
+ UINT8 stream_id;
+ UINT8 is_reliable;
+ UINT16 seq_no;
+ UINT16 length;
+ UINT8 back_to_back_packet;
+ UINT8 slow_data;
+ UINT8 asm_rule_number;
+ UINT8 group_seq_no;
+ UINT32 timestamp;
+ UINT16 stream_id_expansion;
+ UINT16 total_reliable;
+ UINT16 asm_rule_number_expansion;
+ buffer data;
+};
+
+const UINT32 TNGMultiCastDataPacket_static_size();
+
+UINT8* TNGMultiCastDataPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGMultiCastDataPacket* pkt);
+UINT8* TNGMultiCastDataPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGMultiCastDataPacket* pkt);
+
+
+struct TNGASMActionPacket {
+ UINT8 length_included_flag;
+ UINT8 stream_id;
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT16 packet_type;
+ UINT16 reliable_seq_no;
+ UINT16 length;
+ UINT16 stream_id_expansion;
+ buffer data;
+};
+
+const UINT32 TNGASMActionPacket_static_size();
+UINT8* TNGASMActionPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGASMActionPacket* pkt);
+
+UINT8* TNGASMActionPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGASMActionPacket* pkt);
+
+
+
+struct TNGBandwidthReportPacket {
+ UINT8 length_included_flag;
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 dummy2;
+ UINT16 packet_type;
+ UINT16 length;
+ UINT16 interval;
+ UINT32 bandwidth;
+ UINT8 sequence;
+};
+
+const UINT32 TNGBandwidthReportPacket_static_size();
+UINT8* TNGBandwidthReportPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGBandwidthReportPacket* pkt);
+UINT8* TNGBandwidthReportPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGBandwidthReportPacket* pkt);
+
+
+
+struct TNGReportPacket {
+ UINT8 length_included_flag;
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 dummy2;
+ UINT16 packet_type;
+ UINT16 length;
+ buffer data;
+};
+
+const UINT32 TNGReportPacket_static_size();
+UINT8* TNGReportPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGReportPacket* pkt);
+UINT8* TNGReportPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGReportPacket* pkt);
+
+
+
+struct TNGACKPacket {
+ UINT8 length_included_flag;
+ UINT8 lost_high;
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT16 packet_type;
+ UINT16 length;
+ buffer data;
+};
+
+const UINT32 TNGACKPacket_static_size();
+UINT8* TNGACKPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGACKPacket* pkt);
+UINT8* TNGACKPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGACKPacket* pkt);
+
+
+struct TNGRTTRequestPacket {
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 dummy2;
+ UINT8 dummy3;
+ UINT16 packet_type;
+};
+
+const UINT32 TNGRTTRequestPacket_static_size();
+UINT8* TNGRTTRequestPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGRTTRequestPacket* pkt);
+UINT8* TNGRTTRequestPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGRTTRequestPacket* pkt);
+
+struct TNGRTTResponsePacket {
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 dummy2;
+ UINT8 dummy3;
+ UINT16 packet_type;
+ UINT32 timestamp_sec;
+ UINT32 timestamp_usec;
+};
+
+const UINT32 TNGRTTResponsePacket_static_size();
+UINT8* TNGRTTResponsePacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGRTTResponsePacket* pkt);
+UINT8* TNGRTTResponsePacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGRTTResponsePacket* pkt);
+
+
+struct TNGCongestionPacket {
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 dummy2;
+ UINT8 dummy3;
+ UINT16 packet_type;
+ INT32 xmit_multiplier;
+ INT32 recv_multiplier;
+};
+
+const UINT32 TNGCongestionPacket_static_size();
+UINT8* TNGCongestionPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGCongestionPacket* pkt);
+UINT8* TNGCongestionPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGCongestionPacket* pkt);
+
+
+struct TNGStreamEndPacket {
+ UINT8 need_reliable_flag;
+ UINT8 stream_id;
+ UINT8 packet_sent;
+ UINT8 ext_flag;
+ UINT16 packet_type;
+ UINT16 seq_no;
+ UINT32 timestamp;
+ UINT16 stream_id_expansion;
+ UINT16 total_reliable;
+ UINT8 reason_dummy[3];
+ UINT32 reason_code;
+ pmc_string reason_text;
+};
+
+const UINT32 TNGStreamEndPacket_static_size();
+UINT8* TNGStreamEndPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGStreamEndPacket* pkt);
+
+/* TNGStreamEndPacket_unpack will malloc room for the reason_text.
+ * You must free this memory or it will be leaked */
+UINT8* TNGStreamEndPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGStreamEndPacket* pkt);
+
+UINT8* TNGStreamEndPacket_unpack_fromPool(UINT8* buf,
+ UINT32 len,
+ struct TNGStreamEndPacket* pkt,
+ rm_malloc_func_ptr fpMalloc,
+ void* pMemoryPool);
+
+
+
+
+struct TNGLatencyReportPacket {
+ UINT8 length_included_flag;
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 dummy2;
+ UINT16 packet_type;
+ UINT16 length;
+ UINT32 server_out_time;
+};
+
+const UINT32 TNGLatencyReportPacket_static_size();
+UINT8* TNGLatencyReportPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGLatencyReportPacket* pkt);
+UINT8* TNGLatencyReportPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGLatencyReportPacket* pkt);
+
+
+
+
+/*
+ * RDTFeatureLevel 3 packets
+ */
+
+struct RDTTransportInfoRequestPacket {
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 request_rtt_info;
+ UINT8 request_buffer_info;
+ UINT16 packet_type;
+ UINT32 request_time_ms;
+};
+
+const UINT32 RDTTransportInfoRequestPacket_static_size();
+UINT8* RDTTransportInfoRequestPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct RDTTransportInfoRequestPacket* pkt);
+UINT8* RDTTransportInfoRequestPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct RDTTransportInfoRequestPacket* pkt);
+
+
+
+
+struct RDTBufferInfo {
+ UINT16 stream_id;
+ UINT32 lowest_timestamp;
+ UINT32 highest_timestamp;
+ UINT32 bytes_buffered;
+};
+
+const UINT32 RDTBufferInfo_static_size();
+UINT8* RDTBufferInfo_pack(UINT8* buf,
+ UINT32 len, struct RDTBufferInfo* pkt);
+UINT8* RDTBufferInfo_unpack(UINT8* buf,
+ UINT32 len, struct RDTBufferInfo* pkt);
+
+
+
+
+struct RDTTransportInfoResponsePacket {
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 has_rtt_info;
+ UINT8 is_delayed;
+ UINT8 has_buffer_info;
+ UINT16 packet_type;
+ UINT32 request_time_ms;
+ UINT32 response_time_ms;
+ UINT16 buffer_info_count;
+ struct RDTBufferInfo *buffer_info;
+};
+
+const UINT32 RDTTransportInfoResponsePacket_static_size();
+UINT8* RDTTransportInfoResponsePacket_pack(UINT8* buf,
+ UINT32 len,
+ struct RDTTransportInfoResponsePacket* pkt);
+UINT8* RDTTransportInfoResponsePacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct RDTTransportInfoResponsePacket* pkt);
+
+UINT8* RDTTransportInfoResponsePacket_unpack_fromPool(UINT8* buf,
+ UINT32 len,
+ struct RDTTransportInfoResponsePacket* pkt,
+ rm_malloc_func_ptr fpMalloc,
+ void* pMemoryPool);
+
+
+
+
+
+
+struct TNGBWProbingPacket {
+ UINT8 length_included_flag;
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 dummy2;
+ UINT16 packet_type;
+ UINT16 length;
+ UINT8 seq_no;
+ UINT32 timestamp;
+ buffer data;
+};
+
+const UINT32 TNGBWProbingPacket_static_size();
+UINT8* TNGBWProbingPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGBWProbingPacket* pkt);
+UINT8* TNGBWProbingPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGBWProbingPacket* pkt);
+#endif /* _TNGPKT_H_ */
diff --git a/audio_codec/libfaad/Android.mk b/audio_codec/libfaad/Android.mk
new file mode 100755
index 0000000..3a8b4dc
--- a/dev/null
+++ b/audio_codec/libfaad/Android.mk
@@ -0,0 +1,101 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libfaad
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+
+#helix aac decoder enabled
+#ENABLE_HELIX_AAC_DECODER := true
+ifdef ENABLE_HELIX_AAC_DECODER
+LOCAL_SRC_FILES += \
+ helixaac/aacdec.c \
+ helixaac/aactabs.c \
+ helixaac/bitstream.c \
+ helixaac/buffers.c \
+ helixaac/dct4.c \
+ helixaac/decelmnt.c \
+ helixaac/dequant.c \
+ helixaac/fft.c \
+ helixaac/filefmt.c \
+ helixaac/huffman_helix.c \
+ helixaac/hufftabs.c \
+ helixaac/imdct.c \
+ helixaac/noiseless.c \
+ helixaac/pns_helix.c \
+ helixaac/sbr.c \
+ helixaac/sbrfft.c \
+ helixaac/sbrfreq.c \
+ helixaac/sbrhfadj.c \
+ helixaac/sbrhfgen.c \
+ helixaac/sbrhuff.c \
+ helixaac/sbrimdct.c \
+ helixaac/sbrmath.c \
+ helixaac/sbrqmf.c \
+ helixaac/sbrside.c \
+ helixaac/sbrtabs.c \
+ helixaac/stproc.c \
+ helixaac/tns_helix.c \
+ helixaac/trigtabs.c \
+ helixaac/trigtabs_fltgen.c
+LOCAL_CFLAGS += -DUSE_DEFAULT_STDLIB -DUSE_HELIX_AAC_DECODER
+endif
+LOCAL_ARM_MODE := arm
+LOCAL_C_INCLUDES := $(LOCAL_PATH) \
+ $(LOCAL_PATH)/codebook
+#aac helix include file
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/helixaac
+
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_SHARED_LIBRARIES += libutils libz libbinder libdl libcutils libc
+
+LOCAL_MODULE := libfaad
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+ifdef ENABLE_HELIX_AAC_DECODER
+#helix aac files
+LOCAL_SRC_FILES += \
+ helixaac/aacdec.c \
+ helixaac/aactabs.c \
+ helixaac/bitstream.c \
+ helixaac/buffers.c \
+ helixaac/dct4.c \
+ helixaac/decelmnt.c \
+ helixaac/dequant.c \
+ helixaac/fft.c \
+ helixaac/filefmt.c \
+ helixaac/huffman_helix.c \
+ helixaac/hufftabs.c \
+ helixaac/imdct.c \
+ helixaac/noiseless.c \
+ helixaac/pns_helix.c \
+ helixaac/sbr.c \
+ helixaac/sbrfft.c \
+ helixaac/sbrfreq.c \
+ helixaac/sbrhfadj.c \
+ helixaac/sbrhfgen.c \
+ helixaac/sbrhuff.c \
+ helixaac/sbrimdct.c \
+ helixaac/sbrmath.c \
+ helixaac/sbrqmf.c \
+ helixaac/sbrside.c \
+ helixaac/sbrtabs.c \
+ helixaac/stproc.c \
+ helixaac/tns_helix.c \
+ helixaac/trigtabs.c \
+ helixaac/trigtabs_fltgen.c
+LOCAL_CFLAGS += -DUSE_DEFAULT_STDLIB -DUSE_HELIX_AAC_DECODER
+endif
+
+LOCAL_ARM_MODE := arm
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := $(LOCAL_PATH) \
+ $(LOCAL_PATH)/codebook
+
+#aac helix include file
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/helixaac
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/audio_codec/libfaad/Makefile b/audio_codec/libfaad/Makefile
new file mode 100755
index 0000000..551d047
--- a/dev/null
+++ b/audio_codec/libfaad/Makefile
@@ -0,0 +1,130 @@
+#****************************************************************************
+# 通用的生æˆåŠ¨æ€åº“çš?c/c++ GNU Makefile
+# Writen By ZhuFeng,2007.2
+# 功能:自动从所有的.cæˆ?cpp文件列表中生æˆè¾“出文件,å¯ä»¥ç”ŸæˆåŠ¨æ€åº“
+#****************************************************************************
+
+#常用定义选项
+DW_NAME = faad
+DW_VERSION = 1.1.0
+MACHINE = $(shell uname -m)
+OUTPUT_BIN_PATH = ../bin/
+OUTPUT_INCLUDE_PATH = ./include/
+SRC_PATH = ./
+
+SRC_FILES = $(wildcard $(SRC_PATH)*.c)
+
+EXPORT_INCLUDE_FILES = $(wildcard $(SRC_PATH)*.h) $(wildcard $(SRC_PATH)codebook/*.h)
+
+USING_LIBS =
+USING_INCLUDES_PATH =
+
+#将会自动附加$(MACHINE)/$DEBUG
+USING_LIBS_PATH =
+DEBUG = YES
+DEFINES =
+
+#通用定义
+G++ = g++
+GCC = gcc
+LD = g++
+
+DEBUG_CFLAGS := -c -Wall -shared -fPIC -Wno-format -g -DDEBUG -fexceptions -fnon-call-exceptions
+RELEASE_CFLAGS := -c -Wall -shared -fPIC -Wno-unknown-pragmas -Wno-format -O3 -fexceptions -fnon-call-exceptions
+
+DEBUG_LDFLAGS := -g -shared -fPIC -Wl,-soname,lib$(DW_NAME).so
+RELEASE_LDFLAGS := -shared -fPIC -Wl,-soname,lib$(DW_NAME).so
+
+
+ifeq (YES, ${DEBUG})
+ CFLAGS := ${DEBUG_CFLAGS}
+ LDFLAGS := ${DEBUG_LDFLAGS}
+ USING_LIBS_PATH := $(addsuffix $(MACHINE)/debug/,$(USING_LIBS_PATH))
+ OUTPUT_PATH := $(OUTPUT_BIN_PATH)
+else
+ CFLAGS := ${RELEASE_CFLAGS}
+ LDFLAGS := ${RELEASE_LDFLAGS}
+ USING_LIBS_PATH := $(addsuffix $(MACHINE)/release/,$(USING_LIBS_PATH))
+ OUTPUT_PATH := $(OUTPUT_BIN_PATH)$(MACHINE)/release/
+endif
+
+#****************************************************************************
+# Makefile code common to all platforms
+#****************************************************************************
+
+CFLAGS += $(DEFINES)
+CFLAGS += $(USING_INCLUDES_PATH)
+
+#****************************************************************************
+# 定义自动化编译å®ï¼Œä½¿ç”¨GCCæ–¹å¼
+#****************************************************************************
+# $(call make-depend,source-file,object-file,depend-file)
+define make-depend
+ $(GCC) -MM -MF $3 -MP -MT $2 $(CFLAGS) $1
+endef
+
+OBJS = $(addsuffix .o,$(basename $(SRC_FILES)))
+DEPENDS = $(addsuffix .d,$(basename $(SRC_FILES)))
+
+DW_SVNVER = $(shell svnversion . | sed "s/.*://")
+DW_BUILD_DATE = $(shell date)
+
+OUTPUT = $(OUTPUT_PATH)lib$(DW_NAME).so.$(DW_VERSION)
+CFLAGS += -DDW_SVNVER="\"$(DW_SVNVER)\"" -DDW_BUILD_DATE="\"$(DW_BUILD_DATE)\"" -DDW_VERSION="\"$(DW_VERSION)\""
+
+VPATH = $(SRC_PATH)
+EXPORT_INCLUDE_FILES := $(addprefix $(SRC_PATH),$(EXPORT_INCLUDE_FILES))
+
+
+default:$(OUTPUT)
+ @echo "Build_Version: $(DW_VERSION)"
+ @ln -sf ./lib$(DW_NAME).so.$(DW_VERSION) $(OUTPUT_PATH)lib$(DW_NAME).so
+ @cp $(EXPORT_INCLUDE_FILES) $(OUTPUT_INCLUDE_PATH)
+ @echo "$(OUTPUT) MAKE 处ç†å®Œæ¯•"
+ @echo "\\033[32m\\033[1m[生æˆ]\\033[21m 执行完毕!"
+ @echo "$(OUTPUT) 被生æˆ?\\12$(EXPORT_INCLUDE_FILES)被å¤åˆ¶åˆ°$(OUTPUT_INCLUDE_PATH)\\033[0m"
+
+$(OUTPUT):$(OBJS)
+ @mkdir -p $(OUTPUT_PATH)
+ $(LD) $(LDFLAGS) -o $@ $^ $(USING_LIBS_PATH) $(USING_LIBS)
+ @echo "\\033[35m\\033[1m[链接]\\033[21m $@ 执行完毕,总计更新处ç†ï¼?(words $?) 个文件\\033[0m"
+
+%.o:%.c
+ @$(call make-depend,$<,$@,$(subst .o,.d,$@))
+ @$(GCC) $(CFLAGS) $< -o $@
+ @echo "\\033[32m\\033[1m[编译]\\033[21m $< 执行完毕\\033[0m"
+
+%.o:%.cpp
+ @$(call make-depend,$<,$@,$(subst .o,.d,$@))
+ @$(G++) $(CFLAGS) $< -o $@
+ @echo "\\033[32m\\033[1m[编译]\\033[21m $< 执行完毕\\033[0m"
+
+-include $(DEPENDS)
+
+help:
+ @echo "\\033[1m\\033[33m============== 通用动æ€åº“MAKEFILE ==============\\033[0m"
+ @echo "\\033[33m 2007.2 Writen By ZhuFeng \\033[0m"
+ @echo "\\033[32m\\033[1mmake :\\033[21m 缺çœè°ƒç”¨æ–¹å¼ï¼Œä½¿ç”¨debug模å¼è¿›è¡Œç¼–译与连接,输出二进制文件到指定目录\\033[0m"
+ @echo "\\033[32m\\033[1mmake DEBUG=NO :\\033[21m 使用release模å¼è¿›è¡Œç¼–译与连接,输出二进制文件到指定目录 \\033[0m"
+ @echo "\\033[32m\\033[1mmake help :\\033[21m显示帮助信æ¯\\033[0m"
+ @echo "\\033[32m\\033[1mmake rebuild :\\033[21mé‡æ–°ç”Ÿæˆæ‰€æœ‰æ–‡ä»¶\\033[0m"
+ @echo "\\033[32m\\033[1mmake clean :\\033[21m清除生æˆçš„中间文件\\033[0m"
+ @echo "\\033[32m\\033[1mmake install :\\033[21m安装生æˆçš„文件到/usr/local/lib目录,拷è´å¤´æ–‡ä»¶åˆ?usr/local/include目录\\033[0m"
+
+
+rebuild:clean default
+ @echo "\\033[34m\\033[1m[rebuild]\\033[21m 执行完毕\\033[0m"
+clean:
+ @rm -f *.o
+ @rm -f *.d
+ @echo "\\033[34m\\033[1m[clean]\\033[21m 执行完毕\\033[0m"
+test:
+ @echo "SVN_VERSION:$(SVN_VERSION)"
+ @echo "DW_VERSION:$(DW_VERSION)"
+ @echo "OUTPUT:$(OUTPUT)"
+
+
+
+
+
+
diff --git a/audio_codec/libfaad/analysis.h b/audio_codec/libfaad/analysis.h
new file mode 100644
index 0000000..0464b1e
--- a/dev/null
+++ b/audio_codec/libfaad/analysis.h
@@ -0,0 +1,52 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: analysis.h,v 1.18 2007/11/01 12:33:29 menno Exp $
+**/
+
+#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/audio_codec/libfaad/audio.d b/audio_codec/libfaad/audio.d
new file mode 100755
index 0000000..2504225
--- a/dev/null
+++ b/audio_codec/libfaad/audio.d
@@ -0,0 +1,3 @@
+audio.o: audio.c audio.h
+
+audio.h:
diff --git a/audio_codec/libfaad/bits.c b/audio_codec/libfaad/bits.c
new file mode 100644
index 0000000..727e047
--- a/dev/null
+++ b/audio_codec/libfaad/bits.c
@@ -0,0 +1,261 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: bits.c,v 1.44 2007/11/01 12:33:29 menno Exp $
+**/
+#include <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+#include "bits.h"
+
+/* 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;
+ }
+
+ // useless
+ //memset(ld, 0, sizeof(bitfile));
+
+ if (buffer_size == 0 || _buffer == NULL) {
+ ld->error = 1;
+ return;
+ }
+
+ ld->buffer = _buffer;
+
+ ld->buffer_size = buffer_size;
+ ld->bytes_left = buffer_size;
+
+ if (ld->bytes_left >= 4) {
+ tmp = getdword((uint32_t*)ld->buffer);
+ ld->bytes_left -= 4;
+ } else {
+ tmp = getdword_n((uint32_t*)ld->buffer, ld->bytes_left);
+ ld->bytes_left = 0;
+ }
+ ld->bufa = tmp;
+
+ if (ld->bytes_left >= 4) {
+ tmp = getdword((uint32_t*)ld->buffer + 1);
+ ld->bytes_left -= 4;
+ } else {
+ tmp = getdword_n((uint32_t*)ld->buffer + 1, ld->bytes_left);
+ ld->bytes_left = 0;
+ }
+ ld->bufb = tmp;
+
+ ld->start = (uint32_t*)ld->buffer;
+ ld->tail = ((uint32_t*)ld->buffer + 2);
+
+ ld->bits_left = 32;
+
+ ld->error = 0;
+}
+
+void faad_endbits(bitfile *ld)
+{
+ // void
+}
+
+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)
+{
+ int remainder = (32 - ld->bits_left) & 0x7;
+
+ if (remainder) {
+ faad_flushbits(ld, 8 - remainder);
+ return (uint8_t)(8 - remainder);
+ }
+ return 0;
+}
+
+void faad_flushbits_ex(bitfile *ld, uint32_t bits)
+{
+ uint32_t tmp;
+
+ ld->bufa = ld->bufb;
+ if (ld->bytes_left >= 4) {
+ tmp = getdword(ld->tail);
+ ld->bytes_left -= 4;
+ } else {
+ tmp = getdword_n(ld->tail, ld->bytes_left);
+ ld->bytes_left = 0;
+ }
+ ld->bufb = tmp;
+ ld->tail++;
+ ld->bits_left += (32 - bits);
+ //ld->bytes_left -= 4;
+ // if (ld->bytes_left == 0)
+ // ld->no_more_reading = 1;
+ // if (ld->bytes_left < 0)
+ // ld->error = 1;
+}
+
+/* rewind to beginning */
+void faad_rewindbits(bitfile *ld)
+{
+ uint32_t tmp;
+
+ ld->bytes_left = ld->buffer_size;
+
+ if (ld->bytes_left >= 4) {
+ tmp = getdword((uint32_t*)&ld->start[0]);
+ ld->bytes_left -= 4;
+ } else {
+ tmp = getdword_n((uint32_t*)&ld->start[0], ld->bytes_left);
+ ld->bytes_left = 0;
+ }
+ ld->bufa = tmp;
+
+ if (ld->bytes_left >= 4) {
+ tmp = getdword((uint32_t*)&ld->start[1]);
+ ld->bytes_left -= 4;
+ } else {
+ tmp = getdword_n((uint32_t*)&ld->start[1], ld->bytes_left);
+ ld->bytes_left = 0;
+ }
+ ld->bufb = tmp;
+
+ ld->bits_left = 32;
+ ld->tail = &ld->start[2];
+}
+
+/* reset to a certain point */
+void faad_resetbits(bitfile *ld, int bits)
+{
+ uint32_t tmp;
+ int words = bits >> 5;
+ int remainder = bits & 0x1F;
+
+ ld->bytes_left = ld->buffer_size - words * 4;
+
+ if (ld->bytes_left >= 4) {
+ tmp = getdword(&ld->start[words]);
+ ld->bytes_left -= 4;
+ } else {
+ tmp = getdword_n(&ld->start[words], ld->bytes_left);
+ ld->bytes_left = 0;
+ }
+ ld->bufa = tmp;
+
+ if (ld->bytes_left >= 4) {
+ tmp = getdword(&ld->start[words + 1]);
+ ld->bytes_left -= 4;
+ } else {
+ tmp = getdword_n(&ld->start[words + 1], ld->bytes_left);
+ ld->bytes_left = 0;
+ }
+ ld->bufb = tmp;
+
+ ld->bits_left = 32 - remainder;
+ ld->tail = &ld->start[words + 2];
+
+ /* recheck for reading too many bytes */
+ ld->error = 0;
+ // if (ld->bytes_left == 0)
+ // ld->no_more_reading = 1;
+ // if (ld->bytes_left < 0)
+ // ld->error = 1;
+}
+
+uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits
+ DEBUGDEC)
+{
+ int i;
+ unsigned int temp;
+ int bytes = bits >> 3;
+ int remainder = bits & 0x7;
+
+ 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 = faad_getbits(ld, remainder DEBUGVAR(print, var, dbg)) << (8 - remainder);
+
+ buffer[bytes] = (uint8_t)temp;
+ }
+
+ return buffer;
+}
+
+#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 */
+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_left = ld->buffer_size;
+ ld->error = 0;
+}
+
+/* EOF */
diff --git a/audio_codec/libfaad/bits.d b/audio_codec/libfaad/bits.d
new file mode 100755
index 0000000..1a23624
--- a/dev/null
+++ b/audio_codec/libfaad/bits.d
@@ -0,0 +1,18 @@
+bits.o: bits.c common.h neaacdec.h structs.h cfft.h sbr_dec.h ps_dec.h \
+ bits.h analysis.h
+
+common.h:
+
+neaacdec.h:
+
+structs.h:
+
+cfft.h:
+
+sbr_dec.h:
+
+ps_dec.h:
+
+bits.h:
+
+analysis.h:
diff --git a/audio_codec/libfaad/bits.h b/audio_codec/libfaad/bits.h
new file mode 100644
index 0000000..b63dd23
--- a/dev/null
+++ b/audio_codec/libfaad/bits.h
@@ -0,0 +1,446 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: bits.h,v 1.45 2007/11/01 12:33:29 menno Exp $
+**/
+
+#ifndef __BITS_H__
+#define __BITS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "analysis.h"
+#ifdef ANALYSIS
+#include <stdio.h>
+#endif
+
+#define BYTE_NUMBIT 8
+#define BYTE_NUMBIT_LD 3
+ //#define bit2byte(a) ((a+7)/BYTE_NUMBIT)
+#define bit2byte(a) ((a+7)>>BYTE_NUMBIT_LD)
+
+ 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_left;
+ uint8_t error;
+ uint32_t *tail;
+ uint32_t *start;
+ const void *buffer;
+ } bitfile;
+
+
+#if 0
+ static uint32_t const 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
+ };
+#endif
+
+ void faad_initbits(bitfile *ld, const void *buffer, const uint32_t buffer_size);
+ void faad_endbits(bitfile *ld);
+ 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_flushbits_ex(bitfile *ld, uint32_t bits);
+ void faad_rewindbits(bitfile *ld);
+ void faad_resetbits(bitfile *ld, int bits);
+ 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
+
+ /* circumvent memory alignment errors on ARM */
+ static INLINE uint32_t getdword(void *mem)
+ {
+ uint32_t tmp;
+#ifndef ARCH_IS_BIG_ENDIAN
+ ((uint8_t*)&tmp)[0] = ((uint8_t*)mem)[3];
+ ((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[2];
+ ((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[1];
+ ((uint8_t*)&tmp)[3] = ((uint8_t*)mem)[0];
+#else
+ ((uint8_t*)&tmp)[0] = ((uint8_t*)mem)[0];
+ ((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[1];
+ ((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[2];
+ ((uint8_t*)&tmp)[3] = ((uint8_t*)mem)[3];
+#endif
+
+ return tmp;
+ }
+
+ /* reads only n bytes from the stream instead of the standard 4 */
+ static /*INLINE*/ uint32_t getdword_n(void *mem, int n)
+ {
+ uint32_t tmp = 0;
+#ifndef ARCH_IS_BIG_ENDIAN
+ switch (n) {
+ case 3:
+ ((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[2];
+ case 2:
+ ((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[1];
+ case 1:
+ ((uint8_t*)&tmp)[3] = ((uint8_t*)mem)[0];
+ default:
+ break;
+ }
+#else
+ switch (n) {
+ case 3:
+ ((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[2];
+ case 2:
+ ((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[1];
+ case 1:
+ ((uint8_t*)&tmp)[0] = ((uint8_t*)mem)[0];
+ default:
+ break;
+ }
+#endif
+
+ return tmp;
+ }
+
+ 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];
+ return (ld->bufa << (32 - ld->bits_left)) >> (32 - bits);
+ }
+
+ bits -= ld->bits_left;
+ //return ((ld->bufa & bitmask[ld->bits_left]) << bits) | (ld->bufb >> (32 - bits));
+ return ((ld->bufa & ((1 << ld->bits_left) - 1)) << 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 /*INLINE*/ uint32_t faad_getbits(bitfile *ld, uint32_t n DEBUGDEC)
+ {
+ uint32_t ret;
+
+ if (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);
+
+ if (ld->bytes_left < 4) {
+ ld->error = 1;
+ ld->bytes_left = 0;
+ } else {
+ ld->bytes_left -= 4;
+ }
+ // if (ld->bytes_left == 0)
+ // ld->no_more_reading = 1;
+ }
+ }
+
+ static /*INLINE*/ uint32_t faad_getbits_rev(bitfile *ld, uint32_t n
+ DEBUGDEC)
+ {
+ uint32_t ret;
+
+ 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
+ /* CRC lookup table for G8 polynome in DRM standard */
+ static const uint8_t crc_table_G8[256] = {
+ 0x0, 0x1d, 0x3a, 0x27, 0x74, 0x69, 0x4e, 0x53,
+ 0xe8, 0xf5, 0xd2, 0xcf, 0x9c, 0x81, 0xa6, 0xbb,
+ 0xcd, 0xd0, 0xf7, 0xea, 0xb9, 0xa4, 0x83, 0x9e,
+ 0x25, 0x38, 0x1f, 0x2, 0x51, 0x4c, 0x6b, 0x76,
+ 0x87, 0x9a, 0xbd, 0xa0, 0xf3, 0xee, 0xc9, 0xd4,
+ 0x6f, 0x72, 0x55, 0x48, 0x1b, 0x6, 0x21, 0x3c,
+ 0x4a, 0x57, 0x70, 0x6d, 0x3e, 0x23, 0x4, 0x19,
+ 0xa2, 0xbf, 0x98, 0x85, 0xd6, 0xcb, 0xec, 0xf1,
+ 0x13, 0xe, 0x29, 0x34, 0x67, 0x7a, 0x5d, 0x40,
+ 0xfb, 0xe6, 0xc1, 0xdc, 0x8f, 0x92, 0xb5, 0xa8,
+ 0xde, 0xc3, 0xe4, 0xf9, 0xaa, 0xb7, 0x90, 0x8d,
+ 0x36, 0x2b, 0xc, 0x11, 0x42, 0x5f, 0x78, 0x65,
+ 0x94, 0x89, 0xae, 0xb3, 0xe0, 0xfd, 0xda, 0xc7,
+ 0x7c, 0x61, 0x46, 0x5b, 0x8, 0x15, 0x32, 0x2f,
+ 0x59, 0x44, 0x63, 0x7e, 0x2d, 0x30, 0x17, 0xa,
+ 0xb1, 0xac, 0x8b, 0x96, 0xc5, 0xd8, 0xff, 0xe2,
+ 0x26, 0x3b, 0x1c, 0x1, 0x52, 0x4f, 0x68, 0x75,
+ 0xce, 0xd3, 0xf4, 0xe9, 0xba, 0xa7, 0x80, 0x9d,
+ 0xeb, 0xf6, 0xd1, 0xcc, 0x9f, 0x82, 0xa5, 0xb8,
+ 0x3, 0x1e, 0x39, 0x24, 0x77, 0x6a, 0x4d, 0x50,
+ 0xa1, 0xbc, 0x9b, 0x86, 0xd5, 0xc8, 0xef, 0xf2,
+ 0x49, 0x54, 0x73, 0x6e, 0x3d, 0x20, 0x7, 0x1a,
+ 0x6c, 0x71, 0x56, 0x4b, 0x18, 0x5, 0x22, 0x3f,
+ 0x84, 0x99, 0xbe, 0xa3, 0xf0, 0xed, 0xca, 0xd7,
+ 0x35, 0x28, 0xf, 0x12, 0x41, 0x5c, 0x7b, 0x66,
+ 0xdd, 0xc0, 0xe7, 0xfa, 0xa9, 0xb4, 0x93, 0x8e,
+ 0xf8, 0xe5, 0xc2, 0xdf, 0x8c, 0x91, 0xb6, 0xab,
+ 0x10, 0xd, 0x2a, 0x37, 0x64, 0x79, 0x5e, 0x43,
+ 0xb2, 0xaf, 0x88, 0x95, 0xc6, 0xdb, 0xfc, 0xe1,
+ 0x5a, 0x47, 0x60, 0x7d, 0x2e, 0x33, 0x14, 0x9,
+ 0x7f, 0x62, 0x45, 0x58, 0xb, 0x16, 0x31, 0x2c,
+ 0x97, 0x8a, 0xad, 0xb0, 0xe3, 0xfe, 0xd9, 0xc4,
+ };
+
+ static uint8_t faad_check_CRC(bitfile *ld, uint16_t len)
+ {
+ int bytes, rem;
+ unsigned int CRC;
+ unsigned int 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 = (unsigned int) ~faad_getbits(ld, 8
+ DEBUGVAR(1, 999, "faad_check_CRC(): CRC")) & 0xFF; /* CRC is stored inverted */
+
+ bytes = len >> 3;
+ rem = len & 0x7;
+
+ for (; bytes > 0; bytes--) {
+ r = crc_table_G8[(r ^ faad_getbits(ld, 8 DEBUGVAR(1, 998, ""))) & 0xFF];
+ }
+ for (; rem > 0; rem--) {
+ r = ((r << 1) ^(((faad_get1bit(ld
+ DEBUGVAR(1, 998, "")) & 1) ^((r >> 7) & 1)) * GPOLY)) & 0xFF;
+ }
+
+ if (r != CRC)
+ // if (0)
+ {
+ return 28;
+ } 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/audio_codec/libfaad/cfft.c b/audio_codec/libfaad/cfft.c
new file mode 100644
index 0000000..222b70d
--- a/dev/null
+++ b/audio_codec/libfaad/cfft.c
@@ -0,0 +1,988 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: cfft.c,v 1.35 2007/11/01 12:33:29 menno Exp $
+**/
+
+/*
+ * Algorithmically based on Fortran-77 FFTPACK
+ * by Paul N. Swarztrauber(Version 4, 1985).
+ *
+ * Does even sized fft only
+ */
+
+/* isign is +1 for backward and -1 for forward transforms */
+#include <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+
+#include "cfft.h"
+#include "cfft_tab.h"
+
+
+/* static function declarations */
+static void passf2pos(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa);
+static void passf2neg(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa);
+static void passf3(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa1, const complex_t *wa2, const int8_t isign);
+static void passf4pos(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch,
+ const complex_t *wa1, const complex_t *wa2, const complex_t *wa3);
+static void passf4neg(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch,
+ const complex_t *wa1, const complex_t *wa2, const complex_t *wa3);
+static void passf5(const uint16_t ido, const uint16_t l1, const complex_t *cc, complex_t *ch,
+ const complex_t *wa1, const complex_t *wa2, const complex_t *wa3,
+ const complex_t *wa4, const int8_t isign);
+INLINE void cfftf1(uint16_t n, complex_t *c, complex_t *ch,
+ const uint16_t *ifac, const complex_t *wa, const int8_t isign);
+static void cffti1(uint16_t n, complex_t *wa, uint16_t *ifac);
+
+
+/*----------------------------------------------------------------------
+ passf2, passf3, passf4, passf5. Complex FFT passes fwd and bwd.
+ ----------------------------------------------------------------------*/
+
+static void passf2pos(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa)
+{
+ uint16_t i, k, ah, ac;
+
+ if (ido == 1) {
+ for (k = 0; k < l1; k++) {
+ ah = 2 * k;
+ ac = 4 * k;
+
+ RE(ch[ah]) = RE(cc[ac]) + RE(cc[ac + 1]);
+ RE(ch[ah + l1]) = RE(cc[ac]) - RE(cc[ac + 1]);
+ IM(ch[ah]) = IM(cc[ac]) + IM(cc[ac + 1]);
+ IM(ch[ah + l1]) = IM(cc[ac]) - IM(cc[ac + 1]);
+ }
+ } else {
+ for (k = 0; k < l1; k++) {
+ ah = k * ido;
+ ac = 2 * k * ido;
+
+ for (i = 0; i < ido; i++) {
+ complex_t t2;
+
+ RE(ch[ah + i]) = RE(cc[ac + i]) + RE(cc[ac + i + ido]);
+ RE(t2) = RE(cc[ac + i]) - RE(cc[ac + i + ido]);
+
+ IM(ch[ah + i]) = IM(cc[ac + i]) + IM(cc[ac + i + ido]);
+ IM(t2) = IM(cc[ac + i]) - IM(cc[ac + i + ido]);
+
+#if 1
+ ComplexMult(&IM(ch[ah + i + l1 * ido]), &RE(ch[ah + i + l1 * ido]),
+ IM(t2), RE(t2), RE(wa[i]), IM(wa[i]));
+#else
+ ComplexMult(&RE(ch[ah + i + l1 * ido]), &IM(ch[ah + i + l1 * ido]),
+ RE(t2), IM(t2), RE(wa[i]), IM(wa[i]));
+#endif
+ }
+ }
+ }
+}
+
+static void passf2neg(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa)
+{
+ uint16_t i, k, ah, ac;
+
+ if (ido == 1) {
+ for (k = 0; k < l1; k++) {
+ ah = 2 * k;
+ ac = 4 * k;
+
+ RE(ch[ah]) = RE(cc[ac]) + RE(cc[ac + 1]);
+ RE(ch[ah + l1]) = RE(cc[ac]) - RE(cc[ac + 1]);
+ IM(ch[ah]) = IM(cc[ac]) + IM(cc[ac + 1]);
+ IM(ch[ah + l1]) = IM(cc[ac]) - IM(cc[ac + 1]);
+ }
+ } else {
+ for (k = 0; k < l1; k++) {
+ ah = k * ido;
+ ac = 2 * k * ido;
+
+ for (i = 0; i < ido; i++) {
+ complex_t t2;
+
+ RE(ch[ah + i]) = RE(cc[ac + i]) + RE(cc[ac + i + ido]);
+ RE(t2) = RE(cc[ac + i]) - RE(cc[ac + i + ido]);
+
+ IM(ch[ah + i]) = IM(cc[ac + i]) + IM(cc[ac + i + ido]);
+ IM(t2) = IM(cc[ac + i]) - IM(cc[ac + i + ido]);
+
+#if 1
+ ComplexMult(&RE(ch[ah + i + l1 * ido]), &IM(ch[ah + i + l1 * ido]),
+ RE(t2), IM(t2), RE(wa[i]), IM(wa[i]));
+#else
+ ComplexMult(&IM(ch[ah + i + l1 * ido]), &RE(ch[ah + i + l1 * ido]),
+ IM(t2), RE(t2), RE(wa[i]), IM(wa[i]));
+#endif
+ }
+ }
+ }
+}
+
+
+static void passf3(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa1, const complex_t *wa2,
+ const int8_t isign)
+{
+ static real_t taur = FRAC_CONST(-0.5);
+ static real_t taui = FRAC_CONST(0.866025403784439);
+ uint16_t i, k, ac, ah;
+ complex_t c2, c3, d2, d3, t2;
+
+ if (ido == 1) {
+ if (isign == 1) {
+ for (k = 0; k < l1; k++) {
+ ac = 3 * k + 1;
+ ah = k;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac + 1]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac + 1]);
+ RE(c2) = RE(cc[ac - 1]) + MUL_F(RE(t2), taur);
+ IM(c2) = IM(cc[ac - 1]) + MUL_F(IM(t2), taur);
+
+ RE(ch[ah]) = RE(cc[ac - 1]) + RE(t2);
+ IM(ch[ah]) = IM(cc[ac - 1]) + IM(t2);
+
+ RE(c3) = MUL_F((RE(cc[ac]) - RE(cc[ac + 1])), taui);
+ IM(c3) = MUL_F((IM(cc[ac]) - IM(cc[ac + 1])), taui);
+
+ RE(ch[ah + l1]) = RE(c2) - IM(c3);
+ IM(ch[ah + l1]) = IM(c2) + RE(c3);
+ RE(ch[ah + 2 * l1]) = RE(c2) + IM(c3);
+ IM(ch[ah + 2 * l1]) = IM(c2) - RE(c3);
+ }
+ } else {
+ for (k = 0; k < l1; k++) {
+ ac = 3 * k + 1;
+ ah = k;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac + 1]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac + 1]);
+ RE(c2) = RE(cc[ac - 1]) + MUL_F(RE(t2), taur);
+ IM(c2) = IM(cc[ac - 1]) + MUL_F(IM(t2), taur);
+
+ RE(ch[ah]) = RE(cc[ac - 1]) + RE(t2);
+ IM(ch[ah]) = IM(cc[ac - 1]) + IM(t2);
+
+ RE(c3) = MUL_F((RE(cc[ac]) - RE(cc[ac + 1])), taui);
+ IM(c3) = MUL_F((IM(cc[ac]) - IM(cc[ac + 1])), taui);
+
+ RE(ch[ah + l1]) = RE(c2) + IM(c3);
+ IM(ch[ah + l1]) = IM(c2) - RE(c3);
+ RE(ch[ah + 2 * l1]) = RE(c2) - IM(c3);
+ IM(ch[ah + 2 * l1]) = IM(c2) + RE(c3);
+ }
+ }
+ } else {
+ if (isign == 1) {
+ for (k = 0; k < l1; k++) {
+ for (i = 0; i < ido; i++) {
+ ac = i + (3 * k + 1) * ido;
+ ah = i + k * ido;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac + ido]);
+ RE(c2) = RE(cc[ac - ido]) + MUL_F(RE(t2), taur);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac + ido]);
+ IM(c2) = IM(cc[ac - ido]) + MUL_F(IM(t2), taur);
+
+ RE(ch[ah]) = RE(cc[ac - ido]) + RE(t2);
+ IM(ch[ah]) = IM(cc[ac - ido]) + IM(t2);
+
+ RE(c3) = MUL_F((RE(cc[ac]) - RE(cc[ac + ido])), taui);
+ IM(c3) = MUL_F((IM(cc[ac]) - IM(cc[ac + ido])), taui);
+
+ RE(d2) = RE(c2) - IM(c3);
+ IM(d3) = IM(c2) - RE(c3);
+ RE(d3) = RE(c2) + IM(c3);
+ IM(d2) = IM(c2) + RE(c3);
+
+#if 1
+ ComplexMult(&IM(ch[ah + l1 * ido]), &RE(ch[ah + l1 * ido]),
+ IM(d2), RE(d2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&IM(ch[ah + 2 * l1 * ido]), &RE(ch[ah + 2 * l1 * ido]),
+ IM(d3), RE(d3), RE(wa2[i]), IM(wa2[i]));
+#else
+ ComplexMult(&RE(ch[ah + l1 * ido]), &IM(ch[ah + l1 * ido]),
+ RE(d2), IM(d2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&RE(ch[ah + 2 * l1 * ido]), &IM(ch[ah + 2 * l1 * ido]),
+ RE(d3), IM(d3), RE(wa2[i]), IM(wa2[i]));
+#endif
+ }
+ }
+ } else {
+ for (k = 0; k < l1; k++) {
+ for (i = 0; i < ido; i++) {
+ ac = i + (3 * k + 1) * ido;
+ ah = i + k * ido;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac + ido]);
+ RE(c2) = RE(cc[ac - ido]) + MUL_F(RE(t2), taur);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac + ido]);
+ IM(c2) = IM(cc[ac - ido]) + MUL_F(IM(t2), taur);
+
+ RE(ch[ah]) = RE(cc[ac - ido]) + RE(t2);
+ IM(ch[ah]) = IM(cc[ac - ido]) + IM(t2);
+
+ RE(c3) = MUL_F((RE(cc[ac]) - RE(cc[ac + ido])), taui);
+ IM(c3) = MUL_F((IM(cc[ac]) - IM(cc[ac + ido])), taui);
+
+ RE(d2) = RE(c2) + IM(c3);
+ IM(d3) = IM(c2) + RE(c3);
+ RE(d3) = RE(c2) - IM(c3);
+ IM(d2) = IM(c2) - RE(c3);
+
+#if 1
+ ComplexMult(&RE(ch[ah + l1 * ido]), &IM(ch[ah + l1 * ido]),
+ RE(d2), IM(d2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&RE(ch[ah + 2 * l1 * ido]), &IM(ch[ah + 2 * l1 * ido]),
+ RE(d3), IM(d3), RE(wa2[i]), IM(wa2[i]));
+#else
+ ComplexMult(&IM(ch[ah + l1 * ido]), &RE(ch[ah + l1 * ido]),
+ IM(d2), RE(d2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&IM(ch[ah + 2 * l1 * ido]), &RE(ch[ah + 2 * l1 * ido]),
+ IM(d3), RE(d3), RE(wa2[i]), IM(wa2[i]));
+#endif
+ }
+ }
+ }
+ }
+}
+
+
+static void passf4pos(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa1, const complex_t *wa2,
+ const complex_t *wa3)
+{
+ uint16_t i, k, ac, ah;
+
+ if (ido == 1) {
+ for (k = 0; k < l1; k++) {
+ complex_t t1, t2, t3, t4;
+
+ ac = 4 * k;
+ ah = k;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac + 2]);
+ RE(t1) = RE(cc[ac]) - RE(cc[ac + 2]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac + 2]);
+ IM(t1) = IM(cc[ac]) - IM(cc[ac + 2]);
+ RE(t3) = RE(cc[ac + 1]) + RE(cc[ac + 3]);
+ IM(t4) = RE(cc[ac + 1]) - RE(cc[ac + 3]);
+ IM(t3) = IM(cc[ac + 3]) + IM(cc[ac + 1]);
+ RE(t4) = IM(cc[ac + 3]) - IM(cc[ac + 1]);
+
+ RE(ch[ah]) = RE(t2) + RE(t3);
+ RE(ch[ah + 2 * l1]) = RE(t2) - RE(t3);
+
+ IM(ch[ah]) = IM(t2) + IM(t3);
+ IM(ch[ah + 2 * l1]) = IM(t2) - IM(t3);
+
+ RE(ch[ah + l1]) = RE(t1) + RE(t4);
+ RE(ch[ah + 3 * l1]) = RE(t1) - RE(t4);
+
+ IM(ch[ah + l1]) = IM(t1) + IM(t4);
+ IM(ch[ah + 3 * l1]) = IM(t1) - IM(t4);
+ }
+ } else {
+ for (k = 0; k < l1; k++) {
+ ac = 4 * k * ido;
+ ah = k * ido;
+
+ for (i = 0; i < ido; i++) {
+ complex_t c2, c3, c4, t1, t2, t3, t4;
+
+ RE(t2) = RE(cc[ac + i]) + RE(cc[ac + i + 2 * ido]);
+ RE(t1) = RE(cc[ac + i]) - RE(cc[ac + i + 2 * ido]);
+ IM(t2) = IM(cc[ac + i]) + IM(cc[ac + i + 2 * ido]);
+ IM(t1) = IM(cc[ac + i]) - IM(cc[ac + i + 2 * ido]);
+ RE(t3) = RE(cc[ac + i + ido]) + RE(cc[ac + i + 3 * ido]);
+ IM(t4) = RE(cc[ac + i + ido]) - RE(cc[ac + i + 3 * ido]);
+ IM(t3) = IM(cc[ac + i + 3 * ido]) + IM(cc[ac + i + ido]);
+ RE(t4) = IM(cc[ac + i + 3 * ido]) - IM(cc[ac + i + ido]);
+
+ RE(c2) = RE(t1) + RE(t4);
+ RE(c4) = RE(t1) - RE(t4);
+
+ IM(c2) = IM(t1) + IM(t4);
+ IM(c4) = IM(t1) - IM(t4);
+
+ RE(ch[ah + i]) = RE(t2) + RE(t3);
+ RE(c3) = RE(t2) - RE(t3);
+
+ IM(ch[ah + i]) = IM(t2) + IM(t3);
+ IM(c3) = IM(t2) - IM(t3);
+
+#if 1
+ ComplexMult(&IM(ch[ah + i + l1 * ido]), &RE(ch[ah + i + l1 * ido]),
+ IM(c2), RE(c2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&IM(ch[ah + i + 2 * l1 * ido]), &RE(ch[ah + i + 2 * l1 * ido]),
+ IM(c3), RE(c3), RE(wa2[i]), IM(wa2[i]));
+ ComplexMult(&IM(ch[ah + i + 3 * l1 * ido]), &RE(ch[ah + i + 3 * l1 * ido]),
+ IM(c4), RE(c4), RE(wa3[i]), IM(wa3[i]));
+#else
+ ComplexMult(&RE(ch[ah + i + l1 * ido]), &IM(ch[ah + i + l1 * ido]),
+ RE(c2), IM(c2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&RE(ch[ah + i + 2 * l1 * ido]), &IM(ch[ah + i + 2 * l1 * ido]),
+ RE(c3), IM(c3), RE(wa2[i]), IM(wa2[i]));
+ ComplexMult(&RE(ch[ah + i + 3 * l1 * ido]), &IM(ch[ah + i + 3 * l1 * ido]),
+ RE(c4), IM(c4), RE(wa3[i]), IM(wa3[i]));
+#endif
+ }
+ }
+ }
+}
+
+static void passf4neg(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa1, const complex_t *wa2,
+ const complex_t *wa3)
+{
+ uint16_t i, k, ac, ah;
+
+ if (ido == 1) {
+ for (k = 0; k < l1; k++) {
+ complex_t t1, t2, t3, t4;
+
+ ac = 4 * k;
+ ah = k;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac + 2]);
+ RE(t1) = RE(cc[ac]) - RE(cc[ac + 2]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac + 2]);
+ IM(t1) = IM(cc[ac]) - IM(cc[ac + 2]);
+ RE(t3) = RE(cc[ac + 1]) + RE(cc[ac + 3]);
+ IM(t4) = RE(cc[ac + 1]) - RE(cc[ac + 3]);
+ IM(t3) = IM(cc[ac + 3]) + IM(cc[ac + 1]);
+ RE(t4) = IM(cc[ac + 3]) - IM(cc[ac + 1]);
+
+ RE(ch[ah]) = RE(t2) + RE(t3);
+ RE(ch[ah + 2 * l1]) = RE(t2) - RE(t3);
+
+ IM(ch[ah]) = IM(t2) + IM(t3);
+ IM(ch[ah + 2 * l1]) = IM(t2) - IM(t3);
+
+ RE(ch[ah + l1]) = RE(t1) - RE(t4);
+ RE(ch[ah + 3 * l1]) = RE(t1) + RE(t4);
+
+ IM(ch[ah + l1]) = IM(t1) - IM(t4);
+ IM(ch[ah + 3 * l1]) = IM(t1) + IM(t4);
+ }
+ } else {
+ for (k = 0; k < l1; k++) {
+ ac = 4 * k * ido;
+ ah = k * ido;
+
+ for (i = 0; i < ido; i++) {
+ complex_t c2, c3, c4, t1, t2, t3, t4;
+
+ RE(t2) = RE(cc[ac + i]) + RE(cc[ac + i + 2 * ido]);
+ RE(t1) = RE(cc[ac + i]) - RE(cc[ac + i + 2 * ido]);
+ IM(t2) = IM(cc[ac + i]) + IM(cc[ac + i + 2 * ido]);
+ IM(t1) = IM(cc[ac + i]) - IM(cc[ac + i + 2 * ido]);
+ RE(t3) = RE(cc[ac + i + ido]) + RE(cc[ac + i + 3 * ido]);
+ IM(t4) = RE(cc[ac + i + ido]) - RE(cc[ac + i + 3 * ido]);
+ IM(t3) = IM(cc[ac + i + 3 * ido]) + IM(cc[ac + i + ido]);
+ RE(t4) = IM(cc[ac + i + 3 * ido]) - IM(cc[ac + i + ido]);
+
+ RE(c2) = RE(t1) - RE(t4);
+ RE(c4) = RE(t1) + RE(t4);
+
+ IM(c2) = IM(t1) - IM(t4);
+ IM(c4) = IM(t1) + IM(t4);
+
+ RE(ch[ah + i]) = RE(t2) + RE(t3);
+ RE(c3) = RE(t2) - RE(t3);
+
+ IM(ch[ah + i]) = IM(t2) + IM(t3);
+ IM(c3) = IM(t2) - IM(t3);
+
+#if 1
+ ComplexMult(&RE(ch[ah + i + l1 * ido]), &IM(ch[ah + i + l1 * ido]),
+ RE(c2), IM(c2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&RE(ch[ah + i + 2 * l1 * ido]), &IM(ch[ah + i + 2 * l1 * ido]),
+ RE(c3), IM(c3), RE(wa2[i]), IM(wa2[i]));
+ ComplexMult(&RE(ch[ah + i + 3 * l1 * ido]), &IM(ch[ah + i + 3 * l1 * ido]),
+ RE(c4), IM(c4), RE(wa3[i]), IM(wa3[i]));
+#else
+ ComplexMult(&IM(ch[ah + i + l1 * ido]), &RE(ch[ah + i + l1 * ido]),
+ IM(c2), RE(c2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&IM(ch[ah + i + 2 * l1 * ido]), &RE(ch[ah + i + 2 * l1 * ido]),
+ IM(c3), RE(c3), RE(wa2[i]), IM(wa2[i]));
+ ComplexMult(&IM(ch[ah + i + 3 * l1 * ido]), &RE(ch[ah + i + 3 * l1 * ido]),
+ IM(c4), RE(c4), RE(wa3[i]), IM(wa3[i]));
+#endif
+ }
+ }
+ }
+}
+
+static void passf5(const uint16_t ido, const uint16_t l1, const complex_t *cc,
+ complex_t *ch, const complex_t *wa1, const complex_t *wa2, const complex_t *wa3,
+ const complex_t *wa4, const int8_t isign)
+{
+ static real_t tr11 = FRAC_CONST(0.309016994374947);
+ static real_t ti11 = FRAC_CONST(0.951056516295154);
+ static real_t tr12 = FRAC_CONST(-0.809016994374947);
+ static real_t ti12 = FRAC_CONST(0.587785252292473);
+ uint16_t i, k, ac, ah;
+ complex_t c2, c3, c4, c5, d3, d4, d5, d2, t2, t3, t4, t5;
+
+ if (ido == 1) {
+ if (isign == 1) {
+ for (k = 0; k < l1; k++) {
+ ac = 5 * k + 1;
+ ah = k;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac + 3]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac + 3]);
+ RE(t3) = RE(cc[ac + 1]) + RE(cc[ac + 2]);
+ IM(t3) = IM(cc[ac + 1]) + IM(cc[ac + 2]);
+ RE(t4) = RE(cc[ac + 1]) - RE(cc[ac + 2]);
+ IM(t4) = IM(cc[ac + 1]) - IM(cc[ac + 2]);
+ RE(t5) = RE(cc[ac]) - RE(cc[ac + 3]);
+ IM(t5) = IM(cc[ac]) - IM(cc[ac + 3]);
+
+ RE(ch[ah]) = RE(cc[ac - 1]) + RE(t2) + RE(t3);
+ IM(ch[ah]) = IM(cc[ac - 1]) + IM(t2) + IM(t3);
+
+ RE(c2) = RE(cc[ac - 1]) + MUL_F(RE(t2), tr11) + MUL_F(RE(t3), tr12);
+ IM(c2) = IM(cc[ac - 1]) + MUL_F(IM(t2), tr11) + MUL_F(IM(t3), tr12);
+ RE(c3) = RE(cc[ac - 1]) + MUL_F(RE(t2), tr12) + MUL_F(RE(t3), tr11);
+ IM(c3) = IM(cc[ac - 1]) + MUL_F(IM(t2), tr12) + MUL_F(IM(t3), tr11);
+
+ ComplexMult(&RE(c5), &RE(c4),
+ ti11, ti12, RE(t5), RE(t4));
+ ComplexMult(&IM(c5), &IM(c4),
+ ti11, ti12, IM(t5), IM(t4));
+
+ RE(ch[ah + l1]) = RE(c2) - IM(c5);
+ IM(ch[ah + l1]) = IM(c2) + RE(c5);
+ RE(ch[ah + 2 * l1]) = RE(c3) - IM(c4);
+ IM(ch[ah + 2 * l1]) = IM(c3) + RE(c4);
+ RE(ch[ah + 3 * l1]) = RE(c3) + IM(c4);
+ IM(ch[ah + 3 * l1]) = IM(c3) - RE(c4);
+ RE(ch[ah + 4 * l1]) = RE(c2) + IM(c5);
+ IM(ch[ah + 4 * l1]) = IM(c2) - RE(c5);
+ }
+ } else {
+ for (k = 0; k < l1; k++) {
+ ac = 5 * k + 1;
+ ah = k;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac + 3]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac + 3]);
+ RE(t3) = RE(cc[ac + 1]) + RE(cc[ac + 2]);
+ IM(t3) = IM(cc[ac + 1]) + IM(cc[ac + 2]);
+ RE(t4) = RE(cc[ac + 1]) - RE(cc[ac + 2]);
+ IM(t4) = IM(cc[ac + 1]) - IM(cc[ac + 2]);
+ RE(t5) = RE(cc[ac]) - RE(cc[ac + 3]);
+ IM(t5) = IM(cc[ac]) - IM(cc[ac + 3]);
+
+ RE(ch[ah]) = RE(cc[ac - 1]) + RE(t2) + RE(t3);
+ IM(ch[ah]) = IM(cc[ac - 1]) + IM(t2) + IM(t3);
+
+ RE(c2) = RE(cc[ac - 1]) + MUL_F(RE(t2), tr11) + MUL_F(RE(t3), tr12);
+ IM(c2) = IM(cc[ac - 1]) + MUL_F(IM(t2), tr11) + MUL_F(IM(t3), tr12);
+ RE(c3) = RE(cc[ac - 1]) + MUL_F(RE(t2), tr12) + MUL_F(RE(t3), tr11);
+ IM(c3) = IM(cc[ac - 1]) + MUL_F(IM(t2), tr12) + MUL_F(IM(t3), tr11);
+
+ ComplexMult(&RE(c4), &RE(c5),
+ ti12, ti11, RE(t5), RE(t4));
+ ComplexMult(&IM(c4), &IM(c5),
+ ti12, ti11, IM(t5), IM(t4));
+
+ RE(ch[ah + l1]) = RE(c2) + IM(c5);
+ IM(ch[ah + l1]) = IM(c2) - RE(c5);
+ RE(ch[ah + 2 * l1]) = RE(c3) + IM(c4);
+ IM(ch[ah + 2 * l1]) = IM(c3) - RE(c4);
+ RE(ch[ah + 3 * l1]) = RE(c3) - IM(c4);
+ IM(ch[ah + 3 * l1]) = IM(c3) + RE(c4);
+ RE(ch[ah + 4 * l1]) = RE(c2) - IM(c5);
+ IM(ch[ah + 4 * l1]) = IM(c2) + RE(c5);
+ }
+ }
+ } else {
+ if (isign == 1) {
+ for (k = 0; k < l1; k++) {
+ for (i = 0; i < ido; i++) {
+ ac = i + (k * 5 + 1) * ido;
+ ah = i + k * ido;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac + 3 * ido]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac + 3 * ido]);
+ RE(t3) = RE(cc[ac + ido]) + RE(cc[ac + 2 * ido]);
+ IM(t3) = IM(cc[ac + ido]) + IM(cc[ac + 2 * ido]);
+ RE(t4) = RE(cc[ac + ido]) - RE(cc[ac + 2 * ido]);
+ IM(t4) = IM(cc[ac + ido]) - IM(cc[ac + 2 * ido]);
+ RE(t5) = RE(cc[ac]) - RE(cc[ac + 3 * ido]);
+ IM(t5) = IM(cc[ac]) - IM(cc[ac + 3 * ido]);
+
+ RE(ch[ah]) = RE(cc[ac - ido]) + RE(t2) + RE(t3);
+ IM(ch[ah]) = IM(cc[ac - ido]) + IM(t2) + IM(t3);
+
+ RE(c2) = RE(cc[ac - ido]) + MUL_F(RE(t2), tr11) + MUL_F(RE(t3), tr12);
+ IM(c2) = IM(cc[ac - ido]) + MUL_F(IM(t2), tr11) + MUL_F(IM(t3), tr12);
+ RE(c3) = RE(cc[ac - ido]) + MUL_F(RE(t2), tr12) + MUL_F(RE(t3), tr11);
+ IM(c3) = IM(cc[ac - ido]) + MUL_F(IM(t2), tr12) + MUL_F(IM(t3), tr11);
+
+ ComplexMult(&RE(c5), &RE(c4),
+ ti11, ti12, RE(t5), RE(t4));
+ ComplexMult(&IM(c5), &IM(c4),
+ ti11, ti12, IM(t5), IM(t4));
+
+ IM(d2) = IM(c2) + RE(c5);
+ IM(d3) = IM(c3) + RE(c4);
+ RE(d4) = RE(c3) + IM(c4);
+ RE(d5) = RE(c2) + IM(c5);
+ RE(d2) = RE(c2) - IM(c5);
+ IM(d5) = IM(c2) - RE(c5);
+ RE(d3) = RE(c3) - IM(c4);
+ IM(d4) = IM(c3) - RE(c4);
+
+#if 1
+ ComplexMult(&IM(ch[ah + l1 * ido]), &RE(ch[ah + l1 * ido]),
+ IM(d2), RE(d2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&IM(ch[ah + 2 * l1 * ido]), &RE(ch[ah + 2 * l1 * ido]),
+ IM(d3), RE(d3), RE(wa2[i]), IM(wa2[i]));
+ ComplexMult(&IM(ch[ah + 3 * l1 * ido]), &RE(ch[ah + 3 * l1 * ido]),
+ IM(d4), RE(d4), RE(wa3[i]), IM(wa3[i]));
+ ComplexMult(&IM(ch[ah + 4 * l1 * ido]), &RE(ch[ah + 4 * l1 * ido]),
+ IM(d5), RE(d5), RE(wa4[i]), IM(wa4[i]));
+#else
+ ComplexMult(&RE(ch[ah + l1 * ido]), &IM(ch[ah + l1 * ido]),
+ RE(d2), IM(d2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&RE(ch[ah + 2 * l1 * ido]), &IM(ch[ah + 2 * l1 * ido]),
+ RE(d3), IM(d3), RE(wa2[i]), IM(wa2[i]));
+ ComplexMult(&RE(ch[ah + 3 * l1 * ido]), &IM(ch[ah + 3 * l1 * ido]),
+ RE(d4), IM(d4), RE(wa3[i]), IM(wa3[i]));
+ ComplexMult(&RE(ch[ah + 4 * l1 * ido]), &IM(ch[ah + 4 * l1 * ido]),
+ RE(d5), IM(d5), RE(wa4[i]), IM(wa4[i]));
+#endif
+ }
+ }
+ } else {
+ for (k = 0; k < l1; k++) {
+ for (i = 0; i < ido; i++) {
+ ac = i + (k * 5 + 1) * ido;
+ ah = i + k * ido;
+
+ RE(t2) = RE(cc[ac]) + RE(cc[ac + 3 * ido]);
+ IM(t2) = IM(cc[ac]) + IM(cc[ac + 3 * ido]);
+ RE(t3) = RE(cc[ac + ido]) + RE(cc[ac + 2 * ido]);
+ IM(t3) = IM(cc[ac + ido]) + IM(cc[ac + 2 * ido]);
+ RE(t4) = RE(cc[ac + ido]) - RE(cc[ac + 2 * ido]);
+ IM(t4) = IM(cc[ac + ido]) - IM(cc[ac + 2 * ido]);
+ RE(t5) = RE(cc[ac]) - RE(cc[ac + 3 * ido]);
+ IM(t5) = IM(cc[ac]) - IM(cc[ac + 3 * ido]);
+
+ RE(ch[ah]) = RE(cc[ac - ido]) + RE(t2) + RE(t3);
+ IM(ch[ah]) = IM(cc[ac - ido]) + IM(t2) + IM(t3);
+
+ RE(c2) = RE(cc[ac - ido]) + MUL_F(RE(t2), tr11) + MUL_F(RE(t3), tr12);
+ IM(c2) = IM(cc[ac - ido]) + MUL_F(IM(t2), tr11) + MUL_F(IM(t3), tr12);
+ RE(c3) = RE(cc[ac - ido]) + MUL_F(RE(t2), tr12) + MUL_F(RE(t3), tr11);
+ IM(c3) = IM(cc[ac - ido]) + MUL_F(IM(t2), tr12) + MUL_F(IM(t3), tr11);
+
+ ComplexMult(&RE(c4), &RE(c5),
+ ti12, ti11, RE(t5), RE(t4));
+ ComplexMult(&IM(c4), &IM(c5),
+ ti12, ti11, IM(t5), IM(t4));
+
+ IM(d2) = IM(c2) - RE(c5);
+ IM(d3) = IM(c3) - RE(c4);
+ RE(d4) = RE(c3) - IM(c4);
+ RE(d5) = RE(c2) - IM(c5);
+ RE(d2) = RE(c2) + IM(c5);
+ IM(d5) = IM(c2) + RE(c5);
+ RE(d3) = RE(c3) + IM(c4);
+ IM(d4) = IM(c3) + RE(c4);
+
+#if 1
+ ComplexMult(&RE(ch[ah + l1 * ido]), &IM(ch[ah + l1 * ido]),
+ RE(d2), IM(d2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&RE(ch[ah + 2 * l1 * ido]), &IM(ch[ah + 2 * l1 * ido]),
+ RE(d3), IM(d3), RE(wa2[i]), IM(wa2[i]));
+ ComplexMult(&RE(ch[ah + 3 * l1 * ido]), &IM(ch[ah + 3 * l1 * ido]),
+ RE(d4), IM(d4), RE(wa3[i]), IM(wa3[i]));
+ ComplexMult(&RE(ch[ah + 4 * l1 * ido]), &IM(ch[ah + 4 * l1 * ido]),
+ RE(d5), IM(d5), RE(wa4[i]), IM(wa4[i]));
+#else
+ ComplexMult(&IM(ch[ah + l1 * ido]), &RE(ch[ah + l1 * ido]),
+ IM(d2), RE(d2), RE(wa1[i]), IM(wa1[i]));
+ ComplexMult(&IM(ch[ah + 2 * l1 * ido]), &RE(ch[ah + 2 * l1 * ido]),
+ IM(d3), RE(d3), RE(wa2[i]), IM(wa2[i]));
+ ComplexMult(&IM(ch[ah + 3 * l1 * ido]), &RE(ch[ah + 3 * l1 * ido]),
+ IM(d4), RE(d4), RE(wa3[i]), IM(wa3[i]));
+ ComplexMult(&IM(ch[ah + 4 * l1 * ido]), &RE(ch[ah + 4 * l1 * ido]),
+ IM(d5), RE(d5), RE(wa4[i]), IM(wa4[i]));
+#endif
+ }
+ }
+ }
+ }
+}
+
+
+/*----------------------------------------------------------------------
+ cfftf1, cfftf, cfftb, cffti1, cffti. Complex FFTs.
+ ----------------------------------------------------------------------*/
+
+static INLINE void cfftf1pos(uint16_t n, complex_t *c, complex_t *ch,
+ const uint16_t *ifac, const complex_t *wa,
+ const int8_t isign)
+{
+ uint16_t i;
+ uint16_t k1, l1, l2;
+ uint16_t na, nf, ip, iw, ix2, ix3, ix4, ido, idl1;
+
+ nf = ifac[1];
+ na = 0;
+ l1 = 1;
+ iw = 0;
+
+ for (k1 = 2; k1 <= nf + 1; k1++) {
+ ip = ifac[k1];
+ l2 = ip * l1;
+ ido = n / l2;
+ idl1 = ido * l1;
+
+ switch (ip) {
+ case 4:
+ ix2 = iw + ido;
+ ix3 = ix2 + ido;
+
+ if (na == 0) {
+ passf4pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3]);
+ } else {
+ passf4pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3]);
+ }
+
+ na = 1 - na;
+ break;
+ case 2:
+ if (na == 0) {
+ passf2pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw]);
+ } else {
+ passf2pos((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw]);
+ }
+
+ na = 1 - na;
+ break;
+ case 3:
+ ix2 = iw + ido;
+
+ if (na == 0) {
+ passf3((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], isign);
+ } else {
+ passf3((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], isign);
+ }
+
+ na = 1 - na;
+ break;
+ case 5:
+ ix2 = iw + ido;
+ ix3 = ix2 + ido;
+ ix4 = ix3 + ido;
+
+ if (na == 0) {
+ passf5((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3], &wa[ix4], isign);
+ } else {
+ passf5((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3], &wa[ix4], isign);
+ }
+
+ na = 1 - na;
+ break;
+ }
+
+ l1 = l2;
+ iw += (ip - 1) * ido;
+ }
+
+ if (na == 0) {
+ return;
+ }
+
+ for (i = 0; i < n; i++) {
+ RE(c[i]) = RE(ch[i]);
+ IM(c[i]) = IM(ch[i]);
+ }
+}
+
+static INLINE void cfftf1neg(uint16_t n, complex_t *c, complex_t *ch,
+ const uint16_t *ifac, const complex_t *wa,
+ const int8_t isign)
+{
+ uint16_t i;
+ uint16_t k1, l1, l2;
+ uint16_t na, nf, ip, iw, ix2, ix3, ix4, ido, idl1;
+
+ nf = ifac[1];
+ na = 0;
+ l1 = 1;
+ iw = 0;
+
+ for (k1 = 2; k1 <= nf + 1; k1++) {
+ ip = ifac[k1];
+ l2 = ip * l1;
+ ido = n / l2;
+ idl1 = ido * l1;
+
+ switch (ip) {
+ case 4:
+ ix2 = iw + ido;
+ ix3 = ix2 + ido;
+
+ if (na == 0) {
+ passf4neg((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3]);
+ } else {
+ passf4neg((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3]);
+ }
+
+ na = 1 - na;
+ break;
+ case 2:
+ if (na == 0) {
+ passf2neg((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw]);
+ } else {
+ passf2neg((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw]);
+ }
+
+ na = 1 - na;
+ break;
+ case 3:
+ ix2 = iw + ido;
+
+ if (na == 0) {
+ passf3((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], isign);
+ } else {
+ passf3((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], isign);
+ }
+
+ na = 1 - na;
+ break;
+ case 5:
+ ix2 = iw + ido;
+ ix3 = ix2 + ido;
+ ix4 = ix3 + ido;
+
+ if (na == 0) {
+ passf5((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)c, ch, &wa[iw], &wa[ix2], &wa[ix3], &wa[ix4], isign);
+ } else {
+ passf5((const uint16_t)ido, (const uint16_t)l1, (const complex_t*)ch, c, &wa[iw], &wa[ix2], &wa[ix3], &wa[ix4], isign);
+ }
+
+ na = 1 - na;
+ break;
+ }
+
+ l1 = l2;
+ iw += (ip - 1) * ido;
+ }
+
+ if (na == 0) {
+ return;
+ }
+
+ for (i = 0; i < n; i++) {
+ RE(c[i]) = RE(ch[i]);
+ IM(c[i]) = IM(ch[i]);
+ }
+}
+
+void cfftf(cfft_info *cfft, complex_t *c)
+{
+ cfftf1neg(cfft->n, c, cfft->work, (const uint16_t*)cfft->ifac, (const complex_t*)cfft->tab, -1);
+}
+
+void cfftb(cfft_info *cfft, complex_t *c)
+{
+ cfftf1pos(cfft->n, c, cfft->work, (const uint16_t*)cfft->ifac, (const complex_t*)cfft->tab, +1);
+}
+
+static void cffti1(uint16_t n, complex_t *wa, uint16_t *ifac)
+{
+ static uint16_t ntryh[4] = {3, 4, 2, 5};
+#ifndef FIXED_POINT
+ real_t arg, argh, argld, fi;
+ uint16_t ido, ipm;
+ uint16_t i1, k1, l1, l2;
+ uint16_t ld, ii, ip;
+#endif
+ uint16_t ntry = 0, i, j;
+ uint16_t ib;
+ uint16_t nf, nl, nq, nr;
+
+ nl = n;
+ nf = 0;
+ j = 0;
+
+startloop:
+ j++;
+
+ if (j <= 4) {
+ ntry = ntryh[j - 1];
+ } else {
+ ntry += 2;
+ }
+
+ do {
+ nq = nl / ntry;
+ nr = nl - ntry * nq;
+
+ if (nr != 0) {
+ goto startloop;
+ }
+
+ nf++;
+ ifac[nf + 1] = ntry;
+ nl = nq;
+
+ if (ntry == 2 && nf != 1) {
+ for (i = 2; i <= nf; i++) {
+ ib = nf - i + 2;
+ ifac[ib + 1] = ifac[ib];
+ }
+ ifac[2] = 2;
+ }
+ } while (nl != 1);
+
+ ifac[0] = n;
+ ifac[1] = nf;
+
+#ifndef FIXED_POINT
+ argh = (real_t)2.0 * (real_t)M_PI / (real_t)n;
+ i = 0;
+ l1 = 1;
+
+ for (k1 = 1; k1 <= nf; k1++) {
+ ip = ifac[k1 + 1];
+ ld = 0;
+ l2 = l1 * ip;
+ ido = n / l2;
+ ipm = ip - 1;
+
+ for (j = 0; j < ipm; j++) {
+ i1 = i;
+ RE(wa[i]) = 1.0;
+ IM(wa[i]) = 0.0;
+ ld += l1;
+ fi = 0;
+ argld = ld * argh;
+
+ for (ii = 0; ii < ido; ii++) {
+ i++;
+ fi++;
+ arg = fi * argld;
+ RE(wa[i]) = (real_t)cos(arg);
+#if 1
+ IM(wa[i]) = (real_t)sin(arg);
+#else
+ IM(wa[i]) = (real_t) - sin(arg);
+#endif
+ }
+
+ if (ip > 5) {
+ RE(wa[i1]) = RE(wa[i]);
+ IM(wa[i1]) = IM(wa[i]);
+ }
+ }
+ l1 = l2;
+ }
+#endif
+}
+
+cfft_info *cffti(uint16_t n)
+{
+ cfft_info *cfft = (cfft_info*)faad_malloc(sizeof(cfft_info));
+
+ cfft->n = n;
+ cfft->work = (complex_t*)faad_malloc(n * sizeof(complex_t));
+
+#ifndef FIXED_POINT
+ cfft->tab = (complex_t*)faad_malloc(n * sizeof(complex_t));
+
+ cffti1(n, cfft->tab, cfft->ifac);
+#else
+ cffti1(n, NULL, cfft->ifac);
+
+ switch (n) {
+ case 64:
+ cfft->tab = (complex_t*)cfft_tab_64;
+ break;
+ case 512:
+ cfft->tab = (complex_t*)cfft_tab_512;
+ break;
+#ifdef LD_DEC
+ case 256:
+ cfft->tab = (complex_t*)cfft_tab_256;
+ break;
+#endif
+
+#ifdef ALLOW_SMALL_FRAMELENGTH
+ case 60:
+ cfft->tab = (complex_t*)cfft_tab_60;
+ break;
+ case 480:
+ cfft->tab = (complex_t*)cfft_tab_480;
+ break;
+#ifdef LD_DEC
+ case 240:
+ cfft->tab = (complex_t*)cfft_tab_240;
+ break;
+#endif
+#endif
+ case 128:
+ cfft->tab = (complex_t*)cfft_tab_128;
+ break;
+ }
+#endif
+
+ return cfft;
+}
+
+void cfftu(cfft_info *cfft)
+{
+ if (cfft->work) {
+ faad_free(cfft->work);
+ }
+#ifndef FIXED_POINT
+ if (cfft->tab) {
+ faad_free(cfft->tab);
+ }
+#endif
+
+ if (cfft) {
+ faad_free(cfft);
+ }
+}
+
diff --git a/audio_codec/libfaad/cfft.h b/audio_codec/libfaad/cfft.h
new file mode 100644
index 0000000..2f828a3
--- a/dev/null
+++ b/audio_codec/libfaad/cfft.h
@@ -0,0 +1,55 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: cfft.h,v 1.24 2007/11/01 12:33:29 menno Exp $
+**/
+
+#ifndef __CFFT_H__
+#define __CFFT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef struct {
+ uint16_t n;
+ uint16_t ifac[15];
+ complex_t *work;
+ complex_t *tab;
+ } cfft_info;
+
+
+ void cfftf(cfft_info *cfft, complex_t *c);
+ void cfftb(cfft_info *cfft, complex_t *c);
+ cfft_info *cffti(uint16_t n);
+ void cfftu(cfft_info *cfft);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/audio_codec/libfaad/cfft_tab.h b/audio_codec/libfaad/cfft_tab.h
new file mode 100644
index 0000000..6c9fee6
--- a/dev/null
+++ b/audio_codec/libfaad/cfft_tab.h
@@ -0,0 +1,1816 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: cfft_tab.h,v 1.21 2007/11/01 12:33:29 menno Exp $
+**/
+
+#ifndef __CFFT_TAB_H__
+#define __CFFT_TAB_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef FIXED_POINT
+
+ ALIGN static const complex_t cfft_tab_512[] = {
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.999924719333649), FRAC_CONST(0.012271538376808) },
+ { FRAC_CONST(0.999698817729950), FRAC_CONST(0.024541229009628) },
+ { FRAC_CONST(0.999322354793549), FRAC_CONST(0.036807224154472) },
+ { FRAC_CONST(0.998795449733734), FRAC_CONST(0.049067676067352) },
+ { FRAC_CONST(0.998118102550507), FRAC_CONST(0.061320740729570) },
+ { FRAC_CONST(0.997290432453156), FRAC_CONST(0.073564566671848) },
+ { FRAC_CONST(0.996312618255615), FRAC_CONST(0.085797317326069) },
+ { FRAC_CONST(0.995184719562531), FRAC_CONST(0.098017141222954) },
+ { FRAC_CONST(0.993906974792480), FRAC_CONST(0.110222205519676) },
+ { FRAC_CONST(0.992479562759399), FRAC_CONST(0.122410677373409) },
+ { FRAC_CONST(0.990902662277222), FRAC_CONST(0.134580716490746) },
+ { FRAC_CONST(0.989176511764526), FRAC_CONST(0.146730467677116) },
+ { FRAC_CONST(0.987301409244537), FRAC_CONST(0.158858150243759) },
+ { FRAC_CONST(0.985277652740479), FRAC_CONST(0.170961901545525) },
+ { FRAC_CONST(0.983105480670929), FRAC_CONST(0.183039888739586) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.978317379951477), FRAC_CONST(0.207111388444901) },
+ { FRAC_CONST(0.975702106952667), FRAC_CONST(0.219101235270500) },
+ { FRAC_CONST(0.972939968109131), FRAC_CONST(0.231058120727539) },
+ { FRAC_CONST(0.970031261444092), FRAC_CONST(0.242980197072029) },
+ { FRAC_CONST(0.966976463794708), FRAC_CONST(0.254865676164627) },
+ { FRAC_CONST(0.963776051998138), FRAC_CONST(0.266712784767151) },
+ { FRAC_CONST(0.960430502891541), FRAC_CONST(0.278519690036774) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.953306019306183), FRAC_CONST(0.302005946636200) },
+ { FRAC_CONST(0.949528157711029), FRAC_CONST(0.313681751489639) },
+ { FRAC_CONST(0.945607304573059), FRAC_CONST(0.325310319662094) },
+ { FRAC_CONST(0.941544055938721), FRAC_CONST(0.336889863014221) },
+ { FRAC_CONST(0.937339007854462), FRAC_CONST(0.348418682813644) },
+ { FRAC_CONST(0.932992815971375), FRAC_CONST(0.359895050525665) },
+ { FRAC_CONST(0.928506076335907), FRAC_CONST(0.371317207813263) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.919113874435425), FRAC_CONST(0.393992066383362) },
+ { FRAC_CONST(0.914209723472595), FRAC_CONST(0.405241340398788) },
+ { FRAC_CONST(0.909167945384979), FRAC_CONST(0.416429579257965) },
+ { FRAC_CONST(0.903989315032959), FRAC_CONST(0.427555084228516) },
+ { FRAC_CONST(0.898674488067627), FRAC_CONST(0.438616245985031) },
+ { FRAC_CONST(0.893224298954010), FRAC_CONST(0.449611335992813) },
+ { FRAC_CONST(0.887639641761780), FRAC_CONST(0.460538715124130) },
+ { FRAC_CONST(0.881921231746674), FRAC_CONST(0.471396744251251) },
+ { FRAC_CONST(0.876070082187653), FRAC_CONST(0.482183754444122) },
+ { FRAC_CONST(0.870086967945099), FRAC_CONST(0.492898225784302) },
+ { FRAC_CONST(0.863972842693329), FRAC_CONST(0.503538370132446) },
+ { FRAC_CONST(0.857728600502014), FRAC_CONST(0.514102756977081) },
+ { FRAC_CONST(0.851355195045471), FRAC_CONST(0.524589717388153) },
+ { FRAC_CONST(0.844853579998016), FRAC_CONST(0.534997642040253) },
+ { FRAC_CONST(0.838224709033966), FRAC_CONST(0.545324981212616) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.824589252471924), FRAC_CONST(0.565731823444366) },
+ { FRAC_CONST(0.817584812641144), FRAC_CONST(0.575808227062225) },
+ { FRAC_CONST(0.810457170009613), FRAC_CONST(0.585797905921936) },
+ { FRAC_CONST(0.803207516670227), FRAC_CONST(0.595699310302734) },
+ { FRAC_CONST(0.795836925506592), FRAC_CONST(0.605511009693146) },
+ { FRAC_CONST(0.788346409797668), FRAC_CONST(0.615231633186340) },
+ { FRAC_CONST(0.780737221240997), FRAC_CONST(0.624859511852264) },
+ { FRAC_CONST(0.773010432720184), FRAC_CONST(0.634393334388733) },
+ { FRAC_CONST(0.765167236328125), FRAC_CONST(0.643831551074982) },
+ { FRAC_CONST(0.757208824157715), FRAC_CONST(0.653172850608826) },
+ { FRAC_CONST(0.749136388301849), FRAC_CONST(0.662415802478790) },
+ { FRAC_CONST(0.740951120853424), FRAC_CONST(0.671558976173401) },
+ { FRAC_CONST(0.732654273509979), FRAC_CONST(0.680601000785828) },
+ { FRAC_CONST(0.724247097969055), FRAC_CONST(0.689540565013886) },
+ { FRAC_CONST(0.715730786323547), FRAC_CONST(0.698376297950745) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.698376238346100), FRAC_CONST(0.715730845928192) },
+ { FRAC_CONST(0.689540505409241), FRAC_CONST(0.724247097969055) },
+ { FRAC_CONST(0.680601000785828), FRAC_CONST(0.732654273509979) },
+ { FRAC_CONST(0.671558916568756), FRAC_CONST(0.740951180458069) },
+ { FRAC_CONST(0.662415742874146), FRAC_CONST(0.749136388301849) },
+ { FRAC_CONST(0.653172791004181), FRAC_CONST(0.757208883762360) },
+ { FRAC_CONST(0.643831551074982), FRAC_CONST(0.765167295932770) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.624859452247620), FRAC_CONST(0.780737280845642) },
+ { FRAC_CONST(0.615231573581696), FRAC_CONST(0.788346409797668) },
+ { FRAC_CONST(0.605511009693146), FRAC_CONST(0.795836925506592) },
+ { FRAC_CONST(0.595699310302734), FRAC_CONST(0.803207516670227) },
+ { FRAC_CONST(0.585797846317291), FRAC_CONST(0.810457170009613) },
+ { FRAC_CONST(0.575808167457581), FRAC_CONST(0.817584812641144) },
+ { FRAC_CONST(0.565731823444366), FRAC_CONST(0.824589312076569) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.545324981212616), FRAC_CONST(0.838224709033966) },
+ { FRAC_CONST(0.534997642040253), FRAC_CONST(0.844853579998016) },
+ { FRAC_CONST(0.524589657783508), FRAC_CONST(0.851355195045471) },
+ { FRAC_CONST(0.514102697372437), FRAC_CONST(0.857728660106659) },
+ { FRAC_CONST(0.503538429737091), FRAC_CONST(0.863972842693329) },
+ { FRAC_CONST(0.492898195981979), FRAC_CONST(0.870086967945099) },
+ { FRAC_CONST(0.482183724641800), FRAC_CONST(0.876070141792297) },
+ { FRAC_CONST(0.471396654844284), FRAC_CONST(0.881921291351318) },
+ { FRAC_CONST(0.460538715124130), FRAC_CONST(0.887639641761780) },
+ { FRAC_CONST(0.449611306190491), FRAC_CONST(0.893224298954010) },
+ { FRAC_CONST(0.438616186380386), FRAC_CONST(0.898674488067627) },
+ { FRAC_CONST(0.427555114030838), FRAC_CONST(0.903989315032959) },
+ { FRAC_CONST(0.416429549455643), FRAC_CONST(0.909168004989624) },
+ { FRAC_CONST(0.405241280794144), FRAC_CONST(0.914209783077240) },
+ { FRAC_CONST(0.393991947174072), FRAC_CONST(0.919113874435425) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.371317148208618), FRAC_CONST(0.928506076335907) },
+ { FRAC_CONST(0.359894961118698), FRAC_CONST(0.932992815971375) },
+ { FRAC_CONST(0.348418682813644), FRAC_CONST(0.937339007854462) },
+ { FRAC_CONST(0.336889833211899), FRAC_CONST(0.941544055938721) },
+ { FRAC_CONST(0.325310230255127), FRAC_CONST(0.945607364177704) },
+ { FRAC_CONST(0.313681662082672), FRAC_CONST(0.949528217315674) },
+ { FRAC_CONST(0.302005946636200), FRAC_CONST(0.953306019306183) },
+ { FRAC_CONST(0.290284633636475), FRAC_CONST(0.956940352916718) },
+ { FRAC_CONST(0.278519600629807), FRAC_CONST(0.960430562496185) },
+ { FRAC_CONST(0.266712754964828), FRAC_CONST(0.963776051998138) },
+ { FRAC_CONST(0.254865646362305), FRAC_CONST(0.966976463794708) },
+ { FRAC_CONST(0.242980122566223), FRAC_CONST(0.970031261444092) },
+ { FRAC_CONST(0.231058135628700), FRAC_CONST(0.972939968109131) },
+ { FRAC_CONST(0.219101220369339), FRAC_CONST(0.975702106952667) },
+ { FRAC_CONST(0.207111328840256), FRAC_CONST(0.978317379951477) },
+ { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) },
+ { FRAC_CONST(0.183039888739586), FRAC_CONST(0.983105480670929) },
+ { FRAC_CONST(0.170961856842041), FRAC_CONST(0.985277652740479) },
+ { FRAC_CONST(0.158858075737953), FRAC_CONST(0.987301409244537) },
+ { FRAC_CONST(0.146730497479439), FRAC_CONST(0.989176511764526) },
+ { FRAC_CONST(0.134580686688423), FRAC_CONST(0.990902662277222) },
+ { FRAC_CONST(0.122410625219345), FRAC_CONST(0.992479562759399) },
+ { FRAC_CONST(0.110222116112709), FRAC_CONST(0.993906974792480) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(0.085797272622585), FRAC_CONST(0.996312618255615) },
+ { FRAC_CONST(0.073564492166042), FRAC_CONST(0.997290432453156) },
+ { FRAC_CONST(0.061320748180151), FRAC_CONST(0.998118102550507) },
+ { FRAC_CONST(0.049067649990320), FRAC_CONST(0.998795449733734) },
+ { FRAC_CONST(0.036807164549828), FRAC_CONST(0.999322414398193) },
+ { FRAC_CONST(0.024541135877371), FRAC_CONST(0.999698817729950) },
+ { FRAC_CONST(0.012271529063582), FRAC_CONST(0.999924719333649) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.012271616607904), FRAC_CONST(0.999924719333649) },
+ { FRAC_CONST(-0.024541223421693), FRAC_CONST(0.999698817729950) },
+ { FRAC_CONST(-0.036807250231504), FRAC_CONST(0.999322354793549) },
+ { FRAC_CONST(-0.049067739397287), FRAC_CONST(0.998795449733734) },
+ { FRAC_CONST(-0.061320833861828), FRAC_CONST(0.998118102550507) },
+ { FRAC_CONST(-0.073564574122429), FRAC_CONST(0.997290432453156) },
+ { FRAC_CONST(-0.085797362029552), FRAC_CONST(0.996312618255615) },
+ { FRAC_CONST(-0.098017223179340), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(-0.110222205519676), FRAC_CONST(0.993906974792480) },
+ { FRAC_CONST(-0.122410707175732), FRAC_CONST(0.992479503154755) },
+ { FRAC_CONST(-0.134580776095390), FRAC_CONST(0.990902602672577) },
+ { FRAC_CONST(-0.146730571985245), FRAC_CONST(0.989176511764526) },
+ { FRAC_CONST(-0.158858165144920), FRAC_CONST(0.987301409244537) },
+ { FRAC_CONST(-0.170961946249008), FRAC_CONST(0.985277652740479) },
+ { FRAC_CONST(-0.183039978146553), FRAC_CONST(0.983105480670929) },
+ { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) },
+ { FRAC_CONST(-0.207111418247223), FRAC_CONST(0.978317379951477) },
+ { FRAC_CONST(-0.219101309776306), FRAC_CONST(0.975702106952667) },
+ { FRAC_CONST(-0.231058210134506), FRAC_CONST(0.972939908504486) },
+ { FRAC_CONST(-0.242980197072029), FRAC_CONST(0.970031261444092) },
+ { FRAC_CONST(-0.254865705966949), FRAC_CONST(0.966976463794708) },
+ { FRAC_CONST(-0.266712844371796), FRAC_CONST(0.963776051998138) },
+ { FRAC_CONST(-0.278519690036774), FRAC_CONST(0.960430502891541) },
+ { FRAC_CONST(-0.290284723043442), FRAC_CONST(0.956940293312073) },
+ { FRAC_CONST(-0.302006036043167), FRAC_CONST(0.953306019306183) },
+ { FRAC_CONST(-0.313681721687317), FRAC_CONST(0.949528157711029) },
+ { FRAC_CONST(-0.325310319662094), FRAC_CONST(0.945607304573059) },
+ { FRAC_CONST(-0.336889922618866), FRAC_CONST(0.941544055938721) },
+ { FRAC_CONST(-0.348418772220612), FRAC_CONST(0.937338948249817) },
+ { FRAC_CONST(-0.359895050525665), FRAC_CONST(0.932992815971375) },
+ { FRAC_CONST(-0.371317237615585), FRAC_CONST(0.928506076335907) },
+ { FRAC_CONST(-0.382683515548706), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(-0.393992036581039), FRAC_CONST(0.919113874435425) },
+ { FRAC_CONST(-0.405241340398788), FRAC_CONST(0.914209723472595) },
+ { FRAC_CONST(-0.416429519653320), FRAC_CONST(0.909168004989624) },
+ { FRAC_CONST(-0.427555084228516), FRAC_CONST(0.903989315032959) },
+ { FRAC_CONST(-0.438616245985031), FRAC_CONST(0.898674428462982) },
+ { FRAC_CONST(-0.449611365795136), FRAC_CONST(0.893224298954010) },
+ { FRAC_CONST(-0.460538804531097), FRAC_CONST(0.887639582157135) },
+ { FRAC_CONST(-0.471396833658218), FRAC_CONST(0.881921231746674) },
+ { FRAC_CONST(-0.482183903455734), FRAC_CONST(0.876070022583008) },
+ { FRAC_CONST(-0.492898166179657), FRAC_CONST(0.870087027549744) },
+ { FRAC_CONST(-0.503538370132446), FRAC_CONST(0.863972842693329) },
+ { FRAC_CONST(-0.514102756977081), FRAC_CONST(0.857728600502014) },
+ { FRAC_CONST(-0.524589717388153), FRAC_CONST(0.851355135440826) },
+ { FRAC_CONST(-0.534997701644897), FRAC_CONST(0.844853520393372) },
+ { FRAC_CONST(-0.545325100421906), FRAC_CONST(0.838224649429321) },
+ { FRAC_CONST(-0.555570363998413), FRAC_CONST(0.831469535827637) },
+ { FRAC_CONST(-0.565731763839722), FRAC_CONST(0.824589312076569) },
+ { FRAC_CONST(-0.575808167457581), FRAC_CONST(0.817584812641144) },
+ { FRAC_CONST(-0.585797905921936), FRAC_CONST(0.810457170009613) },
+ { FRAC_CONST(-0.595699369907379), FRAC_CONST(0.803207516670227) },
+ { FRAC_CONST(-0.605511128902435), FRAC_CONST(0.795836865901947) },
+ { FRAC_CONST(-0.615231692790985), FRAC_CONST(0.788346350193024) },
+ { FRAC_CONST(-0.624859631061554), FRAC_CONST(0.780737102031708) },
+ { FRAC_CONST(-0.634393274784088), FRAC_CONST(0.773010492324829) },
+ { FRAC_CONST(-0.643831551074982), FRAC_CONST(0.765167236328125) },
+ { FRAC_CONST(-0.653172850608826), FRAC_CONST(0.757208824157715) },
+ { FRAC_CONST(-0.662415802478790), FRAC_CONST(0.749136328697205) },
+ { FRAC_CONST(-0.671559035778046), FRAC_CONST(0.740951061248779) },
+ { FRAC_CONST(-0.680601119995117), FRAC_CONST(0.732654154300690) },
+ { FRAC_CONST(-0.689540684223175), FRAC_CONST(0.724246978759766) },
+ { FRAC_CONST(-0.698376238346100), FRAC_CONST(0.715730845928192) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.715730845928192), FRAC_CONST(0.698376238346100) },
+ { FRAC_CONST(-0.724247157573700), FRAC_CONST(0.689540505409241) },
+ { FRAC_CONST(-0.732654333114624), FRAC_CONST(0.680600941181183) },
+ { FRAC_CONST(-0.740951240062714), FRAC_CONST(0.671558856964111) },
+ { FRAC_CONST(-0.749136507511139), FRAC_CONST(0.662415623664856) },
+ { FRAC_CONST(-0.757208824157715), FRAC_CONST(0.653172850608826) },
+ { FRAC_CONST(-0.765167295932770), FRAC_CONST(0.643831551074982) },
+ { FRAC_CONST(-0.773010492324829), FRAC_CONST(0.634393274784088) },
+ { FRAC_CONST(-0.780737280845642), FRAC_CONST(0.624859452247620) },
+ { FRAC_CONST(-0.788346469402313), FRAC_CONST(0.615231513977051) },
+ { FRAC_CONST(-0.795836985111237), FRAC_CONST(0.605510950088501) },
+ { FRAC_CONST(-0.803207635879517), FRAC_CONST(0.595699131488800) },
+ { FRAC_CONST(-0.810457170009613), FRAC_CONST(0.585797846317291) },
+ { FRAC_CONST(-0.817584812641144), FRAC_CONST(0.575808167457581) },
+ { FRAC_CONST(-0.824589312076569), FRAC_CONST(0.565731763839722) },
+ { FRAC_CONST(-0.831469655036926), FRAC_CONST(0.555570185184479) },
+ { FRAC_CONST(-0.838224768638611), FRAC_CONST(0.545324862003326) },
+ { FRAC_CONST(-0.844853639602661), FRAC_CONST(0.534997463226318) },
+ { FRAC_CONST(-0.851355314254761), FRAC_CONST(0.524589538574219) },
+ { FRAC_CONST(-0.857728600502014), FRAC_CONST(0.514102756977081) },
+ { FRAC_CONST(-0.863972842693329), FRAC_CONST(0.503538370132446) },
+ { FRAC_CONST(-0.870087027549744), FRAC_CONST(0.492898136377335) },
+ { FRAC_CONST(-0.876070141792297), FRAC_CONST(0.482183694839478) },
+ { FRAC_CONST(-0.881921350955963), FRAC_CONST(0.471396625041962) },
+ { FRAC_CONST(-0.887639701366425), FRAC_CONST(0.460538566112518) },
+ { FRAC_CONST(-0.893224298954010), FRAC_CONST(0.449611365795136) },
+ { FRAC_CONST(-0.898674488067627), FRAC_CONST(0.438616245985031) },
+ { FRAC_CONST(-0.903989315032959), FRAC_CONST(0.427555054426193) },
+ { FRAC_CONST(-0.909168004989624), FRAC_CONST(0.416429489850998) },
+ { FRAC_CONST(-0.914209783077240), FRAC_CONST(0.405241221189499) },
+ { FRAC_CONST(-0.919113874435425), FRAC_CONST(0.393991917371750) },
+ { FRAC_CONST(-0.923879623413086), FRAC_CONST(0.382683277130127) },
+ { FRAC_CONST(-0.928506076335907), FRAC_CONST(0.371317237615585) },
+ { FRAC_CONST(-0.932992815971375), FRAC_CONST(0.359895050525665) },
+ { FRAC_CONST(-0.937339007854462), FRAC_CONST(0.348418653011322) },
+ { FRAC_CONST(-0.941544115543365), FRAC_CONST(0.336889803409576) },
+ { FRAC_CONST(-0.945607364177704), FRAC_CONST(0.325310200452805) },
+ { FRAC_CONST(-0.949528217315674), FRAC_CONST(0.313681602478027) },
+ { FRAC_CONST(-0.953306078910828), FRAC_CONST(0.302005797624588) },
+ { FRAC_CONST(-0.956940352916718), FRAC_CONST(0.290284723043442) },
+ { FRAC_CONST(-0.960430502891541), FRAC_CONST(0.278519690036774) },
+ { FRAC_CONST(-0.963776051998138), FRAC_CONST(0.266712725162506) },
+ { FRAC_CONST(-0.966976463794708), FRAC_CONST(0.254865586757660) },
+ { FRAC_CONST(-0.970031261444092), FRAC_CONST(0.242980077862740) },
+ { FRAC_CONST(-0.972939968109131), FRAC_CONST(0.231057971715927) },
+ { FRAC_CONST(-0.975702166557312), FRAC_CONST(0.219101071357727) },
+ { FRAC_CONST(-0.978317379951477), FRAC_CONST(0.207111403346062) },
+ { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) },
+ { FRAC_CONST(-0.983105480670929), FRAC_CONST(0.183039844036102) },
+ { FRAC_CONST(-0.985277652740479), FRAC_CONST(0.170961812138557) },
+ { FRAC_CONST(-0.987301409244537), FRAC_CONST(0.158858031034470) },
+ { FRAC_CONST(-0.989176511764526), FRAC_CONST(0.146730333566666) },
+ { FRAC_CONST(-0.990902662277222), FRAC_CONST(0.134580522775650) },
+ { FRAC_CONST(-0.992479503154755), FRAC_CONST(0.122410699725151) },
+ { FRAC_CONST(-0.993906974792480), FRAC_CONST(0.110222198069096) },
+ { FRAC_CONST(-0.995184719562531), FRAC_CONST(0.098017096519470) },
+ { FRAC_CONST(-0.996312618255615), FRAC_CONST(0.085797227919102) },
+ { FRAC_CONST(-0.997290492057800), FRAC_CONST(0.073564447462559) },
+ { FRAC_CONST(-0.998118102550507), FRAC_CONST(0.061320584267378) },
+ { FRAC_CONST(-0.998795449733734), FRAC_CONST(0.049067486077547) },
+ { FRAC_CONST(-0.999322354793549), FRAC_CONST(0.036807239055634) },
+ { FRAC_CONST(-0.999698817729950), FRAC_CONST(0.024541210383177) },
+ { FRAC_CONST(-0.999924719333649), FRAC_CONST(0.012271485291421) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.999698817729950), FRAC_CONST(0.024541229009628) },
+ { FRAC_CONST(0.998795449733734), FRAC_CONST(0.049067676067352) },
+ { FRAC_CONST(0.997290432453156), FRAC_CONST(0.073564566671848) },
+ { FRAC_CONST(0.995184719562531), FRAC_CONST(0.098017141222954) },
+ { FRAC_CONST(0.992479562759399), FRAC_CONST(0.122410677373409) },
+ { FRAC_CONST(0.989176511764526), FRAC_CONST(0.146730467677116) },
+ { FRAC_CONST(0.985277652740479), FRAC_CONST(0.170961901545525) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.975702106952667), FRAC_CONST(0.219101235270500) },
+ { FRAC_CONST(0.970031261444092), FRAC_CONST(0.242980197072029) },
+ { FRAC_CONST(0.963776051998138), FRAC_CONST(0.266712784767151) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.949528157711029), FRAC_CONST(0.313681751489639) },
+ { FRAC_CONST(0.941544055938721), FRAC_CONST(0.336889863014221) },
+ { FRAC_CONST(0.932992815971375), FRAC_CONST(0.359895050525665) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.914209723472595), FRAC_CONST(0.405241340398788) },
+ { FRAC_CONST(0.903989315032959), FRAC_CONST(0.427555084228516) },
+ { FRAC_CONST(0.893224298954010), FRAC_CONST(0.449611335992813) },
+ { FRAC_CONST(0.881921231746674), FRAC_CONST(0.471396744251251) },
+ { FRAC_CONST(0.870086967945099), FRAC_CONST(0.492898225784302) },
+ { FRAC_CONST(0.857728600502014), FRAC_CONST(0.514102756977081) },
+ { FRAC_CONST(0.844853579998016), FRAC_CONST(0.534997642040253) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.817584812641144), FRAC_CONST(0.575808227062225) },
+ { FRAC_CONST(0.803207516670227), FRAC_CONST(0.595699310302734) },
+ { FRAC_CONST(0.788346409797668), FRAC_CONST(0.615231633186340) },
+ { FRAC_CONST(0.773010432720184), FRAC_CONST(0.634393334388733) },
+ { FRAC_CONST(0.757208824157715), FRAC_CONST(0.653172850608826) },
+ { FRAC_CONST(0.740951120853424), FRAC_CONST(0.671558976173401) },
+ { FRAC_CONST(0.724247097969055), FRAC_CONST(0.689540565013886) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.689540505409241), FRAC_CONST(0.724247097969055) },
+ { FRAC_CONST(0.671558916568756), FRAC_CONST(0.740951180458069) },
+ { FRAC_CONST(0.653172791004181), FRAC_CONST(0.757208883762360) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.615231573581696), FRAC_CONST(0.788346409797668) },
+ { FRAC_CONST(0.595699310302734), FRAC_CONST(0.803207516670227) },
+ { FRAC_CONST(0.575808167457581), FRAC_CONST(0.817584812641144) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.534997642040253), FRAC_CONST(0.844853579998016) },
+ { FRAC_CONST(0.514102697372437), FRAC_CONST(0.857728660106659) },
+ { FRAC_CONST(0.492898195981979), FRAC_CONST(0.870086967945099) },
+ { FRAC_CONST(0.471396654844284), FRAC_CONST(0.881921291351318) },
+ { FRAC_CONST(0.449611306190491), FRAC_CONST(0.893224298954010) },
+ { FRAC_CONST(0.427555114030838), FRAC_CONST(0.903989315032959) },
+ { FRAC_CONST(0.405241280794144), FRAC_CONST(0.914209783077240) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.359894961118698), FRAC_CONST(0.932992815971375) },
+ { FRAC_CONST(0.336889833211899), FRAC_CONST(0.941544055938721) },
+ { FRAC_CONST(0.313681662082672), FRAC_CONST(0.949528217315674) },
+ { FRAC_CONST(0.290284633636475), FRAC_CONST(0.956940352916718) },
+ { FRAC_CONST(0.266712754964828), FRAC_CONST(0.963776051998138) },
+ { FRAC_CONST(0.242980122566223), FRAC_CONST(0.970031261444092) },
+ { FRAC_CONST(0.219101220369339), FRAC_CONST(0.975702106952667) },
+ { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) },
+ { FRAC_CONST(0.170961856842041), FRAC_CONST(0.985277652740479) },
+ { FRAC_CONST(0.146730497479439), FRAC_CONST(0.989176511764526) },
+ { FRAC_CONST(0.122410625219345), FRAC_CONST(0.992479562759399) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(0.073564492166042), FRAC_CONST(0.997290432453156) },
+ { FRAC_CONST(0.049067649990320), FRAC_CONST(0.998795449733734) },
+ { FRAC_CONST(0.024541135877371), FRAC_CONST(0.999698817729950) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.998795449733734), FRAC_CONST(0.049067676067352) },
+ { FRAC_CONST(0.995184719562531), FRAC_CONST(0.098017141222954) },
+ { FRAC_CONST(0.989176511764526), FRAC_CONST(0.146730467677116) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.970031261444092), FRAC_CONST(0.242980197072029) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.941544055938721), FRAC_CONST(0.336889863014221) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.903989315032959), FRAC_CONST(0.427555084228516) },
+ { FRAC_CONST(0.881921231746674), FRAC_CONST(0.471396744251251) },
+ { FRAC_CONST(0.857728600502014), FRAC_CONST(0.514102756977081) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.803207516670227), FRAC_CONST(0.595699310302734) },
+ { FRAC_CONST(0.773010432720184), FRAC_CONST(0.634393334388733) },
+ { FRAC_CONST(0.740951120853424), FRAC_CONST(0.671558976173401) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.671558916568756), FRAC_CONST(0.740951180458069) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.595699310302734), FRAC_CONST(0.803207516670227) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.514102697372437), FRAC_CONST(0.857728660106659) },
+ { FRAC_CONST(0.471396654844284), FRAC_CONST(0.881921291351318) },
+ { FRAC_CONST(0.427555114030838), FRAC_CONST(0.903989315032959) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.336889833211899), FRAC_CONST(0.941544055938721) },
+ { FRAC_CONST(0.290284633636475), FRAC_CONST(0.956940352916718) },
+ { FRAC_CONST(0.242980122566223), FRAC_CONST(0.970031261444092) },
+ { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) },
+ { FRAC_CONST(0.146730497479439), FRAC_CONST(0.989176511764526) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(0.049067649990320), FRAC_CONST(0.998795449733734) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.049067739397287), FRAC_CONST(0.998795449733734) },
+ { FRAC_CONST(-0.098017223179340), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(-0.146730571985245), FRAC_CONST(0.989176511764526) },
+ { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) },
+ { FRAC_CONST(-0.242980197072029), FRAC_CONST(0.970031261444092) },
+ { FRAC_CONST(-0.290284723043442), FRAC_CONST(0.956940293312073) },
+ { FRAC_CONST(-0.336889922618866), FRAC_CONST(0.941544055938721) },
+ { FRAC_CONST(-0.382683515548706), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(-0.427555084228516), FRAC_CONST(0.903989315032959) },
+ { FRAC_CONST(-0.471396833658218), FRAC_CONST(0.881921231746674) },
+ { FRAC_CONST(-0.514102756977081), FRAC_CONST(0.857728600502014) },
+ { FRAC_CONST(-0.555570363998413), FRAC_CONST(0.831469535827637) },
+ { FRAC_CONST(-0.595699369907379), FRAC_CONST(0.803207516670227) },
+ { FRAC_CONST(-0.634393274784088), FRAC_CONST(0.773010492324829) },
+ { FRAC_CONST(-0.671559035778046), FRAC_CONST(0.740951061248779) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.740951240062714), FRAC_CONST(0.671558856964111) },
+ { FRAC_CONST(-0.773010492324829), FRAC_CONST(0.634393274784088) },
+ { FRAC_CONST(-0.803207635879517), FRAC_CONST(0.595699131488800) },
+ { FRAC_CONST(-0.831469655036926), FRAC_CONST(0.555570185184479) },
+ { FRAC_CONST(-0.857728600502014), FRAC_CONST(0.514102756977081) },
+ { FRAC_CONST(-0.881921350955963), FRAC_CONST(0.471396625041962) },
+ { FRAC_CONST(-0.903989315032959), FRAC_CONST(0.427555054426193) },
+ { FRAC_CONST(-0.923879623413086), FRAC_CONST(0.382683277130127) },
+ { FRAC_CONST(-0.941544115543365), FRAC_CONST(0.336889803409576) },
+ { FRAC_CONST(-0.956940352916718), FRAC_CONST(0.290284723043442) },
+ { FRAC_CONST(-0.970031261444092), FRAC_CONST(0.242980077862740) },
+ { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) },
+ { FRAC_CONST(-0.989176511764526), FRAC_CONST(0.146730333566666) },
+ { FRAC_CONST(-0.995184719562531), FRAC_CONST(0.098017096519470) },
+ { FRAC_CONST(-0.998795449733734), FRAC_CONST(0.049067486077547) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.997290432453156), FRAC_CONST(0.073564566671848) },
+ { FRAC_CONST(0.989176511764526), FRAC_CONST(0.146730467677116) },
+ { FRAC_CONST(0.975702106952667), FRAC_CONST(0.219101235270500) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.932992815971375), FRAC_CONST(0.359895050525665) },
+ { FRAC_CONST(0.903989315032959), FRAC_CONST(0.427555084228516) },
+ { FRAC_CONST(0.870086967945099), FRAC_CONST(0.492898225784302) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.788346469402313), FRAC_CONST(0.615231573581696) },
+ { FRAC_CONST(0.740951120853424), FRAC_CONST(0.671558976173401) },
+ { FRAC_CONST(0.689540505409241), FRAC_CONST(0.724247097969055) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.575808227062225), FRAC_CONST(0.817584812641144) },
+ { FRAC_CONST(0.514102697372437), FRAC_CONST(0.857728660106659) },
+ { FRAC_CONST(0.449611306190491), FRAC_CONST(0.893224298954010) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.313681751489639), FRAC_CONST(0.949528157711029) },
+ { FRAC_CONST(0.242980241775513), FRAC_CONST(0.970031261444092) },
+ { FRAC_CONST(0.170961856842041), FRAC_CONST(0.985277652740479) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(0.024541255086660), FRAC_CONST(0.999698817729950) },
+ { FRAC_CONST(-0.049067739397287), FRAC_CONST(0.998795449733734) },
+ { FRAC_CONST(-0.122410707175732), FRAC_CONST(0.992479503154755) },
+ { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) },
+ { FRAC_CONST(-0.266712725162506), FRAC_CONST(0.963776051998138) },
+ { FRAC_CONST(-0.336889803409576), FRAC_CONST(0.941544055938721) },
+ { FRAC_CONST(-0.405241340398788), FRAC_CONST(0.914209723472595) },
+ { FRAC_CONST(-0.471396833658218), FRAC_CONST(0.881921231746674) },
+ { FRAC_CONST(-0.534997701644897), FRAC_CONST(0.844853520393372) },
+ { FRAC_CONST(-0.595699369907379), FRAC_CONST(0.803207516670227) },
+ { FRAC_CONST(-0.653172850608826), FRAC_CONST(0.757208824157715) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.757208824157715), FRAC_CONST(0.653172850608826) },
+ { FRAC_CONST(-0.803207516670227), FRAC_CONST(0.595699369907379) },
+ { FRAC_CONST(-0.844853520393372), FRAC_CONST(0.534997701644897) },
+ { FRAC_CONST(-0.881921231746674), FRAC_CONST(0.471396833658218) },
+ { FRAC_CONST(-0.914209783077240), FRAC_CONST(0.405241221189499) },
+ { FRAC_CONST(-0.941544115543365), FRAC_CONST(0.336889803409576) },
+ { FRAC_CONST(-0.963776051998138), FRAC_CONST(0.266712725162506) },
+ { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) },
+ { FRAC_CONST(-0.992479503154755), FRAC_CONST(0.122410699725151) },
+ { FRAC_CONST(-0.998795449733734), FRAC_CONST(0.049067724496126) },
+ { FRAC_CONST(-0.999698817729950), FRAC_CONST(-0.024541147053242) },
+ { FRAC_CONST(-0.995184719562531), FRAC_CONST(-0.098017267882824) },
+ { FRAC_CONST(-0.985277652740479), FRAC_CONST(-0.170961990952492) },
+ { FRAC_CONST(-0.970031261444092), FRAC_CONST(-0.242980241775513) },
+ { FRAC_CONST(-0.949528157711029), FRAC_CONST(-0.313681781291962) },
+ { FRAC_CONST(-0.923879504203796), FRAC_CONST(-0.382683426141739) },
+ { FRAC_CONST(-0.893224298954010), FRAC_CONST(-0.449611306190491) },
+ { FRAC_CONST(-0.857728660106659), FRAC_CONST(-0.514102697372437) },
+ { FRAC_CONST(-0.817584872245789), FRAC_CONST(-0.575808107852936) },
+ { FRAC_CONST(-0.773010551929474), FRAC_CONST(-0.634393215179443) },
+ { FRAC_CONST(-0.724247038364410), FRAC_CONST(-0.689540624618530) },
+ { FRAC_CONST(-0.671558916568756), FRAC_CONST(-0.740951180458069) },
+ { FRAC_CONST(-0.615231573581696), FRAC_CONST(-0.788346469402313) },
+ { FRAC_CONST(-0.555570006370544), FRAC_CONST(-0.831469774246216) },
+ { FRAC_CONST(-0.492898195981979), FRAC_CONST(-0.870086967945099) },
+ { FRAC_CONST(-0.427554935216904), FRAC_CONST(-0.903989374637604) },
+ { FRAC_CONST(-0.359895110130310), FRAC_CONST(-0.932992756366730) },
+ { FRAC_CONST(-0.290284544229507), FRAC_CONST(-0.956940352916718) },
+ { FRAC_CONST(-0.219101369380951), FRAC_CONST(-0.975702106952667) },
+ { FRAC_CONST(-0.146730408072472), FRAC_CONST(-0.989176511764526) },
+ { FRAC_CONST(-0.073564760386944), FRAC_CONST(-0.997290432453156) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.995184719562531), FRAC_CONST(0.098017141222954) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.881921231746674), FRAC_CONST(0.471396744251251) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.773010432720184), FRAC_CONST(0.634393334388733) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.471396654844284), FRAC_CONST(0.881921291351318) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.290284633636475), FRAC_CONST(0.956940352916718) },
+ { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) },
+ { FRAC_CONST(-0.382683515548706), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(-0.555570363998413), FRAC_CONST(0.831469535827637) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.831469655036926), FRAC_CONST(0.555570185184479) },
+ { FRAC_CONST(-0.923879623413086), FRAC_CONST(0.382683277130127) },
+ { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) },
+ { FRAC_CONST(-0.471396833658218), FRAC_CONST(0.881921231746674) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.881921231746674), FRAC_CONST(0.471396833658218) },
+ { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) },
+ { FRAC_CONST(-0.995184719562531), FRAC_CONST(-0.098017267882824) },
+ { FRAC_CONST(-0.923879504203796), FRAC_CONST(-0.382683426141739) },
+ { FRAC_CONST(-0.773010551929474), FRAC_CONST(-0.634393215179443) },
+ { FRAC_CONST(-0.555570006370544), FRAC_CONST(-0.831469774246216) },
+ { FRAC_CONST(-0.290284544229507), FRAC_CONST(-0.956940352916718) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.923879504203796), FRAC_CONST(-0.382683426141739) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.000000011924881), FRAC_CONST(-1.000000000000000) }
+ };
+
+#ifdef ALLOW_SMALL_FRAMELENGTH
+ ALIGN static const complex_t cfft_tab_480[] = {
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.999914348125458), FRAC_CONST(0.013089596293867) },
+ { FRAC_CONST(0.999657332897186), FRAC_CONST(0.026176949962974) },
+ { FRAC_CONST(0.999229013919830), FRAC_CONST(0.039259817451239) },
+ { FRAC_CONST(0.998629510402679), FRAC_CONST(0.052335958927870) },
+ { FRAC_CONST(0.997858941555023), FRAC_CONST(0.065403133630753) },
+ { FRAC_CONST(0.996917307376862), FRAC_CONST(0.078459098935127) },
+ { FRAC_CONST(0.995804905891418), FRAC_CONST(0.091501623392105) },
+ { FRAC_CONST(0.994521915912628), FRAC_CONST(0.104528464376926) },
+ { FRAC_CONST(0.993068456649780), FRAC_CONST(0.117537401616573) },
+ { FRAC_CONST(0.991444885730743), FRAC_CONST(0.130526199936867) },
+ { FRAC_CONST(0.989651381969452), FRAC_CONST(0.143492624163628) },
+ { FRAC_CONST(0.987688362598419), FRAC_CONST(0.156434476375580) },
+ { FRAC_CONST(0.985556066036224), FRAC_CONST(0.169349506497383) },
+ { FRAC_CONST(0.983254909515381), FRAC_CONST(0.182235524058342) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.978147625923157), FRAC_CONST(0.207911700010300) },
+ { FRAC_CONST(0.975342333316803), FRAC_CONST(0.220697447657585) },
+ { FRAC_CONST(0.972369909286499), FRAC_CONST(0.233445376157761) },
+ { FRAC_CONST(0.969230890274048), FRAC_CONST(0.246153295040131) },
+ { FRAC_CONST(0.965925812721252), FRAC_CONST(0.258819043636322) },
+ { FRAC_CONST(0.962455213069916), FRAC_CONST(0.271440446376801) },
+ { FRAC_CONST(0.958819746971130), FRAC_CONST(0.284015357494354) },
+ { FRAC_CONST(0.955019950866699), FRAC_CONST(0.296541601419449) },
+ { FRAC_CONST(0.951056540012360), FRAC_CONST(0.309017002582550) },
+ { FRAC_CONST(0.946930110454559), FRAC_CONST(0.321439445018768) },
+ { FRAC_CONST(0.942641496658325), FRAC_CONST(0.333806872367859) },
+ { FRAC_CONST(0.938191354274750), FRAC_CONST(0.346117079257965) },
+ { FRAC_CONST(0.933580398559570), FRAC_CONST(0.358367949724197) },
+ { FRAC_CONST(0.928809583187103), FRAC_CONST(0.370557427406311) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.918791174888611), FRAC_CONST(0.394743889570236) },
+ { FRAC_CONST(0.913545429706573), FRAC_CONST(0.406736642122269) },
+ { FRAC_CONST(0.908143162727356), FRAC_CONST(0.418659746646881) },
+ { FRAC_CONST(0.902585268020630), FRAC_CONST(0.430511116981506) },
+ { FRAC_CONST(0.896872758865356), FRAC_CONST(0.442288726568222) },
+ { FRAC_CONST(0.891006529331207), FRAC_CONST(0.453990519046783) },
+ { FRAC_CONST(0.884987652301788), FRAC_CONST(0.465614527463913) },
+ { FRAC_CONST(0.878817081451416), FRAC_CONST(0.477158784866333) },
+ { FRAC_CONST(0.872496008872986), FRAC_CONST(0.488621264696121) },
+ { FRAC_CONST(0.866025388240814), FRAC_CONST(0.500000000000000) },
+ { FRAC_CONST(0.859406411647797), FRAC_CONST(0.511293113231659) },
+ { FRAC_CONST(0.852640151977539), FRAC_CONST(0.522498548030853) },
+ { FRAC_CONST(0.845727801322937), FRAC_CONST(0.533614516258240) },
+ { FRAC_CONST(0.838670551776886), FRAC_CONST(0.544639050960541) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.824126183986664), FRAC_CONST(0.566406250000000) },
+ { FRAC_CONST(0.816641509532928), FRAC_CONST(0.577145218849182) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.801253795623779), FRAC_CONST(0.598324596881866) },
+ { FRAC_CONST(0.793353319168091), FRAC_CONST(0.608761429786682) },
+ { FRAC_CONST(0.785316884517670), FRAC_CONST(0.619093954563141) },
+ { FRAC_CONST(0.777145922183990), FRAC_CONST(0.629320383071899) },
+ { FRAC_CONST(0.768841803073883), FRAC_CONST(0.639438986778259) },
+ { FRAC_CONST(0.760405957698822), FRAC_CONST(0.649448096752167) },
+ { FRAC_CONST(0.751839756965637), FRAC_CONST(0.659345865249634) },
+ { FRAC_CONST(0.743144810199738), FRAC_CONST(0.669130623340607) },
+ { FRAC_CONST(0.734322488307953), FRAC_CONST(0.678800761699677) },
+ { FRAC_CONST(0.725374400615692), FRAC_CONST(0.688354551792145) },
+ { FRAC_CONST(0.716301918029785), FRAC_CONST(0.697790503501892) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.697790443897247), FRAC_CONST(0.716301977634430) },
+ { FRAC_CONST(0.688354551792145), FRAC_CONST(0.725374400615692) },
+ { FRAC_CONST(0.678800702095032), FRAC_CONST(0.734322547912598) },
+ { FRAC_CONST(0.669130563735962), FRAC_CONST(0.743144869804382) },
+ { FRAC_CONST(0.659345805644989), FRAC_CONST(0.751839816570282) },
+ { FRAC_CONST(0.649448037147522), FRAC_CONST(0.760405957698822) },
+ { FRAC_CONST(0.639438986778259), FRAC_CONST(0.768841862678528) },
+ { FRAC_CONST(0.629320383071899), FRAC_CONST(0.777145981788635) },
+ { FRAC_CONST(0.619093954563141), FRAC_CONST(0.785316944122314) },
+ { FRAC_CONST(0.608761370182037), FRAC_CONST(0.793353378772736) },
+ { FRAC_CONST(0.598324596881866), FRAC_CONST(0.801253855228424) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(0.577145159244537), FRAC_CONST(0.816641569137573) },
+ { FRAC_CONST(0.566406250000000), FRAC_CONST(0.824126183986664) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.544638991355896), FRAC_CONST(0.838670611381531) },
+ { FRAC_CONST(0.533614516258240), FRAC_CONST(0.845727801322937) },
+ { FRAC_CONST(0.522498488426209), FRAC_CONST(0.852640211582184) },
+ { FRAC_CONST(0.511293113231659), FRAC_CONST(0.859406411647797) },
+ { FRAC_CONST(0.499999970197678), FRAC_CONST(0.866025447845459) },
+ { FRAC_CONST(0.488621175289154), FRAC_CONST(0.872496068477631) },
+ { FRAC_CONST(0.477158755064011), FRAC_CONST(0.878817141056061) },
+ { FRAC_CONST(0.465614467859268), FRAC_CONST(0.884987652301788) },
+ { FRAC_CONST(0.453990519046783), FRAC_CONST(0.891006529331207) },
+ { FRAC_CONST(0.442288666963577), FRAC_CONST(0.896872758865356) },
+ { FRAC_CONST(0.430511027574539), FRAC_CONST(0.902585327625275) },
+ { FRAC_CONST(0.418659746646881), FRAC_CONST(0.908143162727356) },
+ { FRAC_CONST(0.406736612319946), FRAC_CONST(0.913545489311218) },
+ { FRAC_CONST(0.394743800163269), FRAC_CONST(0.918791234493256) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.370557397603989), FRAC_CONST(0.928809583187103) },
+ { FRAC_CONST(0.358367860317230), FRAC_CONST(0.933580458164215) },
+ { FRAC_CONST(0.346117049455643), FRAC_CONST(0.938191354274750) },
+ { FRAC_CONST(0.333806812763214), FRAC_CONST(0.942641496658325) },
+ { FRAC_CONST(0.321439474821091), FRAC_CONST(0.946930110454559) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(0.296541512012482), FRAC_CONST(0.955019950866699) },
+ { FRAC_CONST(0.284015327692032), FRAC_CONST(0.958819746971130) },
+ { FRAC_CONST(0.271440386772156), FRAC_CONST(0.962455272674561) },
+ { FRAC_CONST(0.258819073438644), FRAC_CONST(0.965925812721252) },
+ { FRAC_CONST(0.246153265237808), FRAC_CONST(0.969230890274048) },
+ { FRAC_CONST(0.233445301651955), FRAC_CONST(0.972369909286499) },
+ { FRAC_CONST(0.220697447657585), FRAC_CONST(0.975342333316803) },
+ { FRAC_CONST(0.207911655306816), FRAC_CONST(0.978147625923157) },
+ { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) },
+ { FRAC_CONST(0.182235524058342), FRAC_CONST(0.983254909515381) },
+ { FRAC_CONST(0.169349446892738), FRAC_CONST(0.985556066036224) },
+ { FRAC_CONST(0.156434372067451), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(0.143492594361305), FRAC_CONST(0.989651381969452) },
+ { FRAC_CONST(0.130526125431061), FRAC_CONST(0.991444885730743) },
+ { FRAC_CONST(0.117537401616573), FRAC_CONST(0.993068456649780) },
+ { FRAC_CONST(0.104528419673443), FRAC_CONST(0.994521915912628) },
+ { FRAC_CONST(0.091501533985138), FRAC_CONST(0.995804905891418) },
+ { FRAC_CONST(0.078459084033966), FRAC_CONST(0.996917307376862) },
+ { FRAC_CONST(0.065403074026108), FRAC_CONST(0.997858941555023) },
+ { FRAC_CONST(0.052335973829031), FRAC_CONST(0.998629510402679) },
+ { FRAC_CONST(0.039259787648916), FRAC_CONST(0.999229013919830) },
+ { FRAC_CONST(0.026176875457168), FRAC_CONST(0.999657332897186) },
+ { FRAC_CONST(0.013089597225189), FRAC_CONST(0.999914348125458) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.013089684769511), FRAC_CONST(0.999914348125458) },
+ { FRAC_CONST(-0.026176963001490), FRAC_CONST(0.999657332897186) },
+ { FRAC_CONST(-0.039259877055883), FRAC_CONST(0.999229013919830) },
+ { FRAC_CONST(-0.052336059510708), FRAC_CONST(0.998629510402679) },
+ { FRAC_CONST(-0.065403163433075), FRAC_CONST(0.997858941555023) },
+ { FRAC_CONST(-0.078459173440933), FRAC_CONST(0.996917307376862) },
+ { FRAC_CONST(-0.091501623392105), FRAC_CONST(0.995804905891418) },
+ { FRAC_CONST(-0.104528509080410), FRAC_CONST(0.994521915912628) },
+ { FRAC_CONST(-0.117537491023541), FRAC_CONST(0.993068456649780) },
+ { FRAC_CONST(-0.130526214838028), FRAC_CONST(0.991444885730743) },
+ { FRAC_CONST(-0.143492683768272), FRAC_CONST(0.989651381969452) },
+ { FRAC_CONST(-0.156434446573257), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(-0.169349536299706), FRAC_CONST(0.985556066036224) },
+ { FRAC_CONST(-0.182235598564148), FRAC_CONST(0.983254909515381) },
+ { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) },
+ { FRAC_CONST(-0.207911744713783), FRAC_CONST(0.978147566318512) },
+ { FRAC_CONST(-0.220697522163391), FRAC_CONST(0.975342273712158) },
+ { FRAC_CONST(-0.233445391058922), FRAC_CONST(0.972369909286499) },
+ { FRAC_CONST(-0.246153354644775), FRAC_CONST(0.969230890274048) },
+ { FRAC_CONST(-0.258819162845612), FRAC_CONST(0.965925812721252) },
+ { FRAC_CONST(-0.271440476179123), FRAC_CONST(0.962455213069916) },
+ { FRAC_CONST(-0.284015417098999), FRAC_CONST(0.958819687366486) },
+ { FRAC_CONST(-0.296541571617126), FRAC_CONST(0.955019950866699) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.321439564228058), FRAC_CONST(0.946930110454559) },
+ { FRAC_CONST(-0.333806872367859), FRAC_CONST(0.942641496658325) },
+ { FRAC_CONST(-0.346117109060287), FRAC_CONST(0.938191294670105) },
+ { FRAC_CONST(-0.358367949724197), FRAC_CONST(0.933580458164215) },
+ { FRAC_CONST(-0.370557487010956), FRAC_CONST(0.928809523582459) },
+ { FRAC_CONST(-0.382683515548706), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(-0.394743859767914), FRAC_CONST(0.918791234493256) },
+ { FRAC_CONST(-0.406736701726913), FRAC_CONST(0.913545429706573) },
+ { FRAC_CONST(-0.418659836053848), FRAC_CONST(0.908143103122711) },
+ { FRAC_CONST(-0.430511116981506), FRAC_CONST(0.902585268020630) },
+ { FRAC_CONST(-0.442288637161255), FRAC_CONST(0.896872758865356) },
+ { FRAC_CONST(-0.453990608453751), FRAC_CONST(0.891006469726563) },
+ { FRAC_CONST(-0.465614557266235), FRAC_CONST(0.884987592697144) },
+ { FRAC_CONST(-0.477158725261688), FRAC_CONST(0.878817141056061) },
+ { FRAC_CONST(-0.488621354103088), FRAC_CONST(0.872495949268341) },
+ { FRAC_CONST(-0.500000059604645), FRAC_CONST(0.866025388240814) },
+ { FRAC_CONST(-0.511293053627014), FRAC_CONST(0.859406411647797) },
+ { FRAC_CONST(-0.522498667240143), FRAC_CONST(0.852640092372894) },
+ { FRAC_CONST(-0.533614575862885), FRAC_CONST(0.845727801322937) },
+ { FRAC_CONST(-0.544639050960541), FRAC_CONST(0.838670551776886) },
+ { FRAC_CONST(-0.555570363998413), FRAC_CONST(0.831469535827637) },
+ { FRAC_CONST(-0.566406309604645), FRAC_CONST(0.824126124382019) },
+ { FRAC_CONST(-0.577145218849182), FRAC_CONST(0.816641569137573) },
+ { FRAC_CONST(-0.587785184383392), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(-0.598324656486511), FRAC_CONST(0.801253736019135) },
+ { FRAC_CONST(-0.608761429786682), FRAC_CONST(0.793353319168091) },
+ { FRAC_CONST(-0.619093894958496), FRAC_CONST(0.785316944122314) },
+ { FRAC_CONST(-0.629320502281189), FRAC_CONST(0.777145862579346) },
+ { FRAC_CONST(-0.639439046382904), FRAC_CONST(0.768841803073883) },
+ { FRAC_CONST(-0.649448037147522), FRAC_CONST(0.760405957698822) },
+ { FRAC_CONST(-0.659345924854279), FRAC_CONST(0.751839697360992) },
+ { FRAC_CONST(-0.669130682945251), FRAC_CONST(0.743144810199738) },
+ { FRAC_CONST(-0.678800761699677), FRAC_CONST(0.734322488307953) },
+ { FRAC_CONST(-0.688354671001434), FRAC_CONST(0.725374281406403) },
+ { FRAC_CONST(-0.697790503501892), FRAC_CONST(0.716301858425140) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.716302037239075), FRAC_CONST(0.697790324687958) },
+ { FRAC_CONST(-0.725374460220337), FRAC_CONST(0.688354492187500) },
+ { FRAC_CONST(-0.734322547912598), FRAC_CONST(0.678800702095032) },
+ { FRAC_CONST(-0.743144929409027), FRAC_CONST(0.669130444526672) },
+ { FRAC_CONST(-0.751839876174927), FRAC_CONST(0.659345746040344) },
+ { FRAC_CONST(-0.760406017303467), FRAC_CONST(0.649448037147522) },
+ { FRAC_CONST(-0.768841803073883), FRAC_CONST(0.639439046382904) },
+ { FRAC_CONST(-0.777146041393280), FRAC_CONST(0.629320263862610) },
+ { FRAC_CONST(-0.785316944122314), FRAC_CONST(0.619093894958496) },
+ { FRAC_CONST(-0.793353319168091), FRAC_CONST(0.608761429786682) },
+ { FRAC_CONST(-0.801253914833069), FRAC_CONST(0.598324477672577) },
+ { FRAC_CONST(-0.809017062187195), FRAC_CONST(0.587785184383392) },
+ { FRAC_CONST(-0.816641569137573), FRAC_CONST(0.577145218849182) },
+ { FRAC_CONST(-0.824126303195953), FRAC_CONST(0.566406130790710) },
+ { FRAC_CONST(-0.831469655036926), FRAC_CONST(0.555570185184479) },
+ { FRAC_CONST(-0.838670551776886), FRAC_CONST(0.544639050960541) },
+ { FRAC_CONST(-0.845727920532227), FRAC_CONST(0.533614337444305) },
+ { FRAC_CONST(-0.852640211582184), FRAC_CONST(0.522498488426209) },
+ { FRAC_CONST(-0.859406411647797), FRAC_CONST(0.511293053627014) },
+ { FRAC_CONST(-0.866025388240814), FRAC_CONST(0.500000059604645) },
+ { FRAC_CONST(-0.872496068477631), FRAC_CONST(0.488621145486832) },
+ { FRAC_CONST(-0.878817141056061), FRAC_CONST(0.477158725261688) },
+ { FRAC_CONST(-0.884987652301788), FRAC_CONST(0.465614557266235) },
+ { FRAC_CONST(-0.891006588935852), FRAC_CONST(0.453990370035172) },
+ { FRAC_CONST(-0.896872758865356), FRAC_CONST(0.442288637161255) },
+ { FRAC_CONST(-0.902585268020630), FRAC_CONST(0.430511116981506) },
+ { FRAC_CONST(-0.908143222332001), FRAC_CONST(0.418659597635269) },
+ { FRAC_CONST(-0.913545489311218), FRAC_CONST(0.406736582517624) },
+ { FRAC_CONST(-0.918791234493256), FRAC_CONST(0.394743859767914) },
+ { FRAC_CONST(-0.923879623413086), FRAC_CONST(0.382683277130127) },
+ { FRAC_CONST(-0.928809583187103), FRAC_CONST(0.370557337999344) },
+ { FRAC_CONST(-0.933580458164215), FRAC_CONST(0.358367919921875) },
+ { FRAC_CONST(-0.938191413879395), FRAC_CONST(0.346116900444031) },
+ { FRAC_CONST(-0.942641556262970), FRAC_CONST(0.333806753158569) },
+ { FRAC_CONST(-0.946930170059204), FRAC_CONST(0.321439445018768) },
+ { FRAC_CONST(-0.951056599617004), FRAC_CONST(0.309016793966293) },
+ { FRAC_CONST(-0.955020010471344), FRAC_CONST(0.296541452407837) },
+ { FRAC_CONST(-0.958819746971130), FRAC_CONST(0.284015297889709) },
+ { FRAC_CONST(-0.962455213069916), FRAC_CONST(0.271440476179123) },
+ { FRAC_CONST(-0.965925872325897), FRAC_CONST(0.258818924427032) },
+ { FRAC_CONST(-0.969230949878693), FRAC_CONST(0.246153235435486) },
+ { FRAC_CONST(-0.972369909286499), FRAC_CONST(0.233445376157761) },
+ { FRAC_CONST(-0.975342333316803), FRAC_CONST(0.220697283744812) },
+ { FRAC_CONST(-0.978147625923157), FRAC_CONST(0.207911610603333) },
+ { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) },
+ { FRAC_CONST(-0.983254909515381), FRAC_CONST(0.182235360145569) },
+ { FRAC_CONST(-0.985556066036224), FRAC_CONST(0.169349402189255) },
+ { FRAC_CONST(-0.987688362598419), FRAC_CONST(0.156434446573257) },
+ { FRAC_CONST(-0.989651441574097), FRAC_CONST(0.143492430448532) },
+ { FRAC_CONST(-0.991444885730743), FRAC_CONST(0.130526080727577) },
+ { FRAC_CONST(-0.993068456649780), FRAC_CONST(0.117537356913090) },
+ { FRAC_CONST(-0.994521915912628), FRAC_CONST(0.104528494179249) },
+ { FRAC_CONST(-0.995804965496063), FRAC_CONST(0.091501489281654) },
+ { FRAC_CONST(-0.996917366981506), FRAC_CONST(0.078459039330482) },
+ { FRAC_CONST(-0.997858941555023), FRAC_CONST(0.065403148531914) },
+ { FRAC_CONST(-0.998629570007324), FRAC_CONST(0.052335809916258) },
+ { FRAC_CONST(-0.999229013919830), FRAC_CONST(0.039259742945433) },
+ { FRAC_CONST(-0.999657332897186), FRAC_CONST(0.026176951825619) },
+ { FRAC_CONST(-0.999914348125458), FRAC_CONST(0.013089434243739) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.999657332897186), FRAC_CONST(0.026176949962974) },
+ { FRAC_CONST(0.998629510402679), FRAC_CONST(0.052335958927870) },
+ { FRAC_CONST(0.996917307376862), FRAC_CONST(0.078459098935127) },
+ { FRAC_CONST(0.994521915912628), FRAC_CONST(0.104528464376926) },
+ { FRAC_CONST(0.991444885730743), FRAC_CONST(0.130526199936867) },
+ { FRAC_CONST(0.987688362598419), FRAC_CONST(0.156434476375580) },
+ { FRAC_CONST(0.983254909515381), FRAC_CONST(0.182235524058342) },
+ { FRAC_CONST(0.978147625923157), FRAC_CONST(0.207911700010300) },
+ { FRAC_CONST(0.972369909286499), FRAC_CONST(0.233445376157761) },
+ { FRAC_CONST(0.965925812721252), FRAC_CONST(0.258819043636322) },
+ { FRAC_CONST(0.958819746971130), FRAC_CONST(0.284015357494354) },
+ { FRAC_CONST(0.951056540012360), FRAC_CONST(0.309017002582550) },
+ { FRAC_CONST(0.942641496658325), FRAC_CONST(0.333806872367859) },
+ { FRAC_CONST(0.933580398559570), FRAC_CONST(0.358367949724197) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.913545429706573), FRAC_CONST(0.406736642122269) },
+ { FRAC_CONST(0.902585268020630), FRAC_CONST(0.430511116981506) },
+ { FRAC_CONST(0.891006529331207), FRAC_CONST(0.453990519046783) },
+ { FRAC_CONST(0.878817081451416), FRAC_CONST(0.477158784866333) },
+ { FRAC_CONST(0.866025388240814), FRAC_CONST(0.500000000000000) },
+ { FRAC_CONST(0.852640151977539), FRAC_CONST(0.522498548030853) },
+ { FRAC_CONST(0.838670551776886), FRAC_CONST(0.544639050960541) },
+ { FRAC_CONST(0.824126183986664), FRAC_CONST(0.566406250000000) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.793353319168091), FRAC_CONST(0.608761429786682) },
+ { FRAC_CONST(0.777145922183990), FRAC_CONST(0.629320383071899) },
+ { FRAC_CONST(0.760405957698822), FRAC_CONST(0.649448096752167) },
+ { FRAC_CONST(0.743144810199738), FRAC_CONST(0.669130623340607) },
+ { FRAC_CONST(0.725374400615692), FRAC_CONST(0.688354551792145) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.688354551792145), FRAC_CONST(0.725374400615692) },
+ { FRAC_CONST(0.669130563735962), FRAC_CONST(0.743144869804382) },
+ { FRAC_CONST(0.649448037147522), FRAC_CONST(0.760405957698822) },
+ { FRAC_CONST(0.629320383071899), FRAC_CONST(0.777145981788635) },
+ { FRAC_CONST(0.608761370182037), FRAC_CONST(0.793353378772736) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(0.566406250000000), FRAC_CONST(0.824126183986664) },
+ { FRAC_CONST(0.544638991355896), FRAC_CONST(0.838670611381531) },
+ { FRAC_CONST(0.522498488426209), FRAC_CONST(0.852640211582184) },
+ { FRAC_CONST(0.499999970197678), FRAC_CONST(0.866025447845459) },
+ { FRAC_CONST(0.477158755064011), FRAC_CONST(0.878817141056061) },
+ { FRAC_CONST(0.453990519046783), FRAC_CONST(0.891006529331207) },
+ { FRAC_CONST(0.430511027574539), FRAC_CONST(0.902585327625275) },
+ { FRAC_CONST(0.406736612319946), FRAC_CONST(0.913545489311218) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.358367860317230), FRAC_CONST(0.933580458164215) },
+ { FRAC_CONST(0.333806812763214), FRAC_CONST(0.942641496658325) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(0.284015327692032), FRAC_CONST(0.958819746971130) },
+ { FRAC_CONST(0.258819073438644), FRAC_CONST(0.965925812721252) },
+ { FRAC_CONST(0.233445301651955), FRAC_CONST(0.972369909286499) },
+ { FRAC_CONST(0.207911655306816), FRAC_CONST(0.978147625923157) },
+ { FRAC_CONST(0.182235524058342), FRAC_CONST(0.983254909515381) },
+ { FRAC_CONST(0.156434372067451), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(0.130526125431061), FRAC_CONST(0.991444885730743) },
+ { FRAC_CONST(0.104528419673443), FRAC_CONST(0.994521915912628) },
+ { FRAC_CONST(0.078459084033966), FRAC_CONST(0.996917307376862) },
+ { FRAC_CONST(0.052335973829031), FRAC_CONST(0.998629510402679) },
+ { FRAC_CONST(0.026176875457168), FRAC_CONST(0.999657332897186) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.026176963001490), FRAC_CONST(0.999657332897186) },
+ { FRAC_CONST(-0.052336059510708), FRAC_CONST(0.998629510402679) },
+ { FRAC_CONST(-0.078459173440933), FRAC_CONST(0.996917307376862) },
+ { FRAC_CONST(-0.104528509080410), FRAC_CONST(0.994521915912628) },
+ { FRAC_CONST(-0.130526214838028), FRAC_CONST(0.991444885730743) },
+ { FRAC_CONST(-0.156434446573257), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(-0.182235598564148), FRAC_CONST(0.983254909515381) },
+ { FRAC_CONST(-0.207911744713783), FRAC_CONST(0.978147566318512) },
+ { FRAC_CONST(-0.233445391058922), FRAC_CONST(0.972369909286499) },
+ { FRAC_CONST(-0.258819162845612), FRAC_CONST(0.965925812721252) },
+ { FRAC_CONST(-0.284015417098999), FRAC_CONST(0.958819687366486) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.333806872367859), FRAC_CONST(0.942641496658325) },
+ { FRAC_CONST(-0.358367949724197), FRAC_CONST(0.933580458164215) },
+ { FRAC_CONST(-0.382683515548706), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(-0.406736701726913), FRAC_CONST(0.913545429706573) },
+ { FRAC_CONST(-0.430511116981506), FRAC_CONST(0.902585268020630) },
+ { FRAC_CONST(-0.453990608453751), FRAC_CONST(0.891006469726563) },
+ { FRAC_CONST(-0.477158725261688), FRAC_CONST(0.878817141056061) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.998629510402679), FRAC_CONST(0.052335958927870) },
+ { FRAC_CONST(0.994521915912628), FRAC_CONST(0.104528464376926) },
+ { FRAC_CONST(0.987688362598419), FRAC_CONST(0.156434476375580) },
+ { FRAC_CONST(0.978147625923157), FRAC_CONST(0.207911700010300) },
+ { FRAC_CONST(0.965925812721252), FRAC_CONST(0.258819043636322) },
+ { FRAC_CONST(0.951056540012360), FRAC_CONST(0.309017002582550) },
+ { FRAC_CONST(0.933580398559570), FRAC_CONST(0.358367949724197) },
+ { FRAC_CONST(0.913545429706573), FRAC_CONST(0.406736642122269) },
+ { FRAC_CONST(0.891006529331207), FRAC_CONST(0.453990519046783) },
+ { FRAC_CONST(0.866025388240814), FRAC_CONST(0.500000000000000) },
+ { FRAC_CONST(0.838670551776886), FRAC_CONST(0.544639050960541) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.777145922183990), FRAC_CONST(0.629320383071899) },
+ { FRAC_CONST(0.743144810199738), FRAC_CONST(0.669130623340607) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.669130563735962), FRAC_CONST(0.743144869804382) },
+ { FRAC_CONST(0.629320383071899), FRAC_CONST(0.777145981788635) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(0.544638991355896), FRAC_CONST(0.838670611381531) },
+ { FRAC_CONST(0.499999970197678), FRAC_CONST(0.866025447845459) },
+ { FRAC_CONST(0.453990519046783), FRAC_CONST(0.891006529331207) },
+ { FRAC_CONST(0.406736612319946), FRAC_CONST(0.913545489311218) },
+ { FRAC_CONST(0.358367860317230), FRAC_CONST(0.933580458164215) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(0.258819073438644), FRAC_CONST(0.965925812721252) },
+ { FRAC_CONST(0.207911655306816), FRAC_CONST(0.978147625923157) },
+ { FRAC_CONST(0.156434372067451), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(0.104528419673443), FRAC_CONST(0.994521915912628) },
+ { FRAC_CONST(0.052335973829031), FRAC_CONST(0.998629510402679) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.052336059510708), FRAC_CONST(0.998629510402679) },
+ { FRAC_CONST(-0.104528509080410), FRAC_CONST(0.994521915912628) },
+ { FRAC_CONST(-0.156434446573257), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(-0.207911744713783), FRAC_CONST(0.978147566318512) },
+ { FRAC_CONST(-0.258819162845612), FRAC_CONST(0.965925812721252) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.358367949724197), FRAC_CONST(0.933580458164215) },
+ { FRAC_CONST(-0.406736701726913), FRAC_CONST(0.913545429706573) },
+ { FRAC_CONST(-0.453990608453751), FRAC_CONST(0.891006469726563) },
+ { FRAC_CONST(-0.500000059604645), FRAC_CONST(0.866025388240814) },
+ { FRAC_CONST(-0.544639050960541), FRAC_CONST(0.838670551776886) },
+ { FRAC_CONST(-0.587785184383392), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(-0.629320502281189), FRAC_CONST(0.777145862579346) },
+ { FRAC_CONST(-0.669130682945251), FRAC_CONST(0.743144810199738) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.743144929409027), FRAC_CONST(0.669130444526672) },
+ { FRAC_CONST(-0.777146041393280), FRAC_CONST(0.629320263862610) },
+ { FRAC_CONST(-0.809017062187195), FRAC_CONST(0.587785184383392) },
+ { FRAC_CONST(-0.838670551776886), FRAC_CONST(0.544639050960541) },
+ { FRAC_CONST(-0.866025388240814), FRAC_CONST(0.500000059604645) },
+ { FRAC_CONST(-0.891006588935852), FRAC_CONST(0.453990370035172) },
+ { FRAC_CONST(-0.913545489311218), FRAC_CONST(0.406736582517624) },
+ { FRAC_CONST(-0.933580458164215), FRAC_CONST(0.358367919921875) },
+ { FRAC_CONST(-0.951056599617004), FRAC_CONST(0.309016793966293) },
+ { FRAC_CONST(-0.965925872325897), FRAC_CONST(0.258818924427032) },
+ { FRAC_CONST(-0.978147625923157), FRAC_CONST(0.207911610603333) },
+ { FRAC_CONST(-0.987688362598419), FRAC_CONST(0.156434446573257) },
+ { FRAC_CONST(-0.994521915912628), FRAC_CONST(0.104528494179249) },
+ { FRAC_CONST(-0.998629570007324), FRAC_CONST(0.052335809916258) },
+ { FRAC_CONST(-1.000000000000000), FRAC_CONST(-0.000000087422777) },
+ { FRAC_CONST(-0.998629510402679), FRAC_CONST(-0.052335985004902) },
+ { FRAC_CONST(-0.994521856307983), FRAC_CONST(-0.104528672993183) },
+ { FRAC_CONST(-0.987688302993774), FRAC_CONST(-0.156434610486031) },
+ { FRAC_CONST(-0.978147566318512), FRAC_CONST(-0.207911789417267) },
+ { FRAC_CONST(-0.965925812721252), FRAC_CONST(-0.258819073438644) },
+ { FRAC_CONST(-0.951056540012360), FRAC_CONST(-0.309016972780228) },
+ { FRAC_CONST(-0.933580398559570), FRAC_CONST(-0.358368098735809) },
+ { FRAC_CONST(-0.913545429706573), FRAC_CONST(-0.406736731529236) },
+ { FRAC_CONST(-0.891006529331207), FRAC_CONST(-0.453990548849106) },
+ { FRAC_CONST(-0.866025269031525), FRAC_CONST(-0.500000178813934) },
+ { FRAC_CONST(-0.838670492172241), FRAC_CONST(-0.544639170169830) },
+ { FRAC_CONST(-0.809016942977905), FRAC_CONST(-0.587785363197327) },
+ { FRAC_CONST(-0.777145922183990), FRAC_CONST(-0.629320442676544) },
+ { FRAC_CONST(-0.743144810199738), FRAC_CONST(-0.669130623340607) },
+ { FRAC_CONST(-0.707106649875641), FRAC_CONST(-0.707106888294220) },
+ { FRAC_CONST(-0.669130504131317), FRAC_CONST(-0.743144869804382) },
+ { FRAC_CONST(-0.629320323467255), FRAC_CONST(-0.777145981788635) },
+ { FRAC_CONST(-0.587785065174103), FRAC_CONST(-0.809017121791840) },
+ { FRAC_CONST(-0.544639110565186), FRAC_CONST(-0.838670551776886) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.996917307376862), FRAC_CONST(0.078459098935127) },
+ { FRAC_CONST(0.987688362598419), FRAC_CONST(0.156434476375580) },
+ { FRAC_CONST(0.972369909286499), FRAC_CONST(0.233445376157761) },
+ { FRAC_CONST(0.951056540012360), FRAC_CONST(0.309017002582550) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.891006529331207), FRAC_CONST(0.453990519046783) },
+ { FRAC_CONST(0.852640151977539), FRAC_CONST(0.522498548030853) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.760405957698822), FRAC_CONST(0.649448096752167) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.649448037147522), FRAC_CONST(0.760405957698822) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(0.522498488426209), FRAC_CONST(0.852640211582184) },
+ { FRAC_CONST(0.453990519046783), FRAC_CONST(0.891006529331207) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(0.233445301651955), FRAC_CONST(0.972369909286499) },
+ { FRAC_CONST(0.156434372067451), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(0.078459084033966), FRAC_CONST(0.996917307376862) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.987688362598419), FRAC_CONST(0.156434476375580) },
+ { FRAC_CONST(0.951056540012360), FRAC_CONST(0.309017002582550) },
+ { FRAC_CONST(0.891006529331207), FRAC_CONST(0.453990519046783) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(0.453990519046783), FRAC_CONST(0.891006529331207) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(0.156434372067451), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.156434446573257), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.453990608453751), FRAC_CONST(0.891006469726563) },
+ { FRAC_CONST(-0.587785184383392), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.809017062187195), FRAC_CONST(0.587785184383392) },
+ { FRAC_CONST(-0.891006588935852), FRAC_CONST(0.453990370035172) },
+ { FRAC_CONST(-0.951056599617004), FRAC_CONST(0.309016793966293) },
+ { FRAC_CONST(-0.987688362598419), FRAC_CONST(0.156434446573257) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.972369909286499), FRAC_CONST(0.233445376157761) },
+ { FRAC_CONST(0.891006529331207), FRAC_CONST(0.453990519046783) },
+ { FRAC_CONST(0.760405957698822), FRAC_CONST(0.649448096752167) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.156434372067451), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(-0.078459173440933), FRAC_CONST(0.996917307376862) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.522498667240143), FRAC_CONST(0.852640092372894) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.852640211582184), FRAC_CONST(0.522498488426209) },
+ { FRAC_CONST(-0.951056599617004), FRAC_CONST(0.309016793966293) },
+ { FRAC_CONST(-0.996917366981506), FRAC_CONST(0.078459039330482) },
+ { FRAC_CONST(-0.987688302993774), FRAC_CONST(-0.156434610486031) },
+ { FRAC_CONST(-0.923879504203796), FRAC_CONST(-0.382683426141739) },
+ { FRAC_CONST(-0.809016942977905), FRAC_CONST(-0.587785363197327) },
+ { FRAC_CONST(-0.649447917938232), FRAC_CONST(-0.760406076908112) },
+ { FRAC_CONST(-0.453990221023560), FRAC_CONST(-0.891006648540497) },
+ { FRAC_CONST(-0.233445450663567), FRAC_CONST(-0.972369909286499) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.951056540012360), FRAC_CONST(0.309017002582550) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.809017062187195), FRAC_CONST(0.587785184383392) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.951056599617004), FRAC_CONST(0.309016793966293) },
+ { FRAC_CONST(-0.809016942977905), FRAC_CONST(-0.587785363197327) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.309017121791840), FRAC_CONST(-0.951056480407715) }
+ };
+#endif
+
+ ALIGN static const complex_t cfft_tab_64[] = {
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.995184719562531), FRAC_CONST(0.098017141222954) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.881921231746674), FRAC_CONST(0.471396744251251) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.773010432720184), FRAC_CONST(0.634393334388733) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.471396654844284), FRAC_CONST(0.881921291351318) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.290284633636475), FRAC_CONST(0.956940352916718) },
+ { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) },
+ { FRAC_CONST(-0.382683515548706), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(-0.555570363998413), FRAC_CONST(0.831469535827637) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.831469655036926), FRAC_CONST(0.555570185184479) },
+ { FRAC_CONST(-0.923879623413086), FRAC_CONST(0.382683277130127) },
+ { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) },
+ { FRAC_CONST(-0.471396833658218), FRAC_CONST(0.881921231746674) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.881921231746674), FRAC_CONST(0.471396833658218) },
+ { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) },
+ { FRAC_CONST(-0.995184719562531), FRAC_CONST(-0.098017267882824) },
+ { FRAC_CONST(-0.923879504203796), FRAC_CONST(-0.382683426141739) },
+ { FRAC_CONST(-0.773010551929474), FRAC_CONST(-0.634393215179443) },
+ { FRAC_CONST(-0.555570006370544), FRAC_CONST(-0.831469774246216) },
+ { FRAC_CONST(-0.290284544229507), FRAC_CONST(-0.956940352916718) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.923879504203796), FRAC_CONST(-0.382683426141739) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.000000011924881), FRAC_CONST(-1.000000000000000) }
+ };
+
+#ifdef ALLOW_SMALL_FRAMELENGTH
+ ALIGN static const complex_t cfft_tab_60[] = {
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.994521915912628), FRAC_CONST(0.104528464376926) },
+ { FRAC_CONST(0.978147625923157), FRAC_CONST(0.207911700010300) },
+ { FRAC_CONST(0.951056540012360), FRAC_CONST(0.309017002582550) },
+ { FRAC_CONST(0.913545429706573), FRAC_CONST(0.406736642122269) },
+ { FRAC_CONST(0.866025388240814), FRAC_CONST(0.500000000000000) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.743144810199738), FRAC_CONST(0.669130623340607) },
+ { FRAC_CONST(0.669130563735962), FRAC_CONST(0.743144869804382) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(0.499999970197678), FRAC_CONST(0.866025447845459) },
+ { FRAC_CONST(0.406736612319946), FRAC_CONST(0.913545489311218) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(0.207911655306816), FRAC_CONST(0.978147625923157) },
+ { FRAC_CONST(0.104528419673443), FRAC_CONST(0.994521915912628) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.104528509080410), FRAC_CONST(0.994521915912628) },
+ { FRAC_CONST(-0.207911744713783), FRAC_CONST(0.978147566318512) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.406736701726913), FRAC_CONST(0.913545429706573) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.978147625923157), FRAC_CONST(0.207911700010300) },
+ { FRAC_CONST(0.913545429706573), FRAC_CONST(0.406736642122269) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.669130563735962), FRAC_CONST(0.743144869804382) },
+ { FRAC_CONST(0.499999970197678), FRAC_CONST(0.866025447845459) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(0.104528419673443), FRAC_CONST(0.994521915912628) },
+ { FRAC_CONST(-0.104528509080410), FRAC_CONST(0.994521915912628) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.500000059604645), FRAC_CONST(0.866025388240814) },
+ { FRAC_CONST(-0.669130682945251), FRAC_CONST(0.743144810199738) },
+ { FRAC_CONST(-0.809017062187195), FRAC_CONST(0.587785184383392) },
+ { FRAC_CONST(-0.913545489311218), FRAC_CONST(0.406736582517624) },
+ { FRAC_CONST(-0.978147625923157), FRAC_CONST(0.207911610603333) },
+ { FRAC_CONST(-1.000000000000000), FRAC_CONST(-0.000000087422777) },
+ { FRAC_CONST(-0.978147566318512), FRAC_CONST(-0.207911789417267) },
+ { FRAC_CONST(-0.913545429706573), FRAC_CONST(-0.406736731529236) },
+ { FRAC_CONST(-0.809016942977905), FRAC_CONST(-0.587785363197327) },
+ { FRAC_CONST(-0.669130504131317), FRAC_CONST(-0.743144869804382) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.951056540012360), FRAC_CONST(0.309017002582550) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.809017062187195), FRAC_CONST(0.587785184383392) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.951056599617004), FRAC_CONST(0.309016793966293) },
+ { FRAC_CONST(-0.809016942977905), FRAC_CONST(-0.587785363197327) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.309017121791840), FRAC_CONST(-0.951056480407715) }
+ };
+#endif
+
+#ifdef LD_DEC
+
+ ALIGN static const complex_t cfft_tab_256[] = {
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.999698817729950), FRAC_CONST(0.024541229009628) },
+ { FRAC_CONST(0.998795449733734), FRAC_CONST(0.049067676067352) },
+ { FRAC_CONST(0.997290432453156), FRAC_CONST(0.073564566671848) },
+ { FRAC_CONST(0.995184719562531), FRAC_CONST(0.098017141222954) },
+ { FRAC_CONST(0.992479562759399), FRAC_CONST(0.122410677373409) },
+ { FRAC_CONST(0.989176511764526), FRAC_CONST(0.146730467677116) },
+ { FRAC_CONST(0.985277652740479), FRAC_CONST(0.170961901545525) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.975702106952667), FRAC_CONST(0.219101235270500) },
+ { FRAC_CONST(0.970031261444092), FRAC_CONST(0.242980197072029) },
+ { FRAC_CONST(0.963776051998138), FRAC_CONST(0.266712784767151) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.949528157711029), FRAC_CONST(0.313681751489639) },
+ { FRAC_CONST(0.941544055938721), FRAC_CONST(0.336889863014221) },
+ { FRAC_CONST(0.932992815971375), FRAC_CONST(0.359895050525665) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.914209723472595), FRAC_CONST(0.405241340398788) },
+ { FRAC_CONST(0.903989315032959), FRAC_CONST(0.427555084228516) },
+ { FRAC_CONST(0.893224298954010), FRAC_CONST(0.449611335992813) },
+ { FRAC_CONST(0.881921231746674), FRAC_CONST(0.471396744251251) },
+ { FRAC_CONST(0.870086967945099), FRAC_CONST(0.492898225784302) },
+ { FRAC_CONST(0.857728600502014), FRAC_CONST(0.514102756977081) },
+ { FRAC_CONST(0.844853579998016), FRAC_CONST(0.534997642040253) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.817584812641144), FRAC_CONST(0.575808227062225) },
+ { FRAC_CONST(0.803207516670227), FRAC_CONST(0.595699310302734) },
+ { FRAC_CONST(0.788346409797668), FRAC_CONST(0.615231633186340) },
+ { FRAC_CONST(0.773010432720184), FRAC_CONST(0.634393334388733) },
+ { FRAC_CONST(0.757208824157715), FRAC_CONST(0.653172850608826) },
+ { FRAC_CONST(0.740951120853424), FRAC_CONST(0.671558976173401) },
+ { FRAC_CONST(0.724247097969055), FRAC_CONST(0.689540565013886) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.689540505409241), FRAC_CONST(0.724247097969055) },
+ { FRAC_CONST(0.671558916568756), FRAC_CONST(0.740951180458069) },
+ { FRAC_CONST(0.653172791004181), FRAC_CONST(0.757208883762360) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.615231573581696), FRAC_CONST(0.788346409797668) },
+ { FRAC_CONST(0.595699310302734), FRAC_CONST(0.803207516670227) },
+ { FRAC_CONST(0.575808167457581), FRAC_CONST(0.817584812641144) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.534997642040253), FRAC_CONST(0.844853579998016) },
+ { FRAC_CONST(0.514102697372437), FRAC_CONST(0.857728660106659) },
+ { FRAC_CONST(0.492898195981979), FRAC_CONST(0.870086967945099) },
+ { FRAC_CONST(0.471396654844284), FRAC_CONST(0.881921291351318) },
+ { FRAC_CONST(0.449611306190491), FRAC_CONST(0.893224298954010) },
+ { FRAC_CONST(0.427555114030838), FRAC_CONST(0.903989315032959) },
+ { FRAC_CONST(0.405241280794144), FRAC_CONST(0.914209783077240) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.359894961118698), FRAC_CONST(0.932992815971375) },
+ { FRAC_CONST(0.336889833211899), FRAC_CONST(0.941544055938721) },
+ { FRAC_CONST(0.313681662082672), FRAC_CONST(0.949528217315674) },
+ { FRAC_CONST(0.290284633636475), FRAC_CONST(0.956940352916718) },
+ { FRAC_CONST(0.266712754964828), FRAC_CONST(0.963776051998138) },
+ { FRAC_CONST(0.242980122566223), FRAC_CONST(0.970031261444092) },
+ { FRAC_CONST(0.219101220369339), FRAC_CONST(0.975702106952667) },
+ { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) },
+ { FRAC_CONST(0.170961856842041), FRAC_CONST(0.985277652740479) },
+ { FRAC_CONST(0.146730497479439), FRAC_CONST(0.989176511764526) },
+ { FRAC_CONST(0.122410625219345), FRAC_CONST(0.992479562759399) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(0.073564492166042), FRAC_CONST(0.997290432453156) },
+ { FRAC_CONST(0.049067649990320), FRAC_CONST(0.998795449733734) },
+ { FRAC_CONST(0.024541135877371), FRAC_CONST(0.999698817729950) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.998795449733734), FRAC_CONST(0.049067676067352) },
+ { FRAC_CONST(0.995184719562531), FRAC_CONST(0.098017141222954) },
+ { FRAC_CONST(0.989176511764526), FRAC_CONST(0.146730467677116) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.970031261444092), FRAC_CONST(0.242980197072029) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.941544055938721), FRAC_CONST(0.336889863014221) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.903989315032959), FRAC_CONST(0.427555084228516) },
+ { FRAC_CONST(0.881921231746674), FRAC_CONST(0.471396744251251) },
+ { FRAC_CONST(0.857728600502014), FRAC_CONST(0.514102756977081) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.803207516670227), FRAC_CONST(0.595699310302734) },
+ { FRAC_CONST(0.773010432720184), FRAC_CONST(0.634393334388733) },
+ { FRAC_CONST(0.740951120853424), FRAC_CONST(0.671558976173401) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.671558916568756), FRAC_CONST(0.740951180458069) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.595699310302734), FRAC_CONST(0.803207516670227) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.514102697372437), FRAC_CONST(0.857728660106659) },
+ { FRAC_CONST(0.471396654844284), FRAC_CONST(0.881921291351318) },
+ { FRAC_CONST(0.427555114030838), FRAC_CONST(0.903989315032959) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.336889833211899), FRAC_CONST(0.941544055938721) },
+ { FRAC_CONST(0.290284633636475), FRAC_CONST(0.956940352916718) },
+ { FRAC_CONST(0.242980122566223), FRAC_CONST(0.970031261444092) },
+ { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) },
+ { FRAC_CONST(0.146730497479439), FRAC_CONST(0.989176511764526) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(0.049067649990320), FRAC_CONST(0.998795449733734) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.049067739397287), FRAC_CONST(0.998795449733734) },
+ { FRAC_CONST(-0.098017223179340), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(-0.146730571985245), FRAC_CONST(0.989176511764526) },
+ { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) },
+ { FRAC_CONST(-0.242980197072029), FRAC_CONST(0.970031261444092) },
+ { FRAC_CONST(-0.290284723043442), FRAC_CONST(0.956940293312073) },
+ { FRAC_CONST(-0.336889922618866), FRAC_CONST(0.941544055938721) },
+ { FRAC_CONST(-0.382683515548706), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(-0.427555084228516), FRAC_CONST(0.903989315032959) },
+ { FRAC_CONST(-0.471396833658218), FRAC_CONST(0.881921231746674) },
+ { FRAC_CONST(-0.514102756977081), FRAC_CONST(0.857728600502014) },
+ { FRAC_CONST(-0.555570363998413), FRAC_CONST(0.831469535827637) },
+ { FRAC_CONST(-0.595699369907379), FRAC_CONST(0.803207516670227) },
+ { FRAC_CONST(-0.634393274784088), FRAC_CONST(0.773010492324829) },
+ { FRAC_CONST(-0.671559035778046), FRAC_CONST(0.740951061248779) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.740951240062714), FRAC_CONST(0.671558856964111) },
+ { FRAC_CONST(-0.773010492324829), FRAC_CONST(0.634393274784088) },
+ { FRAC_CONST(-0.803207635879517), FRAC_CONST(0.595699131488800) },
+ { FRAC_CONST(-0.831469655036926), FRAC_CONST(0.555570185184479) },
+ { FRAC_CONST(-0.857728600502014), FRAC_CONST(0.514102756977081) },
+ { FRAC_CONST(-0.881921350955963), FRAC_CONST(0.471396625041962) },
+ { FRAC_CONST(-0.903989315032959), FRAC_CONST(0.427555054426193) },
+ { FRAC_CONST(-0.923879623413086), FRAC_CONST(0.382683277130127) },
+ { FRAC_CONST(-0.941544115543365), FRAC_CONST(0.336889803409576) },
+ { FRAC_CONST(-0.956940352916718), FRAC_CONST(0.290284723043442) },
+ { FRAC_CONST(-0.970031261444092), FRAC_CONST(0.242980077862740) },
+ { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) },
+ { FRAC_CONST(-0.989176511764526), FRAC_CONST(0.146730333566666) },
+ { FRAC_CONST(-0.995184719562531), FRAC_CONST(0.098017096519470) },
+ { FRAC_CONST(-0.998795449733734), FRAC_CONST(0.049067486077547) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.997290432453156), FRAC_CONST(0.073564566671848) },
+ { FRAC_CONST(0.989176511764526), FRAC_CONST(0.146730467677116) },
+ { FRAC_CONST(0.975702106952667), FRAC_CONST(0.219101235270500) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.932992815971375), FRAC_CONST(0.359895050525665) },
+ { FRAC_CONST(0.903989315032959), FRAC_CONST(0.427555084228516) },
+ { FRAC_CONST(0.870086967945099), FRAC_CONST(0.492898225784302) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.788346469402313), FRAC_CONST(0.615231573581696) },
+ { FRAC_CONST(0.740951120853424), FRAC_CONST(0.671558976173401) },
+ { FRAC_CONST(0.689540505409241), FRAC_CONST(0.724247097969055) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.575808227062225), FRAC_CONST(0.817584812641144) },
+ { FRAC_CONST(0.514102697372437), FRAC_CONST(0.857728660106659) },
+ { FRAC_CONST(0.449611306190491), FRAC_CONST(0.893224298954010) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.313681751489639), FRAC_CONST(0.949528157711029) },
+ { FRAC_CONST(0.242980241775513), FRAC_CONST(0.970031261444092) },
+ { FRAC_CONST(0.170961856842041), FRAC_CONST(0.985277652740479) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(0.024541255086660), FRAC_CONST(0.999698817729950) },
+ { FRAC_CONST(-0.049067739397287), FRAC_CONST(0.998795449733734) },
+ { FRAC_CONST(-0.122410707175732), FRAC_CONST(0.992479503154755) },
+ { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) },
+ { FRAC_CONST(-0.266712725162506), FRAC_CONST(0.963776051998138) },
+ { FRAC_CONST(-0.336889803409576), FRAC_CONST(0.941544055938721) },
+ { FRAC_CONST(-0.405241340398788), FRAC_CONST(0.914209723472595) },
+ { FRAC_CONST(-0.471396833658218), FRAC_CONST(0.881921231746674) },
+ { FRAC_CONST(-0.534997701644897), FRAC_CONST(0.844853520393372) },
+ { FRAC_CONST(-0.595699369907379), FRAC_CONST(0.803207516670227) },
+ { FRAC_CONST(-0.653172850608826), FRAC_CONST(0.757208824157715) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.757208824157715), FRAC_CONST(0.653172850608826) },
+ { FRAC_CONST(-0.803207516670227), FRAC_CONST(0.595699369907379) },
+ { FRAC_CONST(-0.844853520393372), FRAC_CONST(0.534997701644897) },
+ { FRAC_CONST(-0.881921231746674), FRAC_CONST(0.471396833658218) },
+ { FRAC_CONST(-0.914209783077240), FRAC_CONST(0.405241221189499) },
+ { FRAC_CONST(-0.941544115543365), FRAC_CONST(0.336889803409576) },
+ { FRAC_CONST(-0.963776051998138), FRAC_CONST(0.266712725162506) },
+ { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) },
+ { FRAC_CONST(-0.992479503154755), FRAC_CONST(0.122410699725151) },
+ { FRAC_CONST(-0.998795449733734), FRAC_CONST(0.049067724496126) },
+ { FRAC_CONST(-0.999698817729950), FRAC_CONST(-0.024541147053242) },
+ { FRAC_CONST(-0.995184719562531), FRAC_CONST(-0.098017267882824) },
+ { FRAC_CONST(-0.985277652740479), FRAC_CONST(-0.170961990952492) },
+ { FRAC_CONST(-0.970031261444092), FRAC_CONST(-0.242980241775513) },
+ { FRAC_CONST(-0.949528157711029), FRAC_CONST(-0.313681781291962) },
+ { FRAC_CONST(-0.923879504203796), FRAC_CONST(-0.382683426141739) },
+ { FRAC_CONST(-0.893224298954010), FRAC_CONST(-0.449611306190491) },
+ { FRAC_CONST(-0.857728660106659), FRAC_CONST(-0.514102697372437) },
+ { FRAC_CONST(-0.817584872245789), FRAC_CONST(-0.575808107852936) },
+ { FRAC_CONST(-0.773010551929474), FRAC_CONST(-0.634393215179443) },
+ { FRAC_CONST(-0.724247038364410), FRAC_CONST(-0.689540624618530) },
+ { FRAC_CONST(-0.671558916568756), FRAC_CONST(-0.740951180458069) },
+ { FRAC_CONST(-0.615231573581696), FRAC_CONST(-0.788346469402313) },
+ { FRAC_CONST(-0.555570006370544), FRAC_CONST(-0.831469774246216) },
+ { FRAC_CONST(-0.492898195981979), FRAC_CONST(-0.870086967945099) },
+ { FRAC_CONST(-0.427554935216904), FRAC_CONST(-0.903989374637604) },
+ { FRAC_CONST(-0.359895110130310), FRAC_CONST(-0.932992756366730) },
+ { FRAC_CONST(-0.290284544229507), FRAC_CONST(-0.956940352916718) },
+ { FRAC_CONST(-0.219101369380951), FRAC_CONST(-0.975702106952667) },
+ { FRAC_CONST(-0.146730408072472), FRAC_CONST(-0.989176511764526) },
+ { FRAC_CONST(-0.073564760386944), FRAC_CONST(-0.997290432453156) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.995184719562531), FRAC_CONST(0.098017141222954) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.881921231746674), FRAC_CONST(0.471396744251251) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.773010432720184), FRAC_CONST(0.634393334388733) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.471396654844284), FRAC_CONST(0.881921291351318) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.290284633636475), FRAC_CONST(0.956940352916718) },
+ { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) },
+ { FRAC_CONST(-0.382683515548706), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(-0.555570363998413), FRAC_CONST(0.831469535827637) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.831469655036926), FRAC_CONST(0.555570185184479) },
+ { FRAC_CONST(-0.923879623413086), FRAC_CONST(0.382683277130127) },
+ { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) },
+ { FRAC_CONST(-0.471396833658218), FRAC_CONST(0.881921231746674) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.881921231746674), FRAC_CONST(0.471396833658218) },
+ { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) },
+ { FRAC_CONST(-0.995184719562531), FRAC_CONST(-0.098017267882824) },
+ { FRAC_CONST(-0.923879504203796), FRAC_CONST(-0.382683426141739) },
+ { FRAC_CONST(-0.773010551929474), FRAC_CONST(-0.634393215179443) },
+ { FRAC_CONST(-0.555570006370544), FRAC_CONST(-0.831469774246216) },
+ { FRAC_CONST(-0.290284544229507), FRAC_CONST(-0.956940352916718) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.923879504203796), FRAC_CONST(-0.382683426141739) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.000000011924881), FRAC_CONST(-1.000000000000000) }
+ };
+
+#ifdef ALLOW_SMALL_FRAMELENGTH
+ ALIGN static const complex_t cfft_tab_240[] = {
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.999657332897186), FRAC_CONST(0.026176949962974) },
+ { FRAC_CONST(0.998629510402679), FRAC_CONST(0.052335958927870) },
+ { FRAC_CONST(0.996917307376862), FRAC_CONST(0.078459098935127) },
+ { FRAC_CONST(0.994521915912628), FRAC_CONST(0.104528464376926) },
+ { FRAC_CONST(0.991444885730743), FRAC_CONST(0.130526199936867) },
+ { FRAC_CONST(0.987688362598419), FRAC_CONST(0.156434476375580) },
+ { FRAC_CONST(0.983254909515381), FRAC_CONST(0.182235524058342) },
+ { FRAC_CONST(0.978147625923157), FRAC_CONST(0.207911700010300) },
+ { FRAC_CONST(0.972369909286499), FRAC_CONST(0.233445376157761) },
+ { FRAC_CONST(0.965925812721252), FRAC_CONST(0.258819043636322) },
+ { FRAC_CONST(0.958819746971130), FRAC_CONST(0.284015357494354) },
+ { FRAC_CONST(0.951056540012360), FRAC_CONST(0.309017002582550) },
+ { FRAC_CONST(0.942641496658325), FRAC_CONST(0.333806872367859) },
+ { FRAC_CONST(0.933580398559570), FRAC_CONST(0.358367949724197) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.913545429706573), FRAC_CONST(0.406736642122269) },
+ { FRAC_CONST(0.902585268020630), FRAC_CONST(0.430511116981506) },
+ { FRAC_CONST(0.891006529331207), FRAC_CONST(0.453990519046783) },
+ { FRAC_CONST(0.878817081451416), FRAC_CONST(0.477158784866333) },
+ { FRAC_CONST(0.866025388240814), FRAC_CONST(0.500000000000000) },
+ { FRAC_CONST(0.852640151977539), FRAC_CONST(0.522498548030853) },
+ { FRAC_CONST(0.838670551776886), FRAC_CONST(0.544639050960541) },
+ { FRAC_CONST(0.824126183986664), FRAC_CONST(0.566406250000000) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.793353319168091), FRAC_CONST(0.608761429786682) },
+ { FRAC_CONST(0.777145922183990), FRAC_CONST(0.629320383071899) },
+ { FRAC_CONST(0.760405957698822), FRAC_CONST(0.649448096752167) },
+ { FRAC_CONST(0.743144810199738), FRAC_CONST(0.669130623340607) },
+ { FRAC_CONST(0.725374400615692), FRAC_CONST(0.688354551792145) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.688354551792145), FRAC_CONST(0.725374400615692) },
+ { FRAC_CONST(0.669130563735962), FRAC_CONST(0.743144869804382) },
+ { FRAC_CONST(0.649448037147522), FRAC_CONST(0.760405957698822) },
+ { FRAC_CONST(0.629320383071899), FRAC_CONST(0.777145981788635) },
+ { FRAC_CONST(0.608761370182037), FRAC_CONST(0.793353378772736) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(0.566406250000000), FRAC_CONST(0.824126183986664) },
+ { FRAC_CONST(0.544638991355896), FRAC_CONST(0.838670611381531) },
+ { FRAC_CONST(0.522498488426209), FRAC_CONST(0.852640211582184) },
+ { FRAC_CONST(0.499999970197678), FRAC_CONST(0.866025447845459) },
+ { FRAC_CONST(0.477158755064011), FRAC_CONST(0.878817141056061) },
+ { FRAC_CONST(0.453990519046783), FRAC_CONST(0.891006529331207) },
+ { FRAC_CONST(0.430511027574539), FRAC_CONST(0.902585327625275) },
+ { FRAC_CONST(0.406736612319946), FRAC_CONST(0.913545489311218) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.358367860317230), FRAC_CONST(0.933580458164215) },
+ { FRAC_CONST(0.333806812763214), FRAC_CONST(0.942641496658325) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(0.284015327692032), FRAC_CONST(0.958819746971130) },
+ { FRAC_CONST(0.258819073438644), FRAC_CONST(0.965925812721252) },
+ { FRAC_CONST(0.233445301651955), FRAC_CONST(0.972369909286499) },
+ { FRAC_CONST(0.207911655306816), FRAC_CONST(0.978147625923157) },
+ { FRAC_CONST(0.182235524058342), FRAC_CONST(0.983254909515381) },
+ { FRAC_CONST(0.156434372067451), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(0.130526125431061), FRAC_CONST(0.991444885730743) },
+ { FRAC_CONST(0.104528419673443), FRAC_CONST(0.994521915912628) },
+ { FRAC_CONST(0.078459084033966), FRAC_CONST(0.996917307376862) },
+ { FRAC_CONST(0.052335973829031), FRAC_CONST(0.998629510402679) },
+ { FRAC_CONST(0.026176875457168), FRAC_CONST(0.999657332897186) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.026176963001490), FRAC_CONST(0.999657332897186) },
+ { FRAC_CONST(-0.052336059510708), FRAC_CONST(0.998629510402679) },
+ { FRAC_CONST(-0.078459173440933), FRAC_CONST(0.996917307376862) },
+ { FRAC_CONST(-0.104528509080410), FRAC_CONST(0.994521915912628) },
+ { FRAC_CONST(-0.130526214838028), FRAC_CONST(0.991444885730743) },
+ { FRAC_CONST(-0.156434446573257), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(-0.182235598564148), FRAC_CONST(0.983254909515381) },
+ { FRAC_CONST(-0.207911744713783), FRAC_CONST(0.978147566318512) },
+ { FRAC_CONST(-0.233445391058922), FRAC_CONST(0.972369909286499) },
+ { FRAC_CONST(-0.258819162845612), FRAC_CONST(0.965925812721252) },
+ { FRAC_CONST(-0.284015417098999), FRAC_CONST(0.958819687366486) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.333806872367859), FRAC_CONST(0.942641496658325) },
+ { FRAC_CONST(-0.358367949724197), FRAC_CONST(0.933580458164215) },
+ { FRAC_CONST(-0.382683515548706), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(-0.406736701726913), FRAC_CONST(0.913545429706573) },
+ { FRAC_CONST(-0.430511116981506), FRAC_CONST(0.902585268020630) },
+ { FRAC_CONST(-0.453990608453751), FRAC_CONST(0.891006469726563) },
+ { FRAC_CONST(-0.477158725261688), FRAC_CONST(0.878817141056061) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.998629510402679), FRAC_CONST(0.052335958927870) },
+ { FRAC_CONST(0.994521915912628), FRAC_CONST(0.104528464376926) },
+ { FRAC_CONST(0.987688362598419), FRAC_CONST(0.156434476375580) },
+ { FRAC_CONST(0.978147625923157), FRAC_CONST(0.207911700010300) },
+ { FRAC_CONST(0.965925812721252), FRAC_CONST(0.258819043636322) },
+ { FRAC_CONST(0.951056540012360), FRAC_CONST(0.309017002582550) },
+ { FRAC_CONST(0.933580398559570), FRAC_CONST(0.358367949724197) },
+ { FRAC_CONST(0.913545429706573), FRAC_CONST(0.406736642122269) },
+ { FRAC_CONST(0.891006529331207), FRAC_CONST(0.453990519046783) },
+ { FRAC_CONST(0.866025388240814), FRAC_CONST(0.500000000000000) },
+ { FRAC_CONST(0.838670551776886), FRAC_CONST(0.544639050960541) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.777145922183990), FRAC_CONST(0.629320383071899) },
+ { FRAC_CONST(0.743144810199738), FRAC_CONST(0.669130623340607) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.669130563735962), FRAC_CONST(0.743144869804382) },
+ { FRAC_CONST(0.629320383071899), FRAC_CONST(0.777145981788635) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(0.544638991355896), FRAC_CONST(0.838670611381531) },
+ { FRAC_CONST(0.499999970197678), FRAC_CONST(0.866025447845459) },
+ { FRAC_CONST(0.453990519046783), FRAC_CONST(0.891006529331207) },
+ { FRAC_CONST(0.406736612319946), FRAC_CONST(0.913545489311218) },
+ { FRAC_CONST(0.358367860317230), FRAC_CONST(0.933580458164215) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(0.258819073438644), FRAC_CONST(0.965925812721252) },
+ { FRAC_CONST(0.207911655306816), FRAC_CONST(0.978147625923157) },
+ { FRAC_CONST(0.156434372067451), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(0.104528419673443), FRAC_CONST(0.994521915912628) },
+ { FRAC_CONST(0.052335973829031), FRAC_CONST(0.998629510402679) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.052336059510708), FRAC_CONST(0.998629510402679) },
+ { FRAC_CONST(-0.104528509080410), FRAC_CONST(0.994521915912628) },
+ { FRAC_CONST(-0.156434446573257), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(-0.207911744713783), FRAC_CONST(0.978147566318512) },
+ { FRAC_CONST(-0.258819162845612), FRAC_CONST(0.965925812721252) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.358367949724197), FRAC_CONST(0.933580458164215) },
+ { FRAC_CONST(-0.406736701726913), FRAC_CONST(0.913545429706573) },
+ { FRAC_CONST(-0.453990608453751), FRAC_CONST(0.891006469726563) },
+ { FRAC_CONST(-0.500000059604645), FRAC_CONST(0.866025388240814) },
+ { FRAC_CONST(-0.544639050960541), FRAC_CONST(0.838670551776886) },
+ { FRAC_CONST(-0.587785184383392), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(-0.629320502281189), FRAC_CONST(0.777145862579346) },
+ { FRAC_CONST(-0.669130682945251), FRAC_CONST(0.743144810199738) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.743144929409027), FRAC_CONST(0.669130444526672) },
+ { FRAC_CONST(-0.777146041393280), FRAC_CONST(0.629320263862610) },
+ { FRAC_CONST(-0.809017062187195), FRAC_CONST(0.587785184383392) },
+ { FRAC_CONST(-0.838670551776886), FRAC_CONST(0.544639050960541) },
+ { FRAC_CONST(-0.866025388240814), FRAC_CONST(0.500000059604645) },
+ { FRAC_CONST(-0.891006588935852), FRAC_CONST(0.453990370035172) },
+ { FRAC_CONST(-0.913545489311218), FRAC_CONST(0.406736582517624) },
+ { FRAC_CONST(-0.933580458164215), FRAC_CONST(0.358367919921875) },
+ { FRAC_CONST(-0.951056599617004), FRAC_CONST(0.309016793966293) },
+ { FRAC_CONST(-0.965925872325897), FRAC_CONST(0.258818924427032) },
+ { FRAC_CONST(-0.978147625923157), FRAC_CONST(0.207911610603333) },
+ { FRAC_CONST(-0.987688362598419), FRAC_CONST(0.156434446573257) },
+ { FRAC_CONST(-0.994521915912628), FRAC_CONST(0.104528494179249) },
+ { FRAC_CONST(-0.998629570007324), FRAC_CONST(0.052335809916258) },
+ { FRAC_CONST(-1.000000000000000), FRAC_CONST(-0.000000087422777) },
+ { FRAC_CONST(-0.998629510402679), FRAC_CONST(-0.052335985004902) },
+ { FRAC_CONST(-0.994521856307983), FRAC_CONST(-0.104528672993183) },
+ { FRAC_CONST(-0.987688302993774), FRAC_CONST(-0.156434610486031) },
+ { FRAC_CONST(-0.978147566318512), FRAC_CONST(-0.207911789417267) },
+ { FRAC_CONST(-0.965925812721252), FRAC_CONST(-0.258819073438644) },
+ { FRAC_CONST(-0.951056540012360), FRAC_CONST(-0.309016972780228) },
+ { FRAC_CONST(-0.933580398559570), FRAC_CONST(-0.358368098735809) },
+ { FRAC_CONST(-0.913545429706573), FRAC_CONST(-0.406736731529236) },
+ { FRAC_CONST(-0.891006529331207), FRAC_CONST(-0.453990548849106) },
+ { FRAC_CONST(-0.866025269031525), FRAC_CONST(-0.500000178813934) },
+ { FRAC_CONST(-0.838670492172241), FRAC_CONST(-0.544639170169830) },
+ { FRAC_CONST(-0.809016942977905), FRAC_CONST(-0.587785363197327) },
+ { FRAC_CONST(-0.777145922183990), FRAC_CONST(-0.629320442676544) },
+ { FRAC_CONST(-0.743144810199738), FRAC_CONST(-0.669130623340607) },
+ { FRAC_CONST(-0.707106649875641), FRAC_CONST(-0.707106888294220) },
+ { FRAC_CONST(-0.669130504131317), FRAC_CONST(-0.743144869804382) },
+ { FRAC_CONST(-0.629320323467255), FRAC_CONST(-0.777145981788635) },
+ { FRAC_CONST(-0.587785065174103), FRAC_CONST(-0.809017121791840) },
+ { FRAC_CONST(-0.544639110565186), FRAC_CONST(-0.838670551776886) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.996917307376862), FRAC_CONST(0.078459098935127) },
+ { FRAC_CONST(0.987688362598419), FRAC_CONST(0.156434476375580) },
+ { FRAC_CONST(0.972369909286499), FRAC_CONST(0.233445376157761) },
+ { FRAC_CONST(0.951056540012360), FRAC_CONST(0.309017002582550) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.891006529331207), FRAC_CONST(0.453990519046783) },
+ { FRAC_CONST(0.852640151977539), FRAC_CONST(0.522498548030853) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.760405957698822), FRAC_CONST(0.649448096752167) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.649448037147522), FRAC_CONST(0.760405957698822) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(0.522498488426209), FRAC_CONST(0.852640211582184) },
+ { FRAC_CONST(0.453990519046783), FRAC_CONST(0.891006529331207) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(0.233445301651955), FRAC_CONST(0.972369909286499) },
+ { FRAC_CONST(0.156434372067451), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(0.078459084033966), FRAC_CONST(0.996917307376862) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.987688362598419), FRAC_CONST(0.156434476375580) },
+ { FRAC_CONST(0.951056540012360), FRAC_CONST(0.309017002582550) },
+ { FRAC_CONST(0.891006529331207), FRAC_CONST(0.453990519046783) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(0.453990519046783), FRAC_CONST(0.891006529331207) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(0.156434372067451), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.156434446573257), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.453990608453751), FRAC_CONST(0.891006469726563) },
+ { FRAC_CONST(-0.587785184383392), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.809017062187195), FRAC_CONST(0.587785184383392) },
+ { FRAC_CONST(-0.891006588935852), FRAC_CONST(0.453990370035172) },
+ { FRAC_CONST(-0.951056599617004), FRAC_CONST(0.309016793966293) },
+ { FRAC_CONST(-0.987688362598419), FRAC_CONST(0.156434446573257) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.972369909286499), FRAC_CONST(0.233445376157761) },
+ { FRAC_CONST(0.891006529331207), FRAC_CONST(0.453990519046783) },
+ { FRAC_CONST(0.760405957698822), FRAC_CONST(0.649448096752167) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.156434372067451), FRAC_CONST(0.987688362598419) },
+ { FRAC_CONST(-0.078459173440933), FRAC_CONST(0.996917307376862) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.522498667240143), FRAC_CONST(0.852640092372894) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.852640211582184), FRAC_CONST(0.522498488426209) },
+ { FRAC_CONST(-0.951056599617004), FRAC_CONST(0.309016793966293) },
+ { FRAC_CONST(-0.996917366981506), FRAC_CONST(0.078459039330482) },
+ { FRAC_CONST(-0.987688302993774), FRAC_CONST(-0.156434610486031) },
+ { FRAC_CONST(-0.923879504203796), FRAC_CONST(-0.382683426141739) },
+ { FRAC_CONST(-0.809016942977905), FRAC_CONST(-0.587785363197327) },
+ { FRAC_CONST(-0.649447917938232), FRAC_CONST(-0.760406076908112) },
+ { FRAC_CONST(-0.453990221023560), FRAC_CONST(-0.891006648540497) },
+ { FRAC_CONST(-0.233445450663567), FRAC_CONST(-0.972369909286499) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.951056540012360), FRAC_CONST(0.309017002582550) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.809017002582550), FRAC_CONST(0.587785243988037) },
+ { FRAC_CONST(0.309016972780228), FRAC_CONST(0.951056540012360) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.809017062187195), FRAC_CONST(0.587785184383392) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.587785243988037), FRAC_CONST(0.809017002582550) },
+ { FRAC_CONST(-0.309017032384872), FRAC_CONST(0.951056480407715) },
+ { FRAC_CONST(-0.951056599617004), FRAC_CONST(0.309016793966293) },
+ { FRAC_CONST(-0.809016942977905), FRAC_CONST(-0.587785363197327) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.309017121791840), FRAC_CONST(-0.951056480407715) }
+ };
+#endif
+
+#endif
+
+ ALIGN static const complex_t cfft_tab_128[] = {
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.998795449733734), FRAC_CONST(0.049067676067352) },
+ { FRAC_CONST(0.995184719562531), FRAC_CONST(0.098017141222954) },
+ { FRAC_CONST(0.989176511764526), FRAC_CONST(0.146730467677116) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.970031261444092), FRAC_CONST(0.242980197072029) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.941544055938721), FRAC_CONST(0.336889863014221) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.903989315032959), FRAC_CONST(0.427555084228516) },
+ { FRAC_CONST(0.881921231746674), FRAC_CONST(0.471396744251251) },
+ { FRAC_CONST(0.857728600502014), FRAC_CONST(0.514102756977081) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.803207516670227), FRAC_CONST(0.595699310302734) },
+ { FRAC_CONST(0.773010432720184), FRAC_CONST(0.634393334388733) },
+ { FRAC_CONST(0.740951120853424), FRAC_CONST(0.671558976173401) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.671558916568756), FRAC_CONST(0.740951180458069) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.595699310302734), FRAC_CONST(0.803207516670227) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.514102697372437), FRAC_CONST(0.857728660106659) },
+ { FRAC_CONST(0.471396654844284), FRAC_CONST(0.881921291351318) },
+ { FRAC_CONST(0.427555114030838), FRAC_CONST(0.903989315032959) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.336889833211899), FRAC_CONST(0.941544055938721) },
+ { FRAC_CONST(0.290284633636475), FRAC_CONST(0.956940352916718) },
+ { FRAC_CONST(0.242980122566223), FRAC_CONST(0.970031261444092) },
+ { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) },
+ { FRAC_CONST(0.146730497479439), FRAC_CONST(0.989176511764526) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(0.049067649990320), FRAC_CONST(0.998795449733734) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.049067739397287), FRAC_CONST(0.998795449733734) },
+ { FRAC_CONST(-0.098017223179340), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(-0.146730571985245), FRAC_CONST(0.989176511764526) },
+ { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) },
+ { FRAC_CONST(-0.242980197072029), FRAC_CONST(0.970031261444092) },
+ { FRAC_CONST(-0.290284723043442), FRAC_CONST(0.956940293312073) },
+ { FRAC_CONST(-0.336889922618866), FRAC_CONST(0.941544055938721) },
+ { FRAC_CONST(-0.382683515548706), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(-0.427555084228516), FRAC_CONST(0.903989315032959) },
+ { FRAC_CONST(-0.471396833658218), FRAC_CONST(0.881921231746674) },
+ { FRAC_CONST(-0.514102756977081), FRAC_CONST(0.857728600502014) },
+ { FRAC_CONST(-0.555570363998413), FRAC_CONST(0.831469535827637) },
+ { FRAC_CONST(-0.595699369907379), FRAC_CONST(0.803207516670227) },
+ { FRAC_CONST(-0.634393274784088), FRAC_CONST(0.773010492324829) },
+ { FRAC_CONST(-0.671559035778046), FRAC_CONST(0.740951061248779) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.740951240062714), FRAC_CONST(0.671558856964111) },
+ { FRAC_CONST(-0.773010492324829), FRAC_CONST(0.634393274784088) },
+ { FRAC_CONST(-0.803207635879517), FRAC_CONST(0.595699131488800) },
+ { FRAC_CONST(-0.831469655036926), FRAC_CONST(0.555570185184479) },
+ { FRAC_CONST(-0.857728600502014), FRAC_CONST(0.514102756977081) },
+ { FRAC_CONST(-0.881921350955963), FRAC_CONST(0.471396625041962) },
+ { FRAC_CONST(-0.903989315032959), FRAC_CONST(0.427555054426193) },
+ { FRAC_CONST(-0.923879623413086), FRAC_CONST(0.382683277130127) },
+ { FRAC_CONST(-0.941544115543365), FRAC_CONST(0.336889803409576) },
+ { FRAC_CONST(-0.956940352916718), FRAC_CONST(0.290284723043442) },
+ { FRAC_CONST(-0.970031261444092), FRAC_CONST(0.242980077862740) },
+ { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) },
+ { FRAC_CONST(-0.989176511764526), FRAC_CONST(0.146730333566666) },
+ { FRAC_CONST(-0.995184719562531), FRAC_CONST(0.098017096519470) },
+ { FRAC_CONST(-0.998795449733734), FRAC_CONST(0.049067486077547) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.995184719562531), FRAC_CONST(0.098017141222954) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.881921231746674), FRAC_CONST(0.471396744251251) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.773010432720184), FRAC_CONST(0.634393334388733) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.471396654844284), FRAC_CONST(0.881921291351318) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.290284633636475), FRAC_CONST(0.956940352916718) },
+ { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.980785250663757), FRAC_CONST(0.195090323686600) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.555570185184479), FRAC_CONST(0.831469655036926) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.195090234279633), FRAC_CONST(0.980785310268402) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) },
+ { FRAC_CONST(-0.382683515548706), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(-0.555570363998413), FRAC_CONST(0.831469535827637) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.831469655036926), FRAC_CONST(0.555570185184479) },
+ { FRAC_CONST(-0.923879623413086), FRAC_CONST(0.382683277130127) },
+ { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.956940352916718), FRAC_CONST(0.290284663438797) },
+ { FRAC_CONST(0.831469595432281), FRAC_CONST(0.555570244789124) },
+ { FRAC_CONST(0.634393274784088), FRAC_CONST(0.773010432720184) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(0.098017133772373), FRAC_CONST(0.995184719562531) },
+ { FRAC_CONST(-0.195090323686600), FRAC_CONST(0.980785250663757) },
+ { FRAC_CONST(-0.471396833658218), FRAC_CONST(0.881921231746674) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.881921231746674), FRAC_CONST(0.471396833658218) },
+ { FRAC_CONST(-0.980785310268402), FRAC_CONST(0.195090308785439) },
+ { FRAC_CONST(-0.995184719562531), FRAC_CONST(-0.098017267882824) },
+ { FRAC_CONST(-0.923879504203796), FRAC_CONST(-0.382683426141739) },
+ { FRAC_CONST(-0.773010551929474), FRAC_CONST(-0.634393215179443) },
+ { FRAC_CONST(-0.555570006370544), FRAC_CONST(-0.831469774246216) },
+ { FRAC_CONST(-0.290284544229507), FRAC_CONST(-0.956940352916718) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.923879504203796), FRAC_CONST(0.382683455944061) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.000000043711388), FRAC_CONST(1.000000000000000) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.382683426141739), FRAC_CONST(0.923879504203796) },
+ { FRAC_CONST(-0.707106769084930), FRAC_CONST(0.707106769084930) },
+ { FRAC_CONST(-0.923879504203796), FRAC_CONST(-0.382683426141739) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
+ { FRAC_CONST(0.000000011924881), FRAC_CONST(-1.000000000000000) }
+ };
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/audio_codec/libfaad/codebook/hcb.h b/audio_codec/libfaad/codebook/hcb.h
new file mode 100644
index 0000000..4fca89a
--- a/dev/null
+++ b/audio_codec/libfaad/codebook/hcb.h
@@ -0,0 +1,140 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: hcb.h,v 1.8 2007/11/01 12:34:10 menno Exp $
+**/
+
+#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/audio_codec/libfaad/codebook/hcb_1.h b/audio_codec/libfaad/codebook/hcb_1.h
new file mode 100644
index 0000000..86c7159
--- a/dev/null
+++ b/audio_codec/libfaad/codebook/hcb_1.h
@@ -0,0 +1,186 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: hcb_1.h,v 1.5 2007/11/01 12:34:11 menno Exp $
+**/
+
+/* 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[] = {
+ { /* 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[] = {
+ /* 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/audio_codec/libfaad/codebook/hcb_10.h b/audio_codec/libfaad/codebook/hcb_10.h
new file mode 100644
index 0000000..d31dc81
--- a/dev/null
+++ b/audio_codec/libfaad/codebook/hcb_10.h
@@ -0,0 +1,312 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: hcb_10.h,v 1.5 2007/11/01 12:34:11 menno Exp $
+**/
+
+/* 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[] = {
+ /* 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[] = {
+ /* 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/audio_codec/libfaad/codebook/hcb_11.h b/audio_codec/libfaad/codebook/hcb_11.h
new file mode 100644
index 0000000..e181735
--- a/dev/null
+++ b/audio_codec/libfaad/codebook/hcb_11.h
@@ -0,0 +1,415 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: hcb_11.h,v 1.5 2007/11/01 12:34:11 menno Exp $
+**/
+
+/* 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[] = {
+ /* 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[] = {
+ /* 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/audio_codec/libfaad/codebook/hcb_2.h b/audio_codec/libfaad/codebook/hcb_2.h
new file mode 100644
index 0000000..0d9fb51
--- a/dev/null
+++ b/audio_codec/libfaad/codebook/hcb_2.h
@@ -0,0 +1,185 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: hcb_2.h,v 1.5 2007/11/01 12:34:11 menno Exp $
+**/
+
+/* 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[] = {
+ { /* 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[] = {
+ /* 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/audio_codec/libfaad/codebook/hcb_3.h b/audio_codec/libfaad/codebook/hcb_3.h
new file mode 100644
index 0000000..6bcf66c
--- a/dev/null
+++ b/audio_codec/libfaad/codebook/hcb_3.h
@@ -0,0 +1,196 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: hcb_3.h,v 1.5 2007/11/01 12:34:11 menno Exp $
+**/
+
+/* Binary search huffman table HCB_3 */
+
+
+static hcb_bin_quad hcb3[] = {
+ { /* 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/audio_codec/libfaad/codebook/hcb_4.h b/audio_codec/libfaad/codebook/hcb_4.h
new file mode 100644
index 0000000..0e5e06e
--- a/dev/null
+++ b/audio_codec/libfaad/codebook/hcb_4.h
@@ -0,0 +1,199 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: hcb_4.h,v 1.5 2007/11/01 12:34:11 menno Exp $
+**/
+
+/* 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[] = {
+ /* 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[] = {
+ /* 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/audio_codec/libfaad/codebook/hcb_5.h b/audio_codec/libfaad/codebook/hcb_5.h
new file mode 100644
index 0000000..f015641
--- a/dev/null
+++ b/audio_codec/libfaad/codebook/hcb_5.h
@@ -0,0 +1,196 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: hcb_5.h,v 1.5 2007/11/01 12:34:11 menno Exp $
+**/
+
+/* Binary search huffman table HCB_5 */
+
+
+static hcb_bin_pair hcb5[] = {
+ { /* 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/audio_codec/libfaad/codebook/hcb_6.h b/audio_codec/libfaad/codebook/hcb_6.h
new file mode 100644
index 0000000..dbbaa42
--- a/dev/null
+++ b/audio_codec/libfaad/codebook/hcb_6.h
@@ -0,0 +1,182 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: hcb_6.h,v 1.5 2007/11/01 12:34:11 menno Exp $
+**/
+
+/* 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[] = {
+ /* 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[] = {
+ /* 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/audio_codec/libfaad/codebook/hcb_7.h b/audio_codec/libfaad/codebook/hcb_7.h
new file mode 100644
index 0000000..f680693
--- a/dev/null
+++ b/audio_codec/libfaad/codebook/hcb_7.h
@@ -0,0 +1,162 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: hcb_7.h,v 1.5 2007/11/01 12:34:11 menno Exp $
+**/
+
+/* Binary search huffman table HCB_7 */
+
+
+static hcb_bin_pair hcb7[] = {
+ { /* 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/audio_codec/libfaad/codebook/hcb_8.h b/audio_codec/libfaad/codebook/hcb_8.h
new file mode 100644
index 0000000..751a3ad
--- a/dev/null
+++ b/audio_codec/libfaad/codebook/hcb_8.h
@@ -0,0 +1,173 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: hcb_8.h,v 1.5 2007/11/01 12:34:11 menno Exp $
+**/
+
+/* 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[] = {
+ /* 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[] = {
+ /* 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/audio_codec/libfaad/codebook/hcb_9.h b/audio_codec/libfaad/codebook/hcb_9.h
new file mode 100644
index 0000000..37e3fdc
--- a/dev/null
+++ b/audio_codec/libfaad/codebook/hcb_9.h
@@ -0,0 +1,372 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: hcb_9.h,v 1.5 2007/11/01 12:34:11 menno Exp $
+**/
+
+/* Binary search huffman table HCB_9 */
+
+
+static hcb_bin_pair hcb9[] = {
+ { /* 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/audio_codec/libfaad/codebook/hcb_sf.h b/audio_codec/libfaad/codebook/hcb_sf.h
new file mode 100644
index 0000000..0fc9f59
--- a/dev/null
+++ b/audio_codec/libfaad/codebook/hcb_sf.h
@@ -0,0 +1,276 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: hcb_sf.h,v 1.7 2007/11/01 12:34:11 menno Exp $
+**/
+
+/* Binary search huffman table HCB_SF */
+
+
+static uint8_t hcb_sf[][2] = {
+ { /* 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/audio_codec/libfaad/common.c b/audio_codec/libfaad/common.c
new file mode 100644
index 0000000..ef9a03a
--- a/dev/null
+++ b/audio_codec/libfaad/common.c
@@ -0,0 +1,558 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: common.c,v 1.27 2008/03/23 23:03:28 menno Exp $
+**/
+
+/* just some common functions that could be used anywhere */
+#include <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+#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;
+}
+
+void *faad_malloc(size_t size)
+{
+#if 0 // defined(_WIN32) && !defined(_WIN32_WCE)
+ return _aligned_malloc(size, 16);
+#else // #ifdef 0
+ return malloc(size);
+#endif // #ifdef 0
+}
+
+/* common free function */
+void faad_free(void *b)
+{
+#if 0 // defined(_WIN32) && !defined(_WIN32_WCE)
+ _aligned_free(b);
+#else
+ free(b);
+}
+#endif
+
+ 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 ne_rng(uint32_t *__r1, uint32_t *__r2)
+ {
+ 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);
+ }
+
+ static uint32_t ones32(uint32_t x)
+ {
+ x -= ((x >> 1) & 0x55555555);
+ x = (((x >> 2) & 0x33333333) + (x & 0x33333333));
+ x = (((x >> 4) + x) & 0x0f0f0f0f);
+ x += (x >> 8);
+ x += (x >> 16);
+
+ return (x & 0x0000003f);
+ }
+
+ static uint32_t floor_log2(uint32_t x)
+ {
+#if 1
+ x |= (x >> 1);
+ x |= (x >> 2);
+ x |= (x >> 4);
+ x |= (x >> 8);
+ x |= (x >> 16);
+
+ return (ones32(x) - 1);
+#else
+ uint32_t count = 0;
+
+ while (x >>= 1) {
+ count++;
+ }
+
+ return count;
+#endif
+ }
+
+ /* returns position of first bit that is not 0 from msb,
+ * starting count at lsb */
+ uint32_t wl_min_lzc(uint32_t x)
+ {
+#if 1
+ x |= (x >> 1);
+ x |= (x >> 2);
+ x |= (x >> 4);
+ x |= (x >> 8);
+ x |= (x >> 16);
+
+ return (ones32(x));
+#else
+ uint32_t count = 0;
+
+ while (x >>= 1) {
+ count++;
+ }
+
+ return (count + 1);
+#endif
+ }
+
+#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[] = {
+ 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[] = {
+ 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)
+ };
+
+ real_t pow2_fix(real_t val)
+ {
+ uint32_t x1, x2;
+ uint32_t errcorr;
+ uint32_t index_frac;
+ real_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);
+
+
+ if (val == 0) {
+ return (1 << REAL_BITS);
+ }
+
+ /* leave INTERP_BITS bits */
+ index_frac = rest >> (REAL_BITS - TABLE_BITS - INTERP_BITS);
+ index_frac = index_frac & ((1 << INTERP_BITS) - 1);
+
+ if (whole > 0) {
+ retval = 1 << whole;
+ } else {
+ retval = REAL_CONST(1) >> -whole;
+ }
+
+ x1 = pow2_tab[index & ((1 << TABLE_BITS) - 1)];
+ x2 = pow2_tab[(index & ((1 << TABLE_BITS) - 1)) + 1];
+ errcorr = ((index_frac * (x2 - x1))) >> INTERP_BITS;
+
+ if (whole > 0) {
+ retval = retval * (errcorr + x1);
+ } else {
+ retval = MUL_R(retval, (errcorr + x1));
+ }
+
+ return retval;
+ }
+
+ int32_t pow2_int(real_t val)
+ {
+ uint32_t x1, x2;
+ uint32_t errcorr;
+ uint32_t index_frac;
+ real_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);
+
+
+ if (val == 0) {
+ return 1;
+ }
+
+ /* leave INTERP_BITS bits */
+ index_frac = rest >> (REAL_BITS - TABLE_BITS - INTERP_BITS);
+ index_frac = index_frac & ((1 << INTERP_BITS) - 1);
+
+ if (whole > 0) {
+ retval = 1 << whole;
+ } else {
+ retval = 0;
+ }
+
+ x1 = pow2_tab[index & ((1 << TABLE_BITS) - 1)];
+ x2 = pow2_tab[(index & ((1 << TABLE_BITS) - 1)) + 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;
+ uint32_t whole = (val);
+ 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 << TABLE_BITS) - 1)];
+ x2 = log2_tab[(index & ((1 << TABLE_BITS) - 1)) + 1];
+
+ /* linear interpolation */
+ /* retval = exp + ((index_frac)*x2 + (1-index_frac)*x1) */
+
+ errcorr = (index_frac * (x2 - x1)) >> 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;
+ uint32_t whole = (val >> REAL_BITS);
+ 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 << TABLE_BITS) - 1)];
+ x2 = log2_tab[(index & ((1 << TABLE_BITS) - 1)) + 1];
+
+ /* linear interpolation */
+ /* retval = exp + ((index_frac)*x2 + (1-index_frac)*x1) */
+
+ errcorr = (index_frac * (x2 - x1)) >> INTERP_BITS;
+
+ return (exp << REAL_BITS) + errcorr + x1;
+ }
+#endif
diff --git a/audio_codec/libfaad/common.h b/audio_codec/libfaad/common.h
new file mode 100644
index 0000000..e59f811
--- a/dev/null
+++ b/audio_codec/libfaad/common.h
@@ -0,0 +1,453 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: common.h,v 1.77 2009/02/05 00:51:03 menno Exp $
+**/
+
+#ifndef __COMMON_H__
+#define __COMMON_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include "../config.h"
+#endif
+
+#include "neaacdec.h"
+#include <android/log.h>
+
+#define LOG_TAG "FaadDecoder"
+#define audio_codec_print(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define DEBUG audio_codec_print
+#define HAVE_MEMCPY 1
+#if 1
+#define INLINE __inline
+#else
+#define INLINE inline
+#endif
+
+#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
+
+ /* Use if target platform has address generators with autoincrement */
+ //#define PREFER_POINTERS
+
+#ifdef _WIN32_WCE
+#define FIXED_POINT
+#endif
+
+#ifdef __BFIN__
+#define FIXED_POINT
+#endif
+
+#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 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
+ //#define DISABLE_SBR
+#define SBR_DEC
+ //#define SBR_LOW_POWER
+#define PS_DEC
+
+#ifdef SBR_LOW_POWER
+#undef PS_DEC
+#endif
+
+ /* FIXED POINT: No MAIN decoding */
+#ifdef FIXED_POINT
+# ifdef MAIN_DEC
+# undef MAIN_DEC
+# endif
+#endif // FIXED_POINT
+
+#ifdef DRM
+# ifndef ALLOW_SMALL_FRAMELENGTH
+# define ALLOW_SMALL_FRAMELENGTH
+# endif
+# undef LD_DEC
+# undef LTP_DEC
+# undef MAIN_DEC
+# undef SSR_DEC
+#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)
+#else
+#define DIV_R(A, B) ((A)/(B))
+#define DIV_C(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 <stdlib.h>
+
+ typedef unsigned __int64 uint64_t;
+ typedef unsigned __int32 uint32_t;
+ typedef unsigned __int16 uint16_t;
+ typedef unsigned __int8 uint8_t;
+ typedef signed __int64 int64_t;
+ typedef signed __int32 int32_t;
+ typedef signed __int16 int16_t;
+ typedef signed __int8 int8_t;
+ typedef float float32_t;
+
+
+#else
+
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+# include <stdint.h>
+# else
+ /* we need these... */
+#ifndef __TCS__
+ //typedef unsigned long long uint64_t;
+ //typedef signed long long int64_t;
+#else
+ typedef unsigned long uint64_t;
+ typedef signed long int64_t;
+#endif
+ //typedef unsigned long uint32_t;
+ typedef unsigned short uint16_t;
+ typedef unsigned char uint8_t;
+ //typedef signed long int32_t;
+ typedef signed short int16_t;
+ typedef signed char int8_t;
+# endif
+#endif
+#if HAVE_UNISTD_H
+ //# include <unistd.h>
+#endif
+
+#ifndef HAVE_FLOAT32_T
+ typedef float float32_t;
+#endif
+
+#if STDC_HEADERS
+# include <string.h>
+#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 <math.h>
+
+#define MUL_R(A,B) ((A)*(B))
+#define MUL_C(A,B) ((A)*(B))
+#define MUL_F(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 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);
+ }
+
+
+#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__) && \
+ !defined(__CYGWIN__) && !defined(__MINGW32__))
+#ifndef HAVE_LRINTF
+#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 /* HAVE_LRINTF */
+#endif
+
+
+#ifdef __ICL /* only Intel C compiler has fmath ??? */
+
+#include <mathf.h>
+
+#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 <math.h>
+
+#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 ne_rng(uint32_t *__r1, uint32_t *__r2);
+ uint32_t wl_min_lzc(uint32_t x);
+#ifdef FIXED_POINT
+#define LOG2_MIN_INF REAL_CONST(-10000)
+ int32_t log2_int(uint32_t val);
+ int32_t log2_fix(uint32_t val);
+ int32_t pow2_int(real_t val);
+ real_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);
+
+ void *faad_malloc(size_t size);
+ void faad_free(void *b);
+
+ //#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/audio_codec/libfaad/decoder.c b/audio_codec/libfaad/decoder.c
new file mode 100644
index 0000000..88edad5
--- a/dev/null
+++ b/audio_codec/libfaad/decoder.c
@@ -0,0 +1,2266 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: decoder.c,v 1.117 2009/02/05 00:51:03 menno Exp $
+**/
+
+#include "common.h"
+#include "structs.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include "mp4.h"
+#include "syntax.h"
+#include "error.h"
+#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"
+#include "ssr_fb.h"
+#endif
+
+#ifdef USE_HELIX_AAC_DECODER
+#include "aaccommon.h"
+#include "aacdec.h"
+int AACDataSource = 1;
+static HAACDecoder hAACDecoder;
+static short dec_buffer[1024 * 6 * 2];
+static short output_buffer[1024 * 2 * 2];
+static int adts_sample_rates[] = {96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350, 0, 0, 0};
+
+static int FindAdtsSRIndex(int sr)
+{
+ int i;
+
+ for (i = 0; i < 16; i++) {
+ if (sr == adts_sample_rates[i]) {
+ return i;
+ }
+ }
+ return 16 - 1;
+}
+static void MakeAdtsHeader(NeAACDecFrameInfo *hInfo, unsigned char *adts_header, int channel)
+{
+ unsigned char *data;
+ int old_format = 0;
+ int profile = hInfo->object_type;
+ if (profile == 5) { //sbr
+ profile = 2;
+ }
+ profile = (profile - 1) & 0x3;
+ int sr_index = ((hInfo->sbr == SBR_UPSAMPLED) || (hInfo->sbr == NO_SBR_UPSAMPLED)) ?
+ FindAdtsSRIndex(hInfo->samplerate / 2) : FindAdtsSRIndex(hInfo->samplerate);
+ int skip = (old_format) ? 8 : 7;
+ int framesize = skip + hInfo->bytesconsumed;
+
+ if (hInfo->header_type == ADTS) {
+ framesize -= skip;
+ }
+
+ // audio_codec_print("MakeAdtsHeader profile %d ,ch %d,sr_index %d\n",profile,channel,sr_index);
+
+ data = adts_header;
+ memset(data, 0, 7 * sizeof(unsigned char));
+
+ data[0] += 0xFF; /* 8b: syncword */
+
+ data[1] += 0xF0; /* 4b: syncword */
+ /* 1b: mpeg id = 0 */
+ /* 2b: layer = 0 */
+ data[1] += 1; /* 1b: protection absent */
+
+ data[2] += ((profile << 6) & 0xC0); /* 2b: profile */
+ data[2] += ((sr_index << 2) & 0x3C); /* 4b: sampling_frequency_index */
+ /* 1b: private = 0 */
+ data[2] += ((channel >> 2) & 0x1); /* 1b: channel_configuration */
+
+ data[3] += ((channel << 6) & 0xC0); /* 2b: channel_configuration */
+ /* 1b: original */
+ /* 1b: home */
+ /* 1b: copyright_id */
+ /* 1b: copyright_id_start */
+ data[3] += ((framesize >> 11) & 0x3); /* 2b: aac_frame_length */
+
+ data[4] += ((framesize >> 3) & 0xFF); /* 8b: aac_frame_length */
+
+ data[5] += ((framesize << 5) & 0xE0); /* 3b: aac_frame_length */
+ data[5] += ((0x7FF >> 6) & 0x1F); /* 5b: adts_buffer_fullness */
+
+ data[6] += ((0x7FF << 2) & 0x3F); /* 6b: adts_buffer_fullness */
+ /* 2b: num_raw_data_blocks */
+
+}
+#endif
+
+#ifdef ANALYSIS
+uint16_t dbg_count;
+#endif
+
+#define faad_log_info audio_codec_print
+
+
+#ifdef NEW_CODE_CHECK_LATM
+static unsigned char temp_bufer[200 * 1024];
+static int temp_size = 0;
+#define LATM_LOG audio_codec_print
+static const int pi_sample_rates[16] = {
+ 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050,
+ 16000, 12000, 11025, 8000, 7350, 0, 0, 0
+};
+static int LOASSyncInfo(uint8_t p_header[LOAS_HEADER_SIZE], unsigned int *pi_header_size)
+{
+ *pi_header_size = 3;
+ return ((p_header[1] & 0x1f) << 8) + p_header[2];
+}
+
+static int Mpeg4GAProgramConfigElement(bitfile *ld,mpeg4_cfg_t *p_cfg)
+{
+ /* TODO compute channels count ? */
+ int i_tag = faad_getbits(ld, 4);
+ //if (i_tag != 0x05) {
+ // return -1;
+ //}
+ faad_getbits(ld, 2 + 4); // object type + sampling index
+ int i_num_front = faad_getbits(ld, 4);
+ int i_num_side = faad_getbits(ld, 4);
+ int i_num_back = faad_getbits(ld, 4);
+ int i_num_lfe = faad_getbits(ld, 2);
+ int i_num_assoc_data = faad_getbits(ld, 3);
+ int i_num_valid_cc = faad_getbits(ld, 4);
+ int i,tmp;
+ if (faad_getbits(ld, 1)) {
+ faad_getbits(ld, 4); // mono downmix
+ }
+ if (faad_getbits(ld, 1)) {
+ faad_getbits(ld, 4); // stereo downmix
+ }
+ if (faad_getbits(ld, 1)) {
+ faad_getbits(ld, 2 + 1); // matrix downmix + pseudo_surround
+ }
+
+ for (i = 0; i < i_num_front; i++) {
+ tmp = faad_get1bit(ld DEBUGVAR(1, 26, "program_config_element(): front_element_is_cpe"));
+ faad_getbits(ld, 4 DEBUGVAR(1, 27, "program_config_element(): front_element_tag_select"));
+
+ if (tmp & 1) {
+ p_cfg->i_channel += 2;
+ } else {
+ p_cfg->i_channel++;
+ }
+ }
+
+ for (i = 0; i < i_num_side; i++) {
+ tmp = faad_get1bit(ld DEBUGVAR(1, 28, "program_config_element(): side_element_is_cpe"));
+ faad_getbits(ld, 4 DEBUGVAR(1, 29, "program_config_element(): side_element_tag_select"));
+
+ if (tmp & 1) {
+ p_cfg->i_channel += 2;
+ } else {
+ p_cfg->i_channel++;
+ }
+ }
+
+ for (i = 0; i < i_num_back; i++) {
+ tmp = faad_get1bit(ld DEBUGVAR(1, 30, "program_config_element(): back_element_is_cpe"));
+ faad_getbits(ld, 4 DEBUGVAR(1, 31, "program_config_element(): back_element_tag_select"));
+
+ if (tmp & 1) {
+ p_cfg->i_channel += 2;
+ } else {
+ p_cfg->i_channel++;
+ }
+ }
+
+ for (i = 0; i < i_num_lfe; i++) {
+ tmp = (uint8_t)faad_getbits(ld, 4 DEBUGVAR(1, 32, "program_config_element(): lfe_element_tag_select"));
+ p_cfg->i_channel++;
+ }
+
+ for (i = 0; i < i_num_assoc_data; i++)
+ faad_getbits(ld, 4 DEBUGVAR(1, 33, "program_config_element(): assoc_data_element_tag_select"));
+
+ for (i = 0; i < i_num_valid_cc; i++) {
+ faad_get1bit(ld DEBUGVAR(1, 34, "program_config_element(): cc_element_is_ind_sw"));
+ faad_getbits(ld, 4 DEBUGVAR(1, 35, "program_config_element(): valid_cc_element_tag_select"));
+ }
+ faad_byte_align(ld);
+ int i_comment = faad_getbits(ld, 8);
+ faad_getbits(ld, i_comment * 8);
+ return 0;
+}
+
+static int Mpeg4GASpecificConfig(mpeg4_cfg_t *p_cfg, bitfile *ld)
+{
+ p_cfg->i_frame_length = faad_getbits(ld, 1) ? 960 : 1024;
+
+ if (faad_getbits(ld, 1)) { // depend on core coder
+ faad_getbits(ld, 14); // core coder delay
+ }
+
+ int i_extension_flag = faad_getbits(ld, 1);
+ if (p_cfg->i_channel == 0) {
+ Mpeg4GAProgramConfigElement(ld,p_cfg);
+ }
+ if (p_cfg->i_object_type == 6 || p_cfg->i_object_type == 20) {
+ faad_getbits(ld, 3); // layer
+ }
+
+ if (i_extension_flag) {
+ if (p_cfg->i_object_type == 22) {
+ faad_getbits(ld, 5 + 11); // numOfSubFrame + layer length
+ }
+ if (p_cfg->i_object_type == 17 || p_cfg->i_object_type == 19 ||
+ p_cfg->i_object_type == 20 || p_cfg->i_object_type == 23) {
+ faad_getbits(ld, 1 + 1 + 1); // ER data : section scale spectral */
+ }
+ if (faad_getbits(ld, 1)) { // extension 3
+ LATM_LOG("Mpeg4GASpecificConfig: error 1\n");
+ }
+ }
+ return 0;
+}
+
+static int Mpeg4ReadAudioObjectType(bitfile *ld)
+{
+ int i_type = faad_getbits(ld, 5);
+ if (i_type == 31) {
+ i_type = 32 + faad_getbits(ld, 6);
+ }
+ return i_type;
+}
+
+static int Mpeg4ReadAudioSamplerate(bitfile *ld)
+{
+ int i_index = faad_getbits(ld, 4);
+ if (i_index != 0x0f) {
+ return pi_sample_rates[i_index];
+ }
+ return faad_getbits(ld, 24);
+}
+
+static int Mpeg4ReadAudioSpecificInfo(mpeg4_cfg_t *p_cfg, int *pi_extra, uint8_t *p_extra, bitfile *ld, int i_max_size)
+{
+#if 0
+ static const char *ppsz_otype[] = {
+ "NULL",
+ "AAC Main", "AAC LC", "AAC SSR", "AAC LTP", "SBR", "AAC Scalable",
+ "TwinVQ",
+ "CELP", "HVXC",
+ "Reserved", "Reserved",
+ "TTSI",
+ "Main Synthetic", "Wavetables Synthesis", "General MIDI",
+ "Algorithmic Synthesis and Audio FX",
+ "ER AAC LC",
+ "Reserved",
+ "ER AAC LTP", "ER AAC Scalable", "ER TwinVQ", "ER BSAC", "ER AAC LD",
+ "ER CELP", "ER HVXC", "ER HILN", "ER Parametric",
+ "SSC",
+ "PS", "Reserved", "Escape",
+ "Layer 1", "Layer 2", "Layer 3",
+ "DST",
+ };
+#endif
+ const int i_pos_start = faad_get_processed_bits(ld);
+ bitfile s_sav = *ld;
+ int i_bits;
+ int i;
+
+ memset(p_cfg, 0, sizeof(*p_cfg));
+ *pi_extra = 0;
+
+ p_cfg->i_object_type = Mpeg4ReadAudioObjectType(ld);
+ p_cfg->i_samplerate = Mpeg4ReadAudioSamplerate(ld);
+
+ p_cfg->i_channel = faad_getbits(ld, 4);
+ if (p_cfg->i_channel == 7) {
+ p_cfg->i_channel = 8; // 7.1
+ } else if (p_cfg->i_channel >= 8) {
+ p_cfg->i_channel = -1;
+ }
+
+ p_cfg->i_sbr = -1;
+ p_cfg->i_ps = -1;
+ p_cfg->extension.i_object_type = 0;
+ p_cfg->extension.i_samplerate = 0;
+ if (p_cfg->i_object_type == 5 || (p_cfg->i_object_type == 29/*&&(faad_showbits(ld, 3) & 0x03 && !(faad_showbits(ld, 9) & 0x3F))*/)) {
+ p_cfg->i_sbr = 1;
+ if (p_cfg->i_object_type == 29) {
+ p_cfg->i_ps = 1;
+ }
+ p_cfg->extension.i_object_type = 5;
+ p_cfg->extension.i_samplerate = Mpeg4ReadAudioSamplerate(ld);
+
+ p_cfg->i_object_type = Mpeg4ReadAudioObjectType(ld);
+ }
+
+ switch (p_cfg->i_object_type) {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 6:
+ case 7:
+ case 17:
+ case 19:
+ case 20:
+ case 21:
+ case 22:
+ case 23:
+ Mpeg4GASpecificConfig(p_cfg, ld);
+ break;
+ case 8:
+ // CelpSpecificConfig();
+ break;
+ case 9:
+ // HvxcSpecificConfig();
+ break;
+ case 12:
+ // TTSSSpecificConfig();
+ break;
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ // StructuredAudioSpecificConfig();
+ break;
+ case 24:
+ // ERCelpSpecificConfig();
+ break;
+ case 25:
+ // ERHvxcSpecificConfig();
+ break;
+ case 26:
+ case 27:
+ // ParametricSpecificConfig();
+ break;
+ case 28:
+ // SSCSpecificConfig();
+ break;
+ case 32:
+ case 33:
+ case 34:
+ // MPEG_1_2_SpecificConfig();
+ break;
+ case 35:
+ // DSTSpecificConfig();
+ break;
+ case 36:
+ // ALSSpecificConfig();
+ break;
+ default:
+ // error
+ break;
+ }
+ switch (p_cfg->i_object_type) {
+ case 17:
+ case 19:
+ case 20:
+ case 21:
+ case 22:
+ case 23:
+ case 24:
+ case 25:
+ case 26:
+ case 27: {
+ int epConfig = faad_getbits(ld, 2);
+ if (epConfig == 2 || epConfig == 3)
+ //ErrorProtectionSpecificConfig();
+ if (epConfig == 3)
+ if (faad_getbits(ld, 1)) {
+ // TODO : directMapping
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ if (p_cfg->extension.i_object_type != 5 && i_max_size > 0 && i_max_size - (faad_get_processed_bits(ld) - i_pos_start) >= 16 &&
+ faad_getbits(ld, 11) == 0x2b7) {
+ p_cfg->extension.i_object_type = Mpeg4ReadAudioObjectType(ld);
+ if (p_cfg->extension.i_object_type == 5) {
+ p_cfg->i_sbr = faad_getbits(ld, 1);
+ if (p_cfg->i_sbr == 1) {
+ p_cfg->extension.i_samplerate = Mpeg4ReadAudioSamplerate(ld);
+ if (i_max_size > 0 && i_max_size - (faad_get_processed_bits(ld) - i_pos_start) >= 12 && faad_getbits(ld, 11) == 0x548) {
+ p_cfg->i_ps = faad_getbits(ld, 1);
+ }
+ }
+ }
+ }
+
+ //fprintf(stderr, "Mpeg4ReadAudioSpecificInfo: t=%s(%d)f=%d c=%d sbr=%d\n",
+ // ppsz_otype[p_cfg->i_object_type], p_cfg->i_object_type, p_cfg->i_samplerate, p_cfg->i_channel, p_cfg->i_sbr);
+
+ i_bits = faad_get_processed_bits(ld) - i_pos_start;
+
+ *pi_extra = min((i_bits + 7) / 8, LATM_MAX_EXTRA_SIZE);
+ for (i = 0; i < *pi_extra; i++) {
+ const int i_read = min(8, i_bits - 8 * i);
+ p_extra[i] = faad_getbits(&s_sav, i_read) << (8 - i_read);
+ }
+ return i_bits;
+}
+
+static int LatmGetValue(bitfile *ld)
+{
+ int i_bytes = faad_getbits(ld, 2);
+ int v = 0;
+ int i;
+ for (i = 0; i < i_bytes; i++) {
+ v = (v << 8) + faad_getbits(ld, 8);
+ }
+
+ return v;
+}
+
+static int LatmReadStreamMuxConfiguration(latm_mux_t *m, bitfile *ld)
+{
+ int i_mux_version;
+ int i_mux_versionA;
+
+ i_mux_version = faad_getbits(ld, 1);
+ i_mux_versionA = 0;
+ if (i_mux_version) {
+ i_mux_versionA = faad_getbits(ld, 1);
+ }
+
+ if (i_mux_versionA != 0) { /* support only A=0 */
+ return -1;
+ }
+
+ memset(m, 0, sizeof(*m));
+
+ if (i_mux_versionA == 0)
+ if (i_mux_version == 1) {
+ LatmGetValue(ld); /* taraBufferFullness */
+ }
+
+ m->b_same_time_framing = faad_getbits(ld, 1);
+ m->i_sub_frames = 1 + faad_getbits(ld, 6);
+ m->i_programs = 1 + faad_getbits(ld, 4);
+ if (m->i_programs > 1) {
+ return -1;
+ }
+ int i_program;
+ for (i_program = 0; i_program < m->i_programs; i_program++) {
+ m->pi_layers[i_program] = 1 + faad_getbits(ld, 3);
+ if (m->pi_layers[0] > 1) {
+ return -1;
+ }
+ int i_layer;
+ for (i_layer = 0; i_layer < m->pi_layers[i_program]; i_layer++) {
+ latm_stream_t *st = &m->stream[m->i_streams];
+ unsigned char b_previous_cfg;
+
+ m->pi_stream[i_program][i_layer] = m->i_streams;
+ st->i_program = i_program;
+ st->i_layer = i_layer;
+
+ b_previous_cfg = 0;
+ if (i_program != 0 || i_layer != 0) {
+ b_previous_cfg = faad_getbits(ld, 1);
+ }
+
+ if (b_previous_cfg) {
+ if (m->i_streams <= 0) {
+ LATM_LOG("assert failed \n");
+ while (1) {
+ ;
+ }
+ }
+ st->cfg = m->stream[m->i_streams - 1].cfg;
+ } else {
+ int i_cfg_size = 0;
+ if (i_mux_version == 1) {
+ i_cfg_size = LatmGetValue(ld);
+ }
+ i_cfg_size -= Mpeg4ReadAudioSpecificInfo(&st->cfg, &st->i_extra, st->extra, ld, i_cfg_size);
+ if (i_cfg_size > 0) {
+ faad_flushbits(ld, i_cfg_size);
+ }
+ }
+
+ st->i_frame_length_type = faad_getbits(ld, 3);
+ switch (st->i_frame_length_type) {
+ case 0: {
+ faad_flushbits(ld, 8); /* latmBufferFullnes */
+ if (!m->b_same_time_framing)
+ if (st->cfg.i_object_type == 6 || st->cfg.i_object_type == 20 ||
+ st->cfg.i_object_type == 8 || st->cfg.i_object_type == 24) {
+ faad_flushbits(ld, 6); /* eFrameOffset */
+ }
+ break;
+ }
+ case 1:
+ st->i_frame_length = faad_getbits(ld, 9);
+ break;
+ case 3:
+ case 4:
+ case 5:
+ st->i_frame_length_index = faad_getbits(ld, 6); // celp
+ break;
+ case 6:
+ case 7:
+ st->i_frame_length_index = faad_getbits(ld, 1); // hvxc
+ default:
+ break;
+ }
+ /* Next stream */
+ m->i_streams++;
+ }
+ }
+
+ /* other data */
+ if (faad_getbits(ld, 1)) {
+ if (i_mux_version == 1) {
+ m->i_other_data = LatmGetValue(ld);
+ } else {
+ int b_continue;
+ do {
+ b_continue = faad_getbits(ld, 1);
+ m->i_other_data = (m->i_other_data << 8) + faad_getbits(ld, 8);
+ } while (b_continue);
+ }
+ }
+
+ /* crc */
+ m->i_crc = -1;
+ if (faad_getbits(ld, 1)) {
+ m->i_crc = faad_getbits(ld, 8);
+ }
+
+ return 0;
+}
+static int LOASParse(uint8_t *p_buffer, int i_buffer, decoder_sys_t *p_sys)
+{
+ bitfile ld = {0};
+ int i_accumulated = 0;
+ const latm_stream_t *st;
+ faad_initbits(&ld, p_buffer, i_buffer);
+ int ret = 0;
+ //bs_init(&s, p_buffer, i_buffer);
+
+ /* Read the stream mux configuration if present */
+ if (!faad_getbits(&ld, 1) && !(ret = LatmReadStreamMuxConfiguration(&p_sys->latm, &ld)) &&
+ p_sys->latm.i_streams > 0) {
+ st = &p_sys->latm.stream[0];
+
+ p_sys->i_channels = st->cfg.i_channel;
+ p_sys->i_rate = st->cfg.i_samplerate;
+ p_sys->i_frame_length = st->cfg.i_frame_length;
+ // LATM_LOG("ch %d, rate %d,frame len %d \n",p_sys->i_channels,p_sys->i_rate,p_sys->i_frame_length);
+ /* FIXME And if it changes ? */
+ if (p_sys->i_channels && p_sys->i_rate && p_sys->i_frame_length > 0) {
+#if 0
+ if (!p_dec->fmt_out.i_extra && st->i_extra > 0) {
+ p_dec->fmt_out.i_extra = st->i_extra;
+ p_dec->fmt_out.p_extra = malloc(st->i_extra);
+ if (!p_dec->fmt_out.p_extra) {
+ p_dec->fmt_out.i_extra = 0;
+ return 0;
+ }
+ memcpy(p_dec->fmt_out.p_extra, st->extra, st->i_extra);
+ }
+#endif
+ p_sys->b_latm_cfg = 1;
+ }
+ }
+
+ /* Wait for the configuration */
+ if (!p_sys->b_latm_cfg || ret < 0) {
+ return 0;
+ }
+
+ /* FIXME do we need to split the subframe into independent packet ? */
+ if (p_sys->latm.i_sub_frames > 1) {
+ printf("latm sub frames not yet supported, please send a sample");
+ }
+ int i_sub;
+ for (i_sub = 0; i_sub < p_sys->latm.i_sub_frames; i_sub++) {
+ int pi_payload[LATM_MAX_PROGRAM][LATM_MAX_LAYER];
+ if (p_sys->latm.b_same_time_framing) {
+ /* Payload length */
+ int i_program, i_layer;
+ for (i_program = 0; i_program < p_sys->latm.i_programs; i_program++) {
+ for (i_layer = 0; i_layer < p_sys->latm.pi_layers[i_program]; i_layer++) {
+ latm_stream_t *st = &p_sys->latm.stream[p_sys->latm.pi_stream[i_program][i_layer]];
+ if (st->i_frame_length_type == 0) {
+ int i_payload = 0;
+ for (;;) {
+ int i_tmp = faad_getbits(&ld, 8);
+ i_payload += i_tmp;
+ if (i_tmp != 255) {
+ break;
+ }
+ }
+ pi_payload[i_program][i_layer] = i_payload;
+ } else if (st->i_frame_length_type == 1) {
+ pi_payload[i_program][i_layer] = st->i_frame_length / 8; /* XXX not correct */
+ } else if ((st->i_frame_length_type == 3) ||
+ (st->i_frame_length_type == 5) ||
+ (st->i_frame_length_type == 7)) {
+ faad_getbits(&ld, 2); // muxSlotLengthCoded
+ pi_payload[i_program][i_layer] = 0; /* TODO */
+ } else {
+ pi_payload[i_program][i_layer] = 0; /* TODO */
+ }
+ }
+ }
+
+ /* Payload Data */
+ // int i_program,i_layer;
+ for (i_program = 0; i_program < p_sys->latm.i_programs; i_program++) {
+ for (i_layer = 0; i_layer < p_sys->latm.pi_layers[i_program]; i_layer++) {
+ /* XXX we only extract 1 stream */
+ if (i_program != 0 || i_layer != 0) {
+ break;
+ }
+
+ if (pi_payload[i_program][i_layer] <= 0) {
+ continue;
+ }
+
+ /* FIXME that's slow (and a bit ugly to write in place) */
+ int i;
+ for (i = 0; i < pi_payload[i_program][i_layer]; i++) {
+ if (i_accumulated >= i_buffer) {
+ return 0;
+ }
+ p_buffer[i_accumulated++] = faad_getbits(&ld, 8);
+ }
+ }
+ }
+ } else {
+ const int i_chunks = faad_getbits(&ld, 4);
+ int pi_program[16];
+ int pi_layer[16];
+
+ // printf( "latm without same time frameing not yet supported, please send a sample");
+ int i_chunk;
+ for (i_chunk = 0; i_chunk < i_chunks; i_chunk++) {
+ const int streamIndex = faad_getbits(&ld, 4);
+ latm_stream_t *st = &p_sys->latm.stream[streamIndex];
+ const int i_program = st->i_program;
+ const int i_layer = st->i_layer;
+
+ pi_program[i_chunk] = i_program;
+ pi_layer[i_chunk] = i_layer;
+
+ if (st->i_frame_length_type == 0) {
+ int i_payload = 0;
+ for (;;) {
+ int i_tmp = faad_getbits(&ld, 8);
+ i_payload += i_tmp;
+ if (i_tmp != 255) {
+ break;
+ }
+ }
+ pi_payload[i_program][i_layer] = i_payload;
+ faad_getbits(&ld, 1); // auEndFlag
+ } else if (st->i_frame_length_type == 1) {
+ pi_payload[i_program][i_layer] = st->i_frame_length / 8; /* XXX not correct */
+ } else if ((st->i_frame_length_type == 3) ||
+ (st->i_frame_length_type == 5) ||
+ (st->i_frame_length_type == 7)) {
+ faad_getbits(&ld, 2); // muxSlotLengthCoded
+ }
+ }
+ // int i_chunk;
+ for (i_chunk = 0; i_chunk < i_chunks; i_chunk++) {
+ //const int i_program = pi_program[i_chunk];
+ //const int i_layer = pi_layer[i_chunk];
+
+ /* TODO ? Payload */
+ }
+ }
+ }
+
+#if 0
+ if (p_sys->latm.i_other_data > 0) {
+ ; // TODO
+ }
+#endif
+ faad_byte_align(&ld);
+
+ return i_accumulated;
+}
+
+
+#endif
+
+/* static function declarations */
+static void* aac_frame_decode(NeAACDecStruct *hDecoder,
+ NeAACDecFrameInfo *hInfo,
+ unsigned char *buffer,
+ unsigned long buffer_size,
+ void **sample_buffer2,
+ unsigned long sample_buffer_size);
+static void create_channel_config(NeAACDecStruct *hDecoder,
+ NeAACDecFrameInfo *hInfo);
+
+
+char* NEAACDECAPI NeAACDecGetErrorMessage(unsigned char errcode)
+{
+ if (errcode >= NUM_ERROR_MESSAGES) {
+ return NULL;
+ }
+ return err_msg[errcode];
+}
+
+unsigned long 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;
+}
+
+const unsigned char mes[] = { 0x67, 0x20, 0x61, 0x20, 0x20, 0x20, 0x6f, 0x20, 0x72, 0x20, 0x65, 0x20, 0x6e, 0x20, 0x20, 0x20, 0x74, 0x20, 0x68, 0x20, 0x67, 0x20, 0x69, 0x20, 0x72, 0x20, 0x79, 0x20, 0x70, 0x20, 0x6f, 0x20, 0x63 };
+NeAACDecHandle NEAACDECAPI NeAACDecOpen(void)
+{
+ uint8_t i;
+ NeAACDecStruct *hDecoder = NULL;
+
+ if ((hDecoder = (NeAACDecStruct*)faad_malloc(sizeof(NeAACDecStruct))) == NULL) {
+ return NULL;
+ }
+
+ memset(hDecoder, 0, sizeof(NeAACDecStruct));
+
+ hDecoder->cmes = mes;
+ hDecoder->config.outputFormat = FAAD_FMT_16BIT;
+ hDecoder->config.defObjectType = MAIN;
+ hDecoder->config.defSampleRate = 44100; /* Default: 44.1kHz */
+ hDecoder->config.downMatrix = 0x01;
+ hDecoder->adts_header_present = 0;
+ hDecoder->adif_header_present = 0;
+ hDecoder->latm_header_present = 0;
+#ifdef ERROR_RESILIENCE
+ hDecoder->aacSectionDataResilienceFlag = 0;
+ hDecoder->aacScalefactorDataResilienceFlag = 0;
+ hDecoder->aacSpectralDataResilienceFlag = 0;
+#endif
+ hDecoder->frameLength = 1024;
+
+ hDecoder->frame = 0;
+ hDecoder->sample_buffer = NULL;
+
+ hDecoder->__r1 = 1;
+ hDecoder->__r2 = 1;
+
+ for (i = 0; i < MAX_CHANNELS; i++) {
+ hDecoder->window_shape_prev[i] = 0;
+ hDecoder->time_out[i] = NULL;
+ hDecoder->fb_intermed[i] = NULL;
+#ifdef SSR_DEC
+ hDecoder->ssr_overlap[i] = NULL;
+ hDecoder->prev_fmd[i] = NULL;
+#endif
+#ifdef MAIN_DEC
+ hDecoder->pred_stat[i] = NULL;
+#endif
+#ifdef LTP_DEC
+ hDecoder->ltp_lag[i] = 0;
+ hDecoder->lt_pred_stat[i] = NULL;
+#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));
+ hDecoder->last_ch_configure = -1;
+ hDecoder->last_sf_index = -1;
+ return hDecoder;
+}
+
+NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hpDecoder)
+{
+ NeAACDecStruct* hDecoder = (NeAACDecStruct*)hpDecoder;
+ if (hDecoder) {
+ NeAACDecConfigurationPtr config = &(hDecoder->config);
+
+ return config;
+ }
+
+ return NULL;
+}
+
+unsigned char NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hpDecoder,
+ NeAACDecConfigurationPtr config)
+{
+ NeAACDecStruct* hDecoder = (NeAACDecStruct*)hpDecoder;
+ 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;
+}
+
+
+static int latmCheck(latm_header *latm, bitfile *ld)
+{
+ uint32_t good = 0, bad = 0, bits, m;
+
+ while (ld->bytes_left) {
+ bits = faad_latm_frame(latm, ld);
+ if (bits == -1U) {
+ bad++;
+ } else {
+ good++;
+ while (bits > 0) {
+ m = min(bits, 8);
+ faad_getbits(ld, m DEBUGVAR(print, var, dbg));
+ bits -= m;
+ }
+ }
+ }
+
+ return (good > 0);
+}
+
+#define SKIP_LATM_BYTE 16*4*2
+static int latm_check_internal(unsigned char *buffer, unsigned buffer_size, unsigned *byte_cost)
+{
+ latm_header l = {0};
+ int is_latm = 0;
+ bitfile ld;
+ int byte_consumed = 0;
+ int byte_left = buffer_size;
+retry:
+ memset(&l, 0, sizeof(latm_header));
+ faad_initbits(&ld, buffer + byte_consumed, buffer_size - byte_consumed);
+ is_latm = latmCheck(&l, &ld);
+ if (is_latm && l.ASCbits > 0) {
+ is_latm = 1;
+ } else {
+ is_latm = 0;
+ byte_consumed += SKIP_LATM_BYTE;
+ byte_left -= SKIP_LATM_BYTE;
+
+ }
+ if (is_latm == 0 && byte_left > 400) {
+ goto retry;
+ }
+exit:
+ *byte_cost = byte_consumed;
+ return is_latm;
+}
+
+long NEAACDECAPI NeAACDecInit(NeAACDecHandle hpDecoder,
+ unsigned char *buffer,
+ unsigned long buffer_size,
+ unsigned long *samplerate,
+ unsigned char *channels,
+ int is_latm_external,
+ int *skipbytes)
+{
+ uint32_t bits = 0;
+ bitfile ld;
+ adif_header adif;
+ adts_header adts;
+ NeAACDecStruct* hDecoder = (NeAACDecStruct*)hpDecoder;
+ faad_log_info("enter NeAACDecInit \r\n");
+#ifdef NEW_CODE_CHECK_LATM
+ int i_frame_size;
+ if (buffer_size > sizeof(temp_bufer)) {
+ LATM_LOG("init input buffer size tooo big %d, buffer size %d \n", buffer_size, sizeof(temp_bufer));
+ buffer_size = sizeof(temp_bufer);
+ }
+ if (buffer_size > 0) {
+ memcpy(temp_bufer, buffer, buffer_size);
+ temp_size = buffer_size;
+ buffer = temp_bufer;
+ }
+ unsigned char *pbuffer = buffer;
+ int pbuffer_size = buffer_size;
+ decoder_sys_t *p_sys = &hDecoder->dec_sys;
+ latm_mux_t *m = &p_sys->latm;
+ latm_stream_t *st = NULL;
+#endif
+
+ if ((hDecoder == NULL) || (samplerate == NULL) || (channels == NULL)) {
+ return -1;
+ }
+ //memset(latm_payload,0,sizeof(latm_payload));
+ hDecoder->sf_index = get_sr_index(hDecoder->config.defSampleRate);
+ hDecoder->object_type = hDecoder->config.defObjectType;
+ *samplerate = get_sample_rate(hDecoder->sf_index);
+ *channels = 1;
+ *samplerate = 0;
+ *channels = 0;
+ int latm_audio = 0;
+ unsigned byte_cost = 0;
+ if (buffer != NULL) {
+ int is_latm;
+ latm_header *l = &hDecoder->latm_config;
+ faad_initbits(&ld, buffer, buffer_size);
+#ifdef NEW_CODE_CHECK_LATM
+ memset(&hDecoder->dec_sys, 0, sizeof(decoder_sys_t));
+NEXT_CHECK:
+ while (pbuffer_size >= 2) {
+ if (pbuffer[0] == 0x56 && (pbuffer[1] & 0xe0) == 0xe0) { //LOAS sync word detected
+ // LATM_LOG("find LOAS sync word pos %d\n",buffer_size-pbuffer_size);
+ break;
+ }
+ pbuffer++;
+ pbuffer_size--;
+ }
+ if (pbuffer_size < LOAS_HEADER_SIZE) {
+ LATM_LOG("check the loas frame failed\n");
+ *skipbytes = buffer_size-pbuffer_size;
+ goto exit_check;
+ }
+ /* Check if frame is valid and get frame info */
+ i_frame_size = ((pbuffer[1] & 0x1f) << 8) + pbuffer[2];
+ if (i_frame_size <= 0 || i_frame_size > 6 * 768) {
+ LATM_LOG("i_frame_size/%d error\n",i_frame_size);
+ pbuffer++;
+ pbuffer_size--;
+ goto NEXT_CHECK;
+ }
+ if (pbuffer_size < (LOAS_HEADER_SIZE + i_frame_size)) {
+ LATM_LOG("[%s %d]buffer size %d small then frame size %d,\n", __FUNCTION__,__LINE__,pbuffer_size, i_frame_size+LOAS_HEADER_SIZE);
+ *skipbytes = buffer_size-pbuffer_size;
+ goto exit_check;
+ }
+#if 1
+ if (pbuffer[LOAS_HEADER_SIZE + i_frame_size] != 0x56 || (pbuffer[LOAS_HEADER_SIZE + i_frame_size + 1] & 0xe0) != 0xe0) { // next frame LOAS sync header detected
+ LATM_LOG("emulated sync word no (sync on following frame) \n");
+ pbuffer++;
+ pbuffer_size--;
+ goto NEXT_CHECK;
+ }
+#endif
+ pbuffer += LOAS_HEADER_SIZE; //skip header
+ pbuffer_size = pbuffer_size - LOAS_HEADER_SIZE;
+ //parse the playload of one real LOAS aac frame
+ i_frame_size = LOASParse(pbuffer, i_frame_size, p_sys);
+ if (i_frame_size <= 0) {
+ LATM_LOG("[%s %d]invalid i_frame_size/%d ,go on next check!...\n", __FUNCTION__, __LINE__, i_frame_size);
+ goto NEXT_CHECK;
+ } else {
+ LATM_LOG("latm detected\n");
+ hDecoder->latm_header_present = 1;
+ }
+ //assue latm detected. start init code
+exit_check:
+ if (m->i_streams > 0) {
+ st = &m->stream[m->i_streams - 1];
+ }
+ memset(l, 0, sizeof(latm_header));
+ if (st && st->i_extra || is_latm_external) {
+ int32_t x;
+
+ hDecoder->latm_header_present = 1;
+ if (st && st->i_extra) {
+ x = NeAACDecInit2(hDecoder, st->extra, st->i_extra, samplerate, channels);
+ } else {
+ x = -1;
+ }
+ if (x != 0) {
+ hDecoder->latm_header_present = 0;
+ }
+#ifdef USE_HELIX_AAC_DECODER
+ else {
+ hAACDecoder = AACInitDecoder();
+ if (!hAACDecoder) {
+ faad_log_info("fatal error,helix aac decoder init failed\n");
+ return -1;
+ } else {
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+ if (aacDecInfo) {
+ aacDecInfo->format = AAC_FF_ADTS;
+ aacDecInfo->nChans = *channels;
+ } else {
+ LATM_LOG("aacDecInfo NULL\n");
+ return NULL;
+ }
+ }
+ }
+#endif
+ LATM_LOG("latm init ret %d \n", x);
+ return x;
+ } else
+#else
+ memset(l, 0, sizeof(latm_header));
+ is_latm = latmCheck(l, &ld);
+ l->inited = 0;
+ l->frameLength = 0;
+ faad_rewindbits(&ld);
+ if (is_latm && l->ASCbits > 0) {
+ int32_t x;
+ hDecoder->latm_header_present = 1;
+ x = NeAACDecInit2(hDecoder, l->ASC, (l->ASCbits + 7) / 8, samplerate, channels);
+ if (x != 0) {
+ hDecoder->latm_header_present = 0;
+ }
+ return x;
+ } else
+#endif
+ /* 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;
+ faad_log_info("[%s %d]ADIF aac file detected\n", __FUNCTION__, __LINE__);
+ 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;
+ if (adts.sf_index >= 0 && adts.sf_index < 12 && adts.channel_configuration > 0 && adts.channel_configuration <= 8) {
+ hDecoder->last_sf_index = hDecoder->sf_index;
+ hDecoder->last_ch_configure = adts.channel_configuration;
+ }
+ *samplerate = get_sample_rate(hDecoder->sf_index);
+ *channels = (adts.channel_configuration > 6) ?
+ 2 : adts.channel_configuration;
+ } else {
+ /*we guess it is a ADTS aac files and try to resync from the error*/
+ int ii;
+ int adts_err = 0;
+ faad_log_info("[%s %d]guess it is a ADTS aac files and try to resync\n", __FUNCTION__, __LINE__);
+ faad_initbits(&ld, buffer, buffer_size);
+ for (ii = 0; ii < buffer_size; ii++) {
+ if ((faad_showbits(&ld, 16) & 0xfff6) != 0xFFF0) {
+ faad_getbits(&ld, 8
+ DEBUGVAR(0, 0, ""));
+ } else {
+ bits = bit2byte(faad_get_processed_bits(&ld));
+ hDecoder->adts_header_present = 1;
+ faad_log_info("[%s %d]resync and got ADTS header\n", __FUNCTION__, __LINE__);
+ adts.old_format = hDecoder->config.useOldADTSFormat;
+ adts_err = adts_frame(&adts, &ld);
+ if (adts_err == 5) {
+ return -1;
+ }
+ hDecoder->sf_index = adts.sf_index;
+ hDecoder->object_type = adts.profile + 1;
+ faad_log_info("sf index %d,object type %d \n", hDecoder->sf_index, hDecoder->object_type);
+ if (adts.sf_index >= 0 && adts.sf_index < 12 && adts.channel_configuration > 0 && adts.channel_configuration <= 8) {
+ hDecoder->last_sf_index = hDecoder->sf_index;
+ hDecoder->last_ch_configure = adts.channel_configuration;
+ }
+ *samplerate = get_sample_rate(hDecoder->sf_index);
+ if (*samplerate > 96000 || adts.channel_configuration > 6 || hDecoder->sf_index >= 12) {
+ return -1;
+ }
+ *channels = (adts.channel_configuration > 6) ? 2 : adts.channel_configuration;
+ faad_log_info("[%s %d]resync adts info:FS/%d object_type/%d chnum/%d\n", __FUNCTION__, __LINE__, *samplerate, hDecoder->object_type, channels);
+ break;
+ }
+ }
+ if (ii == buffer_size) {
+ faad_log_info("[%s %d]sync for adts frame failed\n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ }
+ }
+ if (ld.error) {
+ faad_endbits(&ld);
+ return -1;
+ }
+ faad_endbits(&ld);
+
+#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
+
+ hDecoder->channelConfiguration = *channels;
+
+#ifdef SBR_DEC
+ /* implicit signalling */
+ if (*samplerate <= 24000 && (hDecoder->config.dontUpSampleImplicitSBR == 0)) {
+ *samplerate *= 2;
+ hDecoder->forceUpSampling = 1;
+ } else if (*samplerate > 24000 && (hDecoder->config.dontUpSampleImplicitSBR == 0)) {
+ 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
+ hDecoder->fb = filter_bank_init(hDecoder->frameLength);
+
+#ifdef LD_DEC
+ if (hDecoder->object_type == LD) {
+ hDecoder->frameLength >>= 1;
+ }
+#endif
+
+ if (can_decode_ot(hDecoder->object_type) < 0) {
+ faad_log_info("[%s %d]object_type/%d can not support\n", __FUNCTION__, __LINE__, hDecoder->object_type);
+ return -1;
+ }
+ faad_log_info("[%s %d]aac init finished. cost bits%d\n", __FUNCTION__, __LINE__, bits);
+ return bits;
+}
+
+/* Init the library using a DecoderSpecificInfo */
+int NEAACDECAPI NeAACDecInit2(NeAACDecHandle hpDecoder,
+ unsigned char *pBuffer,
+ unsigned long SizeOfDecoderSpecificInfo,
+ unsigned long *samplerate,
+ unsigned char *channels)
+{
+ NeAACDecStruct* hDecoder = (NeAACDecStruct*)hpDecoder;
+ int8_t rc;
+ mp4AudioSpecificConfig mp4ASC;
+ faad_log_info("enter NeAACDecInit2 \r\n");
+ faad_log_info("extra data size %d\r\n", SizeOfDecoderSpecificInfo);
+ 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), hDecoder->latm_header_present);
+
+ /* 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
+ 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
+ hDecoder->fb = filter_bank_init(hDecoder->frameLength);
+
+#ifdef LD_DEC
+ if (hDecoder->object_type == LD) {
+ hDecoder->frameLength >>= 1;
+ }
+#endif
+ faad_log_info("aac init2 finished\r\n");
+ return 0;
+}
+
+#ifdef DRM
+char NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hpDecoder,
+ unsigned long samplerate,
+ unsigned char channels)
+{
+ NeAACDecStruct** hDecoder = (NeAACDecStruct**)hpDecoder;
+ if (hDecoder == NULL) {
+ return 1; /* error */
+ }
+
+ NeAACDecClose(*hDecoder);
+
+ *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
+
+ (*hDecoder)->fb = filter_bank_init((*hDecoder)->frameLength);
+
+ return 0;
+}
+#endif
+
+void NEAACDECAPI NeAACDecClose(NeAACDecHandle hpDecoder)
+{
+ uint8_t i;
+ NeAACDecStruct* hDecoder = (NeAACDecStruct*)hpDecoder;
+#ifdef USE_HELIX_AAC_DECODER
+ if (hAACDecoder) {
+ AACFreeDecoder(hAACDecoder);
+ hAACDecoder = NULL;
+ }
+#endif
+ if (hDecoder == NULL) {
+ return;
+ }
+
+#ifdef PROFILE
+ //printk("AAC decoder total: %I64d cycles\n", hDecoder->cycles);
+ //printk("requant: %I64d cycles\n", hDecoder->requant_cycles);
+ //printk("spectral_data: %I64d cycles\n", hDecoder->spectral_cycles);
+ //printk("scalefactors: %I64d cycles\n", hDecoder->scalefac_cycles);
+ //printk("output: %I64d cycles\n", hDecoder->output_cycles);
+#endif
+
+ for (i = 0; i < MAX_CHANNELS; i++) {
+ if (hDecoder->time_out[i]) {
+ faad_free(hDecoder->time_out[i]);
+ }
+ if (hDecoder->fb_intermed[i]) {
+ faad_free(hDecoder->fb_intermed[i]);
+ }
+#ifdef SSR_DEC
+ if (hDecoder->ssr_overlap[i]) {
+ faad_free(hDecoder->ssr_overlap[i]);
+ }
+ if (hDecoder->prev_fmd[i]) {
+ faad_free(hDecoder->prev_fmd[i]);
+ }
+#endif
+#ifdef MAIN_DEC
+ if (hDecoder->pred_stat[i]) {
+ faad_free(hDecoder->pred_stat[i]);
+ }
+#endif
+#ifdef LTP_DEC
+ if (hDecoder->lt_pred_stat[i]) {
+ faad_free(hDecoder->lt_pred_stat[i]);
+ }
+#endif
+ }
+
+#ifdef SSR_DEC
+ if (hDecoder->object_type == SSR) {
+ ssr_filter_bank_end(hDecoder->fb);
+ } else
+#endif
+ filter_bank_end(hDecoder->fb);
+
+ drc_end(hDecoder->drc);
+
+ if (hDecoder->sample_buffer) {
+ faad_free(hDecoder->sample_buffer);
+ }
+
+
+ if (hDecoder->sample_buffer_all) {
+ faad_free(hDecoder->sample_buffer_all);
+ }
+
+#ifdef SBR_DEC
+ for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++) {
+ if (hDecoder->sbr[i]) {
+ sbrDecodeEnd(hDecoder->sbr[i]);
+ }
+ }
+#endif
+ //why not free before?
+ if (hDecoder) {
+ faad_free(hDecoder);
+ }
+}
+
+void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hpDecoder, long frame)
+{
+ NeAACDecStruct* hDecoder = (NeAACDecStruct*)hpDecoder;
+ if (hDecoder) {
+ hDecoder->postSeekResetFlag = 1;
+
+ if (frame != -1) {
+ hDecoder->frame = frame;
+ }
+ }
+}
+
+static void create_channel_config(NeAACDecStruct *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) {
+#if (defined(PS_DEC) || defined(DRM_PS))
+ /* When PS is enabled output is always stereo */
+ hInfo->channel_position[chpos++] = FRONT_CHANNEL_LEFT;
+ hInfo->channel_position[chpos++] = FRONT_CHANNEL_RIGHT;
+#else
+ hInfo->channel_position[chpos++] = FRONT_CHANNEL_CENTER;
+ chdir--;
+#endif
+ }
+ 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:
+#if (defined(PS_DEC) || defined(DRM_PS))
+ /* When PS is enabled output is always stereo */
+ hInfo->num_front_channels = 2;
+ hInfo->channel_position[0] = FRONT_CHANNEL_LEFT;
+ hInfo->channel_position[1] = FRONT_CHANNEL_RIGHT;
+#else
+ hInfo->num_front_channels = 1;
+ hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
+#endif
+ 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;
+ }
+ }
+}
+
+void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hpDecoder,
+ NeAACDecFrameInfo *hInfo,
+ unsigned char *buffer,
+ unsigned long buffer_size)
+{
+ NeAACDecStruct* hDecoder = (NeAACDecStruct*)hpDecoder;
+ return aac_frame_decode(hDecoder, hInfo, buffer, buffer_size, NULL, 0);
+}
+
+void* NEAACDECAPI NeAACDecDecode2(NeAACDecHandle hpDecoder,
+ NeAACDecFrameInfo *hInfo,
+ unsigned char *buffer,
+ unsigned long buffer_size,
+ void **sample_buffer,
+ unsigned long sample_buffer_size)
+{
+ NeAACDecStruct* hDecoder = (NeAACDecStruct*)hpDecoder;
+ if ((sample_buffer == NULL) || (sample_buffer_size == 0)) {
+ hInfo->error = 27;
+ return NULL;
+ }
+
+ return aac_frame_decode(hDecoder, hInfo, buffer, buffer_size,
+ sample_buffer, sample_buffer_size);
+}
+
+#ifdef DRM
+
+#define ERROR_STATE_INIT 6
+
+static void conceal_output(NeAACDecStruct *hDecoder, uint16_t frame_len,
+ uint8_t out_ch, void *sample_buffer)
+{
+ return;
+}
+#endif
+
+static int multi_sub_frame(NeAACDecStruct *hDecoder)
+{
+#ifdef NEW_CODE_CHECK_LATM
+ int i_frame_size;
+ decoder_sys_t *p_sys = &hDecoder->dec_sys;
+
+ if (hDecoder->latm_header_present && p_sys->latm.i_sub_frames > 1)
+ return 1;
+#endif
+
+ return 0;
+}
+
+static void* aac_frame_decode(NeAACDecStruct *hDecoder,
+ NeAACDecFrameInfo *hInfo,
+ unsigned char *buffer,
+ unsigned long buffer_size,
+ void **sample_buffer2,
+ unsigned long sample_buffer_size)
+{
+ uint16_t i;
+ uint8_t channels = 0;
+ uint8_t output_channels = 0;
+ bitfile ld = {0};
+ uint32_t bitsconsumed;
+ uint16_t frame_len;
+ void *sample_buffer;
+ uint32_t startbit = 0, endbit = 0, payload_bits = 0;
+ int b_multi_sub_frame;
+ int mux_length = 0;
+#ifdef NEW_CODE_CHECK_LATM
+ int i_frame_size;
+ decoder_sys_t *p_sys = &hDecoder->dec_sys;
+#endif
+#ifdef PROFILE
+ int64_t count = faad_get_ts();
+#endif
+
+ /* safety checks */
+ if ((hDecoder == NULL) || (hInfo == NULL) || (buffer == NULL)) {
+ return NULL;
+ }
+
+ frame_len = hDecoder->frameLength;
+ memset(hInfo, 0, sizeof(NeAACDecFrameInfo));
+ memset(hDecoder->internal_channel, 0, MAX_CHANNELS * sizeof(hDecoder->internal_channel[0]));
+
+#ifdef USE_TIME_LIMIT
+ if ((TIME_LIMIT * get_sample_rate(hDecoder->sf_index)) > hDecoder->TL_count) {
+ hDecoder->TL_count += 1024;
+ } else {
+ hInfo->error = (NUM_ERROR_MESSAGES - 1);
+ goto error;
+ }
+#endif
+
+
+ /* check for some common metadata tag types in the bitstream
+ * No need to return an error
+ */
+ /* ID3 */
+ if (buffer_size >= 128) {
+ if (memcmp(buffer, "TAG", 3) == 0) {
+ /* found it */
+ hInfo->bytesconsumed = 128; /* 128 bytes fixed size */
+ /* no error, but no output either */
+ return NULL;
+ }
+ }
+#ifdef NEW_CODE_CHECK_LATM
+ if (buffer_size > sizeof(temp_bufer)) {
+ LATM_LOG("input buffer size tooo big %d, buffer size %d \n", buffer_size, sizeof(temp_bufer));
+ buffer_size = sizeof(temp_bufer);
+ }
+ if (buffer_size > 0) {
+ memcpy(temp_bufer, buffer, buffer_size);
+ temp_size = buffer_size;
+ buffer = temp_bufer;
+ }
+NEXT_CHECK:
+ if (hDecoder->latm_header_present) {
+ while (buffer_size >= 7) {
+ if (buffer[0] == 0x56 && (buffer[1] & 0xe0) == 0xe0) {
+
+ break;
+ }
+ buffer++;
+ buffer_size--;
+ }
+ if (buffer_size <= 2) {
+ LATM_LOG("check the loas frame failed\n");
+ return NULL;
+ }
+ /* Check if frame is valid and get frame info */
+ i_frame_size = ((buffer[1] & 0x1f) << 8) + buffer[2];
+ //LATM_LOG("i_frame_size %d \n",i_frame_size);
+ mux_length = i_frame_size + 3;
+ if (i_frame_size <= 0) {
+ LATM_LOG("i_frame_size error\n");
+ return NULL;
+ }
+ if (buffer_size < (LOAS_HEADER_SIZE + i_frame_size)) {
+ hInfo->error = 35;
+ LATM_LOG("buffer size small then frame size,need more data\n");
+ return NULL;
+ }
+#if 1
+ if (buffer[3 + i_frame_size] != 0x56 || (buffer[3 + i_frame_size + 1] & 0xe0) != 0xe0) {
+
+ LATM_LOG("emulated sync word (no sync on following frame) \n");
+ buffer++;
+ buffer_size--;
+ goto NEXT_CHECK;
+ }
+#endif
+ buffer += LOAS_HEADER_SIZE; //skip header
+ buffer_size = buffer_size - LOAS_HEADER_SIZE;
+ i_frame_size = LOASParse(buffer, i_frame_size, p_sys);
+ if (i_frame_size <= 0) {
+ goto NEXT_CHECK;
+ } else {
+ // LATM_LOG("latm detected\n");
+ }
+
+ }
+
+ b_multi_sub_frame = multi_sub_frame(hDecoder);
+
+ /* check if we want to use internal sample_buffer */
+ if (sample_buffer_size == 0 && b_multi_sub_frame) {
+ if (hDecoder->sample_buffer_all) {
+ faad_free(hDecoder->sample_buffer_all);
+ }
+ hDecoder->sample_buffer_all = NULL;
+ }
+#endif
+
+start_decode:
+
+ /* initialize the bitstream */
+ faad_initbits(&ld, buffer, buffer_size);
+
+#ifndef NEW_CODE_CHECK_LATM
+ if (hDecoder->latm_header_present) {
+ payload_bits = faad_latm_frame(&hDecoder->latm_config, &ld);
+ startbit = faad_get_processed_bits(&ld);
+ if (payload_bits == -1U) {
+ hInfo->error = 1;
+ goto error;
+ }
+ }
+#endif
+#ifdef DRM
+ if (hDecoder->object_type == DRM_ER_LC) {
+ /* We do not support stereo right now */
+ if (0) { //(hDecoder->channelConfiguration == 2)
+ hInfo->error = 28; // 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;
+ }
+ if (adts.aac_frame_length > buffer_size) {
+ hInfo->error = 35; //more data needed
+ audio_codec_print("decoder need more data for adts frame,frame len %d,have %d \n", adts.aac_frame_length, buffer_size);
+ if (adts.aac_frame_length > 6 * 768) {
+ audio_codec_print("adts frame len exceed aac spec \n");
+ hInfo->error = 36;//
+ goto error;
+
+ }
+ //here need return to get more input data for decoder
+ faad_endbits(&ld);
+ return NULL;
+ }
+ if (adts.sf_index >= 12 || adts.channel_configuration > 6) {
+ audio_codec_print("adts sf/ch error,sf %d,ch config %d \n", adts.sf_index, adts.channel_configuration);
+ hDecoder->sf_index = 3;
+ hInfo->error = 12;
+ goto error;
+ }
+ hDecoder->sf_index = adts.sf_index;
+ if (adts.sf_index != hDecoder->last_sf_index && adts.channel_configuration != hDecoder->last_ch_configure) {
+ if (adts.sf_index >= 0 && adts.sf_index < 12 && adts.channel_configuration > 0 && adts.channel_configuration <= 8) {
+ hInfo->error = 34;
+ audio_codec_print("[%s %d]last_sf_index/%d,Ch/%d,Now %d/%d\n", __FUNCTION__, __LINE__, hDecoder->last_sf_index, hDecoder->last_ch_configure, adts.sf_index, adts.channel_configuration);
+ hDecoder->last_sf_index = hDecoder->sf_index;
+ hDecoder->last_ch_configure = adts.channel_configuration;
+ goto error;
+ }
+ }
+ }
+
+#ifdef ANALYSIS
+ dbg_count = 0;
+#endif
+
+ /* decode the complete bitstream */
+#ifdef DRM
+ if (/*(hDecoder->object_type == 6) ||*/ (hDecoder->object_type == DRM_ER_LC)) {
+ DRM_aac_scalable_main_element(hDecoder, hInfo, &ld, &hDecoder->pce, hDecoder->drc);
+ } else {
+#endif
+ raw_data_block(hDecoder, hInfo, &ld, &hDecoder->pce, hDecoder->drc);
+#ifdef DRM
+ }
+#endif
+#ifndef NEW_CODE_CHECK_LATM
+ if (hDecoder->latm_header_present) {
+ endbit = faad_get_processed_bits(&ld);
+ if (endbit - startbit > payload_bits)
+ DEBUG("[%s %d]ERROR, too many payload bits read: %u > %d. Please. report with a link to a sample\n",
+ __FUNCTION__, __LINE__, endbit - startbit, payload_bits);
+ if (hDecoder->latm_config.otherDataLenBits > 0) {
+ faad_getbits(&ld, hDecoder->latm_config.otherDataLenBits);
+ }
+ faad_byte_align(&ld);
+ }
+#endif
+
+ channels = hDecoder->fr_channels;
+
+ if (hInfo->error > 0) {
+ goto error;
+ }
+
+ /* safety check */
+ if (channels == 0 || channels > MAX_CHANNELS) {
+ DEBUG("[%s %d]invalid Channels/%d\n", __FUNCTION__, __LINE__, channels);
+ hInfo->error = 12;
+ goto error;
+ }
+
+ /* no more bit reading after this */
+ bitsconsumed = faad_get_processed_bits(&ld);
+ hInfo->bytesconsumed = bit2byte(bitsconsumed);
+ if (mux_length && hDecoder->latm_header_present && !ld.error) {
+ if (p_sys->latm.i_sub_frames <= 1)
+ hInfo->bytesconsumed = mux_length;
+ }
+ if (ld.error) {
+ hInfo->error = 14;
+ goto error;
+ }
+ faad_endbits(&ld);
+
+
+ if (!hDecoder->adts_header_present && !hDecoder->adif_header_present
+#if 1
+ && !hDecoder->latm_header_present
+#endif
+ ) {
+ 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 (channels == 6 || channels == 4) {
+ output_channels = 2;
+ } else if (channels == 3 && hDecoder->config.downMatrix) {
+ 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 */
+ 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 1
+ if (hDecoder->latm_header_present) {
+ hInfo->header_type = LATM;
+ }
+#endif
+#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->sample_buffer == NULL) ||
+ (hDecoder->alloced_channels != output_channels)) {
+ static const uint8_t str[] = { sizeof(int16_t), sizeof(int32_t), sizeof(int32_t),
+ sizeof(float32_t), sizeof(double), sizeof(int16_t), sizeof(int16_t),
+ sizeof(int16_t), sizeof(int16_t), 0, 0, 0
+ };
+ uint8_t stride = str[hDecoder->config.outputFormat - 1];
+#ifdef SBR_DEC
+ if (((hDecoder->sbr_present_flag == 1) && (!hDecoder->downSampledSBR)) || (hDecoder->forceUpSampling == 1)) {
+ stride = 2 * stride;
+ }
+#endif
+ /* check if we want to use internal sample_buffer */
+ if (sample_buffer_size == 0) {
+ if (hDecoder->sample_buffer) {
+ faad_free(hDecoder->sample_buffer);
+ }
+ hDecoder->sample_buffer = NULL;
+ hDecoder->sample_buffer = faad_malloc(frame_len * output_channels * stride);
+ } else if (sample_buffer_size < frame_len * output_channels * stride) {
+ /* provided sample buffer is not big enough */
+ hInfo->error = 27;
+ return NULL;
+ }
+ hDecoder->alloced_channels = output_channels;
+ }
+
+ if (sample_buffer_size == 0) {
+ sample_buffer = hDecoder->sample_buffer;
+ } else {
+ sample_buffer = *sample_buffer2;
+ }
+
+#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
+
+ if (b_multi_sub_frame && sample_buffer_size == 0 &&
+ hDecoder->sample_buffer_all == NULL) {
+
+ hDecoder->sample_buffer_all = faad_malloc(p_sys->latm.i_sub_frames * hInfo->samples * 2);
+ }
+
+ sample_buffer = output_to_PCM(hDecoder, hDecoder->time_out, sample_buffer,
+ output_channels, frame_len, hDecoder->config.outputFormat);
+
+ if (b_multi_sub_frame && i_frame_size > 0 && sample_buffer_size == 0) {
+
+ memcpy(hDecoder->sample_buffer_all,sample_buffer,hInfo->samples * 2);
+ hDecoder->sample_buffer_all += hInfo->samples * 2;
+ i_frame_size -= hInfo->bytesconsumed;
+ buffer += hInfo->bytesconsumed;
+ buffer_size -= hInfo->bytesconsumed;
+ if (i_frame_size > 0)
+ goto start_decode;
+ }
+
+ if (b_multi_sub_frame && sample_buffer_size == 0) {
+ // calculate all sub_frames as one samples
+ hInfo->samples = hInfo->samples * p_sys->latm.i_sub_frames;
+ hDecoder->sample_buffer_all -= hInfo->samples * 2;
+ hInfo->bytesconsumed = mux_length;
+ return hDecoder->sample_buffer_all;
+ }
+
+
+#ifdef DRM
+ //conceal_output(hDecoder, frame_len, output_channels, sample_buffer);
+#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
+
+#ifdef USE_HELIX_AAC_DECODER
+ /* Channel definitions */
+#define FRONT_CENTER (0)
+#define FRONT_LEFT (1)
+#define FRONT_RIGHT (2)
+#define SIDE_LEFT (3)
+#define SIDE_RIGHT (4)
+#define BACK_LEFT (5)
+#define LFE_CHANNEL (6)
+
+ if (hDecoder->latm_header_present && !hInfo->error) {
+ unsigned char *dec_buf = buffer;
+ int dec_size = hInfo->bytesconsumed ;
+ int err;
+ int ch_num;
+ int sample_out;
+ int sum;
+ unsigned ch_map_scale[6] = {2, 4, 4, 2, 2, 0}; //full scale == 8
+ short *ouput = dec_buffer;
+ unsigned char adts_header[7];
+ unsigned char *pbuf = NULL;
+ unsigned char *inbuf = NULL;
+#ifdef PS_DEC
+ if (hDecoder->ps_used_global) {
+ // LATM_LOG("decoder ps channel %d \n",channels);
+ if (channels == 2) {
+ channels = 1;
+ }
+ }
+#endif
+ MakeAdtsHeader(hInfo, adts_header, channels);
+ pbuf = malloc(7 + dec_size);
+ if (!pbuf) {
+ LATM_LOG("malloc decoder buffer failed %d \n", dec_size);
+ return NULL;
+ }
+ dec_size += 7;
+ memcpy(pbuf, adts_header, 7);
+ memcpy(pbuf + 7, buffer, hInfo->bytesconsumed);
+ inbuf = pbuf;
+ err = AACDecode(hAACDecoder, &inbuf, &dec_size, dec_buffer);
+ if (pbuf) {
+ free(pbuf);
+ pbuf = NULL;
+ }
+ if (err == 0) {
+ AACFrameInfo aacFrameInfo = {0};
+ AACGetLastFrameInfo(hAACDecoder, &aacFrameInfo);
+ hInfo->error = 0;
+ hInfo->bytesconsumed = mux_length;
+ hInfo->channels = aacFrameInfo.nChans > 2 ? 2 : aacFrameInfo.nChans;
+ hInfo->samplerate = aacFrameInfo.sampRateOut;;
+ if (aacFrameInfo.nChans > 2) { //should do downmix to 2ch output.
+ ch_num = aacFrameInfo.nChans;
+ sample_out = aacFrameInfo.outputSamps / ch_num * 2 * 2; //ch_num*sample_num*16bit
+ if (ch_num == 3 || ch_num == 4) {
+ ch_map_scale[0] = 4; //50%
+ ch_map_scale[1] = 4;//50%
+ ch_map_scale[2] = 4;//50%
+ ch_map_scale[3] = 0;
+ ch_map_scale[4] = 0;
+ ch_map_scale[5] = 0;
+ }
+ for (i = 0; i < aacFrameInfo.outputSamps / ch_num; i++) {
+ if (ch_num == 5 || ch_num == 6) {
+ output_buffer[i * 2] = ((int)(ouput[ch_num * i + FRONT_LEFT]) +
+ ((int)((((int)ouput[ch_num * i + FRONT_CENTER]) -
+ ((int)ouput[ch_num * i + SIDE_LEFT]) -
+ ((int)ouput[ch_num * i + SIDE_RIGHT])) * 707 / 1000)));
+ output_buffer[2 * i + 1] = ((int)(ouput[ch_num * i + FRONT_RIGHT]) +
+ ((int)((((int)ouput[ch_num * i + FRONT_CENTER]) +
+ ((int)ouput[ch_num * i + SIDE_LEFT]) +
+ ((int)ouput[ch_num * i + SIDE_RIGHT])) * 707 / 1000)));
+ } else {
+ sum = ((int)ouput[ch_num * i + FRONT_LEFT] * ch_map_scale[FRONT_LEFT] + (int)ouput[ch_num * i + FRONT_CENTER] * ch_map_scale[FRONT_CENTER] + (int)ouput[ch_num * i + BACK_LEFT] * ch_map_scale[BACK_LEFT]);
+ output_buffer[i * 2] = sum >> 3;
+ sum = ((int)ouput[ch_num * i + FRONT_RIGHT] * ch_map_scale[FRONT_RIGHT] + (int)ouput[ch_num * i + FRONT_CENTER] * ch_map_scale[FRONT_CENTER] + (int)ouput[ch_num * i + BACK_LEFT] * ch_map_scale[BACK_LEFT]);
+ output_buffer[2 * i + 1] = sum >> 3;
+ }
+ }
+ } else {
+ sample_out = aacFrameInfo.outputSamps * 2; //ch_num*sample_num*16bit
+ memcpy(output_buffer, dec_buffer, sample_out);
+
+ }
+ hInfo->samples = sample_out / 2;
+ return output_buffer;
+
+ } else {
+ LATM_LOG("decoder error id %d \n", err);
+ hInfo->error = err > 0 ? err : -err;
+ return NULL;
+ }
+ }
+#endif
+ return sample_buffer;
+
+error:
+
+
+#ifdef DRM
+ hDecoder->error_state = ERROR_STATE_INIT;
+#endif
+
+ /* reset filterbank state */
+ for (i = 0; i < MAX_CHANNELS; i++) {
+ if (hDecoder->fb_intermed[i] != NULL) {
+ memset(hDecoder->fb_intermed[i], 0, hDecoder->frameLength * sizeof(real_t));
+ }
+ }
+#ifdef SBR_DEC
+ for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++) {
+ if (hDecoder->sbr[i] != NULL) {
+ sbrReset(hDecoder->sbr[i]);
+ }
+ }
+#endif
+ faad_endbits(&ld);
+ /* cleanup */
+#ifdef ANALYSIS
+ fflush(stdout);
+#endif
+
+ return NULL;
+}
+
+int is_latm_aac(NeAACDecHandle hpDecoder)
+{
+ NeAACDecStruct* hDecoder = (NeAACDecStruct*)hpDecoder;
+ return hDecoder->latm_header_present;
+
+}
+
diff --git a/audio_codec/libfaad/drc.c b/audio_codec/libfaad/drc.c
new file mode 100644
index 0000000..55b4483
--- a/dev/null
+++ b/audio_codec/libfaad/drc.c
@@ -0,0 +1,173 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: drc.c,v 1.28 2007/11/01 12:33:30 menno Exp $
+**/
+#include <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+#include <string.h>
+#include "syntax.h"
+#include "drc.h"
+
+drc_info *drc_init(real_t cut, real_t boost)
+{
+ drc_info *drc = (drc_info*)faad_malloc(sizeof(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;
+}
+
+void drc_end(drc_info *drc)
+{
+ if (drc) {
+ faad_free(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/audio_codec/libfaad/drc.h b/audio_codec/libfaad/drc.h
new file mode 100644
index 0000000..c8e6b45
--- a/dev/null
+++ b/audio_codec/libfaad/drc.h
@@ -0,0 +1,49 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: drc.h,v 1.22 2007/11/01 12:33:30 menno Exp $
+**/
+
+#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_end(drc_info *drc);
+ void drc_decode(drc_info *drc, real_t *spec);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/audio_codec/libfaad/drm_dec.c b/audio_codec/libfaad/drm_dec.c
new file mode 100644
index 0000000..cc7dc5c
--- a/dev/null
+++ b/audio_codec/libfaad/drm_dec.c
@@ -0,0 +1,912 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: drm_dec.c,v 1.9 2007/11/01 12:33:30 menno Exp $
+**/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#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 definitaions */
+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] = {
+ 0, 1, 2, 3, 5, 7, 10, 13, 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[3] = {
+ 3, 4, 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 = FRAC_CONST(0.76592833836465);
+
+static const real_t smooth_coeff = 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 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) {
+ /* wait until we get a DT frame */
+ ps->bs_enable_sa = 0;
+ } else if (ps->bs_sa_dt_flag) {
+ /* DT frame, we have a last frame, so we can decode */
+ ps->g_sa_index[0] = sa_delta_clip(ps, ps->g_prev_sa_index[0] + ps->bs_sa_data[0]);
+ } else {
+ /* DF always decodable */
+ 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_last_had_sa) {
+ ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_prev_sa_index[band] + ps->bs_sa_data[band]);
+ } else if (!ps->bs_sa_dt_flag) {
+ 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) {
+ ps->bs_enable_pan = 0;
+ } else 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_last_had_pan) {
+ ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_prev_pan_index[band] + ps->bs_pan_data[band]);
+ } else if (!ps->bs_pan_dt_flag) {
+ 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[38][64])
+{
+ 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]; 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);
+ 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);
+ ps->prev_peakdiff[b] = peakdiff;
+
+ nrg = ps->prev_nrg[b];
+ nrg += MUL_F((power - ps->prev_nrg[b]), smooth_coeff);
+ 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]) {
+ 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, qmf_t X_left[38][64], qmf_t X_right[38][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]; 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]; 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]; 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, qmf_t X_left[38][64], qmf_t X_right[38][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 = (drm_ps_info*)faad_malloc(sizeof(drm_ps_info));
+
+ memset(ps, 0, sizeof(drm_ps_info));
+
+ return ps;
+}
+
+void drm_ps_free(drm_ps_info *ps)
+{
+ faad_free(ps);
+}
+
+/* main DRM PS decoding function */
+uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, qmf_t X_left[38][64], qmf_t X_right[38][64])
+{
+ 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);
+ drm_add_ambiance(ps, 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, 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/audio_codec/libfaad/drm_dec.h b/audio_codec/libfaad/drm_dec.h
new file mode 100644
index 0000000..95b06e1
--- a/dev/null
+++ b/audio_codec/libfaad/drm_dec.h
@@ -0,0 +1,99 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: drm_dec.h,v 1.8 2007/11/01 12:33:30 menno Exp $
+**/
+
+#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);
+ void drm_ps_free(drm_ps_info *ps);
+
+ uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, qmf_t X_left[38][64], qmf_t X_right[38][64]);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/audio_codec/libfaad/error.c b/audio_codec/libfaad/error.c
new file mode 100644
index 0000000..f048c30
--- a/dev/null
+++ b/audio_codec/libfaad/error.c
@@ -0,0 +1,72 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: error.c,v 1.33 2008/09/19 23:31:39 menno Exp $
+**/
+
+#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",
+ "CRC error in DRM data",
+ "PNS not allowed in DRM data stream",
+ "No standard extension payload allowed in DRM",
+ "PCE shall be the first element in a frame",
+ "Bitstream value not allowed by specification",
+ "MAIN prediction not initialised",
+ "channel cofigure and sample rate changed ",
+ " more data needed",
+};
+
diff --git a/audio_codec/libfaad/error.h b/audio_codec/libfaad/error.h
new file mode 100644
index 0000000..36d2d47
--- a/dev/null
+++ b/audio_codec/libfaad/error.h
@@ -0,0 +1,44 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: error.h,v 1.27 2008/09/19 23:31:40 menno Exp $
+**/
+
+#ifndef __ERROR_H__
+#define __ERROR_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NUM_ERROR_MESSAGES 36
+ extern char *err_msg[];
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/audio_codec/libfaad/filtbank.c b/audio_codec/libfaad/filtbank.c
new file mode 100644
index 0000000..c115c51
--- a/dev/null
+++ b/audio_codec/libfaad/filtbank.c
@@ -0,0 +1,408 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: filtbank.c,v 1.46 2009/01/26 23:51:15 menno Exp $
+**/
+#include <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+#include <string.h>
+#ifdef _WIN32_WCE
+#define assert(x)
+#else
+#include <assert.h>
+#endif
+
+#include "filtbank.h"
+#include "syntax.h"
+#include "kbd_win.h"
+#include "sine_win.h"
+#include "mdct.h"
+
+
+fb_info *filter_bank_init(uint16_t frame_len)
+{
+ uint16_t nshort = frame_len / 8;
+#ifdef LD_DEC
+ uint16_t frame_len_ld = frame_len / 2;
+#endif
+
+ fb_info *fb = (fb_info*)faad_malloc(sizeof(fb_info));
+ memset(fb, 0, sizeof(fb_info));
+
+ /* normal */
+ fb->mdct256 = faad_mdct_init(2 * nshort);
+ fb->mdct2048 = faad_mdct_init(2 * frame_len);
+#ifdef LD_DEC
+ /* LD */
+ fb->mdct1024 = faad_mdct_init(2 * frame_len_ld);
+#endif
+
+#ifdef ALLOW_SMALL_FRAMELENGTH
+ if (frame_len == 1024) {
+#endif
+ fb->long_window[0] = sine_long_1024;
+ fb->short_window[0] = sine_short_128;
+ fb->long_window[1] = kbd_long_1024;
+ fb->short_window[1] = kbd_short_128;
+#ifdef LD_DEC
+ fb->ld_window[0] = sine_mid_512;
+ fb->ld_window[1] = ld_mid_512;
+#endif
+#ifdef ALLOW_SMALL_FRAMELENGTH
+ } else /* (frame_len == 960) */ {
+ fb->long_window[0] = sine_long_960;
+ fb->short_window[0] = sine_short_120;
+ fb->long_window[1] = kbd_long_960;
+ fb->short_window[1] = kbd_short_120;
+#ifdef LD_DEC
+ fb->ld_window[0] = sine_mid_480;
+ fb->ld_window[1] = ld_mid_480;
+#endif
+ }
+#endif
+
+ return fb;
+}
+
+void filter_bank_end(fb_info *fb)
+{
+ if (fb != NULL) {
+#ifdef PROFILE
+ printf("FB: %I64d cycles\n", fb->cycles);
+#endif
+
+ faad_mdct_end(fb->mdct256);
+ faad_mdct_end(fb->mdct2048);
+#ifdef LD_DEC
+ faad_mdct_end(fb->mdct1024);
+#endif
+
+ faad_free(fb);
+ }
+}
+
+static INLINE void imdct_long(fb_info *fb, real_t *in_data, real_t *out_data, uint16_t len)
+{
+#ifdef LD_DEC
+ mdct_info *mdct = NULL;
+
+ switch (len) {
+ case 2048:
+ case 1920:
+ mdct = fb->mdct2048;
+ break;
+ case 1024:
+ case 960:
+ mdct = fb->mdct1024;
+ break;
+ }
+
+ faad_imdct(mdct, in_data, out_data);
+#else
+ faad_imdct(fb->mdct2048, in_data, out_data);
+#endif
+}
+
+
+#ifdef LTP_DEC
+static INLINE void mdct(fb_info *fb, real_t *in_data, real_t *out_data, uint16_t len)
+{
+ mdct_info *mdct = NULL;
+
+ switch (len) {
+ case 2048:
+ case 1920:
+ mdct = fb->mdct2048;
+ 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(fb_info *fb, 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)
+{
+ int16_t i;
+ ALIGN real_t transf_buf[2 * 1024] = {0};
+
+ 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 trans = nshort / 2;
+
+ uint16_t nflat_ls = (nlong - nshort) / 2;
+
+#ifdef PROFILE
+ int64_t count = faad_get_ts();
+#endif
+
+ /* 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 {
+#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
+
+#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 */
+ imdct_long(fb, freq_in, transf_buf, 2 * nlong);
+
+ /* add second half output of previous frame to windowed output of current frame */
+ for (i = 0; i < nlong; i += 4) {
+ time_out[i] = overlap[i] + MUL_F(transf_buf[i], window_long_prev[i]);
+ time_out[i + 1] = overlap[i + 1] + MUL_F(transf_buf[i + 1], window_long_prev[i + 1]);
+ time_out[i + 2] = overlap[i + 2] + MUL_F(transf_buf[i + 2], window_long_prev[i + 2]);
+ time_out[i + 3] = overlap[i + 3] + MUL_F(transf_buf[i + 3], window_long_prev[i + 3]);
+ }
+
+ /* window the second half and save as overlap for next frame */
+ for (i = 0; i < nlong; i += 4) {
+ overlap[i] = MUL_F(transf_buf[nlong + i], window_long[nlong - 1 - i]);
+ overlap[i + 1] = MUL_F(transf_buf[nlong + i + 1], window_long[nlong - 2 - i]);
+ overlap[i + 2] = MUL_F(transf_buf[nlong + i + 2], window_long[nlong - 3 - i]);
+ overlap[i + 3] = MUL_F(transf_buf[nlong + i + 3], window_long[nlong - 4 - i]);
+ }
+ break;
+
+ case LONG_START_SEQUENCE:
+ /* perform iMDCT */
+ imdct_long(fb, freq_in, transf_buf, 2 * nlong);
+
+ /* add second half output of previous frame to windowed output of current frame */
+ for (i = 0; i < nlong; i += 4) {
+ time_out[i] = overlap[i] + MUL_F(transf_buf[i], window_long_prev[i]);
+ time_out[i + 1] = overlap[i + 1] + MUL_F(transf_buf[i + 1], window_long_prev[i + 1]);
+ time_out[i + 2] = overlap[i + 2] + MUL_F(transf_buf[i + 2], window_long_prev[i + 2]);
+ time_out[i + 3] = overlap[i + 3] + MUL_F(transf_buf[i + 3], window_long_prev[i + 3]);
+ }
+
+ /* window the second half and save as overlap for next frame */
+ /* construct second half window using padding with 1's and 0's */
+ for (i = 0; i < nflat_ls; i++) {
+ overlap[i] = transf_buf[nlong + i];
+ }
+ for (i = 0; i < nshort; i++) {
+ overlap[nflat_ls + i] = MUL_F(transf_buf[nlong + nflat_ls + i], window_short[nshort - i - 1]);
+ }
+ for (i = 0; i < nflat_ls; i++) {
+ overlap[nflat_ls + nshort + i] = 0;
+ }
+ break;
+
+ case EIGHT_SHORT_SEQUENCE:
+ /* perform iMDCT for each short block */
+ faad_imdct(fb->mdct256, freq_in + 0 * nshort, transf_buf + 2 * nshort * 0);
+ faad_imdct(fb->mdct256, freq_in + 1 * nshort, transf_buf + 2 * nshort * 1);
+ faad_imdct(fb->mdct256, freq_in + 2 * nshort, transf_buf + 2 * nshort * 2);
+ faad_imdct(fb->mdct256, freq_in + 3 * nshort, transf_buf + 2 * nshort * 3);
+ faad_imdct(fb->mdct256, freq_in + 4 * nshort, transf_buf + 2 * nshort * 4);
+ faad_imdct(fb->mdct256, freq_in + 5 * nshort, transf_buf + 2 * nshort * 5);
+ faad_imdct(fb->mdct256, freq_in + 6 * nshort, transf_buf + 2 * nshort * 6);
+ faad_imdct(fb->mdct256, freq_in + 7 * nshort, transf_buf + 2 * nshort * 7);
+
+ /* add second half output of previous frame to windowed output of current frame */
+ for (i = 0; i < nflat_ls; i++) {
+ time_out[i] = overlap[i];
+ }
+ for (i = 0; i < nshort; i++) {
+ time_out[nflat_ls + i] = overlap[nflat_ls + i] + MUL_F(transf_buf[nshort * 0 + i], window_short_prev[i]);
+ time_out[nflat_ls + 1 * nshort + i] = overlap[nflat_ls + nshort * 1 + i] + MUL_F(transf_buf[nshort * 1 + i], window_short[nshort - 1 - i]) + MUL_F(transf_buf[nshort * 2 + i], window_short[i]);
+ time_out[nflat_ls + 2 * nshort + i] = overlap[nflat_ls + nshort * 2 + i] + MUL_F(transf_buf[nshort * 3 + i], window_short[nshort - 1 - i]) + MUL_F(transf_buf[nshort * 4 + i], window_short[i]);
+ time_out[nflat_ls + 3 * nshort + i] = overlap[nflat_ls + nshort * 3 + i] + MUL_F(transf_buf[nshort * 5 + i], window_short[nshort - 1 - i]) + MUL_F(transf_buf[nshort * 6 + i], window_short[i]);
+ if (i < trans) {
+ time_out[nflat_ls + 4 * nshort + i] = overlap[nflat_ls + nshort * 4 + i] + MUL_F(transf_buf[nshort * 7 + i], window_short[nshort - 1 - i]) + MUL_F(transf_buf[nshort * 8 + i], window_short[i]);
+ }
+ }
+
+ /* window the second half and save as overlap for next frame */
+ for (i = 0; i < nshort; i++) {
+ if (i >= trans) {
+ overlap[nflat_ls + 4 * nshort + i - nlong] = MUL_F(transf_buf[nshort * 7 + i], window_short[nshort - 1 - i]) + MUL_F(transf_buf[nshort * 8 + i], window_short[i]);
+ }
+ overlap[nflat_ls + 5 * nshort + i - nlong] = MUL_F(transf_buf[nshort * 9 + i], window_short[nshort - 1 - i]) + MUL_F(transf_buf[nshort * 10 + i], window_short[i]);
+ overlap[nflat_ls + 6 * nshort + i - nlong] = MUL_F(transf_buf[nshort * 11 + i], window_short[nshort - 1 - i]) + MUL_F(transf_buf[nshort * 12 + i], window_short[i]);
+ overlap[nflat_ls + 7 * nshort + i - nlong] = MUL_F(transf_buf[nshort * 13 + i], window_short[nshort - 1 - i]) + MUL_F(transf_buf[nshort * 14 + i], window_short[i]);
+ overlap[nflat_ls + 8 * nshort + i - nlong] = MUL_F(transf_buf[nshort * 15 + i], window_short[nshort - 1 - i]);
+ }
+ for (i = 0; i < nflat_ls; i++) {
+ overlap[nflat_ls + nshort + i] = 0;
+ }
+ break;
+
+ case LONG_STOP_SEQUENCE:
+ /* perform iMDCT */
+ imdct_long(fb, freq_in, transf_buf, 2 * nlong);
+
+ /* 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 */
+ for (i = 0; i < nflat_ls; i++) {
+ time_out[i] = overlap[i];
+ }
+ for (i = 0; i < nshort; i++) {
+ time_out[nflat_ls + i] = overlap[nflat_ls + i] + MUL_F(transf_buf[nflat_ls + i], window_short_prev[i]);
+ }
+ for (i = 0; i < nflat_ls; i++) {
+ time_out[nflat_ls + nshort + i] = overlap[nflat_ls + nshort + i] + transf_buf[nflat_ls + nshort + i];
+ }
+
+ /* window the second half and save as overlap for next frame */
+ for (i = 0; i < nlong; i++) {
+ overlap[i] = MUL_F(transf_buf[nlong + i], window_long[nlong - 1 - i]);
+ }
+ 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;
+ ALIGN real_t windowed_buf[2 * 1024] = {0};
+
+ 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);
+
+#ifdef LD_DEC
+ if (object_type == LD) {
+ window_long = fb->ld_window[window_shape];
+ window_long_prev = fb->ld_window[window_shape_prev];
+ } else {
+#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/audio_codec/libfaad/filtbank.h b/audio_codec/libfaad/filtbank.h
new file mode 100644
index 0000000..bddc2ab
--- a/dev/null
+++ b/audio_codec/libfaad/filtbank.h
@@ -0,0 +1,61 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: filtbank.h,v 1.27 2007/11/01 12:33:30 menno Exp $
+**/
+
+#ifndef __FILTBANK_H__
+#define __FILTBANK_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+ fb_info *filter_bank_init(uint16_t frame_len);
+ void filter_bank_end(fb_info *fb);
+
+#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(fb_info *fb, 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/audio_codec/libfaad/fixed.h b/audio_codec/libfaad/fixed.h
new file mode 100644
index 0000000..20f45cf
--- a/dev/null
+++ b/audio_codec/libfaad/fixed.h
@@ -0,0 +1,287 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: fixed.h,v 1.32 2007/11/01 12:33:30 menno Exp $
+**/
+
+#ifndef __FIXED_H__
+#define __FIXED_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(_WIN32_WCE) && defined(_ARM_)
+#include <cmnintrin.h>
+#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 REAL_CONST(A) (((A) >= 0) ? ((real_t)((A)*(REAL_PRECISION)+0.5)) : ((real_t)((A)*(REAL_PRECISION)-0.5)))
+#define COEF_CONST(A) (((A) >= 0) ? ((real_t)((A)*(COEF_PRECISION)+0.5)) : ((real_t)((A)*(COEF_PRECISION)-0.5)))
+#define FRAC_CONST(A) (((A) == 1.00) ? ((real_t)FRAC_MAX) : (((A) >= 0) ? ((real_t)((A)*(FRAC_PRECISION)+0.5)) : ((real_t)((A)*(FRAC_PRECISION)-0.5))))
+ //#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) (((A) >= 0) ? ((real_t)((A)*(Q2_PRECISION)+0.5)) : ((real_t)((A)*(Q2_PRECISION)-0.5)))
+
+#if defined(_WIN32) && !defined(_WIN32_WCE)
+
+ /* multiply with real shift */
+ static INLINE real_t MUL_R(real_t A, real_t B)
+ {
+ _asm {
+ mov eax, A
+ imul B
+ shrd eax, edx, REAL_BITS
+ }
+ }
+
+ /* multiply with coef shift */
+ static INLINE real_t MUL_C(real_t A, real_t B)
+ {
+ _asm {
+ mov eax, A
+ imul B
+ shrd eax, edx, COEF_BITS
+ }
+ }
+
+ static INLINE real_t MUL_Q2(real_t A, real_t B)
+ {
+ _asm {
+ mov eax, A
+ imul B
+ shrd eax, edx, Q2_BITS
+ }
+ }
+
+ static INLINE real_t MUL_SHIFT6(real_t A, real_t B)
+ {
+ _asm {
+ mov eax, A
+ imul B
+ shrd eax, edx, 6
+ }
+ }
+
+ static INLINE real_t MUL_SHIFT23(real_t A, real_t B)
+ {
+ _asm {
+ mov eax, A
+ imul B
+ shrd eax, edx, 23
+ }
+ }
+
+#if 1
+ static INLINE real_t _MulHigh(real_t A, real_t B)
+ {
+ _asm {
+ mov eax, A
+ imul B
+ mov eax, edx
+ }
+ }
+
+ /* multiply with fractional shift */
+ 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)
+ {
+ *y1 = (_MulHigh(x1, c1) + _MulHigh(x2, c2)) << (FRAC_SIZE - FRAC_BITS);
+ *y2 = (_MulHigh(x2, c1) - _MulHigh(x1, c2)) << (FRAC_SIZE - FRAC_BITS);
+ }
+#else
+ static INLINE real_t MUL_F(real_t A, real_t B)
+ {
+ _asm {
+ mov eax, A
+ imul B
+ shrd eax, edx, 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)
+ {
+ *y1 = MUL_F(x1, c1) + MUL_F(x2, c2);
+ *y2 = MUL_F(x2, c1) - MUL_F(x1, c2);
+ }
+#endif
+
+#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 MUL_SHIFT6(real_t A, real_t B)
+ {
+ return arm_mul(A, B, 6);
+ }
+
+ static INLINE real_t MUL_SHIFT23(real_t A, real_t B)
+ {
+ return arm_mul(A, B, 23);
+ }
+
+ 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
+#ifdef __BFIN__
+#define _MulHigh(X,Y) ({ int __xxo; \
+ asm ( \
+ "a1 = %2.H * %1.L (IS,M);\n\t" \
+ "a0 = %1.H * %2.H, a1+= %1.H * %2.L (IS,M);\n\t"\
+ "a1 = a1 >>> 16;\n\t" \
+ "%0 = (a0 += a1);\n\t" \
+ : "=d" (__xxo) : "d" (X), "d" (Y) : "A0","A1"); __xxo; })
+
+#define MUL_F(X,Y) ({ int __xxo; \
+ asm ( \
+ "a1 = %2.H * %1.L (M);\n\t" \
+ "a0 = %1.H * %2.H, a1+= %1.H * %2.L (M);\n\t" \
+ "a1 = a1 >>> 16;\n\t" \
+ "%0 = (a0 += a1);\n\t" \
+ : "=d" (__xxo) : "d" (X), "d" (Y) : "A0","A1"); __xxo; })
+#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
+#endif
+#define MUL_Q2(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (Q2_BITS-1))) >> Q2_BITS)
+#define MUL_SHIFT6(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (6-1))) >> 6)
+#define MUL_SHIFT23(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (23-1))) >> 23)
+
+ /* 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/audio_codec/libfaad/hcr.c b/audio_codec/libfaad/hcr.c
new file mode 100644
index 0000000..db3faee
--- a/dev/null
+++ b/audio_codec/libfaad/hcr.c
@@ -0,0 +1,422 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: hcr.c,v 1.26 2009/01/26 23:51:15 menno Exp $
+**/
+#include <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+#include <string.h>
+
+#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;
+}
+
+static 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;
+}
+
+static 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;
+ }
+}
+
+static 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(NeAACDecStruct *hDecoder, ic_stream *ics,
+ bitfile *ld, int16_t *spectral_data)
+{
+ uint16_t PCWs_done;
+ uint16_t numberOfSegments, numberOfSets, numberOfCodewords;
+
+ codeword_t codeword[512];
+ bits_t segment[512];
+
+ uint16_t sp_offset[8];
+ uint16_t g, i, sortloop, set, bitsread;
+ uint16_t bitsleft, codewordsleft;
+ 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 < (min(ics->swb_offset[sfb + 1], ics->swb_offset_max) - 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]);
+ }
+ }
+
+#if 0 // Seems to give false errors
+ bitsleft = 0;
+
+ for (i = 0; i < numberOfSegments && !bitsleft; i++) {
+ bitsleft += segment[i].len;
+ }
+
+ if (bitsleft) {
+ return 10;
+ }
+
+ codewordsleft = 0;
+
+ for (i = 0; (i < numberOfCodewords - numberOfSegments) && (!codewordsleft); i++)
+ if (!codeword[i].decoded) {
+ codewordsleft++;
+ }
+
+ if (codewordsleft) {
+ return 10;
+ }
+#endif
+
+
+ return 0;
+
+}
+#endif
diff --git a/audio_codec/libfaad/helixaac/aaccommon.h b/audio_codec/libfaad/helixaac/aaccommon.h
new file mode 100644
index 0000000..ab900b7
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/aaccommon.h
@@ -0,0 +1,210 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aaccommon.h,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * aaccommon.h - implementation-independent API's, datatypes, and definitions
+ **************************************************************************************/
+
+#ifndef _AACCOMMON_H
+#define _AACCOMMON_H
+
+#include "aacdec.h"
+#include "statname.h"
+
+#include <android/log.h>
+#include <stdio.h>
+#include <stdarg.h>
+//#include <string.h>
+#define LOG_TAG "FaadDecoder"
+#define audio_codec_print(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define printk audio_codec_print
+#define LOCAL /*inline*/
+
+/* 12-bit syncword */
+#define SYNCWORDH 0xff
+#define SYNCWORDL 0xf0
+
+#define SYNCWORD0 0x67
+#define SYNCWORD1 0x89
+
+#define MAX_NCHANS_ELEM 2// /* max number of channels in any single bitstream element (SCE,CPE,CCE,LFE) */
+
+#define ADTS_HEADER_BYTES 7
+#define NUM_SAMPLE_RATES 12
+#define NUM_DEF_CHAN_MAPS 8
+#define NUM_ELEMENTS 8
+#define MAX_NUM_PCE_ADIF 16
+
+#define MAX_WIN_GROUPS 8
+#define MAX_SFB_SHORT 15
+#define MAX_SF_BANDS (MAX_SFB_SHORT*MAX_WIN_GROUPS) /* worst case = 15 sfb's * 8 windows for short block */
+#define MAX_MS_MASK_BYTES ((MAX_SF_BANDS + 7) >> 3)
+#define MAX_PRED_SFB 41
+#define MAX_TNS_FILTERS 8
+#define MAX_TNS_COEFS 60
+#define MAX_TNS_ORDER 20
+#define MAX_PULSES 4
+#define MAX_GAIN_BANDS 3
+#define MAX_GAIN_WIN 8
+#define MAX_GAIN_ADJUST 7
+
+#define NSAMPS_LONG 1024
+#define NSAMPS_SHORT 128
+
+#define NUM_SYN_ID_BITS 3
+#define NUM_INST_TAG_BITS 4
+
+#define EXT_SBR_DATA 0x0d
+#define EXT_SBR_DATA_CRC 0x0e
+
+#define IS_ADIF(p) ((p)[0] == 'A' && (p)[1] == 'D' && (p)[2] == 'I' && (p)[3] == 'F')
+#define GET_ELE_ID(p) ((AACElementID)(*(p) >> (8-NUM_SYN_ID_BITS)))
+
+/* AAC file format */
+enum {
+ AAC_FF_Unknown = 0, /* should be 0 on init */
+
+ AAC_FF_ADTS = 1,
+ AAC_FF_ADIF = 2,
+ AAC_FF_RAW = 3
+
+};
+
+/* syntactic element type */
+enum {
+ AAC_ID_INVALID = -1,
+
+ AAC_ID_SCE = 0,
+ AAC_ID_CPE = 1,
+ AAC_ID_CCE = 2,
+ AAC_ID_LFE = 3,
+ AAC_ID_DSE = 4,
+ AAC_ID_PCE = 5,
+ AAC_ID_FIL = 6,
+ AAC_ID_END = 7
+};
+
+typedef struct _AACDecInfo {
+ /* pointers to platform-specific state information */
+ void *psInfoBase; /* baseline MPEG-4 LC decoding */
+ void *psInfoSBR; /* MPEG-4 SBR decoding */
+
+ /* raw decoded data, before rounding to 16-bit PCM (for postprocessing such as SBR) */
+ void *rawSampleBuf[AAC_MAX_NCHANS];
+ int rawSampleBytes;
+ int rawSampleFBits;
+
+ /* fill data (can be used for processing SBR or other extensions) */
+ unsigned char *fillBuf;
+ int fillCount;
+ int fillExtType;
+
+ /* block information */
+ int prevBlockID;
+ int currBlockID;
+ int currInstTag;
+ int sbDeinterleaveReqd[MAX_NCHANS_ELEM];
+ int adtsBlocksLeft;
+
+ /* user-accessible info */
+ int bitRate;
+ int nChans;
+ int sampRate;
+ int profile;
+ int format;
+ int sbrEnabled;
+ int tnsUsed;
+ int pnsUsed;
+ int frameCount;
+ int byteParsed;
+ int sampleDecoded;
+ unsigned audio_send_by_frame;
+ unsigned frame_length;
+} AACDecInfo;
+
+/* decoder functions which must be implemented for each platform */
+AACDecInfo *AllocateBuffers(void);
+void FreeBuffers(AACDecInfo *aacDecInfo);
+void ClearBuffer(void *buf, int nBytes);
+
+int UnpackADTSHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail);
+int GetADTSChannelMapping(AACDecInfo *aacDecInfo, unsigned char *buf, int bitOffset, int bitsAvail);
+int UnpackADIFHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail);
+int SetRawBlockParams(AACDecInfo *aacDecInfo, int copyLast, int nChans, int sampRate, int profile);
+int PrepareRawBlock(AACDecInfo *aacDecInfo);
+int FlushCodec(AACDecInfo *aacDecInfo);
+
+int DecodeNextElement(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail);
+int DecodeNoiselessData(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail, int ch);
+
+int Dequantize(AACDecInfo *aacDecInfo, int ch);
+int StereoProcess(AACDecInfo *aacDecInfo);
+int DeinterleaveShortBlocks(AACDecInfo *aacDecInfo, int ch);
+int PNS(AACDecInfo *aacDecInfo, int ch);
+int TNSFilter(AACDecInfo *aacDecInfo, int ch);
+int IMDCT(AACDecInfo *aacDecInfo, int ch, int chBase, short *outbuf);
+
+/* SBR specific functions */
+int InitSBR(AACDecInfo *aacDecInfo);
+void FreeSBR(AACDecInfo *aacDecInfo);
+int DecodeSBRBitstream(AACDecInfo *aacDecInfo, int chBase);
+int DecodeSBRData(AACDecInfo *aacDecInfo, int chBase, short *outbuf);
+int FlushCodecSBR(AACDecInfo *aacDecInfo);
+
+/* aactabs.c - global ROM tables */
+extern const int sampRateTab[NUM_SAMPLE_RATES];
+extern const int predSFBMax[NUM_SAMPLE_RATES];
+extern const int channelMapTab[NUM_DEF_CHAN_MAPS];
+extern const int elementNumChans[NUM_ELEMENTS];
+extern const unsigned char sfBandTotalShort[NUM_SAMPLE_RATES];
+extern const unsigned char sfBandTotalLong[NUM_SAMPLE_RATES];
+extern const int sfBandTabShortOffset[NUM_SAMPLE_RATES];
+extern const short sfBandTabShort[76];
+extern const int sfBandTabLongOffset[NUM_SAMPLE_RATES];
+extern const short sfBandTabLong[325];
+extern const int tnsMaxBandsShortOffset[AAC_NUM_PROFILES];
+extern const unsigned char tnsMaxBandsShort[2 * NUM_SAMPLE_RATES];
+extern const unsigned char tnsMaxOrderShort[AAC_NUM_PROFILES];
+extern const int tnsMaxBandsLongOffset[AAC_NUM_PROFILES];
+extern const unsigned char tnsMaxBandsLong[2 * NUM_SAMPLE_RATES];
+extern const unsigned char tnsMaxOrderLong[AAC_NUM_PROFILES];
+
+#endif /* _AACCOMMON_H */
diff --git a/audio_codec/libfaad/helixaac/aacdec.c b/audio_codec/libfaad/helixaac/aacdec.c
new file mode 100644
index 0000000..e8297a4
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/aacdec.c
@@ -0,0 +1,508 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aacdec.c,v 1.1 2005/02/26 01:47:31 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * aacdec.c - platform-independent top level decoder API
+ **************************************************************************************/
+#include "aaccommon.h"
+#include "bitstream.h"
+#include <stdio.h>
+#include "aacdec.h"
+
+#define HELIX_MAX_DECODE_CH_NUM (6)
+
+/**************************************************************************************
+ * Function: AACInitDecoder
+ *
+ * Description: allocate memory for platform-specific data
+ * clear all the user-accessible fields
+ * initialize SBR decoder if enabled
+ *
+ * Inputs: none
+ *
+ * Outputs: none
+ *
+ * Return: handle to AAC decoder instance, 0 if malloc fails
+ **************************************************************************************/
+HAACDecoder AACInitDecoder(void)
+{
+ AACDecInfo *aacDecInfo;
+
+ aacDecInfo = AllocateBuffers();
+ if (!aacDecInfo) {
+ return 0;
+ }
+
+#ifdef AAC_ENABLE_SBR
+ if (InitSBR(aacDecInfo)) {
+ AACFreeDecoder(aacDecInfo);
+ return 0;
+ }
+#endif
+
+ return (HAACDecoder)aacDecInfo;
+}
+
+/**************************************************************************************
+ * Function: AACFreeDecoder
+ *
+ * Description: free platform-specific data allocated by AACInitDecoder
+ * free SBR decoder if enabled
+ *
+ * Inputs: valid AAC decoder instance pointer (HAACDecoder)
+ *
+ * Outputs: none
+ *
+ * Return: none
+ **************************************************************************************/
+void AACFreeDecoder(HAACDecoder hAACDecoder)
+{
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+
+ if (!aacDecInfo) {
+ return;
+ }
+
+#ifdef AAC_ENABLE_SBR
+ FreeSBR(aacDecInfo);
+#endif
+ FreeBuffers(aacDecInfo);
+}
+
+/**************************************************************************************
+ * Function: AACFindSyncWord
+ *
+ * Description: locate the next byte-alinged sync word in the raw AAC stream
+ *
+ * Inputs: buffer to search for sync word
+ * max number of bytes to search in buffer
+ *
+ * Outputs: none
+ *
+ * Return: offset to first sync word (bytes from start of buf)
+ * -1 if sync not found after searching nBytes
+ **************************************************************************************/
+int AACFindSyncWord(unsigned char *buf, int nBytes)
+{
+ int i;
+
+ /* find byte-aligned syncword (12 bits = 0xFFF) */
+ for (i = 0; i < nBytes - 1; i++) {
+ if ((buf[i + 0] & SYNCWORDH) == SYNCWORDH && (buf[i + 1] & SYNCWORDL) == SYNCWORDL) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+/**************************************************************************************
+ * Function: AACGetLastFrameInfo
+ *
+ * Description: get info about last AAC frame decoded (number of samples decoded,
+ * sample rate, bit rate, etc.)
+ *
+ * Inputs: valid AAC decoder instance pointer (HAACDecoder)
+ * pointer to AACFrameInfo struct
+ *
+ * Outputs: filled-in AACFrameInfo struct
+ *
+ * Return: none
+ *
+ * Notes: call this right after calling AACDecode()
+ **************************************************************************************/
+void AACGetLastFrameInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo)
+{
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+
+ if (!aacDecInfo) {
+ aacFrameInfo->format = 0;
+ aacFrameInfo->bitRate = 0;
+ aacFrameInfo->nChans = 0;
+ aacFrameInfo->sampRateCore = 0;
+ aacFrameInfo->sampRateOut = 0;
+ aacFrameInfo->bitsPerSample = 0;
+ aacFrameInfo->outputSamps = 0;
+ aacFrameInfo->profile = 0;
+ aacFrameInfo->tnsUsed = 0;
+ aacFrameInfo->pnsUsed = 0;
+ } else {
+ aacFrameInfo->format = aacDecInfo->format;
+ aacFrameInfo->nChans = aacDecInfo->nChans;
+ aacFrameInfo->sampRateCore = aacDecInfo->sampRate;
+ aacFrameInfo->sampRateOut = aacDecInfo->sampRate * (aacDecInfo->sbrEnabled ? 2 : 1);
+ aacFrameInfo->bitsPerSample = 16;
+ aacFrameInfo->outputSamps = aacDecInfo->nChans * AAC_MAX_NSAMPS * (aacDecInfo->sbrEnabled ? 2 : 1);
+ aacFrameInfo->profile = aacDecInfo->profile;
+ aacFrameInfo->tnsUsed = aacDecInfo->tnsUsed;
+ aacFrameInfo->pnsUsed = aacDecInfo->pnsUsed;
+ }
+}
+
+void AACGetDecoderInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo)
+{
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+
+ if (aacDecInfo) {
+ aacFrameInfo->format = aacDecInfo->format;
+ aacFrameInfo->nChans = aacDecInfo->nChans;
+ aacFrameInfo->sampRateCore = aacDecInfo->sampRate;
+ aacFrameInfo->sampRateOut = aacDecInfo->sampRate * (aacDecInfo->sbrEnabled ? 2 : 1);
+ aacFrameInfo->bitsPerSample = 16;
+ aacFrameInfo->outputSamps = aacDecInfo->nChans * AAC_MAX_NSAMPS * (aacDecInfo->sbrEnabled ? 2 : 1);
+ aacFrameInfo->profile = aacDecInfo->profile;
+ aacFrameInfo->tnsUsed = aacDecInfo->tnsUsed;
+ aacFrameInfo->pnsUsed = aacDecInfo->pnsUsed;
+ aacFrameInfo->total_byte_parsed = aacDecInfo->byteParsed;
+ aacFrameInfo->total_sample_decoded = aacDecInfo->sampleDecoded;
+
+ if (aacDecInfo->bitRate) {
+ aacFrameInfo->bitRate = aacDecInfo->bitRate;
+ } else if (aacDecInfo->sampleDecoded > 0) {
+ aacFrameInfo->bitRate = (int)(((float)(aacDecInfo->byteParsed)) / ((float)aacDecInfo->sampleDecoded / (float)aacFrameInfo->sampRateOut)) << 3;
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: AACSetRawBlockParams
+ *
+ * Description: set internal state variables for decoding a stream of raw data blocks
+ *
+ * Inputs: valid AAC decoder instance pointer (HAACDecoder)
+ * flag indicating source of parameters
+ * AACFrameInfo struct, with the members nChans, sampRate, and profile
+ * optionally filled-in
+ *
+ * Outputs: updated codec state
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: if copyLast == 1, then the codec sets up its internal state (for
+ * decoding raw blocks) based on previously-decoded ADTS header info
+ * if copyLast == 0, then the codec uses the values passed in
+ * aacFrameInfo to configure its internal state (useful when the
+ * source is MP4 format, for example)
+ **************************************************************************************/
+int AACSetRawBlockParams(HAACDecoder hAACDecoder, int copyLast, AACFrameInfo *aacFrameInfo)
+{
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+
+ if (!aacDecInfo) {
+ return ERR_AAC_NULL_POINTER;
+ }
+
+ aacDecInfo->format = AAC_FF_RAW;
+ aacDecInfo->audio_send_by_frame = aacFrameInfo->audio_send_by_frame;
+ if (copyLast) {
+ return SetRawBlockParams(aacDecInfo, 1, 0, 0, 0);
+ } else {
+ return SetRawBlockParams(aacDecInfo, 0, aacFrameInfo->nChans, aacFrameInfo->sampRateCore, aacFrameInfo->profile);
+ }
+}
+
+/**************************************************************************************
+ * Function: AACFlushCodec
+ *
+ * Description: flush internal codec state (after seeking, for example)
+ *
+ * Inputs: valid AAC decoder instance pointer (HAACDecoder)
+ *
+ * Outputs: updated state variables in aacDecInfo
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int AACFlushCodec(HAACDecoder hAACDecoder)
+{
+ int ch;
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+
+ if (!aacDecInfo) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ /* reset common state variables which change per-frame
+ * don't touch state variables which are (usually) constant for entire clip
+ * (nChans, sampRate, profile, format, sbrEnabled)
+ */
+ aacDecInfo->prevBlockID = AAC_ID_INVALID;
+ aacDecInfo->currBlockID = AAC_ID_INVALID;
+ aacDecInfo->currInstTag = -1;
+ for (ch = 0; ch < MAX_NCHANS_ELEM; ch++) {
+ aacDecInfo->sbDeinterleaveReqd[ch] = 0;
+ }
+ aacDecInfo->adtsBlocksLeft = 0;
+ aacDecInfo->tnsUsed = 0;
+ aacDecInfo->pnsUsed = 0;
+
+ /* reset internal codec state (flush overlap buffers, etc.) */
+ FlushCodec(aacDecInfo);
+#ifdef AAC_ENABLE_SBR
+ FlushCodecSBR(aacDecInfo);
+#endif
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: AACDecode
+ *
+ * Description: decode AAC frame
+ *
+ * Inputs: valid AAC decoder instance pointer (HAACDecoder)
+ * double pointer to buffer of AAC data
+ * pointer to number of valid bytes remaining in inbuf
+ * pointer to outbuf, big enough to hold one frame of decoded PCM samples
+ * (outbuf must be double-sized if SBR enabled)
+ *
+ * Outputs: PCM data in outbuf, interleaved LRLRLR... if stereo
+ * number of output samples = 1024 per channel (2048 if SBR enabled)
+ * updated inbuf pointer
+ * updated bytesLeft
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: inbuf pointer and bytesLeft are not updated until whole frame is
+ * successfully decoded, so if ERR_AAC_INDATA_UNDERFLOW is returned
+ * just call AACDecode again with more data in inbuf
+ **************************************************************************************/
+int AACDecode(HAACDecoder hAACDecoder, unsigned char **inbuf, int *bytesLeft, short *outbuf)
+{
+ int err, offset, bitOffset, bitsAvail;
+ int ch, baseChan, baseChanSBR, elementChans;
+ unsigned char *inptr;
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+#ifdef AAC_ENABLE_SBR
+ int elementChansSBR;
+#endif
+
+ if (!aacDecInfo) {
+ return ERR_AAC_NULL_POINTER;
+ }
+
+ /* make local copies (see "Notes" above) */
+ inptr = *inbuf;
+ bitOffset = 0;
+ bitsAvail = (*bytesLeft) << 3;
+
+ /* first time through figure out what the file format is */
+ if (aacDecInfo->format == AAC_FF_Unknown) {
+ if (bitsAvail < 32) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+
+ if (IS_ADIF(inptr)) {
+ /* unpack ADIF header */
+ aacDecInfo->format = AAC_FF_ADIF;
+ //printk("ADIF_DBG:ready step into UnpackADIFHeader()!\n");
+ err = UnpackADIFHeader(aacDecInfo, &inptr, &bitOffset, &bitsAvail);
+ if (err) {
+ return err;
+ }
+ } else {
+ /* assume ADTS by default */
+ aacDecInfo->format = AAC_FF_ADTS;
+ }
+ }
+ //printk("ADIF_DBG:aacDecInfo->format1=%d\n",aacDecInfo->format);
+
+ /* if ADTS, search for start of next frame */
+ if (aacDecInfo->format == AAC_FF_ADTS) {
+ /* can have 1-4 raw data blocks per ADTS frame (header only present for first one) */
+ if (/*aacDecInfo->adtsBlocksLeft == 0*/1) {
+ offset = AACFindSyncWord(inptr, bitsAvail >> 3);
+ if (AACDataSource == 1) {
+ if (offset < 0) { //not find sync word in current buffer
+ return ERR_AAC_INVALID_ADTS_SYNCWORD; //ERR_AAC_INDATA_UNDERFLOW;
+ }
+ inptr += offset;
+ bitsAvail -= (offset << 3);
+ }
+ err = UnpackADTSHeader(aacDecInfo, &inptr, &bitOffset, &bitsAvail);
+ if (err) {
+ return err;
+ }
+
+ if (aacDecInfo->nChans == -1) {
+ /* figure out implicit channel mapping if necessary */
+ err = GetADTSChannelMapping(aacDecInfo, inptr, bitOffset, bitsAvail);
+ if (err) {
+ return err;
+ }
+ }
+ }
+ aacDecInfo->adtsBlocksLeft--;
+ } else if (aacDecInfo->format == AAC_FF_RAW) {
+ err = PrepareRawBlock(aacDecInfo);
+ if (err) {
+ return err;
+ }
+ }
+
+ //printk("ADIF_DBG:aacDecInfo->nChans=%d aacDecInfo->sampRate=%d\n",aacDecInfo->nChans,aacDecInfo->sampRate);
+ /* check for valid number of channels */
+ if (aacDecInfo->nChans > AAC_MAX_NCHANS || aacDecInfo->nChans <= 0) {
+ printk("AAC ERR: ERR_AAC_NCHANS_TOO_HIGH\n");
+ return ERR_AAC_NCHANS_TOO_HIGH;
+ }
+
+ /* will be set later if active in this frame */
+ aacDecInfo->tnsUsed = 0;
+ aacDecInfo->pnsUsed = 0;
+
+ bitOffset = 0;
+ baseChan = 0;
+ baseChanSBR = 0;
+ do {
+ /* parse next syntactic element */
+ err = DecodeNextElement(aacDecInfo, &inptr, &bitOffset, &bitsAvail);
+ if (err) {
+ return err;
+ }
+
+ elementChans = elementNumChans[aacDecInfo->currBlockID];
+ if (baseChan + elementChans > AAC_MAX_NCHANS) {
+ return ERR_AAC_NCHANS_TOO_HIGH;
+ }
+
+ /* noiseless decoder and dequantizer */
+ for (ch = 0; ch < elementChans; ch++) {
+ err = DecodeNoiselessData(aacDecInfo, &inptr, &bitOffset, &bitsAvail, ch);
+ if (err) {
+ return err;
+ }
+
+ if (Dequantize(aacDecInfo, ch)) {
+ return ERR_AAC_DEQUANT;
+ }
+ }
+
+ /* mid-side and intensity stereo */
+ if (aacDecInfo->currBlockID == AAC_ID_CPE) {
+ if (StereoProcess(aacDecInfo)) {
+ return ERR_AAC_STEREO_PROCESS;
+ }
+ }
+
+ /* PNS, TNS, inverse transform */
+ for (ch = 0; ch < elementChans; ch++) {
+ if (PNS(aacDecInfo, ch)) {
+ return ERR_AAC_PNS;
+ }
+
+ if (aacDecInfo->sbDeinterleaveReqd[ch]) {
+ /* deinterleave short blocks, if required */
+ if (DeinterleaveShortBlocks(aacDecInfo, ch)) {
+ return ERR_AAC_SHORT_BLOCK_DEINT;
+ }
+ aacDecInfo->sbDeinterleaveReqd[ch] = 0;
+ }
+
+ if (TNSFilter(aacDecInfo, ch)) {
+ return ERR_AAC_TNS;
+ }
+
+ if (IMDCT(aacDecInfo, ch, baseChan + ch, outbuf)) {
+ return ERR_AAC_IMDCT;
+ }
+ }
+
+#ifdef AAC_ENABLE_SBR
+ if (aacDecInfo->sbrEnabled && (aacDecInfo->currBlockID == AAC_ID_FIL || aacDecInfo->currBlockID == AAC_ID_LFE)) {
+ if (aacDecInfo->currBlockID == AAC_ID_LFE) {
+ elementChansSBR = elementNumChans[AAC_ID_LFE];
+ } else if (aacDecInfo->currBlockID == AAC_ID_FIL && (aacDecInfo->prevBlockID == AAC_ID_SCE || aacDecInfo->prevBlockID == AAC_ID_CPE)) {
+ elementChansSBR = elementNumChans[aacDecInfo->prevBlockID];
+ } else {
+ elementChansSBR = 0;
+ }
+
+ if (baseChanSBR + elementChansSBR > AAC_MAX_NCHANS) {
+ return ERR_AAC_SBR_NCHANS_TOO_HIGH;
+ }
+
+ /* parse SBR extension data if present (contained in a fill element) */
+ if (DecodeSBRBitstream(aacDecInfo, baseChanSBR)) {
+ return ERR_AAC_SBR_BITSTREAM;
+ }
+
+ /* apply SBR */
+ if (DecodeSBRData(aacDecInfo, baseChanSBR, outbuf)) {
+ return ERR_AAC_SBR_DATA;
+ }
+
+ baseChanSBR += elementChansSBR;
+ }
+#endif
+
+ baseChan += elementChans;
+ } while (aacDecInfo->currBlockID != AAC_ID_END);
+
+ /* byte align after each raw_data_block */
+ if (bitOffset) {
+ inptr++;
+ bitsAvail -= (8 - bitOffset);
+ bitOffset = 0;
+ if (bitsAvail < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+
+ /* update pointers */
+ if (AACDataSource == 1) {
+ aacDecInfo->frameCount++;
+ aacDecInfo->byteParsed += inptr - *inbuf;
+ //printk(" decode one frame cost byte %d \n",inptr - *inbuf);
+ aacDecInfo->sampleDecoded += AAC_MAX_NSAMPS * (aacDecInfo->sbrEnabled ? 2 : 1);
+ *bytesLeft -= (inptr - *inbuf);
+ *inbuf = inptr;
+ } else {
+ aacDecInfo->frameCount++;
+ aacDecInfo->byteParsed = CalcBitsUsed(0, 0, 0) >> 3;
+ aacDecInfo->sampleDecoded += AAC_MAX_NSAMPS * (aacDecInfo->sbrEnabled ? 2 : 1);
+ *bytesLeft -= (CalcBitsUsed(0, 0, 0) >> 3);
+ // *inbuf = *inbuf+;
+ }
+
+
+
+ return ERR_AAC_NONE;
+}
+
diff --git a/audio_codec/libfaad/helixaac/aacdec.h b/audio_codec/libfaad/helixaac/aacdec.h
new file mode 100644
index 0000000..6d22a9e
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/aacdec.h
@@ -0,0 +1,206 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aacdec.h,v 1.8 2005/11/10 00:15:08 margotm Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * aacdec.h - public C API for AAC decoder
+ **************************************************************************************/
+
+#ifndef _AACDEC_H
+#define _AACDEC_H
+
+#define _ARC32
+
+#if defined(_WIN32) && !defined(_WIN32_WCE)
+#
+#elif defined(_WIN32) && defined(_WIN32_WCE) && defined(ARM)
+#
+#elif defined(_WIN32) && defined(WINCE_EMULATOR)
+#
+#elif defined (__arm) && defined (__ARMCC_VERSION)
+#
+#elif defined(_SYMBIAN) && defined(__WINS__)
+#
+#elif defined(__GNUC__) && defined(__arm__)
+#
+#elif defined(__GNUC__) && defined(__i386__)
+#
+#elif defined(__GNUC__) && defined(__amd64__)
+#
+#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__))
+#
+#elif defined(_OPENWAVE_SIMULATOR) || defined(_OPENWAVE_ARMULATOR)
+#
+#elif defined(_SOLARIS) && !defined(__GNUC__)
+#
+#elif defined(_ARC32)
+#define __inline _Inline
+#else
+#error No platform defined. See valid options in aacdec.h
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* according to spec (13818-7 section 8.2.2, 14496-3 section 4.5.3)
+ * max size of input buffer =
+ * 6144 bits = 768 bytes per SCE or CCE-I
+ * 12288 bits = 1536 bytes per CPE
+ * 0 bits = 0 bytes per CCE-D (uses bits from the SCE/CPE/CCE-I it is coupled to)
+ */
+#ifndef AAC_MAX_NCHANS /* if max channels isn't set in makefile, */
+#define AAC_MAX_NCHANS 6 /* set to default max number of channels */
+#endif
+#define AAC_MAX_NSAMPS 1024
+#define AAC_MAINBUF_SIZE (768 * AAC_MAX_NCHANS)
+
+#define AAC_NUM_PROFILES 3
+#define AAC_PROFILE_MP 0
+#define AAC_PROFILE_LC 1
+#define AAC_PROFILE_SSR 2
+
+#define AAC_INPUTBUF_SIZE (2 * 768 * 4) /* pick something big enough to hold a bunch of frames */
+
+ /* define these to enable decoder features */
+#ifndef __ARC600__
+#define HELIX_FEATURE_AUDIO_CODEC_AAC_SBR
+#endif /* __ARC600__ */
+#if defined(HELIX_FEATURE_AUDIO_CODEC_AAC_SBR)
+#define AAC_ENABLE_SBR
+#endif // HELIX_FEATURE_AUDIO_CODEC_AAC_SBR.
+#define AAC_ENABLE_MPEG4
+
+#ifdef AAC_ENABLE_SBR
+#define SBR_MUL 2
+#else
+#define SBR_MUL 1
+#endif
+
+ enum {
+ ERR_AAC_NONE = 0,
+ ERR_AAC_INDATA_UNDERFLOW = -1,
+ ERR_AAC_NULL_POINTER = -2,
+ ERR_AAC_INVALID_ADTS_HEADER = -3,
+ ERR_AAC_INVALID_ADIF_HEADER = -4,
+ ERR_AAC_INVALID_FRAME = -5,
+ ERR_AAC_MPEG4_UNSUPPORTED = -6,
+ ERR_AAC_CHANNEL_MAP = -7,
+ ERR_AAC_SYNTAX_ELEMENT = -8,
+
+ ERR_AAC_DEQUANT = -9,
+ ERR_AAC_STEREO_PROCESS = -10,
+ ERR_AAC_PNS = -11,
+ ERR_AAC_SHORT_BLOCK_DEINT = -12,
+ ERR_AAC_TNS = -13,
+ ERR_AAC_IMDCT = -14,
+ ERR_AAC_NCHANS_TOO_HIGH = -15,
+
+ ERR_AAC_SBR_INIT = -16,
+ ERR_AAC_SBR_BITSTREAM = -17,
+ ERR_AAC_SBR_DATA = -18,
+ ERR_AAC_SBR_PCM_FORMAT = -19,
+ ERR_AAC_SBR_NCHANS_TOO_HIGH = -20,
+ ERR_AAC_SBR_SINGLERATE_UNSUPPORTED = -21,
+
+ ERR_AAC_RAWBLOCK_PARAMS = -22,
+ ERR_AAC_COFF_EXCEED_RANGE = -23,
+ ERR_AAC_HUFFMAN_DECODING = -24,
+ ERR_AAC_SPEC_NOT_MATCH = -25,
+ ERR_AAC_INVALID_ADTS_SYNCWORD = -26,
+ ERR_AAC_SSR_GAIN_NOT_ADDED = -27,
+ ERR_AAC_EXIT_DECODE = -28,
+
+ ERR_UNKNOWN = -9999
+ };
+
+ typedef struct _AACIOBuf {
+ int bytesLeft;
+ unsigned char *readPtr;
+ unsigned char readBuf[AAC_INPUTBUF_SIZE];
+ short outBuf[AAC_MAX_NCHANS * AAC_MAX_NSAMPS * SBR_MUL];
+ } AACIOBuf;
+
+ typedef struct _AACFrameInfo { // should keep same as _audio_codec_config_aacdec_t in audio_codec_aac.h
+ int bitRate;
+ int nChans;
+ int sampRateCore;
+ int sampRateOut;
+ int bitsPerSample;
+ int outputSamps;
+ int profile;
+ int tnsUsed;
+ int pnsUsed;
+ int format;
+ unsigned total_byte_parsed;
+ unsigned total_sample_decoded;
+ unsigned audio_send_by_frame;
+ //#ifndef PRE_APOLLO
+ unsigned char *extra_data;
+ unsigned extradata_len;
+ //#endif
+ } AACFrameInfo;
+
+ typedef void *HAACDecoder;
+ typedef void *HAACIOBuf;
+
+ /* public C API */
+ HAACDecoder AACInitDecoder();
+ void AACFreeDecoder(HAACDecoder hAACDecoder);
+ int AACDecode(HAACDecoder hAACDecoder, unsigned char **inbuf, int *bytesLeft, short *outbuf);
+
+ int AACFindSyncWord(unsigned char *buf, int nBytes);
+ void AACGetLastFrameInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo);
+ void AACGetDecoderInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo);
+ int AACSetRawBlockParams(HAACDecoder hAACDecoder, int copyLast, AACFrameInfo *aacFrameInfo);
+ int AACFlushCodec(HAACDecoder hAACDecoder);
+
+#ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT
+ int AACInitTrigtabsFloat(void);
+ void AACFreeTrigtabsFloat(void);
+#endif
+
+ extern int AACDataSource;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _AACDEC_H */
diff --git a/audio_codec/libfaad/helixaac/aactabs.c b/audio_codec/libfaad/helixaac/aactabs.c
new file mode 100644
index 0000000..3cade7d
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/aactabs.c
@@ -0,0 +1,157 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aactabs.c,v 1.1 2005/02/26 01:47:31 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * aactabs.c - platform-independent tables for AAC decoder (global, read-only)
+ **************************************************************************************/
+
+#include "aaccommon.h"
+
+/* sample rates (table 4.5.1) */
+const int sampRateTab[NUM_SAMPLE_RATES] = {
+ 96000, 88200, 64000, 48000, 44100, 32000,
+ 24000, 22050, 16000, 12000, 11025, 8000
+};
+
+/* max scalefactor band for prediction (main profile only) */
+const int predSFBMax[NUM_SAMPLE_RATES] = {
+ 33, 33, 38, 40, 40, 40, 41, 41, 37, 37, 37, 34
+};
+
+/* channel mapping (table 1.6.3.4) (-1 = unknown, so need to determine mapping based on rules in 8.5.1) */
+const int channelMapTab[NUM_DEF_CHAN_MAPS] = {
+ -1, 1, 2, 3, 4, 5, 6, 8
+};
+
+/* number of channels in each element (SCE, CPE, etc.)
+ * see AACElementID in aaccommon.h
+ */
+const int elementNumChans[NUM_ELEMENTS] = {
+ 1, 2, 0, 1, 0, 0, 0, 0
+};
+
+/* total number of scale factor bands in one window */
+const unsigned char sfBandTotalShort[NUM_SAMPLE_RATES] = {
+ 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15
+};
+
+const unsigned char sfBandTotalLong[NUM_SAMPLE_RATES] = {
+ 41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40
+};
+
+/* scale factor band tables */
+const int sfBandTabShortOffset[NUM_SAMPLE_RATES] = {0, 0, 0, 13, 13, 13, 28, 28, 44, 44, 44, 60};
+
+const short sfBandTabShort[76] = {
+ /* short block 64, 88, 96 kHz [13] (tables 4.5.24, 4.5.26) */
+ 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128,
+
+ /* short block 32, 44, 48 kHz [15] (table 4.5.15) */
+ 0, 4, 8, 12, 16, 20, 28, 36, 44, 56, 68, 80, 96, 112, 128,
+
+ /* short block 22, 24 kHz [16] (table 4.5.22) */
+ 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 64, 76, 92, 108, 128,
+
+ /* short block 11, 12, 16 kHz [16] (table 4.5.20) */
+ 0, 4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 60, 72, 88, 108, 128,
+
+ /* short block 8 kHz [16] (table 4.5.18) */
+ 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 128
+};
+
+const int sfBandTabLongOffset[NUM_SAMPLE_RATES] = {0, 0, 42, 90, 90, 140, 192, 192, 240, 240, 240, 284};
+
+const short sfBandTabLong[325] = {
+ /* long block 88, 96 kHz [42] (table 4.5.25) */
+ 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,
+
+ /* long block 64 kHz [48] (table 4.5.13) */
+ 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,
+
+ /* long block 44, 48 kHz [50] (table 4.5.14) */
+ 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,
+
+ /* long block 32 kHz [52] (table 4.5.16) */
+ 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,
+
+ /* long block 22, 24 kHz [48] (table 4.5.21) */
+ 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,
+
+ /* long block 11, 12, 16 kHz [44] (table 4.5.19) */
+ 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,
+
+ /* long block 8 kHz [41] (table 4.5.17) */
+ 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
+};
+
+
+/* TNS max bands (table 4.139) and max order (table 4.138) */
+const int tnsMaxBandsShortOffset[AAC_NUM_PROFILES] = {0, 0, 12};
+
+const unsigned char tnsMaxBandsShort[2 * NUM_SAMPLE_RATES] = {
+ 9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, /* short block, Main/LC */
+ 7, 7, 7, 6, 6, 6, 7, 7, 8, 8, 8, 7 /* short block, SSR */
+};
+
+const unsigned char tnsMaxOrderShort[AAC_NUM_PROFILES] = {7, 7, 7};
+
+const int tnsMaxBandsLongOffset[AAC_NUM_PROFILES] = {0, 0, 12};
+
+const unsigned char tnsMaxBandsLong[2 * NUM_SAMPLE_RATES] = {
+ 31, 31, 34, 40, 42, 51, 46, 46, 42, 42, 42, 39, /* long block, Main/LC */
+ 28, 28, 27, 26, 26, 26, 29, 29, 23, 23, 23, 19, /* long block, SSR */
+};
+
+const unsigned char tnsMaxOrderLong[AAC_NUM_PROFILES] = {20, 12, 12};
diff --git a/audio_codec/libfaad/helixaac/assembly.h b/audio_codec/libfaad/helixaac/assembly.h
new file mode 100644
index 0000000..a0f8095
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/assembly.h
@@ -0,0 +1,631 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: assembly.h,v 1.9 2007/02/28 07:10:21 gahluwalia Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * assembly.h - inline assembly language functions and prototypes
+ *
+ * MULSHIFT32(x, y) signed multiply of two 32-bit integers (x and y),
+ * returns top 32-bits of 64-bit result
+ * CLIPTOSHORT(x) convert 32-bit integer to 16-bit short,
+ * clipping to [-32768, 32767]
+ * FASTABS(x) branchless absolute value of signed integer x
+ * CLZ(x) count leading zeros on signed integer x
+ * MADD64(sum64, x, y) 64-bit multiply accumulate: sum64 += (x*y)
+ **************************************************************************************/
+
+#ifndef _ASSEMBLY_H
+#define _ASSEMBLY_H
+
+/* toolchain: MSFT Visual C++
+ * target architecture: x86
+ */
+#if (defined (_WIN32) && !defined (_WIN32_WCE)) || (defined (__WINS__) && defined (_SYMBIAN)) || (defined (WINCE_EMULATOR)) || (defined (_OPENWAVE_SIMULATOR))
+
+#pragma warning( disable : 4035 ) /* complains about inline asm not returning a value */
+
+static __inline int MULSHIFT32(int x, int y)
+{
+ __asm {
+ mov eax, x
+ imul y
+ mov eax, edx
+ }
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+}
+
+#ifdef __CW32__
+typedef long long Word64;
+#else
+typedef __int64 Word64;
+#endif
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* x86 = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+/* returns 64-bit value in [edx:eax] */
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+#if (defined (_SYMBIAN_61_) || defined (_SYMBIAN_70_)) && defined (__WINS__) && !defined (__CW32__)
+ /* Workaround for the Symbian emulator because of non existing longlong.lib and
+ * hence __allmul not defined. */
+ __asm {
+ mov eax, x
+ imul y
+ add dword ptr sum64, eax
+ adc dword ptr sum64 + 4, edx
+ }
+#else
+ sum64 += (Word64)x * (Word64)y;
+#endif
+
+ return sum64;
+}
+
+/* toolchain: MSFT Embedded Visual C++
+ * target architecture: ARM v.4 and above (require 'M' type processor for 32x32->64 multiplier)
+ */
+#elif defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search (function should be 17 ARM instructions total) */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+}
+
+/* implemented in asmfunc.s */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef __int64 Word64;
+
+ typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* ARM WinCE = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+ } U64;
+
+ /* manual name mangling for just this platform (must match labels in .s file) */
+#define MULSHIFT32 raac_MULSHIFT32
+#define MADD64 raac_MADD64
+
+ int MULSHIFT32(int x, int y);
+ Word64 MADD64(Word64 sum64, int x, int y);
+
+#ifdef __cplusplus
+}
+#endif
+
+/* toolchain: ARM ADS or RealView
+ * target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier)
+ */
+#elif (defined (__arm) && defined (__ARMCC_VERSION)) || (defined(HELIX_CONFIG_SYMBIAN_GENERATE_MMP) && !defined(__GCCE__))
+
+static __inline int MULSHIFT32(int x, int y)
+{
+ /* rules for smull RdLo, RdHi, Rm, Rs:
+ * RdHi != Rm
+ * RdLo != Rm
+ * RdHi != RdLo
+ */
+ int zlow;
+ __asm {
+ smull zlow, y, x, y
+ }
+
+ return y;
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search (function should be 17 ARM instructions total) */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+
+ /* ARM code would look like this, but do NOT use inline asm in ADS for this,
+ because you can't safely use the status register flags intermixed with C code
+
+ __asm {
+ mov numZeros, #1
+ tst x, 0xffff0000
+ addeq numZeros, numZeros, #16
+ moveq x, x, lsl #16
+ tst x, 0xff000000
+ addeq numZeros, numZeros, #8
+ moveq x, x, lsl #8
+ tst x, 0xf0000000
+ addeq numZeros, numZeros, #4
+ moveq x, x, lsl #4
+ tst x, 0xc0000000
+ addeq numZeros, numZeros, #2
+ moveq x, x, lsl #2
+ sub numZeros, numZeros, x, lsr #31
+ }
+ */
+ /* reference:
+ numZeros = 0;
+ while (!(x & 0x80000000)) {
+ numZeros++;
+ x <<= 1;
+ }
+ */
+}
+
+typedef __int64 Word64;
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* ARM ADS = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+ U64 u;
+ u.w64 = sum64;
+
+ __asm {
+ smlal u.r.lo32, u.r.hi32, x, y
+ }
+
+ return u.w64;
+}
+
+/* toolchain: ARM gcc
+ * target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier)
+ */
+#elif defined(__GNUC__) && defined(__arm__)
+
+static __inline__ int MULSHIFT32(int x, int y)
+{
+ int zlow;
+ __asm__ volatile("smull %0,%1,%2,%3" : "=&r"(zlow), "=r"(y) : "r"(x), "1"(y) : "cc");
+ return y;
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return (sizeof(int) * 8);
+ }
+
+ numZeros = 0;
+ while (!(x & 0x80000000)) {
+ numZeros++;
+ x <<= 1;
+ }
+
+ return numZeros;
+}
+
+typedef long long Word64;
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* ARM ADS = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+ U64 u;
+ u.w64 = sum64;
+
+ __asm__ volatile("smlal %0,%1,%2,%3" : "+&r"(u.r.lo32), "+&r"(u.r.hi32) : "r"(x), "r"(y) : "cc");
+
+ return u.w64;
+}
+
+/* toolchain: x86 gcc
+ * target architecture: x86
+ */
+#elif defined(__GNUC__) && (defined(__i386__) || defined(__amd64__)) || (defined (_SOLARIS) && !defined (__GNUC__) && defined(_SOLARISX86))
+
+typedef long long Word64;
+
+static __inline__ int MULSHIFT32(int x, int y)
+{
+ int z;
+
+ z = (Word64)x * (Word64)y >> 32;
+
+ return z;
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search (function should be 17 ARM instructions total) */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+}
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* x86 = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+ sum64 += (Word64)x * (Word64)y;
+
+ return sum64;
+}
+
+#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__)) || (defined (_SOLARIS) && !defined (__GNUC__) && !defined (_SOLARISX86))
+
+typedef long long Word64;
+
+static __inline__ int MULSHIFT32(int x, int y)
+{
+ int z;
+
+ z = (Word64)x * (Word64)y >> 32;
+
+ return z;
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search (function should be 17 ARM instructions total) */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+}
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* PowerPC = big endian */
+ signed int hi32;
+ unsigned int lo32;
+ } r;
+} U64;
+
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+ sum64 += (Word64)x * (Word64)y;
+
+ return sum64;
+}
+
+#else
+
+#error Unsupported platform in assembly.h
+
+#endif /* platforms */
+
+#endif /* _ASSEMBLY_H */
diff --git a/audio_codec/libfaad/helixaac/assembly_mw.h b/audio_codec/libfaad/helixaac/assembly_mw.h
new file mode 100644
index 0000000..335f4b0
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/assembly_mw.h
@@ -0,0 +1,743 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: assembly.h,v 1.7 2005/11/10 00:04:40 margotm Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * assembly.h - inline assembly language functions and prototypes
+ *
+ * MULSHIFT32(x, y) signed multiply of two 32-bit integers (x and y),
+ * returns top 32-bits of 64-bit result
+ * CLIPTOSHORT(x) convert 32-bit integer to 16-bit short,
+ * clipping to [-32768, 32767]
+ * FASTABS(x) branchless absolute value of signed integer x
+ * CLZ(x) count leading zeros on signed integer x
+ * MADD64(sum64, x, y) 64-bit multiply accumulate: sum64 += (x*y)
+ **************************************************************************************/
+
+#ifndef _ASSEMBLY_H
+#define _ASSEMBLY_H
+
+//#define _Inline inline
+#define _ARC32
+/* toolchain: MSFT Visual C++
+ * target architecture: x86
+ */
+#if (defined (_WIN32) && !defined (_WIN32_WCE)) || (defined (__WINS__) && defined (_SYMBIAN)) || (defined (WINCE_EMULATOR)) || (defined (_OPENWAVE_SIMULATOR))
+
+#pragma warning( disable : 4035 ) /* complains about inline asm not returning a value */
+
+static __inline int MULSHIFT32(int x, int y)
+{
+ __asm {
+ mov eax, x
+ imul y
+ mov eax, edx
+ }
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+}
+
+#ifdef __CW32__
+typedef long long Word64;
+#else
+typedef __int64 Word64;
+#endif
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* x86 = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+/* returns 64-bit value in [edx:eax] */
+static __inline Word64 madd64(Word64 sum64, int x, int y)
+{
+#if (defined (_SYMBIAN_61_) || defined (_SYMBIAN_70_)) && defined (__WINS__) && !defined (__CW32__)
+ /* Workaround for the Symbian emulator because of non existing longlong.lib and
+ * hence __allmul not defined. */
+ __asm {
+ mov eax, x
+ imul y
+ add dword ptr sum64, eax
+ adc dword ptr sum64 + 4, edx
+ }
+#else
+ sum64 += (Word64)x * (Word64)y;
+
+ /* equivalent to return (sum + ((__int64)x * y)); */
+#endif
+}
+
+#define SET_ZERO(x) x=0
+#define MADD64(sum64, x, y) sum64=madd64(sum64, x, y)
+#define ADD64(x64, y64) x64 += y64;
+
+/* toolchain: MSFT Embedded Visual C++
+ * target architecture: ARM v.4 and above (require 'M' type processor for 32x32->64 multiplier)
+ */
+#elif defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search (function should be 17 ARM instructions total) */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+}
+
+/* implemented in asmfunc.s */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef __int64 Word64;
+
+ typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* ARM WinCE = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+ } U64;
+
+ /* manual name mangling for just this platform (must match labels in .s file) */
+#define MULSHIFT32 raac_MULSHIFT32
+#define MADD64 raac_MADD64
+
+ int MULSHIFT32(int x, int y);
+ Word64 MADD64(Word64 sum64, int x, int y);
+
+#ifdef __cplusplus
+}
+#endif
+
+/* toolchain: ARM ADS or RealView
+ * target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier)
+ */
+#elif (defined (__arm) && defined (__ARMCC_VERSION)) || (defined(HELIX_CONFIG_SYMBIAN_GENERATE_MMP) && !defined(__GCCE__))
+
+static __inline int MULSHIFT32(int x, int y)
+{
+ /* rules for smull RdLo, RdHi, Rm, Rs:
+ * RdHi != Rm
+ * RdLo != Rm
+ * RdHi != RdLo
+ */
+ int zlow;
+ __asm {
+ smull zlow, y, x, y
+ }
+
+ return y;
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search (function should be 17 ARM instructions total) */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+
+ /* ARM code would look like this, but do NOT use inline asm in ADS for this,
+ because you can't safely use the status register flags intermixed with C code
+
+ __asm {
+ mov numZeros, #1
+ tst x, 0xffff0000
+ addeq numZeros, numZeros, #16
+ moveq x, x, lsl #16
+ tst x, 0xff000000
+ addeq numZeros, numZeros, #8
+ moveq x, x, lsl #8
+ tst x, 0xf0000000
+ addeq numZeros, numZeros, #4
+ moveq x, x, lsl #4
+ tst x, 0xc0000000
+ addeq numZeros, numZeros, #2
+ moveq x, x, lsl #2
+ sub numZeros, numZeros, x, lsr #31
+ }
+ */
+ /* reference:
+ numZeros = 0;
+ while (!(x & 0x80000000)) {
+ numZeros++;
+ x <<= 1;
+ }
+ */
+}
+
+typedef __int64 Word64;
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* ARM ADS = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+ U64 u;
+ u.w64 = sum64;
+
+ __asm {
+ smlal u.r.lo32, u.r.hi32, x, y
+ }
+
+ return u.w64;
+}
+
+/* toolchain: ARM gcc
+ * target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier)
+ */
+#elif defined(__GNUC__) && defined(__arm__)
+
+static __inline__ int MULSHIFT32(int x, int y)
+{
+ int zlow;
+ __asm__ volatile("smull %0,%1,%2,%3" : "=&r"(zlow), "=r"(y) : "r"(x), "1"(y) : "cc");
+ return y;
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return (sizeof(int) * 8);
+ }
+
+ numZeros = 0;
+ while (!(x & 0x80000000)) {
+ numZeros++;
+ x <<= 1;
+ }
+
+ return numZeros;
+}
+
+typedef long long Word64;
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* ARM ADS = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+ U64 u;
+ u.w64 = sum64;
+
+ __asm__ volatile("smlal %0,%1,%2,%3" : "+&r"(u.r.lo32), "+&r"(u.r.hi32) : "r"(x), "r"(y) : "cc");
+
+ return u.w64;
+}
+
+/* toolchain: x86 gcc
+ * target architecture: x86
+ */
+#elif defined(__GNUC__) && (defined(__i386__) || defined(__amd64__)) || (defined (_SOLARIS) && !defined (__GNUC__) && defined(_SOLARISX86))
+
+typedef long long Word64;
+
+static __inline__ int MULSHIFT32(int x, int y)
+{
+ int z;
+
+ z = (Word64)x * (Word64)y >> 32;
+
+ return z;
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search (function should be 17 ARM instructions total) */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+}
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* x86 = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+ sum64 += (Word64)x * (Word64)y;
+
+ return sum64;
+}
+
+#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__)) || (defined (_SOLARIS) && !defined (__GNUC__) && !defined (_SOLARISX86))
+
+typedef long long Word64;
+
+static __inline__ int MULSHIFT32(int x, int y)
+{
+ int z;
+
+ z = (Word64)x * (Word64)y >> 32;
+
+ return z;
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search (function should be 17 ARM instructions total) */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+}
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* PowerPC = big endian */
+ signed int hi32;
+ unsigned int lo32;
+ } r;
+} U64;
+
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+ sum64 += (Word64)x * (Word64)y;
+
+ return sum64;
+}
+
+#elif defined(_ARC32)
+
+_Asm _Inline int MULSHIFT32(int x, int y)
+{
+ % reg x, y
+ mullw 0, x, y
+ machlw % r0, x, y
+ % error
+}
+
+_Asm _Inline short CLIPTOSHORT(int x)
+{
+ % reg x
+ min % r0, x, 0x7fff
+ max % r0, % r0, -0x8000
+ % error
+}
+
+_Asm _Inline int FASTABS(int x)
+{
+ % reg x
+ abs % r0, x
+ % error
+}
+
+_Asm _Inline int CLZ(int x)
+{
+ /* assume x>0, if x<0 should return 0 */
+ % reg x;
+ norm % r0, x
+ add % r0, % r0, 1
+ % error
+}
+#endif
+typedef struct {
+ unsigned int lo32;
+ signed int hi32;
+} Word64;
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+_Asm _Inline unsigned add64_lo(unsigned int xlo, unsigned int ylo)
+{
+ % reg xlo, ylo;
+ add.f % r0, xlo, ylo
+ % error
+}
+
+_Asm _Inline int add64_hi(unsigned int xhi, unsigned int yhi)
+{
+ % reg xhi, yhi;
+ adc % r0, xhi, yhi
+ % error
+}
+
+_Asm _Inline unsigned madd64_lo(unsigned lo, int a, int b)
+{
+ % reg lo, a, b;
+ mpy % r0, a, b
+ add.f % r0, lo, % r0
+ % error
+}
+
+
+_Asm _Inline int madd64_hi(int hi, int a, int b)
+{
+ % reg hi, a, b;
+ mpyh % r0, a, b
+ adc % r0, hi, % r0
+ % error
+}
+
+
+
+_Asm _Inline void madd64(int a, int b)
+{
+ % reg a, b;
+ mulhlw 0, a, b
+ maclw 0, a, b
+ % error
+}
+
+_Asm _Inline int madd64hi(int hi)
+{
+ % reg hi
+ //mov %r0, %acc2
+ adc % r0, hi, % acc1
+ % error
+}
+
+_Asm _Inline int madd64lo(int lo)
+{
+ % reg lo
+ //mov %r0, %acc1
+ add.f % r0, lo, % acc2
+ % error
+}
+
+
+
+#define SET_ZERO(x) x.lo32 = x.hi32 = 0
+
+#define MADD64(w64, a, b) madd64(a, b); w64.lo32 = madd64lo(w64.lo32); w64.hi32 = madd64hi(w64.hi32);
+
+#define ADD64(x64, y64) x64.lo32 = add64_lo(x64.lo32,y64.lo32); x64.hi32 = add64_hi(x64.hi32,y64.hi32);
+
+#endif /* _ASSEMBLY_H */
diff --git a/audio_codec/libfaad/helixaac/bitstream.c b/audio_codec/libfaad/helixaac/bitstream.c
new file mode 100644
index 0000000..3ae6eed
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/bitstream.c
@@ -0,0 +1,261 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: bitstream.c,v 1.1.2.1.6.1 2005/10/19 00:18:49 gwright Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * bitstream.c - bitstream parsing functions
+ **************************************************************************************/
+
+#include "bitstream.h"
+
+/**************************************************************************************
+ * Function: SetBitstreamPointer
+ *
+ * Description: initialize bitstream reader
+ *
+ * Inputs: pointer to BitStreamInfo struct
+ * number of bytes in bitstream
+ * pointer to byte-aligned buffer of data to read from
+ *
+ * Outputs: initialized bitstream info struct
+ *
+ * Return: none
+ **************************************************************************************/
+void SetBitstreamPointer(BitStreamInfo *bsi, int nBytes, unsigned char *buf)
+{
+ /* init bitstream */
+ bsi->bytePtr = buf;
+ bsi->iCache = 0; /* 4-byte unsigned int */
+ bsi->cachedBits = 0; /* i.e. zero bits in cache */
+ bsi->nBytes = nBytes;
+}
+
+/**************************************************************************************
+ * Function: RefillBitstreamCache
+ *
+ * Description: read new data from bitstream buffer into 32-bit cache
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ *
+ * Outputs: updated bitstream info struct
+ *
+ * Return: none
+ *
+ * Notes: only call when iCache is completely drained (resets bitOffset to 0)
+ * always loads 4 new bytes except when bsi->nBytes < 4 (end of buffer)
+ * stores data as big-endian in cache, regardless of machine endian-ness
+ **************************************************************************************/
+static __inline void RefillBitstreamCache(BitStreamInfo *bsi)
+{
+ int nBytes = bsi->nBytes;
+
+ /* optimize for common case, independent of machine endian-ness */
+ if (nBytes >= 4) {
+ bsi->iCache = (*bsi->bytePtr++) << 24;
+ bsi->iCache |= (*bsi->bytePtr++) << 16;
+ bsi->iCache |= (*bsi->bytePtr++) << 8;
+ bsi->iCache |= (*bsi->bytePtr++);
+ bsi->cachedBits = 32;
+ bsi->nBytes -= 4;
+ } else {
+ bsi->iCache = 0;
+ while (nBytes--) {
+ bsi->iCache |= (*bsi->bytePtr++);
+ bsi->iCache <<= 8;
+ }
+ bsi->iCache <<= ((3 - bsi->nBytes) * 8);
+ bsi->cachedBits = 8 * bsi->nBytes;
+ bsi->nBytes = 0;
+ }
+}
+
+/**************************************************************************************
+ * Function: GetBits
+ *
+ * Description: get bits from bitstream, advance bitstream pointer
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ * number of bits to get from bitstream
+ *
+ * Outputs: updated bitstream info struct
+ *
+ * Return: the next nBits bits of data from bitstream buffer
+ *
+ * Notes: nBits must be in range [0, 31], nBits outside this range masked by 0x1f
+ * for speed, does not indicate error if you overrun bit buffer
+ * if nBits == 0, returns 0
+ **************************************************************************************/
+unsigned int GetBits(BitStreamInfo *bsi, int nBits)
+{
+ unsigned int data, lowBits;
+
+ nBits &= 0x1f; /* nBits mod 32 to avoid unpredictable results like >> by negative amount */
+ data = bsi->iCache >> (31 - nBits); /* unsigned >> so zero-extend */
+ data >>= 1; /* do as >> 31, >> 1 so that nBits = 0 works okay (returns 0) */
+ bsi->iCache <<= nBits; /* left-justify cache */
+ bsi->cachedBits -= nBits; /* how many bits have we drawn from the cache so far */
+
+ /* if we cross an int boundary, refill the cache */
+ if (bsi->cachedBits < 0) {
+ lowBits = -bsi->cachedBits;
+ RefillBitstreamCache(bsi);
+ data |= bsi->iCache >> (32 - lowBits); /* get the low-order bits */
+
+ bsi->cachedBits -= lowBits; /* how many bits have we drawn from the cache so far */
+ bsi->iCache <<= lowBits; /* left-justify cache */
+ }
+
+ return data;
+}
+
+/**************************************************************************************
+ * Function: GetBitsNoAdvance
+ *
+ * Description: get bits from bitstream, do not advance bitstream pointer
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ * number of bits to get from bitstream
+ *
+ * Outputs: none (state of BitStreamInfo struct left unchanged)
+ *
+ * Return: the next nBits bits of data from bitstream buffer
+ *
+ * Notes: nBits must be in range [0, 31], nBits outside this range masked by 0x1f
+ * for speed, does not indicate error if you overrun bit buffer
+ * if nBits == 0, returns 0
+ **************************************************************************************/
+unsigned int GetBitsNoAdvance(BitStreamInfo *bsi, int nBits)
+{
+ unsigned char *buf;
+ unsigned int data, iCache;
+ signed int lowBits;
+
+ nBits &= 0x1f; /* nBits mod 32 to avoid unpredictable results like >> by negative amount */
+ data = bsi->iCache >> (31 - nBits); /* unsigned >> so zero-extend */
+ data >>= 1; /* do as >> 31, >> 1 so that nBits = 0 works okay (returns 0) */
+ lowBits = nBits - bsi->cachedBits; /* how many bits do we have left to read */
+
+ /* if we cross an int boundary, read next bytes in buffer */
+ if (lowBits > 0) {
+ iCache = 0;
+ buf = bsi->bytePtr;
+ while (lowBits > 0) {
+ iCache <<= 8;
+ if (buf < bsi->bytePtr + bsi->nBytes) {
+ iCache |= (unsigned int) * buf++;
+ }
+ lowBits -= 8;
+ }
+ lowBits = -lowBits;
+ data |= iCache >> lowBits;
+ }
+
+ return data;
+}
+
+/**************************************************************************************
+ * Function: AdvanceBitstream
+ *
+ * Description: move bitstream pointer ahead
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ * number of bits to advance bitstream
+ *
+ * Outputs: updated bitstream info struct
+ *
+ * Return: none
+ *
+ * Notes: generally used following GetBitsNoAdvance(bsi, maxBits)
+ **************************************************************************************/
+void AdvanceBitstream(BitStreamInfo *bsi, int nBits)
+{
+ nBits &= 0x1f;
+ if (nBits > bsi->cachedBits) {
+ nBits -= bsi->cachedBits;
+ RefillBitstreamCache(bsi);
+ }
+ bsi->iCache <<= nBits;
+ bsi->cachedBits -= nBits;
+}
+
+/**************************************************************************************
+ * Function: CalcBitsUsed
+ *
+ * Description: calculate how many bits have been read from bitstream
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ * pointer to start of bitstream buffer
+ * bit offset into first byte of startBuf (0-7)
+ *
+ * Outputs: none
+ *
+ * Return: number of bits read from bitstream, as offset from startBuf:startOffset
+ **************************************************************************************/
+int CalcBitsUsed(BitStreamInfo *bsi, unsigned char *startBuf, int startOffset)
+{
+ int bitsUsed;
+
+ bitsUsed = (bsi->bytePtr - startBuf) * 8;
+ bitsUsed -= bsi->cachedBits;
+ bitsUsed -= startOffset;
+
+ return bitsUsed;
+}
+
+/**************************************************************************************
+ * Function: ByteAlignBitstream
+ *
+ * Description: bump bitstream pointer to start of next byte
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ *
+ * Outputs: byte-aligned bitstream BitStreamInfo struct
+ *
+ * Return: none
+ *
+ * Notes: if bitstream is already byte-aligned, do nothing
+ **************************************************************************************/
+void ByteAlignBitstream(BitStreamInfo *bsi)
+{
+ int offset;
+
+ offset = bsi->cachedBits & 0x07;
+ AdvanceBitstream(bsi, offset);
+}
diff --git a/audio_codec/libfaad/helixaac/bitstream.h b/audio_codec/libfaad/helixaac/bitstream.h
new file mode 100644
index 0000000..5bfc54d
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/bitstream.h
@@ -0,0 +1,74 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: bitstream.h,v 1.1.2.1 2005/02/26 02:05:12 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * bitstream.h - definitions of bitstream handling functions
+ **************************************************************************************/
+
+#ifndef _BITSTREAM_H
+#define _BITSTREAM_H
+
+#include "aaccommon.h"
+
+/* additional external symbols to name-mangle for static linking */
+#define SetBitstreamPointer STATNAME(SetBitstreamPointer)
+#define GetBits STATNAME(GetBits)
+#define GetBitsNoAdvance STATNAME(GetBitsNoAdvance)
+#define AdvanceBitstream STATNAME(AdvanceBitstream)
+#define CalcBitsUsed STATNAME(CalcBitsUsed)
+#define ByteAlignBitstream STATNAME(ByteAlignBitstream)
+
+typedef struct _BitStreamInfo {
+ unsigned char *bytePtr;
+ unsigned int iCache;
+ int cachedBits;
+ int nBytes;
+} BitStreamInfo;
+
+/* bitstream.c */
+void SetBitstreamPointer(BitStreamInfo *bsi, int nBytes, unsigned char *buf);
+unsigned int GetBits(BitStreamInfo *bsi, int nBits);
+unsigned int GetBitsNoAdvance(BitStreamInfo *bsi, int nBits);
+void AdvanceBitstream(BitStreamInfo *bsi, int nBits);
+int CalcBitsUsed(BitStreamInfo *bsi, unsigned char *startBuf, int startOffset);
+void ByteAlignBitstream(BitStreamInfo *bsi);
+
+#endif /* _BITSTREAM_H */
diff --git a/audio_codec/libfaad/helixaac/buffers.c b/audio_codec/libfaad/helixaac/buffers.c
new file mode 100644
index 0000000..2428213
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/buffers.c
@@ -0,0 +1,140 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: buffers.c,v 1.1.2.1 2005/02/26 02:05:12 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * buffers.c - allocation and deallocation of internal AAC decoder buffers
+ **************************************************************************************/
+
+#ifdef USE_DEFAULT_STDLIB
+#include <stdlib.h>
+#else
+#include "hlxclib/stdlib.h"
+#endif
+
+#include "coder.h"
+
+/**************************************************************************************
+ * Function: ClearBuffer
+ *
+ * Description: fill buffer with 0's
+ *
+ * Inputs: pointer to buffer
+ * number of bytes to fill with 0
+ *
+ * Outputs: cleared buffer
+ *
+ * Return: none
+ *
+ * Notes: slow, platform-independent equivalent to memset(buf, 0, nBytes)
+ **************************************************************************************/
+void ClearBuffer(void *buf, int nBytes)
+{
+ int i;
+ unsigned char *cbuf = (unsigned char *)buf;
+
+ for (i = 0; i < nBytes; i++) {
+ cbuf[i] = 0;
+ }
+
+ return;
+}
+
+/**************************************************************************************
+ * Function: AllocateBuffers
+ *
+ * Description: allocate all the memory needed for the AAC decoder
+ *
+ * Inputs: none
+ *
+ * Outputs: none
+ *
+ * Return: pointer to AACDecInfo structure, cleared to all 0's (except for
+ * pointer to platform-specific data structure)
+ *
+ * Notes: if one or more mallocs fail, function frees any buffers already
+ * allocated before returning
+ **************************************************************************************/
+AACDecInfo *AllocateBuffers(void)
+{
+ AACDecInfo *aacDecInfo;
+
+ aacDecInfo = (AACDecInfo *)malloc(sizeof(AACDecInfo));
+ if (!aacDecInfo) {
+ return 0;
+ }
+ ClearBuffer(aacDecInfo, sizeof(AACDecInfo));
+
+ aacDecInfo->psInfoBase = malloc(sizeof(PSInfoBase));
+ if (!aacDecInfo->psInfoBase) {
+ FreeBuffers(aacDecInfo);
+ return 0;
+ }
+ ClearBuffer(aacDecInfo->psInfoBase, sizeof(PSInfoBase));
+
+ return aacDecInfo;
+}
+
+#ifndef SAFE_FREE
+#define SAFE_FREE(x) {if (x) free(x); (x) = 0;} /* helper macro */
+#endif
+
+/**************************************************************************************
+ * Function: FreeBuffers
+ *
+ * Description: frees all the memory used by the AAC decoder
+ *
+ * Inputs: pointer to initialized AACDecInfo structure
+ *
+ * Outputs: none
+ *
+ * Return: none
+ *
+ * Notes: safe to call even if some buffers were not allocated (uses SAFE_FREE)
+ **************************************************************************************/
+void FreeBuffers(AACDecInfo *aacDecInfo)
+{
+ if (!aacDecInfo) {
+ return;
+ }
+
+ SAFE_FREE(aacDecInfo->psInfoBase);
+ SAFE_FREE(aacDecInfo);
+}
diff --git a/audio_codec/libfaad/helixaac/coder.h b/audio_codec/libfaad/helixaac/coder.h
new file mode 100644
index 0000000..d57e5d7
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/coder.h
@@ -0,0 +1,369 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: coder.h,v 1.2 2005/06/27 21:06:00 gwright Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * coder.h - definitions of platform-specific data structures, functions, and tables
+ **************************************************************************************/
+
+#ifndef _CODER_H
+#define _CODER_H
+
+#include "aaccommon.h"
+#include "bitstream.h"
+
+#if 1//ndef ASSERT
+#if 0// defined(_WIN32) && defined(_M_IX86) && (defined (_DEBUG) || defined (REL_ENABLE_ASSERTS))
+#define ASSERT(x) if (!(x)) __asm int 3;
+#else
+#define ASSERT(x,errid) do{if(!(x)) {/*printk(" aac decoder error ,errid %d\n",(errid));*/return (errid);}}while(0)/* do nothing */
+#endif
+#endif
+
+#ifndef MAX
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+#ifndef MIN
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+#define NWINDOWS_LONG 1
+#define NWINDOWS_SHORT 8
+
+#define DATA_BUF_SIZE 510 /* max count = 255 + 255 */
+#define FILL_BUF_SIZE 269 /* max count = 15 + 255 - 1*/
+#define ADIF_COPYID_SIZE 9
+#define MAX_COMMENT_BYTES 255
+
+#define MAX_NUM_FCE 15
+#define MAX_NUM_SCE 15
+#define MAX_NUM_BCE 15
+#define MAX_NUM_LCE 3
+#define MAX_NUM_ADE 7
+#define MAX_NUM_CCE 15
+
+#define CHAN_ELEM_IS_CPE(x) (((x) & 0x10) >> 4) /* bit 4 = SCE/CPE flag */
+#define CHAN_ELEM_GET_TAG(x) (((x) & 0x0f) >> 0) /* bits 3-0 = instance tag */
+
+#define CHAN_ELEM_SET_CPE(x) (((x) & 0x01) << 4) /* bit 4 = SCE/CPE flag */
+#define CHAN_ELEM_SET_TAG(x) (((x) & 0x0f) << 0) /* bits 3-0 = instance tag */
+
+#define MAX_HUFF_BITS 20
+#define HUFFTAB_SPEC_OFFSET 1
+
+/* do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) */
+#define CLIP_2N_SHIFT(y, n) { \
+ int sign = (y) >> 31; \
+ if (sign != (y) >> (30 - (n))) { \
+ (y) = sign ^ (0x3fffffff); \
+ } else { \
+ (y) = (y) << (n); \
+ } \
+ }
+
+/* clip to [-2^n, 2^n-1], valid range of n = [1, 30] */
+#define CLIP_2N(val, n) { \
+ if ((val) >> 31 != (val) >> (n)) \
+ (val) = ((val) >> 31) ^ ((1 << (n)) - 1); \
+ }
+
+#define SF_DQ_OFFSET 15
+#define FBITS_OUT_DQ 20
+#define FBITS_OUT_DQ_OFF (FBITS_OUT_DQ - SF_DQ_OFFSET) /* number of fraction bits out of dequant, including 2^15 bias */
+
+#define FBITS_IN_IMDCT FBITS_OUT_DQ_OFF /* number of fraction bits into IMDCT */
+#define GBITS_IN_DCT4 4 /* min guard bits in for DCT4 */
+
+#define FBITS_LOST_DCT4 1 /* number of fraction bits lost (>> out) in DCT-IV */
+#define FBITS_LOST_WND 1 /* number of fraction bits lost (>> out) in synthesis window (neg = gain frac bits) */
+#define FBITS_LOST_IMDCT (FBITS_LOST_DCT4 + FBITS_LOST_WND)
+#define FBITS_OUT_IMDCT (FBITS_IN_IMDCT - FBITS_LOST_IMDCT)
+
+#define NUM_IMDCT_SIZES 2
+
+/* additional external symbols to name-mangle for static linking */
+#define DecodeProgramConfigElement STATNAME(DecodeProgramConfigElement)
+#define DecodeHuffmanScalar STATNAME(DecodeHuffmanScalar)
+#define DecodeSpectrumLong STATNAME(DecodeSpectrumLong)
+#define DecodeSpectrumShort STATNAME(DecodeSpectrumShort)
+#define DecodeICSInfo STATNAME(DecodeICSInfo)
+#define DCT4 STATNAME(DCT4)
+#define R4FFT STATNAME(R4FFT)
+
+#define DecWindowOverlapNoClip STATNAME(DecWindowOverlapNoClip)
+#define DecWindowOverlapLongStartNoClip STATNAME(DecWindowOverlapLongStartNoClip)
+#define DecWindowOverlapLongStopNoClip STATNAME(DecWindowOverlapLongStopNoClip)
+#define DecWindowOverlapShortNoClip STATNAME(DecWindowOverlapShortNoClip)
+
+#define huffTabSpecInfo STATNAME(huffTabSpecInfo)
+#define huffTabSpec STATNAME(huffTabSpec)
+#define huffTabScaleFactInfo STATNAME(huffTabScaleFactInfo)
+#define huffTabScaleFact STATNAME(huffTabScaleFact)
+#define cos4sin4tab STATNAME(cos4sin4tab)
+#define cos4sin4tabOffset STATNAME(cos4sin4tabOffset)
+#define cos1sin1tab STATNAME(cos1sin1tab)
+#define sinWindow STATNAME(sinWindow)
+#define sinWindowOffset STATNAME(sinWindowOffset)
+#define kbdWindow STATNAME(kbdWindow)
+#define kbdWindowOffset STATNAME(kbdWindowOffset)
+#define bitrevtab STATNAME(bitrevtab)
+#define bitrevtabOffset STATNAME(bitrevtabOffset)
+#define uniqueIDTab STATNAME(uniqueIDTab)
+#define twidTabEven STATNAME(twidTabEven)
+#define twidTabOdd STATNAME(twidTabOdd)
+
+typedef struct _HuffInfo {
+ int maxBits; /* number of bits in longest codeword */
+ unsigned char count[MAX_HUFF_BITS]; /* count[i] = number of codes with length i+1 bits */
+ int offset; /* offset into symbol table */
+} HuffInfo;
+
+typedef struct _PulseInfo {
+ unsigned char pulseDataPresent;
+ unsigned char numPulse;
+ unsigned char startSFB;
+ unsigned char offset[MAX_PULSES];
+ unsigned char amp[MAX_PULSES];
+} PulseInfo;
+
+typedef struct _TNSInfo {
+ unsigned char tnsDataPresent;
+ unsigned char numFilt[MAX_TNS_FILTERS]; /* max 1 filter each for 8 short windows, or 3 filters for 1 long window */
+ unsigned char coefRes[MAX_TNS_FILTERS];
+ unsigned char length[MAX_TNS_FILTERS];
+ unsigned char order[MAX_TNS_FILTERS];
+ unsigned char dir[MAX_TNS_FILTERS];
+ signed char coef[MAX_TNS_COEFS]; /* max 3 filters * 20 coefs for 1 long window, or 1 filter * 7 coefs for each of 8 short windows */
+} TNSInfo;
+
+typedef struct _GainControlInfo {
+ unsigned char gainControlDataPresent;
+ unsigned char maxBand;
+ unsigned char adjNum[MAX_GAIN_BANDS][MAX_GAIN_WIN];
+ unsigned char alevCode[MAX_GAIN_BANDS][MAX_GAIN_WIN][MAX_GAIN_ADJUST];
+ unsigned char alocCode[MAX_GAIN_BANDS][MAX_GAIN_WIN][MAX_GAIN_ADJUST];
+} GainControlInfo;
+
+typedef struct _ICSInfo {
+ unsigned char icsResBit;
+ unsigned char winSequence;
+ unsigned char winShape;
+ unsigned char maxSFB;
+ unsigned char sfGroup;
+ unsigned char predictorDataPresent;
+ unsigned char predictorReset;
+ unsigned char predictorResetGroupNum;
+ unsigned char predictionUsed[MAX_PRED_SFB];
+ unsigned char numWinGroup;
+ unsigned char winGroupLen[MAX_WIN_GROUPS];
+} ICSInfo;
+
+typedef struct _ADTSHeader {
+ /* fixed */
+ unsigned char id; /* MPEG bit - should be 1 */
+ unsigned char layer; /* MPEG layer - should be 0 */
+ unsigned char protectBit; /* 0 = CRC word follows, 1 = no CRC word */
+ unsigned char profile; /* 0 = main, 1 = LC, 2 = SSR, 3 = reserved */
+ unsigned char sampRateIdx; /* sample rate index range = [0, 11] */
+ unsigned char privateBit; /* ignore */
+ unsigned char channelConfig; /* 0 = implicit, >0 = use default table */
+ unsigned char origCopy; /* 0 = copy, 1 = original */
+ unsigned char home; /* ignore */
+
+ /* variable */
+ unsigned char copyBit; /* 1 bit of the 72-bit copyright ID (transmitted as 1 bit per frame) */
+ unsigned char copyStart; /* 1 = this bit starts the 72-bit ID, 0 = it does not */
+ int frameLength; /* length of frame */
+ int bufferFull; /* number of 32-bit words left in enc buffer, 0x7FF = VBR */
+ unsigned char numRawDataBlocks; /* number of raw data blocks in frame */
+
+ /* CRC */
+ int crcCheckWord; /* 16-bit CRC check word (present if protectBit == 0) */
+} ADTSHeader;
+
+typedef struct _ADIFHeader {
+ unsigned char copyBit; /* 0 = no copyright ID, 1 = 72-bit copyright ID follows immediately */
+ unsigned char origCopy; /* 0 = copy, 1 = original */
+ unsigned char home; /* ignore */
+ unsigned char bsType; /* bitstream type: 0 = CBR, 1 = VBR */
+ int bitRate; /* bitRate: CBR = bits/sec, VBR = peak bits/frame, 0 = unknown */
+ unsigned char numPCE; /* number of program config elements (max = 16) */
+ int bufferFull; /* bits left in bit reservoir */
+ unsigned char copyID[ADIF_COPYID_SIZE]; /* optional 72-bit copyright ID */
+} ADIFHeader;
+
+/* sizeof(ProgConfigElement) = 82 bytes (if KEEP_PCE_COMMENTS not defined) */
+typedef struct _ProgConfigElement {
+ unsigned char elemInstTag; /* element instance tag */
+ unsigned char profile; /* 0 = main, 1 = LC, 2 = SSR, 3 = reserved */
+ unsigned char sampRateIdx; /* sample rate index range = [0, 11] */
+ unsigned char numFCE; /* number of front channel elements (max = 15) */
+ unsigned char numSCE; /* number of side channel elements (max = 15) */
+ unsigned char numBCE; /* number of back channel elements (max = 15) */
+ unsigned char numLCE; /* number of LFE channel elements (max = 3) */
+ unsigned char numADE; /* number of associated data elements (max = 7) */
+ unsigned char numCCE; /* number of valid channel coupling elements (max = 15) */
+ unsigned char monoMixdown; /* mono mixdown: bit 4 = present flag, bits 3-0 = element number */
+ unsigned char stereoMixdown; /* stereo mixdown: bit 4 = present flag, bits 3-0 = element number */
+ unsigned char matrixMixdown; /* matrix mixdown: bit 4 = present flag, bit 3 = unused,
+ bits 2-1 = index, bit 0 = pseudo-surround enable */
+ unsigned char fce[MAX_NUM_FCE]; /* front element channel pair: bit 4 = SCE/CPE flag, bits 3-0 = inst tag */
+ unsigned char sce[MAX_NUM_SCE]; /* side element channel pair: bit 4 = SCE/CPE flag, bits 3-0 = inst tag */
+ unsigned char bce[MAX_NUM_BCE]; /* back element channel pair: bit 4 = SCE/CPE flag, bits 3-0 = inst tag */
+ unsigned char lce[MAX_NUM_LCE]; /* instance tag for LFE elements */
+ unsigned char ade[MAX_NUM_ADE]; /* instance tag for ADE elements */
+ unsigned char cce[MAX_NUM_BCE]; /* channel coupling elements: bit 4 = switching flag, bits 3-0 = inst tag */
+
+#ifdef KEEP_PCE_COMMENTS
+ /* make this optional - if not enabled, decoder will just skip comments */
+ unsigned char commentBytes;
+ unsigned char commentField[MAX_COMMENT_BYTES];
+#endif
+
+} ProgConfigElement;
+
+/* state info struct for baseline (MPEG-4 LC) decoding */
+typedef struct _PSInfoBase {
+ /* header information */
+ ADTSHeader fhADTS;
+ ADIFHeader fhADIF;
+ ProgConfigElement pce[MAX_NUM_PCE_ADIF];
+ int dataCount;
+ unsigned char dataBuf[DATA_BUF_SIZE];
+ int fillCount;
+ unsigned char fillBuf[FILL_BUF_SIZE];
+
+ /* state information which is the same throughout whole frame */
+ int nChans;
+ int useImpChanMap;
+ int sampRateIdx;
+
+ /* state information which can be overwritten by subsequent elements within frame */
+ ICSInfo icsInfo[MAX_NCHANS_ELEM];
+
+ int commonWin;
+ short scaleFactors[MAX_NCHANS_ELEM][MAX_SF_BANDS];
+ unsigned char sfbCodeBook[MAX_NCHANS_ELEM][MAX_SF_BANDS];
+
+ int msMaskPresent;
+ unsigned char msMaskBits[MAX_MS_MASK_BYTES];
+
+ int pnsUsed[MAX_NCHANS_ELEM];
+ int pnsLastVal;
+ int intensityUsed[MAX_NCHANS_ELEM];
+
+ PulseInfo pulseInfo[MAX_NCHANS_ELEM];
+
+ TNSInfo tnsInfo[MAX_NCHANS_ELEM];
+ int tnsLPCBuf[MAX_TNS_ORDER];
+ int tnsWorkBuf[MAX_TNS_ORDER];
+
+ GainControlInfo gainControlInfo[MAX_NCHANS_ELEM];
+
+ int gbCurrent[MAX_NCHANS_ELEM];
+ int coef[MAX_NCHANS_ELEM][AAC_MAX_NSAMPS];
+#ifdef AAC_ENABLE_SBR
+ int sbrWorkBuf[MAX_NCHANS_ELEM][AAC_MAX_NSAMPS];
+#endif
+ /* state information which must be saved for each element and used in next frame */
+ int overlap[AAC_MAX_NCHANS][AAC_MAX_NSAMPS];
+ int prevWinShape[AAC_MAX_NCHANS];
+
+} PSInfoBase;
+
+/* private implementation-specific functions */
+
+/* decelmnt.c */
+int DecodeProgramConfigElement(ProgConfigElement *pce, BitStreamInfo *bsi);
+
+/* huffman.c */
+int DecodeHuffmanScalar(const signed short *huffTab, const HuffInfo *huffTabInfo, unsigned int bitBuf, signed int *val);
+int DecodeSpectrumLong(PSInfoBase *psi, BitStreamInfo *bsi, int ch);
+int DecodeSpectrumShort(PSInfoBase *psi, BitStreamInfo *bsi, int ch);
+
+/* noiseless.c */
+void DecodeICSInfo(BitStreamInfo *bsi, ICSInfo *icsInfo, int sampRateIdx);
+
+/* dct4.c */
+void DCT4(int tabidx, int *coef, int gb);
+
+/* fft.c */
+void R4FFT(int tabidx, int *x);
+
+/* sbrimdct.c */
+void DecWindowOverlapNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev);
+void DecWindowOverlapLongStartNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev);
+void DecWindowOverlapLongStopNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev);
+void DecWindowOverlapShortNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev);
+
+/* hufftabs.c */
+extern const HuffInfo huffTabSpecInfo[11];
+extern const signed short huffTabSpec[1241];
+extern const HuffInfo huffTabScaleFactInfo;
+extern const signed short huffTabScaleFact[121];
+
+/* trigtabs.c */
+extern const int cos4sin4tabOffset[NUM_IMDCT_SIZES];
+extern const int sinWindowOffset[NUM_IMDCT_SIZES];
+extern const int kbdWindowOffset[NUM_IMDCT_SIZES];
+extern const unsigned char bitrevtab[17 + 129];
+extern const int bitrevtabOffset[NUM_IMDCT_SIZES];
+
+#ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT
+/* trigtabs_fltgen.c */
+extern int cos4sin4tab[128 + 1024];
+extern int cos1sin1tab[514];
+extern int sinWindow[128 + 1024];
+extern int kbdWindow[128 + 1024];
+extern int twidTabEven[4 * 6 + 16 * 6 + 64 * 6];
+extern int twidTabOdd[8 * 6 + 32 * 6 + 128 * 6];
+#else
+/* trigtabs.c */
+extern const int cos4sin4tab[128 + 1024];
+extern const int cos1sin1tab[514];
+extern const int sinWindow[128 + 1024];
+extern const int kbdWindow[128 + 1024];
+extern const int twidTabEven[4 * 6 + 16 * 6 + 64 * 6];
+extern const int twidTabOdd[8 * 6 + 32 * 6 + 128 * 6];
+#endif
+
+#endif /* _CODER_H */
+
diff --git a/audio_codec/libfaad/helixaac/dct4.c b/audio_codec/libfaad/helixaac/dct4.c
new file mode 100644
index 0000000..3182479
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/dct4.c
@@ -0,0 +1,337 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: dct4.c,v 1.1.2.1 2005/02/26 02:05:12 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * dct4.c - optimized DCT-IV
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+static const int nmdctTab[NUM_IMDCT_SIZES] = {128, 1024};
+static const int postSkip[NUM_IMDCT_SIZES] = {15, 1};
+
+/**************************************************************************************
+ * Function: PreMultiply
+ *
+ * Description: pre-twiddle stage of DCT4
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmdct samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: minimum 1 GB in, 2 GB out, gains 5 (short) or 8 (long) frac bits
+ * i.e. gains 2-7= -5 int bits (short) or 2-10 = -8 int bits (long)
+ * normalization by -1/N is rolled into tables here (see trigtabs.c)
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ **************************************************************************************/
+static void PreMultiply(int tabidx, int *zbuf1)
+{
+ int i, nmdct, ar1, ai1, ar2, ai2, z1, z2;
+ int t, cms2, cps2a, sin2a, cps2b, sin2b;
+ int *zbuf2;
+ const int *csptr;
+
+ nmdct = nmdctTab[tabidx];
+ zbuf2 = zbuf1 + nmdct - 1;
+ csptr = cos4sin4tab + cos4sin4tabOffset[tabidx];
+
+ /* whole thing should fit in registers - verify that compiler does this */
+ for (i = nmdct >> 2; i != 0; i--) {
+ /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */
+ cps2a = *csptr++;
+ sin2a = *csptr++;
+ cps2b = *csptr++;
+ sin2b = *csptr++;
+
+ ar1 = *(zbuf1 + 0);
+ ai2 = *(zbuf1 + 1);
+ ai1 = *(zbuf2 + 0);
+ ar2 = *(zbuf2 - 1);
+
+ /* gain 2 ints bit from MULSHIFT32 by Q30, but drop 7 or 10 int bits from table scaling of 1/M
+ * max per-sample gain (ignoring implicit scaling) = MAX(sin(angle)+cos(angle)) = 1.414
+ * i.e. gain 1 GB since worst case is sin(angle) = cos(angle) = 0.707 (Q30), gain 2 from
+ * extra sign bits, and eat one in adding
+ */
+ t = MULSHIFT32(sin2a, ar1 + ai1);
+ z2 = MULSHIFT32(cps2a, ai1) - t;
+ cms2 = cps2a - 2 * sin2a;
+ z1 = MULSHIFT32(cms2, ar1) + t;
+ *zbuf1++ = z1; /* cos*ar1 + sin*ai1 */
+ *zbuf1++ = z2; /* cos*ai1 - sin*ar1 */
+
+ t = MULSHIFT32(sin2b, ar2 + ai2);
+ z2 = MULSHIFT32(cps2b, ai2) - t;
+ cms2 = cps2b - 2 * sin2b;
+ z1 = MULSHIFT32(cms2, ar2) + t;
+ *zbuf2-- = z2; /* cos*ai2 - sin*ar2 */
+ *zbuf2-- = z1; /* cos*ar2 + sin*ai2 */
+ }
+}
+
+/**************************************************************************************
+ * Function: PostMultiply
+ *
+ * Description: post-twiddle stage of DCT4
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmdct samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: minimum 1 GB in, 2 GB out - gains 2 int bits
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ **************************************************************************************/
+static void PostMultiply(int tabidx, int *fft1)
+{
+ int i, nmdct, ar1, ai1, ar2, ai2, skipFactor;
+ int t, cms2, cps2, sin2;
+ int *fft2;
+ const int *csptr;
+
+ nmdct = nmdctTab[tabidx];
+ csptr = cos1sin1tab;
+ skipFactor = postSkip[tabidx];
+ fft2 = fft1 + nmdct - 1;
+
+ /* load coeffs for first pass
+ * cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin)
+ */
+ cps2 = *csptr++;
+ sin2 = *csptr;
+ csptr += skipFactor;
+ cms2 = cps2 - 2 * sin2;
+
+ for (i = nmdct >> 2; i != 0; i--) {
+ ar1 = *(fft1 + 0);
+ ai1 = *(fft1 + 1);
+ ar2 = *(fft2 - 1);
+ ai2 = *(fft2 + 0);
+
+ /* gain 2 ints bit from MULSHIFT32 by Q30
+ * max per-sample gain = MAX(sin(angle)+cos(angle)) = 1.414
+ * i.e. gain 1 GB since worst case is sin(angle) = cos(angle) = 0.707 (Q30), gain 2 from
+ * extra sign bits, and eat one in adding
+ */
+ t = MULSHIFT32(sin2, ar1 + ai1);
+ *fft2-- = t - MULSHIFT32(cps2, ai1); /* sin*ar1 - cos*ai1 */
+ *fft1++ = t + MULSHIFT32(cms2, ar1); /* cos*ar1 + sin*ai1 */
+ cps2 = *csptr++;
+ sin2 = *csptr;
+ csptr += skipFactor;
+
+ ai2 = -ai2;
+ t = MULSHIFT32(sin2, ar2 + ai2);
+ *fft2-- = t - MULSHIFT32(cps2, ai2); /* sin*ar1 - cos*ai1 */
+ cms2 = cps2 - 2 * sin2;
+ *fft1++ = t + MULSHIFT32(cms2, ar2); /* cos*ar1 + sin*ai1 */
+ }
+}
+
+/**************************************************************************************
+ * Function: PreMultiplyRescale
+ *
+ * Description: pre-twiddle stage of DCT4, with rescaling for extra guard bits
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmdct samples
+ * number of guard bits to add to input before processing
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: see notes on PreMultiply(), above
+ **************************************************************************************/
+static void PreMultiplyRescale(int tabidx, int *zbuf1, int es)
+{
+ int i, nmdct, ar1, ai1, ar2, ai2, z1, z2;
+ int t, cms2, cps2a, sin2a, cps2b, sin2b;
+ int *zbuf2;
+ const int *csptr;
+
+ nmdct = nmdctTab[tabidx];
+ zbuf2 = zbuf1 + nmdct - 1;
+ csptr = cos4sin4tab + cos4sin4tabOffset[tabidx];
+
+ /* whole thing should fit in registers - verify that compiler does this */
+ for (i = nmdct >> 2; i != 0; i--) {
+ /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */
+ cps2a = *csptr++;
+ sin2a = *csptr++;
+ cps2b = *csptr++;
+ sin2b = *csptr++;
+
+ ar1 = *(zbuf1 + 0) >> es;
+ ai1 = *(zbuf2 + 0) >> es;
+ ai2 = *(zbuf1 + 1) >> es;
+
+ t = MULSHIFT32(sin2a, ar1 + ai1);
+ z2 = MULSHIFT32(cps2a, ai1) - t;
+ cms2 = cps2a - 2 * sin2a;
+ z1 = MULSHIFT32(cms2, ar1) + t;
+ *zbuf1++ = z1;
+ *zbuf1++ = z2;
+
+ ar2 = *(zbuf2 - 1) >> es; /* do here to free up register used for es */
+
+ t = MULSHIFT32(sin2b, ar2 + ai2);
+ z2 = MULSHIFT32(cps2b, ai2) - t;
+ cms2 = cps2b - 2 * sin2b;
+ z1 = MULSHIFT32(cms2, ar2) + t;
+ *zbuf2-- = z2;
+ *zbuf2-- = z1;
+
+ }
+}
+
+/**************************************************************************************
+ * Function: PostMultiplyRescale
+ *
+ * Description: post-twiddle stage of DCT4, with rescaling for extra guard bits
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmdct samples
+ * number of guard bits to remove from output
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: clips output to [-2^30, 2^30 - 1], guaranteeing at least 1 guard bit
+ * see notes on PostMultiply(), above
+ **************************************************************************************/
+static void PostMultiplyRescale(int tabidx, int *fft1, int es)
+{
+ int i, nmdct, ar1, ai1, ar2, ai2, skipFactor, z;
+ int t, cs2, sin2;
+ int *fft2;
+ const int *csptr;
+
+ nmdct = nmdctTab[tabidx];
+ csptr = cos1sin1tab;
+ skipFactor = postSkip[tabidx];
+ fft2 = fft1 + nmdct - 1;
+
+ /* load coeffs for first pass
+ * cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin)
+ */
+ cs2 = *csptr++;
+ sin2 = *csptr;
+ csptr += skipFactor;
+
+ for (i = nmdct >> 2; i != 0; i--) {
+ ar1 = *(fft1 + 0);
+ ai1 = *(fft1 + 1);
+ ai2 = *(fft2 + 0);
+
+ t = MULSHIFT32(sin2, ar1 + ai1);
+ z = t - MULSHIFT32(cs2, ai1);
+ CLIP_2N_SHIFT(z, es);
+ *fft2-- = z;
+ cs2 -= 2 * sin2;
+ z = t + MULSHIFT32(cs2, ar1);
+ CLIP_2N_SHIFT(z, es);
+ *fft1++ = z;
+
+ cs2 = *csptr++;
+ sin2 = *csptr;
+ csptr += skipFactor;
+
+ ar2 = *fft2;
+ ai2 = -ai2;
+ t = MULSHIFT32(sin2, ar2 + ai2);
+ z = t - MULSHIFT32(cs2, ai2);
+ CLIP_2N_SHIFT(z, es);
+ *fft2-- = z;
+ cs2 -= 2 * sin2;
+ z = t + MULSHIFT32(cs2, ar2);
+ CLIP_2N_SHIFT(z, es);
+ *fft1++ = z;
+ cs2 += 2 * sin2;
+ }
+}
+
+/**************************************************************************************
+ * Function: DCT4
+ *
+ * Description: type-IV DCT
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmdct samples
+ * number of guard bits in the input buffer
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: operates in-place
+ * if number of guard bits in input is < GBITS_IN_DCT4, the input is
+ * scaled (>>) before the DCT4 and rescaled (<<, with clipping) after
+ * the DCT4 (rare)
+ * the output has FBITS_LOST_DCT4 fewer fraction bits than the input
+ * the output will always have at least 1 guard bit (GBITS_IN_DCT4 >= 4)
+ * int bits gained per stage (PreMul + FFT + PostMul)
+ * short blocks = (-5 + 4 + 2) = 1 total
+ * long blocks = (-8 + 7 + 2) = 1 total
+ **************************************************************************************/
+void DCT4(int tabidx, int *coef, int gb)
+{
+ int es;
+
+ /* fast in-place DCT-IV - adds guard bits if necessary */
+ if (gb < GBITS_IN_DCT4) {
+ es = GBITS_IN_DCT4 - gb;
+ PreMultiplyRescale(tabidx, coef, es);
+ R4FFT(tabidx, coef);
+ PostMultiplyRescale(tabidx, coef, es);
+ } else {
+ PreMultiply(tabidx, coef);
+ R4FFT(tabidx, coef);
+ PostMultiply(tabidx, coef);
+ }
+}
diff --git a/audio_codec/libfaad/helixaac/decelmnt.c b/audio_codec/libfaad/helixaac/decelmnt.c
new file mode 100644
index 0000000..4cd4ef8
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/decelmnt.c
@@ -0,0 +1,445 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: decelmnt.c,v 1.1.2.1 2005/02/26 02:05:12 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * decelmnt.c - syntactic element decoding
+ **************************************************************************************/
+
+#include "coder.h"
+
+/**************************************************************************************
+ * Function: DecodeSingleChannelElement
+ *
+ * Description: decode one SCE
+ *
+ * Inputs: BitStreamInfo struct pointing to start of SCE (14496-3, table 4.4.4)
+ *
+ * Outputs: updated element instance tag
+ *
+ * Return: 0 if successful, -1 if error
+ *
+ * Notes: doesn't decode individual channel stream (part of DecodeNoiselessData)
+ **************************************************************************************/
+static int DecodeSingleChannelElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
+{
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+
+ /* read instance tag */
+ aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS);
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeChannelPairElement
+ *
+ * Description: decode one CPE
+ *
+ * Inputs: BitStreamInfo struct pointing to start of CPE (14496-3, table 4.4.5)
+ *
+ * Outputs: updated element instance tag
+ * updated commonWin
+ * updated ICS info, if commonWin == 1
+ * updated mid-side stereo info, if commonWin == 1
+ *
+ * Return: 0 if successful, -1 if error
+ *
+ * Notes: doesn't decode individual channel stream (part of DecodeNoiselessData)
+ **************************************************************************************/
+static int DecodeChannelPairElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
+{
+ int sfb, gp, maskOffset;
+ unsigned char currBit, *maskPtr;
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = psi->icsInfo;
+
+ /* read instance tag */
+ aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS);
+
+ /* read common window flag and mid-side info (if present)
+ * store msMask bits in psi->msMaskBits[] as follows:
+ * long blocks - pack bits for each SFB in range [0, maxSFB) starting with lsb of msMaskBits[0]
+ * short blocks - pack bits for each SFB in range [0, maxSFB), for each group [0, 7]
+ * msMaskPresent = 0 means no M/S coding
+ * = 1 means psi->msMaskBits contains 1 bit per SFB to toggle M/S coding
+ * = 2 means all SFB's are M/S coded (so psi->msMaskBits is not needed)
+ */
+ psi->commonWin = GetBits(bsi, 1);
+ if (psi->commonWin) {
+ DecodeICSInfo(bsi, icsInfo, psi->sampRateIdx);
+ psi->msMaskPresent = GetBits(bsi, 2);
+ if (psi->msMaskPresent == 1) {
+ maskPtr = psi->msMaskBits;
+ *maskPtr = 0;
+ maskOffset = 0;
+ for (gp = 0; gp < icsInfo->numWinGroup; gp++) {
+ for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) {
+ currBit = (unsigned char)GetBits(bsi, 1);
+ *maskPtr |= currBit << maskOffset;
+ if (++maskOffset == 8) {
+ maskPtr++;
+ *maskPtr = 0;
+ maskOffset = 0;
+ }
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeLFEChannelElement
+ *
+ * Description: decode one LFE
+ *
+ * Inputs: BitStreamInfo struct pointing to start of LFE (14496-3, table 4.4.9)
+ *
+ * Outputs: updated element instance tag
+ *
+ * Return: 0 if successful, -1 if error
+ *
+ * Notes: doesn't decode individual channel stream (part of DecodeNoiselessData)
+ **************************************************************************************/
+static int DecodeLFEChannelElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
+{
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+
+ /* read instance tag */
+ aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS);
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeDataStreamElement
+ *
+ * Description: decode one DSE
+ *
+ * Inputs: BitStreamInfo struct pointing to start of DSE (14496-3, table 4.4.10)
+ *
+ * Outputs: updated element instance tag
+ * filled in data stream buffer
+ *
+ * Return: 0 if successful, -1 if error
+ **************************************************************************************/
+static int DecodeDataStreamElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
+{
+ unsigned int byteAlign, dataCount;
+ unsigned char *dataBuf;
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS);
+ byteAlign = GetBits(bsi, 1);
+ dataCount = GetBits(bsi, 8);
+ if (dataCount == 255) {
+ dataCount += GetBits(bsi, 8);
+ }
+
+ if (byteAlign) {
+ ByteAlignBitstream(bsi);
+ }
+
+ psi->dataCount = dataCount;
+ dataBuf = psi->dataBuf;
+ while (dataCount--) {
+ *dataBuf++ = GetBits(bsi, 8);
+ }
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeProgramConfigElement
+ *
+ * Description: decode one PCE
+ *
+ * Inputs: BitStreamInfo struct pointing to start of PCE (14496-3, table 4.4.2)
+ *
+ * Outputs: filled-in ProgConfigElement struct
+ * updated BitStreamInfo struct
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: #define KEEP_PCE_COMMENTS to save the comment field of the PCE
+ * (otherwise we just skip it in the bitstream, to save memory)
+ **************************************************************************************/
+int DecodeProgramConfigElement(ProgConfigElement *pce, BitStreamInfo *bsi)
+{
+ int i;
+
+ pce->elemInstTag = GetBits(bsi, 4);
+ pce->profile = GetBits(bsi, 2);
+ pce->sampRateIdx = GetBits(bsi, 4);
+ pce->numFCE = GetBits(bsi, 4);
+ pce->numSCE = GetBits(bsi, 4);
+ pce->numBCE = GetBits(bsi, 4);
+ pce->numLCE = GetBits(bsi, 2);
+ pce->numADE = GetBits(bsi, 3);
+ pce->numCCE = GetBits(bsi, 4);
+
+ pce->monoMixdown = GetBits(bsi, 1) << 4; /* present flag */
+ if (pce->monoMixdown) {
+ pce->monoMixdown |= GetBits(bsi, 4); /* element number */
+ }
+
+ pce->stereoMixdown = GetBits(bsi, 1) << 4; /* present flag */
+ if (pce->stereoMixdown) {
+ pce->stereoMixdown |= GetBits(bsi, 4); /* element number */
+ }
+
+ pce->matrixMixdown = GetBits(bsi, 1) << 4; /* present flag */
+ if (pce->matrixMixdown) {
+ pce->matrixMixdown |= GetBits(bsi, 2) << 1; /* index */
+ pce->matrixMixdown |= GetBits(bsi, 1); /* pseudo-surround enable */
+ }
+
+ for (i = 0; i < pce->numFCE; i++) {
+ pce->fce[i] = GetBits(bsi, 1) << 4; /* is_cpe flag */
+ pce->fce[i] |= GetBits(bsi, 4); /* tag select */
+ }
+
+ for (i = 0; i < pce->numSCE; i++) {
+ pce->sce[i] = GetBits(bsi, 1) << 4; /* is_cpe flag */
+ pce->sce[i] |= GetBits(bsi, 4); /* tag select */
+ }
+
+ for (i = 0; i < pce->numBCE; i++) {
+ pce->bce[i] = GetBits(bsi, 1) << 4; /* is_cpe flag */
+ pce->bce[i] |= GetBits(bsi, 4); /* tag select */
+ }
+
+ for (i = 0; i < pce->numLCE; i++) {
+ pce->lce[i] = GetBits(bsi, 4); /* tag select */
+ }
+
+ for (i = 0; i < pce->numADE; i++) {
+ pce->ade[i] = GetBits(bsi, 4); /* tag select */
+ }
+
+ for (i = 0; i < pce->numCCE; i++) {
+ pce->cce[i] = GetBits(bsi, 1) << 4; /* independent/dependent flag */
+ pce->cce[i] |= GetBits(bsi, 4); /* tag select */
+ }
+
+
+ ByteAlignBitstream(bsi);
+
+#ifdef KEEP_PCE_COMMENTS
+ pce->commentBytes = GetBits(bsi, 8);
+ for (i = 0; i < pce->commentBytes; i++) {
+ pce->commentField[i] = GetBits(bsi, 8);
+ }
+#else
+ /* eat comment bytes and throw away */
+ i = GetBits(bsi, 8);
+ while (i--) {
+ GetBits(bsi, 8);
+ }
+#endif
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeFillElement
+ *
+ * Description: decode one fill element
+ *
+ * Inputs: BitStreamInfo struct pointing to start of fill element
+ * (14496-3, table 4.4.11)
+ *
+ * Outputs: updated element instance tag
+ * unpacked extension payload
+ *
+ * Return: 0 if successful, -1 if error
+ **************************************************************************************/
+static int DecodeFillElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
+{
+ unsigned int fillCount;
+ unsigned char *fillBuf;
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ fillCount = GetBits(bsi, 4);
+ if (fillCount == 15) {
+ fillCount += (GetBits(bsi, 8) - 1);
+ }
+
+ psi->fillCount = fillCount;
+ fillBuf = psi->fillBuf;
+ while (fillCount--) {
+ *fillBuf++ = GetBits(bsi, 8);
+ }
+
+ aacDecInfo->currInstTag = -1; /* fill elements don't have instance tag */
+ aacDecInfo->fillExtType = 0;
+
+#ifdef AAC_ENABLE_SBR
+ /* check for SBR
+ * aacDecInfo->sbrEnabled is sticky (reset each raw_data_block), so for multichannel
+ * need to verify that all SCE/CPE/ICCE have valid SBR fill element following, and
+ * must upsample by 2 for LFE
+ */
+ if (psi->fillCount > 0) {
+ aacDecInfo->fillExtType = (int)((psi->fillBuf[0] >> 4) & 0x0f);
+ if (aacDecInfo->fillExtType == EXT_SBR_DATA || aacDecInfo->fillExtType == EXT_SBR_DATA_CRC) {
+ aacDecInfo->sbrEnabled = 1;
+ }
+ }
+#endif
+
+ aacDecInfo->fillBuf = psi->fillBuf;
+ aacDecInfo->fillCount = psi->fillCount;
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeNextElement
+ *
+ * Description: decode next syntactic element in AAC frame
+ *
+ * Inputs: valid AACDecInfo struct
+ * double pointer to buffer containing next element
+ * pointer to bit offset
+ * pointer to number of valid bits remaining in buf
+ *
+ * Outputs: type of element decoded (aacDecInfo->currBlockID)
+ * type of element decoded last time (aacDecInfo->prevBlockID)
+ * updated aacDecInfo state, depending on which element was decoded
+ * updated buffer pointer
+ * updated bit offset
+ * updated number of available bits
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int DecodeNextElement(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail)
+{
+ int err, bitsUsed;
+ PSInfoBase *psi;
+ BitStreamInfo bsi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ /* init bitstream reader */
+ SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf);
+ GetBits(&bsi, *bitOffset);
+
+ /* read element ID (save last ID for SBR purposes) */
+ aacDecInfo->prevBlockID = aacDecInfo->currBlockID;
+ aacDecInfo->currBlockID = GetBits(&bsi, NUM_SYN_ID_BITS);
+
+ /* set defaults (could be overwritten by DecodeXXXElement(), depending on currBlockID) */
+ psi->commonWin = 0;
+
+ err = 0;
+ switch (aacDecInfo->currBlockID) {
+ case AAC_ID_SCE:
+ err = DecodeSingleChannelElement(aacDecInfo, &bsi);
+ break;
+ case AAC_ID_CPE:
+ err = DecodeChannelPairElement(aacDecInfo, &bsi);
+ break;
+ case AAC_ID_CCE:
+ /* TODO - implement CCE decoding */
+ break;
+ case AAC_ID_LFE:
+ err = DecodeLFEChannelElement(aacDecInfo, &bsi);
+ break;
+ case AAC_ID_DSE:
+ err = DecodeDataStreamElement(aacDecInfo, &bsi);
+ break;
+ case AAC_ID_PCE:
+ err = DecodeProgramConfigElement(psi->pce + 0, &bsi);
+ break;
+ case AAC_ID_FIL:
+ err = DecodeFillElement(aacDecInfo, &bsi);
+ break;
+ case AAC_ID_END:
+ break;
+ }
+ if (err) {
+ return ERR_AAC_SYNTAX_ELEMENT;
+ }
+
+ /* update bitstream reader */
+ bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset);
+ *buf += (bitsUsed + *bitOffset) >> 3;
+ *bitOffset = (bitsUsed + *bitOffset) & 0x07;
+ *bitsAvail -= bitsUsed;
+
+ if (*bitsAvail < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+
+ return ERR_AAC_NONE;
+}
+
diff --git a/audio_codec/libfaad/helixaac/dequant.c b/audio_codec/libfaad/helixaac/dequant.c
new file mode 100644
index 0000000..43f4a5e
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/dequant.c
@@ -0,0 +1,379 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: dequant.c,v 1.2 2005/05/20 18:05:41 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * dequant.c - transform coefficient dequantization and short-block deinterleaving
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+#include <stdio.h>
+
+
+#define SF_OFFSET 100
+
+/* pow(2, i/4.0) for i = [0,1,2,3], format = Q30 */
+static const int pow14[4] = {
+ 0x40000000, 0x4c1bf829, 0x5a82799a, 0x6ba27e65
+};
+
+/* pow(2, i/4.0) * pow(j, 4.0/3.0) for i = [0,1,2,3], j = [0,1,2,...,15]
+ * format = Q28 for j = [0-3], Q25 for j = [4-15]
+ */
+static const int pow43_14[4][16] = {
+ {
+ 0x00000000, 0x10000000, 0x285145f3, 0x453a5cdb, /* Q28 */
+ 0x0cb2ff53, 0x111989d6, 0x15ce31c8, 0x1ac7f203, /* Q25 */
+ 0x20000000, 0x257106b9, 0x2b16b4a3, 0x30ed74b4, /* Q25 */
+ 0x36f23fa5, 0x3d227bd3, 0x437be656, 0x49fc823c, /* Q25 */
+ },
+ {
+ 0x00000000, 0x1306fe0a, 0x2ff221af, 0x52538f52,
+ 0x0f1a1bf4, 0x1455ccc2, 0x19ee62a8, 0x1fd92396,
+ 0x260dfc14, 0x2c8694d8, 0x333dcb29, 0x3a2f5c7a,
+ 0x4157aed5, 0x48b3aaa3, 0x50409f76, 0x57fc3010,
+ },
+ {
+ 0x00000000, 0x16a09e66, 0x39047c0f, 0x61e734aa,
+ 0x11f59ac4, 0x182ec633, 0x1ed66a45, 0x25dfc55a,
+ 0x2d413ccd, 0x34f3462d, 0x3cefc603, 0x4531ab69,
+ 0x4db4adf8, 0x56752054, 0x5f6fcfcd, 0x68a1eca1,
+ },
+ {
+ 0x00000000, 0x1ae89f99, 0x43ce3e4b, 0x746d57b2,
+ 0x155b8109, 0x1cc21cdc, 0x24ac1839, 0x2d0a479e,
+ 0x35d13f33, 0x3ef80748, 0x48775c93, 0x524938cd,
+ 0x5c68841d, 0x66d0df0a, 0x717e7bfe, 0x7c6e0305,
+ },
+};
+
+/* pow(j, 4.0 / 3.0) for j = [16,17,18,...,63], format = Q23 */
+static const int pow43[48] = {
+ 0x1428a2fa, 0x15db1bd6, 0x1796302c, 0x19598d85,
+ 0x1b24e8bb, 0x1cf7fcfa, 0x1ed28af2, 0x20b4582a,
+ 0x229d2e6e, 0x248cdb55, 0x26832fda, 0x28800000,
+ 0x2a832287, 0x2c8c70a8, 0x2e9bc5d8, 0x30b0ff99,
+ 0x32cbfd4a, 0x34eca001, 0x3712ca62, 0x393e6088,
+ 0x3b6f47e0, 0x3da56717, 0x3fe0a5fc, 0x4220ed72,
+ 0x44662758, 0x46b03e7c, 0x48ff1e87, 0x4b52b3f3,
+ 0x4daaebfd, 0x5007b497, 0x5268fc62, 0x54ceb29c,
+ 0x5738c721, 0x59a72a59, 0x5c19cd35, 0x5e90a129,
+ 0x610b9821, 0x638aa47f, 0x660db90f, 0x6894c90b,
+ 0x6b1fc80c, 0x6daeaa0d, 0x70416360, 0x72d7e8b0,
+ 0x75722ef9, 0x78102b85, 0x7ab1d3ec, 0x7d571e09,
+};
+
+/* sqrt(0.5), format = Q31 */
+#define SQRTHALF 0x5a82799a
+
+/* Minimax polynomial approximation to pow(x, 4/3), over the range
+ * poly43lo: x = [0.5, 0.7071]
+ * poly43hi: x = [0.7071, 1.0]
+ *
+ * Relative error < 1E-7
+ * Coefs are scaled by 4, 2, 1, 0.5, 0.25
+ */
+static const int poly43lo[5] = { 0x29a0bda9, 0xb02e4828, 0x5957aa1b, 0x236c498d, 0xff581859 };
+static const int poly43hi[5] = { 0x10852163, 0xd333f6a4, 0x46e9408b, 0x27c2cef0, 0xfef577b4 };
+
+/* pow2exp[i] = pow(2, i*4/3) exponent */
+static const int pow2exp[8] = { 14, 13, 11, 10, 9, 7, 6, 5 };
+
+/* pow2exp[i] = pow(2, i*4/3) fraction */
+static const int pow2frac[8] = {
+ 0x6597fa94, 0x50a28be6, 0x7fffffff, 0x6597fa94,
+ 0x50a28be6, 0x7fffffff, 0x6597fa94, 0x50a28be6
+};
+
+/**************************************************************************************
+ * Function: DequantBlock
+ *
+ * Description: dequantize one block of transform coefficients (in-place)
+ *
+ * Inputs: quantized transform coefficients, range = [0, 8191]
+ * number of samples to dequantize
+ * scalefactor for this block of data, range = [0, 256]
+ *
+ * Outputs: dequantized transform coefficients in Q(FBITS_OUT_DQ_OFF)
+ *
+ * Return: guard bit mask (OR of abs value of all dequantized coefs)
+ *
+ * Notes: applies dequant formula y = pow(x, 4.0/3.0) * pow(2, (scale - 100)/4.0)
+ * * pow(2, FBITS_OUT_DQ_OFF)
+ * clips outputs to Q(FBITS_OUT_DQ_OFF)
+ * output has no minimum number of guard bits
+ **************************************************************************************/
+static int DequantBlock(int *inbuf, int nSamps, int scale)
+{
+ int iSamp, scalef, scalei, x, y, gbMask, shift, tab4[4];
+ const int *tab16, *coef;
+
+ if (nSamps <= 0) {
+ return 0;
+ }
+
+ scale -= SF_OFFSET; /* new range = [-100, 156] */
+
+ /* with two's complement numbers, scalei/scalef factorization works for pos and neg values of scale:
+ * [+4...+7] >> 2 = +1, [ 0...+3] >> 2 = 0, [-4...-1] >> 2 = -1, [-8...-5] >> 2 = -2 ...
+ * (-1 & 0x3) = 3, (-2 & 0x3) = 2, (-3 & 0x3) = 1, (0 & 0x3) = 0
+ *
+ * Example: 2^(-5/4) = 2^(-1) * 2^(-1/4) = 2^-2 * 2^(3/4)
+ */
+ tab16 = pow43_14[scale & 0x3];
+ scalef = pow14[scale & 0x3];
+ scalei = (scale >> 2) + FBITS_OUT_DQ_OFF;
+
+ /* cache first 4 values:
+ * tab16[j] = Q28 for j = [0,3]
+ * tab4[x] = x^(4.0/3.0) * 2^(0.25*scale), Q(FBITS_OUT_DQ_OFF)
+ */
+ shift = 28 - scalei;
+ if (shift > 31) {
+ tab4[0] = tab4[1] = tab4[2] = tab4[3] = 0;
+ } else if (shift <= 0) {
+ shift = -shift;
+ if (shift > 31) {
+ shift = 31;
+ }
+ for (x = 0; x < 4; x++) {
+ y = tab16[x];
+ if (y > (0x7fffffff >> shift)) {
+ y = 0x7fffffff; /* clip (rare) */
+ } else {
+ y <<= shift;
+ }
+ tab4[x] = y;
+ }
+ } else {
+ tab4[0] = 0;
+ tab4[1] = tab16[1] >> shift;
+ tab4[2] = tab16[2] >> shift;
+ tab4[3] = tab16[3] >> shift;
+ }
+
+ gbMask = 0;
+ do {
+ iSamp = *inbuf;
+ x = FASTABS(iSamp);
+
+ if (x < 4) {
+ y = tab4[x];
+ } else {
+
+ if (x < 16) {
+ /* result: y = Q25 (tab16 = Q25) */
+ y = tab16[x];
+ shift = 25 - scalei;
+ } else if (x < 64) {
+ /* result: y = Q21 (pow43tab[j] = Q23, scalef = Q30) */
+ y = pow43[x - 16];
+ shift = 21 - scalei;
+ y = MULSHIFT32(y, scalef);
+ } else {
+ /* normalize to [0x40000000, 0x7fffffff]
+ * input x = [64, 8191] = [64, 2^13-1]
+ * ranges:
+ * shift = 7: 64 - 127
+ * shift = 6: 128 - 255
+ * shift = 5: 256 - 511
+ * shift = 4: 512 - 1023
+ * shift = 3: 1024 - 2047
+ * shift = 2: 2048 - 4095
+ * shift = 1: 4096 - 8191
+ */
+ x <<= 17;
+ shift = 0;
+ if (x < 0x08000000) {
+ x <<= 4, shift += 4;
+ }
+ if (x < 0x20000000) {
+ x <<= 2, shift += 2;
+ }
+ if (x < 0x40000000) {
+ x <<= 1, shift += 1;
+ }
+
+ coef = (x < SQRTHALF) ? poly43lo : poly43hi;
+
+ /* polynomial */
+ y = coef[0];
+ y = MULSHIFT32(y, x) + coef[1];
+ y = MULSHIFT32(y, x) + coef[2];
+ y = MULSHIFT32(y, x) + coef[3];
+ y = MULSHIFT32(y, x) + coef[4];
+ y = MULSHIFT32(y, pow2frac[shift]) << 3;
+
+ /* fractional scale
+ * result: y = Q21 (pow43tab[j] = Q23, scalef = Q30)
+ */
+ y = MULSHIFT32(y, scalef); /* now y is Q24 */
+ shift = 24 - scalei - pow2exp[shift];
+ }
+
+ /* integer scale */
+ if (shift <= 0) {
+ shift = -shift;
+ if (shift > 31) {
+ shift = 31;
+ }
+
+ if (y > (0x7fffffff >> shift)) {
+ y = 0x7fffffff; /* clip (rare) */
+ } else {
+ y <<= shift;
+ }
+ } else {
+ if (shift > 31) {
+ shift = 31;
+ }
+ y >>= shift;
+ }
+ }
+
+ /* sign and store (gbMask used to count GB's) */
+ gbMask |= y;
+
+ /* apply sign */
+ iSamp >>= 31;
+ y ^= iSamp;
+ y -= iSamp;
+
+ *inbuf++ = y;
+ } while (--nSamps);
+
+ return gbMask;
+}
+
+/**************************************************************************************
+ * Function: Dequantize
+ *
+ * Description: dequantize all transform coefficients for one channel
+ *
+ * Inputs: valid AACDecInfo struct (including unpacked, quantized coefficients)
+ * index of current channel
+ *
+ * Outputs: dequantized coefficients, including short-block deinterleaving
+ * flags indicating if intensity and/or PNS is active
+ * minimum guard bit count for dequantized coefficients
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int Dequantize(AACDecInfo *aacDecInfo, int ch)
+{
+ int gp, cb, sfb, win, width, nSamps, gbMask;
+ int *coef;
+ const short *sfbTab;
+ unsigned char *sfbCodeBook;
+ short *scaleFactors;
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ if (icsInfo->winSequence == 2) {
+ sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_SHORT;
+ } else {
+ sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_LONG;
+ }
+ coef = psi->coef[ch];
+ sfbCodeBook = psi->sfbCodeBook[ch];
+ scaleFactors = psi->scaleFactors[ch];
+
+ psi->intensityUsed[ch] = 0;
+ psi->pnsUsed[ch] = 0;
+ gbMask = 0;
+ for (gp = 0; gp < icsInfo->numWinGroup; gp++) {
+ for (win = 0; win < icsInfo->winGroupLen[gp]; win++) {
+ for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) {
+ /* dequantize one scalefactor band (not necessary if codebook is intensity or PNS)
+ * for zero codebook, still run dequantizer in case non-zero pulse data was added
+ */
+ cb = (int)(sfbCodeBook[sfb]);
+ width = sfbTab[sfb + 1] - sfbTab[sfb];
+ if (cb >= 0 && cb <= 11) {
+ gbMask |= DequantBlock(coef, width, scaleFactors[sfb]);
+ } else if (cb == 13) {
+ psi->pnsUsed[ch] = 1;
+ } else if (cb == 14 || cb == 15) {
+ psi->intensityUsed[ch] = 1; /* should only happen if ch == 1 */
+ }
+ coef += width;
+ }
+ coef += (nSamps - sfbTab[icsInfo->maxSFB]);
+ }
+ sfbCodeBook += icsInfo->maxSFB;
+ scaleFactors += icsInfo->maxSFB;
+ }
+ aacDecInfo->pnsUsed |= psi->pnsUsed[ch]; /* set flag if PNS used for any channel */
+
+ /* calculate number of guard bits in dequantized data */
+ psi->gbCurrent[ch] = CLZ(gbMask) - 1;
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: DeinterleaveShortBlocks
+ *
+ * Description: deinterleave transform coefficients in short blocks for one channel
+ *
+ * Inputs: valid AACDecInfo struct (including unpacked, quantized coefficients)
+ * index of current channel
+ *
+ * Outputs: deinterleaved coefficients (window groups into 8 separate windows)
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: only necessary if deinterleaving not part of Huffman decoding
+ **************************************************************************************/
+int DeinterleaveShortBlocks(AACDecInfo *aacDecInfo, int ch)
+{
+ /* not used for this implementation - short block deinterleaving performed during Huffman decoding */
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/libfaad/helixaac/fft.c b/audio_codec/libfaad/helixaac/fft.c
new file mode 100644
index 0000000..db17d27
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/fft.c
@@ -0,0 +1,391 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: fft.c,v 1.1.2.1 2005/02/26 02:05:12 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * fft.c - Ken's optimized radix-4 DIT FFT, optional radix-8 first pass for odd log2(N)
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+#define NUM_FFT_SIZES 2
+static const int nfftTab[NUM_FFT_SIZES] = {64, 512};
+static const int nfftlog2Tab[NUM_FFT_SIZES] = {6, 9};
+
+#define SQRT1_2 0x5a82799a /* sqrt(1/2) in Q31 */
+
+#define swapcplx(p0,p1) \
+ t = p0; t1 = *(&(p0)+1); p0 = p1; *(&(p0)+1) = *(&(p1)+1); p1 = t; *(&(p1)+1) = t1
+
+/**************************************************************************************
+ * Function: BitReverse
+ *
+ * Description: Ken's fast in-place bit reverse, using super-small table
+ *
+ * Inputs: buffer of samples
+ * table index (for transform size)
+ *
+ * Outputs: bit-reversed samples in same buffer
+ *
+ * Return: none
+ **************************************************************************************/
+static void BitReverse(int *inout, int tabidx)
+{
+ int *part0, *part1;
+ int a, b, t, t1;
+ const unsigned char* tab = bitrevtab + bitrevtabOffset[tabidx];
+ int nbits = nfftlog2Tab[tabidx];
+
+ part0 = inout;
+ part1 = inout + (1 << nbits);
+
+ while ((a = *tab++) != 0) {
+ b = *tab++;
+
+ swapcplx(part0[4 * a + 0], part0[4 * b + 0]); /* 0xxx0 <-> 0yyy0 */
+ swapcplx(part0[4 * a + 2], part1[4 * b + 0]); /* 0xxx1 <-> 1yyy0 */
+ swapcplx(part1[4 * a + 0], part0[4 * b + 2]); /* 1xxx0 <-> 0yyy1 */
+ swapcplx(part1[4 * a + 2], part1[4 * b + 2]); /* 1xxx1 <-> 1yyy1 */
+ }
+
+ do {
+ swapcplx(part0[4 * a + 2], part1[4 * a + 0]); /* 0xxx1 <-> 1xxx0 */
+ } while ((a = *tab++) != 0);
+}
+
+/**************************************************************************************
+ * Function: R4FirstPass
+ *
+ * Description: radix-4 trivial pass for decimation-in-time FFT
+ *
+ * Inputs: buffer of (bit-reversed) samples
+ * number of R4 butterflies per group (i.e. nfft / 4)
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 2 guard bits, gains no integer bits,
+ * guard bits out = guard bits in - 2
+ **************************************************************************************/
+static void R4FirstPass(int *x, int bg)
+{
+ int ar, ai, br, bi, cr, ci, dr, di;
+
+ for (; bg != 0; bg--) {
+
+ ar = x[0] + x[2];
+ br = x[0] - x[2];
+ ai = x[1] + x[3];
+ bi = x[1] - x[3];
+ cr = x[4] + x[6];
+ dr = x[4] - x[6];
+ ci = x[5] + x[7];
+ di = x[5] - x[7];
+
+ /* max per-sample gain = 4.0 (adding 4 inputs together) */
+ x[0] = ar + cr;
+ x[4] = ar - cr;
+ x[1] = ai + ci;
+ x[5] = ai - ci;
+ x[2] = br + di;
+ x[6] = br - di;
+ x[3] = bi - dr;
+ x[7] = bi + dr;
+
+ x += 8;
+ }
+}
+
+/**************************************************************************************
+ * Function: R8FirstPass
+ *
+ * Description: radix-8 trivial pass for decimation-in-time FFT
+ *
+ * Inputs: buffer of (bit-reversed) samples
+ * number of R8 butterflies per group (i.e. nfft / 8)
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 3 guard bits, gains 1 integer bit
+ * guard bits out = guard bits in - 3 (if inputs are full scale)
+ * or guard bits in - 2 (if inputs bounded to +/- sqrt(2)/2)
+ * see scaling comments in code
+ **************************************************************************************/
+static void R8FirstPass(int *x, int bg)
+{
+ int ar, ai, br, bi, cr, ci, dr, di;
+ int sr, si, tr, ti, ur, ui, vr, vi;
+ int wr, wi, xr, xi, yr, yi, zr, zi;
+
+ for (; bg != 0; bg--) {
+
+ ar = x[0] + x[2];
+ br = x[0] - x[2];
+ ai = x[1] + x[3];
+ bi = x[1] - x[3];
+ cr = x[4] + x[6];
+ dr = x[4] - x[6];
+ ci = x[5] + x[7];
+ di = x[5] - x[7];
+
+ sr = ar + cr;
+ ur = ar - cr;
+ si = ai + ci;
+ ui = ai - ci;
+ tr = br - di;
+ vr = br + di;
+ ti = bi + dr;
+ vi = bi - dr;
+
+ ar = x[ 8] + x[10];
+ br = x[ 8] - x[10];
+ ai = x[ 9] + x[11];
+ bi = x[ 9] - x[11];
+ cr = x[12] + x[14];
+ dr = x[12] - x[14];
+ ci = x[13] + x[15];
+ di = x[13] - x[15];
+
+ /* max gain of wr/wi/yr/yi vs input = 2
+ * (sum of 4 samples >> 1)
+ */
+ wr = (ar + cr) >> 1;
+ yr = (ar - cr) >> 1;
+ wi = (ai + ci) >> 1;
+ yi = (ai - ci) >> 1;
+
+ /* max gain of output vs input = 4
+ * (sum of 4 samples >> 1 + sum of 4 samples >> 1)
+ */
+ x[ 0] = (sr >> 1) + wr;
+ x[ 8] = (sr >> 1) - wr;
+ x[ 1] = (si >> 1) + wi;
+ x[ 9] = (si >> 1) - wi;
+ x[ 4] = (ur >> 1) + yi;
+ x[12] = (ur >> 1) - yi;
+ x[ 5] = (ui >> 1) - yr;
+ x[13] = (ui >> 1) + yr;
+
+ ar = br - di;
+ cr = br + di;
+ ai = bi + dr;
+ ci = bi - dr;
+
+ /* max gain of xr/xi/zr/zi vs input = 4*sqrt(2)/2 = 2*sqrt(2)
+ * (sum of 8 samples, multiply by sqrt(2)/2, implicit >> 1 from Q31)
+ */
+ xr = MULSHIFT32(SQRT1_2, ar - ai);
+ xi = MULSHIFT32(SQRT1_2, ar + ai);
+ zr = MULSHIFT32(SQRT1_2, cr - ci);
+ zi = MULSHIFT32(SQRT1_2, cr + ci);
+
+ /* max gain of output vs input = (2 + 2*sqrt(2) ~= 4.83)
+ * (sum of 4 samples >> 1, plus xr/xi/zr/zi with gain of 2*sqrt(2))
+ * in absolute terms, we have max gain of appx 9.656 (4 + 0.707*8)
+ * but we also gain 1 int bit (from MULSHIFT32 or from explicit >> 1)
+ */
+ x[ 6] = (tr >> 1) - xr;
+ x[14] = (tr >> 1) + xr;
+ x[ 7] = (ti >> 1) - xi;
+ x[15] = (ti >> 1) + xi;
+ x[ 2] = (vr >> 1) + zi;
+ x[10] = (vr >> 1) - zi;
+ x[ 3] = (vi >> 1) - zr;
+ x[11] = (vi >> 1) + zr;
+
+ x += 16;
+ }
+}
+
+/**************************************************************************************
+ * Function: R4Core
+ *
+ * Description: radix-4 pass for decimation-in-time FFT
+ *
+ * Inputs: buffer of samples
+ * number of R4 butterflies per group
+ * number of R4 groups per pass
+ * pointer to twiddle factors tables
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: gain 2 integer bits per pass (see scaling comments in code)
+ * min 1 GB in
+ * gbOut = gbIn - 1 (short block) or gbIn - 2 (long block)
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ **************************************************************************************/
+static void R4Core(int *x, int bg, int gp, int *wtab)
+{
+ int ar, ai, br, bi, cr, ci, dr, di, tr, ti;
+ int wd, ws, wi;
+ int i, j, step;
+ int *xptr, *wptr;
+
+ for (; bg != 0; gp <<= 2, bg >>= 2) {
+
+ step = 2 * gp;
+ xptr = x;
+
+ /* max per-sample gain, per group < 1 + 3*sqrt(2) ~= 5.25 if inputs x are full-scale
+ * do 3 groups for long block, 2 groups for short block (gain 2 int bits per group)
+ *
+ * very conservative scaling:
+ * group 1: max gain = 5.25, int bits gained = 2, gb used = 1 (2^3 = 8)
+ * group 2: max gain = 5.25^2 = 27.6, int bits gained = 4, gb used = 1 (2^5 = 32)
+ * group 3: max gain = 5.25^3 = 144.7, int bits gained = 6, gb used = 2 (2^8 = 256)
+ */
+ for (i = bg; i != 0; i--) {
+
+ wptr = wtab;
+
+ for (j = gp; j != 0; j--) {
+
+ ar = xptr[0];
+ ai = xptr[1];
+ xptr += step;
+
+ /* gain 2 int bits for br/bi, cr/ci, dr/di (MULSHIFT32 by Q30)
+ * gain 1 net GB
+ */
+ ws = wptr[0];
+ wi = wptr[1];
+ br = xptr[0];
+ bi = xptr[1];
+ wd = ws + 2 * wi;
+ tr = MULSHIFT32(wi, br + bi);
+ br = MULSHIFT32(wd, br) - tr; /* cos*br + sin*bi */
+ bi = MULSHIFT32(ws, bi) + tr; /* cos*bi - sin*br */
+ xptr += step;
+
+ ws = wptr[2];
+ wi = wptr[3];
+ cr = xptr[0];
+ ci = xptr[1];
+ wd = ws + 2 * wi;
+ tr = MULSHIFT32(wi, cr + ci);
+ cr = MULSHIFT32(wd, cr) - tr;
+ ci = MULSHIFT32(ws, ci) + tr;
+ xptr += step;
+
+ ws = wptr[4];
+ wi = wptr[5];
+ dr = xptr[0];
+ di = xptr[1];
+ wd = ws + 2 * wi;
+ tr = MULSHIFT32(wi, dr + di);
+ dr = MULSHIFT32(wd, dr) - tr;
+ di = MULSHIFT32(ws, di) + tr;
+ wptr += 6;
+
+ tr = ar;
+ ti = ai;
+ ar = (tr >> 2) - br;
+ ai = (ti >> 2) - bi;
+ br = (tr >> 2) + br;
+ bi = (ti >> 2) + bi;
+
+ tr = cr;
+ ti = ci;
+ cr = tr + dr;
+ ci = di - ti;
+ dr = tr - dr;
+ di = di + ti;
+
+ xptr[0] = ar + ci;
+ xptr[1] = ai + dr;
+ xptr -= step;
+ xptr[0] = br - cr;
+ xptr[1] = bi - di;
+ xptr -= step;
+ xptr[0] = ar - ci;
+ xptr[1] = ai - dr;
+ xptr -= step;
+ xptr[0] = br + cr;
+ xptr[1] = bi + di;
+ xptr += 2;
+ }
+ xptr += 3 * step;
+ }
+ wtab += 3 * step;
+ }
+}
+
+
+/**************************************************************************************
+ * Function: R4FFT
+ *
+ * Description: Ken's very fast in-place radix-4 decimation-in-time FFT
+ *
+ * Inputs: table index (for transform size)
+ * buffer of samples (non bit-reversed)
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 5 guard bits in for nfft <= 512
+ * gbOut = gbIn - 4 (assuming input is from PreMultiply)
+ * gains log2(nfft) - 2 int bits total
+ * so gain 7 int bits (LONG), 4 int bits (SHORT)
+ **************************************************************************************/
+void R4FFT(int tabidx, int *x)
+{
+ int order = nfftlog2Tab[tabidx];
+ int nfft = nfftTab[tabidx];
+
+ /* decimation in time */
+ BitReverse(x, tabidx);
+
+ if (order & 0x1) {
+ /* long block: order = 9, nfft = 512 */
+ R8FirstPass(x, nfft >> 3); /* gain 1 int bit, lose 2 GB */
+ R4Core(x, nfft >> 5, 8, (int *)twidTabOdd); /* gain 6 int bits, lose 2 GB */
+ } else {
+ /* short block: order = 6, nfft = 64 */
+ R4FirstPass(x, nfft >> 2); /* gain 0 int bits, lose 2 GB */
+ R4Core(x, nfft >> 4, 4, (int *)twidTabEven); /* gain 4 int bits, lose 1 GB */
+ }
+}
diff --git a/audio_codec/libfaad/helixaac/filefmt.c b/audio_codec/libfaad/helixaac/filefmt.c
new file mode 100644
index 0000000..9db47d4
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/filefmt.c
@@ -0,0 +1,539 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: filefmt.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * filefmt.c - ADIF and ADTS header decoding, raw block handling
+ **************************************************************************************/
+
+#include "coder.h"
+#include <stdio.h>
+
+/**************************************************************************************
+* Function: UnpackADTSHeader
+*
+* Description: parse the ADTS frame header and initialize decoder state
+*
+* Inputs: valid AACDecInfo struct
+* double pointer to buffer with complete ADTS frame header (byte aligned)
+* header size = 7 bytes, plus 2 if CRC
+*
+* Outputs: filled in ADTS struct
+* updated buffer pointer
+* updated bit offset
+* updated number of available bits
+*
+* Return: 0 if successful, error code (< 0) if error
+*
+* TODO: test CRC
+* verify that fixed fields don't change between frames
+**************************************************************************************/
+int UnpackADTSHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail)
+{
+ int bitsUsed;
+ PSInfoBase *psi;
+ BitStreamInfo bsi;
+ ADTSHeader *fhADTS;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ fhADTS = &(psi->fhADTS);
+
+ if (AACDataSource == 1) {
+ /* init bitstream reader */
+ SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf);
+ GetBits(&bsi, *bitOffset);
+
+ /* verify that first 12 bits of header are syncword */
+ if (GetBits(&bsi, 12) != 0x0fff) {
+ return ERR_AAC_INVALID_ADTS_HEADER;
+ }
+ }
+ /* fixed fields - should not change from frame to frame */
+ fhADTS->id = GetBits(&bsi, 1);
+ fhADTS->layer = GetBits(&bsi, 2);
+ fhADTS->protectBit = GetBits(&bsi, 1);
+ fhADTS->profile = GetBits(&bsi, 2);
+ fhADTS->sampRateIdx = GetBits(&bsi, 4);
+ fhADTS->privateBit = GetBits(&bsi, 1);
+ fhADTS->channelConfig = GetBits(&bsi, 3);
+ fhADTS->origCopy = GetBits(&bsi, 1);
+ fhADTS->home = GetBits(&bsi, 1);
+
+ /* variable fields - can change from frame to frame */
+ fhADTS->copyBit = GetBits(&bsi, 1);
+ fhADTS->copyStart = GetBits(&bsi, 1);
+ fhADTS->frameLength = GetBits(&bsi, 13);
+ fhADTS->bufferFull = GetBits(&bsi, 11);
+ fhADTS->numRawDataBlocks = GetBits(&bsi, 2) + 1;
+
+ /* note - MPEG4 spec, correction 1 changes how CRC is handled when protectBit == 0 and numRawDataBlocks > 1 */
+ if (fhADTS->protectBit == 0) {
+ fhADTS->crcCheckWord = GetBits(&bsi, 16);
+ }
+
+ /* byte align */
+ ByteAlignBitstream(&bsi); /* should always be aligned anyway */
+
+ /* check validity of header */
+ if (fhADTS->layer != 0 || fhADTS->profile != AAC_PROFILE_LC ||
+ fhADTS->sampRateIdx >= NUM_SAMPLE_RATES || fhADTS->channelConfig >= NUM_DEF_CHAN_MAPS) {
+ return ERR_AAC_INVALID_ADTS_HEADER;
+ }
+
+#ifndef AAC_ENABLE_MPEG4
+ if (fhADTS->id != 1) {
+ return ERR_AAC_MPEG4_UNSUPPORTED;
+ }
+#endif
+
+ /* update codec info */
+ psi->sampRateIdx = fhADTS->sampRateIdx;
+ if (!psi->useImpChanMap) {
+ psi->nChans = channelMapTab[fhADTS->channelConfig];
+ }
+
+ /* syntactic element fields will be read from bitstream for each element */
+ aacDecInfo->prevBlockID = AAC_ID_INVALID;
+ aacDecInfo->currBlockID = AAC_ID_INVALID;
+ aacDecInfo->currInstTag = -1;
+
+ /* fill in user-accessible data (TODO - calc bitrate, handle tricky channel config cases) */
+ aacDecInfo->bitRate = 0;
+ aacDecInfo->nChans = psi->nChans;
+ aacDecInfo->sampRate = sampRateTab[psi->sampRateIdx];
+ aacDecInfo->profile = fhADTS->profile;
+ aacDecInfo->sbrEnabled = 0;
+ aacDecInfo->adtsBlocksLeft = fhADTS->numRawDataBlocks;
+ aacDecInfo->frame_length = fhADTS->frameLength;
+ if (AACDataSource == 1) {
+ /* update bitstream reader */
+ bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset);
+ *buf += (bitsUsed + *bitOffset) >> 3;
+ *bitOffset = (bitsUsed + *bitOffset) & 0x07;
+ *bitsAvail -= bitsUsed ;
+ if (*bitsAvail < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: GetADTSChannelMapping
+ *
+ * Description: determine the number of channels from implicit mapping rules
+ *
+ * Inputs: valid AACDecInfo struct
+ * pointer to start of raw_data_block
+ * bit offset
+ * bits available
+ *
+ * Outputs: updated number of channels
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: calculates total number of channels using rules in 14496-3, 4.5.1.2.1
+ * does not attempt to deduce speaker geometry
+ **************************************************************************************/
+int GetADTSChannelMapping(AACDecInfo *aacDecInfo, unsigned char *buf, int bitOffset, int bitsAvail)
+{
+ int ch, nChans, elementChans, err;
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ nChans = 0;
+ do {
+ /* parse next syntactic element */
+ err = DecodeNextElement(aacDecInfo, &buf, &bitOffset, &bitsAvail);
+ if (err) {
+ return err;
+ }
+
+ elementChans = elementNumChans[aacDecInfo->currBlockID];
+ nChans += elementChans;
+
+ for (ch = 0; ch < elementChans; ch++) {
+ err = DecodeNoiselessData(aacDecInfo, &buf, &bitOffset, &bitsAvail, ch);
+ if (err) {
+ return err;
+ }
+ }
+ } while (aacDecInfo->currBlockID != AAC_ID_END);
+
+ if (nChans <= 0) {
+ return ERR_AAC_CHANNEL_MAP;
+ }
+
+ /* update number of channels in codec state and user-accessible info structs */
+ psi->nChans = nChans;
+ aacDecInfo->nChans = psi->nChans;
+ psi->useImpChanMap = 1;
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: GetNumChannelsADIF
+ *
+ * Description: get number of channels from program config elements in an ADIF file
+ *
+ * Inputs: array of filled-in program config element structures
+ * number of PCE's
+ *
+ * Outputs: none
+ *
+ * Return: total number of channels in file
+ * -1 if error (invalid number of PCE's or unsupported mode)
+ **************************************************************************************/
+static int GetNumChannelsADIF(ProgConfigElement *fhPCE, int nPCE)
+{
+ int i, j, nChans;
+
+ if (nPCE < 1 || nPCE > MAX_NUM_PCE_ADIF) {
+ return -1;
+ }
+
+ nChans = 0;
+ for (i = 0; i < nPCE; i++) {
+ /* for now: only support LC, no channel coupling */
+#if 0
+ if (fhPCE[i].profile != AAC_PROFILE_LC || fhPCE[i].numCCE > 0) {
+ return -1;
+ }
+#endif
+
+ /* add up number of channels in all channel elements (assume all single-channel) */
+ nChans += fhPCE[i].numFCE;
+ nChans += fhPCE[i].numSCE;
+ nChans += fhPCE[i].numBCE;
+ nChans += fhPCE[i].numLCE;
+
+ /* add one more for every element which is a channel pair */
+ for (j = 0; j < fhPCE[i].numFCE; j++) {
+ if (CHAN_ELEM_IS_CPE(fhPCE[i].fce[j])) {
+ nChans++;
+ }
+ }
+ for (j = 0; j < fhPCE[i].numSCE; j++) {
+ if (CHAN_ELEM_IS_CPE(fhPCE[i].sce[j])) {
+ nChans++;
+ }
+ }
+ for (j = 0; j < fhPCE[i].numBCE; j++) {
+ if (CHAN_ELEM_IS_CPE(fhPCE[i].bce[j])) {
+ nChans++;
+ }
+ }
+
+ }
+
+ return nChans;
+}
+
+/**************************************************************************************
+ * Function: GetSampleRateIdxADIF
+ *
+ * Description: get sampling rate index from program config elements in an ADIF file
+ *
+ * Inputs: array of filled-in program config element structures
+ * number of PCE's
+ *
+ * Outputs: none
+ *
+ * Return: sample rate of file
+ * -1 if error (invalid number of PCE's or sample rate mismatch)
+ **************************************************************************************/
+static int GetSampleRateIdxADIF(ProgConfigElement *fhPCE, int nPCE)
+{
+ int i, idx;
+
+ if (nPCE < 1 || nPCE > MAX_NUM_PCE_ADIF) {
+ return -1;
+ }
+
+ /* make sure all PCE's have the same sample rate */
+ idx = fhPCE[0].sampRateIdx;
+ for (i = 1; i < nPCE; i++) {
+ if (fhPCE[i].sampRateIdx != idx) {
+ return -1;
+ }
+ }
+
+ return idx;
+}
+
+/**************************************************************************************
+ * Function: UnpackADIFHeader
+ *
+ * Description: parse the ADIF file header and initialize decoder state
+ *
+ * Inputs: valid AACDecInfo struct
+ * double pointer to buffer with complete ADIF header
+ * (starting at 'A' in 'ADIF' tag)
+ * pointer to bit offset
+ * pointer to number of valid bits remaining in inbuf
+ *
+ * Outputs: filled-in ADIF struct
+ * updated buffer pointer
+ * updated bit offset
+ * updated number of available bits
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int UnpackADIFHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail)
+{
+ int i, bitsUsed;
+ PSInfoBase *psi;
+ BitStreamInfo bsi;
+ ADIFHeader *fhADIF;
+ ProgConfigElement *pce;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ if (AACDataSource == 1) {
+ /* init bitstream reader */
+ SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf);
+ GetBits(&bsi, *bitOffset);
+ }
+
+ /* unpack ADIF file header */
+ fhADIF = &(psi->fhADIF);
+ pce = psi->pce;
+
+ /* verify that first 32 bits of header are "ADIF" */
+ if (GetBits(&bsi, 8) != 'A' || GetBits(&bsi, 8) != 'D' || GetBits(&bsi, 8) != 'I' || GetBits(&bsi, 8) != 'F') {
+ return ERR_AAC_INVALID_ADIF_HEADER;
+ }
+
+ /* read ADIF header fields */
+ fhADIF->copyBit = GetBits(&bsi, 1);
+ if (fhADIF->copyBit) {
+ for (i = 0; i < ADIF_COPYID_SIZE; i++) {
+ fhADIF->copyID[i] = GetBits(&bsi, 8);
+ }
+ }
+ fhADIF->origCopy = GetBits(&bsi, 1);
+ fhADIF->home = GetBits(&bsi, 1);
+ fhADIF->bsType = GetBits(&bsi, 1);
+ fhADIF->bitRate = GetBits(&bsi, 23);
+ fhADIF->numPCE = GetBits(&bsi, 4) + 1; /* add 1 (so range = [1, 16]) */
+
+ //if (fhADIF->bsType == 0)
+ // fhADIF->bufferFull = GetBits(&bsi, 20);
+
+ /* parse all program config elements */
+ for (i = 0; i < fhADIF->numPCE; i++) {
+ if (fhADIF->bsType == 0) {
+ fhADIF->bufferFull = GetBits(&bsi, 20);
+ } else {
+ fhADIF->bufferFull = 0;
+ }
+ DecodeProgramConfigElement(pce + i, &bsi);
+
+ }
+
+ /* byte align */
+ ByteAlignBitstream(&bsi);
+
+ /* update codec info */
+ psi->nChans = GetNumChannelsADIF(pce, 1/*fhADIF->numPCE*/);
+ psi->sampRateIdx = GetSampleRateIdxADIF(pce, fhADIF->numPCE);
+
+ /* check validity of header */
+ if (psi->nChans < 0 || psi->sampRateIdx < 0 || psi->sampRateIdx >= NUM_SAMPLE_RATES) {
+ return ERR_AAC_INVALID_ADIF_HEADER;
+ }
+
+ /* syntactic element fields will be read from bitstream for each element */
+ aacDecInfo->prevBlockID = AAC_ID_INVALID;
+ aacDecInfo->currBlockID = AAC_ID_INVALID;
+ aacDecInfo->currInstTag = -1;
+
+ /* fill in user-accessible data */
+ aacDecInfo->bitRate = fhADIF->bitRate;
+ aacDecInfo->nChans = psi->nChans;
+ aacDecInfo->sampRate = sampRateTab[psi->sampRateIdx];
+ aacDecInfo->profile = pce[0].profile;
+ aacDecInfo->sbrEnabled = 0;
+
+ if (AACDataSource == 1) {
+ /* update bitstream reader */
+ bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset);
+ *buf += (bitsUsed + *bitOffset) >> 3;
+ *bitOffset = (bitsUsed + *bitOffset) & 0x07;
+ *bitsAvail -= bitsUsed ;
+ if (*bitsAvail < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: SetRawBlockParams
+ *
+ * Description: set internal state variables for decoding a stream of raw data blocks
+ *
+ * Inputs: valid AACDecInfo struct
+ * flag indicating source of parameters (from previous headers or passed
+ * explicitly by caller)
+ * number of channels
+ * sample rate
+ * profile ID
+ *
+ * Outputs: updated state variables in aacDecInfo
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: if copyLast == 1, then psi->nChans, psi->sampRateIdx, and
+ * aacDecInfo->profile are not changed (it's assumed that we already
+ * set them, such as by a previous call to UnpackADTSHeader())
+ * if copyLast == 0, then the parameters we passed in are used instead
+ **************************************************************************************/
+int SetRawBlockParams(AACDecInfo *aacDecInfo, int copyLast, int nChans, int sampRate, int profile)
+{
+ int idx;
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ if (!copyLast) {
+ aacDecInfo->profile = profile;
+ psi->nChans = nChans;
+ for (idx = 0; idx < NUM_SAMPLE_RATES; idx++) {
+ if (sampRate == sampRateTab[idx]) {
+ psi->sampRateIdx = idx;
+ break;
+ }
+ }
+ if (idx == NUM_SAMPLE_RATES) {
+ return ERR_AAC_INVALID_FRAME;
+ }
+ }
+ aacDecInfo->nChans = psi->nChans;
+ aacDecInfo->sampRate = sampRateTab[psi->sampRateIdx];
+
+ /* check validity of header */
+ if (psi->sampRateIdx >= NUM_SAMPLE_RATES || psi->sampRateIdx < 0 || aacDecInfo->profile != AAC_PROFILE_LC) {
+ return ERR_AAC_RAWBLOCK_PARAMS;
+ }
+
+ return ERR_AAC_NONE;
+}
+/**************************************************************************************
+ * Function: PrepareRawBlock
+ *
+ * Description: reset per-block state variables for raw blocks (no ADTS/ADIF headers)
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: updated state variables in aacDecInfo
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int PrepareRawBlock(AACDecInfo *aacDecInfo)
+{
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ /* syntactic element fields will be read from bitstream for each element */
+ aacDecInfo->prevBlockID = AAC_ID_INVALID;
+ aacDecInfo->currBlockID = AAC_ID_INVALID;
+ aacDecInfo->currInstTag = -1;
+
+ /* fill in user-accessible data */
+ aacDecInfo->bitRate = 0;
+ aacDecInfo->sbrEnabled = 0;
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: FlushCodec
+ *
+ * Description: flush internal codec state (after seeking, for example)
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: updated state variables in aacDecInfo
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: only need to clear data which is persistent between frames
+ * (such as overlap buffer)
+ **************************************************************************************/
+int FlushCodec(AACDecInfo *aacDecInfo)
+{
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ ClearBuffer(psi->overlap, AAC_MAX_NCHANS * AAC_MAX_NSAMPS * sizeof(int));
+ ClearBuffer(psi->prevWinShape, AAC_MAX_NCHANS * sizeof(int));
+
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/libfaad/helixaac/huffman_helix.c b/audio_codec/libfaad/helixaac/huffman_helix.c
new file mode 100644
index 0000000..fdf310f
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/huffman_helix.c
@@ -0,0 +1,450 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: huffman.c,v 1.2 2005/05/24 16:01:55 albertofloyd Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * huffman.c - Huffman decoding
+ **************************************************************************************/
+
+#include "coder.h"
+
+/**************************************************************************************
+ * Function: DecodeHuffmanScalar
+ *
+ * Description: decode one Huffman symbol from bitstream
+ *
+ * Inputs: pointers to Huffman table and info struct
+ * left-aligned bit buffer with >= huffTabInfo->maxBits bits
+ *
+ * Outputs: decoded symbol in *val
+ *
+ * Return: number of bits in symbol
+ *
+ * Notes: assumes canonical Huffman codes:
+ * first CW always 0, we have "count" CW's of length "nBits" bits
+ * starting CW for codes of length nBits+1 =
+ * (startCW[nBits] + count[nBits]) << 1
+ * if there are no codes at nBits, then we just keep << 1 each time
+ * (since count[nBits] = 0)
+ **************************************************************************************/
+int DecodeHuffmanScalar(const signed short *huffTab, const HuffInfo *huffTabInfo, unsigned int bitBuf, signed int *val)
+{
+ unsigned int count, start, shift, t;
+ const unsigned char *countPtr;
+ const signed short *map;
+
+ map = huffTab + huffTabInfo->offset;
+ countPtr = huffTabInfo->count;
+
+ start = 0;
+ count = 0;
+ shift = 32;
+ do {
+ start += count;
+ start <<= 1;
+ map += count;
+ count = *countPtr++;
+ shift--;
+ t = (bitBuf >> shift) - start;
+ } while (t >= count);
+
+ *val = (signed int)map[t];
+ return (countPtr - huffTabInfo->count);
+}
+
+#define APPLY_SIGN(v, s) {(v) ^= ((signed int)(s) >> 31); (v) -= ((signed int)(s) >> 31);}
+
+#define GET_QUAD_SIGNBITS(v) (((unsigned int)(v) << 17) >> 29) /* bits 14-12, unsigned */
+#define GET_QUAD_W(v) (((signed int)(v) << 20) >> 29) /* bits 11-9, sign-extend */
+#define GET_QUAD_X(v) (((signed int)(v) << 23) >> 29) /* bits 8-6, sign-extend */
+#define GET_QUAD_Y(v) (((signed int)(v) << 26) >> 29) /* bits 5-3, sign-extend */
+#define GET_QUAD_Z(v) (((signed int)(v) << 29) >> 29) /* bits 2-0, sign-extend */
+
+#define GET_PAIR_SIGNBITS(v) (((unsigned int)(v) << 20) >> 30) /* bits 11-10, unsigned */
+#define GET_PAIR_Y(v) (((signed int)(v) << 22) >> 27) /* bits 9-5, sign-extend */
+#define GET_PAIR_Z(v) (((signed int)(v) << 27) >> 27) /* bits 4-0, sign-extend */
+
+#define GET_ESC_SIGNBITS(v) (((unsigned int)(v) << 18) >> 30) /* bits 13-12, unsigned */
+#define GET_ESC_Y(v) (((signed int)(v) << 20) >> 26) /* bits 11-6, sign-extend */
+#define GET_ESC_Z(v) (((signed int)(v) << 26) >> 26) /* bits 5-0, sign-extend */
+
+/**************************************************************************************
+ * Function: UnpackZeros
+ *
+ * Description: fill a section of coefficients with zeros
+ *
+ * Inputs: number of coefficients
+ *
+ * Outputs: nVals zeros, starting at coef
+ *
+ * Return: none
+ *
+ * Notes: assumes nVals is always a multiple of 4 because all scalefactor bands
+ * are a multiple of 4 coefficients long
+ **************************************************************************************/
+static void UnpackZeros(int nVals, int *coef)
+{
+ while (nVals > 0) {
+ *coef++ = 0;
+ *coef++ = 0;
+ *coef++ = 0;
+ *coef++ = 0;
+ nVals -= 4;
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackQuads
+ *
+ * Description: decode a section of 4-way vector Huffman coded coefficients
+ *
+ * Inputs BitStreamInfo struct pointing to start of codewords for this section
+ * index of Huffman codebook
+ * number of coefficients
+ *
+ * Outputs: nVals coefficients, starting at coef
+ *
+ * Return: none
+ *
+ * Notes: assumes nVals is always a multiple of 4 because all scalefactor bands
+ * are a multiple of 4 coefficients long
+ **************************************************************************************/
+static void UnpackQuads(BitStreamInfo *bsi, int cb, int nVals, int *coef)
+{
+ int w, x, y, z, maxBits, nCodeBits, nSignBits, val;
+ unsigned int bitBuf;
+
+ maxBits = huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET].maxBits + 4;
+ while (nVals > 0) {
+ /* decode quad */
+ bitBuf = GetBitsNoAdvance(bsi, maxBits) << (32 - maxBits);
+ nCodeBits = DecodeHuffmanScalar(huffTabSpec, &huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET], bitBuf, &val);
+
+ w = GET_QUAD_W(val);
+ x = GET_QUAD_X(val);
+ y = GET_QUAD_Y(val);
+ z = GET_QUAD_Z(val);
+
+ bitBuf <<= nCodeBits;
+ nSignBits = (int)GET_QUAD_SIGNBITS(val);
+ AdvanceBitstream(bsi, nCodeBits + nSignBits);
+ if (nSignBits) {
+ if (w) {
+ APPLY_SIGN(w, bitBuf);
+ bitBuf <<= 1;
+ }
+ if (x) {
+ APPLY_SIGN(x, bitBuf);
+ bitBuf <<= 1;
+ }
+ if (y) {
+ APPLY_SIGN(y, bitBuf);
+ bitBuf <<= 1;
+ }
+ if (z) {
+ APPLY_SIGN(z, bitBuf);
+ bitBuf <<= 1;
+ }
+ }
+ *coef++ = w;
+ *coef++ = x;
+ *coef++ = y;
+ *coef++ = z;
+ nVals -= 4;
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackPairsNoEsc
+ *
+ * Description: decode a section of 2-way vector Huffman coded coefficients,
+ * using non-esc tables (5 through 10)
+ *
+ * Inputs BitStreamInfo struct pointing to start of codewords for this section
+ * index of Huffman codebook (must not be the escape codebook)
+ * number of coefficients
+ *
+ * Outputs: nVals coefficients, starting at coef
+ *
+ * Return: none
+ *
+ * Notes: assumes nVals is always a multiple of 2 because all scalefactor bands
+ * are a multiple of 4 coefficients long
+ **************************************************************************************/
+static void UnpackPairsNoEsc(BitStreamInfo *bsi, int cb, int nVals, int *coef)
+{
+ int y, z, maxBits, nCodeBits, nSignBits, val;
+ unsigned int bitBuf;
+
+ maxBits = huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET].maxBits + 2;
+ while (nVals > 0) {
+ /* decode pair */
+ bitBuf = GetBitsNoAdvance(bsi, maxBits) << (32 - maxBits);
+ nCodeBits = DecodeHuffmanScalar(huffTabSpec, &huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET], bitBuf, &val);
+
+ y = GET_PAIR_Y(val);
+ z = GET_PAIR_Z(val);
+
+ bitBuf <<= nCodeBits;
+ nSignBits = GET_PAIR_SIGNBITS(val);
+ AdvanceBitstream(bsi, nCodeBits + nSignBits);
+ if (nSignBits) {
+ if (y) {
+ APPLY_SIGN(y, bitBuf);
+ bitBuf <<= 1;
+ }
+ if (z) {
+ APPLY_SIGN(z, bitBuf);
+ bitBuf <<= 1;
+ }
+ }
+ *coef++ = y;
+ *coef++ = z;
+ nVals -= 2;
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackPairsEsc
+ *
+ * Description: decode a section of 2-way vector Huffman coded coefficients,
+ * using esc table (11)
+ *
+ * Inputs BitStreamInfo struct pointing to start of codewords for this section
+ * index of Huffman codebook (must be the escape codebook)
+ * number of coefficients
+ *
+ * Outputs: nVals coefficients, starting at coef
+ *
+ * Return: none
+ *
+ * Notes: assumes nVals is always a multiple of 2 because all scalefactor bands
+ * are a multiple of 4 coefficients long
+ **************************************************************************************/
+static void UnpackPairsEsc(BitStreamInfo *bsi, int cb, int nVals, int *coef)
+{
+ int y, z, maxBits, nCodeBits, nSignBits, n, val;
+ unsigned int bitBuf;
+
+ maxBits = huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET].maxBits + 2;
+ while (nVals > 0) {
+ /* decode pair with escape value */
+ bitBuf = GetBitsNoAdvance(bsi, maxBits) << (32 - maxBits);
+ nCodeBits = DecodeHuffmanScalar(huffTabSpec, &huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET], bitBuf, &val);
+
+ y = GET_ESC_Y(val);
+ z = GET_ESC_Z(val);
+
+ bitBuf <<= nCodeBits;
+ nSignBits = GET_ESC_SIGNBITS(val);
+ AdvanceBitstream(bsi, nCodeBits + nSignBits);
+
+ if (y == 16) {
+ n = 4;
+ while (GetBits(bsi, 1) == 1) {
+ n++;
+ }
+ y = (1 << n) + GetBits(bsi, n);
+ }
+ if (z == 16) {
+ n = 4;
+ while (GetBits(bsi, 1) == 1) {
+ n++;
+ }
+ z = (1 << n) + GetBits(bsi, n);
+ }
+
+ if (nSignBits) {
+ if (y) {
+ APPLY_SIGN(y, bitBuf);
+ bitBuf <<= 1;
+ }
+ if (z) {
+ APPLY_SIGN(z, bitBuf);
+ bitBuf <<= 1;
+ }
+ }
+
+ *coef++ = y;
+ *coef++ = z;
+ nVals -= 2;
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodeSpectrumLong
+ *
+ * Description: decode transform coefficients for frame with one long block
+ *
+ * Inputs: platform specific info struct
+ * BitStreamInfo struct pointing to start of spectral data
+ * (14496-3, table 4.4.29)
+ * index of current channel
+ *
+ * Outputs: decoded, quantized coefficients for this channel
+ *
+ * Return: none
+ *
+ * Notes: adds in pulse data if present
+ * fills coefficient buffer with zeros in any region not coded with
+ * codebook in range [1, 11] (including sfb's above sfbMax)
+ **************************************************************************************/
+int DecodeSpectrumLong(PSInfoBase *psi, BitStreamInfo *bsi, int ch)
+{
+ int i, sfb, cb, nVals, offset;
+ const short *sfbTab;
+ unsigned char *sfbCodeBook;
+ int *coef;
+ ICSInfo *icsInfo;
+ PulseInfo *pi;
+
+ coef = psi->coef[ch];
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ /* decode long block */
+ sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx];
+ sfbCodeBook = psi->sfbCodeBook[ch];
+ for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) {
+ cb = *sfbCodeBook++;
+ nVals = sfbTab[sfb + 1] - sfbTab[sfb];
+
+ if (cb == 0) {
+ UnpackZeros(nVals, coef);
+ } else if (cb <= 4) {
+ UnpackQuads(bsi, cb, nVals, coef);
+ } else if (cb <= 10) {
+ UnpackPairsNoEsc(bsi, cb, nVals, coef);
+ } else if (cb == 11) {
+ UnpackPairsEsc(bsi, cb, nVals, coef);
+ } else {
+ UnpackZeros(nVals, coef);
+ }
+
+ coef += nVals;
+ }
+
+ /* fill with zeros above maxSFB */
+ nVals = NSAMPS_LONG - sfbTab[sfb];
+ UnpackZeros(nVals, coef);
+
+ /* add pulse data, if present */
+ pi = &psi->pulseInfo[ch];
+ if (pi->pulseDataPresent) {
+ coef = psi->coef[ch];
+ offset = sfbTab[pi->startSFB];
+ for (i = 0; i < pi->numPulse; i++) {
+ offset += pi->offset[i];
+ if (coef[offset] > 0) {
+ coef[offset] += pi->amp[i];
+ } else {
+ coef[offset] -= pi->amp[i];
+ }
+ }
+ ASSERT(offset < NSAMPS_LONG, ERR_AAC_HUFFMAN_DECODING);
+ }
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: DecodeSpectrumShort
+ *
+ * Description: decode transform coefficients for frame with eight short blocks
+ *
+ * Inputs: platform specific info struct
+ * BitStreamInfo struct pointing to start of spectral data
+ * (14496-3, table 4.4.29)
+ * index of current channel
+ *
+ * Outputs: decoded, quantized coefficients for this channel
+ *
+ * Return: none
+ *
+ * Notes: fills coefficient buffer with zeros in any region not coded with
+ * codebook in range [1, 11] (including sfb's above sfbMax)
+ * deinterleaves window groups into 8 windows
+ **************************************************************************************/
+int DecodeSpectrumShort(PSInfoBase *psi, BitStreamInfo *bsi, int ch)
+{
+ int gp, cb, nVals = 0, win, offset, sfb;
+ const short *sfbTab;
+ unsigned char *sfbCodeBook;
+ int *coef;
+ ICSInfo *icsInfo;
+ coef = psi->coef[ch];
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ /* decode short blocks, deinterleaving in-place */
+ sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx];
+ sfbCodeBook = psi->sfbCodeBook[ch];
+ for (gp = 0; gp < icsInfo->numWinGroup; gp++) {
+ for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) {
+ nVals = sfbTab[sfb + 1] - sfbTab[sfb];
+ cb = *sfbCodeBook++;
+
+ for (win = 0; win < icsInfo->winGroupLen[gp]; win++) {
+ offset = win * NSAMPS_SHORT;
+ if (cb == 0) {
+ UnpackZeros(nVals, coef + offset);
+ } else if (cb <= 4) {
+ UnpackQuads(bsi, cb, nVals, coef + offset);
+ } else if (cb <= 10) {
+ UnpackPairsNoEsc(bsi, cb, nVals, coef + offset);
+ } else if (cb == 11) {
+ UnpackPairsEsc(bsi, cb, nVals, coef + offset);
+ } else {
+ UnpackZeros(nVals, coef + offset);
+ }
+ }
+ coef += nVals;
+ }
+
+ /* fill with zeros above maxSFB */
+ for (win = 0; win < icsInfo->winGroupLen[gp]; win++) {
+ offset = win * NSAMPS_SHORT;
+ nVals = NSAMPS_SHORT - sfbTab[sfb];
+ UnpackZeros(nVals, coef + offset);
+ }
+ coef += nVals;
+ coef += (icsInfo->winGroupLen[gp] - 1) * NSAMPS_SHORT;
+ }
+
+ ASSERT(coef == psi->coef[ch] + NSAMPS_LONG, ERR_AAC_COFF_EXCEED_RANGE);
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/libfaad/helixaac/hufftabs.c b/audio_codec/libfaad/helixaac/hufftabs.c
new file mode 100644
index 0000000..e153a61
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/hufftabs.c
@@ -0,0 +1,177 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: hufftabs.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * hufftabs.c - Huffman symbol tables
+ **************************************************************************************/
+
+#include "coder.h"
+
+const HuffInfo huffTabSpecInfo[11] = {
+ /* table 0 not used */
+ {11, { 1, 0, 0, 0, 8, 0, 24, 0, 24, 8, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0},
+ { 9, { 0, 0, 1, 1, 7, 24, 15, 19, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 81},
+ {16, { 1, 0, 0, 4, 2, 6, 3, 5, 15, 15, 8, 9, 3, 3, 5, 2, 0, 0, 0, 0}, 162},
+ {12, { 0, 0, 0, 10, 6, 0, 9, 21, 8, 14, 11, 2, 0, 0, 0, 0, 0, 0, 0, 0}, 243},
+ {13, { 1, 0, 0, 4, 4, 0, 4, 12, 12, 12, 18, 10, 4, 0, 0, 0, 0, 0, 0, 0}, 324},
+ {11, { 0, 0, 0, 9, 0, 16, 13, 8, 23, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 405},
+ {12, { 1, 0, 2, 1, 0, 4, 5, 10, 14, 15, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0}, 486},
+ {10, { 0, 0, 1, 5, 7, 10, 14, 15, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 550},
+ {15, { 1, 0, 2, 1, 0, 4, 3, 8, 11, 20, 31, 38, 32, 14, 4, 0, 0, 0, 0, 0}, 614},
+ {12, { 0, 0, 0, 3, 8, 14, 17, 25, 31, 41, 22, 8, 0, 0, 0, 0, 0, 0, 0, 0}, 783},
+ {12, { 0, 0, 0, 2, 6, 7, 16, 59, 55, 95, 43, 6, 0, 0, 0, 0, 0, 0, 0, 0}, 952},
+};
+
+const signed short huffTabSpec[1241] = {
+ /* spectrum table 1 [81] (signed) */
+ 0x0000, 0x0200, 0x0e00, 0x0007, 0x0040, 0x0001, 0x0038, 0x0008, 0x01c0, 0x03c0, 0x0e40, 0x0039, 0x0078, 0x01c8, 0x000f, 0x0240,
+ 0x003f, 0x0fc0, 0x01f8, 0x0238, 0x0047, 0x0e08, 0x0009, 0x0208, 0x01c1, 0x0048, 0x0041, 0x0e38, 0x0201, 0x0e07, 0x0207, 0x0e01,
+ 0x01c7, 0x0278, 0x0e78, 0x03c8, 0x004f, 0x0079, 0x01c9, 0x01cf, 0x03f8, 0x0239, 0x007f, 0x0e48, 0x0e0f, 0x0fc8, 0x01f9, 0x03c1,
+ 0x03c7, 0x0e47, 0x0ff8, 0x01ff, 0x0049, 0x020f, 0x0241, 0x0e41, 0x0248, 0x0fc1, 0x0e3f, 0x0247, 0x023f, 0x0e39, 0x0fc7, 0x0e09,
+ 0x0209, 0x03cf, 0x0e79, 0x0e4f, 0x03f9, 0x0249, 0x0fc9, 0x027f, 0x0fcf, 0x0fff, 0x0279, 0x03c9, 0x0e49, 0x0e7f, 0x0ff9, 0x03ff,
+ 0x024f,
+ /* spectrum table 2 [81] (signed) */
+ 0x0000, 0x0200, 0x0e00, 0x0001, 0x0038, 0x0007, 0x01c0, 0x0008, 0x0040, 0x01c8, 0x0e40, 0x0078, 0x000f, 0x0047, 0x0039, 0x0e07,
+ 0x03c0, 0x0238, 0x0fc0, 0x003f, 0x0208, 0x0201, 0x01c1, 0x0e08, 0x0041, 0x01f8, 0x0e01, 0x01c7, 0x0e38, 0x0240, 0x0048, 0x0009,
+ 0x0207, 0x0079, 0x0239, 0x0e78, 0x01cf, 0x03c8, 0x0247, 0x0209, 0x0e48, 0x01f9, 0x0248, 0x0e0f, 0x0ff8, 0x0e39, 0x03f8, 0x0278,
+ 0x03c1, 0x0e47, 0x0fc8, 0x0e09, 0x0fc1, 0x0fc7, 0x01ff, 0x020f, 0x023f, 0x007f, 0x0049, 0x0e41, 0x0e3f, 0x004f, 0x03c7, 0x01c9,
+ 0x0241, 0x03cf, 0x0e79, 0x03f9, 0x0fff, 0x0e4f, 0x0e49, 0x0249, 0x0fcf, 0x03c9, 0x0e7f, 0x0fc9, 0x027f, 0x03ff, 0x0ff9, 0x0279,
+ 0x024f,
+ /* spectrum table 3 [81] (unsigned) */
+ 0x0000, 0x1200, 0x1001, 0x1040, 0x1008, 0x2240, 0x2009, 0x2048, 0x2041, 0x2208, 0x3049, 0x2201, 0x3248, 0x4249, 0x3209, 0x3241,
+ 0x1400, 0x1002, 0x200a, 0x2440, 0x3288, 0x2011, 0x3051, 0x2280, 0x304a, 0x3448, 0x1010, 0x2088, 0x2050, 0x1080, 0x2042, 0x2408,
+ 0x4289, 0x3089, 0x3250, 0x4251, 0x3281, 0x2210, 0x3211, 0x2081, 0x4449, 0x424a, 0x3441, 0x320a, 0x2012, 0x3052, 0x3488, 0x3290,
+ 0x2202, 0x2401, 0x3091, 0x2480, 0x4291, 0x3242, 0x3409, 0x4252, 0x4489, 0x2090, 0x308a, 0x3212, 0x3481, 0x3450, 0x3490, 0x3092,
+ 0x4491, 0x4451, 0x428a, 0x4292, 0x2082, 0x2410, 0x3282, 0x3411, 0x444a, 0x3442, 0x4492, 0x448a, 0x4452, 0x340a, 0x2402, 0x3482,
+ 0x3412,
+ /* spectrum table 4 [81] (unsigned) */
+ 0x4249, 0x3049, 0x3241, 0x3248, 0x3209, 0x1200, 0x2240, 0x0000, 0x2009, 0x2208, 0x2201, 0x2048, 0x1001, 0x2041, 0x1008, 0x1040,
+ 0x4449, 0x4251, 0x4289, 0x424a, 0x3448, 0x3441, 0x3288, 0x3409, 0x3051, 0x304a, 0x3250, 0x3089, 0x320a, 0x3281, 0x3242, 0x3211,
+ 0x2440, 0x2408, 0x2280, 0x2401, 0x2042, 0x2088, 0x200a, 0x2050, 0x2081, 0x2202, 0x2011, 0x2210, 0x1400, 0x1002, 0x1080, 0x1010,
+ 0x4291, 0x4489, 0x4451, 0x4252, 0x428a, 0x444a, 0x3290, 0x3488, 0x3450, 0x3091, 0x3052, 0x3481, 0x308a, 0x3411, 0x3212, 0x4491,
+ 0x3282, 0x340a, 0x3442, 0x4292, 0x4452, 0x448a, 0x2090, 0x2480, 0x2012, 0x2410, 0x2082, 0x2402, 0x4492, 0x3092, 0x3490, 0x3482,
+ 0x3412,
+ /* spectrum table 5 [81] (signed) */
+ 0x0000, 0x03e0, 0x0020, 0x0001, 0x001f, 0x003f, 0x03e1, 0x03ff, 0x0021, 0x03c0, 0x0002, 0x0040, 0x001e, 0x03df, 0x0041, 0x03fe,
+ 0x0022, 0x03c1, 0x005f, 0x03e2, 0x003e, 0x03a0, 0x0060, 0x001d, 0x0003, 0x03bf, 0x0023, 0x0061, 0x03fd, 0x03a1, 0x007f, 0x003d,
+ 0x03e3, 0x03c2, 0x0042, 0x03de, 0x005e, 0x03be, 0x007e, 0x03c3, 0x005d, 0x0062, 0x0043, 0x03a2, 0x03dd, 0x001c, 0x0380, 0x0081,
+ 0x0080, 0x039f, 0x0004, 0x009f, 0x03fc, 0x0024, 0x03e4, 0x0381, 0x003c, 0x007d, 0x03bd, 0x03a3, 0x03c4, 0x039e, 0x0082, 0x005c,
+ 0x0044, 0x0063, 0x0382, 0x03dc, 0x009e, 0x007c, 0x039d, 0x0383, 0x0064, 0x03a4, 0x0083, 0x009d, 0x03bc, 0x009c, 0x0384, 0x0084,
+ 0x039c,
+ /* spectrum table 6 [81] (signed) */
+ 0x0000, 0x0020, 0x001f, 0x0001, 0x03e0, 0x0021, 0x03e1, 0x003f, 0x03ff, 0x005f, 0x0041, 0x03c1, 0x03df, 0x03c0, 0x03e2, 0x0040,
+ 0x003e, 0x0022, 0x001e, 0x03fe, 0x0002, 0x005e, 0x03c2, 0x03de, 0x0042, 0x03a1, 0x0061, 0x007f, 0x03e3, 0x03bf, 0x0023, 0x003d,
+ 0x03fd, 0x0060, 0x03a0, 0x001d, 0x0003, 0x0062, 0x03be, 0x03c3, 0x0043, 0x007e, 0x005d, 0x03dd, 0x03a2, 0x0063, 0x007d, 0x03bd,
+ 0x03a3, 0x003c, 0x03fc, 0x0081, 0x0381, 0x039f, 0x0024, 0x009f, 0x03e4, 0x001c, 0x0382, 0x039e, 0x0044, 0x03dc, 0x0380, 0x0082,
+ 0x009e, 0x03c4, 0x0080, 0x005c, 0x0004, 0x03bc, 0x03a4, 0x007c, 0x009d, 0x0064, 0x0083, 0x0383, 0x039d, 0x0084, 0x0384, 0x039c,
+ 0x009c,
+ /* spectrum table 7 [64] (unsigned) */
+ 0x0000, 0x0420, 0x0401, 0x0821, 0x0841, 0x0822, 0x0440, 0x0402, 0x0861, 0x0823, 0x0842, 0x0460, 0x0403, 0x0843, 0x0862, 0x0824,
+ 0x0881, 0x0825, 0x08a1, 0x0863, 0x0844, 0x0404, 0x0480, 0x0882, 0x0845, 0x08a2, 0x0405, 0x08c1, 0x04a0, 0x0826, 0x0883, 0x0865,
+ 0x0864, 0x08a3, 0x0846, 0x08c2, 0x0827, 0x0866, 0x0406, 0x04c0, 0x0884, 0x08e1, 0x0885, 0x08e2, 0x08a4, 0x08c3, 0x0847, 0x08e3,
+ 0x08c4, 0x08a5, 0x0886, 0x0867, 0x04e0, 0x0407, 0x08c5, 0x08a6, 0x08e4, 0x0887, 0x08a7, 0x08e5, 0x08e6, 0x08c6, 0x08c7, 0x08e7,
+ /* spectrum table 8 [64] (unsigned) */
+ 0x0821, 0x0841, 0x0420, 0x0822, 0x0401, 0x0842, 0x0000, 0x0440, 0x0402, 0x0861, 0x0823, 0x0862, 0x0843, 0x0863, 0x0881, 0x0824,
+ 0x0882, 0x0844, 0x0460, 0x0403, 0x0883, 0x0864, 0x08a2, 0x08a1, 0x0845, 0x0825, 0x08a3, 0x0865, 0x0884, 0x08a4, 0x0404, 0x0885,
+ 0x0480, 0x0846, 0x08c2, 0x08c1, 0x0826, 0x0866, 0x08c3, 0x08a5, 0x04a0, 0x08c4, 0x0405, 0x0886, 0x08e1, 0x08e2, 0x0847, 0x08c5,
+ 0x08e3, 0x0827, 0x08a6, 0x0867, 0x08c6, 0x08e4, 0x04c0, 0x0887, 0x0406, 0x08e5, 0x08e6, 0x08c7, 0x08a7, 0x04e0, 0x0407, 0x08e7,
+ /* spectrum table 9 [169] (unsigned) */
+ 0x0000, 0x0420, 0x0401, 0x0821, 0x0841, 0x0822, 0x0440, 0x0402, 0x0861, 0x0842, 0x0823, 0x0460, 0x0403, 0x0843, 0x0862, 0x0824,
+ 0x0881, 0x0844, 0x0825, 0x0882, 0x0863, 0x0404, 0x0480, 0x08a1, 0x0845, 0x0826, 0x0864, 0x08a2, 0x08c1, 0x0883, 0x0405, 0x0846,
+ 0x04a0, 0x0827, 0x0865, 0x0828, 0x0901, 0x0884, 0x08a3, 0x08c2, 0x08e1, 0x0406, 0x0902, 0x0848, 0x0866, 0x0847, 0x0885, 0x0921,
+ 0x0829, 0x08e2, 0x04c0, 0x08a4, 0x08c3, 0x0903, 0x0407, 0x0922, 0x0868, 0x0886, 0x0867, 0x0408, 0x0941, 0x08c4, 0x0849, 0x08a5,
+ 0x0500, 0x04e0, 0x08e3, 0x0942, 0x0923, 0x0904, 0x082a, 0x08e4, 0x08c5, 0x08a6, 0x0888, 0x0887, 0x0869, 0x0961, 0x08a8, 0x0520,
+ 0x0905, 0x0943, 0x084a, 0x0409, 0x0962, 0x0924, 0x08c6, 0x0981, 0x0889, 0x0906, 0x082b, 0x0925, 0x0944, 0x08a7, 0x08e5, 0x084b,
+ 0x082c, 0x0982, 0x0963, 0x086a, 0x08a9, 0x08c7, 0x0907, 0x0964, 0x040a, 0x08e6, 0x0983, 0x0540, 0x0945, 0x088a, 0x08c8, 0x084c,
+ 0x0926, 0x0927, 0x088b, 0x0560, 0x08c9, 0x086b, 0x08aa, 0x0908, 0x08e8, 0x0985, 0x086c, 0x0965, 0x08e7, 0x0984, 0x0966, 0x0946,
+ 0x088c, 0x08e9, 0x08ab, 0x040b, 0x0986, 0x08ca, 0x0580, 0x0947, 0x08ac, 0x08ea, 0x0928, 0x040c, 0x0967, 0x0909, 0x0929, 0x0948,
+ 0x08eb, 0x0987, 0x08cb, 0x090b, 0x0968, 0x08ec, 0x08cc, 0x090a, 0x0949, 0x090c, 0x092a, 0x092b, 0x092c, 0x094b, 0x0989, 0x094a,
+ 0x0969, 0x0988, 0x096a, 0x098a, 0x098b, 0x094c, 0x096b, 0x096c, 0x098c,
+ /* spectrum table 10 [169] (unsigned) */
+ 0x0821, 0x0822, 0x0841, 0x0842, 0x0420, 0x0401, 0x0823, 0x0862, 0x0861, 0x0843, 0x0863, 0x0440, 0x0402, 0x0844, 0x0882, 0x0824,
+ 0x0881, 0x0000, 0x0883, 0x0864, 0x0460, 0x0403, 0x0884, 0x0845, 0x08a2, 0x0825, 0x08a1, 0x08a3, 0x0865, 0x08a4, 0x0885, 0x08c2,
+ 0x0846, 0x08c3, 0x0480, 0x08c1, 0x0404, 0x0826, 0x0866, 0x08a5, 0x08c4, 0x0886, 0x08c5, 0x08e2, 0x0867, 0x0847, 0x08a6, 0x0902,
+ 0x08e3, 0x04a0, 0x08e1, 0x0405, 0x0901, 0x0827, 0x0903, 0x08e4, 0x0887, 0x0848, 0x08c6, 0x08e5, 0x0828, 0x0868, 0x0904, 0x0888,
+ 0x08a7, 0x0905, 0x08a8, 0x08e6, 0x08c7, 0x0922, 0x04c0, 0x08c8, 0x0923, 0x0869, 0x0921, 0x0849, 0x0406, 0x0906, 0x0924, 0x0889,
+ 0x0942, 0x0829, 0x08e7, 0x0907, 0x0925, 0x08e8, 0x0943, 0x08a9, 0x0944, 0x084a, 0x0941, 0x086a, 0x0926, 0x08c9, 0x0500, 0x088a,
+ 0x04e0, 0x0962, 0x08e9, 0x0963, 0x0946, 0x082a, 0x0961, 0x0927, 0x0407, 0x0908, 0x0945, 0x086b, 0x08aa, 0x0909, 0x0965, 0x0408,
+ 0x0964, 0x084b, 0x08ea, 0x08ca, 0x0947, 0x088b, 0x082b, 0x0982, 0x0928, 0x0983, 0x0966, 0x08ab, 0x0984, 0x0967, 0x0985, 0x086c,
+ 0x08cb, 0x0520, 0x0948, 0x0540, 0x0981, 0x0409, 0x088c, 0x0929, 0x0986, 0x084c, 0x090a, 0x092a, 0x082c, 0x0968, 0x0987, 0x08eb,
+ 0x08ac, 0x08cc, 0x0949, 0x090b, 0x0988, 0x040a, 0x08ec, 0x0560, 0x094a, 0x0969, 0x096a, 0x040b, 0x096b, 0x092b, 0x094b, 0x0580,
+ 0x090c, 0x0989, 0x094c, 0x092c, 0x096c, 0x098b, 0x040c, 0x098a, 0x098c,
+ /* spectrum table 11 [289] (unsigned) */
+ 0x0000, 0x2041, 0x2410, 0x1040, 0x1001, 0x2081, 0x2042, 0x2082, 0x2043, 0x20c1, 0x20c2, 0x1080, 0x2083, 0x1002, 0x20c3, 0x2101,
+ 0x2044, 0x2102, 0x2084, 0x2103, 0x20c4, 0x10c0, 0x1003, 0x2141, 0x2142, 0x2085, 0x2104, 0x2045, 0x2143, 0x20c5, 0x2144, 0x2105,
+ 0x2182, 0x2086, 0x2181, 0x2183, 0x20c6, 0x2046, 0x2110, 0x20d0, 0x2405, 0x2403, 0x2404, 0x2184, 0x2406, 0x1100, 0x2106, 0x1004,
+ 0x2090, 0x2145, 0x2150, 0x2407, 0x2402, 0x2408, 0x2087, 0x21c2, 0x20c7, 0x2185, 0x2146, 0x2190, 0x240a, 0x21c3, 0x21c1, 0x2409,
+ 0x21d0, 0x2050, 0x2047, 0x2107, 0x240b, 0x21c4, 0x240c, 0x2210, 0x2401, 0x2186, 0x2250, 0x2088, 0x2147, 0x2290, 0x240d, 0x2203,
+ 0x2202, 0x20c8, 0x1140, 0x240e, 0x22d0, 0x21c5, 0x2108, 0x2187, 0x21c6, 0x1005, 0x2204, 0x240f, 0x2310, 0x2048, 0x2201, 0x2390,
+ 0x2148, 0x2350, 0x20c9, 0x2205, 0x21c7, 0x2089, 0x2206, 0x2242, 0x2243, 0x23d0, 0x2109, 0x2188, 0x1180, 0x2244, 0x2149, 0x2207,
+ 0x21c8, 0x2049, 0x2283, 0x1006, 0x2282, 0x2241, 0x2245, 0x210a, 0x208a, 0x2246, 0x20ca, 0x2189, 0x2284, 0x2208, 0x2285, 0x2247,
+ 0x22c3, 0x204a, 0x11c0, 0x2286, 0x21c9, 0x20cb, 0x214a, 0x2281, 0x210b, 0x22c2, 0x2342, 0x218a, 0x2343, 0x208b, 0x1400, 0x214b,
+ 0x22c5, 0x22c4, 0x2248, 0x21ca, 0x2209, 0x1010, 0x210d, 0x1007, 0x20cd, 0x22c6, 0x2341, 0x2344, 0x2303, 0x208d, 0x2345, 0x220a,
+ 0x218b, 0x2288, 0x2287, 0x2382, 0x2304, 0x204b, 0x210c, 0x22c1, 0x20cc, 0x204d, 0x2302, 0x21cb, 0x20ce, 0x214c, 0x214d, 0x2384,
+ 0x210e, 0x22c7, 0x2383, 0x2305, 0x2346, 0x2306, 0x1200, 0x22c8, 0x208c, 0x2249, 0x2385, 0x218d, 0x228a, 0x23c2, 0x220b, 0x224a,
+ 0x2386, 0x2289, 0x214e, 0x22c9, 0x2381, 0x208e, 0x218c, 0x204c, 0x2348, 0x1008, 0x2347, 0x21cc, 0x2307, 0x21cd, 0x23c3, 0x2301,
+ 0x218e, 0x208f, 0x23c5, 0x23c4, 0x204e, 0x224b, 0x210f, 0x2387, 0x220d, 0x2349, 0x220c, 0x214f, 0x20cf, 0x228b, 0x22ca, 0x2308,
+ 0x23c6, 0x23c7, 0x220e, 0x23c1, 0x21ce, 0x1240, 0x1009, 0x224d, 0x224c, 0x2309, 0x2388, 0x228d, 0x2389, 0x230a, 0x218f, 0x21cf,
+ 0x224e, 0x23c8, 0x22cb, 0x22ce, 0x204f, 0x228c, 0x228e, 0x234b, 0x234a, 0x22cd, 0x22cc, 0x220f, 0x238b, 0x234c, 0x230d, 0x23c9,
+ 0x238a, 0x1280, 0x230b, 0x224f, 0x100a, 0x230c, 0x12c0, 0x230e, 0x228f, 0x234d, 0x100d, 0x238c, 0x23ca, 0x23cb, 0x22cf, 0x238d,
+ 0x1340, 0x100b, 0x234e, 0x23cc, 0x23cd, 0x230f, 0x1380, 0x238e, 0x234f, 0x1300, 0x238f, 0x100e, 0x100c, 0x23ce, 0x13c0, 0x100f,
+ 0x23cf,
+};
+
+const HuffInfo huffTabScaleFactInfo =
+{19, { 1, 0, 1, 3, 2, 4, 3, 5, 4, 6, 6, 6, 5, 8, 4, 7, 3, 7, 46, 0}, 0};
+
+/* note - includes offset of -60 (4.6.2.3 in spec) */
+const signed short huffTabScaleFact[121] = {
+ /* scale factor table [121] */
+ 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, 14, -14, 16, 15, 17,
+ 18, -15, -17, -16, 19, -18, -19, 20, -20, 21, -21, 22, -22, 23, -23, -25,
+ 25, -27, -24, -26, 24, -28, 27, 29, -30, -29, 26, -31, -34, -33, -32, -36,
+ 28, -35, -38, -37, 30, -39, -41, -57, -59, -58, -60, 38, 39, 40, 41, 42,
+ 57, 37, 31, 32, 33, 34, 35, 36, 44, 51, 52, 53, 54, 55, 56, 50,
+ 45, 46, 47, 48, 49, 58, -54, -52, -51, -50, -55, 43, 60, 59, -56, -53,
+ -45, -44, -42, -40, -43, -49, -48, -46, -47,
+};
+
diff --git a/audio_codec/libfaad/helixaac/imdct.c b/audio_codec/libfaad/helixaac/imdct.c
new file mode 100644
index 0000000..1a20f28
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/imdct.c
@@ -0,0 +1,596 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: imdct.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * imdct.c - inverse MDCT
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+#include "aacdec.h"
+
+#define RND_VAL (1 << (FBITS_OUT_IMDCT-1))
+
+#ifndef AAC_ENABLE_SBR
+
+/**************************************************************************************
+ * Function: DecWindowOverlap
+ *
+ * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM,
+ * for winSequence LONG-LONG
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * number of channels
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans
+ *
+ * Return: none
+ *
+ * Notes: this processes one channel at a time, but skips every other sample in
+ * the output buffer (pcm) for stereo interleaving
+ * this should fit in registers on ARM
+ *
+ * TODO: ARM5E version with saturating overlap/add (QADD)
+ * asm code with free pointer updates, better load scheduling
+ **************************************************************************************/
+static void DecWindowOverlap(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev)
+{
+ int in, w0, w1, f0, f1;
+ int *buf1, *over1;
+ short *pcm1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ pcm1 = pcm0 + (1024 - 1) * nChans;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ if (winTypeCurr == winTypePrev) {
+ /* cut window loads in half since current and overlap sections use same symmetric window */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ } else {
+ /* different windows for current and overlap parts - should still fit in registers on ARM w/o stack spill */
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapLongStart
+ *
+ * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM,
+ * for winSequence LONG-START
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * number of channels
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans
+ *
+ * Return: none
+ *
+ * Notes: this processes one channel at a time, but skips every other sample in
+ * the output buffer (pcm) for stereo interleaving
+ * this should fit in registers on ARM
+ *
+ * TODO: ARM5E version with saturating overlap/add (QADD)
+ * asm code with free pointer updates, better load scheduling
+ **************************************************************************************/
+static void DecWindowOverlapLongStart(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1;
+ short *pcm1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ pcm1 = pcm0 + (1024 - 1) * nChans;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ i = 448; /* 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ in = *buf1--;
+
+ *over1-- = 0; /* Wn = 0 for n = (2047, 2046, ... 1600) */
+ *over0++ = in >> 1; /* Wn = 1 for n = (1024, 1025, ... 1471) */
+ } while (--i);
+
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+
+ /* do 64 more loops - 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ w0 = *wndCurr++; /* W[0], W[1], ... --> W[255], W[254], ... */
+ w1 = *wndCurr++; /* W[127], W[126], ... --> W[128], W[129], ... */
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in); /* Wn = short window for n = (1599, 1598, ... , 1536) */
+ *over0++ = MULSHIFT32(w1, in); /* Wn = short window for n = (1472, 1473, ... , 1535) */
+ } while (over0 < over1);
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapLongStop
+ *
+ * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM,
+ * for winSequence LONG-STOP
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * number of channels
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans
+ *
+ * Return: none
+ *
+ * Notes: this processes one channel at a time, but skips every other sample in
+ * the output buffer (pcm) for stereo interleaving
+ * this should fit in registers on ARM
+ *
+ * TODO: ARM5E version with saturating overlap/add (QADD)
+ * asm code with free pointer updates, better load scheduling
+ **************************************************************************************/
+static void DecWindowOverlapLongStop(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1;
+ short *pcm1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ pcm1 = pcm0 + (1024 - 1) * nChans;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+
+ i = 448; /* 2 outputs, 2 overlaps per loop */
+ do {
+ /* Wn = 0 for n = (0, 1, ... 447) */
+ /* Wn = 1 for n = (576, 577, ... 1023) */
+ in = *buf0++;
+ f1 = in >> 1; /* scale since skipping multiply by Q31 */
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (--i);
+
+ /* do 64 more loops - 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++; /* W[0], W[1], ...W[63] */
+ w1 = *wndPrev++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapShort
+ *
+ * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM,
+ * for winSequence EIGHT-SHORT (does all 8 short blocks)
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * number of channels
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans
+ *
+ * Return: none
+ *
+ * Notes: this processes one channel at a time, but skips every other sample in
+ * the output buffer (pcm) for stereo interleaving
+ * this should fit in registers on ARM
+ *
+ * TODO: ARM5E version with saturating overlap/add (QADD)
+ * asm code with free pointer updates, better load scheduling
+ **************************************************************************************/
+static void DecWindowOverlapShort(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1;
+ short *pcm1;
+ const int *wndPrev, *wndCurr;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+
+ /* pcm[0-447] = 0 + overlap[0-447] */
+ i = 448;
+ do {
+ f0 = *over0++;
+ f1 = *over0++;
+ *pcm0 = CLIPTOSHORT((f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+ *pcm0 = CLIPTOSHORT((f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+ i -= 2;
+ } while (i);
+
+ /* pcm[448-575] = Wp[0-127] * block0[0-127] + overlap[448-575] */
+ pcm1 = pcm0 + (128 - 1) * nChans;
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ do {
+ w0 = *wndPrev++; /* W[0], W[1], ...W[63] */
+ w1 = *wndPrev++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ /* save over0/over1 for next short block, in the slots just vacated */
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+
+ /* pcm[576-703] = Wc[128-255] * block0[128-255] + Wc[0-127] * block1[0-127] + overlap[576-703]
+ * pcm[704-831] = Wc[128-255] * block1[128-255] + Wc[0-127] * block2[0-127] + overlap[704-831]
+ * pcm[832-959] = Wc[128-255] * block2[128-255] + Wc[0-127] * block3[0-127] + overlap[832-959]
+ */
+ for (i = 0; i < 3; i++) {
+ pcm0 += 64 * nChans;
+ pcm1 = pcm0 + (128 - 1) * nChans;
+ over0 += 64;
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *(over0 - 128); /* from last short block */
+ in += *(over0 + 0); /* from last full frame */
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *(over1 - 128); /* from last short block */
+ in += *(over1 + 0); /* from last full frame */
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ /* save over0/over1 for next short block, in the slots just vacated */
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+
+ /* pcm[960-1023] = Wc[128-191] * block3[128-191] + Wc[0-63] * block4[0-63] + overlap[960-1023]
+ * over[0-63] = Wc[192-255] * block3[192-255] + Wc[64-127] * block4[64-127]
+ */
+ pcm0 += 64 * nChans;
+ over0 -= 832; /* points at overlap[64] */
+ over1 = over0 + 128 - 1; /* points at overlap[191] */
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *(over0 + 768); /* from last short block */
+ in += *(over0 + 896); /* from last full frame */
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *(over1 + 768); /* from last short block */
+ *(over1 - 128) = in + f1;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in); /* save in overlap[128-191] */
+ *over0++ = MULSHIFT32(w1, in); /* save in overlap[64-127] */
+ } while (over0 < over1);
+
+ /* over0 now points at overlap[128] */
+
+ /* over[64-191] = Wc[128-255] * block4[128-255] + Wc[0-127] * block5[0-127]
+ * over[192-319] = Wc[128-255] * block5[128-255] + Wc[0-127] * block6[0-127]
+ * over[320-447] = Wc[128-255] * block6[128-255] + Wc[0-127] * block7[0-127]
+ * over[448-576] = Wc[128-255] * block7[128-255]
+ */
+ for (i = 0; i < 3; i++) {
+ over0 += 64;
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ /* from last short block */
+ *(over0 - 128) -= f0;
+ *(over1 - 128) += f1;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+
+ /* over[576-1024] = 0 */
+ i = 448;
+ over0 += 64;
+ do {
+ *over0++ = 0;
+ *over0++ = 0;
+ *over0++ = 0;
+ *over0++ = 0;
+ i -= 4;
+ } while (i);
+}
+
+#endif /* !AAC_ENABLE_SBR */
+
+/**************************************************************************************
+ * Function: IMDCT
+ *
+ * Description: inverse transform and convert to 16-bit PCM
+ *
+ * Inputs: valid AACDecInfo struct
+ * index of current channel (0 for SCE/LFE, 0 or 1 for CPE)
+ * output channel (range = [0, nChans-1])
+ *
+ * Outputs: complete frame of decoded PCM, after inverse transform
+ *
+ * Return: 0 if successful, -1 if error
+ *
+ * Notes: If AAC_ENABLE_SBR is defined at compile time then window + overlap
+ * does NOT clip to 16-bit PCM and does NOT interleave channels
+ * If AAC_ENABLE_SBR is NOT defined at compile time, then window + overlap
+ * does clip to 16-bit PCM and interleaves channels
+ * If SBR is enabled at compile time, but we don't know whether it is
+ * actually used for this frame (e.g. the first frame of a stream),
+ * we need to produce both clipped 16-bit PCM in outbuf AND
+ * unclipped 32-bit PCM in the SBR input buffer. In this case we make
+ * a separate pass over the 32-bit PCM to produce 16-bit PCM output.
+ * This inflicts a slight performance hit when decoding non-SBR files.
+ **************************************************************************************/
+int IMDCT(AACDecInfo *aacDecInfo, int ch, int chOut, short *outbuf)
+{
+ int i;
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+ outbuf += chOut;
+
+ /* optimized type-IV DCT (operates inplace) */
+ if (icsInfo->winSequence == 2) {
+ /* 8 short blocks */
+ for (i = 0; i < 8; i++) {
+ DCT4(0, psi->coef[ch] + i * 128, psi->gbCurrent[ch]);
+ }
+ } else {
+ /* 1 long block */
+ DCT4(1, psi->coef[ch], psi->gbCurrent[ch]);
+ }
+
+#ifdef AAC_ENABLE_SBR
+ /* window, overlap-add, don't clip to short (send to SBR decoder)
+ * store the decoded 32-bit samples in top half (second AAC_MAX_NSAMPS samples) of coef buffer
+ */
+ if (icsInfo->winSequence == 0) {
+ DecWindowOverlapNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 1) {
+ DecWindowOverlapLongStartNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 2) {
+ DecWindowOverlapShortNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 3) {
+ DecWindowOverlapLongStopNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]);
+ }
+
+ if (!aacDecInfo->sbrEnabled) {
+ for (i = 0; i < AAC_MAX_NSAMPS; i++) {
+ *outbuf = CLIPTOSHORT((psi->sbrWorkBuf[ch][i] + RND_VAL) >> FBITS_OUT_IMDCT);
+ outbuf += aacDecInfo->nChans;
+ }
+ }
+
+ aacDecInfo->rawSampleBuf[ch] = psi->sbrWorkBuf[ch];
+ aacDecInfo->rawSampleBytes = sizeof(int);
+ aacDecInfo->rawSampleFBits = FBITS_OUT_IMDCT;
+#else
+ /* window, overlap-add, round to PCM - optimized for each window sequence */
+ if (icsInfo->winSequence == 0) {
+ DecWindowOverlap(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 1) {
+ DecWindowOverlapLongStart(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 2) {
+ DecWindowOverlapShort(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 3) {
+ DecWindowOverlapLongStop(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]);
+ }
+
+ aacDecInfo->rawSampleBuf[ch] = 0;
+ aacDecInfo->rawSampleBytes = 0;
+ aacDecInfo->rawSampleFBits = 0;
+#endif
+
+ psi->prevWinShape[chOut] = icsInfo->winShape;
+
+ return 0;
+}
diff --git a/audio_codec/libfaad/helixaac/noiseless.c b/audio_codec/libfaad/helixaac/noiseless.c
new file mode 100644
index 0000000..e519e9d
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/noiseless.c
@@ -0,0 +1,513 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: noiseless.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * noiseless.c - decode channel info, scalefactors, quantized coefficients,
+ * scalefactor band codebook, and TNS coefficients from bitstream
+ **************************************************************************************/
+
+#include "coder.h"
+#include <stdio.h>
+
+
+/**************************************************************************************
+ * Function: DecodeICSInfo
+ *
+ * Description: decode individual channel stream info
+ *
+ * Inputs: BitStreamInfo struct pointing to start of ICS info
+ * (14496-3, table 4.4.6)
+ * sample rate index
+ *
+ * Outputs: updated icsInfo struct
+ *
+ * Return: none
+ **************************************************************************************/
+void DecodeICSInfo(BitStreamInfo *bsi, ICSInfo *icsInfo, int sampRateIdx)
+{
+ int sfb, g, mask;
+
+ icsInfo->icsResBit = GetBits(bsi, 1);
+ icsInfo->winSequence = GetBits(bsi, 2);
+ icsInfo->winShape = GetBits(bsi, 1);
+ if (icsInfo->winSequence == 2) {
+ /* short block */
+ icsInfo->maxSFB = GetBits(bsi, 4);
+ icsInfo->sfGroup = GetBits(bsi, 7);
+ icsInfo->numWinGroup = 1;
+ icsInfo->winGroupLen[0] = 1;
+ mask = 0x40; /* start with bit 6 */
+ for (g = 0; g < 7; g++) {
+ if (icsInfo->sfGroup & mask) {
+ icsInfo->winGroupLen[icsInfo->numWinGroup - 1]++;
+ } else {
+ icsInfo->numWinGroup++;
+ icsInfo->winGroupLen[icsInfo->numWinGroup - 1] = 1;
+ }
+ mask >>= 1;
+ }
+ } else {
+ /* long block */
+ icsInfo->maxSFB = GetBits(bsi, 6);
+ icsInfo->predictorDataPresent = GetBits(bsi, 1);
+ if (icsInfo->predictorDataPresent) {
+ icsInfo->predictorReset = GetBits(bsi, 1);
+ if (icsInfo->predictorReset) {
+ icsInfo->predictorResetGroupNum = GetBits(bsi, 5);
+ }
+ for (sfb = 0; sfb < MIN(icsInfo->maxSFB, predSFBMax[sampRateIdx]); sfb++) {
+ icsInfo->predictionUsed[sfb] = GetBits(bsi, 1);
+ }
+ }
+ icsInfo->numWinGroup = 1;
+ icsInfo->winGroupLen[0] = 1;
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodeSectionData
+ *
+ * Description: decode section data (scale factor band groupings and
+ * associated Huffman codebooks)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of ICS info
+ * (14496-3, table 4.4.25)
+ * window sequence (short or long blocks)
+ * number of window groups (1 for long blocks, 1-8 for short blocks)
+ * max coded scalefactor band
+ *
+ * Outputs: index of Huffman codebook for each scalefactor band in each section
+ *
+ * Return: none
+ *
+ * Notes: sectCB, sectEnd, sfbCodeBook, ordered by window groups for short blocks
+ **************************************************************************************/
+static int DecodeSectionData(BitStreamInfo *bsi, int winSequence, int numWinGrp, int maxSFB, unsigned char *sfbCodeBook)
+{
+ int g, cb, sfb;
+ int sectLen, sectLenBits, sectLenIncr, sectEscapeVal;
+
+ sectLenBits = (winSequence == 2 ? 3 : 5);
+ sectEscapeVal = (1 << sectLenBits) - 1;
+
+ for (g = 0; g < numWinGrp; g++) {
+ sfb = 0;
+ while (sfb < maxSFB) {
+ cb = GetBits(bsi, 4); /* next section codebook */
+ sectLen = 0;
+ do {
+ sectLenIncr = GetBits(bsi, sectLenBits);
+ sectLen += sectLenIncr;
+ } while (sectLenIncr == sectEscapeVal);
+
+ sfb += sectLen;
+ while (sectLen--) {
+ *sfbCodeBook++ = (unsigned char)cb;
+ }
+ }
+ ASSERT(sfb == maxSFB, ERR_AAC_HUFFMAN_DECODING);
+ }
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: DecodeOneScaleFactor
+ *
+ * Description: decode one scalefactor using scalefactor Huffman codebook
+ *
+ * Inputs: BitStreamInfo struct pointing to start of next coded scalefactor
+ *
+ * Outputs: updated BitstreamInfo struct
+ *
+ * Return: one decoded scalefactor, including index_offset of -60
+ **************************************************************************************/
+static int DecodeOneScaleFactor(BitStreamInfo *bsi)
+{
+ int nBits, val;
+ unsigned int bitBuf;
+
+ /* decode next scalefactor from bitstream */
+ bitBuf = GetBitsNoAdvance(bsi, huffTabScaleFactInfo.maxBits) << (32 - huffTabScaleFactInfo.maxBits);
+ nBits = DecodeHuffmanScalar(huffTabScaleFact, &huffTabScaleFactInfo, bitBuf, &val);
+ AdvanceBitstream(bsi, nBits);
+
+ return val;
+}
+
+/**************************************************************************************
+ * Function: DecodeScaleFactors
+ *
+ * Description: decode scalefactors, PNS energy, and intensity stereo weights
+ *
+ * Inputs: BitStreamInfo struct pointing to start of ICS info
+ * (14496-3, table 4.4.26)
+ * number of window groups (1 for long blocks, 1-8 for short blocks)
+ * max coded scalefactor band
+ * global gain (starting value for differential scalefactor coding)
+ * index of Huffman codebook for each scalefactor band in each section
+ *
+ * Outputs: decoded scalefactor for each section
+ *
+ * Return: none
+ *
+ * Notes: sfbCodeBook, scaleFactors ordered by window groups for short blocks
+ * for section with codebook 13, scaleFactors buffer has decoded PNS
+ * energy instead of regular scalefactor
+ * for section with codebook 14 or 15, scaleFactors buffer has intensity
+ * stereo weight instead of regular scalefactor
+ **************************************************************************************/
+static void DecodeScaleFactors(BitStreamInfo *bsi, int numWinGrp, int maxSFB, int globalGain,
+ unsigned char *sfbCodeBook, short *scaleFactors)
+{
+ int g, sfbCB, nrg, npf, val, sf, is;
+
+ /* starting values for differential coding */
+ sf = globalGain;
+ is = 0;
+ nrg = globalGain - 90 - 256;
+ npf = 1;
+
+ for (g = 0; g < numWinGrp * maxSFB; g++) {
+ sfbCB = *sfbCodeBook++;
+
+ if (sfbCB == 14 || sfbCB == 15) {
+ /* intensity stereo - differential coding */
+ val = DecodeOneScaleFactor(bsi);
+ is += val;
+ *scaleFactors++ = (short)is;
+ } else if (sfbCB == 13) {
+ /* PNS - first energy is directly coded, rest are Huffman coded (npf = noise_pcm_flag) */
+ if (npf) {
+ val = GetBits(bsi, 9);
+ npf = 0;
+ } else {
+ val = DecodeOneScaleFactor(bsi);
+ }
+ nrg += val;
+ *scaleFactors++ = (short)nrg;
+ } else if (sfbCB >= 1 && sfbCB <= 11) {
+ /* regular (non-zero) region - differential coding */
+ val = DecodeOneScaleFactor(bsi);
+ sf += val;
+ *scaleFactors++ = (short)sf;
+ } else {
+ /* inactive scalefactor band if codebook 0 */
+ *scaleFactors++ = 0;
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodePulseInfo
+ *
+ * Description: decode pulse information
+ *
+ * Inputs: BitStreamInfo struct pointing to start of pulse info
+ * (14496-3, table 4.4.7)
+ *
+ * Outputs: updated PulseInfo struct
+ *
+ * Return: none
+ **************************************************************************************/
+static void DecodePulseInfo(BitStreamInfo *bsi, PulseInfo *pi)
+{
+ int i;
+
+ pi->numPulse = GetBits(bsi, 2) + 1; /* add 1 here */
+ pi->startSFB = GetBits(bsi, 6);
+ for (i = 0; i < pi->numPulse; i++) {
+ pi->offset[i] = GetBits(bsi, 5);
+ pi->amp[i] = GetBits(bsi, 4);
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodeTNSInfo
+ *
+ * Description: decode TNS filter information
+ *
+ * Inputs: BitStreamInfo struct pointing to start of TNS info
+ * (14496-3, table 4.4.27)
+ * window sequence (short or long blocks)
+ *
+ * Outputs: updated TNSInfo struct
+ * buffer of decoded (signed) TNS filter coefficients
+ *
+ * Return: none
+ **************************************************************************************/
+static void DecodeTNSInfo(BitStreamInfo *bsi, int winSequence, TNSInfo *ti, signed char *tnsCoef)
+{
+ int i, w, f, coefBits, compress;
+ signed char c, s, n;
+ signed char sgnMask[3] = { 0x02, 0x04, 0x08};
+ signed char negMask[3] = {~0x03, ~0x07, ~0x0f};
+ unsigned char *filtLength, *filtOrder, *filtDir;
+
+ filtLength = ti->length;
+ filtOrder = ti->order;
+ filtDir = ti->dir;
+
+ if (winSequence == 2) {
+ /* short blocks */
+ for (w = 0; w < NWINDOWS_SHORT; w++) {
+ ti->numFilt[w] = GetBits(bsi, 1);
+ if (ti->numFilt[w]) {
+ ti->coefRes[w] = GetBits(bsi, 1) + 3;
+ *filtLength = GetBits(bsi, 4);
+ *filtOrder = GetBits(bsi, 3);
+ if (*filtOrder) {
+ *filtDir++ = GetBits(bsi, 1);
+ compress = GetBits(bsi, 1);
+ coefBits = (int)ti->coefRes[w] - compress; /* 2, 3, or 4 */
+ s = sgnMask[coefBits - 2];
+ n = negMask[coefBits - 2];
+ for (i = 0; i < *filtOrder; i++) {
+ c = GetBits(bsi, coefBits);
+ if (c & s) {
+ c |= n;
+ }
+ *tnsCoef++ = c;
+ }
+ }
+ filtLength++;
+ filtOrder++;
+ }
+ }
+ } else {
+ /* long blocks */
+ ti->numFilt[0] = GetBits(bsi, 2);
+ if (ti->numFilt[0]) {
+ ti->coefRes[0] = GetBits(bsi, 1) + 3;
+ }
+ for (f = 0; f < ti->numFilt[0]; f++) {
+ *filtLength = GetBits(bsi, 6);
+ *filtOrder = GetBits(bsi, 5);
+ if (*filtOrder) {
+ *filtDir++ = GetBits(bsi, 1);
+ compress = GetBits(bsi, 1);
+ coefBits = (int)ti->coefRes[0] - compress; /* 2, 3, or 4 */
+ s = sgnMask[coefBits - 2];
+ n = negMask[coefBits - 2];
+ for (i = 0; i < *filtOrder; i++) {
+ c = GetBits(bsi, coefBits);
+ if (c & s) {
+ c |= n;
+ }
+ *tnsCoef++ = c;
+ }
+ }
+ filtLength++;
+ filtOrder++;
+ }
+ }
+}
+
+/* bitstream field lengths for gain control data:
+ * gainBits[winSequence][0] = maxWindow (how many gain windows there are)
+ * gainBits[winSequence][1] = locBitsZero (bits for alocCode if window == 0)
+ * gainBits[winSequence][2] = locBits (bits for alocCode if window != 0)
+ */
+static const unsigned char gainBits[4][3] = {
+ {1, 5, 5}, /* long */
+ {2, 4, 2}, /* start */
+ {8, 2, 2}, /* short */
+ {2, 4, 5}, /* stop */
+};
+
+/**************************************************************************************
+ * Function: DecodeGainControlInfo
+ *
+ * Description: decode gain control information (SSR profile only)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of gain control info
+ * (14496-3, table 4.4.12)
+ * window sequence (short or long blocks)
+ *
+ * Outputs: updated GainControlInfo struct
+ *
+ * Return: none
+ **************************************************************************************/
+static void DecodeGainControlInfo(BitStreamInfo *bsi, int winSequence, GainControlInfo *gi)
+{
+ int bd, wd, ad;
+ int locBits, locBitsZero, maxWin;
+
+ gi->maxBand = GetBits(bsi, 2);
+ maxWin = (int)gainBits[winSequence][0];
+ locBitsZero = (int)gainBits[winSequence][1];
+ locBits = (int)gainBits[winSequence][2];
+
+ for (bd = 1; bd <= gi->maxBand; bd++) {
+ for (wd = 0; wd < maxWin; wd++) {
+ gi->adjNum[bd][wd] = GetBits(bsi, 3);
+ for (ad = 0; ad < gi->adjNum[bd][wd]; ad++) {
+ gi->alevCode[bd][wd][ad] = GetBits(bsi, 4);
+ gi->alocCode[bd][wd][ad] = GetBits(bsi, (wd == 0 ? locBitsZero : locBits));
+ }
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodeICS
+ *
+ * Description: decode individual channel stream
+ *
+ * Inputs: platform specific info struct
+ * BitStreamInfo struct pointing to start of individual channel stream
+ * (14496-3, table 4.4.24)
+ * index of current channel
+ *
+ * Outputs: updated section data, scale factor data, pulse data, TNS data,
+ * and gain control data
+ *
+ * Return: none
+ **************************************************************************************/
+static int DecodeICS(PSInfoBase *psi, BitStreamInfo *bsi, int ch)
+{
+ int globalGain;
+ ICSInfo *icsInfo;
+ PulseInfo *pi;
+ TNSInfo *ti;
+ GainControlInfo *gi;
+ int err = ERR_AAC_NONE;
+
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ globalGain = GetBits(bsi, 8);
+ if (!psi->commonWin) {
+ DecodeICSInfo(bsi, icsInfo, psi->sampRateIdx);
+ }
+
+ err = DecodeSectionData(bsi, icsInfo->winSequence, icsInfo->numWinGroup, icsInfo->maxSFB, psi->sfbCodeBook[ch]);
+ if (err) {
+ return err;
+ }
+ DecodeScaleFactors(bsi, icsInfo->numWinGroup, icsInfo->maxSFB, globalGain, psi->sfbCodeBook[ch], psi->scaleFactors[ch]);
+
+ pi = &psi->pulseInfo[ch];
+ pi->pulseDataPresent = GetBits(bsi, 1);
+ if (pi->pulseDataPresent) {
+ DecodePulseInfo(bsi, pi);
+ }
+
+ ti = &psi->tnsInfo[ch];
+ ti->tnsDataPresent = GetBits(bsi, 1);
+ if (ti->tnsDataPresent) {
+ DecodeTNSInfo(bsi, icsInfo->winSequence, ti, ti->coef);
+ }
+
+ gi = &psi->gainControlInfo[ch];
+ gi->gainControlDataPresent = GetBits(bsi, 1);
+ if (gi->gainControlDataPresent) {
+ /* disable SSR, as we can decode out this part */
+ return ERR_AAC_SSR_GAIN_NOT_ADDED;
+ DecodeGainControlInfo(bsi, icsInfo->winSequence, gi);
+ }
+ return err;
+}
+
+/**************************************************************************************
+ * Function: DecodeNoiselessData
+ *
+ * Description: decode noiseless data (side info and transform coefficients)
+ *
+ * Inputs: valid AACDecInfo struct
+ * double pointer to buffer pointing to start of individual channel stream
+ * (14496-3, table 4.4.24)
+ * pointer to bit offset
+ * pointer to number of valid bits remaining in buf
+ * index of current channel
+ *
+ * Outputs: updated global gain, section data, scale factor data, pulse data,
+ * TNS data, gain control data, and spectral data
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int DecodeNoiselessData(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail, int ch)
+{
+ int bitsUsed;
+ BitStreamInfo bsi;
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+ int err = 0;
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ if (AACDataSource == 1) {
+ SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf);
+ GetBits(&bsi, *bitOffset);
+ } else {
+ if (((*bitsAvail + 7) >> 3) < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+
+ err = DecodeICS(psi, &bsi, ch);
+ if (err) {
+ return err;
+ }
+ if (icsInfo->winSequence == 2) {
+ err = DecodeSpectrumShort(psi, &bsi, ch);
+ } else {
+ err = DecodeSpectrumLong(psi, &bsi, ch);
+ }
+ if (err) {
+ return err;
+ }
+ if (AACDataSource == 1) {
+ bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset);
+ *buf += ((bitsUsed + *bitOffset) >> 3);
+ *bitOffset = ((bitsUsed + *bitOffset) & 0x07);
+ *bitsAvail -= bitsUsed;
+ if (*bitsAvail < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+ aacDecInfo->sbDeinterleaveReqd[ch] = 0;
+ aacDecInfo->tnsUsed |= psi->tnsInfo[ch].tnsDataPresent; /* set flag if TNS used for any channel */
+
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/libfaad/helixaac/pns_helix.c b/audio_codec/libfaad/helixaac/pns_helix.c
new file mode 100644
index 0000000..2384593
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/pns_helix.c
@@ -0,0 +1,371 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: pns.c,v 1.2 2005/03/10 17:01:56 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * pns.c - perceptual noise substitution
+ **************************************************************************************/
+
+#include "coder.h"
+#ifndef __MW__
+#include "assembly.h"
+#else
+#include "assembly_mw.h"
+#endif /* __MW__ */
+
+/**************************************************************************************
+ * Function: Get32BitVal
+ *
+ * Description: generate 32-bit unsigned random number
+ *
+ * Inputs: last number calculated (seed, first time through)
+ *
+ * Outputs: new number, saved in *last
+ *
+ * Return: 32-bit number, uniformly distributed between [0, 2^32)
+ *
+ * Notes: uses simple linear congruential generator
+ **************************************************************************************/
+static unsigned int Get32BitVal(unsigned int *last)
+{
+ unsigned int r = *last;
+
+ /* use same coefs as MPEG reference code (classic LCG)
+ * use unsigned multiply to force reliable wraparound behavior in C (mod 2^32)
+ */
+ r = (1664525U * r) + 1013904223U;
+ *last = r;
+
+ return r;
+}
+
+/* pow(2, i/4.0) for i = [0,1,2,3], format = Q30 */
+static const int pow14[4] = {
+ 0x40000000, 0x4c1bf829, 0x5a82799a, 0x6ba27e65
+};
+
+#define NUM_ITER_INVSQRT 4
+
+#define X0_COEF_2 0xc0000000 /* Q29: -2.0 */
+#define X0_OFF_2 0x60000000 /* Q29: 3.0 */
+#define Q26_3 0x0c000000 /* Q26: 3.0 */
+
+/**************************************************************************************
+ * Function: InvRootR
+ *
+ * Description: use Newton's method to solve for x = 1/sqrt(r)
+ *
+ * Inputs: r in Q30 format, range = [0.25, 1] (normalize inputs to this range)
+ *
+ * Outputs: none
+ *
+ * Return: x = Q29, range = (1, 2)
+ *
+ * Notes: guaranteed to converge and not overflow for any r in this range
+ *
+ * xn+1 = xn - f(xn)/f'(xn)
+ * f(x) = 1/sqrt(r) - x = 0 (find root)
+ * = 1/x^2 - r
+ * f'(x) = -2/x^3
+ *
+ * so xn+1 = xn/2 * (3 - r*xn^2)
+ *
+ * NUM_ITER_INVSQRT = 3, maxDiff = 1.3747e-02
+ * NUM_ITER_INVSQRT = 4, maxDiff = 3.9832e-04
+ **************************************************************************************/
+static int InvRootR(int r)
+{
+ int i, xn, t;
+
+ /* use linear equation for initial guess
+ * x0 = -2*r + 3 (so x0 always >= correct answer in range [0.25, 1))
+ * xn = Q29 (at every step)
+ */
+ xn = (MULSHIFT32(r, X0_COEF_2) << 2) + X0_OFF_2;
+
+ for (i = 0; i < NUM_ITER_INVSQRT; i++) {
+ t = MULSHIFT32(xn, xn); /* Q26 = Q29*Q29 */
+ t = Q26_3 - (MULSHIFT32(r, t) << 2); /* Q26 = Q26 - (Q31*Q26 << 1) */
+ xn = MULSHIFT32(xn, t) << (6 - 1); /* Q29 = (Q29*Q26 << 6), and -1 for division by 2 */
+ }
+
+ /* clip to range (1.0, 2.0)
+ * (because of rounding, this can converge to xn slightly > 2.0 when r is near 0.25)
+ */
+ if (xn >> 30) {
+ xn = (1 << 30) - 1;
+ }
+
+ return xn;
+}
+
+/**************************************************************************************
+ * Function: ScaleNoiseVector
+ *
+ * Description: apply scaling to vector of noise coefficients for one scalefactor band
+ *
+ * Inputs: unscaled coefficients
+ * number of coefficients in vector (one scalefactor band of coefs)
+ * scalefactor for this band (i.e. noise energy)
+ *
+ * Outputs: nVals coefficients in Q(FBITS_OUT_DQ_OFF)
+ *
+ * Return: guard bit mask (OR of abs value of all noise coefs)
+ **************************************************************************************/
+static int ScaleNoiseVector(int *coef, int nVals, int sf)
+{
+ int i, c, spec, energy, sq, scalef, scalei, invSqrtEnergy, z, gbMask;
+
+ energy = 0;
+ for (i = 0; i < nVals; i++) {
+ spec = coef[i];
+
+ /* max nVals = max SFB width = 96, so energy can gain < 2^7 bits in accumulation */
+ sq = (spec * spec) >> 8; /* spec*spec range = (-2^30, 2^30) */
+ energy += sq;
+ }
+
+ /* unless nVals == 1 (or the number generator is broken...), this should not happen */
+ if (energy == 0) {
+ return 0; /* coef[i] must = 0 for i = [0, nVals-1], so gbMask = 0 */
+ }
+
+ /* pow(2, sf/4) * pow(2, FBITS_OUT_DQ_OFF) */
+ scalef = pow14[sf & 0x3];
+ scalei = (sf >> 2) + FBITS_OUT_DQ_OFF;
+
+ /* energy has implied factor of 2^-8 since we shifted the accumulator
+ * normalize energy to range [0.25, 1.0), calculate 1/sqrt(1), and denormalize
+ * i.e. divide input by 2^(30-z) and convert to Q30
+ * output of 1/sqrt(i) now has extra factor of 2^((30-z)/2)
+ * for energy > 0, z is an even number between 0 and 28
+ * final scaling of invSqrtEnergy:
+ * 2^(15 - z/2) to compensate for implicit 2^(30-z) factor in input
+ * +4 to compensate for implicit 2^-8 factor in input
+ */
+ z = CLZ(energy) - 2; /* energy has at least 2 leading zeros (see acc loop) */
+ z &= 0xfffffffe; /* force even */
+ invSqrtEnergy = InvRootR(energy << z); /* energy << z must be in range [0x10000000, 0x40000000] */
+ scalei -= (15 - z / 2 + 4); /* nInt = 1/sqrt(energy) in Q29 */
+
+ /* normalize for final scaling */
+ z = CLZ(invSqrtEnergy) - 1;
+ invSqrtEnergy <<= z;
+ scalei -= (z - 3 - 2); /* -2 for scalef, z-3 for invSqrtEnergy */
+ scalef = MULSHIFT32(scalef, invSqrtEnergy); /* scalef (input) = Q30, invSqrtEnergy = Q29 * 2^z */
+ gbMask = 0;
+
+ if (scalei < 0) {
+ scalei = -scalei;
+ if (scalei > 31) {
+ scalei = 31;
+ }
+ for (i = 0; i < nVals; i++) {
+ c = MULSHIFT32(coef[i], scalef) >> scalei;
+ gbMask |= FASTABS(c);
+ coef[i] = c;
+ }
+ } else {
+ /* for scalei <= 16, no clipping possible (coef[i] is < 2^15 before scaling)
+ * for scalei > 16, just saturate exponent (rare)
+ * scalef is close to full-scale (since we normalized invSqrtEnergy)
+ * remember, we are just producing noise here
+ */
+ if (scalei > 16) {
+ scalei = 16;
+ }
+ for (i = 0; i < nVals; i++) {
+ c = MULSHIFT32(coef[i] << scalei, scalef);
+ coef[i] = c;
+ gbMask |= FASTABS(c);
+ }
+ }
+
+ return gbMask;
+}
+
+/**************************************************************************************
+ * Function: GenerateNoiseVector
+ *
+ * Description: create vector of noise coefficients for one scalefactor band
+ *
+ * Inputs: seed for number generator
+ * number of coefficients to generate
+ *
+ * Outputs: buffer of nVals coefficients, range = [-2^15, 2^15)
+ * updated seed for number generator
+ *
+ * Return: none
+ **************************************************************************************/
+static void GenerateNoiseVector(int *coef, int *last, int nVals)
+{
+ int i;
+
+ for (i = 0; i < nVals; i++) {
+ coef[i] = ((signed int)Get32BitVal((unsigned int *)last)) >> 16;
+ }
+}
+
+/**************************************************************************************
+ * Function: CopyNoiseVector
+ *
+ * Description: copy vector of noise coefficients for one scalefactor band from L to R
+ *
+ * Inputs: buffer of left coefficients
+ * number of coefficients to copy
+ *
+ * Outputs: buffer of right coefficients
+ *
+ * Return: none
+ **************************************************************************************/
+static void CopyNoiseVector(int *coefL, int *coefR, int nVals)
+{
+ int i;
+
+ for (i = 0; i < nVals; i++) {
+ coefR[i] = coefL[i];
+ }
+}
+
+/**************************************************************************************
+ * Function: PNS
+ *
+ * Description: apply perceptual noise substitution, if enabled (MPEG-4 only)
+ *
+ * Inputs: valid AACDecInfo struct
+ * index of current channel
+ *
+ * Outputs: shaped noise in scalefactor bands where PNS is active
+ * updated minimum guard bit count for this channel
+ *
+ * Return: 0 if successful, -1 if error
+ **************************************************************************************/
+int PNS(AACDecInfo *aacDecInfo, int ch)
+{
+ int gp, sfb, win, width, nSamps, gb, gbMask;
+ int *coef;
+ const short *sfbTab;
+ unsigned char *sfbCodeBook;
+ short *scaleFactors;
+ int msMaskOffset, checkCorr, genNew;
+ unsigned char msMask;
+ unsigned char *msMaskPtr;
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ if (!psi->pnsUsed[ch]) {
+ return 0;
+ }
+
+ if (icsInfo->winSequence == 2) {
+ sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_SHORT;
+ } else {
+ sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_LONG;
+ }
+ coef = psi->coef[ch];
+ sfbCodeBook = psi->sfbCodeBook[ch];
+ scaleFactors = psi->scaleFactors[ch];
+ checkCorr = (aacDecInfo->currBlockID == AAC_ID_CPE && psi->commonWin == 1 ? 1 : 0);
+
+ gbMask = 0;
+ for (gp = 0; gp < icsInfo->numWinGroup; gp++) {
+ for (win = 0; win < icsInfo->winGroupLen[gp]; win++) {
+ msMaskPtr = psi->msMaskBits + ((gp * icsInfo->maxSFB) >> 3);
+ msMaskOffset = ((gp * icsInfo->maxSFB) & 0x07);
+ msMask = (*msMaskPtr++) >> msMaskOffset;
+
+ for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) {
+ width = sfbTab[sfb + 1] - sfbTab[sfb];
+ if (sfbCodeBook[sfb] == 13) {
+ if (ch == 0) {
+ /* generate new vector, copy into ch 1 if it's possible that the channels will be correlated
+ * if ch 1 has PNS enabled for this SFB but it's uncorrelated (i.e. ms_used == 0),
+ * the copied values will be overwritten when we process ch 1
+ */
+ GenerateNoiseVector(coef, &psi->pnsLastVal, width);
+ if (checkCorr && psi->sfbCodeBook[1][gp * icsInfo->maxSFB + sfb] == 13) {
+ CopyNoiseVector(coef, psi->coef[1] + (coef - psi->coef[0]), width);
+ }
+ } else {
+ /* generate new vector if no correlation between channels */
+ genNew = 1;
+ if (checkCorr && psi->sfbCodeBook[0][gp * icsInfo->maxSFB + sfb] == 13) {
+ if ((psi->msMaskPresent == 1 && (msMask & 0x01)) || psi->msMaskPresent == 2) {
+ genNew = 0;
+ }
+ }
+ if (genNew) {
+ GenerateNoiseVector(coef, &psi->pnsLastVal, width);
+ }
+ }
+ gbMask |= ScaleNoiseVector(coef, width, psi->scaleFactors[ch][gp * icsInfo->maxSFB + sfb]);
+ }
+ coef += width;
+
+ /* get next mask bit (should be branchless on ARM) */
+ msMask >>= 1;
+ if (++msMaskOffset == 8) {
+ msMask = *msMaskPtr++;
+ msMaskOffset = 0;
+ }
+ }
+ coef += (nSamps - sfbTab[icsInfo->maxSFB]);
+ }
+ sfbCodeBook += icsInfo->maxSFB;
+ scaleFactors += icsInfo->maxSFB;
+ }
+
+ /* update guard bit count if necessary */
+ gb = CLZ(gbMask) - 1;
+ if (psi->gbCurrent[ch] > gb) {
+ psi->gbCurrent[ch] = gb;
+ }
+
+ return 0;
+}
diff --git a/audio_codec/libfaad/helixaac/sbr.c b/audio_codec/libfaad/helixaac/sbr.c
new file mode 100644
index 0000000..fcf1fe4
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/sbr.c
@@ -0,0 +1,433 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbr.c,v 1.4 2008/01/15 21:20:31 ehyche Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbr.c - top level functions for SBR
+ **************************************************************************************/
+
+#if defined(REAL_FORMAT_SDK)
+#include "rm_memory_shim.h"
+#define malloc hx_realformatsdk_malloc
+#define free hx_realformatsdk_free
+#endif /* #if defined(REAL_FORMAT_SDK) */
+
+#include "sbr.h"
+#include <stdio.h>
+
+/**************************************************************************************
+ * Function: InitSBRState
+ *
+ * Description: initialize PSInfoSBR struct at start of stream or after flush
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: PSInfoSBR struct with proper initial state
+ *
+ * Return: none
+ **************************************************************************************/
+static void InitSBRState(PSInfoSBR *psi)
+{
+ int i, ch;
+ unsigned char *c;
+
+ if (!psi) {
+ return;
+ }
+
+ /* clear SBR state structure */
+ c = (unsigned char *)psi;
+ for (i = 0; i < (int)sizeof(PSInfoSBR); i++) {
+ *c++ = 0;
+ }
+
+ /* initialize non-zero state variables */
+ for (ch = 0; ch < AAC_MAX_NCHANS; ch++) {
+ psi->sbrChan[ch].reset = 1;
+ psi->sbrChan[ch].laPrev = -1;
+ }
+}
+
+/**************************************************************************************
+ * Function: InitSBR
+ *
+ * Description: initialize SBR decoder
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: PSInfoSBR struct to hold SBR state information
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Note: memory allocation for SBR is only done here
+ **************************************************************************************/
+int InitSBR(AACDecInfo *aacDecInfo)
+{
+ PSInfoSBR *psi;
+
+ if (!aacDecInfo) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ /* allocate SBR state structure */
+ psi = (PSInfoSBR *)malloc(sizeof(PSInfoSBR));
+ if (!psi) {
+ return ERR_AAC_SBR_INIT;
+ }
+
+ InitSBRState(psi);
+
+ aacDecInfo->psInfoSBR = psi;
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: FreeSBR
+ *
+ * Description: free SBR decoder
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: none
+ *
+ * Return: none
+ *
+ * Note: memory deallocation for SBR is only done here
+ **************************************************************************************/
+void FreeSBR(AACDecInfo *aacDecInfo)
+{
+ if (aacDecInfo && aacDecInfo->psInfoSBR) {
+ free(aacDecInfo->psInfoSBR);
+ }
+
+ return;
+}
+
+/**************************************************************************************
+ * Function: DecodeSBRBitstream
+ *
+ * Description: decode sideband information for SBR
+ *
+ * Inputs: valid AACDecInfo struct
+ * fill buffer with SBR extension block
+ * number of bytes in fill buffer
+ * base output channel (range = [0, nChans-1])
+ *
+ * Outputs: initialized state structs (SBRHdr, SBRGrid, SBRFreq, SBRChan)
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: SBR payload should be in aacDecInfo->fillBuf
+ * returns with no error if fill buffer is not an SBR extension block,
+ * or if current block is not a fill block (e.g. for LFE upsampling)
+ **************************************************************************************/
+int DecodeSBRBitstream(AACDecInfo *aacDecInfo, int chBase)
+{
+ int headerFlag;
+ BitStreamInfo bsi;
+ PSInfoSBR *psi;
+ int err = ERR_AAC_NONE;
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoSBR) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoSBR *)(aacDecInfo->psInfoSBR);
+
+ if (aacDecInfo->currBlockID != AAC_ID_FIL || (aacDecInfo->fillExtType != EXT_SBR_DATA && aacDecInfo->fillExtType != EXT_SBR_DATA_CRC)) {
+ return ERR_AAC_NONE;
+ }
+
+ SetBitstreamPointer(&bsi, aacDecInfo->fillCount, aacDecInfo->fillBuf);
+ if (GetBits(&bsi, 4) != (unsigned int)aacDecInfo->fillExtType) {
+ return ERR_AAC_SBR_BITSTREAM;
+ }
+
+ if (aacDecInfo->fillExtType == EXT_SBR_DATA_CRC) {
+ psi->crcCheckWord = GetBits(&bsi, 10);
+ }
+
+ headerFlag = GetBits(&bsi, 1);
+ if (headerFlag) {
+ /* get sample rate index for output sample rate (2x base rate) */
+ psi->sampRateIdx = GetSampRateIdx(2 * aacDecInfo->sampRate);
+ if (psi->sampRateIdx < 0 || psi->sampRateIdx >= NUM_SAMPLE_RATES) {
+ return ERR_AAC_SBR_BITSTREAM;
+ } else if (psi->sampRateIdx >= NUM_SAMPLE_RATES_SBR) {
+ return ERR_AAC_SBR_SINGLERATE_UNSUPPORTED;
+ }
+
+ /* reset flag = 1 if header values changed */
+ if (UnpackSBRHeader(&bsi, &(psi->sbrHdr[chBase]))) {
+ psi->sbrChan[chBase].reset = 1;
+ }
+
+ /* first valid SBR header should always trigger CalcFreqTables(), since psi->reset was set in InitSBR() */
+ if (psi->sbrChan[chBase].reset) {
+ CalcFreqTables(&(psi->sbrHdr[chBase + 0]), &(psi->sbrFreq[chBase]), psi->sampRateIdx);
+ }
+
+ /* copy and reset state to right channel for CPE */
+ if (aacDecInfo->prevBlockID == AAC_ID_CPE) {
+ psi->sbrChan[chBase + 1].reset = psi->sbrChan[chBase + 0].reset;
+ }
+ }
+
+
+ /* if no header has been received, upsample only */
+ if (psi->sbrHdr[chBase].count == 0) {
+ return ERR_AAC_NONE;
+ }
+
+ if (aacDecInfo->prevBlockID == AAC_ID_SCE) {
+ err = UnpackSBRSingleChannel(&bsi, psi, chBase);
+ } else if (aacDecInfo->prevBlockID == AAC_ID_CPE) {
+ err = UnpackSBRChannelPair(&bsi, psi, chBase);
+ } else {
+ return ERR_AAC_SBR_BITSTREAM;
+ }
+ ByteAlignBitstream(&bsi);
+
+ return err;
+}
+
+/**************************************************************************************
+ * Function: DecodeSBRData
+ *
+ * Description: apply SBR to one frame of PCM data
+ *
+ * Inputs: 1024 samples of decoded 32-bit PCM, before SBR
+ * size of input PCM samples (must be 4 bytes)
+ * number of fraction bits in input PCM samples
+ * base output channel (range = [0, nChans-1])
+ * initialized state structs (SBRHdr, SBRGrid, SBRFreq, SBRChan)
+ *
+ * Outputs: 2048 samples of decoded 16-bit PCM, after SBR
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int DecodeSBRData(AACDecInfo *aacDecInfo, int chBase, short *outbuf)
+{
+ int k, l, ch, chBlock, qmfaBands, qmfsBands;
+ int upsampleOnly, gbIdx, gbMask;
+ int *inbuf;
+ short *outptr;
+ PSInfoSBR *psi;
+ SBRHeader *sbrHdr;
+ SBRGrid *sbrGrid;
+ SBRFreq *sbrFreq;
+ SBRChan *sbrChan;
+ int err = ERR_AAC_NONE;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoSBR) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoSBR *)(aacDecInfo->psInfoSBR);
+
+ /* same header and freq tables for both channels in CPE */
+ sbrHdr = &(psi->sbrHdr[chBase]);
+ sbrFreq = &(psi->sbrFreq[chBase]);
+
+ /* upsample only if we haven't received an SBR header yet or if we have an LFE block */
+ if (aacDecInfo->currBlockID == AAC_ID_LFE) {
+ chBlock = 1;
+ upsampleOnly = 1;
+ } else if (aacDecInfo->currBlockID == AAC_ID_FIL) {
+ if (aacDecInfo->prevBlockID == AAC_ID_SCE) {
+ chBlock = 1;
+ } else if (aacDecInfo->prevBlockID == AAC_ID_CPE) {
+ chBlock = 2;
+ } else {
+ return ERR_AAC_NONE;
+ }
+
+ upsampleOnly = (sbrHdr->count == 0 ? 1 : 0);
+ if (aacDecInfo->fillExtType != EXT_SBR_DATA && aacDecInfo->fillExtType != EXT_SBR_DATA_CRC) {
+ return ERR_AAC_NONE;
+ }
+ } else {
+ /* ignore non-SBR blocks */
+ return ERR_AAC_NONE;
+ }
+
+ if (upsampleOnly) {
+ sbrFreq->kStart = 32;
+ sbrFreq->numQMFBands = 0;
+ }
+
+ for (ch = 0; ch < chBlock; ch++) {
+ sbrGrid = &(psi->sbrGrid[chBase + ch]);
+ sbrChan = &(psi->sbrChan[chBase + ch]);
+
+ if (aacDecInfo->rawSampleBuf[ch] == 0 || aacDecInfo->rawSampleBytes != 4) {
+ return ERR_AAC_SBR_PCM_FORMAT;
+ }
+ inbuf = (int *)aacDecInfo->rawSampleBuf[ch];
+ outptr = outbuf + chBase + ch;
+
+ /* restore delay buffers (could use ring buffer or keep in temp buffer for nChans == 1) */
+ for (l = 0; l < HF_GEN; l++) {
+ for (k = 0; k < 64; k++) {
+ psi->XBuf[l][k][0] = psi->XBufDelay[chBase + ch][l][k][0];
+ psi->XBuf[l][k][1] = psi->XBufDelay[chBase + ch][l][k][1];
+ }
+ }
+
+ /* step 1 - analysis QMF */
+ qmfaBands = sbrFreq->kStart;
+ for (l = 0; l < 32; l++) {
+ gbMask = QMFAnalysis(inbuf + l * 32, psi->delayQMFA[chBase + ch], psi->XBuf[l + HF_GEN][0],
+ aacDecInfo->rawSampleFBits, &(psi->delayIdxQMFA[chBase + ch]), qmfaBands);
+
+ gbIdx = ((l + HF_GEN) >> 5) & 0x01;
+ sbrChan->gbMask[gbIdx] |= gbMask; /* gbIdx = (0 if i < 32), (1 if i >= 32) */
+ }
+
+ if (upsampleOnly) {
+ /* no SBR - just run synthesis QMF to upsample by 2x */
+ qmfsBands = 32;
+ for (l = 0; l < 32; l++) {
+ /* step 4 - synthesis QMF */
+ QMFSynthesis(psi->XBuf[l + HF_ADJ][0], psi->delayQMFS[chBase + ch], &(psi->delayIdxQMFS[chBase + ch]), qmfsBands, outptr, aacDecInfo->nChans);
+ outptr += 64 * aacDecInfo->nChans;
+ }
+ } else {
+ /* if previous frame had lower SBR starting freq than current, zero out the synthesized QMF
+ * bands so they aren't used as sources for patching
+ * after patch generation, restore from delay buffer
+ * can only happen after header reset
+ */
+ for (k = sbrFreq->kStartPrev; k < sbrFreq->kStart; k++) {
+ for (l = 0; l < sbrGrid->envTimeBorder[0] + HF_ADJ; l++) {
+ psi->XBuf[l][k][0] = 0;
+ psi->XBuf[l][k][1] = 0;
+ }
+ }
+
+ /* step 2 - HF generation */
+ err = GenerateHighFreq(psi, sbrGrid, sbrFreq, sbrChan, ch);
+ if (err) {
+ return err;
+ }
+
+ /* restore SBR bands that were cleared before patch generation (time slots 0, 1 no longer needed) */
+ for (k = sbrFreq->kStartPrev; k < sbrFreq->kStart; k++) {
+ for (l = HF_ADJ; l < sbrGrid->envTimeBorder[0] + HF_ADJ; l++) {
+ psi->XBuf[l][k][0] = psi->XBufDelay[chBase + ch][l][k][0];
+ psi->XBuf[l][k][1] = psi->XBufDelay[chBase + ch][l][k][1];
+ }
+ }
+
+ /* step 3 - HF adjustment */
+ err = AdjustHighFreq(psi, sbrHdr, sbrGrid, sbrFreq, sbrChan, ch);
+ if (err) {
+ return err;
+ }
+
+ /* step 4 - synthesis QMF */
+ qmfsBands = sbrFreq->kStartPrev + sbrFreq->numQMFBandsPrev;
+ for (l = 0; l < sbrGrid->envTimeBorder[0]; l++) {
+ /* if new envelope starts mid-frame, use old settings until start of first envelope in this frame */
+ QMFSynthesis(psi->XBuf[l + HF_ADJ][0], psi->delayQMFS[chBase + ch], &(psi->delayIdxQMFS[chBase + ch]), qmfsBands, outptr, aacDecInfo->nChans);
+ outptr += 64 * aacDecInfo->nChans;
+ }
+
+ qmfsBands = sbrFreq->kStart + sbrFreq->numQMFBands;
+ for (; l < 32; l++) {
+ /* use new settings for rest of frame (usually the entire frame, unless the first envelope starts mid-frame) */
+ QMFSynthesis(psi->XBuf[l + HF_ADJ][0], psi->delayQMFS[chBase + ch], &(psi->delayIdxQMFS[chBase + ch]), qmfsBands, outptr, aacDecInfo->nChans);
+ outptr += 64 * aacDecInfo->nChans;
+ }
+ }
+
+ /* save delay */
+ for (l = 0; l < HF_GEN; l++) {
+ for (k = 0; k < 64; k++) {
+ psi->XBufDelay[chBase + ch][l][k][0] = psi->XBuf[l + 32][k][0];
+ psi->XBufDelay[chBase + ch][l][k][1] = psi->XBuf[l + 32][k][1];
+ }
+ }
+ sbrChan->gbMask[0] = sbrChan->gbMask[1];
+ sbrChan->gbMask[1] = 0;
+
+ if (sbrHdr->count > 0) {
+ sbrChan->reset = 0;
+ }
+ }
+ sbrFreq->kStartPrev = sbrFreq->kStart;
+ sbrFreq->numQMFBandsPrev = sbrFreq->numQMFBands;
+
+ if (aacDecInfo->nChans > 0 && (chBase + ch) == aacDecInfo->nChans) {
+ psi->frameCount++;
+ }
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: FlushCodecSBR
+ *
+ * Description: flush internal SBR codec state (after seeking, for example)
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: updated state variables for SBR
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: SBR is heavily dependent on state from previous frames
+ * (e.g. delta coded scalefactors, previous envelope boundaries, etc.)
+ * On flush, we reset everything as if SBR had just been initialized
+ * for the first time. This triggers "upsample-only" mode until
+ * the first valid SBR header is received. Then SBR starts as usual.
+ **************************************************************************************/
+int FlushCodecSBR(AACDecInfo *aacDecInfo)
+{
+ PSInfoSBR *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoSBR) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoSBR *)(aacDecInfo->psInfoSBR);
+
+ InitSBRState(psi);
+
+ return 0;
+}
diff --git a/audio_codec/libfaad/helixaac/sbr.h b/audio_codec/libfaad/helixaac/sbr.h
new file mode 100644
index 0000000..7d01905
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/sbr.h
@@ -0,0 +1,380 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbr.h,v 1.2 2005/05/20 18:05:41 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbr.h - definitions of platform-specific SBR data structures, functions, and tables
+ **************************************************************************************/
+
+#ifndef _SBR_H
+#define _SBR_H
+
+#include "aaccommon.h"
+#include "bitstream.h"
+#ifndef ASSERT
+#if defined(_WIN32) && defined(_M_IX86) && (defined (_DEBUG) || defined (REL_ENABLE_ASSERTS))
+#define ASSERT(x) if (!(x)) __asm int 3;
+#else
+#define ASSERT(x,errid) do{if(!(x)) {printk(" aac decoder error ,errid %d\n",(errid));return (errid);}}while(0)/* do nothing */
+#endif
+#endif
+
+#ifndef MAX
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+#ifndef MIN
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+#define NUM_TIME_SLOTS 16
+#define SAMPLES_PER_SLOT 2 /* RATE in spec */
+#define NUM_SAMPLE_RATES_SBR 9 /* downsampled (single-rate) mode unsupported, so only use Fs_sbr >= 16 kHz */
+
+#define MAX_NUM_ENV 5
+#define MAX_NUM_NOISE_FLOORS 2
+#define MAX_NUM_NOISE_FLOOR_BANDS 5 /* max Nq, see 4.6.18.3.6 */
+#define MAX_NUM_PATCHES 5
+#define MAX_NUM_SMOOTH_COEFS 5
+
+#define HF_GEN 8
+#define HF_ADJ 2
+
+#define MAX_QMF_BANDS 48 /* max QMF subbands covered by SBR (4.6.18.3.6) */
+
+#define FBITS_IN_QMFA 14
+#define FBITS_LOST_QMFA (1 + 2 + 3 + 2 + 1) /* 1 from cTab, 2 in premul, 3 in FFT, 2 in postmul, 1 for implicit scaling by 2.0 */
+#define FBITS_OUT_QMFA (FBITS_IN_QMFA - FBITS_LOST_QMFA)
+
+#define MIN_GBITS_IN_QMFS 2
+#define FBITS_IN_QMFS FBITS_OUT_QMFA
+#define FBITS_LOST_DCT4_64 (2 + 3 + 2) /* 2 in premul, 3 in FFT, 2 in postmul */
+
+#define FBITS_OUT_DQ_ENV 29 /* dequantized env scalefactors are Q(29 - envDataDequantScale) */
+#define FBITS_OUT_DQ_NOISE 24 /* range of Q_orig = [2^-24, 2^6] */
+#define NOISE_FLOOR_OFFSET 6
+
+/* see comments in ApplyBoost() */
+#define FBITS_GLIM_BOOST 24
+#define FBITS_QLIM_BOOST 14
+
+#define MAX_HUFF_BITS 20
+#define NUM_QMF_DELAY_BUFS 10
+#define DELAY_SAMPS_QMFA (NUM_QMF_DELAY_BUFS * 32)
+#define DELAY_SAMPS_QMFS (NUM_QMF_DELAY_BUFS * 128)
+
+/* additional external symbols to name-mangle for static linking */
+#define FFT32C STATNAME(FFT32C)
+#define CalcFreqTables STATNAME(CalcFreqTables)
+#define AdjustHighFreq STATNAME(AdjustHighFreq)
+#define GenerateHighFreq STATNAME(GenerateHighFreq)
+#define DecodeSBREnvelope STATNAME(DecodeSBREnvelope)
+#define DecodeSBRNoise STATNAME(DecodeSBRNoise)
+#define UncoupleSBREnvelope STATNAME(UncoupleSBREnvelope)
+#define UncoupleSBRNoise STATNAME(UncoupleSBRNoise)
+#define InvRNormalized STATNAME(InvRNormalized)
+#define RatioPowInv STATNAME(RatioPowInv)
+#define SqrtFix STATNAME(SqrtFix)
+#define QMFAnalysis STATNAME(QMFAnalysis)
+#define QMFSynthesis STATNAME(QMFSynthesis)
+#define GetSampRateIdx STATNAME(GetSampRateIdx)
+#define UnpackSBRHeader STATNAME(UnpackSBRHeader)
+#define UnpackSBRSingleChannel STATNAME(UnpackSBRSingleChannel)
+#define UnpackSBRChannelPair STATNAME(UnpackSBRChannelPair)
+
+/* asm functions */
+#define CVKernel1 STATNAME(CVKernel1)
+#define CVKernel2 STATNAME(CVKernel2)
+#define QMFAnalysisConv STATNAME(QMFAnalysisConv)
+#define QMFSynthesisConv STATNAME(QMFSynthesisConv)
+
+#define k0Tab STATNAME(k0Tab)
+#define k2Tab STATNAME(k2Tab)
+#define goalSBTab STATNAME(goalSBTab)
+#define huffTabSBR STATNAME(huffTabSBR)
+#define huffTabSBRInfo STATNAME(huffTabSBRInfo)
+#define log2Tab STATNAME(log2Tab)
+#define noiseTab STATNAME(noiseTab)
+#define cTabA STATNAME(cTabA)
+#define cTabS STATNAME(cTabS)
+
+/* do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) */
+#define CLIP_2N_SHIFT30(y, n) { \
+ int sign = (y) >> 31; \
+ if (sign != (y) >> (30 - (n))) { \
+ (y) = sign ^ (0x3fffffff); \
+ } else { \
+ (y) = (y) << (n); \
+ } \
+}
+
+#define CLIP_2N(y, n) { \
+ int sign = (y) >> 31; \
+ if (sign != ((y) >> (n))) { \
+ (y) = sign ^ ((1 << (n)) - 1); \
+ } \
+}
+
+enum {
+ SBR_GRID_FIXFIX = 0,
+ SBR_GRID_FIXVAR = 1,
+ SBR_GRID_VARFIX = 2,
+ SBR_GRID_VARVAR = 3
+};
+
+enum {
+ HuffTabSBR_tEnv15 = 0,
+ HuffTabSBR_fEnv15 = 1,
+ HuffTabSBR_tEnv15b = 2,
+ HuffTabSBR_fEnv15b = 3,
+ HuffTabSBR_tEnv30 = 4,
+ HuffTabSBR_fEnv30 = 5,
+ HuffTabSBR_tEnv30b = 6,
+ HuffTabSBR_fEnv30b = 7,
+ HuffTabSBR_tNoise30 = 8,
+ HuffTabSBR_fNoise30 = 5,
+ HuffTabSBR_tNoise30b = 9,
+ HuffTabSBR_fNoise30b = 7
+};
+
+typedef struct _HuffInfo {
+ int maxBits; /* number of bits in longest codeword */
+ unsigned char count[MAX_HUFF_BITS]; /* count[i] = number of codes with length i+1 bits */
+ int offset; /* offset into symbol table */
+} HuffInfo;
+
+/* need one SBRHeader per element (SCE/CPE), updated only on new header */
+typedef struct _SBRHeader {
+ int count;
+
+ unsigned char ampRes;
+ unsigned char startFreq;
+ unsigned char stopFreq;
+ unsigned char crossOverBand;
+ unsigned char resBitsHdr;
+ unsigned char hdrExtra1;
+ unsigned char hdrExtra2;
+
+ unsigned char freqScale;
+ unsigned char alterScale;
+ unsigned char noiseBands;
+
+ unsigned char limiterBands;
+ unsigned char limiterGains;
+ unsigned char interpFreq;
+ unsigned char smoothMode;
+} SBRHeader;
+
+/* need one SBRGrid per channel, updated every frame */
+typedef struct _SBRGrid {
+ unsigned char frameClass;
+ unsigned char ampResFrame;
+ unsigned char pointer;
+
+ unsigned char numEnv; /* L_E */
+ unsigned char envTimeBorder[MAX_NUM_ENV + 1]; /* t_E */
+ unsigned char freqRes[MAX_NUM_ENV]; /* r */
+
+ unsigned char numNoiseFloors; /* L_Q */
+ unsigned char noiseTimeBorder[MAX_NUM_NOISE_FLOORS + 1]; /* t_Q */
+
+ unsigned char numEnvPrev;
+ unsigned char numNoiseFloorsPrev;
+ unsigned char freqResPrev;
+} SBRGrid;
+
+/* need one SBRFreq per element (SCE/CPE/LFE), updated only on header reset */
+typedef struct _SBRFreq {
+ int kStart; /* k_x */
+ int nMaster;
+ int nHigh;
+ int nLow;
+ int nLimiter; /* N_l */
+ int numQMFBands; /* M */
+ int numNoiseFloorBands; /* Nq */
+
+ int kStartPrev;
+ int numQMFBandsPrev;
+
+ unsigned char freqMaster[MAX_QMF_BANDS + 1]; /* not necessary to save this after derived tables are generated */
+ unsigned char freqHigh[MAX_QMF_BANDS + 1];
+ unsigned char freqLow[MAX_QMF_BANDS / 2 + 1]; /* nLow = nHigh - (nHigh >> 1) */
+ unsigned char freqNoise[MAX_NUM_NOISE_FLOOR_BANDS + 1];
+ unsigned char freqLimiter[MAX_QMF_BANDS / 2 + MAX_NUM_PATCHES]; /* max (intermediate) size = nLow + numPatches - 1 */
+
+ unsigned char numPatches;
+ unsigned char patchNumSubbands[MAX_NUM_PATCHES + 1];
+ unsigned char patchStartSubband[MAX_NUM_PATCHES + 1];
+} SBRFreq;
+
+typedef struct _SBRChan {
+ int reset;
+ unsigned char deltaFlagEnv[MAX_NUM_ENV];
+ unsigned char deltaFlagNoise[MAX_NUM_NOISE_FLOORS];
+
+ signed char envDataQuant[MAX_NUM_ENV][MAX_QMF_BANDS]; /* range = [0, 127] */
+ signed char noiseDataQuant[MAX_NUM_NOISE_FLOORS][MAX_NUM_NOISE_FLOOR_BANDS];
+
+ unsigned char invfMode[2][MAX_NUM_NOISE_FLOOR_BANDS]; /* invfMode[0/1][band] = prev/curr */
+ int chirpFact[MAX_NUM_NOISE_FLOOR_BANDS]; /* bwArray */
+ unsigned char addHarmonicFlag[2]; /* addHarmonicFlag[0/1] = prev/curr */
+ unsigned char addHarmonic[2][64]; /* addHarmonic[0/1][band] = prev/curr */
+
+ int gbMask[2]; /* gbMask[0/1] = XBuf[0-31]/XBuf[32-39] */
+ signed char laPrev;
+
+ int noiseTabIndex;
+ int sinIndex;
+ int gainNoiseIndex;
+ int gTemp[MAX_NUM_SMOOTH_COEFS][MAX_QMF_BANDS];
+ int qTemp[MAX_NUM_SMOOTH_COEFS][MAX_QMF_BANDS];
+
+} SBRChan;
+
+typedef struct _PSInfoSBR {
+ /* save for entire file */
+ int frameCount;
+ int sampRateIdx;
+
+ /* state info that must be saved for each channel */
+ SBRHeader sbrHdr[AAC_MAX_NCHANS];
+ SBRGrid sbrGrid[AAC_MAX_NCHANS];
+ SBRFreq sbrFreq[AAC_MAX_NCHANS];
+ SBRChan sbrChan[AAC_MAX_NCHANS];
+
+ /* temp variables, no need to save between blocks */
+ unsigned char dataExtra;
+ unsigned char resBitsData;
+ unsigned char extendedDataPresent;
+ int extendedDataSize;
+
+ signed char envDataDequantScale[MAX_NCHANS_ELEM][MAX_NUM_ENV];
+ int envDataDequant[MAX_NCHANS_ELEM][MAX_NUM_ENV][MAX_QMF_BANDS];
+ int noiseDataDequant[MAX_NCHANS_ELEM][MAX_NUM_NOISE_FLOORS][MAX_NUM_NOISE_FLOOR_BANDS];
+
+ int eCurr[MAX_QMF_BANDS];
+ unsigned char eCurrExp[MAX_QMF_BANDS];
+ unsigned char eCurrExpMax;
+ signed char la;
+
+ int crcCheckWord;
+ int couplingFlag;
+ int envBand;
+ int eOMGainMax;
+ int gainMax;
+ int gainMaxFBits;
+ int noiseFloorBand;
+ int qp1Inv;
+ int qqp1Inv;
+ int sMapped;
+ int sBand;
+ int highBand;
+
+ int sumEOrigMapped;
+ int sumECurrGLim;
+ int sumSM;
+ int sumQM;
+ int gLimBoost[MAX_QMF_BANDS];
+ int qmLimBoost[MAX_QMF_BANDS];
+ int smBoost[MAX_QMF_BANDS];
+
+ int smBuf[MAX_QMF_BANDS];
+ int qmLimBuf[MAX_QMF_BANDS];
+ int gLimBuf[MAX_QMF_BANDS];
+ int gLimFbits[MAX_QMF_BANDS];
+
+ int gFiltLast[MAX_QMF_BANDS];
+ int qFiltLast[MAX_QMF_BANDS];
+
+ /* large buffers */
+ int delayIdxQMFA[AAC_MAX_NCHANS];
+ int delayQMFA[AAC_MAX_NCHANS][DELAY_SAMPS_QMFA];
+ int delayIdxQMFS[AAC_MAX_NCHANS];
+ int delayQMFS[AAC_MAX_NCHANS][DELAY_SAMPS_QMFS];
+ int XBufDelay[AAC_MAX_NCHANS][HF_GEN][64][2];
+ int XBuf[32 + 8][64][2];
+
+} PSInfoSBR;
+
+/* sbrfft.c */
+void FFT32C(int *x);
+
+/* sbrfreq.c */
+int CalcFreqTables(SBRHeader *sbrHdr, SBRFreq *sbrFreq, int sampRateIdx);
+
+/* sbrhfadj.c */
+int AdjustHighFreq(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch);
+
+/* sbrhfgen.c */
+int GenerateHighFreq(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch);
+
+/* sbrhuff.c */
+int DecodeSBREnvelope(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch);
+int DecodeSBRNoise(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch);
+void UncoupleSBREnvelope(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR);
+void UncoupleSBRNoise(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR);
+
+/* sbrmath.c */
+int InvRNormalized(int r);
+int RatioPowInv(int a, int b, int c);
+int SqrtFix(int x, int fBitsIn, int *fBitsOut);
+
+/* sbrqmf.c */
+int QMFAnalysis(int *inbuf, int *delay, int *XBuf, int fBitsIn, int *delayIdx, int qmfaBands);
+void QMFSynthesis(int *inbuf, int *delay, int *delayIdx, int qmfsBands, short *outbuf, int nChans);
+
+/* sbrside.c */
+int GetSampRateIdx(int sampRate);
+int UnpackSBRHeader(BitStreamInfo *bsi, SBRHeader *sbrHdr);
+int UnpackSBRSingleChannel(BitStreamInfo *bsi, PSInfoSBR *psi, int chOut);
+int UnpackSBRChannelPair(BitStreamInfo *bsi, PSInfoSBR *psi, int chOut);
+
+/* sbrtabs.c */
+extern const unsigned char k0Tab[NUM_SAMPLE_RATES_SBR][16];
+extern const unsigned char k2Tab[NUM_SAMPLE_RATES_SBR][14];
+extern const unsigned char goalSBTab[NUM_SAMPLE_RATES_SBR];
+extern const HuffInfo huffTabSBRInfo[10];
+extern const signed short huffTabSBR[604];
+extern const int log2Tab[65];
+extern const int noiseTab[512 * 2];
+extern const int cTabA[165];
+extern const int cTabS[640];
+
+#endif /* _SBR_H */
diff --git a/audio_codec/libfaad/helixaac/sbrfft.c b/audio_codec/libfaad/helixaac/sbrfft.c
new file mode 100644
index 0000000..2f74fc5
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/sbrfft.c
@@ -0,0 +1,368 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrfft.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * sbrfft.c - optimized FFT for SBR QMF filters
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+#define SQRT1_2 0x5a82799a
+
+/* swap RE{p0} with RE{p1} and IM{P0} with IM{P1} */
+#define swapcplx(p0,p1) \
+ t = p0; t1 = *(&(p0)+1); p0 = p1; *(&(p0)+1) = *(&(p1)+1); p1 = t; *(&(p1)+1) = t1
+
+/* nfft = 32, hard coded since small, fixed size FFT
+static const unsigned char bitrevtab32[9] = {
+ 0x01, 0x04, 0x03, 0x06, 0x00, 0x02, 0x05, 0x07, 0x00,
+};
+*/
+
+/* twiddle table for radix 4 pass, format = Q31 */
+static const int twidTabOdd32[8 * 6] = {
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x539eba45, 0xe7821d59,
+ 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59,
+ 0x539eba45, 0xc4df2862, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x22a2f4f8, 0xc4df2862,
+ 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862,
+ 0xac6145bb, 0x187de2a7, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52,
+};
+
+/**************************************************************************************
+ * Function: BitReverse32
+ *
+ * Description: Ken's fast in-place bit reverse
+ *
+ * Inputs: buffer of 32 complex samples
+ *
+ * Outputs: bit-reversed samples in same buffer
+ *
+ * Return: none
+**************************************************************************************/
+static void BitReverse32(int *inout)
+{
+ int t, t1;
+
+ swapcplx(inout[2], inout[32]);
+ swapcplx(inout[4], inout[16]);
+ swapcplx(inout[6], inout[48]);
+ swapcplx(inout[10], inout[40]);
+ swapcplx(inout[12], inout[24]);
+ swapcplx(inout[14], inout[56]);
+ swapcplx(inout[18], inout[36]);
+ swapcplx(inout[22], inout[52]);
+ swapcplx(inout[26], inout[44]);
+ swapcplx(inout[30], inout[60]);
+ swapcplx(inout[38], inout[50]);
+ swapcplx(inout[46], inout[58]);
+}
+
+/**************************************************************************************
+ * Function: R8FirstPass32
+ *
+ * Description: radix-8 trivial pass for decimation-in-time FFT (log2(N) = 5)
+ *
+ * Inputs: buffer of (bit-reversed) samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 3 guard bits, gains 1 integer bit
+ * guard bits out = guard bits in - 3 (if inputs are full scale)
+ * or guard bits in - 2 (if inputs bounded to +/- sqrt(2)/2)
+ * see scaling comments in fft.c for base AAC
+ * should compile with no stack spills on ARM (verify compiled output)
+ * current instruction count (per pass): 16 LDR, 16 STR, 4 SMULL, 61 ALU
+ **************************************************************************************/
+static void R8FirstPass32(int *r0)
+{
+ int r1, r2, r3, r4, r5, r6, r7;
+ int r8, r9, r10, r11, r12, r14;
+
+ /* number of passes = fft size / 8 = 32 / 8 = 4 */
+ r1 = (32 >> 3);
+ do {
+
+ r2 = r0[8];
+ r3 = r0[9];
+ r4 = r0[10];
+ r5 = r0[11];
+ r6 = r0[12];
+ r7 = r0[13];
+ r8 = r0[14];
+ r9 = r0[15];
+
+ r10 = r2 + r4;
+ r11 = r3 + r5;
+ r12 = r6 + r8;
+ r14 = r7 + r9;
+
+ r2 -= r4;
+ r3 -= r5;
+ r6 -= r8;
+ r7 -= r9;
+
+ r4 = r2 - r7;
+ r5 = r2 + r7;
+ r8 = r3 - r6;
+ r9 = r3 + r6;
+
+ r2 = r4 - r9;
+ r3 = r4 + r9;
+ r6 = r5 - r8;
+ r7 = r5 + r8;
+
+ r2 = MULSHIFT32(SQRT1_2, r2); /* can use r4, r5, r8, or r9 for constant and lo32 scratch reg */
+ r3 = MULSHIFT32(SQRT1_2, r3);
+ r6 = MULSHIFT32(SQRT1_2, r6);
+ r7 = MULSHIFT32(SQRT1_2, r7);
+
+ r4 = r10 + r12;
+ r5 = r10 - r12;
+ r8 = r11 + r14;
+ r9 = r11 - r14;
+
+ r10 = r0[0];
+ r11 = r0[2];
+ r12 = r0[4];
+ r14 = r0[6];
+
+ r10 += r11;
+ r12 += r14;
+
+ r4 >>= 1;
+ r10 += r12;
+ r4 += (r10 >> 1);
+ r0[ 0] = r4;
+ r4 -= (r10 >> 1);
+ r4 = (r10 >> 1) - r4;
+ r0[ 8] = r4;
+
+ r9 >>= 1;
+ r10 -= 2 * r12;
+ r4 = (r10 >> 1) + r9;
+ r0[ 4] = r4;
+ r4 = (r10 >> 1) - r9;
+ r0[12] = r4;
+ r10 += r12;
+
+ r10 -= 2 * r11;
+ r12 -= 2 * r14;
+
+ r4 = r0[1];
+ r9 = r0[3];
+ r11 = r0[5];
+ r14 = r0[7];
+
+ r4 += r9;
+ r11 += r14;
+
+ r8 >>= 1;
+ r4 += r11;
+ r8 += (r4 >> 1);
+ r0[ 1] = r8;
+ r8 -= (r4 >> 1);
+ r8 = (r4 >> 1) - r8;
+ r0[ 9] = r8;
+
+ r5 >>= 1;
+ r4 -= 2 * r11;
+ r8 = (r4 >> 1) - r5;
+ r0[ 5] = r8;
+ r8 = (r4 >> 1) + r5;
+ r0[13] = r8;
+ r4 += r11;
+
+ r4 -= 2 * r9;
+ r11 -= 2 * r14;
+
+ r9 = r10 - r11;
+ r10 += r11;
+ r14 = r4 + r12;
+ r4 -= r12;
+
+ r5 = (r10 >> 1) + r7;
+ r8 = (r4 >> 1) - r6;
+ r0[ 2] = r5;
+ r0[ 3] = r8;
+
+ r5 = (r9 >> 1) - r2;
+ r8 = (r14 >> 1) - r3;
+ r0[ 6] = r5;
+ r0[ 7] = r8;
+
+ r5 = (r10 >> 1) - r7;
+ r8 = (r4 >> 1) + r6;
+ r0[10] = r5;
+ r0[11] = r8;
+
+ r5 = (r9 >> 1) + r2;
+ r8 = (r14 >> 1) + r3;
+ r0[14] = r5;
+ r0[15] = r8;
+
+ r0 += 16;
+ r1--;
+ } while (r1 != 0);
+}
+
+/**************************************************************************************
+ * Function: R4Core32
+ *
+ * Description: radix-4 pass for 32-point decimation-in-time FFT
+ *
+ * Inputs: buffer of samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: gain 2 integer bits
+ * guard bits out = guard bits in - 1 (if inputs are full scale)
+ * see scaling comments in fft.c for base AAC
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ * should compile with no stack spills on ARM (verify compiled output)
+ * current instruction count (per pass): 16 LDR, 16 STR, 4 SMULL, 61 ALU
+ **************************************************************************************/
+static void R4Core32(int *r0)
+{
+ int r2, r3, r4, r5, r6, r7;
+ int r8, r9, r10, r12, r14;
+ int *r1;
+
+ r1 = (int *)twidTabOdd32;
+ r10 = 8;
+ do {
+ /* can use r14 for lo32 scratch register in all MULSHIFT32 */
+ r2 = r1[0];
+ r3 = r1[1];
+ r4 = r0[16];
+ r5 = r0[17];
+ r12 = r4 + r5;
+ r12 = MULSHIFT32(r3, r12);
+ r5 = MULSHIFT32(r2, r5) + r12;
+ r2 += 2 * r3;
+ r4 = MULSHIFT32(r2, r4) - r12;
+
+ r2 = r1[2];
+ r3 = r1[3];
+ r6 = r0[32];
+ r7 = r0[33];
+ r12 = r6 + r7;
+ r12 = MULSHIFT32(r3, r12);
+ r7 = MULSHIFT32(r2, r7) + r12;
+ r2 += 2 * r3;
+ r6 = MULSHIFT32(r2, r6) - r12;
+
+ r2 = r1[4];
+ r3 = r1[5];
+ r8 = r0[48];
+ r9 = r0[49];
+ r12 = r8 + r9;
+ r12 = MULSHIFT32(r3, r12);
+ r9 = MULSHIFT32(r2, r9) + r12;
+ r2 += 2 * r3;
+ r8 = MULSHIFT32(r2, r8) - r12;
+
+ r2 = r0[0];
+ r3 = r0[1];
+
+ r12 = r6 + r8;
+ r8 = r6 - r8;
+ r14 = r9 - r7;
+ r9 = r9 + r7;
+
+ r6 = (r2 >> 2) - r4;
+ r7 = (r3 >> 2) - r5;
+ r4 += (r2 >> 2);
+ r5 += (r3 >> 2);
+
+ r2 = r4 + r12;
+ r3 = r5 + r9;
+ r0[0] = r2;
+ r0[1] = r3;
+ r2 = r6 - r14;
+ r3 = r7 - r8;
+ r0[16] = r2;
+ r0[17] = r3;
+ r2 = r4 - r12;
+ r3 = r5 - r9;
+ r0[32] = r2;
+ r0[33] = r3;
+ r2 = r6 + r14;
+ r3 = r7 + r8;
+ r0[48] = r2;
+ r0[49] = r3;
+
+ r0 += 2;
+ r1 += 6;
+ r10--;
+ } while (r10 != 0);
+}
+
+/**************************************************************************************
+ * Function: FFT32C
+ *
+ * Description: Ken's very fast in-place radix-4 decimation-in-time FFT
+ *
+ * Inputs: buffer of 32 complex samples (before bit-reversal)
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 3 guard bits in, gains 3 integer bits
+ * guard bits out = guard bits in - 2
+ * (guard bit analysis includes assumptions about steps immediately
+ * before and after, i.e. PreMul and PostMul for DCT)
+ **************************************************************************************/
+void FFT32C(int *x)
+{
+ /* decimation in time */
+ BitReverse32(x);
+
+ /* 32-point complex FFT */
+ R8FirstPass32(x); /* gain 1 int bit, lose 2 GB (making assumptions about input) */
+ R4Core32(x); /* gain 2 int bits, lose 0 GB (making assumptions about input) */
+}
diff --git a/audio_codec/libfaad/helixaac/sbrfreq.c b/audio_codec/libfaad/helixaac/sbrfreq.c
new file mode 100644
index 0000000..5d4b331
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/sbrfreq.c
@@ -0,0 +1,673 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrfreq.c,v 1.2 2005/05/20 18:05:41 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrfreq.c - frequency band table calculation for SBR
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+/**************************************************************************************
+ * Function: BubbleSort
+ *
+ * Description: in-place sort of unsigned chars
+ *
+ * Inputs: buffer of elements to sort
+ * number of elements to sort
+ *
+ * Outputs: sorted buffer
+ *
+ * Return: none
+ **************************************************************************************/
+static void BubbleSort(unsigned char *v, int nItems)
+{
+ int i;
+ unsigned char t;
+
+ while (nItems >= 2) {
+ for (i = 0; i < nItems - 1; i++) {
+ if (v[i + 1] < v[i]) {
+ t = v[i + 1];
+ v[i + 1] = v[i];
+ v[i] = t;
+ }
+ }
+ nItems--;
+ }
+}
+
+/**************************************************************************************
+ * Function: VMin
+ *
+ * Description: find smallest element in a buffer of unsigned chars
+ *
+ * Inputs: buffer of elements to search
+ * number of elements to search
+ *
+ * Outputs: none
+ *
+ * Return: smallest element in buffer
+ **************************************************************************************/
+static unsigned char VMin(unsigned char *v, int nItems)
+{
+ int i;
+ unsigned char vMin;
+
+ vMin = v[0];
+ for (i = 1; i < nItems; i++) {
+ if (v[i] < vMin) {
+ vMin = v[i];
+ }
+ }
+ return vMin;
+}
+
+/**************************************************************************************
+ * Function: VMax
+ *
+ * Description: find largest element in a buffer of unsigned chars
+ *
+ * Inputs: buffer of elements to search
+ * number of elements to search
+ *
+ * Outputs: none
+ *
+ * Return: largest element in buffer
+ **************************************************************************************/
+static unsigned char VMax(unsigned char *v, int nItems)
+{
+ int i;
+ unsigned char vMax;
+
+ vMax = v[0];
+ for (i = 1; i < nItems; i++) {
+ if (v[i] > vMax) {
+ vMax = v[i];
+ }
+ }
+ return vMax;
+}
+
+/**************************************************************************************
+ * Function: CalcFreqMasterScaleZero
+ *
+ * Description: calculate master frequency table when freqScale == 0
+ * (4.6.18.3.2.1, figure 4.39)
+ *
+ * Inputs: alterScale flag
+ * index of first QMF subband in master freq table (k0)
+ * index of last QMF subband (k2)
+ *
+ * Outputs: master frequency table
+ *
+ * Return: number of bands in master frequency table
+ *
+ * Notes: assumes k2 - k0 <= 48 and k2 >= k0 (4.6.18.3.6)
+ **************************************************************************************/
+static int CalcFreqMasterScaleZero(unsigned char *freqMaster, int alterScale, int k0, int k2)
+{
+ int nMaster, k, nBands, k2Achieved, dk, vDk[64], k2Diff;
+
+ if (alterScale) {
+ dk = 2;
+ nBands = 2 * ((k2 - k0 + 2) >> 2);
+ } else {
+ dk = 1;
+ nBands = 2 * ((k2 - k0) >> 1);
+ }
+
+ if (nBands <= 0) {
+ return 0;
+ }
+
+ k2Achieved = k0 + nBands * dk;
+ k2Diff = k2 - k2Achieved;
+ for (k = 0; k < nBands; k++) {
+ vDk[k] = dk;
+ }
+
+ if (k2Diff > 0) {
+ k = nBands - 1;
+ while (k2Diff) {
+ vDk[k]++;
+ k--;
+ k2Diff--;
+ }
+ } else if (k2Diff < 0) {
+ k = 0;
+ while (k2Diff) {
+ vDk[k]--;
+ k++;
+ k2Diff++;
+ }
+ }
+
+ nMaster = nBands;
+ freqMaster[0] = k0;
+ for (k = 1; k <= nBands; k++) {
+ freqMaster[k] = freqMaster[k - 1] + vDk[k - 1];
+ }
+
+ return nMaster;
+}
+
+/* mBandTab[i] = temp1[i] / 2 */
+static const int mBandTab[3] = {6, 5, 4};
+
+/* invWarpTab[i] = 1.0 / temp2[i], Q30 (see 4.6.18.3.2.1) */
+static const int invWarpTab[2] = {0x40000000, 0x313b13b1};
+
+/**************************************************************************************
+ * Function: CalcFreqMasterScale
+ *
+ * Description: calculate master frequency table when freqScale > 0
+ * (4.6.18.3.2.1, figure 4.39)
+ *
+ * Inputs: alterScale flag
+ * freqScale flag
+ * index of first QMF subband in master freq table (k0)
+ * index of last QMF subband (k2)
+ *
+ * Outputs: master frequency table
+ *
+ * Return: number of bands in master frequency table
+ *
+ * Notes: assumes k2 - k0 <= 48 and k2 >= k0 (4.6.18.3.6)
+ **************************************************************************************/
+static int CalcFreqMaster(unsigned char *freqMaster, int freqScale, int alterScale, int k0, int k2)
+{
+ int bands, twoRegions, k, k1, t, vLast, vCurr, pCurr;
+ int invWarp, nBands0, nBands1, change;
+ unsigned char vDk1Min, vDk0Max;
+ unsigned char *vDelta;
+
+ if (freqScale < 1 || freqScale > 3) {
+ return -1;
+ }
+
+ bands = mBandTab[freqScale - 1];
+ invWarp = invWarpTab[alterScale];
+
+ /* tested for all k0 = [5, 64], k2 = [k0, 64] */
+ if (k2 * 10000 > 22449 * k0) {
+ twoRegions = 1;
+ k1 = 2 * k0;
+ } else {
+ twoRegions = 0;
+ k1 = k2;
+ }
+
+ /* tested for all k0 = [5, 64], k1 = [k0, 64], freqScale = [1,3] */
+ t = (log2Tab[k1] - log2Tab[k0]) >> 3; /* log2(k1/k0), Q28 to Q25 */
+ nBands0 = 2 * (((bands * t) + (1 << 24)) >> 25); /* multiply by bands/2, round to nearest int (mBandTab has factor of 1/2 rolled in) */
+
+ /* tested for all valid combinations of k0, k1, nBands (from sampRate, freqScale, alterScale)
+ * roundoff error can be a problem with fixpt (e.g. pCurr = 12.499999 instead of 12.50003)
+ * because successive multiplication always undershoots a little bit, but this
+ * doesn't occur in any of the ratios we encounter from the valid k0/k1 bands in the spec
+ */
+ t = RatioPowInv(k1, k0, nBands0);
+ pCurr = k0 << 24;
+ vLast = k0;
+ vDelta = freqMaster + 1; /* operate in-place */
+ for (k = 0; k < nBands0; k++) {
+ pCurr = MULSHIFT32(pCurr, t) << 8; /* keep in Q24 */
+ vCurr = (pCurr + (1 << 23)) >> 24;
+ vDelta[k] = (vCurr - vLast);
+ vLast = vCurr;
+ }
+
+ /* sort the deltas and find max delta for first region */
+ BubbleSort(vDelta, nBands0);
+ vDk0Max = VMax(vDelta, nBands0);
+
+ /* fill master frequency table with bands from first region */
+ freqMaster[0] = k0;
+ for (k = 1; k <= nBands0; k++) {
+ freqMaster[k] += freqMaster[k - 1];
+ }
+
+ /* if only one region, then the table is complete */
+ if (!twoRegions) {
+ return nBands0;
+ }
+
+ /* tested for all k1 = [10, 64], k2 = [k0, 64], freqScale = [1,3] */
+ t = (log2Tab[k2] - log2Tab[k1]) >> 3; /* log2(k1/k0), Q28 to Q25 */
+ t = MULSHIFT32(bands * t, invWarp) << 2; /* multiply by bands/2, divide by warp factor, keep Q25 */
+ nBands1 = 2 * ((t + (1 << 24)) >> 25); /* round to nearest int */
+
+ /* see comments above for calculations in first region */
+ t = RatioPowInv(k2, k1, nBands1);
+ pCurr = k1 << 24;
+ vLast = k1;
+ vDelta = freqMaster + nBands0 + 1; /* operate in-place */
+ for (k = 0; k < nBands1; k++) {
+ pCurr = MULSHIFT32(pCurr, t) << 8; /* keep in Q24 */
+ vCurr = (pCurr + (1 << 23)) >> 24;
+ vDelta[k] = (vCurr - vLast);
+ vLast = vCurr;
+ }
+
+ /* sort the deltas, adjusting first and last if the second region has smaller deltas than the first */
+ vDk1Min = VMin(vDelta, nBands1);
+ if (vDk1Min < vDk0Max) {
+ BubbleSort(vDelta, nBands1);
+ change = vDk0Max - vDelta[0];
+ if (change > ((vDelta[nBands1 - 1] - vDelta[0]) >> 1)) {
+ change = ((vDelta[nBands1 - 1] - vDelta[0]) >> 1);
+ }
+ vDelta[0] += change;
+ vDelta[nBands1 - 1] -= change;
+ }
+ BubbleSort(vDelta, nBands1);
+
+ /* fill master frequency table with bands from second region
+ * Note: freqMaster[nBands0] = k1
+ */
+ for (k = 1; k <= nBands1; k++) {
+ freqMaster[k + nBands0] += freqMaster[k + nBands0 - 1];
+ }
+
+ return (nBands0 + nBands1);
+}
+
+/**************************************************************************************
+ * Function: CalcFreqHigh
+ *
+ * Description: calculate high resolution frequency table (4.6.18.3.2.2)
+ *
+ * Inputs: master frequency table
+ * number of bands in master frequency table
+ * crossover band from header
+ *
+ * Outputs: high resolution frequency table
+ *
+ * Return: number of bands in high resolution frequency table
+ **************************************************************************************/
+static int CalcFreqHigh(unsigned char *freqHigh, unsigned char *freqMaster, int nMaster, int crossOverBand)
+{
+ int k, nHigh;
+
+ nHigh = nMaster - crossOverBand;
+
+ for (k = 0; k <= nHigh; k++) {
+ freqHigh[k] = freqMaster[k + crossOverBand];
+ }
+
+ return nHigh;
+}
+
+/**************************************************************************************
+ * Function: CalcFreqLow
+ *
+ * Description: calculate low resolution frequency table (4.6.18.3.2.2)
+ *
+ * Inputs: high resolution frequency table
+ * number of bands in high resolution frequency table
+ *
+ * Outputs: low resolution frequency table
+ *
+ * Return: number of bands in low resolution frequency table
+ **************************************************************************************/
+static int CalcFreqLow(unsigned char *freqLow, unsigned char *freqHigh, int nHigh)
+{
+ int k, nLow, oddFlag;
+
+ nLow = nHigh - (nHigh >> 1);
+ freqLow[0] = freqHigh[0];
+ oddFlag = nHigh & 0x01;
+
+ for (k = 1; k <= nLow; k++) {
+ freqLow[k] = freqHigh[2 * k - oddFlag];
+ }
+
+ return nLow;
+}
+
+/**************************************************************************************
+ * Function: CalcFreqNoise
+ *
+ * Description: calculate noise floor frequency table (4.6.18.3.2.2)
+ *
+ * Inputs: low resolution frequency table
+ * number of bands in low resolution frequency table
+ * index of starting QMF subband for SBR (kStart)
+ * index of last QMF subband (k2)
+ * number of noise bands
+ *
+ * Outputs: noise floor frequency table
+ *
+ * Return: number of bands in noise floor frequency table
+ **************************************************************************************/
+static int CalcFreqNoise(unsigned char *freqNoise, unsigned char *freqLow, int nLow, int kStart, int k2, int noiseBands, int *err)
+{
+ int i, iLast, k, nQ, lTop, lBottom;
+
+ lTop = log2Tab[k2];
+ lBottom = log2Tab[kStart];
+ nQ = noiseBands * ((lTop - lBottom) >> 2); /* Q28 to Q26, noiseBands = [0,3] */
+ nQ = (nQ + (1 << 25)) >> 26;
+ if (nQ < 1) {
+ nQ = 1;
+ }
+
+ if (!(nQ <= MAX_NUM_NOISE_FLOOR_BANDS)) { /* required from 4.6.18.3.6 */
+ *err = ERR_AAC_SPEC_NOT_MATCH;
+ return ERR_AAC_SPEC_NOT_MATCH;
+ }
+
+ iLast = 0;
+ freqNoise[0] = freqLow[0];
+ for (k = 1; k <= nQ; k++) {
+ i = iLast + (nLow - iLast) / (nQ + 1 - k); /* truncating division */
+ freqNoise[k] = freqLow[i];
+ iLast = i;
+ }
+
+ return nQ;
+}
+
+/**************************************************************************************
+ * Function: BuildPatches
+ *
+ * Description: build high frequency patches (4.6.18.6.3)
+ *
+ * Inputs: master frequency table
+ * number of bands in low resolution frequency table
+ * index of first QMF subband in master freq table (k0)
+ * index of starting QMF subband for SBR (kStart)
+ * number of QMF bands in high resolution frequency table
+ * sample rate index
+ *
+ * Outputs: starting subband for each patch
+ * number of subbands in each patch
+ *
+ * Return: number of patches
+ **************************************************************************************/
+static int BuildPatches(unsigned char *patchNumSubbands, unsigned char *patchStartSubband, unsigned char *freqMaster,
+ int nMaster, int k0, int kStart, int numQMFBands, int sampRateIdx)
+{
+ int i, j, k;
+ int msb, sb, usb, numPatches, goalSB, oddFlag;
+
+ msb = k0;
+ usb = kStart;
+ numPatches = 0;
+ goalSB = goalSBTab[sampRateIdx];
+
+ if (nMaster == 0) {
+ patchNumSubbands[0] = 0;
+ patchStartSubband[0] = 0;
+ return 0;
+ }
+
+ if (goalSB < kStart + numQMFBands) {
+ k = 0;
+ for (i = 0; freqMaster[i] < goalSB; i++) {
+ k = i + 1;
+ }
+ } else {
+ k = nMaster;
+ }
+
+ do {
+ j = k + 1;
+ do {
+ j--;
+ sb = freqMaster[j];
+ oddFlag = (sb - 2 + k0) & 0x01;
+ } while (sb > k0 - 1 + msb - oddFlag);
+
+ patchNumSubbands[numPatches] = MAX(sb - usb, 0);
+ patchStartSubband[numPatches] = k0 - oddFlag - patchNumSubbands[numPatches];
+
+ /* from MPEG reference code - slightly different from spec */
+ if ((patchNumSubbands[numPatches] < 3) && (numPatches > 0)) {
+ break;
+ }
+
+ if (patchNumSubbands[numPatches] > 0) {
+ usb = sb;
+ msb = sb;
+ numPatches++;
+ } else {
+ msb = kStart;
+ }
+
+ if (freqMaster[k] - sb < 3) {
+ k = nMaster;
+ }
+
+ } while (sb != (kStart + numQMFBands) && numPatches <= MAX_NUM_PATCHES);
+
+ return numPatches;
+}
+
+/**************************************************************************************
+ * Function: FindFreq
+ *
+ * Description: search buffer of unsigned chars for a specific value
+ *
+ * Inputs: buffer of elements to search
+ * number of elements to search
+ * value to search for
+ *
+ * Outputs: none
+ *
+ * Return: non-zero if the value is found anywhere in the buffer, zero otherwise
+ **************************************************************************************/
+static int FindFreq(unsigned char *freq, int nFreq, unsigned char val)
+{
+ int k;
+
+ for (k = 0; k < nFreq; k++) {
+ if (freq[k] == val) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: RemoveFreq
+ *
+ * Description: remove one element from a buffer of unsigned chars
+ *
+ * Inputs: buffer of elements
+ * number of elements
+ * index of element to remove
+ *
+ * Outputs: new buffer of length nFreq-1
+ *
+ * Return: none
+ **************************************************************************************/
+static void RemoveFreq(unsigned char *freq, int nFreq, int removeIdx)
+{
+ int k;
+
+ if (removeIdx >= nFreq) {
+ return;
+ }
+
+ for (k = removeIdx; k < nFreq - 1; k++) {
+ freq[k] = freq[k + 1];
+ }
+}
+
+/**************************************************************************************
+ * Function: CalcFreqLimiter
+ *
+ * Description: calculate limiter frequency table (4.6.18.3.2.3)
+ *
+ * Inputs: number of subbands in each patch
+ * low resolution frequency table
+ * number of bands in low resolution frequency table
+ * index of starting QMF subband for SBR (kStart)
+ * number of limiter bands
+ * number of patches
+ *
+ * Outputs: limiter frequency table
+ *
+ * Return: number of bands in limiter frequency table
+ **************************************************************************************/
+static int CalcFreqLimiter(unsigned char *freqLimiter, unsigned char *patchNumSubbands, unsigned char *freqLow,
+ int nLow, int kStart, int limiterBands, int numPatches)
+{
+ int k, bands, nLimiter, nOctaves;
+ int limBandsPerOctave[3] = {120, 200, 300}; /* [1.2, 2.0, 3.0] * 100 */
+ unsigned char patchBorders[MAX_NUM_PATCHES + 1];
+
+ /* simple case */
+ if (limiterBands == 0) {
+ freqLimiter[0] = freqLow[0] - kStart;
+ freqLimiter[1] = freqLow[nLow] - kStart;
+ return 1;
+ }
+
+ bands = limBandsPerOctave[limiterBands - 1];
+ patchBorders[0] = kStart;
+
+ /* from MPEG reference code - slightly different from spec (top border) */
+ for (k = 1; k < numPatches; k++) {
+ patchBorders[k] = patchBorders[k - 1] + patchNumSubbands[k - 1];
+ }
+ patchBorders[k] = freqLow[nLow];
+
+ for (k = 0; k <= nLow; k++) {
+ freqLimiter[k] = freqLow[k];
+ }
+
+ for (k = 1; k < numPatches; k++) {
+ freqLimiter[k + nLow] = patchBorders[k];
+ }
+
+ k = 1;
+ nLimiter = nLow + numPatches - 1;
+ BubbleSort(freqLimiter, nLimiter + 1);
+
+ while (k <= nLimiter) {
+ nOctaves = log2Tab[freqLimiter[k]] - log2Tab[freqLimiter[k - 1]]; /* Q28 */
+ nOctaves = (nOctaves >> 9) * bands; /* Q19, max bands = 300 < 2^9 */
+ if (nOctaves < (49 << 19)) { /* compare with 0.49*100, in Q19 */
+ if (freqLimiter[k] == freqLimiter[k - 1] || FindFreq(patchBorders, numPatches + 1, freqLimiter[k]) == 0) {
+ RemoveFreq(freqLimiter, nLimiter + 1, k);
+ nLimiter--;
+ } else if (FindFreq(patchBorders, numPatches + 1, freqLimiter[k - 1]) == 0) {
+ RemoveFreq(freqLimiter, nLimiter + 1, k - 1);
+ nLimiter--;
+ } else {
+ k++;
+ }
+ } else {
+ k++;
+ }
+ }
+
+ /* store limiter boundaries as offsets from kStart */
+ for (k = 0; k <= nLimiter; k++) {
+ freqLimiter[k] -= kStart;
+ }
+
+ return nLimiter;
+}
+
+/**************************************************************************************
+ * Function: CalcFreqTables
+ *
+ * Description: calulate master and derived frequency tables, and patches
+ *
+ * Inputs: initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRFreq struct for this SCE/CPE block
+ * sample rate index of output sample rate (after SBR)
+ *
+ * Outputs: master and derived frequency tables, and patches
+ *
+ * Return: non-zero if error, zero otherwise
+ **************************************************************************************/
+int CalcFreqTables(SBRHeader *sbrHdr, SBRFreq *sbrFreq, int sampRateIdx)
+{
+ int k0, k2;
+ int err = ERR_AAC_NONE;
+ k0 = k0Tab[sampRateIdx][sbrHdr->startFreq];
+
+ if (sbrHdr->stopFreq == 14) {
+ k2 = 2 * k0;
+ } else if (sbrHdr->stopFreq == 15) {
+ k2 = 3 * k0;
+ } else {
+ k2 = k2Tab[sampRateIdx][sbrHdr->stopFreq];
+ }
+ if (k2 > 64) {
+ k2 = 64;
+ }
+
+ /* calculate master frequency table */
+ if (sbrHdr->freqScale == 0) {
+ sbrFreq->nMaster = CalcFreqMasterScaleZero(sbrFreq->freqMaster, sbrHdr->alterScale, k0, k2);
+ } else {
+ sbrFreq->nMaster = CalcFreqMaster(sbrFreq->freqMaster, sbrHdr->freqScale, sbrHdr->alterScale, k0, k2);
+ }
+
+ /* calculate high frequency table and related parameters */
+ sbrFreq->nHigh = CalcFreqHigh(sbrFreq->freqHigh, sbrFreq->freqMaster, sbrFreq->nMaster, sbrHdr->crossOverBand);
+ sbrFreq->numQMFBands = sbrFreq->freqHigh[sbrFreq->nHigh] - sbrFreq->freqHigh[0];
+ sbrFreq->kStart = sbrFreq->freqHigh[0];
+
+ /* calculate low frequency table */
+ sbrFreq->nLow = CalcFreqLow(sbrFreq->freqLow, sbrFreq->freqHigh, sbrFreq->nHigh);
+
+ /* calculate noise floor frequency table */
+ sbrFreq->numNoiseFloorBands = CalcFreqNoise(sbrFreq->freqNoise, sbrFreq->freqLow, sbrFreq->nLow, sbrFreq->kStart, k2, sbrHdr->noiseBands, &err);
+ if (err) {
+ return err;
+ }
+
+ /* calculate limiter table */
+ sbrFreq->numPatches = BuildPatches(sbrFreq->patchNumSubbands, sbrFreq->patchStartSubband, sbrFreq->freqMaster,
+ sbrFreq->nMaster, k0, sbrFreq->kStart, sbrFreq->numQMFBands, sampRateIdx);
+ sbrFreq->nLimiter = CalcFreqLimiter(sbrFreq->freqLimiter, sbrFreq->patchNumSubbands, sbrFreq->freqLow, sbrFreq->nLow, sbrFreq->kStart,
+ sbrHdr->limiterBands, sbrFreq->numPatches);
+
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/libfaad/helixaac/sbrhfadj.c b/audio_codec/libfaad/helixaac/sbrhfadj.c
new file mode 100644
index 0000000..d0a85ac
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/sbrhfadj.c
@@ -0,0 +1,882 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrhfadj.c,v 1.1.2.3 2005/05/24 20:34:40 albertofloyd Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrhfadj.c - high frequency adjustment for SBR
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+/* invBandTab[i] = 1.0 / (i + 1), Q31 */
+static const int invBandTab[64] = {
+ 0x7fffffff, 0x40000000, 0x2aaaaaab, 0x20000000, 0x1999999a, 0x15555555, 0x12492492, 0x10000000,
+ 0x0e38e38e, 0x0ccccccd, 0x0ba2e8ba, 0x0aaaaaab, 0x09d89d8a, 0x09249249, 0x08888889, 0x08000000,
+ 0x07878788, 0x071c71c7, 0x06bca1af, 0x06666666, 0x06186186, 0x05d1745d, 0x0590b216, 0x05555555,
+ 0x051eb852, 0x04ec4ec5, 0x04bda12f, 0x04924925, 0x0469ee58, 0x04444444, 0x04210842, 0x04000000,
+ 0x03e0f83e, 0x03c3c3c4, 0x03a83a84, 0x038e38e4, 0x03759f23, 0x035e50d8, 0x03483483, 0x03333333,
+ 0x031f3832, 0x030c30c3, 0x02fa0be8, 0x02e8ba2f, 0x02d82d83, 0x02c8590b, 0x02b93105, 0x02aaaaab,
+ 0x029cbc15, 0x028f5c29, 0x02828283, 0x02762762, 0x026a439f, 0x025ed098, 0x0253c825, 0x02492492,
+ 0x023ee090, 0x0234f72c, 0x022b63cc, 0x02222222, 0x02192e2a, 0x02108421, 0x02082082, 0x02000000,
+};
+
+/**************************************************************************************
+ * Function: EstimateEnvelope
+ *
+ * Description: estimate power of generated HF QMF bands in one time-domain envelope
+ * (4.6.18.7.3)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * index of current envelope
+ *
+ * Outputs: power of each QMF subband, stored as integer (Q0) * 2^N, N >= 0
+ *
+ * Return: none
+ **************************************************************************************/
+static void EstimateEnvelope(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, int env)
+{
+ int i, m, iStart, iEnd, xre, xim, nScale, expMax;
+ int p, n, mStart, mEnd, invFact, t;
+ int *XBuf;
+ U64 eCurr;
+ unsigned char *freqBandTab;
+
+ /* estimate current envelope */
+ iStart = sbrGrid->envTimeBorder[env] + HF_ADJ;
+ iEnd = sbrGrid->envTimeBorder[env + 1] + HF_ADJ;
+ if (sbrGrid->freqRes[env]) {
+ n = sbrFreq->nHigh;
+ freqBandTab = sbrFreq->freqHigh;
+ } else {
+ n = sbrFreq->nLow;
+ freqBandTab = sbrFreq->freqLow;
+ }
+
+ /* ADS should inline MADD64 (smlal) properly, but check to make sure */
+ expMax = 0;
+ if (sbrHdr->interpFreq) {
+ for (m = 0; m < sbrFreq->numQMFBands; m++) {
+ eCurr.w64 = 0;
+ XBuf = psi->XBuf[iStart][sbrFreq->kStart + m];
+ for (i = iStart; i < iEnd; i++) {
+ /* scale to int before calculating power (precision not critical, and avoids overflow) */
+ xre = (*XBuf) >> FBITS_OUT_QMFA;
+ XBuf += 1;
+ xim = (*XBuf) >> FBITS_OUT_QMFA;
+ XBuf += (2 * 64 - 1);
+ eCurr.w64 = MADD64(eCurr.w64, xre, xre);
+ eCurr.w64 = MADD64(eCurr.w64, xim, xim);
+ }
+
+ /* eCurr.w64 is now Q(64 - 2*FBITS_OUT_QMFA) (64-bit word)
+ * if energy is too big to fit in 32-bit word (> 2^31) scale down by power of 2
+ */
+ nScale = 0;
+ if (eCurr.r.hi32) {
+ nScale = (32 - CLZ(eCurr.r.hi32)) + 1;
+ t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */
+ t |= eCurr.r.hi32 << (32 - nScale);
+ } else if (eCurr.r.lo32 >> 31) {
+ nScale = 1;
+ t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */
+ } else {
+ t = (int)eCurr.r.lo32;
+ }
+
+ invFact = invBandTab[(iEnd - iStart) - 1];
+ psi->eCurr[m] = MULSHIFT32(t, invFact);
+ psi->eCurrExp[m] = nScale + 1; /* +1 for invFact = Q31 */
+ if (psi->eCurrExp[m] > expMax) {
+ expMax = psi->eCurrExp[m];
+ }
+ }
+ } else {
+ for (p = 0; p < n; p++) {
+ mStart = freqBandTab[p];
+ mEnd = freqBandTab[p + 1];
+ eCurr.w64 = 0;
+ for (i = iStart; i < iEnd; i++) {
+ XBuf = psi->XBuf[i][mStart];
+ for (m = mStart; m < mEnd; m++) {
+ xre = (*XBuf++) >> FBITS_OUT_QMFA;
+ xim = (*XBuf++) >> FBITS_OUT_QMFA;
+ eCurr.w64 = MADD64(eCurr.w64, xre, xre);
+ eCurr.w64 = MADD64(eCurr.w64, xim, xim);
+ }
+ }
+
+ nScale = 0;
+ if (eCurr.r.hi32) {
+ nScale = (32 - CLZ(eCurr.r.hi32)) + 1;
+ t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */
+ t |= eCurr.r.hi32 << (32 - nScale);
+ } else if (eCurr.r.lo32 >> 31) {
+ nScale = 1;
+ t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */
+ } else {
+ t = (int)eCurr.r.lo32;
+ }
+
+ invFact = invBandTab[(iEnd - iStart) - 1];
+ invFact = MULSHIFT32(invBandTab[(mEnd - mStart) - 1], invFact) << 1;
+ t = MULSHIFT32(t, invFact);
+
+ for (m = mStart; m < mEnd; m++) {
+ psi->eCurr[m - sbrFreq->kStart] = t;
+ psi->eCurrExp[m - sbrFreq->kStart] = nScale + 1; /* +1 for invFact = Q31 */
+ }
+ if (psi->eCurrExp[mStart - sbrFreq->kStart] > expMax) {
+ expMax = psi->eCurrExp[mStart - sbrFreq->kStart];
+ }
+ }
+ }
+ psi->eCurrExpMax = expMax;
+}
+
+/**************************************************************************************
+ * Function: GetSMapped
+ *
+ * Description: calculate SMapped (4.6.18.7.2)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current envelope
+ * index of current QMF band
+ * la flag for this envelope
+ *
+ * Outputs: none
+ *
+ * Return: 1 if a sinusoid is present in this band, 0 if not
+ **************************************************************************************/
+static int GetSMapped(SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int env, int band, int la)
+{
+ int bandStart, bandEnd, oddFlag, r;
+
+ if (sbrGrid->freqRes[env]) {
+ /* high resolution */
+ bandStart = band;
+ bandEnd = band + 1;
+ } else {
+ /* low resolution (see CalcFreqLow() for mapping) */
+ oddFlag = sbrFreq->nHigh & 0x01;
+ bandStart = (band > 0 ? 2 * band - oddFlag : 0); /* starting index for freqLow[band] */
+ bandEnd = 2 * (band + 1) - oddFlag; /* ending index for freqLow[band+1] */
+ }
+
+ /* sMapped = 1 if sIndexMapped == 1 for any frequency in this band */
+ for (band = bandStart; band < bandEnd; band++) {
+ if (sbrChan->addHarmonic[1][band]) {
+ r = ((sbrFreq->freqHigh[band + 1] + sbrFreq->freqHigh[band]) >> 1);
+ if (env >= la || sbrChan->addHarmonic[0][r] == 1) {
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+#define GBOOST_MAX 0x2830afd3 /* Q28, 1.584893192 squared */
+#define ACC_SCALE 6
+
+/* squared version of table in 4.6.18.7.5 */
+static const int limGainTab[4] = {0x20138ca7, 0x40000000, 0x7fb27dce, 0x80000000}; /* Q30 (0x80000000 = sentinel for GMAX) */
+
+/**************************************************************************************
+ * Function: CalcMaxGain
+ *
+ * Description: calculate max gain in one limiter band (4.6.18.7.5)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ * index of current envelope
+ * index of current limiter band
+ * number of fraction bits in dequantized envelope
+ * (max = Q(FBITS_OUT_DQ_ENV - 6) = Q23, can go negative)
+ *
+ * Outputs: updated gainMax, gainMaxFBits, and sumEOrigMapped in PSInfoSBR struct
+ *
+ * Return: none
+ **************************************************************************************/
+static void CalcMaxGain(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, int ch, int env, int lim, int fbitsDQ)
+{
+ int m, mStart, mEnd, q, z, r;
+ int sumEOrigMapped, sumECurr, gainMax, eOMGainMax, envBand;
+ unsigned char eCurrExpMax;
+ unsigned char *freqBandTab;
+
+ mStart = sbrFreq->freqLimiter[lim]; /* these are offsets from kStart */
+ mEnd = sbrFreq->freqLimiter[lim + 1];
+ freqBandTab = (sbrGrid->freqRes[env] ? sbrFreq->freqHigh : sbrFreq->freqLow);
+
+ /* calculate max gain to apply to signal in this limiter band */
+ sumECurr = 0;
+ sumEOrigMapped = 0;
+ eCurrExpMax = psi->eCurrExpMax;
+ eOMGainMax = psi->eOMGainMax;
+ envBand = psi->envBand;
+ for (m = mStart; m < mEnd; m++) {
+ /* map current QMF band to appropriate envelope band */
+ if (m == freqBandTab[envBand + 1] - sbrFreq->kStart) {
+ envBand++;
+ eOMGainMax = psi->envDataDequant[ch][env][envBand] >> ACC_SCALE; /* summing max 48 bands */
+ }
+ sumEOrigMapped += eOMGainMax;
+
+ /* easy test for overflow on ARM */
+ sumECurr += (psi->eCurr[m] >> (eCurrExpMax - psi->eCurrExp[m]));
+ if (sumECurr >> 30) {
+ sumECurr >>= 1;
+ eCurrExpMax++;
+ }
+ }
+ psi->eOMGainMax = eOMGainMax;
+ psi->envBand = envBand;
+
+ psi->gainMaxFBits = 30; /* Q30 tables */
+ if (sumECurr == 0) {
+ /* any non-zero numerator * 1/EPS_0 is > G_MAX */
+ gainMax = (sumEOrigMapped == 0 ? limGainTab[sbrHdr->limiterGains] : 0x80000000);
+ } else if (sumEOrigMapped == 0) {
+ /* 1/(any non-zero denominator) * EPS_0 * limGainTab[x] is appx. 0 */
+ gainMax = 0;
+ } else {
+ /* sumEOrigMapped = Q(fbitsDQ - ACC_SCALE), sumECurr = Q(-eCurrExpMax) */
+ gainMax = limGainTab[sbrHdr->limiterGains];
+ if (sbrHdr->limiterGains != 3) {
+ q = MULSHIFT32(sumEOrigMapped, gainMax); /* Q(fbitsDQ - ACC_SCALE - 2), gainMax = Q30 */
+ z = CLZ(sumECurr) - 1;
+ r = InvRNormalized(sumECurr << z); /* in = Q(z - eCurrExpMax), out = Q(29 + 31 - z + eCurrExpMax) */
+ gainMax = MULSHIFT32(q, r); /* Q(29 + 31 - z + eCurrExpMax + fbitsDQ - ACC_SCALE - 2 - 32) */
+ psi->gainMaxFBits = 26 - z + eCurrExpMax + fbitsDQ - ACC_SCALE;
+ }
+ }
+ psi->sumEOrigMapped = sumEOrigMapped;
+ psi->gainMax = gainMax;
+}
+
+/**************************************************************************************
+ * Function: CalcNoiseDivFactors
+ *
+ * Description: calculate 1/(1+Q) and Q/(1+Q) (4.6.18.7.4; 4.6.18.7.5)
+ *
+ * Inputs: dequantized noise floor scalefactor
+ *
+ * Outputs: 1/(1+Q) and Q/(1+Q), format = Q31
+ *
+ * Return: none
+ **************************************************************************************/
+static void CalcNoiseDivFactors(int q, int *qp1Inv, int *qqp1Inv)
+{
+ int z, qp1, t, s;
+
+ /* 1 + Q_orig */
+ qp1 = (q >> 1);
+ qp1 += (1 << (FBITS_OUT_DQ_NOISE - 1)); /* >> 1 to avoid overflow when adding 1.0 */
+ z = CLZ(qp1) - 1; /* z <= 31 - FBITS_OUT_DQ_NOISE */
+ qp1 <<= z; /* Q(FBITS_OUT_DQ_NOISE + z) = Q31 * 2^-(31 - (FBITS_OUT_DQ_NOISE + z)) */
+ t = InvRNormalized(qp1) << 1; /* Q30 * 2^(31 - (FBITS_OUT_DQ_NOISE + z)), guaranteed not to overflow */
+
+ /* normalize to Q31 */
+ s = (31 - (FBITS_OUT_DQ_NOISE - 1) - z - 1); /* clearly z >= 0, z <= (30 - (FBITS_OUT_DQ_NOISE - 1)) */
+ *qp1Inv = (t >> s); /* s = [0, 31 - FBITS_OUT_DQ_NOISE] */
+ *qqp1Inv = MULSHIFT32(t, q) << (32 - FBITS_OUT_DQ_NOISE - s);
+}
+
+/**************************************************************************************
+ * Function: CalcComponentGains
+ *
+ * Description: calculate gain of envelope, sinusoids, and noise in one limiter band
+ * (4.6.18.7.5)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ * index of current envelope
+ * index of current limiter band
+ * number of fraction bits in dequantized envelope
+ *
+ * Outputs: gains for envelope, sinusoids and noise
+ * number of fraction bits for envelope gain
+ * sum of the total gain for each component in this band
+ * other updated state variables
+ *
+ * Return: none
+ **************************************************************************************/
+static void CalcComponentGains(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch, int env, int lim, int fbitsDQ)
+{
+ int d, m, mStart, mEnd, q, qm, noiseFloor, sIndexMapped;
+ int shift, eCurr, maxFlag, gainMax, gainMaxFBits;
+ int gain, sm, z, r, fbitsGain, gainScale;
+ unsigned char *freqBandTab;
+
+ mStart = sbrFreq->freqLimiter[lim]; /* these are offsets from kStart */
+ mEnd = sbrFreq->freqLimiter[lim + 1];
+
+ gainMax = psi->gainMax;
+ gainMaxFBits = psi->gainMaxFBits;
+
+ d = (env == psi->la || env == sbrChan->laPrev ? 0 : 1);
+ freqBandTab = (sbrGrid->freqRes[env] ? sbrFreq->freqHigh : sbrFreq->freqLow);
+
+ /* figure out which noise floor this envelope is in (only 1 or 2 noise floors allowed) */
+ noiseFloor = 0;
+ if (sbrGrid->numNoiseFloors == 2 && sbrGrid->noiseTimeBorder[1] <= sbrGrid->envTimeBorder[env]) {
+ noiseFloor++;
+ }
+
+ psi->sumECurrGLim = 0;
+ psi->sumSM = 0;
+ psi->sumQM = 0;
+ /* calculate energy of noise to add in this limiter band */
+ for (m = mStart; m < mEnd; m++) {
+ if (m == sbrFreq->freqNoise[psi->noiseFloorBand + 1] - sbrFreq->kStart) {
+ /* map current QMF band to appropriate noise floor band (NOTE: freqLimiter[0] == freqLow[0] = freqHigh[0]) */
+ psi->noiseFloorBand++;
+ CalcNoiseDivFactors(psi->noiseDataDequant[ch][noiseFloor][psi->noiseFloorBand], &(psi->qp1Inv), &(psi->qqp1Inv));
+ }
+ if (m == sbrFreq->freqHigh[psi->highBand + 1] - sbrFreq->kStart) {
+ psi->highBand++;
+ }
+ if (m == freqBandTab[psi->sBand + 1] - sbrFreq->kStart) {
+ psi->sBand++;
+ psi->sMapped = GetSMapped(sbrGrid, sbrFreq, sbrChan, env, psi->sBand, psi->la);
+ }
+
+ /* get sIndexMapped for this QMF subband */
+ sIndexMapped = 0;
+ r = ((sbrFreq->freqHigh[psi->highBand + 1] + sbrFreq->freqHigh[psi->highBand]) >> 1);
+ if (m + sbrFreq->kStart == r) {
+ /* r = center frequency, deltaStep = (env >= la || sIndexMapped'(r, numEnv'-1) == 1) */
+ if (env >= psi->la || sbrChan->addHarmonic[0][r] == 1) {
+ sIndexMapped = sbrChan->addHarmonic[1][psi->highBand];
+ }
+ }
+
+ /* save sine flags from last envelope in this frame:
+ * addHarmonic[0][0...63] = saved sine present flag from previous frame, for each QMF subband
+ * addHarmonic[1][0...nHigh-1] = addHarmonic bit from current frame, for each high-res frequency band
+ * from MPEG reference code - slightly different from spec
+ * (sIndexMapped'(m,LE'-1) can still be 0 when numEnv == psi->la)
+ */
+ if (env == sbrGrid->numEnv - 1) {
+ if (m + sbrFreq->kStart == r) {
+ sbrChan->addHarmonic[0][m + sbrFreq->kStart] = sbrChan->addHarmonic[1][psi->highBand];
+ } else {
+ sbrChan->addHarmonic[0][m + sbrFreq->kStart] = 0;
+ }
+ }
+
+ gain = psi->envDataDequant[ch][env][psi->sBand];
+ qm = MULSHIFT32(gain, psi->qqp1Inv) << 1;
+ sm = (sIndexMapped ? MULSHIFT32(gain, psi->qp1Inv) << 1 : 0);
+
+ /* three cases: (sMapped == 0 && delta == 1), (sMapped == 0 && delta == 0), (sMapped == 1) */
+ if (d == 1 && psi->sMapped == 0) {
+ gain = MULSHIFT32(psi->qp1Inv, gain) << 1;
+ } else if (psi->sMapped != 0) {
+ gain = MULSHIFT32(psi->qqp1Inv, gain) << 1;
+ }
+
+ /* gain, qm, sm = Q(fbitsDQ), gainMax = Q(fbitsGainMax) */
+ eCurr = psi->eCurr[m];
+ if (eCurr) {
+ z = CLZ(eCurr) - 1;
+ r = InvRNormalized(eCurr << z); /* in = Q(z - eCurrExp), out = Q(29 + 31 - z + eCurrExp) */
+ gainScale = MULSHIFT32(gain, r); /* out = Q(29 + 31 - z + eCurrExp + fbitsDQ - 32) */
+ fbitsGain = 29 + 31 - z + psi->eCurrExp[m] + fbitsDQ - 32;
+ } else {
+ /* if eCurr == 0, then gain is unchanged (divide by EPS = 1) */
+ gainScale = gain;
+ fbitsGain = fbitsDQ;
+ }
+
+ /* see if gain for this band exceeds max gain */
+ maxFlag = 0;
+ if (gainMax != (int)0x80000000) {
+ if (fbitsGain >= gainMaxFBits) {
+ shift = MIN(fbitsGain - gainMaxFBits, 31);
+ maxFlag = ((gainScale >> shift) > gainMax ? 1 : 0);
+ } else {
+ shift = MIN(gainMaxFBits - fbitsGain, 31);
+ maxFlag = (gainScale > (gainMax >> shift) ? 1 : 0);
+ }
+ }
+
+ if (maxFlag) {
+ /* gainScale > gainMax, calculate ratio with 32/16 division */
+ q = 0;
+ r = gainScale; /* guaranteed > 0, else maxFlag could not have been set */
+ z = CLZ(r);
+ if (z < 16) {
+ q = 16 - z;
+ r >>= q; /* out = Q(fbitsGain - q) */
+ }
+
+ z = CLZ(gainMax) - 1;
+ r = (gainMax << z) / r; /* out = Q((fbitsGainMax + z) - (fbitsGain - q)) */
+ q = (gainMaxFBits + z) - (fbitsGain - q); /* r = Q(q) */
+ if (q > 30) {
+ r >>= MIN(q - 30, 31);
+ } else {
+ z = MIN(30 - q, 30);
+ CLIP_2N_SHIFT30(r, z); /* let r = Q30 since range = [0.0, 1.0) (clip to 0x3fffffff = 0.99999) */
+ }
+
+ qm = MULSHIFT32(qm, r) << 2;
+ gain = MULSHIFT32(gain, r) << 2;
+ psi->gLimBuf[m] = gainMax;
+ psi->gLimFbits[m] = gainMaxFBits;
+ } else {
+ psi->gLimBuf[m] = gainScale;
+ psi->gLimFbits[m] = fbitsGain;
+ }
+
+ /* sumSM, sumQM, sumECurrGLim = Q(fbitsDQ - ACC_SCALE) */
+ psi->smBuf[m] = sm;
+ psi->sumSM += (sm >> ACC_SCALE);
+
+ psi->qmLimBuf[m] = qm;
+ if (env != psi->la && env != sbrChan->laPrev && sm == 0) {
+ psi->sumQM += (qm >> ACC_SCALE);
+ }
+
+ /* eCurr * gain^2 same as gain^2, before division by eCurr
+ * (but note that gain != 0 even if eCurr == 0, since it's divided by eps)
+ */
+ if (eCurr) {
+ psi->sumECurrGLim += (gain >> ACC_SCALE);
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: ApplyBoost
+ *
+ * Description: calculate and apply boost factor for envelope, sinusoids, and noise
+ * in this limiter band (4.6.18.7.5)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRFreq struct for this SCE/CPE block
+ * index of current limiter band
+ * number of fraction bits in dequantized envelope
+ *
+ * Outputs: envelope gain, sinusoids and noise after scaling by gBoost
+ * format = Q(FBITS_GLIM_BOOST) for envelope gain,
+ * = Q(FBITS_QLIM_BOOST) for noise
+ * = Q(FBITS_OUT_QMFA) for sinusoids
+ *
+ * Return: none
+ *
+ * Notes: after scaling, each component has at least 1 GB
+ **************************************************************************************/
+static void ApplyBoost(PSInfoSBR *psi, SBRFreq *sbrFreq, int lim, int fbitsDQ)
+{
+ int m, mStart, mEnd, q, z, r;
+ int sumEOrigMapped, gBoost;
+
+ mStart = sbrFreq->freqLimiter[lim]; /* these are offsets from kStart */
+ mEnd = sbrFreq->freqLimiter[lim + 1];
+
+ sumEOrigMapped = psi->sumEOrigMapped >> 1;
+ r = (psi->sumECurrGLim >> 1) + (psi->sumSM >> 1) + (psi->sumQM >> 1); /* 1 GB fine (sm and qm are mutually exclusive in acc) */
+ if (r < (1 << (31 - 28))) {
+ /* any non-zero numerator * 1/EPS_0 is > GBOOST_MAX
+ * round very small r to zero to avoid scaling problems
+ */
+ gBoost = (sumEOrigMapped == 0 ? (1 << 28) : GBOOST_MAX);
+ z = 0;
+ } else if (sumEOrigMapped == 0) {
+ /* 1/(any non-zero denominator) * EPS_0 is appx. 0 */
+ gBoost = 0;
+ z = 0;
+ } else {
+ /* numerator (sumEOrigMapped) and denominator (r) have same Q format (before << z) */
+ z = CLZ(r) - 1; /* z = [0, 27] */
+ r = InvRNormalized(r << z);
+ gBoost = MULSHIFT32(sumEOrigMapped, r);
+ }
+
+ /* gBoost = Q(28 - z) */
+ if (gBoost > (GBOOST_MAX >> z)) {
+ gBoost = GBOOST_MAX;
+ z = 0;
+ }
+ gBoost <<= z; /* gBoost = Q28, minimum 1 GB */
+
+ /* convert gain, noise, sinusoids to fixed Q format, clipping if necessary
+ * (rare, usually only happens at very low bitrates, introduces slight
+ * distortion into final HF mapping, but should be inaudible)
+ */
+ for (m = mStart; m < mEnd; m++) {
+ /* let gLimBoost = Q24, since in practice the max values are usually 16 to 20
+ * unless limiterGains == 3 (limiter off) and eCurr ~= 0 (i.e. huge gain, but only
+ * because the envelope has 0 power anyway)
+ */
+ q = MULSHIFT32(psi->gLimBuf[m], gBoost) << 2; /* Q(gLimFbits) * Q(28) --> Q(gLimFbits[m]-2) */
+ r = SqrtFix(q, psi->gLimFbits[m] - 2, &z);
+ z -= FBITS_GLIM_BOOST;
+ if (z >= 0) {
+ psi->gLimBoost[m] = r >> MIN(z, 31);
+ } else {
+ z = MIN(30, -z);
+ CLIP_2N_SHIFT30(r, z);
+ psi->gLimBoost[m] = r;
+ }
+
+ q = MULSHIFT32(psi->qmLimBuf[m], gBoost) << 2; /* Q(fbitsDQ) * Q(28) --> Q(fbitsDQ-2) */
+ r = SqrtFix(q, fbitsDQ - 2, &z);
+ z -= FBITS_QLIM_BOOST; /* << by 14, since integer sqrt of x < 2^16, and we want to leave 1 GB */
+ if (z >= 0) {
+ psi->qmLimBoost[m] = r >> MIN(31, z);
+ } else {
+ z = MIN(30, -z);
+ CLIP_2N_SHIFT30(r, z);
+ psi->qmLimBoost[m] = r;
+ }
+
+ q = MULSHIFT32(psi->smBuf[m], gBoost) << 2; /* Q(fbitsDQ) * Q(28) --> Q(fbitsDQ-2) */
+ r = SqrtFix(q, fbitsDQ - 2, &z);
+ z -= FBITS_OUT_QMFA; /* justify for adding to signal (xBuf) later */
+ if (z >= 0) {
+ psi->smBoost[m] = r >> MIN(31, z);
+ } else {
+ z = MIN(30, -z);
+ CLIP_2N_SHIFT30(r, z);
+ psi->smBoost[m] = r;
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: CalcGain
+ *
+ * Description: calculate and apply proper gain to HF components in one envelope
+ * (4.6.18.7.5)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ * index of current envelope
+ *
+ * Outputs: envelope gain, sinusoids and noise after scaling
+ *
+ * Return: none
+ **************************************************************************************/
+static void CalcGain(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch, int env)
+{
+ int lim, fbitsDQ;
+
+ /* initialize to -1 so that mapping limiter bands to env/noise bands works right on first pass */
+ psi->envBand = -1;
+ psi->noiseFloorBand = -1;
+ psi->sBand = -1;
+ psi->highBand = -1;
+
+ fbitsDQ = (FBITS_OUT_DQ_ENV - psi->envDataDequantScale[ch][env]); /* Q(29 - optional scalefactor) */
+ for (lim = 0; lim < sbrFreq->nLimiter; lim++) {
+ /* the QMF bands are divided into lim regions (consecutive, non-overlapping) */
+ CalcMaxGain(psi, sbrHdr, sbrGrid, sbrFreq, ch, env, lim, fbitsDQ);
+ CalcComponentGains(psi, sbrGrid, sbrFreq, sbrChan, ch, env, lim, fbitsDQ);
+ ApplyBoost(psi, sbrFreq, lim, fbitsDQ);
+ }
+}
+
+/* hSmooth table from 4.7.18.7.6, format = Q31 */
+static const int hSmoothCoef[MAX_NUM_SMOOTH_COEFS] = {
+ 0x2aaaaaab, 0x2697a512, 0x1becfa68, 0x0ebdb043, 0x04130598,
+};
+
+/**************************************************************************************
+ * Function: MapHF
+ *
+ * Description: map HF components to proper QMF bands, with optional gain smoothing
+ * filter (4.6.18.7.6)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current envelope
+ * reset flag (can be non-zero for first envelope only)
+ *
+ * Outputs: complete reconstructed subband QMF samples for this envelope
+ *
+ * Return: none
+ *
+ * Notes: ensures that output has >= MIN_GBITS_IN_QMFS guard bits,
+ * so it's not necessary to check anything in the synth QMF
+ **************************************************************************************/
+static int MapHF(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int env, int hfReset)
+{
+ int noiseTabIndex, sinIndex, gainNoiseIndex, hSL;
+ int i, iStart, iEnd, m, idx, j, s, n, smre, smim;
+ int gFilt, qFilt, xre, xim, gbMask, gbIdx;
+ int *XBuf;
+
+ noiseTabIndex = sbrChan->noiseTabIndex;
+ sinIndex = sbrChan->sinIndex;
+ gainNoiseIndex = sbrChan->gainNoiseIndex; /* oldest entries in filter delay buffer */
+
+ if (hfReset) {
+ noiseTabIndex = 2; /* starts at 1, double since complex */
+ }
+ hSL = (sbrHdr->smoothMode ? 0 : 4);
+
+ if (hfReset) {
+ for (i = 0; i < hSL; i++) {
+ for (m = 0; m < sbrFreq->numQMFBands; m++) {
+ sbrChan->gTemp[gainNoiseIndex][m] = psi->gLimBoost[m];
+ sbrChan->qTemp[gainNoiseIndex][m] = psi->qmLimBoost[m];
+ }
+ gainNoiseIndex++;
+ if (gainNoiseIndex == MAX_NUM_SMOOTH_COEFS) {
+ gainNoiseIndex = 0;
+ }
+ }
+ ASSERT(env == 0, ERR_AAC_SBR_BITSTREAM); /* should only be reset when env == 0 */
+ }
+
+ iStart = sbrGrid->envTimeBorder[env];
+ iEnd = sbrGrid->envTimeBorder[env + 1];
+ for (i = iStart; i < iEnd; i++) {
+ /* save new values in temp buffers (delay)
+ * we only store MAX_NUM_SMOOTH_COEFS most recent values,
+ * so don't keep storing the same value over and over
+ */
+ if (i - iStart < MAX_NUM_SMOOTH_COEFS) {
+ for (m = 0; m < sbrFreq->numQMFBands; m++) {
+ sbrChan->gTemp[gainNoiseIndex][m] = psi->gLimBoost[m];
+ sbrChan->qTemp[gainNoiseIndex][m] = psi->qmLimBoost[m];
+ }
+ }
+
+ /* see 4.6.18.7.6 */
+ XBuf = psi->XBuf[i + HF_ADJ][sbrFreq->kStart];
+ gbMask = 0;
+ for (m = 0; m < sbrFreq->numQMFBands; m++) {
+ if (env == psi->la || env == sbrChan->laPrev) {
+ /* no smoothing filter for gain, and qFilt = 0 (only need to do once) */
+ if (i == iStart) {
+ psi->gFiltLast[m] = sbrChan->gTemp[gainNoiseIndex][m];
+ psi->qFiltLast[m] = 0;
+ }
+ } else if (hSL == 0) {
+ /* no smoothing filter for gain, (only need to do once) */
+ if (i == iStart) {
+ psi->gFiltLast[m] = sbrChan->gTemp[gainNoiseIndex][m];
+ psi->qFiltLast[m] = sbrChan->qTemp[gainNoiseIndex][m];
+ }
+ } else {
+ /* apply smoothing filter to gain and noise (after MAX_NUM_SMOOTH_COEFS, it's always the same) */
+ if (i - iStart < MAX_NUM_SMOOTH_COEFS) {
+ gFilt = 0;
+ qFilt = 0;
+ idx = gainNoiseIndex;
+ for (j = 0; j < MAX_NUM_SMOOTH_COEFS; j++) {
+ /* sum(abs(hSmoothCoef[j])) for all j < 1.0 */
+ gFilt += MULSHIFT32(sbrChan->gTemp[idx][m], hSmoothCoef[j]);
+ qFilt += MULSHIFT32(sbrChan->qTemp[idx][m], hSmoothCoef[j]);
+ idx--;
+ if (idx < 0) {
+ idx += MAX_NUM_SMOOTH_COEFS;
+ }
+ }
+ psi->gFiltLast[m] = gFilt << 1; /* restore to Q(FBITS_GLIM_BOOST) (gain of filter < 1.0, so no overflow) */
+ psi->qFiltLast[m] = qFilt << 1; /* restore to Q(FBITS_QLIM_BOOST) */
+ }
+ }
+
+ if (psi->smBoost[m] != 0) {
+ /* add scaled signal and sinusoid, don't add noise (qFilt = 0) */
+ smre = psi->smBoost[m];
+ smim = smre;
+
+ /* sinIndex: [0] xre += sm [1] xim += sm*s [2] xre -= sm [3] xim -= sm*s */
+ s = (sinIndex >> 1); /* if 2 or 3, flip sign to subtract sm */
+ s <<= 31;
+ smre ^= (s >> 31);
+ smre -= (s >> 31);
+ s ^= ((m + sbrFreq->kStart) << 31);
+ smim ^= (s >> 31);
+ smim -= (s >> 31);
+
+ /* if sinIndex == 0 or 2, smim = 0; if sinIndex == 1 or 3, smre = 0 */
+ s = sinIndex << 31;
+ smim &= (s >> 31);
+ s ^= 0x80000000;
+ smre &= (s >> 31);
+
+ noiseTabIndex += 2; /* noise filtered by 0, but still need to bump index */
+ } else {
+ /* add scaled signal and scaled noise */
+ qFilt = psi->qFiltLast[m];
+ n = noiseTab[noiseTabIndex++];
+ smre = MULSHIFT32(n, qFilt) >> (FBITS_QLIM_BOOST - 1 - FBITS_OUT_QMFA);
+
+ n = noiseTab[noiseTabIndex++];
+ smim = MULSHIFT32(n, qFilt) >> (FBITS_QLIM_BOOST - 1 - FBITS_OUT_QMFA);
+ }
+ noiseTabIndex &= 1023; /* 512 complex numbers */
+
+ gFilt = psi->gFiltLast[m];
+ xre = MULSHIFT32(gFilt, XBuf[0]);
+ xim = MULSHIFT32(gFilt, XBuf[1]);
+ CLIP_2N_SHIFT30(xre, 32 - FBITS_GLIM_BOOST);
+ CLIP_2N_SHIFT30(xim, 32 - FBITS_GLIM_BOOST);
+
+ xre += smre;
+ *XBuf++ = xre;
+ xim += smim;
+ *XBuf++ = xim;
+
+ gbMask |= FASTABS(xre);
+ gbMask |= FASTABS(xim);
+ }
+ /* update circular buffer index */
+ gainNoiseIndex++;
+ if (gainNoiseIndex == MAX_NUM_SMOOTH_COEFS) {
+ gainNoiseIndex = 0;
+ }
+
+ sinIndex++;
+ sinIndex &= 3;
+
+ /* ensure MIN_GBITS_IN_QMFS guard bits in output
+ * almost never occurs in practice, but checking here makes synth QMF logic very simple
+ */
+ if (gbMask >> (31 - MIN_GBITS_IN_QMFS)) {
+ XBuf = psi->XBuf[i + HF_ADJ][sbrFreq->kStart];
+ for (m = 0; m < sbrFreq->numQMFBands; m++) {
+ xre = XBuf[0];
+ xim = XBuf[1];
+ CLIP_2N(xre, (31 - MIN_GBITS_IN_QMFS));
+ CLIP_2N(xim, (31 - MIN_GBITS_IN_QMFS));
+ *XBuf++ = xre;
+ *XBuf++ = xim;
+ }
+ CLIP_2N(gbMask, (31 - MIN_GBITS_IN_QMFS));
+ }
+ gbIdx = ((i + HF_ADJ) >> 5) & 0x01;
+ sbrChan->gbMask[gbIdx] |= gbMask;
+ }
+ sbrChan->noiseTabIndex = noiseTabIndex;
+ sbrChan->sinIndex = sinIndex;
+ sbrChan->gainNoiseIndex = gainNoiseIndex;
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: AdjustHighFreq
+ *
+ * Description: adjust high frequencies and add noise and sinusoids (4.6.18.7)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ *
+ * Outputs: complete reconstructed subband QMF samples for this channel
+ *
+ * Return: none
+ **************************************************************************************/
+int AdjustHighFreq(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch)
+{
+ int i, env, hfReset;
+ unsigned char frameClass, pointer;
+ int err = ERR_AAC_NONE;
+ frameClass = sbrGrid->frameClass;
+ pointer = sbrGrid->pointer;
+
+ /* derive la from table 4.159 */
+ if ((frameClass == SBR_GRID_FIXVAR || frameClass == SBR_GRID_VARVAR) && pointer > 0) {
+ psi->la = sbrGrid->numEnv + 1 - pointer;
+ } else if (frameClass == SBR_GRID_VARFIX && pointer > 1) {
+ psi->la = pointer - 1;
+ } else {
+ psi->la = -1;
+ }
+
+ /* for each envelope, estimate gain and adjust SBR QMF bands */
+ hfReset = sbrChan->reset;
+ for (env = 0; env < sbrGrid->numEnv; env++) {
+ EstimateEnvelope(psi, sbrHdr, sbrGrid, sbrFreq, env);
+ CalcGain(psi, sbrHdr, sbrGrid, sbrFreq, sbrChan, ch, env);
+ err = MapHF(psi, sbrHdr, sbrGrid, sbrFreq, sbrChan, env, hfReset);
+ if (err) {
+ return err;
+ }
+ hfReset = 0; /* only set for first envelope after header reset */
+ }
+
+ /* set saved sine flags to 0 for QMF bands outside of current frequency range */
+ for (i = 0; i < sbrFreq->freqLimiter[0] + sbrFreq->kStart; i++) {
+ sbrChan->addHarmonic[0][i] = 0;
+ }
+ for (i = sbrFreq->freqLimiter[sbrFreq->nLimiter] + sbrFreq->kStart; i < 64; i++) {
+ sbrChan->addHarmonic[0][i] = 0;
+ }
+ sbrChan->addHarmonicFlag[0] = sbrChan->addHarmonicFlag[1];
+
+ /* save la for next frame */
+ if (psi->la == sbrGrid->numEnv) {
+ sbrChan->laPrev = 0;
+ } else {
+ sbrChan->laPrev = -1;
+ }
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/libfaad/helixaac/sbrhfgen.c b/audio_codec/libfaad/helixaac/sbrhfgen.c
new file mode 100644
index 0000000..0ab7dad
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/sbrhfgen.c
@@ -0,0 +1,655 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrhfgen.c,v 1.1.2.2 2005/05/19 21:00:01 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrhfgen.c - high frequency generation for SBR
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+#define FBITS_LPCOEFS 29 /* Q29 for range of (-4, 4) */
+#define MAG_16 (16 * (1 << (32 - (2*(32-FBITS_LPCOEFS))))) /* i.e. 16 in Q26 format */
+#define RELAX_COEF 0x7ffff79c /* 1.0 / (1.0 + 1e-6), Q31 */
+
+/* newBWTab[prev invfMode][curr invfMode], format = Q31 (table 4.158)
+ * sample file which uses all of these: al_sbr_sr_64_2_fsaac32.aac
+ */
+static const int newBWTab[4][4] = {
+ {0x00000000, 0x4ccccccd, 0x73333333, 0x7d70a3d7},
+ {0x4ccccccd, 0x60000000, 0x73333333, 0x7d70a3d7},
+ {0x00000000, 0x60000000, 0x73333333, 0x7d70a3d7},
+ {0x00000000, 0x60000000, 0x73333333, 0x7d70a3d7},
+};
+
+/**************************************************************************************
+ * Function: CVKernel1
+ *
+ * Description: kernel of covariance matrix calculation for p01, p11, p12, p22
+ *
+ * Inputs: buffer of low-freq samples, starting at time index = 0,
+ * freq index = patch subband
+ *
+ * Outputs: 64-bit accumulators for p01re, p01im, p12re, p12im, p11re, p22re
+ * stored in accBuf
+ *
+ * Return: none
+ *
+ * Notes: this is carefully written to be efficient on ARM
+ * use the assembly code version in sbrcov.s when building for ARM!
+ **************************************************************************************/
+#if 0// (defined (__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(__arm__))
+#ifdef __cplusplus
+extern "C"
+#endif
+void CVKernel1(int *XBuf, int *accBuf);
+#else
+void CVKernel1(int *XBuf, int *accBuf)
+{
+ U64 p01re, p01im, p12re, p12im, p11re, p22re;
+ int n, x0re, x0im, x1re, x1im;
+
+ x0re = XBuf[0];
+ x0im = XBuf[1];
+ XBuf += (2 * 64);
+ x1re = XBuf[0];
+ x1im = XBuf[1];
+ XBuf += (2 * 64);
+
+ p01re.w64 = p01im.w64 = 0;
+ p12re.w64 = p12im.w64 = 0;
+ p11re.w64 = 0;
+ p22re.w64 = 0;
+
+ p12re.w64 = MADD64(p12re.w64, x1re, x0re);
+ p12re.w64 = MADD64(p12re.w64, x1im, x0im);
+ p12im.w64 = MADD64(p12im.w64, x0re, x1im);
+ p12im.w64 = MADD64(p12im.w64, -x0im, x1re);
+ p22re.w64 = MADD64(p22re.w64, x0re, x0re);
+ p22re.w64 = MADD64(p22re.w64, x0im, x0im);
+ for (n = (NUM_TIME_SLOTS * SAMPLES_PER_SLOT + 6); n != 0; n--) {
+ /* 4 input, 3*2 acc, 1 ptr, 1 loop counter = 12 registers (use same for x0im, -x0im) */
+ x0re = x1re;
+ x0im = x1im;
+ x1re = XBuf[0];
+ x1im = XBuf[1];
+
+ p01re.w64 = MADD64(p01re.w64, x1re, x0re);
+ p01re.w64 = MADD64(p01re.w64, x1im, x0im);
+ p01im.w64 = MADD64(p01im.w64, x0re, x1im);
+ p01im.w64 = MADD64(p01im.w64, -x0im, x1re);
+ p11re.w64 = MADD64(p11re.w64, x0re, x0re);
+ p11re.w64 = MADD64(p11re.w64, x0im, x0im);
+
+ XBuf += (2 * 64);
+ }
+ /* these can be derived by slight changes to account for boundary conditions */
+ p12re.w64 += p01re.w64;
+ p12re.w64 = MADD64(p12re.w64, x1re, -x0re);
+ p12re.w64 = MADD64(p12re.w64, x1im, -x0im);
+ p12im.w64 += p01im.w64;
+ p12im.w64 = MADD64(p12im.w64, x0re, -x1im);
+ p12im.w64 = MADD64(p12im.w64, x0im, x1re);
+ p22re.w64 += p11re.w64;
+ p22re.w64 = MADD64(p22re.w64, x0re, -x0re);
+ p22re.w64 = MADD64(p22re.w64, x0im, -x0im);
+
+ accBuf[0] = p01re.r.lo32;
+ accBuf[1] = p01re.r.hi32;
+ accBuf[2] = p01im.r.lo32;
+ accBuf[3] = p01im.r.hi32;
+ accBuf[4] = p11re.r.lo32;
+ accBuf[5] = p11re.r.hi32;
+ accBuf[6] = p12re.r.lo32;
+ accBuf[7] = p12re.r.hi32;
+ accBuf[8] = p12im.r.lo32;
+ accBuf[9] = p12im.r.hi32;
+ accBuf[10] = p22re.r.lo32;
+ accBuf[11] = p22re.r.hi32;
+}
+#endif
+
+/**************************************************************************************
+ * Function: CalcCovariance1
+ *
+ * Description: calculate covariance matrix for p01, p12, p11, p22 (4.6.18.6.2)
+ *
+ * Inputs: buffer of low-freq samples, starting at time index 0,
+ * freq index = patch subband
+ *
+ * Outputs: complex covariance elements p01re, p01im, p12re, p12im, p11re, p22re
+ * (p11im = p22im = 0)
+ * format = integer (Q0) * 2^N, with scalefactor N >= 0
+ *
+ * Return: scalefactor N
+ *
+ * Notes: outputs are normalized to have 1 GB (sign in at least top 2 bits)
+ **************************************************************************************/
+static int CalcCovariance1(int *XBuf, int *p01reN, int *p01imN, int *p12reN, int *p12imN, int *p11reN, int *p22reN)
+{
+ int accBuf[2 * 6];
+ int n, z, s, loShift, hiShift, gbMask;
+ U64 p01re, p01im, p12re, p12im, p11re, p22re;
+
+ CVKernel1(XBuf, accBuf);
+ p01re.r.lo32 = accBuf[0];
+ p01re.r.hi32 = accBuf[1];
+ p01im.r.lo32 = accBuf[2];
+ p01im.r.hi32 = accBuf[3];
+ p11re.r.lo32 = accBuf[4];
+ p11re.r.hi32 = accBuf[5];
+ p12re.r.lo32 = accBuf[6];
+ p12re.r.hi32 = accBuf[7];
+ p12im.r.lo32 = accBuf[8];
+ p12im.r.hi32 = accBuf[9];
+ p22re.r.lo32 = accBuf[10];
+ p22re.r.hi32 = accBuf[11];
+
+ /* 64-bit accumulators now have 2*FBITS_OUT_QMFA fraction bits
+ * want to scale them down to integers (32-bit signed, Q0)
+ * with scale factor of 2^n, n >= 0
+ * leave 2 GB's for calculating determinant, so take top 30 non-zero bits
+ */
+ gbMask = ((p01re.r.hi32) ^(p01re.r.hi32 >> 31)) | ((p01im.r.hi32) ^(p01im.r.hi32 >> 31));
+ gbMask |= ((p12re.r.hi32) ^(p12re.r.hi32 >> 31)) | ((p12im.r.hi32) ^(p12im.r.hi32 >> 31));
+ gbMask |= ((p11re.r.hi32) ^(p11re.r.hi32 >> 31)) | ((p22re.r.hi32) ^(p22re.r.hi32 >> 31));
+ if (gbMask == 0) {
+ s = p01re.r.hi32 >> 31;
+ gbMask = (p01re.r.lo32 ^ s) - s;
+ s = p01im.r.hi32 >> 31;
+ gbMask |= (p01im.r.lo32 ^ s) - s;
+ s = p12re.r.hi32 >> 31;
+ gbMask |= (p12re.r.lo32 ^ s) - s;
+ s = p12im.r.hi32 >> 31;
+ gbMask |= (p12im.r.lo32 ^ s) - s;
+ s = p11re.r.hi32 >> 31;
+ gbMask |= (p11re.r.lo32 ^ s) - s;
+ s = p22re.r.hi32 >> 31;
+ gbMask |= (p22re.r.lo32 ^ s) - s;
+ z = 32 + CLZ(gbMask);
+ } else {
+ gbMask = FASTABS(p01re.r.hi32) | FASTABS(p01im.r.hi32);
+ gbMask |= FASTABS(p12re.r.hi32) | FASTABS(p12im.r.hi32);
+ gbMask |= FASTABS(p11re.r.hi32) | FASTABS(p22re.r.hi32);
+ z = CLZ(gbMask);
+ }
+
+ n = 64 - z; /* number of non-zero bits in bottom of 64-bit word */
+ if (n <= 30) {
+ loShift = (30 - n);
+ *p01reN = p01re.r.lo32 << loShift;
+ *p01imN = p01im.r.lo32 << loShift;
+ *p12reN = p12re.r.lo32 << loShift;
+ *p12imN = p12im.r.lo32 << loShift;
+ *p11reN = p11re.r.lo32 << loShift;
+ *p22reN = p22re.r.lo32 << loShift;
+ return -(loShift + 2 * FBITS_OUT_QMFA);
+ } else if (n < 32 + 30) {
+ loShift = (n - 30);
+ hiShift = 32 - loShift;
+ *p01reN = (p01re.r.hi32 << hiShift) | (p01re.r.lo32 >> loShift);
+ *p01imN = (p01im.r.hi32 << hiShift) | (p01im.r.lo32 >> loShift);
+ *p12reN = (p12re.r.hi32 << hiShift) | (p12re.r.lo32 >> loShift);
+ *p12imN = (p12im.r.hi32 << hiShift) | (p12im.r.lo32 >> loShift);
+ *p11reN = (p11re.r.hi32 << hiShift) | (p11re.r.lo32 >> loShift);
+ *p22reN = (p22re.r.hi32 << hiShift) | (p22re.r.lo32 >> loShift);
+ return (loShift - 2 * FBITS_OUT_QMFA);
+ } else {
+ hiShift = n - (32 + 30);
+ *p01reN = p01re.r.hi32 >> hiShift;
+ *p01imN = p01im.r.hi32 >> hiShift;
+ *p12reN = p12re.r.hi32 >> hiShift;
+ *p12imN = p12im.r.hi32 >> hiShift;
+ *p11reN = p11re.r.hi32 >> hiShift;
+ *p22reN = p22re.r.hi32 >> hiShift;
+ return (32 - 2 * FBITS_OUT_QMFA - hiShift);
+ }
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: CVKernel2
+ *
+ * Description: kernel of covariance matrix calculation for p02
+ *
+ * Inputs: buffer of low-freq samples, starting at time index = 0,
+ * freq index = patch subband
+ *
+ * Outputs: 64-bit accumulators for p02re, p02im stored in accBuf
+ *
+ * Return: none
+ *
+ * Notes: this is carefully written to be efficient on ARM
+ * use the assembly code version in sbrcov.s when building for ARM!
+ **************************************************************************************/
+#if 0// (defined (__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(__arm__))
+#ifdef __cplusplus
+extern "C"
+#endif
+void CVKernel2(int *XBuf, int *accBuf);
+#else
+void CVKernel2(int *XBuf, int *accBuf)
+{
+ U64 p02re, p02im;
+ int n, x0re, x0im, x1re, x1im, x2re, x2im;
+
+ p02re.w64 = p02im.w64 = 0;
+
+ x0re = XBuf[0];
+ x0im = XBuf[1];
+ XBuf += (2 * 64);
+ x1re = XBuf[0];
+ x1im = XBuf[1];
+ XBuf += (2 * 64);
+
+ for (n = (NUM_TIME_SLOTS * SAMPLES_PER_SLOT + 6); n != 0; n--) {
+ /* 6 input, 2*2 acc, 1 ptr, 1 loop counter = 12 registers (use same for x0im, -x0im) */
+ x2re = XBuf[0];
+ x2im = XBuf[1];
+
+ p02re.w64 = MADD64(p02re.w64, x2re, x0re);
+ p02re.w64 = MADD64(p02re.w64, x2im, x0im);
+ p02im.w64 = MADD64(p02im.w64, x0re, x2im);
+ p02im.w64 = MADD64(p02im.w64, -x0im, x2re);
+
+ x0re = x1re;
+ x0im = x1im;
+ x1re = x2re;
+ x1im = x2im;
+ XBuf += (2 * 64);
+ }
+
+ accBuf[0] = p02re.r.lo32;
+ accBuf[1] = p02re.r.hi32;
+ accBuf[2] = p02im.r.lo32;
+ accBuf[3] = p02im.r.hi32;
+}
+#endif
+
+/**************************************************************************************
+ * Function: CalcCovariance2
+ *
+ * Description: calculate covariance matrix for p02 (4.6.18.6.2)
+ *
+ * Inputs: buffer of low-freq samples, starting at time index = 0,
+ * freq index = patch subband
+ *
+ * Outputs: complex covariance element p02re, p02im
+ * format = integer (Q0) * 2^N, with scalefactor N >= 0
+ *
+ * Return: scalefactor N
+ *
+ * Notes: outputs are normalized to have 1 GB (sign in at least top 2 bits)
+ **************************************************************************************/
+static int CalcCovariance2(int *XBuf, int *p02reN, int *p02imN)
+{
+ U64 p02re, p02im;
+ int n, z, s, loShift, hiShift, gbMask;
+ int accBuf[2 * 2];
+
+ CVKernel2(XBuf, accBuf);
+ p02re.r.lo32 = accBuf[0];
+ p02re.r.hi32 = accBuf[1];
+ p02im.r.lo32 = accBuf[2];
+ p02im.r.hi32 = accBuf[3];
+
+ /* 64-bit accumulators now have 2*FBITS_OUT_QMFA fraction bits
+ * want to scale them down to integers (32-bit signed, Q0)
+ * with scale factor of 2^n, n >= 0
+ * leave 1 GB for calculating determinant, so take top 30 non-zero bits
+ */
+ gbMask = ((p02re.r.hi32) ^(p02re.r.hi32 >> 31)) | ((p02im.r.hi32) ^(p02im.r.hi32 >> 31));
+ if (gbMask == 0) {
+ s = p02re.r.hi32 >> 31;
+ gbMask = (p02re.r.lo32 ^ s) - s;
+ s = p02im.r.hi32 >> 31;
+ gbMask |= (p02im.r.lo32 ^ s) - s;
+ z = 32 + CLZ(gbMask);
+ } else {
+ gbMask = FASTABS(p02re.r.hi32) | FASTABS(p02im.r.hi32);
+ z = CLZ(gbMask);
+ }
+ n = 64 - z; /* number of non-zero bits in bottom of 64-bit word */
+
+ if (n <= 30) {
+ loShift = (30 - n);
+ *p02reN = p02re.r.lo32 << loShift;
+ *p02imN = p02im.r.lo32 << loShift;
+ return -(loShift + 2 * FBITS_OUT_QMFA);
+ } else if (n < 32 + 30) {
+ loShift = (n - 30);
+ hiShift = 32 - loShift;
+ *p02reN = (p02re.r.hi32 << hiShift) | (p02re.r.lo32 >> loShift);
+ *p02imN = (p02im.r.hi32 << hiShift) | (p02im.r.lo32 >> loShift);
+ return (loShift - 2 * FBITS_OUT_QMFA);
+ } else {
+ hiShift = n - (32 + 30);
+ *p02reN = p02re.r.hi32 >> hiShift;
+ *p02imN = p02im.r.hi32 >> hiShift;
+ return (32 - 2 * FBITS_OUT_QMFA - hiShift);
+ }
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: CalcLPCoefs
+ *
+ * Description: calculate linear prediction coefficients for one subband (4.6.18.6.2)
+ *
+ * Inputs: buffer of low-freq samples, starting at time index = 0,
+ * freq index = patch subband
+ * number of guard bits in input sample buffer
+ *
+ * Outputs: complex LP coefficients a0re, a0im, a1re, a1im, format = Q29
+ *
+ * Return: none
+ *
+ * Notes: output coefficients (a0re, a0im, a1re, a1im) clipped to range (-4, 4)
+ * if the comples coefficients have magnitude >= 4.0, they are all
+ * set to 0 (see spec)
+ **************************************************************************************/
+static int CalcLPCoefs(int *XBuf, int *a0re, int *a0im, int *a1re, int *a1im, int gb)
+{
+ int zFlag, n1, n2, nd, d, dInv, tre, tim;
+ int p01re, p01im, p02re, p02im, p12re, p12im, p11re, p22re;
+
+ /* pre-scale to avoid overflow - probably never happens in practice (see QMFA)
+ * max bit growth per accumulator = 38*2 = 76 mul-adds (X * X)
+ * using 64-bit MADD, so if X has n guard bits, X*X has 2n+1 guard bits
+ * gain 1 extra sign bit per multiply, so ensure ceil(log2(76/2) / 2) = 3 guard bits on inputs
+ */
+ if (gb < 3) {
+ nd = 3 - gb;
+ for (n1 = (NUM_TIME_SLOTS * SAMPLES_PER_SLOT + 6 + 2); n1 != 0; n1--) {
+ XBuf[0] >>= nd;
+ XBuf[1] >>= nd;
+ XBuf += (2 * 64);
+ }
+ XBuf -= (2 * 64 * (NUM_TIME_SLOTS * SAMPLES_PER_SLOT + 6 + 2));
+ }
+
+ /* calculate covariance elements */
+ n1 = CalcCovariance1(XBuf, &p01re, &p01im, &p12re, &p12im, &p11re, &p22re);
+ n2 = CalcCovariance2(XBuf, &p02re, &p02im);
+
+ /* normalize everything to larger power of 2 scalefactor, call it n1 */
+ if (n1 < n2) {
+ nd = MIN(n2 - n1, 31);
+ p01re >>= nd;
+ p01im >>= nd;
+ p12re >>= nd;
+ p12im >>= nd;
+ p11re >>= nd;
+ p22re >>= nd;
+ n1 = n2;
+ } else if (n1 > n2) {
+ nd = MIN(n1 - n2, 31);
+ p02re >>= nd;
+ p02im >>= nd;
+ }
+
+ /* calculate determinant of covariance matrix (at least 1 GB in pXX) */
+ d = MULSHIFT32(p12re, p12re) + MULSHIFT32(p12im, p12im);
+ d = MULSHIFT32(d, RELAX_COEF) << 1;
+ d = MULSHIFT32(p11re, p22re) - d;
+ //this assert always failed,no a fatal error when decoder sbr data ????.
+ //ASSERT(d >= 0,ERR_AAC_SBR_BITSTREAM); /* should never be < 0 */
+
+ zFlag = 0;
+ *a0re = *a0im = 0;
+ *a1re = *a1im = 0;
+ if (d > 0) {
+ /* input = Q31 d = Q(-2*n1 - 32 + nd) = Q31 * 2^(31 + 2*n1 + 32 - nd)
+ * inverse = Q29 dInv = Q29 * 2^(-31 - 2*n1 - 32 + nd) = Q(29 + 31 + 2*n1 + 32 - nd)
+ *
+ * numerator has same Q format as d, since it's sum of normalized squares
+ * so num * inverse = Q(-2*n1 - 32) * Q(29 + 31 + 2*n1 + 32 - nd)
+ * = Q(29 + 31 - nd), drop low 32 in MULSHIFT32
+ * = Q(29 + 31 - 32 - nd) = Q(28 - nd)
+ */
+ nd = CLZ(d) - 1;
+ d <<= nd;
+ dInv = InvRNormalized(d);
+
+ /* 1 GB in pXX */
+ tre = MULSHIFT32(p01re, p12re) - MULSHIFT32(p01im, p12im) - MULSHIFT32(p02re, p11re);
+ tre = MULSHIFT32(tre, dInv);
+ tim = MULSHIFT32(p01re, p12im) + MULSHIFT32(p01im, p12re) - MULSHIFT32(p02im, p11re);
+ tim = MULSHIFT32(tim, dInv);
+
+ /* if d is extremely small, just set coefs to 0 (would have poor precision anyway) */
+ if (nd > 28 || (FASTABS(tre) >> (28 - nd)) >= 4 || (FASTABS(tim) >> (28 - nd)) >= 4) {
+ zFlag = 1;
+ } else {
+ *a1re = tre << (FBITS_LPCOEFS - 28 + nd); /* i.e. convert Q(28 - nd) to Q(29) */
+ *a1im = tim << (FBITS_LPCOEFS - 28 + nd);
+ }
+ }
+
+ if (p11re) {
+ /* input = Q31 p11re = Q(-n1 + nd) = Q31 * 2^(31 + n1 - nd)
+ * inverse = Q29 dInv = Q29 * 2^(-31 - n1 + nd) = Q(29 + 31 + n1 - nd)
+ *
+ * numerator is Q(-n1 - 3)
+ * so num * inverse = Q(-n1 - 3) * Q(29 + 31 + n1 - nd)
+ * = Q(29 + 31 - 3 - nd), drop low 32 in MULSHIFT32
+ * = Q(29 + 31 - 3 - 32 - nd) = Q(25 - nd)
+ */
+ nd = CLZ(p11re) - 1; /* assume positive */
+ p11re <<= nd;
+ dInv = InvRNormalized(p11re);
+
+ /* a1re, a1im = Q29, so scaled by (n1 + 3) */
+ tre = (p01re >> 3) + MULSHIFT32(p12re, *a1re) + MULSHIFT32(p12im, *a1im);
+ tre = -MULSHIFT32(tre, dInv);
+ tim = (p01im >> 3) - MULSHIFT32(p12im, *a1re) + MULSHIFT32(p12re, *a1im);
+ tim = -MULSHIFT32(tim, dInv);
+
+ if (nd > 25 || (FASTABS(tre) >> (25 - nd)) >= 4 || (FASTABS(tim) >> (25 - nd)) >= 4) {
+ zFlag = 1;
+ } else {
+ *a0re = tre << (FBITS_LPCOEFS - 25 + nd); /* i.e. convert Q(25 - nd) to Q(29) */
+ *a0im = tim << (FBITS_LPCOEFS - 25 + nd);
+ }
+ }
+
+ /* see 4.6.18.6.2 - if magnitude of a0 or a1 >= 4 then a0 = a1 = 0
+ * i.e. a0re < 4, a0im < 4, a1re < 4, a1im < 4
+ * Q29*Q29 = Q26
+ */
+ if (zFlag || MULSHIFT32(*a0re, *a0re) + MULSHIFT32(*a0im, *a0im) >= MAG_16 || MULSHIFT32(*a1re, *a1re) + MULSHIFT32(*a1im, *a1im) >= MAG_16) {
+ *a0re = *a0im = 0;
+ *a1re = *a1im = 0;
+ }
+
+ /* no need to clip - we never changed the XBuf data, just used it to calculate a0 and a1 */
+ if (gb < 3) {
+ nd = 3 - gb;
+ for (n1 = (NUM_TIME_SLOTS * SAMPLES_PER_SLOT + 6 + 2); n1 != 0; n1--) {
+ XBuf[0] <<= nd;
+ XBuf[1] <<= nd;
+ XBuf += (2 * 64);
+ }
+ }
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: GenerateHighFreq
+ *
+ * Description: generate high frequencies with SBR (4.6.18.6)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ *
+ * Outputs: new high frequency samples starting at frequency kStart
+ *
+ * Return: none
+ **************************************************************************************/
+int GenerateHighFreq(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch)
+{
+ int band, newBW, c, t, gb, gbMask, gbIdx;
+ int currPatch, p, x, k, g, i, iStart, iEnd, bw, bwsq;
+ int a0re, a0im, a1re, a1im;
+ int x1re, x1im, x2re, x2im;
+ int ACCre, ACCim;
+ int *XBufLo, *XBufHi;
+ int err = ERR_AAC_NONE;
+ /* calculate array of chirp factors */
+ for (band = 0; band < sbrFreq->numNoiseFloorBands; band++) {
+ c = sbrChan->chirpFact[band]; /* previous (bwArray') */
+ newBW = newBWTab[sbrChan->invfMode[0][band]][sbrChan->invfMode[1][band]];
+
+ /* weighted average of new and old (can't overflow - total gain = 1.0) */
+ if (newBW < c) {
+ t = MULSHIFT32(newBW, 0x60000000) + MULSHIFT32(0x20000000, c); /* new is smaller: 0.75*new + 0.25*old */
+ } else {
+ t = MULSHIFT32(newBW, 0x74000000) + MULSHIFT32(0x0c000000, c); /* new is larger: 0.90625*new + 0.09375*old */
+ }
+ t <<= 1;
+
+ if (t < 0x02000000) { /* below 0.015625, clip to 0 */
+ t = 0;
+ }
+ if (t > 0x7f800000) { /* clip to 0.99609375 */
+ t = 0x7f800000;
+ }
+
+ /* save curr as prev for next time */
+ sbrChan->chirpFact[band] = t;
+ sbrChan->invfMode[0][band] = sbrChan->invfMode[1][band];
+ }
+
+ iStart = sbrGrid->envTimeBorder[0] + HF_ADJ;
+ iEnd = sbrGrid->envTimeBorder[sbrGrid->numEnv] + HF_ADJ;
+
+ /* generate new high freqs from low freqs, patches, and chirp factors */
+ k = sbrFreq->kStart;
+ g = 0;
+ bw = sbrChan->chirpFact[g];
+ bwsq = MULSHIFT32(bw, bw) << 1;
+
+ gbMask = (sbrChan->gbMask[0] | sbrChan->gbMask[1]); /* older 32 | newer 8 */
+ gb = CLZ(gbMask) - 1;
+
+ for (currPatch = 0; currPatch < sbrFreq->numPatches; currPatch++) {
+ for (x = 0; x < sbrFreq->patchNumSubbands[currPatch]; x++) {
+ /* map k to corresponding noise floor band */
+ if (k >= sbrFreq->freqNoise[g + 1]) {
+ g++;
+ bw = sbrChan->chirpFact[g]; /* Q31 */
+ bwsq = MULSHIFT32(bw, bw) << 1; /* Q31 */
+ }
+
+ p = sbrFreq->patchStartSubband[currPatch] + x; /* low QMF band */
+ XBufHi = psi->XBuf[iStart][k];
+ if (bw) {
+ err = CalcLPCoefs(psi->XBuf[0][p], &a0re, &a0im, &a1re, &a1im, gb);
+ if (err) {
+ return err;
+ }
+ a0re = MULSHIFT32(bw, a0re); /* Q31 * Q29 = Q28 */
+ a0im = MULSHIFT32(bw, a0im);
+ a1re = MULSHIFT32(bwsq, a1re);
+ a1im = MULSHIFT32(bwsq, a1im);
+
+ XBufLo = psi->XBuf[iStart - 2][p];
+
+ x2re = XBufLo[0]; /* RE{XBuf[n-2]} */
+ x2im = XBufLo[1]; /* IM{XBuf[n-2]} */
+ XBufLo += (64 * 2);
+
+ x1re = XBufLo[0]; /* RE{XBuf[n-1]} */
+ x1im = XBufLo[1]; /* IM{XBuf[n-1]} */
+ XBufLo += (64 * 2);
+
+ for (i = iStart; i < iEnd; i++) {
+ /* a0re/im, a1re/im are Q28 with at least 1 GB,
+ * so the summing for AACre/im is fine (1 GB in, plus 1 from MULSHIFT32)
+ */
+ ACCre = MULSHIFT32(x2re, a1re) - MULSHIFT32(x2im, a1im);
+ ACCim = MULSHIFT32(x2re, a1im) + MULSHIFT32(x2im, a1re);
+ x2re = x1re;
+ x2im = x1im;
+
+ ACCre += MULSHIFT32(x1re, a0re) - MULSHIFT32(x1im, a0im);
+ ACCim += MULSHIFT32(x1re, a0im) + MULSHIFT32(x1im, a0re);
+ x1re = XBufLo[0]; /* RE{XBuf[n]} */
+ x1im = XBufLo[1]; /* IM{XBuf[n]} */
+ XBufLo += (64 * 2);
+
+ /* lost 4 fbits when scaling by a0re/im, a1re/im (Q28) */
+ CLIP_2N_SHIFT30(ACCre, 4);
+ ACCre += x1re;
+ CLIP_2N_SHIFT30(ACCim, 4);
+ ACCim += x1im;
+
+ XBufHi[0] = ACCre;
+ XBufHi[1] = ACCim;
+ XBufHi += (64 * 2);
+
+ /* update guard bit masks */
+ gbMask = FASTABS(ACCre);
+ gbMask |= FASTABS(ACCim);
+ gbIdx = (i >> 5) & 0x01; /* 0 if i < 32, 1 if i >= 32 */
+ sbrChan->gbMask[gbIdx] |= gbMask;
+ }
+ } else {
+ XBufLo = (int *)psi->XBuf[iStart][p];
+ for (i = iStart; i < iEnd; i++) {
+ XBufHi[0] = XBufLo[0];
+ XBufHi[1] = XBufLo[1];
+ XBufLo += (64 * 2);
+ XBufHi += (64 * 2);
+ }
+ }
+ k++; /* high QMF band */
+ }
+ }
+ return ERR_AAC_NONE;
+}
+
+
diff --git a/audio_codec/libfaad/helixaac/sbrhuff.c b/audio_codec/libfaad/helixaac/sbrhuff.c
new file mode 100644
index 0000000..35e759f
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/sbrhuff.c
@@ -0,0 +1,494 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrhuff.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrhuff.c - functions for unpacking Huffman-coded envelope and noise data
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+/**************************************************************************************
+ * Function: DecodeHuffmanScalar
+ *
+ * Description: decode one Huffman symbol from bitstream
+ *
+ * Inputs: pointers to Huffman table and info struct
+ * left-aligned bit buffer with >= huffTabInfo->maxBits bits
+ *
+ * Outputs: decoded symbol in *val
+ *
+ * Return: number of bits in symbol
+ *
+ * Notes: assumes canonical Huffman codes:
+ * first CW always 0, we have "count" CW's of length "nBits" bits
+ * starting CW for codes of length nBits+1 =
+ * (startCW[nBits] + count[nBits]) << 1
+ * if there are no codes at nBits, then we just keep << 1 each time
+ * (since count[nBits] = 0)
+ **************************************************************************************/
+static int DecodeHuffmanScalar(const signed short *huffTab, const HuffInfo *huffTabInfo, unsigned int bitBuf, signed int *val)
+{
+ unsigned int count, start, shift, t;
+ const unsigned char *countPtr;
+ const signed short *map;
+
+ map = huffTab + huffTabInfo->offset;
+ countPtr = huffTabInfo->count;
+
+ start = 0;
+ count = 0;
+ shift = 32;
+ do {
+ start += count;
+ start <<= 1;
+ map += count;
+ count = *countPtr++;
+ shift--;
+ t = (bitBuf >> shift) - start;
+ } while (t >= count);
+
+ *val = (signed int)map[t];
+ return (countPtr - huffTabInfo->count);
+}
+
+/**************************************************************************************
+ * Function: DecodeOneSymbol
+ *
+ * Description: dequantize one Huffman symbol from bitstream,
+ * using table huffTabSBR[huffTabIndex]
+ *
+ * Inputs: BitStreamInfo struct pointing to start of next Huffman codeword
+ * index of Huffman table
+ *
+ * Outputs: bitstream advanced by number of bits in codeword
+ *
+ * Return: one decoded symbol
+ **************************************************************************************/
+static int DecodeOneSymbol(BitStreamInfo *bsi, int huffTabIndex)
+{
+ int nBits, val;
+ unsigned int bitBuf;
+ const HuffInfo *hi;
+
+ hi = &(huffTabSBRInfo[huffTabIndex]);
+
+ bitBuf = GetBitsNoAdvance(bsi, hi->maxBits) << (32 - hi->maxBits);
+ nBits = DecodeHuffmanScalar(huffTabSBR, hi, bitBuf, &val);
+ AdvanceBitstream(bsi, nBits);
+
+ return val;
+}
+
+/* [1.0, sqrt(2)], format = Q29 (one guard bit for decoupling) */
+static const int envDQTab[2] = {0x20000000, 0x2d413ccc};
+
+/**************************************************************************************
+ * Function: DequantizeEnvelope
+ *
+ * Description: dequantize envelope scalefactors
+ *
+ * Inputs: number of scalefactors to process
+ * amplitude resolution flag for this frame (0 or 1)
+ * quantized envelope scalefactors
+ *
+ * Outputs: dequantized envelope scalefactors
+ *
+ * Return: extra int bits in output (6 + expMax)
+ * in other words, output format = Q(FBITS_OUT_DQ_ENV - (6 + expMax))
+ *
+ * Notes: dequantized scalefactors have at least 2 GB
+ **************************************************************************************/
+static int DequantizeEnvelope(int nBands, int ampRes, signed char *envQuant, int *envDequant)
+{
+ int exp, expMax, i, scalei;
+
+ if (nBands <= 0) {
+ return 0;
+ }
+
+ /* scan for largest dequant value (do separately from envelope decoding to keep code cleaner) */
+ expMax = 0;
+ for (i = 0; i < nBands; i++) {
+ if (envQuant[i] > expMax) {
+ expMax = envQuant[i];
+ }
+ }
+
+ /* dequantized envelope gains
+ * envDequant = 64*2^(envQuant / alpha) = 2^(6 + envQuant / alpha)
+ * if ampRes == 0, alpha = 2 and range of envQuant = [0, 127]
+ * if ampRes == 1, alpha = 1 and range of envQuant = [0, 63]
+ * also if coupling is on, envDequant is scaled by something in range [0, 2]
+ * so range of envDequant = [2^6, 2^69] (no coupling), [2^6, 2^70] (with coupling)
+ *
+ * typical range (from observation) of envQuant/alpha = [0, 27] --> largest envQuant ~= 2^33
+ * output: Q(29 - (6 + expMax))
+ *
+ * reference: 14496-3:2001(E)/4.6.18.3.5 and 14496-4:200X/FPDAM8/5.6.5.1.2.1.5
+ */
+ if (ampRes) {
+ do {
+ exp = *envQuant++;
+ scalei = MIN(expMax - exp, 31);
+ *envDequant++ = envDQTab[0] >> scalei;
+ } while (--nBands);
+
+ return (6 + expMax);
+ } else {
+ expMax >>= 1;
+ do {
+ exp = *envQuant++;
+ scalei = MIN(expMax - (exp >> 1), 31);
+ *envDequant++ = envDQTab[exp & 0x01] >> scalei;
+ } while (--nBands);
+
+ return (6 + expMax);
+ }
+
+}
+
+/**************************************************************************************
+ * Function: DequantizeNoise
+ *
+ * Description: dequantize noise scalefactors
+ *
+ * Inputs: number of scalefactors to process
+ * quantized noise scalefactors
+ *
+ * Outputs: dequantized noise scalefactors, format = Q(FBITS_OUT_DQ_NOISE)
+ *
+ * Return: none
+ *
+ * Notes: dequantized scalefactors have at least 2 GB
+ **************************************************************************************/
+static void DequantizeNoise(int nBands, signed char *noiseQuant, int *noiseDequant)
+{
+ int exp, scalei;
+
+ if (nBands <= 0) {
+ return;
+ }
+
+ /* dequantize noise floor gains (4.6.18.3.5):
+ * noiseDequant = 2^(NOISE_FLOOR_OFFSET - noiseQuant)
+ *
+ * range of noiseQuant = [0, 30] (see 4.6.18.3.6), NOISE_FLOOR_OFFSET = 6
+ * so range of noiseDequant = [2^-24, 2^6]
+ */
+ do {
+ exp = *noiseQuant++;
+ scalei = NOISE_FLOOR_OFFSET - exp + FBITS_OUT_DQ_NOISE; /* 6 + 24 - exp, exp = [0,30] */
+
+ if (scalei < 0) {
+ *noiseDequant++ = 0;
+ } else if (scalei < 30) {
+ *noiseDequant++ = 1 << scalei;
+ } else {
+ *noiseDequant++ = 0x3fffffff; /* leave 2 GB */
+ }
+
+ } while (--nBands);
+}
+
+/**************************************************************************************
+ * Function: DecodeSBREnvelope
+ *
+ * Description: decode delta Huffman coded envelope scalefactors from bitstream
+ *
+ * Inputs: BitStreamInfo struct pointing to start of env data
+ * initialized PSInfoSBR struct
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ *
+ * Outputs: dequantized env scalefactors for left channel (before decoupling)
+ * dequantized env scalefactors for right channel (if coupling off)
+ * or raw decoded env scalefactors for right channel (if coupling on)
+ *
+ * Return: none
+ **************************************************************************************/
+int DecodeSBREnvelope(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch)
+{
+ int huffIndexTime, huffIndexFreq, env, envStartBits, band, nBands, sf, lastEnv;
+ int freqRes, freqResPrev, dShift, i;
+
+ if (psi->couplingFlag && ch) {
+ dShift = 1;
+ if (sbrGrid->ampResFrame) {
+ huffIndexTime = HuffTabSBR_tEnv30b;
+ huffIndexFreq = HuffTabSBR_fEnv30b;
+ envStartBits = 5;
+ } else {
+ huffIndexTime = HuffTabSBR_tEnv15b;
+ huffIndexFreq = HuffTabSBR_fEnv15b;
+ envStartBits = 6;
+ }
+ } else {
+ dShift = 0;
+ if (sbrGrid->ampResFrame) {
+ huffIndexTime = HuffTabSBR_tEnv30;
+ huffIndexFreq = HuffTabSBR_fEnv30;
+ envStartBits = 6;
+ } else {
+ huffIndexTime = HuffTabSBR_tEnv15;
+ huffIndexFreq = HuffTabSBR_fEnv15;
+ envStartBits = 7;
+ }
+ }
+
+ /* range of envDataQuant[] = [0, 127] (see comments in DequantizeEnvelope() for reference) */
+ for (env = 0; env < sbrGrid->numEnv; env++) {
+ nBands = (sbrGrid->freqRes[env] ? sbrFreq->nHigh : sbrFreq->nLow);
+ freqRes = (sbrGrid->freqRes[env]);
+ freqResPrev = (env == 0 ? sbrGrid->freqResPrev : sbrGrid->freqRes[env - 1]);
+ lastEnv = (env == 0 ? sbrGrid->numEnvPrev - 1 : env - 1);
+ if (lastEnv < 0) {
+ lastEnv = 0; /* first frame */
+ }
+
+ ASSERT(nBands <= MAX_QMF_BANDS, ERR_AAC_SBR_BITSTREAM);
+
+ if (sbrChan->deltaFlagEnv[env] == 0) {
+ /* delta coding in freq */
+ sf = GetBits(bsi, envStartBits) << dShift;
+ sbrChan->envDataQuant[env][0] = sf;
+ for (band = 1; band < nBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexFreq) << dShift;
+ sbrChan->envDataQuant[env][band] = sf + sbrChan->envDataQuant[env][band - 1];
+ }
+ } else if (freqRes == freqResPrev) {
+ /* delta coding in time - same freq resolution for both frames */
+ for (band = 0; band < nBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift;
+ sbrChan->envDataQuant[env][band] = sf + sbrChan->envDataQuant[lastEnv][band];
+ }
+ } else if (freqRes == 0 && freqResPrev == 1) {
+ /* delta coding in time - low freq resolution for new frame, high freq resolution for old frame */
+ for (band = 0; band < nBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift;
+ sbrChan->envDataQuant[env][band] = sf;
+ for (i = 0; i < sbrFreq->nHigh; i++) {
+ if (sbrFreq->freqHigh[i] == sbrFreq->freqLow[band]) {
+ sbrChan->envDataQuant[env][band] += sbrChan->envDataQuant[lastEnv][i];
+ break;
+ }
+ }
+ }
+ } else if (freqRes == 1 && freqResPrev == 0) {
+ /* delta coding in time - high freq resolution for new frame, low freq resolution for old frame */
+ for (band = 0; band < nBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift;
+ sbrChan->envDataQuant[env][band] = sf;
+ for (i = 0; i < sbrFreq->nLow; i++) {
+ if (sbrFreq->freqLow[i] <= sbrFreq->freqHigh[band] && sbrFreq->freqHigh[band] < sbrFreq->freqLow[i + 1]) {
+ sbrChan->envDataQuant[env][band] += sbrChan->envDataQuant[lastEnv][i];
+ break;
+ }
+ }
+ }
+ }
+
+ /* skip coupling channel */
+ if (ch != 1 || psi->couplingFlag != 1) {
+ psi->envDataDequantScale[ch][env] = DequantizeEnvelope(nBands, sbrGrid->ampResFrame, sbrChan->envDataQuant[env], psi->envDataDequant[ch][env]);
+ }
+ }
+ sbrGrid->numEnvPrev = sbrGrid->numEnv;
+ sbrGrid->freqResPrev = sbrGrid->freqRes[sbrGrid->numEnv - 1];
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: DecodeSBRNoise
+ *
+ * Description: decode delta Huffman coded noise scalefactors from bitstream
+ *
+ * Inputs: BitStreamInfo struct pointing to start of noise data
+ * initialized PSInfoSBR struct
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ *
+ * Outputs: dequantized noise scalefactors for left channel (before decoupling)
+ * dequantized noise scalefactors for right channel (if coupling off)
+ * or raw decoded noise scalefactors for right channel (if coupling on)
+ *
+ * Return: none
+ **************************************************************************************/
+int DecodeSBRNoise(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch)
+{
+ int huffIndexTime, huffIndexFreq, noiseFloor, band, dShift, sf, lastNoiseFloor;
+
+ if (psi->couplingFlag && ch) {
+ dShift = 1;
+ huffIndexTime = HuffTabSBR_tNoise30b;
+ huffIndexFreq = HuffTabSBR_fNoise30b;
+ } else {
+ dShift = 0;
+ huffIndexTime = HuffTabSBR_tNoise30;
+ huffIndexFreq = HuffTabSBR_fNoise30;
+ }
+
+ for (noiseFloor = 0; noiseFloor < sbrGrid->numNoiseFloors; noiseFloor++) {
+ lastNoiseFloor = (noiseFloor == 0 ? sbrGrid->numNoiseFloorsPrev - 1 : noiseFloor - 1);
+ if (lastNoiseFloor < 0) {
+ lastNoiseFloor = 0; /* first frame */
+ }
+
+ ASSERT(sbrFreq->numNoiseFloorBands <= MAX_QMF_BANDS, ERR_AAC_SBR_BITSTREAM);
+
+ if (sbrChan->deltaFlagNoise[noiseFloor] == 0) {
+ /* delta coding in freq */
+ sbrChan->noiseDataQuant[noiseFloor][0] = GetBits(bsi, 5) << dShift;
+ for (band = 1; band < sbrFreq->numNoiseFloorBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexFreq) << dShift;
+ sbrChan->noiseDataQuant[noiseFloor][band] = sf + sbrChan->noiseDataQuant[noiseFloor][band - 1];
+ }
+ } else {
+ /* delta coding in time */
+ for (band = 0; band < sbrFreq->numNoiseFloorBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift;
+ sbrChan->noiseDataQuant[noiseFloor][band] = sf + sbrChan->noiseDataQuant[lastNoiseFloor][band];
+ }
+ }
+
+ /* skip coupling channel */
+ if (ch != 1 || psi->couplingFlag != 1) {
+ DequantizeNoise(sbrFreq->numNoiseFloorBands, sbrChan->noiseDataQuant[noiseFloor], psi->noiseDataDequant[ch][noiseFloor]);
+ }
+ }
+ sbrGrid->numNoiseFloorsPrev = sbrGrid->numNoiseFloors;
+ return ERR_AAC_NONE;
+}
+
+/* dqTabCouple[i] = 2 / (1 + 2^(12 - i)), format = Q30 */
+static const int dqTabCouple[25] = {
+ 0x0007ff80, 0x000ffe00, 0x001ff802, 0x003fe010, 0x007f8080, 0x00fe03f8, 0x01f81f82, 0x03e0f83e,
+ 0x07878788, 0x0e38e38e, 0x1999999a, 0x2aaaaaab, 0x40000000, 0x55555555, 0x66666666, 0x71c71c72,
+ 0x78787878, 0x7c1f07c2, 0x7e07e07e, 0x7f01fc08, 0x7f807f80, 0x7fc01ff0, 0x7fe007fe, 0x7ff00200,
+ 0x7ff80080,
+};
+
+/**************************************************************************************
+ * Function: UncoupleSBREnvelope
+ *
+ * Description: scale dequantized envelope scalefactors according to channel
+ * coupling rules
+ *
+ * Inputs: initialized PSInfoSBR struct including
+ * dequantized envelope data for left channel
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for right channel including
+ * quantized envelope scalefactors
+ *
+ * Outputs: dequantized envelope data for left channel (after decoupling)
+ * dequantized envelope data for right channel (after decoupling)
+ *
+ * Return: none
+ **************************************************************************************/
+void UncoupleSBREnvelope(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR)
+{
+ int env, band, nBands, scalei, E_1;
+
+ scalei = (sbrGrid->ampResFrame ? 0 : 1);
+ for (env = 0; env < sbrGrid->numEnv; env++) {
+ nBands = (sbrGrid->freqRes[env] ? sbrFreq->nHigh : sbrFreq->nLow);
+ psi->envDataDequantScale[1][env] = psi->envDataDequantScale[0][env]; /* same scalefactor for L and R */
+ for (band = 0; band < nBands; band++) {
+ /* clip E_1 to [0, 24] (scalefactors approach 0 or 2) */
+ E_1 = sbrChanR->envDataQuant[env][band] >> scalei;
+ if (E_1 < 0) {
+ E_1 = 0;
+ }
+ if (E_1 > 24) {
+ E_1 = 24;
+ }
+
+ /* envDataDequant[0] has 1 GB, so << by 2 is okay */
+ psi->envDataDequant[1][env][band] = MULSHIFT32(psi->envDataDequant[0][env][band], dqTabCouple[24 - E_1]) << 2;
+ psi->envDataDequant[0][env][band] = MULSHIFT32(psi->envDataDequant[0][env][band], dqTabCouple[E_1]) << 2;
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: UncoupleSBRNoise
+ *
+ * Description: scale dequantized noise floor scalefactors according to channel
+ * coupling rules
+ *
+ * Inputs: initialized PSInfoSBR struct including
+ * dequantized noise data for left channel
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel including
+ * quantized noise scalefactors
+ *
+ * Outputs: dequantized noise data for left channel (after decoupling)
+ * dequantized noise data for right channel (after decoupling)
+ *
+ * Return: none
+ **************************************************************************************/
+void UncoupleSBRNoise(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR)
+{
+ int noiseFloor, band, Q_1;
+
+ for (noiseFloor = 0; noiseFloor < sbrGrid->numNoiseFloors; noiseFloor++) {
+ for (band = 0; band < sbrFreq->numNoiseFloorBands; band++) {
+ /* Q_1 should be in range [0, 24] according to 4.6.18.3.6, but check to make sure */
+ Q_1 = sbrChanR->noiseDataQuant[noiseFloor][band];
+ if (Q_1 < 0) {
+ Q_1 = 0;
+ }
+ if (Q_1 > 24) {
+ Q_1 = 24;
+ }
+
+ /* noiseDataDequant[0] has 1 GB, so << by 2 is okay */
+ psi->noiseDataDequant[1][noiseFloor][band] = MULSHIFT32(psi->noiseDataDequant[0][noiseFloor][band], dqTabCouple[24 - Q_1]) << 2;
+ psi->noiseDataDequant[0][noiseFloor][band] = MULSHIFT32(psi->noiseDataDequant[0][noiseFloor][band], dqTabCouple[Q_1]) << 2;
+ }
+ }
+}
diff --git a/audio_codec/libfaad/helixaac/sbrimdct.c b/audio_codec/libfaad/helixaac/sbrimdct.c
new file mode 100644
index 0000000..abec008
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/sbrimdct.c
@@ -0,0 +1,447 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrimdct.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrimdct.c - inverse MDCT without clipping or interleaving, for input to SBR
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+/**************************************************************************************
+ * Function: DecWindowOverlapNoClip
+ *
+ * Description: apply synthesis window, do overlap-add without clipping,
+ * for winSequence LONG-LONG
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 32-bit PCM, non-interleaved
+ *
+ * Return: none
+ *
+ * Notes: use this function when the decoded PCM is going to the SBR decoder
+ **************************************************************************************/
+void DecWindowOverlapNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev)
+{
+ int in, w0, w1, f0, f1;
+ int *buf1, *over1, *out1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ out1 = out0 + 1024 - 1;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ if (winTypeCurr == winTypePrev) {
+ /* cut window loads in half since current and overlap sections use same symmetric window */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ } else {
+ /* different windows for current and overlap parts - should still fit in registers on ARM w/o stack spill */
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapLongStart
+ *
+ * Description: apply synthesis window, do overlap-add, without clipping
+ * for winSequence LONG-START
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 32-bit PCM, non-interleaved
+ *
+ * Return: none
+ *
+ * Notes: use this function when the decoded PCM is going to the SBR decoder
+ **************************************************************************************/
+void DecWindowOverlapLongStartNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1, *out1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ out1 = out0 + 1024 - 1;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ i = 448; /* 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ in = *buf1--;
+
+ *over1-- = 0; /* Wn = 0 for n = (2047, 2046, ... 1600) */
+ *over0++ = in >> 1; /* Wn = 1 for n = (1024, 1025, ... 1471) */
+ } while (--i);
+
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+
+ /* do 64 more loops - 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ w0 = *wndCurr++; /* W[0], W[1], ... --> W[255], W[254], ... */
+ w1 = *wndCurr++; /* W[127], W[126], ... --> W[128], W[129], ... */
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in); /* Wn = short window for n = (1599, 1598, ... , 1536) */
+ *over0++ = MULSHIFT32(w1, in); /* Wn = short window for n = (1472, 1473, ... , 1535) */
+ } while (over0 < over1);
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapLongStop
+ *
+ * Description: apply synthesis window, do overlap-add, without clipping
+ * for winSequence LONG-STOP
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 32-bit PCM, non-interleaved
+ *
+ * Return: none
+ *
+ * Notes: use this function when the decoded PCM is going to the SBR decoder
+ **************************************************************************************/
+void DecWindowOverlapLongStopNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1, *out1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ out1 = out0 + 1024 - 1;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+
+ i = 448; /* 2 outputs, 2 overlaps per loop */
+ do {
+ /* Wn = 0 for n = (0, 1, ... 447) */
+ /* Wn = 1 for n = (576, 577, ... 1023) */
+ in = *buf0++;
+ f1 = in >> 1; /* scale since skipping multiply by Q31 */
+
+ in = *over0;
+ *out0++ = in;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (--i);
+
+ /* do 64 more loops - 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++; /* W[0], W[1], ...W[63] */
+ w1 = *wndPrev++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapShort
+ *
+ * Description: apply synthesis window, do overlap-add, without clipping
+ * for winSequence EIGHT-SHORT (does all 8 short blocks)
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 32-bit PCM, non-interleaved
+ *
+ * Return: none
+ *
+ * Notes: use this function when the decoded PCM is going to the SBR decoder
+ **************************************************************************************/
+void DecWindowOverlapShortNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1, *out1;
+ const int *wndPrev, *wndCurr;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+
+ /* pcm[0-447] = 0 + overlap[0-447] */
+ i = 448;
+ do {
+ f0 = *over0++;
+ f1 = *over0++;
+ *out0++ = f0;
+ *out0++ = f1;
+ i -= 2;
+ } while (i);
+
+ /* pcm[448-575] = Wp[0-127] * block0[0-127] + overlap[448-575] */
+ out1 = out0 + (128 - 1);
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ do {
+ w0 = *wndPrev++; /* W[0], W[1], ...W[63] */
+ w1 = *wndPrev++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ /* save over0/over1 for next short block, in the slots just vacated */
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+
+ /* pcm[576-703] = Wc[128-255] * block0[128-255] + Wc[0-127] * block1[0-127] + overlap[576-703]
+ * pcm[704-831] = Wc[128-255] * block1[128-255] + Wc[0-127] * block2[0-127] + overlap[704-831]
+ * pcm[832-959] = Wc[128-255] * block2[128-255] + Wc[0-127] * block3[0-127] + overlap[832-959]
+ */
+ for (i = 0; i < 3; i++) {
+ out0 += 64;
+ out1 = out0 + 128 - 1;
+ over0 += 64;
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *(over0 - 128); /* from last short block */
+ in += *(over0 + 0); /* from last full frame */
+ *out0++ = in - f0;
+
+ in = *(over1 - 128); /* from last short block */
+ in += *(over1 + 0); /* from last full frame */
+ *out1-- = in + f1;
+
+ /* save over0/over1 for next short block, in the slots just vacated */
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+
+ /* pcm[960-1023] = Wc[128-191] * block3[128-191] + Wc[0-63] * block4[0-63] + overlap[960-1023]
+ * over[0-63] = Wc[192-255] * block3[192-255] + Wc[64-127] * block4[64-127]
+ */
+ out0 += 64;
+ over0 -= 832; /* points at overlap[64] */
+ over1 = over0 + 128 - 1; /* points at overlap[191] */
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *(over0 + 768); /* from last short block */
+ in += *(over0 + 896); /* from last full frame */
+ *out0++ = in - f0;
+
+ in = *(over1 + 768); /* from last short block */
+ *(over1 - 128) = in + f1;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in); /* save in overlap[128-191] */
+ *over0++ = MULSHIFT32(w1, in); /* save in overlap[64-127] */
+ } while (over0 < over1);
+
+ /* over0 now points at overlap[128] */
+
+ /* over[64-191] = Wc[128-255] * block4[128-255] + Wc[0-127] * block5[0-127]
+ * over[192-319] = Wc[128-255] * block5[128-255] + Wc[0-127] * block6[0-127]
+ * over[320-447] = Wc[128-255] * block6[128-255] + Wc[0-127] * block7[0-127]
+ * over[448-576] = Wc[128-255] * block7[128-255]
+ */
+ for (i = 0; i < 3; i++) {
+ over0 += 64;
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ /* from last short block */
+ *(over0 - 128) -= f0;
+ *(over1 - 128) += f1;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+
+ /* over[576-1024] = 0 */
+ i = 448;
+ over0 += 64;
+ do {
+ *over0++ = 0;
+ *over0++ = 0;
+ *over0++ = 0;
+ *over0++ = 0;
+ i -= 4;
+ } while (i);
+}
diff --git a/audio_codec/libfaad/helixaac/sbrmath.c b/audio_codec/libfaad/helixaac/sbrmath.c
new file mode 100644
index 0000000..784f909
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/sbrmath.c
@@ -0,0 +1,198 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrmath.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrmath.c - fixed-point math functions for SBR
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+#define Q28_2 0x20000000 /* Q28: 2.0 */
+#define Q28_15 0x30000000 /* Q28: 1.5 */
+
+#define NUM_ITER_IRN 5
+
+/**************************************************************************************
+ * Function: InvRNormalized
+ *
+ * Description: use Newton's method to solve for x = 1/r
+ *
+ * Inputs: r = Q31, range = [0.5, 1) (normalize your inputs to this range)
+ *
+ * Outputs: none
+ *
+ * Return: x = Q29, range ~= [1.0, 2.0]
+ *
+ * Notes: guaranteed to converge and not overflow for any r in [0.5, 1)
+ *
+ * xn+1 = xn - f(xn)/f'(xn)
+ * f(x) = 1/r - x = 0 (find root)
+ * = 1/x - r
+ * f'(x) = -1/x^2
+ *
+ * so xn+1 = xn - (1/xn - r) / (-1/xn^2)
+ * = xn * (2 - r*xn)
+ *
+ * NUM_ITER_IRN = 2, maxDiff = 6.2500e-02 (precision of about 4 bits)
+ * NUM_ITER_IRN = 3, maxDiff = 3.9063e-03 (precision of about 8 bits)
+ * NUM_ITER_IRN = 4, maxDiff = 1.5288e-05 (precision of about 16 bits)
+ * NUM_ITER_IRN = 5, maxDiff = 3.0034e-08 (precision of about 24 bits)
+ **************************************************************************************/
+int InvRNormalized(int r)
+{
+ int i, xn, t;
+
+ /* r = [0.5, 1.0)
+ * 1/r = (1.0, 2.0]
+ * so use 1.5 as initial guess
+ */
+ xn = Q28_15;
+
+ /* xn = xn*(2.0 - r*xn) */
+ for (i = NUM_ITER_IRN; i != 0; i--) {
+ t = MULSHIFT32(r, xn); /* Q31*Q29 = Q28 */
+ t = Q28_2 - t; /* Q28 */
+ xn = MULSHIFT32(xn, t) << 4; /* Q29*Q28 << 4 = Q29 */
+ }
+
+ return xn;
+}
+
+#define NUM_TERMS_RPI 5
+#define LOG2_EXP_INV 0x58b90bfc /* 1/log2(e), Q31 */
+
+/* invTab[x] = 1/(x+1), format = Q30 */
+static const int invTab[NUM_TERMS_RPI] = {0x40000000, 0x20000000, 0x15555555, 0x10000000, 0x0ccccccd};
+
+/**************************************************************************************
+ * Function: RatioPowInv
+ *
+ * Description: use Taylor (MacLaurin) series expansion to calculate (a/b) ^ (1/c)
+ *
+ * Inputs: a = [1, 64], b = [1, 64], c = [1, 64], a >= b
+ *
+ * Outputs: none
+ *
+ * Return: y = Q24, range ~= [0.015625, 64]
+ **************************************************************************************/
+int RatioPowInv(int a, int b, int c)
+{
+ int lna, lnb, i, p, t, y;
+
+ if (a < 1 || b < 1 || c < 1 || a > 64 || b > 64 || c > 64 || a < b) {
+ return 0;
+ }
+
+ lna = MULSHIFT32(log2Tab[a], LOG2_EXP_INV) << 1; /* ln(a), Q28 */
+ lnb = MULSHIFT32(log2Tab[b], LOG2_EXP_INV) << 1; /* ln(b), Q28 */
+ p = (lna - lnb) / c; /* Q28 */
+
+ /* sum in Q24 */
+ y = (1 << 24);
+ t = p >> 4; /* t = p^1 * 1/1! (Q24)*/
+ y += t;
+
+ for (i = 2; i <= NUM_TERMS_RPI; i++) {
+ t = MULSHIFT32(invTab[i - 1], t) << 2;
+ t = MULSHIFT32(p, t) << 4; /* t = p^i * 1/i! (Q24) */
+ y += t;
+ }
+
+ return y;
+}
+
+/**************************************************************************************
+ * Function: SqrtFix
+ *
+ * Description: use binary search to calculate sqrt(q)
+ *
+ * Inputs: q = Q30
+ * number of fraction bits in input
+ *
+ * Outputs: number of fraction bits in output
+ *
+ * Return: lo = Q(fBitsOut)
+ *
+ * Notes: absolute precision varies depending on fBitsIn
+ * normalizes input to range [0x200000000, 0x7fffffff] and takes
+ * floor(sqrt(input)), and sets fBitsOut appropriately
+ **************************************************************************************/
+int SqrtFix(int q, int fBitsIn, int *fBitsOut)
+{
+ int z, lo, hi, mid;
+
+ if (q <= 0) {
+ *fBitsOut = fBitsIn;
+ return 0;
+ }
+
+ /* force even fBitsIn */
+ z = fBitsIn & 0x01;
+ q >>= z;
+ fBitsIn -= z;
+
+ /* for max precision, normalize to [0x20000000, 0x7fffffff] */
+ z = (CLZ(q) - 1);
+ z >>= 1;
+ q <<= (2 * z);
+
+ /* choose initial bounds */
+ lo = 1;
+ if (q >= 0x10000000) {
+ lo = 16384; /* (int)sqrt(0x10000000) */
+ }
+ hi = 46340; /* (int)sqrt(0x7fffffff) */
+
+ /* do binary search with 32x32->32 multiply test */
+ do {
+ mid = (lo + hi) >> 1;
+ if (mid * mid > q) {
+ hi = mid - 1;
+ } else {
+ lo = mid + 1;
+ }
+ } while (hi >= lo);
+ lo--;
+
+ *fBitsOut = ((fBitsIn + 2 * z) >> 1);
+ return lo;
+}
diff --git a/audio_codec/libfaad/helixaac/sbrqmf.c b/audio_codec/libfaad/helixaac/sbrqmf.c
new file mode 100644
index 0000000..6a9464a
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/sbrqmf.c
@@ -0,0 +1,648 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrqmf.c,v 1.1.2.2 2005/05/19 21:00:01 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrqmf.c - analysis and synthesis QMF filters for SBR
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+/* PreMultiply64() table
+ * format = Q30
+ * reordered for sequential access
+ *
+ * for (i = 0; i < 64/4; i++) {
+ * angle = (i + 0.25) * M_PI / nmdct;
+ * x = (cos(angle) + sin(angle));
+ * x = sin(angle);
+ *
+ * angle = (nmdct/2 - 1 - i + 0.25) * M_PI / nmdct;
+ * x = (cos(angle) + sin(angle));
+ * x = sin(angle);
+ * }
+ */
+static const int cos4sin4tab64[64] = {
+ 0x40c7d2bd, 0x00c90e90, 0x424ff28f, 0x3ff4e5e0, 0x43cdd89a, 0x03ecadcf, 0x454149fc, 0x3fc395f9,
+ 0x46aa0d6d, 0x070de172, 0x4807eb4b, 0x3f6af2e3, 0x495aada2, 0x0a2abb59, 0x4aa22036, 0x3eeb3347,
+ 0x4bde1089, 0x0d415013, 0x4d0e4de2, 0x3e44a5ef, 0x4e32a956, 0x104fb80e, 0x4f4af5d1, 0x3d77b192,
+ 0x50570819, 0x135410c3, 0x5156b6d9, 0x3c84d496, 0x5249daa2, 0x164c7ddd, 0x53304df6, 0x3b6ca4c4,
+ 0x5409ed4b, 0x19372a64, 0x54d69714, 0x3a2fcee8, 0x55962bc0, 0x1c1249d8, 0x56488dc5, 0x38cf1669,
+ 0x56eda1a0, 0x1edc1953, 0x57854ddd, 0x374b54ce, 0x580f7b19, 0x2192e09b, 0x588c1404, 0x35a5793c,
+ 0x58fb0568, 0x2434f332, 0x595c3e2a, 0x33de87de, 0x59afaf4c, 0x26c0b162, 0x59f54bee, 0x31f79948,
+ 0x5a2d0957, 0x29348937, 0x5a56deec, 0x2ff1d9c7, 0x5a72c63b, 0x2b8ef77d, 0x5a80baf6, 0x2dce88aa,
+};
+
+/* PostMultiply64() table
+ * format = Q30
+ * reordered for sequential access
+ *
+ * for (i = 0; i <= (32/2); i++) {
+ * angle = i * M_PI / 64;
+ * x = (cos(angle) + sin(angle));
+ * x = sin(angle);
+ * }
+ */
+static const int cos1sin1tab64[34] = {
+ 0x40000000, 0x00000000, 0x43103085, 0x0323ecbe, 0x45f704f7, 0x0645e9af, 0x48b2b335, 0x09640837,
+ 0x4b418bbe, 0x0c7c5c1e, 0x4da1fab5, 0x0f8cfcbe, 0x4fd288dc, 0x1294062f, 0x51d1dc80, 0x158f9a76,
+ 0x539eba45, 0x187de2a7, 0x553805f2, 0x1b5d100a, 0x569cc31b, 0x1e2b5d38, 0x57cc15bc, 0x20e70f32,
+ 0x58c542c5, 0x238e7673, 0x5987b08a, 0x261feffa, 0x5a12e720, 0x2899e64a, 0x5a6690ae, 0x2afad269,
+ 0x5a82799a, 0x2d413ccd,
+};
+
+/**************************************************************************************
+ * Function: PreMultiply64
+ *
+ * Description: pre-twiddle stage of 64-point DCT-IV
+ *
+ * Inputs: buffer of 64 samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: minimum 1 GB in, 2 GB out, gains 2 int bits
+ * gbOut = gbIn + 1
+ * output is limited to sqrt(2)/2 plus GB in full GB
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ **************************************************************************************/
+static void PreMultiply64(int *zbuf1)
+{
+ int i, ar1, ai1, ar2, ai2, z1, z2;
+ int t, cms2, cps2a, sin2a, cps2b, sin2b;
+ int *zbuf2;
+ const int *csptr;
+
+ zbuf2 = zbuf1 + 64 - 1;
+ csptr = cos4sin4tab64;
+
+ /* whole thing should fit in registers - verify that compiler does this */
+ for (i = 64 >> 2; i != 0; i--) {
+ /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */
+ cps2a = *csptr++;
+ sin2a = *csptr++;
+ cps2b = *csptr++;
+ sin2b = *csptr++;
+
+ ar1 = *(zbuf1 + 0);
+ ai2 = *(zbuf1 + 1);
+ ai1 = *(zbuf2 + 0);
+ ar2 = *(zbuf2 - 1);
+
+ /* gain 2 ints bit from MULSHIFT32 by Q30
+ * max per-sample gain (ignoring implicit scaling) = MAX(sin(angle)+cos(angle)) = 1.414
+ * i.e. gain 1 GB since worst case is sin(angle) = cos(angle) = 0.707 (Q30), gain 2 from
+ * extra sign bits, and eat one in adding
+ */
+ t = MULSHIFT32(sin2a, ar1 + ai1);
+ z2 = MULSHIFT32(cps2a, ai1) - t;
+ cms2 = cps2a - 2 * sin2a;
+ z1 = MULSHIFT32(cms2, ar1) + t;
+ *zbuf1++ = z1; /* cos*ar1 + sin*ai1 */
+ *zbuf1++ = z2; /* cos*ai1 - sin*ar1 */
+
+ t = MULSHIFT32(sin2b, ar2 + ai2);
+ z2 = MULSHIFT32(cps2b, ai2) - t;
+ cms2 = cps2b - 2 * sin2b;
+ z1 = MULSHIFT32(cms2, ar2) + t;
+ *zbuf2-- = z2; /* cos*ai2 - sin*ar2 */
+ *zbuf2-- = z1; /* cos*ar2 + sin*ai2 */
+ }
+}
+
+/**************************************************************************************
+ * Function: PostMultiply64
+ *
+ * Description: post-twiddle stage of 64-point type-IV DCT
+ *
+ * Inputs: buffer of 64 samples
+ * number of output samples to calculate
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: minimum 1 GB in, 2 GB out, gains 2 int bits
+ * gbOut = gbIn + 1
+ * output is limited to sqrt(2)/2 plus GB in full GB
+ * nSampsOut is rounded up to next multiple of 4, since we calculate
+ * 4 samples per loop
+ **************************************************************************************/
+static void PostMultiply64(int *fft1, int nSampsOut)
+{
+ int i, ar1, ai1, ar2, ai2;
+ int t, cms2, cps2, sin2;
+ int *fft2;
+ const int *csptr;
+
+ csptr = cos1sin1tab64;
+ fft2 = fft1 + 64 - 1;
+
+ /* load coeffs for first pass
+ * cps2 = (cos+sin)/2, sin2 = sin/2, cms2 = (cos-sin)/2
+ */
+ cps2 = *csptr++;
+ sin2 = *csptr++;
+ cms2 = cps2 - 2 * sin2;
+
+ for (i = (nSampsOut + 3) >> 2; i != 0; i--) {
+ ar1 = *(fft1 + 0);
+ ai1 = *(fft1 + 1);
+ ar2 = *(fft2 - 1);
+ ai2 = *(fft2 + 0);
+
+ /* gain 2 int bits (multiplying by Q30), max gain = sqrt(2) */
+ t = MULSHIFT32(sin2, ar1 + ai1);
+ *fft2-- = t - MULSHIFT32(cps2, ai1);
+ *fft1++ = t + MULSHIFT32(cms2, ar1);
+
+ cps2 = *csptr++;
+ sin2 = *csptr++;
+
+ ai2 = -ai2;
+ t = MULSHIFT32(sin2, ar2 + ai2);
+ *fft2-- = t - MULSHIFT32(cps2, ai2);
+ cms2 = cps2 - 2 * sin2;
+ *fft1++ = t + MULSHIFT32(cms2, ar2);
+ }
+}
+
+/**************************************************************************************
+ * Function: QMFAnalysisConv
+ *
+ * Description: convolution kernel for analysis QMF
+ *
+ * Inputs: pointer to coefficient table, reordered for sequential access
+ * delay buffer of size 32*10 = 320 real-valued PCM samples
+ * index for delay ring buffer (range = [0, 9])
+ *
+ * Outputs: 64 consecutive 32-bit samples
+ *
+ * Return: none
+ *
+ * Notes: this is carefully written to be efficient on ARM
+ * use the assembly code version in sbrqmfak.s when building for ARM!
+ **************************************************************************************/
+#if 0// (defined (__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(__arm__))
+#ifdef __cplusplus
+extern "C"
+#endif
+void QMFAnalysisConv(int *cTab, int *delay, int dIdx, int *uBuf);
+#else
+void QMFAnalysisConv(int *cTab, int *delay, int dIdx, int *uBuf)
+{
+ int k, dOff;
+ int *cPtr0, *cPtr1;
+ U64 u64lo, u64hi;
+
+ dOff = dIdx * 32 + 31;
+ cPtr0 = cTab;
+ cPtr1 = cTab + 33 * 5 - 1;
+
+ /* special first pass since we need to flip sign to create cTab[384], cTab[512] */
+ u64lo.w64 = 0;
+ u64hi.w64 = 0;
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, -(*cPtr1--), delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, -(*cPtr1--), delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+
+ uBuf[0] = u64lo.r.hi32;
+ uBuf[32] = u64hi.r.hi32;
+ uBuf++;
+ dOff--;
+
+ /* max gain for any sample in uBuf, after scaling by cTab, ~= 0.99
+ * so we can just sum the uBuf values with no overflow problems
+ */
+ for (k = 1; k <= 31; k++) {
+ u64lo.w64 = 0;
+ u64hi.w64 = 0;
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+
+ uBuf[0] = u64lo.r.hi32;
+ uBuf[32] = u64hi.r.hi32;
+ uBuf++;
+ dOff--;
+ }
+}
+#endif
+
+/**************************************************************************************
+ * Function: QMFAnalysis
+ *
+ * Description: 32-subband analysis QMF (4.6.18.4.1)
+ *
+ * Inputs: 32 consecutive samples of decoded 32-bit PCM, format = Q(fBitsIn)
+ * delay buffer of size 32*10 = 320 PCM samples
+ * number of fraction bits in input PCM
+ * index for delay ring buffer (range = [0, 9])
+ * number of subbands to calculate (range = [0, 32])
+ *
+ * Outputs: qmfaBands complex subband samples, format = Q(FBITS_OUT_QMFA)
+ * updated delay buffer
+ * updated delay index
+ *
+ * Return: guard bit mask
+ *
+ * Notes: output stored as RE{X0}, IM{X0}, RE{X1}, IM{X1}, ... RE{X31}, IM{X31}
+ * output stored in int buffer of size 64*2 = 128
+ * (zero-filled from XBuf[2*qmfaBands] to XBuf[127])
+ **************************************************************************************/
+int QMFAnalysis(int *inbuf, int *delay, int *XBuf, int fBitsIn, int *delayIdx, int qmfaBands)
+{
+ int n, y, shift, gbMask;
+ int *delayPtr, *uBuf, *tBuf;
+
+ /* use XBuf[128] as temp buffer for reordering */
+ uBuf = XBuf; /* first 64 samples */
+ tBuf = XBuf + 64; /* second 64 samples */
+
+ /* overwrite oldest PCM with new PCM
+ * delay[n] has 1 GB after shifting (either << or >>)
+ */
+ delayPtr = delay + (*delayIdx * 32);
+ if (fBitsIn > FBITS_IN_QMFA) {
+ shift = MIN(fBitsIn - FBITS_IN_QMFA, 31);
+ for (n = 32; n != 0; n--) {
+ y = (*inbuf) >> shift;
+ inbuf++;
+ *delayPtr++ = y;
+ }
+ } else {
+ shift = MIN(FBITS_IN_QMFA - fBitsIn, 30);
+ for (n = 32; n != 0; n--) {
+ y = *inbuf++;
+ CLIP_2N_SHIFT30(y, shift);
+ *delayPtr++ = y;
+ }
+ }
+
+ QMFAnalysisConv((int *)cTabA, delay, *delayIdx, uBuf);
+
+ /* uBuf has at least 2 GB right now (1 from clipping to Q(FBITS_IN_QMFA), one from
+ * the scaling by cTab (MULSHIFT32(*delayPtr--, *cPtr++), with net gain of < 1.0)
+ * TODO - fuse with QMFAnalysisConv to avoid separate reordering
+ */
+ tBuf[2 * 0 + 0] = uBuf[0];
+ tBuf[2 * 0 + 1] = uBuf[1];
+ for (n = 1; n < 31; n++) {
+ tBuf[2 * n + 0] = -uBuf[64 - n];
+ tBuf[2 * n + 1] = uBuf[n + 1];
+ }
+ tBuf[2 * 31 + 1] = uBuf[32];
+ tBuf[2 * 31 + 0] = -uBuf[33];
+
+ /* fast in-place DCT-IV - only need 2*qmfaBands output samples */
+ PreMultiply64(tBuf); /* 2 GB in, 3 GB out */
+ FFT32C(tBuf); /* 3 GB in, 1 GB out */
+ PostMultiply64(tBuf, qmfaBands * 2); /* 1 GB in, 2 GB out */
+
+ /* TODO - roll into PostMultiply (if enough registers) */
+ gbMask = 0;
+ for (n = 0; n < qmfaBands; n++) {
+ XBuf[2 * n + 0] = tBuf[ n + 0]; /* implicit scaling of 2 in our output Q format */
+ gbMask |= FASTABS(XBuf[2 * n + 0]);
+ XBuf[2 * n + 1] = -tBuf[63 - n];
+ gbMask |= FASTABS(XBuf[2 * n + 1]);
+ }
+
+ /* fill top section with zeros for HF generation */
+ for (; n < 64; n++) {
+ XBuf[2 * n + 0] = 0;
+ XBuf[2 * n + 1] = 0;
+ }
+
+ *delayIdx = (*delayIdx == NUM_QMF_DELAY_BUFS - 1 ? 0 : *delayIdx + 1);
+
+ /* minimum of 2 GB in output */
+ return gbMask;
+}
+
+/* lose FBITS_LOST_DCT4_64 in DCT4, gain 6 for implicit scaling by 1/64, lose 1 for cTab multiply (Q31) */
+#define FBITS_OUT_QMFS (FBITS_IN_QMFS - FBITS_LOST_DCT4_64 + 6 - 1)
+#define RND_VAL (1 << (FBITS_OUT_QMFS-1))
+
+/**************************************************************************************
+ * Function: QMFSynthesisConv
+ *
+ * Description: final convolution kernel for synthesis QMF
+ *
+ * Inputs: pointer to coefficient table, reordered for sequential access
+ * delay buffer of size 64*10 = 640 complex samples (1280 ints)
+ * index for delay ring buffer (range = [0, 9])
+ * number of QMF subbands to process (range = [0, 64])
+ * number of channels
+ *
+ * Outputs: 64 consecutive 16-bit PCM samples, interleaved by factor of nChans
+ *
+ * Return: none
+ *
+ * Notes: this is carefully written to be efficient on ARM
+ * use the assembly code version in sbrqmfsk.s when building for ARM!
+ **************************************************************************************/
+#if 0// (defined (__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(__arm__))
+#ifdef __cplusplus
+extern "C"
+#endif
+void QMFSynthesisConv(int *cPtr, int *delay, int dIdx, short *outbuf, int nChans);
+#else
+void QMFSynthesisConv(int *cPtr, int *delay, int dIdx, short *outbuf, int nChans)
+{
+ int k, dOff0, dOff1;
+ U64 sum64;
+
+ dOff0 = (dIdx) * 128;
+ dOff1 = dOff0 - 1;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+
+ /* scaling note: total gain of coefs (cPtr[0]-cPtr[9] for any k) is < 2.0, so 1 GB in delay values is adequate */
+ for (k = 0; k <= 63; k++) {
+ sum64.w64 = 0;
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]);
+ dOff0 -= 256;
+ if (dOff0 < 0) {
+ dOff0 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]);
+ dOff1 -= 256;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]);
+ dOff0 -= 256;
+ if (dOff0 < 0) {
+ dOff0 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]);
+ dOff1 -= 256;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]);
+ dOff0 -= 256;
+ if (dOff0 < 0) {
+ dOff0 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]);
+ dOff1 -= 256;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]);
+ dOff0 -= 256;
+ if (dOff0 < 0) {
+ dOff0 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]);
+ dOff1 -= 256;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]);
+ dOff0 -= 256;
+ if (dOff0 < 0) {
+ dOff0 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]);
+ dOff1 -= 256;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+
+ dOff0++;
+ dOff1--;
+ *outbuf = CLIPTOSHORT((sum64.r.hi32 + RND_VAL) >> FBITS_OUT_QMFS);
+ outbuf += nChans;
+ }
+}
+#endif
+
+/**************************************************************************************
+ * Function: QMFSynthesis
+ *
+ * Description: 64-subband synthesis QMF (4.6.18.4.2)
+ *
+ * Inputs: 64 consecutive complex subband QMF samples, format = Q(FBITS_IN_QMFS)
+ * delay buffer of size 64*10 = 640 complex samples (1280 ints)
+ * index for delay ring buffer (range = [0, 9])
+ * number of QMF subbands to process (range = [0, 64])
+ * number of channels
+ *
+ * Outputs: 64 consecutive 16-bit PCM samples, interleaved by factor of nChans
+ * updated delay buffer
+ * updated delay index
+ *
+ * Return: none
+ *
+ * Notes: assumes MIN_GBITS_IN_QMFS guard bits in input, either from
+ * QMFAnalysis (if upsampling only) or from MapHF (if SBR on)
+ **************************************************************************************/
+void QMFSynthesis(int *inbuf, int *delay, int *delayIdx, int qmfsBands, short *outbuf, int nChans)
+{
+ int n, a0, a1, b0, b1, dOff0, dOff1, dIdx;
+ int *tBufLo, *tBufHi;
+
+ dIdx = *delayIdx;
+ tBufLo = delay + dIdx * 128 + 0;
+ tBufHi = delay + dIdx * 128 + 127;
+
+ /* reorder inputs to DCT-IV, only use first qmfsBands (complex) samples
+ * TODO - fuse with PreMultiply64 to avoid separate reordering steps
+ */
+ for (n = 0; n < qmfsBands >> 1; n++) {
+ a0 = *inbuf++;
+ b0 = *inbuf++;
+ a1 = *inbuf++;
+ b1 = *inbuf++;
+ *tBufLo++ = a0;
+ *tBufLo++ = a1;
+ *tBufHi-- = b0;
+ *tBufHi-- = b1;
+ }
+ if (qmfsBands & 0x01) {
+ a0 = *inbuf++;
+ b0 = *inbuf++;
+ *tBufLo++ = a0;
+ *tBufHi-- = b0;
+ *tBufLo++ = 0;
+ *tBufHi-- = 0;
+ n++;
+ }
+ for (; n < 32; n++) {
+ *tBufLo++ = 0;
+ *tBufHi-- = 0;
+ *tBufLo++ = 0;
+ *tBufHi-- = 0;
+ }
+
+ tBufLo = delay + dIdx * 128 + 0;
+ tBufHi = delay + dIdx * 128 + 64;
+
+ /* 2 GB in, 3 GB out */
+ PreMultiply64(tBufLo);
+ PreMultiply64(tBufHi);
+
+ /* 3 GB in, 1 GB out */
+ FFT32C(tBufLo);
+ FFT32C(tBufHi);
+
+ /* 1 GB in, 2 GB out */
+ PostMultiply64(tBufLo, 64);
+ PostMultiply64(tBufHi, 64);
+
+ /* could fuse with PostMultiply64 to avoid separate pass */
+ dOff0 = dIdx * 128;
+ dOff1 = dIdx * 128 + 64;
+ for (n = 32; n != 0; n--) {
+ a0 = (*tBufLo++);
+ a1 = (*tBufLo++);
+ b0 = (*tBufHi++);
+ b1 = -(*tBufHi++);
+
+ delay[dOff0++] = (b0 - a0);
+ delay[dOff0++] = (b1 - a1);
+ delay[dOff1++] = (b0 + a0);
+ delay[dOff1++] = (b1 + a1);
+ }
+
+ QMFSynthesisConv((int *)cTabS, delay, dIdx, outbuf, nChans);
+
+ *delayIdx = (*delayIdx == NUM_QMF_DELAY_BUFS - 1 ? 0 : *delayIdx + 1);
+}
diff --git a/audio_codec/libfaad/helixaac/sbrside.c b/audio_codec/libfaad/helixaac/sbrside.c
new file mode 100644
index 0000000..070af98
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/sbrside.c
@@ -0,0 +1,634 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrside.c,v 1.2 2005/05/24 16:01:55 albertofloyd Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrside.c - functions for unpacking side info from SBR bitstream
+ **************************************************************************************/
+
+#include "sbr.h"
+
+/**************************************************************************************
+ * Function: GetSampRateIdx
+ *
+ * Description: get index of given sample rate
+ *
+ * Inputs: sample rate (in Hz)
+ *
+ * Outputs: none
+ *
+ * Return: index of sample rate (table 1.15 in 14496-3:2001(E))
+ * -1 if sample rate not found in table
+ **************************************************************************************/
+int GetSampRateIdx(int sampRate)
+{
+ int idx;
+
+ for (idx = 0; idx < NUM_SAMPLE_RATES; idx++) {
+ if (sampRate == sampRateTab[idx]) {
+ return idx;
+ }
+ }
+
+ return -1;
+}
+
+/**************************************************************************************
+ * Function: UnpackSBRHeader
+ *
+ * Description: unpack SBR header (table 4.56)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of SBR header
+ *
+ * Outputs: initialized SBRHeader struct for this SCE/CPE block
+ *
+ * Return: non-zero if frame reset is triggered, zero otherwise
+ **************************************************************************************/
+int UnpackSBRHeader(BitStreamInfo *bsi, SBRHeader *sbrHdr)
+{
+ SBRHeader sbrHdrPrev;
+
+ /* save previous values so we know whether to reset decoder */
+ sbrHdrPrev.startFreq = sbrHdr->startFreq;
+ sbrHdrPrev.stopFreq = sbrHdr->stopFreq;
+ sbrHdrPrev.freqScale = sbrHdr->freqScale;
+ sbrHdrPrev.alterScale = sbrHdr->alterScale;
+ sbrHdrPrev.crossOverBand = sbrHdr->crossOverBand;
+ sbrHdrPrev.noiseBands = sbrHdr->noiseBands;
+
+ sbrHdr->ampRes = GetBits(bsi, 1);
+ sbrHdr->startFreq = GetBits(bsi, 4);
+ sbrHdr->stopFreq = GetBits(bsi, 4);
+ sbrHdr->crossOverBand = GetBits(bsi, 3);
+ sbrHdr->resBitsHdr = GetBits(bsi, 2);
+ sbrHdr->hdrExtra1 = GetBits(bsi, 1);
+ sbrHdr->hdrExtra2 = GetBits(bsi, 1);
+
+ if (sbrHdr->hdrExtra1) {
+ sbrHdr->freqScale = GetBits(bsi, 2);
+ sbrHdr->alterScale = GetBits(bsi, 1);
+ sbrHdr->noiseBands = GetBits(bsi, 2);
+ } else {
+ /* defaults */
+ sbrHdr->freqScale = 2;
+ sbrHdr->alterScale = 1;
+ sbrHdr->noiseBands = 2;
+ }
+
+ if (sbrHdr->hdrExtra2) {
+ sbrHdr->limiterBands = GetBits(bsi, 2);
+ sbrHdr->limiterGains = GetBits(bsi, 2);
+ sbrHdr->interpFreq = GetBits(bsi, 1);
+ sbrHdr->smoothMode = GetBits(bsi, 1);
+ } else {
+ /* defaults */
+ sbrHdr->limiterBands = 2;
+ sbrHdr->limiterGains = 2;
+ sbrHdr->interpFreq = 1;
+ sbrHdr->smoothMode = 1;
+ }
+ sbrHdr->count++;
+
+ /* if any of these have changed from previous frame, reset the SBR module */
+ if (sbrHdr->startFreq != sbrHdrPrev.startFreq || sbrHdr->stopFreq != sbrHdrPrev.stopFreq ||
+ sbrHdr->freqScale != sbrHdrPrev.freqScale || sbrHdr->alterScale != sbrHdrPrev.alterScale ||
+ sbrHdr->crossOverBand != sbrHdrPrev.crossOverBand || sbrHdr->noiseBands != sbrHdrPrev.noiseBands
+ ) {
+ return -1;
+ } else {
+ return 0;
+ }
+}
+
+/* cLog2[i] = ceil(log2(i)) (disregard i == 0) */
+static const unsigned char cLog2[9] = {0, 0, 1, 2, 2, 3, 3, 3, 3};
+
+/**************************************************************************************
+ * Function: UnpackSBRGrid
+ *
+ * Description: unpack SBR grid (table 4.62)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of SBR grid
+ * initialized SBRHeader struct for this SCE/CPE block
+ *
+ * Outputs: initialized SBRGrid struct for this channel
+ *
+ * Return: none
+ **************************************************************************************/
+static int UnpackSBRGrid(BitStreamInfo *bsi, SBRHeader *sbrHdr, SBRGrid *sbrGrid)
+{
+ int numEnvRaw, env, rel, pBits, border, middleBorder = 0;
+ unsigned char relBordLead[MAX_NUM_ENV], relBordTrail[MAX_NUM_ENV];
+ unsigned char relBorder0[3], relBorder1[3], relBorder[3];
+ unsigned char numRelBorder0, numRelBorder1, numRelBorder, numRelLead = 0, numRelTrail;
+ unsigned char absBordLead = 0, absBordTrail = 0, absBorder;
+
+ sbrGrid->ampResFrame = sbrHdr->ampRes;
+ sbrGrid->frameClass = GetBits(bsi, 2);
+ switch (sbrGrid->frameClass) {
+
+ case SBR_GRID_FIXFIX:
+ numEnvRaw = GetBits(bsi, 2);
+ sbrGrid->numEnv = (1 << numEnvRaw);
+ if (sbrGrid->numEnv == 1) {
+ sbrGrid->ampResFrame = 0;
+ }
+
+ ASSERT(sbrGrid->numEnv == 1 || sbrGrid->numEnv == 2 || sbrGrid->numEnv == 4, ERR_AAC_SBR_BITSTREAM);
+
+ sbrGrid->freqRes[0] = GetBits(bsi, 1);
+ for (env = 1; env < sbrGrid->numEnv; env++) {
+ sbrGrid->freqRes[env] = sbrGrid->freqRes[0];
+ }
+
+ absBordLead = 0;
+ absBordTrail = NUM_TIME_SLOTS;
+ numRelLead = sbrGrid->numEnv - 1;
+ numRelTrail = 0;
+
+ /* numEnv = 1, 2, or 4 */
+ if (sbrGrid->numEnv == 1) {
+ border = NUM_TIME_SLOTS / 1;
+ } else if (sbrGrid->numEnv == 2) {
+ border = NUM_TIME_SLOTS / 2;
+ } else {
+ border = NUM_TIME_SLOTS / 4;
+ }
+
+ for (rel = 0; rel < numRelLead; rel++) {
+ relBordLead[rel] = border;
+ }
+
+ middleBorder = (sbrGrid->numEnv >> 1);
+
+ break;
+
+ case SBR_GRID_FIXVAR:
+ absBorder = GetBits(bsi, 2) + NUM_TIME_SLOTS;
+ numRelBorder = GetBits(bsi, 2);
+ sbrGrid->numEnv = numRelBorder + 1;
+ for (rel = 0; rel < numRelBorder; rel++) {
+ relBorder[rel] = 2 * GetBits(bsi, 2) + 2;
+ }
+
+ pBits = cLog2[sbrGrid->numEnv + 1];
+ sbrGrid->pointer = GetBits(bsi, pBits);
+
+ for (env = sbrGrid->numEnv - 1; env >= 0; env--) {
+ sbrGrid->freqRes[env] = GetBits(bsi, 1);
+ }
+
+ absBordLead = 0;
+ absBordTrail = absBorder;
+ numRelLead = 0;
+ numRelTrail = numRelBorder;
+
+ for (rel = 0; rel < numRelTrail; rel++) {
+ relBordTrail[rel] = relBorder[rel];
+ }
+
+ if (sbrGrid->pointer > 1) {
+ middleBorder = sbrGrid->numEnv + 1 - sbrGrid->pointer;
+ } else {
+ middleBorder = sbrGrid->numEnv - 1;
+ }
+
+ break;
+
+ case SBR_GRID_VARFIX:
+ absBorder = GetBits(bsi, 2);
+ numRelBorder = GetBits(bsi, 2);
+ sbrGrid->numEnv = numRelBorder + 1;
+ for (rel = 0; rel < numRelBorder; rel++) {
+ relBorder[rel] = 2 * GetBits(bsi, 2) + 2;
+ }
+
+ pBits = cLog2[sbrGrid->numEnv + 1];
+ sbrGrid->pointer = GetBits(bsi, pBits);
+
+ for (env = 0; env < sbrGrid->numEnv; env++) {
+ sbrGrid->freqRes[env] = GetBits(bsi, 1);
+ }
+
+ absBordLead = absBorder;
+ absBordTrail = NUM_TIME_SLOTS;
+ numRelLead = numRelBorder;
+ numRelTrail = 0;
+
+ for (rel = 0; rel < numRelLead; rel++) {
+ relBordLead[rel] = relBorder[rel];
+ }
+
+ if (sbrGrid->pointer == 0) {
+ middleBorder = 1;
+ } else if (sbrGrid->pointer == 1) {
+ middleBorder = sbrGrid->numEnv - 1;
+ } else {
+ middleBorder = sbrGrid->pointer - 1;
+ }
+
+ break;
+
+ case SBR_GRID_VARVAR:
+ absBordLead = GetBits(bsi, 2); /* absBorder0 */
+ absBordTrail = GetBits(bsi, 2) + NUM_TIME_SLOTS; /* absBorder1 */
+ numRelBorder0 = GetBits(bsi, 2);
+ numRelBorder1 = GetBits(bsi, 2);
+
+ sbrGrid->numEnv = numRelBorder0 + numRelBorder1 + 1;
+ ASSERT(sbrGrid->numEnv <= 5, ERR_AAC_SBR_BITSTREAM);
+
+ for (rel = 0; rel < numRelBorder0; rel++) {
+ relBorder0[rel] = 2 * GetBits(bsi, 2) + 2;
+ }
+
+ for (rel = 0; rel < numRelBorder1; rel++) {
+ relBorder1[rel] = 2 * GetBits(bsi, 2) + 2;
+ }
+
+ pBits = cLog2[numRelBorder0 + numRelBorder1 + 2];
+ sbrGrid->pointer = GetBits(bsi, pBits);
+
+ for (env = 0; env < sbrGrid->numEnv; env++) {
+ sbrGrid->freqRes[env] = GetBits(bsi, 1);
+ }
+
+ numRelLead = numRelBorder0;
+ numRelTrail = numRelBorder1;
+
+ for (rel = 0; rel < numRelLead; rel++) {
+ relBordLead[rel] = relBorder0[rel];
+ }
+
+ for (rel = 0; rel < numRelTrail; rel++) {
+ relBordTrail[rel] = relBorder1[rel];
+ }
+
+ if (sbrGrid->pointer > 1) {
+ middleBorder = sbrGrid->numEnv + 1 - sbrGrid->pointer;
+ } else {
+ middleBorder = sbrGrid->numEnv - 1;
+ }
+
+ break;
+ }
+
+ /* build time border vector */
+ sbrGrid->envTimeBorder[0] = absBordLead * SAMPLES_PER_SLOT;
+
+ rel = 0;
+ border = absBordLead;
+ for (env = 1; env <= numRelLead; env++) {
+ border += relBordLead[rel++];
+ sbrGrid->envTimeBorder[env] = border * SAMPLES_PER_SLOT;
+ }
+
+ rel = 0;
+ border = absBordTrail;
+ for (env = sbrGrid->numEnv - 1; env > numRelLead; env--) {
+ border -= relBordTrail[rel++];
+ sbrGrid->envTimeBorder[env] = border * SAMPLES_PER_SLOT;
+ }
+
+ sbrGrid->envTimeBorder[sbrGrid->numEnv] = absBordTrail * SAMPLES_PER_SLOT;
+
+ if (sbrGrid->numEnv > 1) {
+ sbrGrid->numNoiseFloors = 2;
+ sbrGrid->noiseTimeBorder[0] = sbrGrid->envTimeBorder[0];
+ sbrGrid->noiseTimeBorder[1] = sbrGrid->envTimeBorder[middleBorder];
+ sbrGrid->noiseTimeBorder[2] = sbrGrid->envTimeBorder[sbrGrid->numEnv];
+ } else {
+ sbrGrid->numNoiseFloors = 1;
+ sbrGrid->noiseTimeBorder[0] = sbrGrid->envTimeBorder[0];
+ sbrGrid->noiseTimeBorder[1] = sbrGrid->envTimeBorder[1];
+ }
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: UnpackDeltaTimeFreq
+ *
+ * Description: unpack time/freq flags for delta coding of SBR envelopes (table 4.63)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of dt/df flags
+ * number of envelopes
+ * number of noise floors
+ *
+ * Outputs: delta flags for envelope and noise floors
+ *
+ * Return: none
+ **************************************************************************************/
+static void UnpackDeltaTimeFreq(BitStreamInfo *bsi, int numEnv, unsigned char *deltaFlagEnv,
+ int numNoiseFloors, unsigned char *deltaFlagNoise)
+{
+ int env, noiseFloor;
+
+ for (env = 0; env < numEnv; env++) {
+ deltaFlagEnv[env] = GetBits(bsi, 1);
+ }
+
+ for (noiseFloor = 0; noiseFloor < numNoiseFloors; noiseFloor++) {
+ deltaFlagNoise[noiseFloor] = GetBits(bsi, 1);
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackInverseFilterMode
+ *
+ * Description: unpack invf flags for chirp factor calculation (table 4.64)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of invf flags
+ * number of noise floor bands
+ *
+ * Outputs: invf flags for noise floor bands
+ *
+ * Return: none
+ **************************************************************************************/
+static void UnpackInverseFilterMode(BitStreamInfo *bsi, int numNoiseFloorBands, unsigned char *mode)
+{
+ int n;
+
+ for (n = 0; n < numNoiseFloorBands; n++) {
+ mode[n] = GetBits(bsi, 2);
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackSinusoids
+ *
+ * Description: unpack sinusoid (harmonic) flags for each SBR subband (table 4.67)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of sinusoid flags
+ * number of high resolution SBR subbands (nHigh)
+ *
+ * Outputs: sinusoid flags for each SBR subband, zero-filled above nHigh
+ *
+ * Return: none
+ **************************************************************************************/
+static void UnpackSinusoids(BitStreamInfo *bsi, int nHigh, int addHarmonicFlag, unsigned char *addHarmonic)
+{
+ int n;
+
+ n = 0;
+ if (addHarmonicFlag) {
+ for (; n < nHigh; n++) {
+ addHarmonic[n] = GetBits(bsi, 1);
+ }
+ }
+
+ /* zero out unused bands */
+ for (; n < MAX_QMF_BANDS; n++) {
+ addHarmonic[n] = 0;
+ }
+}
+
+/**************************************************************************************
+ * Function: CopyCouplingGrid
+ *
+ * Description: copy grid parameters from left to right for channel coupling
+ *
+ * Inputs: initialized SBRGrid struct for left channel
+ *
+ * Outputs: initialized SBRGrid struct for right channel
+ *
+ * Return: none
+ **************************************************************************************/
+static void CopyCouplingGrid(SBRGrid *sbrGridLeft, SBRGrid *sbrGridRight)
+{
+ int env, noiseFloor;
+
+ sbrGridRight->frameClass = sbrGridLeft->frameClass;
+ sbrGridRight->ampResFrame = sbrGridLeft->ampResFrame;
+ sbrGridRight->pointer = sbrGridLeft->pointer;
+
+ sbrGridRight->numEnv = sbrGridLeft->numEnv;
+ for (env = 0; env < sbrGridLeft->numEnv; env++) {
+ sbrGridRight->envTimeBorder[env] = sbrGridLeft->envTimeBorder[env];
+ sbrGridRight->freqRes[env] = sbrGridLeft->freqRes[env];
+ }
+ sbrGridRight->envTimeBorder[env] = sbrGridLeft->envTimeBorder[env]; /* borders are [0, numEnv] inclusive */
+
+ sbrGridRight->numNoiseFloors = sbrGridLeft->numNoiseFloors;
+ for (noiseFloor = 0; noiseFloor <= sbrGridLeft->numNoiseFloors; noiseFloor++) {
+ sbrGridRight->noiseTimeBorder[noiseFloor] = sbrGridLeft->noiseTimeBorder[noiseFloor];
+ }
+
+ /* numEnvPrev, numNoiseFloorsPrev, freqResPrev are updated in DecodeSBREnvelope() and DecodeSBRNoise() */
+}
+
+/**************************************************************************************
+ * Function: CopyCouplingInverseFilterMode
+ *
+ * Description: copy invf flags from left to right for channel coupling
+ *
+ * Inputs: invf flags for left channel
+ * number of noise floor bands
+ *
+ * Outputs: invf flags for right channel
+ *
+ * Return: none
+ **************************************************************************************/
+static void CopyCouplingInverseFilterMode(int numNoiseFloorBands, unsigned char *modeLeft, unsigned char *modeRight)
+{
+ int band;
+
+ for (band = 0; band < numNoiseFloorBands; band++) {
+ modeRight[band] = modeLeft[band];
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackSBRSingleChannel
+ *
+ * Description: unpack sideband info (grid, delta flags, invf flags, envelope and
+ * noise floor configuration, sinusoids) for a single channel
+ *
+ * Inputs: BitStreamInfo struct pointing to start of sideband info
+ * initialized PSInfoSBR struct (after parsing SBR header and building
+ * frequency tables)
+ * base output channel (range = [0, nChans-1])
+ *
+ * Outputs: updated PSInfoSBR struct (SBRGrid and SBRChan)
+ *
+ * Return: none
+ **************************************************************************************/
+int UnpackSBRSingleChannel(BitStreamInfo *bsi, PSInfoSBR *psi, int chBase)
+{
+ int bitsLeft;
+ int err = ERR_AAC_NONE;
+ SBRHeader *sbrHdr = &(psi->sbrHdr[chBase]);
+ SBRGrid *sbrGridL = &(psi->sbrGrid[chBase + 0]);
+ SBRFreq *sbrFreq = &(psi->sbrFreq[chBase]);
+ SBRChan *sbrChanL = &(psi->sbrChan[chBase + 0]);
+
+ psi->dataExtra = GetBits(bsi, 1);
+ if (psi->dataExtra) {
+ psi->resBitsData = GetBits(bsi, 4);
+ }
+
+ err = UnpackSBRGrid(bsi, sbrHdr, sbrGridL);
+ if (err) {
+ return err;
+ }
+ UnpackDeltaTimeFreq(bsi, sbrGridL->numEnv, sbrChanL->deltaFlagEnv, sbrGridL->numNoiseFloors, sbrChanL->deltaFlagNoise);
+ UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1]);
+
+ err = DecodeSBREnvelope(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ if (err) {
+ return err;
+ }
+ err = DecodeSBRNoise(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ if (err) {
+ return err;
+ }
+
+ sbrChanL->addHarmonicFlag[1] = GetBits(bsi, 1);
+ UnpackSinusoids(bsi, sbrFreq->nHigh, sbrChanL->addHarmonicFlag[1], sbrChanL->addHarmonic[1]);
+
+ psi->extendedDataPresent = GetBits(bsi, 1);
+ if (psi->extendedDataPresent) {
+ psi->extendedDataSize = GetBits(bsi, 4);
+ if (psi->extendedDataSize == 15) {
+ psi->extendedDataSize += GetBits(bsi, 8);
+ }
+
+ bitsLeft = 8 * psi->extendedDataSize;
+
+ /* get ID, unpack extension info, do whatever is necessary with it... */
+ while (bitsLeft > 0) {
+ GetBits(bsi, 8);
+ bitsLeft -= 8;
+ }
+ }
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: UnpackSBRChannelPair
+ *
+ * Description: unpack sideband info (grid, delta flags, invf flags, envelope and
+ * noise floor configuration, sinusoids) for a channel pair
+ *
+ * Inputs: BitStreamInfo struct pointing to start of sideband info
+ * initialized PSInfoSBR struct (after parsing SBR header and building
+ * frequency tables)
+ * base output channel (range = [0, nChans-1])
+ *
+ * Outputs: updated PSInfoSBR struct (SBRGrid and SBRChan for both channels)
+ *
+ * Return: none
+ **************************************************************************************/
+int UnpackSBRChannelPair(BitStreamInfo *bsi, PSInfoSBR *psi, int chBase)
+{
+ int bitsLeft, err = ERR_AAC_NONE;
+ SBRHeader *sbrHdr = &(psi->sbrHdr[chBase]);
+ SBRGrid *sbrGridL = &(psi->sbrGrid[chBase + 0]), *sbrGridR = &(psi->sbrGrid[chBase + 1]);
+ SBRFreq *sbrFreq = &(psi->sbrFreq[chBase]);
+ SBRChan *sbrChanL = &(psi->sbrChan[chBase + 0]), *sbrChanR = &(psi->sbrChan[chBase + 1]);
+
+ psi->dataExtra = GetBits(bsi, 1);
+ if (psi->dataExtra) {
+ psi->resBitsData = GetBits(bsi, 4);
+ psi->resBitsData = GetBits(bsi, 4);
+ }
+
+ psi->couplingFlag = GetBits(bsi, 1);
+ if (psi->couplingFlag) {
+ err = UnpackSBRGrid(bsi, sbrHdr, sbrGridL);
+ if (err) {
+ return err;
+ }
+ CopyCouplingGrid(sbrGridL, sbrGridR);
+
+ UnpackDeltaTimeFreq(bsi, sbrGridL->numEnv, sbrChanL->deltaFlagEnv, sbrGridL->numNoiseFloors, sbrChanL->deltaFlagNoise);
+ UnpackDeltaTimeFreq(bsi, sbrGridR->numEnv, sbrChanR->deltaFlagEnv, sbrGridR->numNoiseFloors, sbrChanR->deltaFlagNoise);
+
+ UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1]);
+ CopyCouplingInverseFilterMode(sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1], sbrChanR->invfMode[1]);
+
+ err = DecodeSBREnvelope(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ if (err) {
+ return err;
+ }
+ DecodeSBRNoise(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ DecodeSBREnvelope(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1);
+ DecodeSBRNoise(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1);
+
+ /* pass RIGHT sbrChan struct */
+ UncoupleSBREnvelope(psi, sbrGridL, sbrFreq, sbrChanR);
+ UncoupleSBRNoise(psi, sbrGridL, sbrFreq, sbrChanR);
+
+ } else {
+ UnpackSBRGrid(bsi, sbrHdr, sbrGridL);
+ UnpackSBRGrid(bsi, sbrHdr, sbrGridR);
+ UnpackDeltaTimeFreq(bsi, sbrGridL->numEnv, sbrChanL->deltaFlagEnv, sbrGridL->numNoiseFloors, sbrChanL->deltaFlagNoise);
+ UnpackDeltaTimeFreq(bsi, sbrGridR->numEnv, sbrChanR->deltaFlagEnv, sbrGridR->numNoiseFloors, sbrChanR->deltaFlagNoise);
+ UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1]);
+ UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanR->invfMode[1]);
+
+ DecodeSBREnvelope(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ DecodeSBREnvelope(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1);
+ DecodeSBRNoise(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ DecodeSBRNoise(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1);
+ }
+
+ sbrChanL->addHarmonicFlag[1] = GetBits(bsi, 1);
+ UnpackSinusoids(bsi, sbrFreq->nHigh, sbrChanL->addHarmonicFlag[1], sbrChanL->addHarmonic[1]);
+
+ sbrChanR->addHarmonicFlag[1] = GetBits(bsi, 1);
+ UnpackSinusoids(bsi, sbrFreq->nHigh, sbrChanR->addHarmonicFlag[1], sbrChanR->addHarmonic[1]);
+
+ psi->extendedDataPresent = GetBits(bsi, 1);
+ if (psi->extendedDataPresent) {
+ psi->extendedDataSize = GetBits(bsi, 4);
+ if (psi->extendedDataSize == 15) {
+ psi->extendedDataSize += GetBits(bsi, 8);
+ }
+
+ bitsLeft = 8 * psi->extendedDataSize;
+
+ /* get ID, unpack extension info, do whatever is necessary with it... */
+ while (bitsLeft > 0) {
+ GetBits(bsi, 8);
+ bitsLeft -= 8;
+ }
+ }
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/libfaad/helixaac/sbrtabs.c b/audio_codec/libfaad/helixaac/sbrtabs.c
new file mode 100644
index 0000000..d7ba798
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/sbrtabs.c
@@ -0,0 +1,400 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrtabs.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrtabs.c - platform-independent tables for SBR (global, read-only)
+ **************************************************************************************/
+
+#include "sbr.h"
+
+/* k0Tab[sampRateIdx][k] = k0 = startMin + offset(bs_start_freq) for given sample rate (4.6.18.3.2.1)
+ * downsampled (single-rate) SBR not currently supported
+ */
+const unsigned char k0Tab[NUM_SAMPLE_RATES_SBR][16] = {
+ { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 23, 27, 31 }, /* 96 kHz */
+ { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 23, 27, 31 }, /* 88 kHz */
+ { 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, 23, 26, 30 }, /* 64 kHz */
+ { 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 27, 31 }, /* 48 kHz */
+ { 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 23, 25, 28, 32 }, /* 44 kHz */
+ { 10, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 27, 29, 32 }, /* 32 kHz */
+ { 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 27, 29, 32 }, /* 24 kHz */
+ { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, 30 }, /* 22 kHz */
+ { 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }, /* 16 kHz */
+};
+
+/* k2Tab[sampRateIdx][k] = stopVector(bs_stop_freq) for given sample rate, bs_stop_freq = [0, 13] (4.6.18.3.2.1)
+ * generated with Matlab script calc_stopvec.m
+ * downsampled (single-rate) SBR not currently supported
+ */
+const unsigned char k2Tab[NUM_SAMPLE_RATES_SBR][14] = {
+ { 13, 15, 17, 19, 21, 24, 27, 31, 35, 39, 44, 50, 57, 64 }, /* 96 kHz */
+ { 15, 17, 19, 21, 23, 26, 29, 33, 37, 41, 46, 51, 57, 64 }, /* 88 kHz */
+ { 20, 22, 24, 26, 28, 31, 34, 37, 41, 45, 49, 54, 59, 64 }, /* 64 kHz */
+ { 21, 23, 25, 27, 29, 32, 35, 38, 41, 45, 49, 54, 59, 64 }, /* 48 kHz */
+ { 23, 25, 27, 29, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64 }, /* 44 kHz */
+ { 32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61, 64 }, /* 32 kHz */
+ { 32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61, 64 }, /* 24 kHz */
+ { 35, 36, 38, 40, 42, 44, 46, 48, 50, 52, 55, 58, 61, 64 }, /* 22 kHz */
+ { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 62, 64 }, /* 16 kHz */
+};
+
+/* NINT(2.048E6 / Fs) (figure 4.47)
+ * downsampled (single-rate) SBR not currently supported
+ */
+const unsigned char goalSBTab[NUM_SAMPLE_RATES_SBR] = {
+ 21, 23, 32, 43, 46, 64, 85, 93, 128
+};
+
+const HuffInfo huffTabSBRInfo[10] = {
+ {19, { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 2, 7, 4, 8, 72, 0}, 0},
+ {20, { 0, 2, 2, 2, 2, 2, 1, 3, 3, 2, 4, 4, 4, 3, 2, 5, 6, 13, 15, 46}, 121},
+ {17, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 0, 0, 1, 25, 10, 0, 0, 0}, 242},
+ {19, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 3, 1, 0, 1, 1, 2, 1, 29, 2, 0}, 291},
+ {19, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 2, 5, 1, 4, 2, 3, 34, 0}, 340},
+ {20, { 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 1, 2, 3, 4, 4, 7, 10, 16}, 403},
+ {14, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 13, 2, 0, 0, 0, 0, 0, 0}, 466},
+ {14, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 6, 8, 0, 0, 0, 0, 0, 0}, 491},
+ {14, { 1, 1, 1, 1, 1, 1, 0, 2, 0, 1, 1, 0, 51, 2, 0, 0, 0, 0, 0, 0}, 516},
+ { 8, { 1, 1, 1, 0, 1, 1, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 579},
+};
+
+/* Huffman tables from appendix 4.A.6.1, includes offset of -LAV[i] for table i */
+const signed short huffTabSBR[604] = {
+ /* SBR table sbr_tenv15 [121] (signed) */
+ 0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8,
+ -9, 8, -10, 9, -11, 10, -12, -13, 11, -14, 12, -15, -16, 13, -19, -18,
+ -17, 14, -24, -20, 16, -26, -21, 15, -23, -25, -22, -60, -59, -58, -57, -56,
+ -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40,
+ -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, 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,
+ /* SBR table sbr_fenv15 [121] (signed) */
+ 0, -1, 1, -2, -3, 2, -4, 3, -5, 4, -6, 5, -7, 6, -8, 7,
+ -9, 8, -10, 9, -11, 10, 11, -12, 12, -13, 13, 14, -14, -15, 15, 16,
+ 17, -16, -17, -18, -19, 18, 19, -20, -21, 20, 21, -24, -23, -22, -26, -28,
+ 22, 23, 25, -41, -25, 26, 27, -30, -27, 24, 28, 44, -51, -46, -44, -43,
+ -37, -33, -31, -29, 30, 37, 42, 47, 48, -60, -59, -58, -57, -56, -55, -54,
+ -53, -52, -50, -49, -48, -47, -45, -42, -40, -39, -38, -36, -35, -34, -32, 29,
+ 31, 32, 33, 34, 35, 36, 38, 39, 40, 41, 43, 45, 46, 49, 50, 51,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60,
+ /* SBR table sbr_tenv15b [49] (signed) */
+ 0, 1, -1, 2, -2, 3, -3, 4, -4, -5, 5, -6, 6, 7, -7, 8,
+ -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9,
+ -8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24,
+ /* SBR table sbr_fenv15b [49] (signed) */
+ 0, -1, 1, -2, 2, 3, -3, -4, 4, -5, 5, -6, 6, -7, 7, 8,
+ -9, -8, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11,
+ -10, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24,
+ /* SBR table sbr_tenv30 [63] (signed) */
+ 0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, -7, 6, -8, 7,
+ -9, -10, 8, 9, 10, -13, -11, -12, -14, 11, 12, -31, -30, -29, -28, -27,
+ -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ /* SBR table sbr_fenv30 [63] (signed) */
+ 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, -15, 14, 15, -14, 18,
+ -18, -24, -19, 16, 17, -22, -21, -16, 20, 21, 22, 25, -23, -20, 24, -31,
+ -30, -29, -28, -27, -26, -25, -17, 19, 23, 26, 27, 28, 29, 30, 31,
+ /* SBR table sbr_tenv30b [25] (signed) */
+ 0, 1, -1, -2, 2, 3, -3, -4, 4, -5, -12, -11, -10, -9, -8, -7,
+ -6, 5, 6, 7, 8, 9, 10, 11, 12,
+ /* SBR table sbr_fenv30b [25] (signed) */
+ 0, -1, 1, -2, 2, 3, -3, -4, 4, -5, 5, 6, -12, -11, -10, -9,
+ -8, -7, -6, 7, 8, 9, 10, 11, 12,
+ /* SBR table sbr_tnoise30 [63] (signed) */
+ 0, 1, -1, -2, 2, -3, 3, -4, 4, -5, 5, 11, -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, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ /* SBR table sbr_tnoise30b [25] (signed) */
+ 0, -1, 1, -2, 2, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, 3,
+ 4, 5, 6, 7, 8, 9, 10, 11, 12,
+};
+
+/* log2Tab[x] = floor(log2(x)), format = Q28 */
+const int log2Tab[65] = {
+ 0x00000000, 0x00000000, 0x10000000, 0x195c01a3, 0x20000000, 0x25269e12, 0x295c01a3, 0x2ceaecfe,
+ 0x30000000, 0x32b80347, 0x35269e12, 0x3759d4f8, 0x395c01a3, 0x3b350047, 0x3ceaecfe, 0x3e829fb6,
+ 0x40000000, 0x41663f6f, 0x42b80347, 0x43f782d7, 0x45269e12, 0x4646eea2, 0x4759d4f8, 0x48608280,
+ 0x495c01a3, 0x4a4d3c25, 0x4b350047, 0x4c1404ea, 0x4ceaecfe, 0x4dba4a47, 0x4e829fb6, 0x4f446359,
+ 0x50000000, 0x50b5d69b, 0x51663f6f, 0x52118b11, 0x52b80347, 0x5359ebc5, 0x53f782d7, 0x549101ea,
+ 0x55269e12, 0x55b88873, 0x5646eea2, 0x56d1fafd, 0x5759d4f8, 0x57dea15a, 0x58608280, 0x58df988f,
+ 0x595c01a3, 0x59d5d9fd, 0x5a4d3c25, 0x5ac24113, 0x5b350047, 0x5ba58feb, 0x5c1404ea, 0x5c80730b,
+ 0x5ceaecfe, 0x5d53847a, 0x5dba4a47, 0x5e1f4e51, 0x5e829fb6, 0x5ee44cd5, 0x5f446359, 0x5fa2f045,
+ 0x60000000
+};
+
+/* coefficient table 4.A.87, format = Q31
+ * reordered as:
+ * cTab[0], cTab[64], cTab[128], cTab[192], cTab[256],
+ * cTab[2], cTab[66], cTab[130], cTab[194], cTab[258],
+ * ...
+ * cTab[64], cTab[128], cTab[192], cTab[256], cTab[320]
+ *
+ * NOTE: cTab[1, 2, ... , 318, 319] = cTab[639, 638, ... 322, 321]
+ * except cTab[384] = -cTab[256], cTab[512] = -cTab[128]
+ */
+const int cTabA[165] = {
+ 0x00000000, 0x0055dba1, 0x01b2e41d, 0x09015651, 0x2e3a7532, 0xffed978a, 0x006090c4, 0x01fd3ba0, 0x08a24899, 0x311af3a4,
+ 0xfff0065d, 0x006b47fa, 0x024bf7a1, 0x082f552e, 0x33ff670e, 0xffef7b8b, 0x0075fded, 0x029e35b4, 0x07a8127d, 0x36e69691,
+ 0xffee1650, 0x00807994, 0x02f3e48d, 0x070bbf58, 0x39ce0477, 0xffecc31b, 0x008a7dd7, 0x034d01f0, 0x06593912, 0x3cb41219,
+ 0xffeb50b2, 0x009424c6, 0x03a966bb, 0x0590a67d, 0x3f962fb8, 0xffe9ca76, 0x009d10bf, 0x04083fec, 0x04b0adcb, 0x4272a385,
+ 0xffe88ba8, 0x00a520bb, 0x04694101, 0x03b8f8dc, 0x4547daea, 0xffe79e16, 0x00abe79e, 0x04cc2fcf, 0x02a99097, 0x4812f848,
+ 0xffe6d466, 0x00b1978d, 0x05303f87, 0x01816e06, 0x4ad237a2, 0xffe65416, 0x00b5c867, 0x05950122, 0x0040c496, 0x4d83976c,
+ 0xffe66dd0, 0x00b8394b, 0x05f9c051, 0xfee723c6, 0x5024d70e, 0xffe69423, 0x00b8c6b0, 0x065dd56a, 0xfd7475d8, 0x52b449de,
+ 0xffe75361, 0x00b73ab0, 0x06c0f0c0, 0xfbe8f5bd, 0x552f8ff7, 0xffe85b4b, 0x00b36acd, 0x0721bf22, 0xfa44a069, 0x579505f5,
+ 0xffea353a, 0x00acbd2f, 0x077fedb3, 0xf887507c, 0x59e2f69e, 0xffec8409, 0x00a3508f, 0x07da2b7f, 0xf6b1f3c3, 0x5c16d0ae,
+ 0xffef2395, 0x0096dcc2, 0x08303897, 0xf4c473c6, 0x5e2f6367, 0xfff294c3, 0x00872c63, 0x0880ffdd, 0xf2bf6ea4, 0x602b0c7f,
+ 0xfff681d6, 0x007400b8, 0x08cb4e23, 0xf0a3959f, 0x6207f220, 0xfffb42b0, 0x005d36df, 0x090ec1fc, 0xee71b2fe, 0x63c45243,
+ 0x00007134, 0x00426f36, 0x0949eaac, 0xec2a3f5f, 0x655f63f2, 0x0006b1cf, 0x0023b989, 0x097c1ee8, 0xe9cea84a, 0x66d76725,
+ 0x000d31b5, 0x0000e790, 0x09a3e163, 0xe75f8bb8, 0x682b39a4, 0x001471f8, 0xffda17f2, 0x09c0e59f, 0xe4de0cb0, 0x6959709d,
+ 0x001c3549, 0xffaea5d6, 0x09d19ca9, 0xe24b8f66, 0x6a619c5e, 0x0024dd50, 0xff7ee3f1, 0x09d5560b, 0xdfa93ab5, 0x6b42a864,
+ 0x002d8e42, 0xff4aabc8, 0x09caeb0f, 0xdcf898fb, 0x6bfbdd98, 0x003745f9, 0xff120d70, 0x09b18a1d, 0xda3b176a, 0x6c8c4c7a,
+ 0x004103f4, 0xfed4bec3, 0x09881dc5, 0xd7722f04, 0x6cf4073e, 0x004b6c46, 0xfe933dc0, 0x094d7ec2, 0xd49fd55f, 0x6d32730f,
+ 0x0055dba1, 0x01b2e41d, 0x09015651, 0x2e3a7532, 0x6d474e1d,
+};
+
+/* coefficient table 4.A.87, format = Q31
+ * reordered as cTab[0], cTab[64], cTab[128], ... cTab[576], cTab[1], cTab[65], cTab[129], ... cTab[639]
+ * keeping full table (not using symmetry) to allow sequential access in synth filter inner loop
+ * format = Q31
+ */
+const int cTabS[640] = {
+ 0x00000000, 0x0055dba1, 0x01b2e41d, 0x09015651, 0x2e3a7532, 0x6d474e1d, 0xd1c58ace, 0x09015651, 0xfe4d1be3, 0x0055dba1,
+ 0xffede50e, 0x005b5371, 0x01d78bfc, 0x08d3e41b, 0x2faa221c, 0x6d41d963, 0xd3337b3d, 0x09299ead, 0xfe70b8d1, 0x0050b177,
+ 0xffed978a, 0x006090c4, 0x01fd3ba0, 0x08a24899, 0x311af3a4, 0x6d32730f, 0xd49fd55f, 0x094d7ec2, 0xfe933dc0, 0x004b6c46,
+ 0xffefc9b9, 0x0065fde5, 0x02244a24, 0x086b1eeb, 0x328cc6f0, 0x6d18520e, 0xd60a46e5, 0x096d0e21, 0xfeb48d0d, 0x00465348,
+ 0xfff0065d, 0x006b47fa, 0x024bf7a1, 0x082f552e, 0x33ff670e, 0x6cf4073e, 0xd7722f04, 0x09881dc5, 0xfed4bec3, 0x004103f4,
+ 0xffeff6ca, 0x0070c8a5, 0x0274ba43, 0x07ee507c, 0x3572ec70, 0x6cc59bab, 0xd8d7f21f, 0x099ec3dc, 0xfef3f6ab, 0x003c1fa4,
+ 0xffef7b8b, 0x0075fded, 0x029e35b4, 0x07a8127d, 0x36e69691, 0x6c8c4c7a, 0xda3b176a, 0x09b18a1d, 0xff120d70, 0x003745f9,
+ 0xffeedfa4, 0x007b3875, 0x02c89901, 0x075ca90c, 0x385a49c4, 0x6c492217, 0xdb9b5b12, 0x09c018ce, 0xff2ef725, 0x00329ab6,
+ 0xffee1650, 0x00807994, 0x02f3e48d, 0x070bbf58, 0x39ce0477, 0x6bfbdd98, 0xdcf898fb, 0x09caeb0f, 0xff4aabc8, 0x002d8e42,
+ 0xffed651d, 0x0085c217, 0x03201116, 0x06b559c3, 0x3b415115, 0x6ba4629f, 0xde529086, 0x09d1fa23, 0xff6542d1, 0x00293718,
+ 0xffecc31b, 0x008a7dd7, 0x034d01f0, 0x06593912, 0x3cb41219, 0x6b42a864, 0xdfa93ab5, 0x09d5560b, 0xff7ee3f1, 0x0024dd50,
+ 0xffebe77b, 0x008f4bfc, 0x037ad438, 0x05f7fb90, 0x3e25b17e, 0x6ad73e8d, 0xe0fc421e, 0x09d52709, 0xff975c01, 0x002064f8,
+ 0xffeb50b2, 0x009424c6, 0x03a966bb, 0x0590a67d, 0x3f962fb8, 0x6a619c5e, 0xe24b8f66, 0x09d19ca9, 0xffaea5d6, 0x001c3549,
+ 0xffea9192, 0x0098b855, 0x03d8afe6, 0x05237f9d, 0x41058bc6, 0x69e29784, 0xe396a45d, 0x09cab9f2, 0xffc4e365, 0x0018703f,
+ 0xffe9ca76, 0x009d10bf, 0x04083fec, 0x04b0adcb, 0x4272a385, 0x6959709d, 0xe4de0cb0, 0x09c0e59f, 0xffda17f2, 0x001471f8,
+ 0xffe940f4, 0x00a1039c, 0x043889c6, 0x0437fb0a, 0x43de620a, 0x68c7269b, 0xe620c476, 0x09b3d77f, 0xffee183b, 0x0010bc63,
+ 0xffe88ba8, 0x00a520bb, 0x04694101, 0x03b8f8dc, 0x4547daea, 0x682b39a4, 0xe75f8bb8, 0x09a3e163, 0x0000e790, 0x000d31b5,
+ 0xffe83a07, 0x00a8739d, 0x049aa82f, 0x03343533, 0x46aea856, 0x6785c24d, 0xe89971b7, 0x099140a7, 0x00131c75, 0x0009aa3f,
+ 0xffe79e16, 0x00abe79e, 0x04cc2fcf, 0x02a99097, 0x4812f848, 0x66d76725, 0xe9cea84a, 0x097c1ee8, 0x0023b989, 0x0006b1cf,
+ 0xffe7746e, 0x00af374c, 0x04fe20be, 0x02186a91, 0x4973fef1, 0x661fd6b8, 0xeafee7f1, 0x0963ed46, 0x0033b927, 0x00039609,
+ 0xffe6d466, 0x00b1978d, 0x05303f87, 0x01816e06, 0x4ad237a2, 0x655f63f2, 0xec2a3f5f, 0x0949eaac, 0x00426f36, 0x00007134,
+ 0xffe6afee, 0x00b3d15c, 0x05626209, 0x00e42fa2, 0x4c2ca3df, 0x64964063, 0xed50a31d, 0x092d7970, 0x00504f41, 0xfffdfa25,
+ 0xffe65416, 0x00b5c867, 0x05950122, 0x0040c496, 0x4d83976c, 0x63c45243, 0xee71b2fe, 0x090ec1fc, 0x005d36df, 0xfffb42b0,
+ 0xffe681c6, 0x00b74c37, 0x05c76fed, 0xff96db90, 0x4ed62be3, 0x62ea6474, 0xef8d4d7b, 0x08edfeaa, 0x006928a0, 0xfff91fca,
+ 0xffe66dd0, 0x00b8394b, 0x05f9c051, 0xfee723c6, 0x5024d70e, 0x6207f220, 0xf0a3959f, 0x08cb4e23, 0x007400b8, 0xfff681d6,
+ 0xffe66fac, 0x00b8fe0d, 0x062bf5ec, 0xfe310657, 0x516eefb9, 0x611d58a3, 0xf1b461ab, 0x08a75da4, 0x007e0393, 0xfff48700,
+ 0xffe69423, 0x00b8c6b0, 0x065dd56a, 0xfd7475d8, 0x52b449de, 0x602b0c7f, 0xf2bf6ea4, 0x0880ffdd, 0x00872c63, 0xfff294c3,
+ 0xffe6fed4, 0x00b85f70, 0x068f8b44, 0xfcb1d740, 0x53f495aa, 0x5f30ff5f, 0xf3c4e887, 0x08594887, 0x008f87aa, 0xfff0e7ef,
+ 0xffe75361, 0x00b73ab0, 0x06c0f0c0, 0xfbe8f5bd, 0x552f8ff7, 0x5e2f6367, 0xf4c473c6, 0x08303897, 0x0096dcc2, 0xffef2395,
+ 0xffe80414, 0x00b58c8c, 0x06f1825d, 0xfb19b7bd, 0x56654bdd, 0x5d26be9b, 0xf5be0fa9, 0x08061671, 0x009da526, 0xffedc418,
+ 0xffe85b4b, 0x00b36acd, 0x0721bf22, 0xfa44a069, 0x579505f5, 0x5c16d0ae, 0xf6b1f3c3, 0x07da2b7f, 0x00a3508f, 0xffec8409,
+ 0xffe954d0, 0x00b06b68, 0x075112a2, 0xf96916f5, 0x58befacd, 0x5b001db8, 0xf79fa13a, 0x07ad8c26, 0x00a85e94, 0xffeb3849,
+ 0xffea353a, 0x00acbd2f, 0x077fedb3, 0xf887507c, 0x59e2f69e, 0x59e2f69e, 0xf887507c, 0x077fedb3, 0x00acbd2f, 0xffea353a,
+ 0xffeb3849, 0x00a85e94, 0x07ad8c26, 0xf79fa13a, 0x5b001db8, 0x58befacd, 0xf96916f5, 0x075112a2, 0x00b06b68, 0xffe954d0,
+ 0xffec8409, 0x00a3508f, 0x07da2b7f, 0xf6b1f3c3, 0x5c16d0ae, 0x579505f5, 0xfa44a069, 0x0721bf22, 0x00b36acd, 0xffe85b4b,
+ 0xffedc418, 0x009da526, 0x08061671, 0xf5be0fa9, 0x5d26be9b, 0x56654bdd, 0xfb19b7bd, 0x06f1825d, 0x00b58c8c, 0xffe80414,
+ 0xffef2395, 0x0096dcc2, 0x08303897, 0xf4c473c6, 0x5e2f6367, 0x552f8ff7, 0xfbe8f5bd, 0x06c0f0c0, 0x00b73ab0, 0xffe75361,
+ 0xfff0e7ef, 0x008f87aa, 0x08594887, 0xf3c4e887, 0x5f30ff5f, 0x53f495aa, 0xfcb1d740, 0x068f8b44, 0x00b85f70, 0xffe6fed4,
+ 0xfff294c3, 0x00872c63, 0x0880ffdd, 0xf2bf6ea4, 0x602b0c7f, 0x52b449de, 0xfd7475d8, 0x065dd56a, 0x00b8c6b0, 0xffe69423,
+ 0xfff48700, 0x007e0393, 0x08a75da4, 0xf1b461ab, 0x611d58a3, 0x516eefb9, 0xfe310657, 0x062bf5ec, 0x00b8fe0d, 0xffe66fac,
+ 0xfff681d6, 0x007400b8, 0x08cb4e23, 0xf0a3959f, 0x6207f220, 0x5024d70e, 0xfee723c6, 0x05f9c051, 0x00b8394b, 0xffe66dd0,
+ 0xfff91fca, 0x006928a0, 0x08edfeaa, 0xef8d4d7b, 0x62ea6474, 0x4ed62be3, 0xff96db90, 0x05c76fed, 0x00b74c37, 0xffe681c6,
+ 0xfffb42b0, 0x005d36df, 0x090ec1fc, 0xee71b2fe, 0x63c45243, 0x4d83976c, 0x0040c496, 0x05950122, 0x00b5c867, 0xffe65416,
+ 0xfffdfa25, 0x00504f41, 0x092d7970, 0xed50a31d, 0x64964063, 0x4c2ca3df, 0x00e42fa2, 0x05626209, 0x00b3d15c, 0xffe6afee,
+ 0x00007134, 0x00426f36, 0x0949eaac, 0xec2a3f5f, 0x655f63f2, 0x4ad237a2, 0x01816e06, 0x05303f87, 0x00b1978d, 0xffe6d466,
+ 0x00039609, 0x0033b927, 0x0963ed46, 0xeafee7f1, 0x661fd6b8, 0x4973fef1, 0x02186a91, 0x04fe20be, 0x00af374c, 0xffe7746e,
+ 0x0006b1cf, 0x0023b989, 0x097c1ee8, 0xe9cea84a, 0x66d76725, 0x4812f848, 0x02a99097, 0x04cc2fcf, 0x00abe79e, 0xffe79e16,
+ 0x0009aa3f, 0x00131c75, 0x099140a7, 0xe89971b7, 0x6785c24d, 0x46aea856, 0x03343533, 0x049aa82f, 0x00a8739d, 0xffe83a07,
+ 0x000d31b5, 0x0000e790, 0x09a3e163, 0xe75f8bb8, 0x682b39a4, 0x4547daea, 0x03b8f8dc, 0x04694101, 0x00a520bb, 0xffe88ba8,
+ 0x0010bc63, 0xffee183b, 0x09b3d77f, 0xe620c476, 0x68c7269b, 0x43de620a, 0x0437fb0a, 0x043889c6, 0x00a1039c, 0xffe940f4,
+ 0x001471f8, 0xffda17f2, 0x09c0e59f, 0xe4de0cb0, 0x6959709d, 0x4272a385, 0x04b0adcb, 0x04083fec, 0x009d10bf, 0xffe9ca76,
+ 0x0018703f, 0xffc4e365, 0x09cab9f2, 0xe396a45d, 0x69e29784, 0x41058bc6, 0x05237f9d, 0x03d8afe6, 0x0098b855, 0xffea9192,
+ 0x001c3549, 0xffaea5d6, 0x09d19ca9, 0xe24b8f66, 0x6a619c5e, 0x3f962fb8, 0x0590a67d, 0x03a966bb, 0x009424c6, 0xffeb50b2,
+ 0x002064f8, 0xff975c01, 0x09d52709, 0xe0fc421e, 0x6ad73e8d, 0x3e25b17e, 0x05f7fb90, 0x037ad438, 0x008f4bfc, 0xffebe77b,
+ 0x0024dd50, 0xff7ee3f1, 0x09d5560b, 0xdfa93ab5, 0x6b42a864, 0x3cb41219, 0x06593912, 0x034d01f0, 0x008a7dd7, 0xffecc31b,
+ 0x00293718, 0xff6542d1, 0x09d1fa23, 0xde529086, 0x6ba4629f, 0x3b415115, 0x06b559c3, 0x03201116, 0x0085c217, 0xffed651d,
+ 0x002d8e42, 0xff4aabc8, 0x09caeb0f, 0xdcf898fb, 0x6bfbdd98, 0x39ce0477, 0x070bbf58, 0x02f3e48d, 0x00807994, 0xffee1650,
+ 0x00329ab6, 0xff2ef725, 0x09c018ce, 0xdb9b5b12, 0x6c492217, 0x385a49c4, 0x075ca90c, 0x02c89901, 0x007b3875, 0xffeedfa4,
+ 0x003745f9, 0xff120d70, 0x09b18a1d, 0xda3b176a, 0x6c8c4c7a, 0x36e69691, 0x07a8127d, 0x029e35b4, 0x0075fded, 0xffef7b8b,
+ 0x003c1fa4, 0xfef3f6ab, 0x099ec3dc, 0xd8d7f21f, 0x6cc59bab, 0x3572ec70, 0x07ee507c, 0x0274ba43, 0x0070c8a5, 0xffeff6ca,
+ 0x004103f4, 0xfed4bec3, 0x09881dc5, 0xd7722f04, 0x6cf4073e, 0x33ff670e, 0x082f552e, 0x024bf7a1, 0x006b47fa, 0xfff0065d,
+ 0x00465348, 0xfeb48d0d, 0x096d0e21, 0xd60a46e5, 0x6d18520e, 0x328cc6f0, 0x086b1eeb, 0x02244a24, 0x0065fde5, 0xffefc9b9,
+ 0x004b6c46, 0xfe933dc0, 0x094d7ec2, 0xd49fd55f, 0x6d32730f, 0x311af3a4, 0x08a24899, 0x01fd3ba0, 0x006090c4, 0xffed978a,
+ 0x0050b177, 0xfe70b8d1, 0x09299ead, 0xd3337b3d, 0x6d41d963, 0x2faa221c, 0x08d3e41b, 0x01d78bfc, 0x005b5371, 0xffede50f,
+};
+
+/* noise table 4.A.88, format = Q31 */
+const int noiseTab[512 * 2] = {
+ 0x8010fd38, 0xb3dc7948, 0x7c4e2301, 0xa9904192, 0x121622a7, 0x86489625, 0xc3d53d25, 0xd0343fa9,
+ 0x674d6f70, 0x25f4e9fd, 0xce1a8c8b, 0x72a726c5, 0xfea6efc6, 0xaa4adb1a, 0x8b2dd628, 0xf14029e4,
+ 0x46321c1a, 0x604889a0, 0x33363b63, 0x815ed069, 0x802b4315, 0x8f2bf7f3, 0x85b86073, 0x745cfb46,
+ 0xc57886b3, 0xb76731f0, 0xa2a66772, 0x828ca631, 0x60cc145e, 0x1ad1010f, 0x090c83d4, 0x9bd7ba87,
+ 0x5f5aeea2, 0x8b4dbd99, 0x848e7b1e, 0x86bb9fa2, 0x26f18ae5, 0xc0b81194, 0x553407bf, 0x52c17953,
+ 0x755f468d, 0x166b04f8, 0xa5687981, 0x4343248b, 0xa6558d5e, 0xc5f6fab7, 0x80a4fb8c, 0x8cb53cb7,
+ 0x7da68a54, 0x9cd8df8a, 0xba05376c, 0xfcb58ee2, 0xfdd657a4, 0x005e35ca, 0x91c75c55, 0x367651e6,
+ 0x816abf85, 0x8f831c4f, 0x423f9c9c, 0x55aa919e, 0x80779834, 0xb59f4244, 0x800a095c, 0x7de9e0cc,
+ 0x46bda5cb, 0x4c184464, 0x2c438f71, 0x797216b5, 0x5035cee6, 0xa0c3a26e, 0x9d3f95fa, 0xd4a100c0,
+ 0x8ac30dac, 0x04b87397, 0x9e5ac516, 0x8b0b442e, 0x66210ad6, 0x88ba7598, 0x45b9bd33, 0xf0be5087,
+ 0x9261b85e, 0x364f6a31, 0x891c4b50, 0x23ad08ce, 0xf10366a6, 0x80414276, 0x1b562e06, 0x8be21591,
+ 0x9e798195, 0x7fb4045c, 0x7d9506cf, 0x854e691f, 0x9207f092, 0x7a94c9d5, 0x88911536, 0x3f45cc61,
+ 0x27059279, 0xa5b57109, 0x6d2bb67b, 0x3bdc5379, 0x74e662d8, 0x80348f8c, 0xf875e638, 0x5a8caea1,
+ 0x2459ae75, 0x2c54b939, 0x79ee3203, 0xb9bc8683, 0x9b6f630c, 0x9f45b351, 0x8563b2b9, 0xe5dbba41,
+ 0x697c7d0d, 0x7bb7c90e, 0xac900866, 0x8e6b5177, 0x8822dd37, 0x7fd5a91e, 0x7506da05, 0x82302aca,
+ 0xa5e4be04, 0x4b4288eb, 0x00b8bc9f, 0x4f1033e4, 0x7200d612, 0x43900c8c, 0xa815b900, 0x676ed1d4,
+ 0x5c5f23b2, 0xa758ee11, 0xaf73abfa, 0x11714ec0, 0x265239e0, 0xc50de679, 0x8a84e341, 0xa1438354,
+ 0x7f1a341f, 0x343ec96b, 0x696e71b0, 0xa13bde39, 0x81e75094, 0x80091111, 0x853a73bf, 0x80f9c1ee,
+ 0xe4980086, 0x886a8e28, 0xa7e89426, 0xdd93edd7, 0x7592100d, 0x0bfa8123, 0x850a26d4, 0x2e34f395,
+ 0x421b6c00, 0xa4a462e4, 0x4e3f5090, 0x3c189f4c, 0x3c971a56, 0xdd0376d2, 0x747a5367, 0x7bcbc9d7,
+ 0x3966be6a, 0x7efda616, 0x55445e15, 0x7ba2ab3f, 0x5fe684f2, 0x8cf42af9, 0x808c61c3, 0x4390c27b,
+ 0x7cac62ff, 0xea6cab22, 0x5d0902ad, 0xc27b7208, 0x7a27389d, 0x5820a357, 0xa29bbe59, 0x9df0f1fd,
+ 0x92bd67e5, 0x7195b587, 0x97cac65b, 0x8339807e, 0x8f72d832, 0x5fad8685, 0xa462d9d3, 0x81d46214,
+ 0x6ae93e1d, 0x6b23a5b9, 0xc2732874, 0x81795268, 0x7c568cb6, 0x668513ea, 0x428d024e, 0x66b78b3a,
+ 0xfee9ef03, 0x9ddcbb82, 0xa605f07e, 0x46dc55e0, 0x85415054, 0xc89ec271, 0x7c42edfb, 0x0befe59b,
+ 0x89b8f607, 0x6d732a1a, 0xa7081ebd, 0x7e403258, 0x21feeb7b, 0x5dd7a1e7, 0x23e3a31a, 0x129bc896,
+ 0xa11a6b54, 0x7f1e031c, 0xfdc1a4d1, 0x96402e53, 0xb9700f1a, 0x8168ecd6, 0x7d63d3cc, 0x87a70d65,
+ 0x81075a7a, 0x55c8caa7, 0xa95d00b5, 0x102b1652, 0x0bb30215, 0xe5b63237, 0xa446ca44, 0x82d4c333,
+ 0x67b2e094, 0x44c3d661, 0x33fd6036, 0xde1ea2a1, 0xa95e8e47, 0x78f66eb9, 0x6f2aef1e, 0xe8887247,
+ 0x80a3b70e, 0xfca0d9d3, 0x6bf0fd20, 0x0d5226de, 0xf4341c87, 0x5902df05, 0x7ff1a38d, 0xf02e5a5b,
+ 0x99f129af, 0x8ac63d01, 0x7b53f599, 0x7bb32532, 0x99ac59b0, 0x5255a80f, 0xf1320a41, 0x2497aa5c,
+ 0xcce60bd8, 0x787c634b, 0x7ed58c5b, 0x8a28eb3a, 0x24a5e647, 0x8b79a2c1, 0x955f5ce5, 0xa9d12bc4,
+ 0x7a1e20c6, 0x3eeda7ac, 0xf7be823a, 0x042924ce, 0x808b3f03, 0x364248da, 0xac2895e5, 0x69a8b5fa,
+ 0x97fe8b63, 0xbdeac9aa, 0x8073e0ad, 0x6c25dba7, 0x005e51d2, 0x52e74389, 0x59d3988c, 0xe5d1f39c,
+ 0x7b57dc91, 0x341adbe7, 0xa7d42b8d, 0x74e9f335, 0xd35bf7d8, 0x5b7c0a4b, 0x75bc0874, 0x552129bf,
+ 0x8144b70d, 0x6de93bbb, 0x5825f14b, 0x473ec5ca, 0x80a8f37c, 0xe6552d69, 0x7898360b, 0x806379b0,
+ 0xa9b59339, 0x3f6bf60c, 0xc367d731, 0x920ade99, 0x125592f7, 0x877e5ed1, 0xda895d95, 0x075f2ece,
+ 0x380e5f5e, 0x9b006b62, 0xd17a6dd2, 0x530a0e13, 0xf4cc9a14, 0x7d0a0ed4, 0x847c6e3f, 0xbaee4975,
+ 0x47131163, 0x64fb2cac, 0x5e2100a6, 0x7b756a42, 0xd87609f4, 0x98bfe48c, 0x0493745e, 0x836c5784,
+ 0x7e5ccb40, 0x3df6b476, 0x97700d28, 0x8bbd93fd, 0x56de9cdb, 0x680b4e65, 0xebc3d90e, 0x6d286793,
+ 0x6753712e, 0xe05c98a7, 0x3d2b6b85, 0xc4b18ddb, 0x7b59b869, 0x31435688, 0x811888e9, 0xe011ee7a,
+ 0x6a5844f9, 0x86ae35ea, 0xb4cbc10b, 0x01a6f5d6, 0x7a49ed64, 0x927caa49, 0x847ddaed, 0xae0d9bb6,
+ 0x836bdb04, 0x0fd810a6, 0x74fe126b, 0x4a346b5f, 0x80184d36, 0x5afd153c, 0x90cc8102, 0xe606d0e6,
+ 0xde69aa58, 0xa89f1222, 0xe06df715, 0x8fd16144, 0x0317c3e8, 0x22ce92fc, 0x690c3eca, 0x93166f02,
+ 0x71573414, 0x8d43cffb, 0xe8bd0bb6, 0xde86770f, 0x0bf99a41, 0x4633a661, 0xba064108, 0x7adafae3,
+ 0x2f6cde5d, 0xb350a52c, 0xa5ebfb0b, 0x74c57b46, 0xd3b603b5, 0x80b70892, 0xa7f7fa53, 0xd94b566c,
+ 0xdda3fd86, 0x6a635793, 0x3ed005ca, 0xc5f087d8, 0x31e3a746, 0x7a4278f9, 0x82def1f9, 0x06caa2b2,
+ 0xe9d2c349, 0x8940e7f7, 0x7feef8dd, 0x4a9b01f0, 0xacde69f8, 0x57ddc280, 0xf09e4ba4, 0xb6d9f729,
+ 0xb48c18f2, 0xd3654aa9, 0xca7a03c8, 0x14d57545, 0x7fda87a5, 0x0e411366, 0xb77d0df0, 0x8c2aa467,
+ 0x787f2590, 0x2d292db1, 0x9f12682c, 0x44ac364d, 0x1a4b31a6, 0x871f7ded, 0x7ff99167, 0x6630a1d5,
+ 0x25385eb9, 0x2d4dd549, 0xaf8a7004, 0x319ebe0f, 0x379ab730, 0x81dc56a4, 0x822d8523, 0x1ae8554c,
+ 0x18fa0786, 0x875f7de4, 0x85ca350f, 0x7de818dc, 0x7786a38f, 0xa5456355, 0x92e60f88, 0xf5526122,
+ 0x916039bc, 0xc561e2de, 0x31c42042, 0x7c82e290, 0x75d158b2, 0xb015bda1, 0x7220c750, 0x46565441,
+ 0xd0da1fdd, 0x7b777481, 0x782e73c6, 0x8cd72b7b, 0x7f1006aa, 0xfb30e51e, 0x87994818, 0x34e7c7db,
+ 0x7faae06b, 0xea74fbc0, 0xd20c7af4, 0xc44f396b, 0x06b4234e, 0xdf2e2a93, 0x2efb07c8, 0xce861911,
+ 0x7550ea05, 0xd8d90bbb, 0x58522eec, 0x746b3520, 0xce844ce9, 0x7f5cacc3, 0xda8f17e0, 0x2fedf9cb,
+ 0xb2f77ec4, 0x6f13f4c0, 0x834de085, 0x7b7ace4b, 0x713b16ac, 0x499c5ab0, 0x06a7961d, 0x1b39a48a,
+ 0xbb853e6e, 0x7c781cc1, 0xc0baebf5, 0x7dace394, 0x815ceebc, 0xcc7b27d4, 0x8274b181, 0xa2be40a2,
+ 0xdd01d5dc, 0x7fefeb14, 0x0813ec78, 0xba3077cc, 0xe5cf1e1c, 0xedcfacae, 0x54c43a9b, 0x5cd62a42,
+ 0x93806b55, 0x03095c5b, 0x8e076ae3, 0x71bfcd2a, 0x7ac1989b, 0x623bc71a, 0x5e15d4d2, 0xfb341dd1,
+ 0xd75dfbca, 0xd0da32be, 0xd4569063, 0x337869da, 0x3d30606a, 0xcd89cca2, 0x7dd2ae36, 0x028c03cd,
+ 0xd85e052c, 0xe8dc9ec5, 0x7ffd9241, 0xde5bf4c6, 0x88c4b235, 0x8228be2e, 0x7fe6ec64, 0x996abe6a,
+ 0xdeb0666d, 0x9eb86611, 0xd249b922, 0x18b3e26b, 0x80211168, 0x5f8bb99c, 0x6ecb0dd2, 0x4728ff8d,
+ 0x2ac325b8, 0x6e5169d2, 0x7ebbd68d, 0x05e41d17, 0xaaa19f28, 0x8ab238a6, 0x51f105be, 0x140809cc,
+ 0x7f7345d9, 0x3aae5a9d, 0xaecec6e4, 0x1afb3473, 0xf6229ed1, 0x8d55f467, 0x7e32003a, 0x70f30c14,
+ 0x6686f33f, 0xd0d45ed8, 0x644fab57, 0x3a3fbbd3, 0x0b255fc4, 0x679a1701, 0x90e17b6e, 0x325d537b,
+ 0xcd7b9b87, 0xaa7be2a2, 0x7d47c966, 0xa33dbce5, 0x8659c3bb, 0x72a41367, 0x15c446e0, 0x45fe8b0a,
+ 0x9d8ddf26, 0x84d47643, 0x7fabe0da, 0x36a70122, 0x7a28ebfe, 0x7c29b8b8, 0x7f760406, 0xbabe4672,
+ 0x23ea216e, 0x92bcc50a, 0x6d20dba2, 0xad5a7c7e, 0xbf3897f5, 0xabb793e1, 0x8391fc7e, 0xe270291c,
+ 0x7a248d58, 0x80f8fd15, 0x83ef19f3, 0x5e6ece7d, 0x278430c1, 0x35239f4d, 0xe09c073b, 0x50e78cb5,
+ 0xd4b811bd, 0xce834ee0, 0xf88aaa34, 0xf71da5a9, 0xe2b0a1d5, 0x7c3aef31, 0xe84eabca, 0x3ce25964,
+ 0xf29336d3, 0x8fa78b2c, 0xa3fc3415, 0x63e1313d, 0x7fbc74e0, 0x7340bc93, 0x49ae583b, 0x8b79de4b,
+ 0x25011ce9, 0x7b462279, 0x36007db0, 0x3da1599c, 0x77780772, 0xc845c9bb, 0x83ba68be, 0x6ee507d1,
+ 0x2f0159b8, 0x5392c4ed, 0x98336ff6, 0x0b3c7f11, 0xde697aac, 0x893fc8d0, 0x6b83f8f3, 0x47799a0d,
+ 0x801d9dfc, 0x8516a83e, 0x5f8d22ec, 0x0f8ba384, 0xa049dc4b, 0xdd920b05, 0x7a99bc9f, 0x9ad19344,
+ 0x7a345dba, 0xf501a13f, 0x3e58bf19, 0x7fffaf9a, 0x3b4e1511, 0x0e08b991, 0x9e157620, 0x7230a326,
+ 0x4977f9ff, 0x2d2bbae1, 0x607aa7fc, 0x7bc85d5f, 0xb441bbbe, 0x8d8fa5f2, 0x601cce26, 0xda1884f2,
+ 0x81c82d64, 0x200b709c, 0xcbd36abe, 0x8cbdddd3, 0x55ab61d3, 0x7e3ee993, 0x833f18aa, 0xffc1aaea,
+ 0x7362e16a, 0x7fb85db2, 0x904ee04c, 0x7f04dca6, 0x8ad7a046, 0xebe7d8f7, 0xfbc4c687, 0xd0609458,
+ 0x093ed977, 0x8e546085, 0x7f5b8236, 0x7c47e118, 0xa01f2641, 0x7ffb3e48, 0x05de7cda, 0x7fc281b9,
+ 0x8e0278fc, 0xd74e6d07, 0x94c24450, 0x7cf9e641, 0x2ad27871, 0x919fa815, 0x805fd205, 0x7758397f,
+ 0xe2c7e02c, 0x1828e194, 0x5613d6fe, 0xfb55359f, 0xf9699516, 0x8978ee26, 0x7feebad9, 0x77d71d82,
+ 0x55b28b60, 0x7e997600, 0x80821a6b, 0xc6d78af1, 0x691822ab, 0x7f6982a0, 0x7ef56f99, 0x5c307f40,
+ 0xac6f8b76, 0x42cc8ba4, 0x782c61d9, 0xa0224dd0, 0x7bd234d1, 0x74576e3b, 0xe38cfe9a, 0x491e66ef,
+ 0xc78291c5, 0x895bb87f, 0x924f7889, 0x71b89394, 0x757b779d, 0xc4a9c604, 0x5cdf7829, 0x8020e9df,
+ 0x805e8245, 0x4a82c398, 0x6360bd62, 0x78bb60fc, 0x09e0d014, 0x4b0ea180, 0xb841978b, 0x69a0e864,
+ 0x7df35977, 0x3284b0dd, 0x3cdc2efd, 0x57d31f5e, 0x541069cc, 0x1776e92e, 0x04309ea3, 0xa015eb2d,
+ 0xce7bfabc, 0x41b638f8, 0x8365932e, 0x846ab44c, 0xbbcc80cb, 0x8afa6cac, 0x7fc422ea, 0x4e403fc0,
+ 0xbfac9aee, 0x8e4c6709, 0x028e01fb, 0x6d160a9b, 0x7fe93004, 0x790f9cdc, 0x6a1f37a0, 0xf7e7ef30,
+ 0xb4ea0f04, 0x7bf4c8e6, 0xe981701f, 0xc258a9d3, 0x6acbbfba, 0xef5479c7, 0x079c8bd8, 0x1a410f56,
+ 0x6853b799, 0x86cd4f01, 0xc66e23b6, 0x34585565, 0x8d1fe00d, 0x7fcdba1a, 0x32c9717b, 0xa02f9f48,
+ 0xf64940db, 0x5ed7d8f1, 0x61b823b2, 0x356f8918, 0xa0a7151e, 0x793fc969, 0x530beaeb, 0x34e93270,
+ 0x4fc4ddb5, 0x88d58b6c, 0x36094774, 0xf620ac80, 0x03763a72, 0xf910c9a6, 0x6666fb2d, 0x752c8be8,
+ 0x9a6dfdd8, 0xd1a7117d, 0x51c1b1d4, 0x0a67773d, 0x43b32a79, 0x4cdcd085, 0x5f067d30, 0x05bfe92a,
+ 0x7ed7d203, 0xe71a3c85, 0x99127ce2, 0x8eb3cac4, 0xad4bbcea, 0x5c6a0fd0, 0x0eec04af, 0x94e95cd4,
+ 0x8654f921, 0x83eabb5d, 0xb058d7ca, 0x69f12d3c, 0x03d881b2, 0x80558ef7, 0x82938cb3, 0x2ec0e1d6,
+ 0x80044422, 0xd1e47051, 0x720fc6ff, 0x82b20316, 0x0d527b02, 0x63049a15, 0x7ad5b9ad, 0xd2a4641d,
+ 0x41144f86, 0x7b04917a, 0x15c4a2c0, 0x9da07916, 0x211df54a, 0x7fdd09af, 0xfe924f3f, 0x7e132cfe,
+ 0x9a1d18d6, 0x7c56508b, 0x80f0f0af, 0x8095ced6, 0x8037d0d7, 0x026719d1, 0xa55fec43, 0x2b1c7cb7,
+ 0xa5cd5ac1, 0x77639fad, 0x7fcd8b62, 0x81a18c27, 0xaee4912e, 0xeae9eebe, 0xeb3081de, 0x8532aada,
+ 0xc822362e, 0x86a649a9, 0x8031a71d, 0x7b319dc6, 0xea8022e6, 0x814bc5a9, 0x8f62f7a1, 0xa430ea17,
+ 0x388deafb, 0x883b5185, 0x776fe13c, 0x801c683f, 0x87c11b98, 0xb7cbc644, 0x8e9ad3e8, 0x3cf5a10c,
+ 0x7ff6a634, 0x949ef096, 0x9f84aa7c, 0x010af13f, 0x782d1de8, 0xf18e492a, 0x6cf63b01, 0x4301cd81,
+ 0x32d15c9e, 0x68ad8cef, 0xd09bd2d6, 0x908c5c15, 0xd1e36260, 0x2c5bfdd0, 0x88765a99, 0x93deba1e,
+ 0xac6ae342, 0xe865b84c, 0x0f4f2847, 0x7fdf0499, 0x78b1c9b3, 0x6a73261e, 0x601a96f6, 0xd2847933,
+ 0x489aa888, 0xe12e8093, 0x3bfa5a5f, 0xd96ba5f7, 0x7c8f4c8d, 0x80940c6f, 0xcef9dd1a, 0x7e1a055f,
+ 0x3483558b, 0x02b59cc4, 0x0c56333e, 0x05a5b813, 0x92d66287, 0x7516b679, 0x71bfe03f, 0x8056bf68,
+ 0xc24d0724, 0x8416bcf3, 0x234afbdb, 0x4b0d6f9c, 0xaba97333, 0x4b4f42b6, 0x7e8343ab, 0x7ffe2603,
+ 0xe590f73c, 0x45e10c76, 0xb07a6a78, 0xb35609d3, 0x1a027dfd, 0x90cb6e20, 0x82d3fe38, 0x7b409257,
+ 0x0e395afa, 0x1b802093, 0xcb0c6c59, 0x241e17e7, 0x1ee3ea0a, 0x41a82302, 0xab04350a, 0xf570beb7,
+ 0xbb444b9b, 0x83021459, 0x838d65dc, 0x1c439c84, 0x6fdcc454, 0xef9ef325, 0x18626c1c, 0x020d251f,
+ 0xc4aae786, 0x8614cb48, 0xf6f53ca6, 0x8710dbab, 0x89abec0d, 0xf29d41c1, 0x94b50336, 0xfdd49178,
+ 0x604658d1, 0x800e85be, 0xca1bb079, 0x7fa48eeb, 0xa3b7fafe, 0xd330436b, 0x64eb604c, 0x43a658ae,
+ 0x7caa1337, 0xddd445e6, 0x7efbf955, 0xb706ec71, 0x624a6b53, 0x9e0e231f, 0x97097248, 0xa1e1a17a,
+ 0x68dd2e44, 0x7f9d2e14, 0xddcc7074, 0x58324197, 0xc88fc426, 0x6d3640ae, 0x7ef83600, 0x759a0270,
+ 0x98b6d854, 0xd63c9b84, 0x372474a2, 0xe3f18cfd, 0x56ab0bdb, 0x85c9be7e, 0x47dfcfeb, 0xa5830d41,
+ 0x0ddd6283, 0xf4f480ad, 0x74c60e38, 0xab8943c3, 0xc1508fe7, 0x480cdc39, 0x8e097362, 0xa44793be,
+ 0x538b7e18, 0x545f5b41, 0x56529175, 0x9771a97e, 0xc2da7421, 0xea8265f2, 0x805d1163, 0x883c5d28,
+ 0x8ba94c48, 0x4f676e65, 0xf78735b3, 0xe1853671, 0x7f454f53, 0x18147f85, 0x7d09e15d, 0xdb4f3494,
+ 0x795c8973, 0x83310632, 0x85d8061c, 0x9a1a0ebf, 0xc125583c, 0x2a1b1a95, 0x7fd9103f, 0x71e98c72,
+ 0x40932ed7, 0x91ed227a, 0x3c5e560e, 0xe816dee9, 0xb0891b80, 0x600038ba, 0xc7d9a80d, 0x7fff5e09,
+ 0x7e3f4351, 0xbb6b4424, 0xb14448d4, 0x8d6bb7e1, 0xfb153626, 0xa68ad537, 0xd9782006, 0xf62f6991,
+ 0x359ba8c1, 0x02ccff0b, 0x91bf2256, 0x7ea71c4d, 0x560ce5df, 0xeeba289b, 0xa574c4e7, 0x9e04f6ee,
+ 0x7860a5ec, 0x0b8db4a2, 0x968ba3d7, 0x0b6c77df, 0xd6f3157d, 0x402eff1a, 0x49b820b3, 0x8152aebb,
+ 0xd180b0b6, 0x098604d4, 0x7ff92224, 0xede9c996, 0x89c58061, 0x829624c4, 0xc6e71ea7, 0xba94d915,
+ 0x389c3cf6, 0x5b4c5a06, 0x04b335e6, 0x516a8aab, 0x42c8d7d9, 0x92b12af6, 0x86c8549f, 0xfda98acf,
+ 0x819673b6, 0x69545dac, 0x6feaa230, 0x726e6d3f, 0x886ebdfe, 0x34f5730a, 0x7af63ba2, 0x77307bbf,
+ 0x7cd80630, 0x6e45efe0, 0x7f8ad7eb, 0x59d7df99, 0x86c70946, 0xda233629, 0x753f6cbf, 0x825eeb40,
+};
diff --git a/audio_codec/libfaad/helixaac/statname.h b/audio_codec/libfaad/helixaac/statname.h
new file mode 100644
index 0000000..127281c
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/statname.h
@@ -0,0 +1,115 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: statname.h,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * statname.h - name mangling macros for static linking
+ **************************************************************************************/
+
+#ifndef _STATNAME_H
+#define _STATNAME_H
+
+/* define STAT_PREFIX to a unique name for static linking
+ * all the C functions and global variables will be mangled by the preprocessor
+ * e.g. void DCT4(...) becomes void raac_DCT4(...)
+ */
+#define STAT_PREFIX raac
+
+#define STATCC1(x,y,z) STATCC2(x,y,z)
+#define STATCC2(x,y,z) x##y##z
+
+#ifdef STAT_PREFIX
+#define STATNAME(func) STATCC1(STAT_PREFIX, _, func)
+#else
+#define STATNAME(func) func
+#endif
+
+/* these symbols are common to all implementations */
+#define AllocateBuffers STATNAME(AllocateBuffers)
+#define FreeBuffers STATNAME(FreeBuffers)
+#define ClearBuffer STATNAME(ClearBuffer)
+
+#define SetRawBlockParams STATNAME(SetRawBlockParams)
+#define PrepareRawBlock STATNAME(PrepareRawBlock)
+#define FlushCodec STATNAME(FlushCodec)
+
+#define UnpackADTSHeader STATNAME(UnpackADTSHeader)
+#define GetADTSChannelMapping STATNAME(GetADTSChannelMapping)
+#define UnpackADIFHeader STATNAME(UnpackADIFHeader)
+#define DecodeNextElement STATNAME(DecodeNextElement)
+#define DecodeNoiselessData STATNAME(DecodeNoiselessData)
+#define Dequantize STATNAME(Dequantize)
+#define StereoProcess STATNAME(StereoProcess)
+#define DeinterleaveShortBlocks STATNAME(DeinterleaveShortBlocks)
+#define PNS STATNAME(PNS)
+#define TNSFilter STATNAME(TNSFilter)
+#define IMDCT STATNAME(IMDCT)
+
+#define InitSBR STATNAME(InitSBR)
+#define DecodeSBRBitstream STATNAME(DecodeSBRBitstream)
+#define DecodeSBRData STATNAME(DecodeSBRData)
+#define FreeSBR STATNAME(FreeSBR)
+#define FlushCodecSBR STATNAME(FlushCodecSBR)
+
+/* global ROM tables */
+#define sampRateTab STATNAME(sampRateTab)
+#define predSFBMax STATNAME(predSFBMax)
+#define channelMapTab STATNAME(channelMapTab)
+#define elementNumChans STATNAME(elementNumChans)
+#define sfBandTotalShort STATNAME(sfBandTotalShort)
+#define sfBandTotalLong STATNAME(sfBandTotalLong)
+#define sfBandTabShortOffset STATNAME(sfBandTabShortOffset)
+#define sfBandTabShort STATNAME(sfBandTabShort)
+#define sfBandTabLongOffset STATNAME(sfBandTabLongOffset)
+#define sfBandTabLong STATNAME(sfBandTabLong)
+#define tnsMaxBandsShortOffset STATNAME(tnsMaxBandsShortOffset)
+#define tnsMaxBandsShort STATNAME(tnsMaxBandsShort)
+#define tnsMaxOrderShort STATNAME(tnsMaxOrderShort)
+#define tnsMaxBandsLongOffset STATNAME(tnsMaxBandsLongOffset)
+#define tnsMaxBandsLong STATNAME(tnsMaxBandsLong)
+#define tnsMaxOrderLong STATNAME(tnsMaxOrderLong)
+
+/* in your implementation's top-level include file (e.g. real\coder.h) you should
+ * add new #define sym STATNAME(sym) lines for all the
+ * additional global functions or variables which your
+ * implementation uses
+ */
+
+#endif /* _STATNAME_H */
diff --git a/audio_codec/libfaad/helixaac/stproc.c b/audio_codec/libfaad/helixaac/stproc.c
new file mode 100644
index 0000000..852fefa
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/stproc.c
@@ -0,0 +1,251 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: stproc.c,v 1.3 2005/05/24 16:01:55 albertofloyd Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * stproc.c - mid-side and intensity stereo processing
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+/* pow14[0][i] = -pow(2, i/4.0)
+ * pow14[1][i] = +pow(2, i/4.0)
+ *
+ * i = [0,1,2,3]
+ * format = Q30
+ */
+static const int pow14[2][4] = {
+ { 0xc0000000, 0xb3e407d7, 0xa57d8666, 0x945d819b },
+ { 0x40000000, 0x4c1bf829, 0x5a82799a, 0x6ba27e65 }
+};
+
+/**************************************************************************************
+ * Function: StereoProcessGroup
+ *
+ * Description: apply mid-side and intensity stereo to group of transform coefficients
+ *
+ * Inputs: dequantized transform coefficients for both channels
+ * pointer to appropriate scalefactor band table
+ * mid-side mask enabled flag
+ * buffer with mid-side mask (one bit for each scalefactor band)
+ * bit offset into mid-side mask buffer
+ * max coded scalefactor band
+ * buffer of codebook indices for right channel
+ * buffer of scalefactors for right channel, range = [0, 256]
+ *
+ * Outputs: updated transform coefficients in Q(FBITS_OUT_DQ_OFF)
+ * updated minimum guard bit count for both channels
+ *
+ * Return: none
+ *
+ * Notes: assume no guard bits in input
+ * gains 0 int bits
+ **************************************************************************************/
+static void StereoProcessGroup(int *coefL, int *coefR, const short *sfbTab,
+ int msMaskPres, unsigned char *msMaskPtr, int msMaskOffset, int maxSFB,
+ unsigned char *cbRight, short *sfRight, int *gbCurrent)
+{
+ int sfb, width, cbIdx, sf, cl, cr, scalef, scalei;
+ int gbMaskL, gbMaskR;
+ unsigned char msMask;
+
+ msMask = (*msMaskPtr++) >> msMaskOffset;
+ gbMaskL = 0;
+ gbMaskR = 0;
+
+ for (sfb = 0; sfb < maxSFB; sfb++) {
+ width = sfbTab[sfb + 1] - sfbTab[sfb]; /* assume >= 0 (see sfBandTabLong/sfBandTabShort) */
+ cbIdx = cbRight[sfb];
+
+ if (cbIdx == 14 || cbIdx == 15) {
+ /* intensity stereo */
+ if (msMaskPres == 1 && (msMask & 0x01)) {
+ cbIdx ^= 0x01; /* invert_intensity(): 14 becomes 15, or 15 becomes 14 */
+ }
+ sf = -sfRight[sfb]; /* negative since we use identity 0.5^(x) = 2^(-x) (see spec) */
+ cbIdx &= 0x01; /* choose - or + scale factor */
+ scalef = pow14[cbIdx][sf & 0x03];
+ scalei = (sf >> 2) + 2; /* +2 to compensate for scalef = Q30 */
+
+ if (scalei > 0) {
+ if (scalei > 30) {
+ scalei = 30;
+ }
+ do {
+ cr = MULSHIFT32(*coefL++, scalef);
+ CLIP_2N(cr, 31 - scalei);
+ cr <<= scalei;
+ gbMaskR |= FASTABS(cr);
+ *coefR++ = cr;
+ } while (--width > 0);
+ } else {
+ scalei = -scalei;
+ if (scalei > 31) {
+ scalei = 31;
+ }
+ do {
+ cr = MULSHIFT32(*coefL++, scalef) >> scalei;
+ gbMaskR |= FASTABS(cr);
+ *coefR++ = cr;
+ } while (--width > 0);
+ }
+ } else if (cbIdx != 13 && ((msMaskPres == 1 && (msMask & 0x01)) || msMaskPres == 2)) {
+ /* mid-side stereo (assumes no GB in inputs) */
+ do {
+ cl = *coefL;
+ cr = *coefR;
+
+ if ((FASTABS(cl) | FASTABS(cr)) >> 30) {
+ /* avoid overflow (rare) */
+ cl >>= 1;
+ sf = cl + (cr >> 1);
+ CLIP_2N(sf, 30);
+ sf <<= 1;
+ cl = cl - (cr >> 1);
+ CLIP_2N(cl, 30);
+ cl <<= 1;
+ } else {
+ /* usual case */
+ sf = cl + cr;
+ cl -= cr;
+ }
+
+ *coefL++ = sf;
+ gbMaskL |= FASTABS(sf);
+ *coefR++ = cl;
+ gbMaskR |= FASTABS(cl);
+ } while (--width > 0);
+
+ } else {
+ /* nothing to do */
+ coefL += width;
+ coefR += width;
+ }
+
+ /* get next mask bit (should be branchless on ARM) */
+ msMask >>= 1;
+ if (++msMaskOffset == 8) {
+ msMask = *msMaskPtr++;
+ msMaskOffset = 0;
+ }
+ }
+
+ cl = CLZ(gbMaskL) - 1;
+ if (gbCurrent[0] > cl) {
+ gbCurrent[0] = cl;
+ }
+
+ cr = CLZ(gbMaskR) - 1;
+ if (gbCurrent[1] > cr) {
+ gbCurrent[1] = cr;
+ }
+
+ return;
+}
+
+/**************************************************************************************
+ * Function: StereoProcess
+ *
+ * Description: apply mid-side and intensity stereo, if enabled
+ *
+ * Inputs: valid AACDecInfo struct (including dequantized transform coefficients)
+ *
+ * Outputs: updated transform coefficients in Q(FBITS_OUT_DQ_OFF)
+ * updated minimum guard bit count for both channels
+ *
+ * Return: 0 if successful, -1 if error
+ **************************************************************************************/
+int StereoProcess(AACDecInfo *aacDecInfo)
+{
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+ int gp, win, nSamps, msMaskOffset;
+ int *coefL, *coefR;
+ unsigned char *msMaskPtr;
+ const short *sfbTab;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ /* mid-side and intensity stereo require common_window == 1 (see MPEG4 spec, Correction 2, 2004) */
+ if (psi->commonWin != 1 || aacDecInfo->currBlockID != AAC_ID_CPE) {
+ return ERR_AAC_NONE;
+ }
+
+ /* nothing to do */
+ if (!psi->msMaskPresent && !psi->intensityUsed[1]) {
+ return ERR_AAC_NONE;
+ }
+
+ icsInfo = &(psi->icsInfo[0]);
+ if (icsInfo->winSequence == 2) {
+ sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_SHORT;
+ } else {
+ sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_LONG;
+ }
+ coefL = psi->coef[0];
+ coefR = psi->coef[1];
+
+ /* do fused mid-side/intensity processing for each block (one long or eight short) */
+ msMaskOffset = 0;
+ msMaskPtr = psi->msMaskBits;
+ for (gp = 0; gp < icsInfo->numWinGroup; gp++) {
+ for (win = 0; win < icsInfo->winGroupLen[gp]; win++) {
+ StereoProcessGroup(coefL, coefR, sfbTab, psi->msMaskPresent,
+ msMaskPtr, msMaskOffset, icsInfo->maxSFB, psi->sfbCodeBook[1] + gp * icsInfo->maxSFB,
+ psi->scaleFactors[1] + gp * icsInfo->maxSFB, psi->gbCurrent);
+ coefL += nSamps;
+ coefR += nSamps;
+ }
+ /* we use one bit per sfb, so there are maxSFB bits for each window group */
+ msMaskPtr += (msMaskOffset + icsInfo->maxSFB) >> 3;
+ msMaskOffset = (msMaskOffset + icsInfo->maxSFB) & 0x07;
+ }
+
+ ASSERT(coefL == psi->coef[0] + 1024, ERR_AAC_COFF_EXCEED_RANGE);
+ ASSERT(coefR == psi->coef[1] + 1024, ERR_AAC_COFF_EXCEED_RANGE);
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/libfaad/helixaac/tns_helix.c b/audio_codec/libfaad/helixaac/tns_helix.c
new file mode 100644
index 0000000..7607502
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/tns_helix.c
@@ -0,0 +1,307 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: tns.c,v 1.1.2.2 2005/05/24 20:34:40 albertofloyd Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * tns.c - apply TNS to spectrum
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+#define FBITS_LPC_COEFS 20
+
+/* inverse quantization tables for TNS filter coefficients, format = Q31
+ * see bottom of file for table generation
+ * negative (vs. spec) since we use MADD for filter kernel
+ */
+static const int invQuant3[16] = {
+ 0x00000000, 0xc8767f65, 0x9becf22c, 0x83358feb, 0x83358feb, 0x9becf22c, 0xc8767f65, 0x00000000,
+ 0x2bc750e9, 0x5246dd49, 0x6ed9eba1, 0x7e0e2e32, 0x7e0e2e32, 0x6ed9eba1, 0x5246dd49, 0x2bc750e9,
+};
+
+static const int invQuant4[16] = {
+ 0x00000000, 0xe5632654, 0xcbf00dbe, 0xb4c373ee, 0xa0e0a15f, 0x9126145f, 0x8643c7b3, 0x80b381ac,
+ 0x7f7437ad, 0x7b1d1a49, 0x7294b5f2, 0x66256db2, 0x563ba8aa, 0x4362210e, 0x2e3d2abb, 0x17851aad,
+};
+
+/**************************************************************************************
+ * Function: DecodeLPCCoefs
+ *
+ * Description: decode LPC coefficients for TNS
+ *
+ * Inputs: order of TNS filter
+ * resolution of coefficients (3 or 4 bits)
+ * coefficients unpacked from bitstream
+ * scratch buffer (b) of size >= order
+ *
+ * Outputs: LPC coefficients in Q(FBITS_LPC_COEFS), in 'a'
+ *
+ * Return: none
+ *
+ * Notes: assumes no guard bits in input transform coefficients
+ * a[i] = Q(FBITS_LPC_COEFS), don't store a0 = 1.0
+ * (so a[0] = first delay tap, etc.)
+ * max abs(a[i]) < log2(order), so for max order = 20 a[i] < 4.4
+ * (up to 3 bits of gain) so a[i] has at least 31 - FBITS_LPC_COEFS - 3
+ * guard bits
+ * to ensure no intermediate overflow in all-pole filter, set
+ * FBITS_LPC_COEFS such that number of guard bits >= log2(max order)
+ **************************************************************************************/
+static void DecodeLPCCoefs(int order, int res, signed char *filtCoef, int *a, int *b)
+{
+ int i, m, t;
+ const int *invQuantTab;
+
+ if (res == 3) {
+ invQuantTab = invQuant3;
+ } else if (res == 4) {
+ invQuantTab = invQuant4;
+ } else {
+ return;
+ }
+
+ for (m = 0; m < order; m++) {
+ t = invQuantTab[filtCoef[m] & 0x0f]; /* t = Q31 */
+ for (i = 0; i < m; i++) {
+ b[i] = a[i] - (MULSHIFT32(t, a[m - i - 1]) << 1);
+ }
+ for (i = 0; i < m; i++) {
+ a[i] = b[i];
+ }
+ a[m] = t >> (31 - FBITS_LPC_COEFS);
+ }
+}
+
+/**************************************************************************************
+ * Function: FilterRegion
+ *
+ * Description: apply LPC filter to one region of coefficients
+ *
+ * Inputs: number of transform coefficients in this region
+ * direction flag (forward = 1, backward = -1)
+ * order of filter
+ * 'size' transform coefficients
+ * 'order' LPC coefficients in Q(FBITS_LPC_COEFS)
+ * scratch buffer for history (must be >= order samples long)
+ *
+ * Outputs: filtered transform coefficients
+ *
+ * Return: guard bit mask (OR of abs value of all filtered transform coefs)
+ *
+ * Notes: assumes no guard bits in input transform coefficients
+ * gains 0 int bits
+ * history buffer does not need to be preserved between regions
+ **************************************************************************************/
+static int FilterRegion(int size, int dir, int order, int *audioCoef, int *a, int *hist)
+{
+ int i, j, y, hi32, inc, gbMask;
+ U64 sum64;
+
+ /* init history to 0 every time */
+ for (i = 0; i < order; i++) {
+ hist[i] = 0;
+ }
+
+ sum64.w64 = 0; /* avoid warning */
+ gbMask = 0;
+ inc = (dir ? -1 : 1);
+ do {
+ /* sum64 = a0*y[n] = 1.0*y[n] */
+ y = *audioCoef;
+ sum64.r.hi32 = y >> (32 - FBITS_LPC_COEFS);
+ sum64.r.lo32 = y << FBITS_LPC_COEFS;
+
+ /* sum64 += (a1*y[n-1] + a2*y[n-2] + ... + a[order-1]*y[n-(order-1)]) */
+ for (j = order - 1; j > 0; j--) {
+ sum64.w64 = MADD64(sum64.w64, hist[j], a[j]);
+ hist[j] = hist[j - 1];
+ }
+ sum64.w64 = MADD64(sum64.w64, hist[0], a[0]);
+ y = (sum64.r.hi32 << (32 - FBITS_LPC_COEFS)) | (sum64.r.lo32 >> FBITS_LPC_COEFS);
+
+ /* clip output (rare) */
+ hi32 = sum64.r.hi32;
+ if ((hi32 >> 31) != (hi32 >> (FBITS_LPC_COEFS - 1))) {
+ y = (hi32 >> 31) ^ 0x7fffffff;
+ }
+
+ hist[0] = y;
+ *audioCoef = y;
+ audioCoef += inc;
+ gbMask |= FASTABS(y);
+ } while (--size);
+
+ return gbMask;
+}
+
+/**************************************************************************************
+ * Function: TNSFilter
+ *
+ * Description: apply temporal noise shaping, if enabled
+ *
+ * Inputs: valid AACDecInfo struct
+ * index of current channel
+ *
+ * Outputs: updated transform coefficients
+ * updated minimum guard bit count for this channel
+ *
+ * Return: 0 if successful, -1 if error
+ **************************************************************************************/
+int TNSFilter(AACDecInfo *aacDecInfo, int ch)
+{
+ int win, winLen, nWindows, nSFB, filt, bottom, top, order, maxOrder, dir;
+ int start, end, size, tnsMaxBand, numFilt, gbMask;
+ int *audioCoef;
+ unsigned char *filtLength, *filtOrder, *filtRes, *filtDir;
+ signed char *filtCoef;
+ const unsigned char *tnsMaxBandTab;
+ const short *sfbTab;
+ ICSInfo *icsInfo;
+ TNSInfo *ti;
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+ ti = &psi->tnsInfo[ch];
+
+ if (!ti->tnsDataPresent) {
+ return 0;
+ }
+
+ if (icsInfo->winSequence == 2) {
+ nWindows = NWINDOWS_SHORT;
+ winLen = NSAMPS_SHORT;
+ nSFB = sfBandTotalShort[psi->sampRateIdx];
+ maxOrder = tnsMaxOrderShort[aacDecInfo->profile];
+ sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx];
+ tnsMaxBandTab = tnsMaxBandsShort + tnsMaxBandsShortOffset[aacDecInfo->profile];
+ tnsMaxBand = tnsMaxBandTab[psi->sampRateIdx];
+ } else {
+ nWindows = NWINDOWS_LONG;
+ winLen = NSAMPS_LONG;
+ nSFB = sfBandTotalLong[psi->sampRateIdx];
+ maxOrder = tnsMaxOrderLong[aacDecInfo->profile];
+ sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx];
+ tnsMaxBandTab = tnsMaxBandsLong + tnsMaxBandsLongOffset[aacDecInfo->profile];
+ tnsMaxBand = tnsMaxBandTab[psi->sampRateIdx];
+ }
+
+ if (tnsMaxBand > icsInfo->maxSFB) {
+ tnsMaxBand = icsInfo->maxSFB;
+ }
+
+ filtRes = ti->coefRes;
+ filtLength = ti->length;
+ filtOrder = ti->order;
+ filtDir = ti->dir;
+ filtCoef = ti->coef;
+
+ gbMask = 0;
+ audioCoef = psi->coef[ch];
+ for (win = 0; win < nWindows; win++) {
+ bottom = nSFB;
+ numFilt = ti->numFilt[win];
+ for (filt = 0; filt < numFilt; filt++) {
+ top = bottom;
+ bottom = top - *filtLength++;
+ bottom = MAX(bottom, 0);
+ order = *filtOrder++;
+ order = MIN(order, maxOrder);
+
+ if (order) {
+ start = sfbTab[MIN(bottom, tnsMaxBand)];
+ end = sfbTab[MIN(top, tnsMaxBand)];
+ size = end - start;
+ if (size > 0) {
+ dir = *filtDir++;
+ if (dir) {
+ start = end - 1;
+ }
+
+ DecodeLPCCoefs(order, filtRes[win], filtCoef, psi->tnsLPCBuf, psi->tnsWorkBuf);
+ gbMask |= FilterRegion(size, dir, order, audioCoef + start, psi->tnsLPCBuf, psi->tnsWorkBuf);
+ }
+ filtCoef += order;
+ }
+ }
+ audioCoef += winLen;
+ }
+
+ /* update guard bit count if necessary */
+ size = CLZ(gbMask) - 1;
+ if (psi->gbCurrent[ch] > size) {
+ psi->gbCurrent[ch] = size;
+ }
+
+ return 0;
+}
+
+/* Code to generate invQuantXXX[] tables
+ * {
+ * int res, i, t;
+ * double powScale, iqfac, iqfac_m, d;
+ *
+ * powScale = pow(2.0, 31) * -1.0; / ** make coefficients negative for using MADD in kernel ** /
+ * for (res = 3; res <= 4; res++) {
+ * iqfac = ( ((1 << (res-1)) - 0.5) * (2.0 / M_PI) );
+ * iqfac_m = ( ((1 << (res-1)) + 0.5) * (2.0 / M_PI) );
+ * printf("static const int invQuant%d[16] = {\n", res);
+ * for (i = 0; i < 16; i++) {
+ * / ** extend bottom 4 bits into signed, 2's complement number ** /
+ * t = (i << 28) >> 28;
+ *
+ * if (t >= 0) d = sin(t / iqfac);
+ * else d = sin(t / iqfac_m);
+ *
+ * d *= powScale;
+ * printf("0x%08x, ", (int)(d > 0 ? d + 0.5 : d - 0.5));
+ * if ((i & 0x07) == 0x07)
+ * printf("\n");
+ * }
+ * printf("};\n\n");
+ * }
+ * }
+ */
+
diff --git a/audio_codec/libfaad/helixaac/trigtabs.c b/audio_codec/libfaad/helixaac/trigtabs.c
new file mode 100644
index 0000000..0a77b6f
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/trigtabs.c
@@ -0,0 +1,1000 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: trigtabs.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * trigtabs.c - tables of sin, cos, etc. for IMDCT
+ **************************************************************************************/
+
+#include "coder.h"
+
+const int cos4sin4tabOffset[NUM_IMDCT_SIZES] = {0, 128};
+
+/* PreMultiply() tables
+ * format = Q30 * 2^[-7, -10] for nmdct = [128, 1024]
+ * reordered for sequential access
+ *
+ * invM = -1.0 / nmdct;
+ * for (i = 0; i < nmdct/4; i++) {
+ * angle = (i + 0.25) * M_PI / nmdct;
+ * x = invM * (cos(angle) + sin(angle));
+ * x = invM * sin(angle);
+ *
+ * angle = (nmdct/2 - 1 - i + 0.25) * M_PI / nmdct;
+ * x = invM * (cos(angle) + sin(angle));
+ * x = invM * sin(angle);
+ * }
+ */
+const int cos4sin4tab[128 + 1024] = {
+ /* 128 - format = Q30 * 2^-7 */
+ 0xbf9bc731, 0xff9b783c, 0xbed5332c, 0xc002c697, 0xbe112251, 0xfe096c8d, 0xbd4f9c30, 0xc00f1c4a,
+ 0xbc90a83f, 0xfc77ae5e, 0xbbd44dd9, 0xc0254e27, 0xbb1a9443, 0xfae67ba2, 0xba6382a6, 0xc04558c0,
+ 0xb9af200f, 0xf9561237, 0xb8fd7373, 0xc06f3726, 0xb84e83ac, 0xf7c6afdc, 0xb7a25779, 0xc0a2e2e3,
+ 0xb6f8f57c, 0xf6389228, 0xb652643e, 0xc0e05401, 0xb5aeaa2a, 0xf4abf67e, 0xb50dcd90, 0xc1278104,
+ 0xb46fd4a4, 0xf3211a07, 0xb3d4c57c, 0xc1785ef4, 0xb33ca614, 0xf19839a6, 0xb2a77c49, 0xc1d2e158,
+ 0xb2154dda, 0xf01191f3, 0xb186206b, 0xc236fa3b, 0xb0f9f981, 0xee8d5f29, 0xb070de82, 0xc2a49a2e,
+ 0xafead4b9, 0xed0bdd25, 0xaf67e14f, 0xc31bb049, 0xaee80952, 0xeb8d475b, 0xae6b51ae, 0xc39c2a2f,
+ 0xadf1bf34, 0xea11d8c8, 0xad7b5692, 0xc425f410, 0xad081c5a, 0xe899cbf1, 0xac9814fd, 0xc4b8f8ad,
+ 0xac2b44cc, 0xe7255ad1, 0xabc1aff9, 0xc555215a, 0xab5b5a96, 0xe5b4bed8, 0xaaf84896, 0xc5fa5603,
+ 0xaa987dca, 0xe44830dd, 0xaa3bfde3, 0xc6a87d2d, 0xa9e2cc73, 0xe2dfe917, 0xa98cece9, 0xc75f7bfe,
+ 0xa93a6296, 0xe17c1f15, 0xa8eb30a7, 0xc81f363d, 0xa89f5a2b, 0xe01d09b4, 0xa856e20e, 0xc8e78e5b,
+ 0xa811cb1b, 0xdec2df18, 0xa7d017fc, 0xc9b86572, 0xa791cb39, 0xdd6dd4a2, 0xa756e73a, 0xca919b4e,
+ 0xa71f6e43, 0xdc1e1ee9, 0xa6eb6279, 0xcb730e70, 0xa6bac5dc, 0xdad3f1b1, 0xa68d9a4c, 0xcc5c9c14,
+ 0xa663e188, 0xd98f7fe6, 0xa63d9d2b, 0xcd4e2037, 0xa61aceaf, 0xd850fb8e, 0xa5fb776b, 0xce47759a,
+ 0xa5df9894, 0xd71895c9, 0xa5c7333e, 0xcf4875ca, 0xa5b2485a, 0xd5e67ec1, 0xa5a0d8b5, 0xd050f926,
+ 0xa592e4fd, 0xd4bae5ab, 0xa5886dba, 0xd160d6e5, 0xa5817354, 0xd395f8ba, 0xa57df60f, 0xd277e518,
+ /* 1024 - format = Q30 * 2^-10 */
+ 0xbff3703e, 0xfff36f02, 0xbfda5824, 0xc0000b1a, 0xbfc149ed, 0xffc12b16, 0xbfa845a0, 0xc0003c74,
+ 0xbf8f4b3e, 0xff8ee750, 0xbf765acc, 0xc0009547, 0xbf5d744e, 0xff5ca3d0, 0xbf4497c8, 0xc0011594,
+ 0xbf2bc53d, 0xff2a60b4, 0xbf12fcb2, 0xc001bd5c, 0xbefa3e2a, 0xfef81e1d, 0xbee189a8, 0xc0028c9c,
+ 0xbec8df32, 0xfec5dc28, 0xbeb03eca, 0xc0038356, 0xbe97a875, 0xfe939af5, 0xbe7f1c36, 0xc004a188,
+ 0xbe669a10, 0xfe615aa3, 0xbe4e2209, 0xc005e731, 0xbe35b423, 0xfe2f1b50, 0xbe1d5062, 0xc0075452,
+ 0xbe04f6cb, 0xfdfcdd1d, 0xbdeca760, 0xc008e8e8, 0xbdd46225, 0xfdcaa027, 0xbdbc2720, 0xc00aa4f3,
+ 0xbda3f652, 0xfd98648d, 0xbd8bcfbf, 0xc00c8872, 0xbd73b36d, 0xfd662a70, 0xbd5ba15d, 0xc00e9364,
+ 0xbd439995, 0xfd33f1ed, 0xbd2b9c17, 0xc010c5c7, 0xbd13a8e7, 0xfd01bb24, 0xbcfbc00a, 0xc0131f9b,
+ 0xbce3e182, 0xfccf8634, 0xbccc0d53, 0xc015a0dd, 0xbcb44382, 0xfc9d533b, 0xbc9c8411, 0xc018498c,
+ 0xbc84cf05, 0xfc6b2259, 0xbc6d2461, 0xc01b19a7, 0xbc558428, 0xfc38f3ac, 0xbc3dee5f, 0xc01e112b,
+ 0xbc266309, 0xfc06c754, 0xbc0ee22a, 0xc0213018, 0xbbf76bc4, 0xfbd49d70, 0xbbdfffdd, 0xc024766a,
+ 0xbbc89e77, 0xfba2761e, 0xbbb14796, 0xc027e421, 0xbb99fb3e, 0xfb70517d, 0xbb82b972, 0xc02b7939,
+ 0xbb6b8235, 0xfb3e2fac, 0xbb54558d, 0xc02f35b1, 0xbb3d337b, 0xfb0c10cb, 0xbb261c04, 0xc0331986,
+ 0xbb0f0f2b, 0xfad9f4f8, 0xbaf80cf4, 0xc03724b6, 0xbae11561, 0xfaa7dc52, 0xbaca2878, 0xc03b573f,
+ 0xbab3463b, 0xfa75c6f8, 0xba9c6eae, 0xc03fb11d, 0xba85a1d4, 0xfa43b508, 0xba6edfb1, 0xc044324f,
+ 0xba582849, 0xfa11a6a3, 0xba417b9e, 0xc048dad1, 0xba2ad9b5, 0xf9df9be6, 0xba144291, 0xc04daaa1,
+ 0xb9fdb635, 0xf9ad94f0, 0xb9e734a4, 0xc052a1bb, 0xb9d0bde4, 0xf97b91e1, 0xb9ba51f6, 0xc057c01d,
+ 0xb9a3f0de, 0xf94992d7, 0xb98d9aa0, 0xc05d05c3, 0xb9774f3f, 0xf91797f0, 0xb9610ebe, 0xc06272aa,
+ 0xb94ad922, 0xf8e5a14d, 0xb934ae6d, 0xc06806ce, 0xb91e8ea3, 0xf8b3af0c, 0xb90879c7, 0xc06dc22e,
+ 0xb8f26fdc, 0xf881c14b, 0xb8dc70e7, 0xc073a4c3, 0xb8c67cea, 0xf84fd829, 0xb8b093ea, 0xc079ae8c,
+ 0xb89ab5e8, 0xf81df3c5, 0xb884e2e9, 0xc07fdf85, 0xb86f1af0, 0xf7ec143e, 0xb8595e00, 0xc08637a9,
+ 0xb843ac1d, 0xf7ba39b3, 0xb82e0549, 0xc08cb6f5, 0xb818698a, 0xf7886442, 0xb802d8e0, 0xc0935d64,
+ 0xb7ed5351, 0xf756940a, 0xb7d7d8df, 0xc09a2af3, 0xb7c2698e, 0xf724c92a, 0xb7ad0561, 0xc0a11f9d,
+ 0xb797ac5b, 0xf6f303c0, 0xb7825e80, 0xc0a83b5e, 0xb76d1bd2, 0xf6c143ec, 0xb757e455, 0xc0af7e33,
+ 0xb742b80d, 0xf68f89cb, 0xb72d96fd, 0xc0b6e815, 0xb7188127, 0xf65dd57d, 0xb7037690, 0xc0be7901,
+ 0xb6ee773a, 0xf62c2721, 0xb6d98328, 0xc0c630f2, 0xb6c49a5e, 0xf5fa7ed4, 0xb6afbce0, 0xc0ce0fe3,
+ 0xb69aeab0, 0xf5c8dcb6, 0xb68623d1, 0xc0d615cf, 0xb6716847, 0xf59740e5, 0xb65cb815, 0xc0de42b2,
+ 0xb648133e, 0xf565ab80, 0xb63379c5, 0xc0e69686, 0xb61eebae, 0xf5341ca5, 0xb60a68fb, 0xc0ef1147,
+ 0xb5f5f1b1, 0xf5029473, 0xb5e185d1, 0xc0f7b2ee, 0xb5cd255f, 0xf4d11308, 0xb5b8d05f, 0xc1007b77,
+ 0xb5a486d2, 0xf49f9884, 0xb59048be, 0xc1096add, 0xb57c1624, 0xf46e2504, 0xb567ef08, 0xc1128119,
+ 0xb553d36c, 0xf43cb8a7, 0xb53fc355, 0xc11bbe26, 0xb52bbec4, 0xf40b538b, 0xb517c5be, 0xc12521ff,
+ 0xb503d845, 0xf3d9f5cf, 0xb4eff65c, 0xc12eac9d, 0xb4dc2007, 0xf3a89f92, 0xb4c85548, 0xc1385dfb,
+ 0xb4b49622, 0xf37750f2, 0xb4a0e299, 0xc1423613, 0xb48d3ab0, 0xf3460a0d, 0xb4799e69, 0xc14c34df,
+ 0xb4660dc8, 0xf314cb02, 0xb45288cf, 0xc1565a58, 0xb43f0f82, 0xf2e393ef, 0xb42ba1e4, 0xc160a678,
+ 0xb4183ff7, 0xf2b264f2, 0xb404e9bf, 0xc16b193a, 0xb3f19f3e, 0xf2813e2a, 0xb3de6078, 0xc175b296,
+ 0xb3cb2d70, 0xf2501fb5, 0xb3b80628, 0xc1807285, 0xb3a4eaa4, 0xf21f09b1, 0xb391dae6, 0xc18b5903,
+ 0xb37ed6f1, 0xf1edfc3d, 0xb36bdec9, 0xc1966606, 0xb358f26f, 0xf1bcf777, 0xb34611e8, 0xc1a1998a,
+ 0xb3333d36, 0xf18bfb7d, 0xb320745c, 0xc1acf386, 0xb30db75d, 0xf15b086d, 0xb2fb063b, 0xc1b873f5,
+ 0xb2e860fa, 0xf12a1e66, 0xb2d5c79d, 0xc1c41ace, 0xb2c33a26, 0xf0f93d86, 0xb2b0b898, 0xc1cfe80a,
+ 0xb29e42f6, 0xf0c865ea, 0xb28bd943, 0xc1dbdba3, 0xb2797b82, 0xf09797b2, 0xb26729b5, 0xc1e7f591,
+ 0xb254e3e0, 0xf066d2fa, 0xb242aa05, 0xc1f435cc, 0xb2307c27, 0xf03617e2, 0xb21e5a49, 0xc2009c4e,
+ 0xb20c446d, 0xf0056687, 0xb1fa3a97, 0xc20d290d, 0xb1e83cc9, 0xefd4bf08, 0xb1d64b06, 0xc219dc03,
+ 0xb1c46551, 0xefa42181, 0xb1b28bad, 0xc226b528, 0xb1a0be1b, 0xef738e12, 0xb18efca0, 0xc233b473,
+ 0xb17d473d, 0xef4304d8, 0xb16b9df6, 0xc240d9de, 0xb15a00cd, 0xef1285f2, 0xb1486fc5, 0xc24e255e,
+ 0xb136eae1, 0xeee2117c, 0xb1257223, 0xc25b96ee, 0xb114058e, 0xeeb1a796, 0xb102a524, 0xc2692e83,
+ 0xb0f150e9, 0xee81485c, 0xb0e008e0, 0xc276ec16, 0xb0cecd09, 0xee50f3ed, 0xb0bd9d6a, 0xc284cf9f,
+ 0xb0ac7a03, 0xee20aa67, 0xb09b62d8, 0xc292d914, 0xb08a57eb, 0xedf06be6, 0xb079593f, 0xc2a1086d,
+ 0xb06866d7, 0xedc0388a, 0xb05780b5, 0xc2af5da2, 0xb046a6db, 0xed901070, 0xb035d94e, 0xc2bdd8a9,
+ 0xb025180e, 0xed5ff3b5, 0xb014631e, 0xc2cc7979, 0xb003ba82, 0xed2fe277, 0xaff31e3b, 0xc2db400a,
+ 0xafe28e4d, 0xecffdcd4, 0xafd20ab9, 0xc2ea2c53, 0xafc19383, 0xeccfe2ea, 0xafb128ad, 0xc2f93e4a,
+ 0xafa0ca39, 0xec9ff4d6, 0xaf90782a, 0xc30875e5, 0xaf803283, 0xec7012b5, 0xaf6ff945, 0xc317d31c,
+ 0xaf5fcc74, 0xec403ca5, 0xaf4fac12, 0xc32755e5, 0xaf3f9822, 0xec1072c4, 0xaf2f90a5, 0xc336fe37,
+ 0xaf1f959f, 0xebe0b52f, 0xaf0fa712, 0xc346cc07, 0xaeffc500, 0xebb10404, 0xaeefef6c, 0xc356bf4d,
+ 0xaee02658, 0xeb815f60, 0xaed069c7, 0xc366d7fd, 0xaec0b9bb, 0xeb51c760, 0xaeb11636, 0xc377160f,
+ 0xaea17f3b, 0xeb223c22, 0xae91f4cd, 0xc3877978, 0xae8276ed, 0xeaf2bdc3, 0xae73059f, 0xc398022f,
+ 0xae63a0e3, 0xeac34c60, 0xae5448be, 0xc3a8b028, 0xae44fd31, 0xea93e817, 0xae35be3f, 0xc3b9835a,
+ 0xae268be9, 0xea649105, 0xae176633, 0xc3ca7bba, 0xae084d1f, 0xea354746, 0xadf940ae, 0xc3db993e,
+ 0xadea40e4, 0xea060af9, 0xaddb4dc2, 0xc3ecdbdc, 0xadcc674b, 0xe9d6dc3b, 0xadbd8d82, 0xc3fe4388,
+ 0xadaec067, 0xe9a7bb28, 0xad9fffff, 0xc40fd037, 0xad914c4b, 0xe978a7dd, 0xad82a54c, 0xc42181e0,
+ 0xad740b07, 0xe949a278, 0xad657d7c, 0xc4335877, 0xad56fcaf, 0xe91aab16, 0xad4888a0, 0xc44553f2,
+ 0xad3a2153, 0xe8ebc1d3, 0xad2bc6ca, 0xc4577444, 0xad1d7907, 0xe8bce6cd, 0xad0f380c, 0xc469b963,
+ 0xad0103db, 0xe88e1a20, 0xacf2dc77, 0xc47c2344, 0xace4c1e2, 0xe85f5be9, 0xacd6b41e, 0xc48eb1db,
+ 0xacc8b32c, 0xe830ac45, 0xacbabf10, 0xc4a1651c, 0xacacd7cb, 0xe8020b52, 0xac9efd60, 0xc4b43cfd,
+ 0xac912fd1, 0xe7d3792b, 0xac836f1f, 0xc4c73972, 0xac75bb4d, 0xe7a4f5ed, 0xac68145d, 0xc4da5a6f,
+ 0xac5a7a52, 0xe77681b6, 0xac4ced2c, 0xc4ed9fe7, 0xac3f6cef, 0xe7481ca1, 0xac31f99d, 0xc50109d0,
+ 0xac249336, 0xe719c6cb, 0xac1739bf, 0xc514981d, 0xac09ed38, 0xe6eb8052, 0xabfcada3, 0xc5284ac3,
+ 0xabef7b04, 0xe6bd4951, 0xabe2555b, 0xc53c21b4, 0xabd53caa, 0xe68f21e5, 0xabc830f5, 0xc5501ce5,
+ 0xabbb323c, 0xe6610a2a, 0xabae4082, 0xc5643c4a, 0xaba15bc9, 0xe633023e, 0xab948413, 0xc5787fd6,
+ 0xab87b962, 0xe6050a3b, 0xab7afbb7, 0xc58ce77c, 0xab6e4b15, 0xe5d72240, 0xab61a77d, 0xc5a17330,
+ 0xab5510f3, 0xe5a94a67, 0xab488776, 0xc5b622e6, 0xab3c0b0b, 0xe57b82cd, 0xab2f9bb1, 0xc5caf690,
+ 0xab23396c, 0xe54dcb8f, 0xab16e43d, 0xc5dfee22, 0xab0a9c27, 0xe52024c9, 0xaafe612a, 0xc5f5098f,
+ 0xaaf23349, 0xe4f28e96, 0xaae61286, 0xc60a48c9, 0xaad9fee3, 0xe4c50914, 0xaacdf861, 0xc61fabc4,
+ 0xaac1ff03, 0xe497945d, 0xaab612ca, 0xc6353273, 0xaaaa33b8, 0xe46a308f, 0xaa9e61cf, 0xc64adcc7,
+ 0xaa929d10, 0xe43cddc4, 0xaa86e57e, 0xc660aab5, 0xaa7b3b1b, 0xe40f9c1a, 0xaa6f9de7, 0xc6769c2e,
+ 0xaa640de6, 0xe3e26bac, 0xaa588b18, 0xc68cb124, 0xaa4d157f, 0xe3b54c95, 0xaa41ad1e, 0xc6a2e98b,
+ 0xaa3651f6, 0xe3883ef2, 0xaa2b0409, 0xc6b94554, 0xaa1fc358, 0xe35b42df, 0xaa148fe6, 0xc6cfc472,
+ 0xaa0969b3, 0xe32e5876, 0xa9fe50c2, 0xc6e666d7, 0xa9f34515, 0xe3017fd5, 0xa9e846ad, 0xc6fd2c75,
+ 0xa9dd558b, 0xe2d4b916, 0xa9d271b2, 0xc714153e, 0xa9c79b23, 0xe2a80456, 0xa9bcd1e0, 0xc72b2123,
+ 0xa9b215ea, 0xe27b61af, 0xa9a76744, 0xc7425016, 0xa99cc5ee, 0xe24ed13d, 0xa99231eb, 0xc759a20a,
+ 0xa987ab3c, 0xe222531c, 0xa97d31e3, 0xc77116f0, 0xa972c5e1, 0xe1f5e768, 0xa9686738, 0xc788aeb9,
+ 0xa95e15e9, 0xe1c98e3b, 0xa953d1f7, 0xc7a06957, 0xa9499b62, 0xe19d47b1, 0xa93f722c, 0xc7b846ba,
+ 0xa9355658, 0xe17113e5, 0xa92b47e5, 0xc7d046d6, 0xa92146d7, 0xe144f2f3, 0xa917532e, 0xc7e8699a,
+ 0xa90d6cec, 0xe118e4f6, 0xa9039413, 0xc800aef7, 0xa8f9c8a4, 0xe0ecea09, 0xa8f00aa0, 0xc81916df,
+ 0xa8e65a0a, 0xe0c10247, 0xa8dcb6e2, 0xc831a143, 0xa8d3212a, 0xe0952dcb, 0xa8c998e3, 0xc84a4e14,
+ 0xa8c01e10, 0xe0696cb0, 0xa8b6b0b1, 0xc8631d42, 0xa8ad50c8, 0xe03dbf11, 0xa8a3fe57, 0xc87c0ebd,
+ 0xa89ab95e, 0xe012250a, 0xa89181df, 0xc8952278, 0xa88857dc, 0xdfe69eb4, 0xa87f3b57, 0xc8ae5862,
+ 0xa8762c4f, 0xdfbb2c2c, 0xa86d2ac8, 0xc8c7b06b, 0xa86436c2, 0xdf8fcd8b, 0xa85b503e, 0xc8e12a84,
+ 0xa852773f, 0xdf6482ed, 0xa849abc4, 0xc8fac69e, 0xa840edd1, 0xdf394c6b, 0xa8383d66, 0xc91484a8,
+ 0xa82f9a84, 0xdf0e2a22, 0xa827052d, 0xc92e6492, 0xa81e7d62, 0xdee31c2b, 0xa8160324, 0xc948664d,
+ 0xa80d9675, 0xdeb822a1, 0xa8053756, 0xc96289c9, 0xa7fce5c9, 0xde8d3d9e, 0xa7f4a1ce, 0xc97ccef5,
+ 0xa7ec6b66, 0xde626d3e, 0xa7e44294, 0xc99735c2, 0xa7dc2759, 0xde37b199, 0xa7d419b4, 0xc9b1be1e,
+ 0xa7cc19a9, 0xde0d0acc, 0xa7c42738, 0xc9cc67fa, 0xa7bc4262, 0xdde278ef, 0xa7b46b29, 0xc9e73346,
+ 0xa7aca18e, 0xddb7fc1e, 0xa7a4e591, 0xca021fef, 0xa79d3735, 0xdd8d9472, 0xa795967a, 0xca1d2de7,
+ 0xa78e0361, 0xdd634206, 0xa7867dec, 0xca385d1d, 0xa77f061c, 0xdd3904f4, 0xa7779bf2, 0xca53ad7e,
+ 0xa7703f70, 0xdd0edd55, 0xa768f095, 0xca6f1efc, 0xa761af64, 0xdce4cb44, 0xa75a7bdd, 0xca8ab184,
+ 0xa7535602, 0xdcbacedb, 0xa74c3dd4, 0xcaa66506, 0xa7453353, 0xdc90e834, 0xa73e3681, 0xcac23971,
+ 0xa7374760, 0xdc671768, 0xa73065ef, 0xcade2eb3, 0xa7299231, 0xdc3d5c91, 0xa722cc25, 0xcafa44bc,
+ 0xa71c13ce, 0xdc13b7c9, 0xa715692c, 0xcb167b79, 0xa70ecc41, 0xdbea292b, 0xa7083d0d, 0xcb32d2da,
+ 0xa701bb91, 0xdbc0b0ce, 0xa6fb47ce, 0xcb4f4acd, 0xa6f4e1c6, 0xdb974ece, 0xa6ee8979, 0xcb6be341,
+ 0xa6e83ee8, 0xdb6e0342, 0xa6e20214, 0xcb889c23, 0xa6dbd2ff, 0xdb44ce46, 0xa6d5b1a9, 0xcba57563,
+ 0xa6cf9e13, 0xdb1baff2, 0xa6c9983e, 0xcbc26eee, 0xa6c3a02b, 0xdaf2a860, 0xa6bdb5da, 0xcbdf88b3,
+ 0xa6b7d94e, 0xdac9b7a9, 0xa6b20a86, 0xcbfcc29f, 0xa6ac4984, 0xdaa0dde7, 0xa6a69649, 0xcc1a1ca0,
+ 0xa6a0f0d5, 0xda781b31, 0xa69b5929, 0xcc3796a5, 0xa695cf46, 0xda4f6fa3, 0xa690532d, 0xcc55309b,
+ 0xa68ae4df, 0xda26db54, 0xa685845c, 0xcc72ea70, 0xa68031a6, 0xd9fe5e5e, 0xa67aecbd, 0xcc90c412,
+ 0xa675b5a3, 0xd9d5f8d9, 0xa6708c57, 0xccaebd6e, 0xa66b70db, 0xd9adaadf, 0xa6666330, 0xccccd671,
+ 0xa6616355, 0xd9857489, 0xa65c714d, 0xcceb0f0a, 0xa6578d18, 0xd95d55ef, 0xa652b6b6, 0xcd096725,
+ 0xa64dee28, 0xd9354f2a, 0xa6493370, 0xcd27deb0, 0xa644868d, 0xd90d6053, 0xa63fe781, 0xcd467599,
+ 0xa63b564c, 0xd8e58982, 0xa636d2ee, 0xcd652bcb, 0xa6325d6a, 0xd8bdcad0, 0xa62df5bf, 0xcd840134,
+ 0xa6299bed, 0xd8962456, 0xa6254ff7, 0xcda2f5c2, 0xa62111db, 0xd86e962b, 0xa61ce19c, 0xcdc20960,
+ 0xa618bf39, 0xd8472069, 0xa614aab3, 0xcde13bfd, 0xa610a40c, 0xd81fc328, 0xa60cab43, 0xce008d84,
+ 0xa608c058, 0xd7f87e7f, 0xa604e34e, 0xce1ffde2, 0xa6011424, 0xd7d15288, 0xa5fd52db, 0xce3f8d05,
+ 0xa5f99f73, 0xd7aa3f5a, 0xa5f5f9ed, 0xce5f3ad8, 0xa5f2624a, 0xd783450d, 0xa5eed88a, 0xce7f0748,
+ 0xa5eb5cae, 0xd75c63ba, 0xa5e7eeb6, 0xce9ef241, 0xa5e48ea3, 0xd7359b78, 0xa5e13c75, 0xcebefbb0,
+ 0xa5ddf82d, 0xd70eec60, 0xa5dac1cb, 0xcedf2380, 0xa5d79950, 0xd6e85689, 0xa5d47ebc, 0xceff699f,
+ 0xa5d17210, 0xd6c1da0b, 0xa5ce734d, 0xcf1fcdf8, 0xa5cb8272, 0xd69b76fe, 0xa5c89f80, 0xcf405077,
+ 0xa5c5ca77, 0xd6752d79, 0xa5c30359, 0xcf60f108, 0xa5c04a25, 0xd64efd94, 0xa5bd9edc, 0xcf81af97,
+ 0xa5bb017f, 0xd628e767, 0xa5b8720d, 0xcfa28c10, 0xa5b5f087, 0xd602eb0a, 0xa5b37cee, 0xcfc3865e,
+ 0xa5b11741, 0xd5dd0892, 0xa5aebf82, 0xcfe49e6d, 0xa5ac75b0, 0xd5b74019, 0xa5aa39cd, 0xd005d42a,
+ 0xa5a80bd7, 0xd59191b5, 0xa5a5ebd0, 0xd027277e, 0xa5a3d9b8, 0xd56bfd7d, 0xa5a1d590, 0xd0489856,
+ 0xa59fdf57, 0xd5468389, 0xa59df70e, 0xd06a269d, 0xa59c1cb5, 0xd52123f0, 0xa59a504c, 0xd08bd23f,
+ 0xa59891d4, 0xd4fbdec9, 0xa596e14e, 0xd0ad9b26, 0xa5953eb8, 0xd4d6b42b, 0xa593aa14, 0xd0cf813e,
+ 0xa5922362, 0xd4b1a42c, 0xa590aaa2, 0xd0f18472, 0xa58f3fd4, 0xd48caee4, 0xa58de2f8, 0xd113a4ad,
+ 0xa58c940f, 0xd467d469, 0xa58b5319, 0xd135e1d9, 0xa58a2016, 0xd44314d3, 0xa588fb06, 0xd1583be2,
+ 0xa587e3ea, 0xd41e7037, 0xa586dac1, 0xd17ab2b3, 0xa585df8c, 0xd3f9e6ad, 0xa584f24b, 0xd19d4636,
+ 0xa58412fe, 0xd3d5784a, 0xa58341a5, 0xd1bff656, 0xa5827e40, 0xd3b12526, 0xa581c8d0, 0xd1e2c2fd,
+ 0xa5812154, 0xd38ced57, 0xa58087cd, 0xd205ac17, 0xa57ffc3b, 0xd368d0f3, 0xa57f7e9d, 0xd228b18d,
+ 0xa57f0ef5, 0xd344d011, 0xa57ead41, 0xd24bd34a, 0xa57e5982, 0xd320eac6, 0xa57e13b8, 0xd26f1138,
+ 0xa57ddbe4, 0xd2fd2129, 0xa57db204, 0xd2926b41, 0xa57d961a, 0xd2d97350, 0xa57d8825, 0xd2b5e151,
+};
+
+/* PostMultiply() tables
+ * format = Q30
+ * reordered for sequential access
+ * decimate (skip by 16 instead of 2) for small transform (128)
+ *
+ * for (i = 0; i <= (512/2); i++) {
+ * angle = i * M_PI / 1024;
+ * x = (cos(angle) + sin(angle));
+ * x = sin(angle);
+ * }
+ */
+const int cos1sin1tab[514] = {
+ /* format = Q30 */
+ 0x40000000, 0x00000000, 0x40323034, 0x003243f1, 0x406438cf, 0x006487c4, 0x409619b2, 0x0096cb58,
+ 0x40c7d2bd, 0x00c90e90, 0x40f963d3, 0x00fb514b, 0x412accd4, 0x012d936c, 0x415c0da3, 0x015fd4d2,
+ 0x418d2621, 0x0192155f, 0x41be162f, 0x01c454f5, 0x41eeddaf, 0x01f69373, 0x421f7c84, 0x0228d0bb,
+ 0x424ff28f, 0x025b0caf, 0x42803fb2, 0x028d472e, 0x42b063d0, 0x02bf801a, 0x42e05ecb, 0x02f1b755,
+ 0x43103085, 0x0323ecbe, 0x433fd8e1, 0x03562038, 0x436f57c1, 0x038851a2, 0x439ead09, 0x03ba80df,
+ 0x43cdd89a, 0x03ecadcf, 0x43fcda59, 0x041ed854, 0x442bb227, 0x0451004d, 0x445a5fe8, 0x0483259d,
+ 0x4488e37f, 0x04b54825, 0x44b73ccf, 0x04e767c5, 0x44e56bbd, 0x0519845e, 0x4513702a, 0x054b9dd3,
+ 0x454149fc, 0x057db403, 0x456ef916, 0x05afc6d0, 0x459c7d5a, 0x05e1d61b, 0x45c9d6af, 0x0613e1c5,
+ 0x45f704f7, 0x0645e9af, 0x46240816, 0x0677edbb, 0x4650dff1, 0x06a9edc9, 0x467d8c6d, 0x06dbe9bb,
+ 0x46aa0d6d, 0x070de172, 0x46d662d6, 0x073fd4cf, 0x47028c8d, 0x0771c3b3, 0x472e8a76, 0x07a3adff,
+ 0x475a5c77, 0x07d59396, 0x47860275, 0x08077457, 0x47b17c54, 0x08395024, 0x47dcc9f9, 0x086b26de,
+ 0x4807eb4b, 0x089cf867, 0x4832e02d, 0x08cec4a0, 0x485da887, 0x09008b6a, 0x4888443d, 0x09324ca7,
+ 0x48b2b335, 0x09640837, 0x48dcf556, 0x0995bdfd, 0x49070a84, 0x09c76dd8, 0x4930f2a6, 0x09f917ac,
+ 0x495aada2, 0x0a2abb59, 0x49843b5f, 0x0a5c58c0, 0x49ad9bc2, 0x0a8defc3, 0x49d6ceb3, 0x0abf8043,
+ 0x49ffd417, 0x0af10a22, 0x4a28abd6, 0x0b228d42, 0x4a5155d6, 0x0b540982, 0x4a79d1ff, 0x0b857ec7,
+ 0x4aa22036, 0x0bb6ecef, 0x4aca4065, 0x0be853de, 0x4af23270, 0x0c19b374, 0x4b19f641, 0x0c4b0b94,
+ 0x4b418bbe, 0x0c7c5c1e, 0x4b68f2cf, 0x0cada4f5, 0x4b902b5c, 0x0cdee5f9, 0x4bb7354d, 0x0d101f0e,
+ 0x4bde1089, 0x0d415013, 0x4c04bcf8, 0x0d7278eb, 0x4c2b3a84, 0x0da39978, 0x4c518913, 0x0dd4b19a,
+ 0x4c77a88e, 0x0e05c135, 0x4c9d98de, 0x0e36c82a, 0x4cc359ec, 0x0e67c65a, 0x4ce8eb9f, 0x0e98bba7,
+ 0x4d0e4de2, 0x0ec9a7f3, 0x4d33809c, 0x0efa8b20, 0x4d5883b7, 0x0f2b650f, 0x4d7d571c, 0x0f5c35a3,
+ 0x4da1fab5, 0x0f8cfcbe, 0x4dc66e6a, 0x0fbdba40, 0x4deab226, 0x0fee6e0d, 0x4e0ec5d1, 0x101f1807,
+ 0x4e32a956, 0x104fb80e, 0x4e565c9f, 0x10804e06, 0x4e79df95, 0x10b0d9d0, 0x4e9d3222, 0x10e15b4e,
+ 0x4ec05432, 0x1111d263, 0x4ee345ad, 0x11423ef0, 0x4f06067f, 0x1172a0d7, 0x4f289692, 0x11a2f7fc,
+ 0x4f4af5d1, 0x11d3443f, 0x4f6d2427, 0x12038584, 0x4f8f217e, 0x1233bbac, 0x4fb0edc1, 0x1263e699,
+ 0x4fd288dc, 0x1294062f, 0x4ff3f2bb, 0x12c41a4f, 0x50152b47, 0x12f422db, 0x5036326e, 0x13241fb6,
+ 0x50570819, 0x135410c3, 0x5077ac37, 0x1383f5e3, 0x50981eb1, 0x13b3cefa, 0x50b85f74, 0x13e39be9,
+ 0x50d86e6d, 0x14135c94, 0x50f84b87, 0x144310dd, 0x5117f6ae, 0x1472b8a5, 0x51376fd0, 0x14a253d1,
+ 0x5156b6d9, 0x14d1e242, 0x5175cbb5, 0x150163dc, 0x5194ae52, 0x1530d881, 0x51b35e9b, 0x15604013,
+ 0x51d1dc80, 0x158f9a76, 0x51f027eb, 0x15bee78c, 0x520e40cc, 0x15ee2738, 0x522c270f, 0x161d595d,
+ 0x5249daa2, 0x164c7ddd, 0x52675b72, 0x167b949d, 0x5284a96e, 0x16aa9d7e, 0x52a1c482, 0x16d99864,
+ 0x52beac9f, 0x17088531, 0x52db61b0, 0x173763c9, 0x52f7e3a6, 0x1766340f, 0x5314326d, 0x1794f5e6,
+ 0x53304df6, 0x17c3a931, 0x534c362d, 0x17f24dd3, 0x5367eb03, 0x1820e3b0, 0x53836c66, 0x184f6aab,
+ 0x539eba45, 0x187de2a7, 0x53b9d48f, 0x18ac4b87, 0x53d4bb34, 0x18daa52f, 0x53ef6e23, 0x1908ef82,
+ 0x5409ed4b, 0x19372a64, 0x5424389d, 0x196555b8, 0x543e5007, 0x19937161, 0x5458337a, 0x19c17d44,
+ 0x5471e2e6, 0x19ef7944, 0x548b5e3b, 0x1a1d6544, 0x54a4a56a, 0x1a4b4128, 0x54bdb862, 0x1a790cd4,
+ 0x54d69714, 0x1aa6c82b, 0x54ef4171, 0x1ad47312, 0x5507b76a, 0x1b020d6c, 0x551ff8ef, 0x1b2f971e,
+ 0x553805f2, 0x1b5d100a, 0x554fde64, 0x1b8a7815, 0x55678236, 0x1bb7cf23, 0x557ef15a, 0x1be51518,
+ 0x55962bc0, 0x1c1249d8, 0x55ad315b, 0x1c3f6d47, 0x55c4021d, 0x1c6c7f4a, 0x55da9df7, 0x1c997fc4,
+ 0x55f104dc, 0x1cc66e99, 0x560736bd, 0x1cf34baf, 0x561d338d, 0x1d2016e9, 0x5632fb3f, 0x1d4cd02c,
+ 0x56488dc5, 0x1d79775c, 0x565deb11, 0x1da60c5d, 0x56731317, 0x1dd28f15, 0x568805c9, 0x1dfeff67,
+ 0x569cc31b, 0x1e2b5d38, 0x56b14b00, 0x1e57a86d, 0x56c59d6a, 0x1e83e0eb, 0x56d9ba4e, 0x1eb00696,
+ 0x56eda1a0, 0x1edc1953, 0x57015352, 0x1f081907, 0x5714cf59, 0x1f340596, 0x572815a8, 0x1f5fdee6,
+ 0x573b2635, 0x1f8ba4dc, 0x574e00f2, 0x1fb7575c, 0x5760a5d5, 0x1fe2f64c, 0x577314d2, 0x200e8190,
+ 0x57854ddd, 0x2039f90f, 0x579750ec, 0x20655cac, 0x57a91df2, 0x2090ac4d, 0x57bab4e6, 0x20bbe7d8,
+ 0x57cc15bc, 0x20e70f32, 0x57dd406a, 0x21122240, 0x57ee34e5, 0x213d20e8, 0x57fef323, 0x21680b0f,
+ 0x580f7b19, 0x2192e09b, 0x581fccbc, 0x21bda171, 0x582fe804, 0x21e84d76, 0x583fcce6, 0x2212e492,
+ 0x584f7b58, 0x223d66a8, 0x585ef351, 0x2267d3a0, 0x586e34c7, 0x22922b5e, 0x587d3fb0, 0x22bc6dca,
+ 0x588c1404, 0x22e69ac8, 0x589ab1b9, 0x2310b23e, 0x58a918c6, 0x233ab414, 0x58b74923, 0x2364a02e,
+ 0x58c542c5, 0x238e7673, 0x58d305a6, 0x23b836ca, 0x58e091bd, 0x23e1e117, 0x58ede700, 0x240b7543,
+ 0x58fb0568, 0x2434f332, 0x5907eced, 0x245e5acc, 0x59149d87, 0x2487abf7, 0x5921172e, 0x24b0e699,
+ 0x592d59da, 0x24da0a9a, 0x59396584, 0x250317df, 0x59453a24, 0x252c0e4f, 0x5950d7b3, 0x2554edd1,
+ 0x595c3e2a, 0x257db64c, 0x59676d82, 0x25a667a7, 0x597265b4, 0x25cf01c8, 0x597d26b8, 0x25f78497,
+ 0x5987b08a, 0x261feffa, 0x59920321, 0x264843d9, 0x599c1e78, 0x2670801a, 0x59a60288, 0x2698a4a6,
+ 0x59afaf4c, 0x26c0b162, 0x59b924bc, 0x26e8a637, 0x59c262d5, 0x2710830c, 0x59cb698f, 0x273847c8,
+ 0x59d438e5, 0x275ff452, 0x59dcd0d3, 0x27878893, 0x59e53151, 0x27af0472, 0x59ed5a5c, 0x27d667d5,
+ 0x59f54bee, 0x27fdb2a7, 0x59fd0603, 0x2824e4cc, 0x5a048895, 0x284bfe2f, 0x5a0bd3a1, 0x2872feb6,
+ 0x5a12e720, 0x2899e64a, 0x5a19c310, 0x28c0b4d2, 0x5a20676c, 0x28e76a37, 0x5a26d42f, 0x290e0661,
+ 0x5a2d0957, 0x29348937, 0x5a3306de, 0x295af2a3, 0x5a38ccc2, 0x2981428c, 0x5a3e5afe, 0x29a778db,
+ 0x5a43b190, 0x29cd9578, 0x5a48d074, 0x29f3984c, 0x5a4db7a6, 0x2a19813f, 0x5a526725, 0x2a3f503a,
+ 0x5a56deec, 0x2a650525, 0x5a5b1efa, 0x2a8a9fea, 0x5a5f274b, 0x2ab02071, 0x5a62f7dd, 0x2ad586a3,
+ 0x5a6690ae, 0x2afad269, 0x5a69f1bb, 0x2b2003ac, 0x5a6d1b03, 0x2b451a55, 0x5a700c84, 0x2b6a164d,
+ 0x5a72c63b, 0x2b8ef77d, 0x5a754827, 0x2bb3bdce, 0x5a779246, 0x2bd8692b, 0x5a79a498, 0x2bfcf97c,
+ 0x5a7b7f1a, 0x2c216eaa, 0x5a7d21cc, 0x2c45c8a0, 0x5a7e8cac, 0x2c6a0746, 0x5a7fbfbb, 0x2c8e2a87,
+ 0x5a80baf6, 0x2cb2324c, 0x5a817e5d, 0x2cd61e7f, 0x5a8209f1, 0x2cf9ef09, 0x5a825db0, 0x2d1da3d5,
+ 0x5a82799a, 0x2d413ccd,
+};
+
+const int sinWindowOffset[NUM_IMDCT_SIZES] = {0, 128};
+
+/* Synthesis window - SIN
+ * format = Q31 for nmdct = [128, 1024]
+ * reordered for sequential access
+ *
+ * for (i = 0; i < nmdct/2; i++) {
+ * angle = (i + 0.5) * M_PI / (2.0 * nmdct);
+ * x = sin(angle);
+ *
+ * angle = (nmdct - 1 - i + 0.5) * M_PI / (2.0 * nmdct);
+ * x = sin(angle);
+ * }
+ */
+const int sinWindow[128 + 1024] = {
+ /* 128 - format = Q31 * 2^0 */
+ 0x00c90f88, 0x7fff6216, 0x025b26d7, 0x7ffa72d1, 0x03ed26e6, 0x7ff09478, 0x057f0035, 0x7fe1c76b,
+ 0x0710a345, 0x7fce0c3e, 0x08a2009a, 0x7fb563b3, 0x0a3308bd, 0x7f97cebd, 0x0bc3ac35, 0x7f754e80,
+ 0x0d53db92, 0x7f4de451, 0x0ee38766, 0x7f2191b4, 0x1072a048, 0x7ef05860, 0x120116d5, 0x7eba3a39,
+ 0x138edbb1, 0x7e7f3957, 0x151bdf86, 0x7e3f57ff, 0x16a81305, 0x7dfa98a8, 0x183366e9, 0x7db0fdf8,
+ 0x19bdcbf3, 0x7d628ac6, 0x1b4732ef, 0x7d0f4218, 0x1ccf8cb3, 0x7cb72724, 0x1e56ca1e, 0x7c5a3d50,
+ 0x1fdcdc1b, 0x7bf88830, 0x2161b3a0, 0x7b920b89, 0x22e541af, 0x7b26cb4f, 0x24677758, 0x7ab6cba4,
+ 0x25e845b6, 0x7a4210d8, 0x27679df4, 0x79c89f6e, 0x28e5714b, 0x794a7c12, 0x2a61b101, 0x78c7aba2,
+ 0x2bdc4e6f, 0x78403329, 0x2d553afc, 0x77b417df, 0x2ecc681e, 0x77235f2d, 0x3041c761, 0x768e0ea6,
+ 0x31b54a5e, 0x75f42c0b, 0x3326e2c3, 0x7555bd4c, 0x34968250, 0x74b2c884, 0x36041ad9, 0x740b53fb,
+ 0x376f9e46, 0x735f6626, 0x38d8fe93, 0x72af05a7, 0x3a402dd2, 0x71fa3949, 0x3ba51e29, 0x71410805,
+ 0x3d07c1d6, 0x708378ff, 0x3e680b2c, 0x6fc19385, 0x3fc5ec98, 0x6efb5f12, 0x4121589b, 0x6e30e34a,
+ 0x427a41d0, 0x6d6227fa, 0x43d09aed, 0x6c8f351c, 0x452456bd, 0x6bb812d1, 0x46756828, 0x6adcc964,
+ 0x47c3c22f, 0x69fd614a, 0x490f57ee, 0x6919e320, 0x4a581c9e, 0x683257ab, 0x4b9e0390, 0x6746c7d8,
+ 0x4ce10034, 0x66573cbb, 0x4e210617, 0x6563bf92, 0x4f5e08e3, 0x646c59bf, 0x5097fc5e, 0x637114cc,
+ 0x51ced46e, 0x6271fa69, 0x53028518, 0x616f146c, 0x5433027d, 0x60686ccf, 0x556040e2, 0x5f5e0db3,
+ 0x568a34a9, 0x5e50015d, 0x57b0d256, 0x5d3e5237, 0x58d40e8c, 0x5c290acc, 0x59f3de12, 0x5b1035cf,
+ /* 1024 - format = Q31 * 2^0 */
+ 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,
+};
+
+const int kbdWindowOffset[NUM_IMDCT_SIZES] = {0, 128};
+
+/* Synthesis window - KBD
+ * format = Q31 for nmdct = [128, 1024]
+ * reordered for sequential access
+ *
+ * aacScaleFact = -sqrt(1.0 / (2.0 * nmdct));
+ * for (i = 0; i < nmdct/2; i++) {
+ * x = kbdWindowRef[i] * aacScaleFact;
+ * x = kbdWindowRef[nmdct - 1 - i] * aacScaleFact;
+ * }
+ * Note: see below for code to generate kbdWindowRef[]
+ */
+const int kbdWindow[128 + 1024] = {
+ /* 128 - format = Q31 * 2^0 */
+ 0x00016f63, 0x7ffffffe, 0x0003e382, 0x7ffffff1, 0x00078f64, 0x7fffffc7, 0x000cc323, 0x7fffff5d,
+ 0x0013d9ed, 0x7ffffe76, 0x001d3a9d, 0x7ffffcaa, 0x0029581f, 0x7ffff953, 0x0038b1bd, 0x7ffff372,
+ 0x004bd34d, 0x7fffe98b, 0x00635538, 0x7fffd975, 0x007fdc64, 0x7fffc024, 0x00a219f1, 0x7fff995b,
+ 0x00cacad0, 0x7fff5f5b, 0x00fab72d, 0x7fff0a75, 0x0132b1af, 0x7ffe9091, 0x01739689, 0x7ffde49e,
+ 0x01be4a63, 0x7ffcf5ef, 0x0213b910, 0x7ffbaf84, 0x0274d41e, 0x7ff9f73a, 0x02e2913a, 0x7ff7acf1,
+ 0x035de86c, 0x7ff4a99a, 0x03e7d233, 0x7ff0be3d, 0x0481457c, 0x7febb2f1, 0x052b357c, 0x7fe545d4,
+ 0x05e68f77, 0x7fdd2a02, 0x06b4386f, 0x7fd30695, 0x07950acb, 0x7fc675b4, 0x0889d3ef, 0x7fb703be,
+ 0x099351e0, 0x7fa42e89, 0x0ab230e0, 0x7f8d64d8, 0x0be70923, 0x7f7205f8, 0x0d325c93, 0x7f516195,
+ 0x0e9494ae, 0x7f2ab7d0, 0x100e0085, 0x7efd3997, 0x119ed2ef, 0x7ec8094a, 0x134720d8, 0x7e8a3ba7,
+ 0x1506dfdc, 0x7e42d906, 0x16dde50b, 0x7df0dee4, 0x18cbe3f7, 0x7d9341b4, 0x1ad06e07, 0x7d28ef02,
+ 0x1ceaf215, 0x7cb0cfcc, 0x1f1abc4f, 0x7c29cb20, 0x215ef677, 0x7b92c8eb, 0x23b6a867, 0x7aeab4ec,
+ 0x2620b8ec, 0x7a3081d0, 0x289beef5, 0x79632c5a, 0x2b26f30b, 0x7881be95, 0x2dc0511f, 0x778b5304,
+ 0x30667aa2, 0x767f17c0, 0x3317c8dd, 0x755c5178, 0x35d27f98, 0x74225e50, 0x3894cff3, 0x72d0b887,
+ 0x3b5cdb7b, 0x7166f8e7, 0x3e28b770, 0x6fe4d8e8, 0x40f6702a, 0x6e4a3491, 0x43c40caa, 0x6c970bfc,
+ 0x468f9231, 0x6acb8483, 0x495707f5, 0x68e7e994, 0x4c187ac7, 0x66ecad1c, 0x4ed200c5, 0x64da6797,
+ 0x5181bcea, 0x62b1d7b7, 0x5425e28e, 0x6073e1ae, 0x56bcb8c2, 0x5e218e16, 0x59449d76, 0x5bbc0875,
+ /* 1024 - format = Q31 * 2^0 */
+ 0x0009962f, 0x7fffffa4, 0x000e16fb, 0x7fffff39, 0x0011ea65, 0x7ffffebf, 0x0015750e, 0x7ffffe34,
+ 0x0018dc74, 0x7ffffd96, 0x001c332e, 0x7ffffce5, 0x001f83f5, 0x7ffffc1f, 0x0022d59a, 0x7ffffb43,
+ 0x00262cc2, 0x7ffffa4f, 0x00298cc4, 0x7ffff942, 0x002cf81f, 0x7ffff81a, 0x003070c4, 0x7ffff6d6,
+ 0x0033f840, 0x7ffff573, 0x00378fd9, 0x7ffff3f1, 0x003b38a1, 0x7ffff24d, 0x003ef381, 0x7ffff085,
+ 0x0042c147, 0x7fffee98, 0x0046a2a8, 0x7fffec83, 0x004a9847, 0x7fffea44, 0x004ea2b7, 0x7fffe7d8,
+ 0x0052c283, 0x7fffe53f, 0x0056f829, 0x7fffe274, 0x005b4422, 0x7fffdf76, 0x005fa6dd, 0x7fffdc43,
+ 0x006420c8, 0x7fffd8d6, 0x0068b249, 0x7fffd52f, 0x006d5bc4, 0x7fffd149, 0x00721d9a, 0x7fffcd22,
+ 0x0076f828, 0x7fffc8b6, 0x007bebca, 0x7fffc404, 0x0080f8d9, 0x7fffbf06, 0x00861fae, 0x7fffb9bb,
+ 0x008b609e, 0x7fffb41e, 0x0090bbff, 0x7fffae2c, 0x00963224, 0x7fffa7e1, 0x009bc362, 0x7fffa13a,
+ 0x00a17009, 0x7fff9a32, 0x00a7386c, 0x7fff92c5, 0x00ad1cdc, 0x7fff8af0, 0x00b31da8, 0x7fff82ad,
+ 0x00b93b21, 0x7fff79f9, 0x00bf7596, 0x7fff70cf, 0x00c5cd57, 0x7fff672a, 0x00cc42b1, 0x7fff5d05,
+ 0x00d2d5f3, 0x7fff525c, 0x00d9876c, 0x7fff4729, 0x00e05769, 0x7fff3b66, 0x00e74638, 0x7fff2f10,
+ 0x00ee5426, 0x7fff221f, 0x00f58182, 0x7fff148e, 0x00fcce97, 0x7fff0658, 0x01043bb3, 0x7ffef776,
+ 0x010bc923, 0x7ffee7e2, 0x01137733, 0x7ffed795, 0x011b4631, 0x7ffec68a, 0x01233669, 0x7ffeb4ba,
+ 0x012b4827, 0x7ffea21d, 0x01337bb8, 0x7ffe8eac, 0x013bd167, 0x7ffe7a61, 0x01444982, 0x7ffe6533,
+ 0x014ce454, 0x7ffe4f1c, 0x0155a229, 0x7ffe3813, 0x015e834d, 0x7ffe2011, 0x0167880c, 0x7ffe070d,
+ 0x0170b0b2, 0x7ffdecff, 0x0179fd8b, 0x7ffdd1df, 0x01836ee1, 0x7ffdb5a2, 0x018d0500, 0x7ffd9842,
+ 0x0196c035, 0x7ffd79b3, 0x01a0a0ca, 0x7ffd59ee, 0x01aaa70a, 0x7ffd38e8, 0x01b4d341, 0x7ffd1697,
+ 0x01bf25b9, 0x7ffcf2f2, 0x01c99ebd, 0x7ffccdee, 0x01d43e99, 0x7ffca780, 0x01df0597, 0x7ffc7f9e,
+ 0x01e9f401, 0x7ffc563d, 0x01f50a22, 0x7ffc2b51, 0x02004844, 0x7ffbfecf, 0x020baeb1, 0x7ffbd0ab,
+ 0x02173db4, 0x7ffba0da, 0x0222f596, 0x7ffb6f4f, 0x022ed6a1, 0x7ffb3bfd, 0x023ae11f, 0x7ffb06d8,
+ 0x02471558, 0x7ffacfd3, 0x02537397, 0x7ffa96e0, 0x025ffc25, 0x7ffa5bf2, 0x026caf4a, 0x7ffa1efc,
+ 0x02798d4f, 0x7ff9dfee, 0x0286967c, 0x7ff99ebb, 0x0293cb1b, 0x7ff95b55, 0x02a12b72, 0x7ff915ab,
+ 0x02aeb7cb, 0x7ff8cdaf, 0x02bc706d, 0x7ff88351, 0x02ca559f, 0x7ff83682, 0x02d867a9, 0x7ff7e731,
+ 0x02e6a6d2, 0x7ff7954e, 0x02f51361, 0x7ff740c8, 0x0303ad9c, 0x7ff6e98e, 0x031275ca, 0x7ff68f8f,
+ 0x03216c30, 0x7ff632ba, 0x03309116, 0x7ff5d2fb, 0x033fe4bf, 0x7ff57042, 0x034f6773, 0x7ff50a7a,
+ 0x035f1975, 0x7ff4a192, 0x036efb0a, 0x7ff43576, 0x037f0c78, 0x7ff3c612, 0x038f4e02, 0x7ff35353,
+ 0x039fbfeb, 0x7ff2dd24, 0x03b06279, 0x7ff26370, 0x03c135ed, 0x7ff1e623, 0x03d23a8b, 0x7ff16527,
+ 0x03e37095, 0x7ff0e067, 0x03f4d84e, 0x7ff057cc, 0x040671f7, 0x7fefcb40, 0x04183dd3, 0x7fef3aad,
+ 0x042a3c22, 0x7feea5fa, 0x043c6d25, 0x7fee0d11, 0x044ed11d, 0x7fed6fda, 0x04616849, 0x7fecce3d,
+ 0x047432eb, 0x7fec2821, 0x04873140, 0x7feb7d6c, 0x049a6388, 0x7feace07, 0x04adca01, 0x7fea19d6,
+ 0x04c164ea, 0x7fe960c0, 0x04d53481, 0x7fe8a2aa, 0x04e93902, 0x7fe7df79, 0x04fd72aa, 0x7fe71712,
+ 0x0511e1b6, 0x7fe6495a, 0x05268663, 0x7fe57634, 0x053b60eb, 0x7fe49d83, 0x05507189, 0x7fe3bf2b,
+ 0x0565b879, 0x7fe2db0f, 0x057b35f4, 0x7fe1f110, 0x0590ea35, 0x7fe10111, 0x05a6d574, 0x7fe00af3,
+ 0x05bcf7ea, 0x7fdf0e97, 0x05d351cf, 0x7fde0bdd, 0x05e9e35c, 0x7fdd02a6, 0x0600acc8, 0x7fdbf2d2,
+ 0x0617ae48, 0x7fdadc40, 0x062ee814, 0x7fd9becf, 0x06465a62, 0x7fd89a5e, 0x065e0565, 0x7fd76eca,
+ 0x0675e954, 0x7fd63bf1, 0x068e0662, 0x7fd501b0, 0x06a65cc3, 0x7fd3bfe4, 0x06beecaa, 0x7fd2766a,
+ 0x06d7b648, 0x7fd1251e, 0x06f0b9d1, 0x7fcfcbda, 0x0709f775, 0x7fce6a7a, 0x07236f65, 0x7fcd00d8,
+ 0x073d21d2, 0x7fcb8ecf, 0x07570eea, 0x7fca1439, 0x077136dd, 0x7fc890ed, 0x078b99da, 0x7fc704c7,
+ 0x07a6380d, 0x7fc56f9d, 0x07c111a4, 0x7fc3d147, 0x07dc26cc, 0x7fc2299e, 0x07f777b1, 0x7fc07878,
+ 0x0813047d, 0x7fbebdac, 0x082ecd5b, 0x7fbcf90f, 0x084ad276, 0x7fbb2a78, 0x086713f7, 0x7fb951bc,
+ 0x08839206, 0x7fb76eaf, 0x08a04ccb, 0x7fb58126, 0x08bd446e, 0x7fb388f4, 0x08da7915, 0x7fb185ee,
+ 0x08f7eae7, 0x7faf77e5, 0x09159a09, 0x7fad5ead, 0x0933869f, 0x7fab3a17, 0x0951b0cd, 0x7fa909f6,
+ 0x097018b7, 0x7fa6ce1a, 0x098ebe7f, 0x7fa48653, 0x09ada248, 0x7fa23273, 0x09ccc431, 0x7f9fd249,
+ 0x09ec245b, 0x7f9d65a4, 0x0a0bc2e7, 0x7f9aec53, 0x0a2b9ff3, 0x7f986625, 0x0a4bbb9e, 0x7f95d2e7,
+ 0x0a6c1604, 0x7f933267, 0x0a8caf43, 0x7f908472, 0x0aad8776, 0x7f8dc8d5, 0x0ace9eb9, 0x7f8aff5c,
+ 0x0aeff526, 0x7f8827d3, 0x0b118ad8, 0x7f854204, 0x0b335fe6, 0x7f824dbb, 0x0b557469, 0x7f7f4ac3,
+ 0x0b77c879, 0x7f7c38e4, 0x0b9a5c2b, 0x7f7917e9, 0x0bbd2f97, 0x7f75e79b, 0x0be042d0, 0x7f72a7c3,
+ 0x0c0395ec, 0x7f6f5828, 0x0c2728fd, 0x7f6bf892, 0x0c4afc16, 0x7f6888c9, 0x0c6f0f4a, 0x7f650894,
+ 0x0c9362a8, 0x7f6177b9, 0x0cb7f642, 0x7f5dd5ff, 0x0cdcca26, 0x7f5a232a, 0x0d01de63, 0x7f565f00,
+ 0x0d273307, 0x7f528947, 0x0d4cc81f, 0x7f4ea1c2, 0x0d729db7, 0x7f4aa835, 0x0d98b3da, 0x7f469c65,
+ 0x0dbf0a92, 0x7f427e13, 0x0de5a1e9, 0x7f3e4d04, 0x0e0c79e7, 0x7f3a08f9, 0x0e339295, 0x7f35b1b4,
+ 0x0e5aebfa, 0x7f3146f8, 0x0e82861a, 0x7f2cc884, 0x0eaa60fd, 0x7f28361b, 0x0ed27ca5, 0x7f238f7c,
+ 0x0efad917, 0x7f1ed467, 0x0f237656, 0x7f1a049d, 0x0f4c5462, 0x7f151fdc, 0x0f75733d, 0x7f1025e3,
+ 0x0f9ed2e6, 0x7f0b1672, 0x0fc8735e, 0x7f05f146, 0x0ff254a1, 0x7f00b61d, 0x101c76ae, 0x7efb64b4,
+ 0x1046d981, 0x7ef5fcca, 0x10717d15, 0x7ef07e19, 0x109c6165, 0x7eeae860, 0x10c7866a, 0x7ee53b5b,
+ 0x10f2ec1e, 0x7edf76c4, 0x111e9279, 0x7ed99a58, 0x114a7971, 0x7ed3a5d1, 0x1176a0fc, 0x7ecd98eb,
+ 0x11a30910, 0x7ec77360, 0x11cfb1a1, 0x7ec134eb, 0x11fc9aa2, 0x7ebadd44, 0x1229c406, 0x7eb46c27,
+ 0x12572dbf, 0x7eade14c, 0x1284d7bc, 0x7ea73c6c, 0x12b2c1ed, 0x7ea07d41, 0x12e0ec42, 0x7e99a382,
+ 0x130f56a8, 0x7e92aee7, 0x133e010b, 0x7e8b9f2a, 0x136ceb59, 0x7e847402, 0x139c157b, 0x7e7d2d25,
+ 0x13cb7f5d, 0x7e75ca4c, 0x13fb28e6, 0x7e6e4b2d, 0x142b1200, 0x7e66af7f, 0x145b3a92, 0x7e5ef6f8,
+ 0x148ba281, 0x7e572150, 0x14bc49b4, 0x7e4f2e3b, 0x14ed300f, 0x7e471d70, 0x151e5575, 0x7e3eeea5,
+ 0x154fb9c9, 0x7e36a18e, 0x15815ced, 0x7e2e35e2, 0x15b33ec1, 0x7e25ab56, 0x15e55f25, 0x7e1d019e,
+ 0x1617bdf9, 0x7e14386e, 0x164a5b19, 0x7e0b4f7d, 0x167d3662, 0x7e02467e, 0x16b04fb2, 0x7df91d25,
+ 0x16e3a6e2, 0x7defd327, 0x17173bce, 0x7de66837, 0x174b0e4d, 0x7ddcdc0a, 0x177f1e39, 0x7dd32e53,
+ 0x17b36b69, 0x7dc95ec6, 0x17e7f5b3, 0x7dbf6d17, 0x181cbcec, 0x7db558f9, 0x1851c0e9, 0x7dab221f,
+ 0x1887017d, 0x7da0c83c, 0x18bc7e7c, 0x7d964b05, 0x18f237b6, 0x7d8baa2b, 0x19282cfd, 0x7d80e563,
+ 0x195e5e20, 0x7d75fc5e, 0x1994caee, 0x7d6aeed0, 0x19cb7335, 0x7d5fbc6d, 0x1a0256c2, 0x7d5464e6,
+ 0x1a397561, 0x7d48e7ef, 0x1a70cede, 0x7d3d453b, 0x1aa86301, 0x7d317c7c, 0x1ae03195, 0x7d258d65,
+ 0x1b183a63, 0x7d1977aa, 0x1b507d30, 0x7d0d3afc, 0x1b88f9c5, 0x7d00d710, 0x1bc1afe6, 0x7cf44b97,
+ 0x1bfa9f58, 0x7ce79846, 0x1c33c7e0, 0x7cdabcce, 0x1c6d293f, 0x7ccdb8e4, 0x1ca6c337, 0x7cc08c39,
+ 0x1ce0958a, 0x7cb33682, 0x1d1a9ff8, 0x7ca5b772, 0x1d54e240, 0x7c980ebd, 0x1d8f5c21, 0x7c8a3c14,
+ 0x1dca0d56, 0x7c7c3f2e, 0x1e04f59f, 0x7c6e17bc, 0x1e4014b4, 0x7c5fc573, 0x1e7b6a53, 0x7c514807,
+ 0x1eb6f633, 0x7c429f2c, 0x1ef2b80f, 0x7c33ca96, 0x1f2eaf9e, 0x7c24c9fa, 0x1f6adc98, 0x7c159d0d,
+ 0x1fa73eb2, 0x7c064383, 0x1fe3d5a3, 0x7bf6bd11, 0x2020a11e, 0x7be7096c, 0x205da0d8, 0x7bd7284a,
+ 0x209ad483, 0x7bc71960, 0x20d83bd1, 0x7bb6dc65, 0x2115d674, 0x7ba6710d, 0x2153a41b, 0x7b95d710,
+ 0x2191a476, 0x7b850e24, 0x21cfd734, 0x7b7415ff, 0x220e3c02, 0x7b62ee59, 0x224cd28d, 0x7b5196e9,
+ 0x228b9a82, 0x7b400f67, 0x22ca938a, 0x7b2e578a, 0x2309bd52, 0x7b1c6f0b, 0x23491783, 0x7b0a55a1,
+ 0x2388a1c4, 0x7af80b07, 0x23c85bbf, 0x7ae58ef5, 0x2408451a, 0x7ad2e124, 0x24485d7c, 0x7ac0014e,
+ 0x2488a48a, 0x7aacef2e, 0x24c919e9, 0x7a99aa7e, 0x2509bd3d, 0x7a8632f8, 0x254a8e29, 0x7a728858,
+ 0x258b8c50, 0x7a5eaa5a, 0x25ccb753, 0x7a4a98b9, 0x260e0ed3, 0x7a365333, 0x264f9271, 0x7a21d983,
+ 0x269141cb, 0x7a0d2b68, 0x26d31c80, 0x79f8489e, 0x2715222f, 0x79e330e4, 0x27575273, 0x79cde3f8,
+ 0x2799acea, 0x79b8619a, 0x27dc3130, 0x79a2a989, 0x281ededf, 0x798cbb85, 0x2861b591, 0x7976974e,
+ 0x28a4b4e0, 0x79603ca5, 0x28e7dc65, 0x7949ab4c, 0x292b2bb8, 0x7932e304, 0x296ea270, 0x791be390,
+ 0x29b24024, 0x7904acb3, 0x29f6046b, 0x78ed3e30, 0x2a39eed8, 0x78d597cc, 0x2a7dff02, 0x78bdb94a,
+ 0x2ac2347c, 0x78a5a270, 0x2b068eda, 0x788d5304, 0x2b4b0dae, 0x7874cacb, 0x2b8fb08a, 0x785c098d,
+ 0x2bd47700, 0x78430f11, 0x2c1960a1, 0x7829db1f, 0x2c5e6cfd, 0x78106d7f, 0x2ca39ba3, 0x77f6c5fb,
+ 0x2ce8ec23, 0x77dce45c, 0x2d2e5e0b, 0x77c2c86e, 0x2d73f0e8, 0x77a871fa, 0x2db9a449, 0x778de0cd,
+ 0x2dff77b8, 0x777314b2, 0x2e456ac4, 0x77580d78, 0x2e8b7cf6, 0x773ccaeb, 0x2ed1addb, 0x77214cdb,
+ 0x2f17fcfb, 0x77059315, 0x2f5e69e2, 0x76e99d69, 0x2fa4f419, 0x76cd6ba9, 0x2feb9b27, 0x76b0fda4,
+ 0x30325e96, 0x7694532e, 0x30793dee, 0x76776c17, 0x30c038b5, 0x765a4834, 0x31074e72, 0x763ce759,
+ 0x314e7eab, 0x761f4959, 0x3195c8e6, 0x76016e0b, 0x31dd2ca9, 0x75e35545, 0x3224a979, 0x75c4fedc,
+ 0x326c3ed8, 0x75a66aab, 0x32b3ec4d, 0x75879887, 0x32fbb159, 0x7568884b, 0x33438d81, 0x754939d1,
+ 0x338b8045, 0x7529acf4, 0x33d3892a, 0x7509e18e, 0x341ba7b1, 0x74e9d77d, 0x3463db5a, 0x74c98e9e,
+ 0x34ac23a7, 0x74a906cd, 0x34f48019, 0x74883fec, 0x353cf02f, 0x746739d8, 0x3585736a, 0x7445f472,
+ 0x35ce0949, 0x74246f9c, 0x3616b14c, 0x7402ab37, 0x365f6af0, 0x73e0a727, 0x36a835b5, 0x73be6350,
+ 0x36f11118, 0x739bdf95, 0x3739fc98, 0x73791bdd, 0x3782f7b2, 0x7356180e, 0x37cc01e3, 0x7332d410,
+ 0x38151aa8, 0x730f4fc9, 0x385e417e, 0x72eb8b24, 0x38a775e1, 0x72c7860a, 0x38f0b74d, 0x72a34066,
+ 0x393a053e, 0x727eba24, 0x39835f30, 0x7259f331, 0x39ccc49e, 0x7234eb79, 0x3a163503, 0x720fa2eb,
+ 0x3a5fafda, 0x71ea1977, 0x3aa9349e, 0x71c44f0c, 0x3af2c2ca, 0x719e439d, 0x3b3c59d7, 0x7177f71a,
+ 0x3b85f940, 0x71516978, 0x3bcfa07e, 0x712a9aaa, 0x3c194f0d, 0x71038aa4, 0x3c630464, 0x70dc395e,
+ 0x3cacbfff, 0x70b4a6cd, 0x3cf68155, 0x708cd2e9, 0x3d4047e1, 0x7064bdab, 0x3d8a131c, 0x703c670d,
+ 0x3dd3e27e, 0x7013cf0a, 0x3e1db580, 0x6feaf59c, 0x3e678b9b, 0x6fc1dac1, 0x3eb16449, 0x6f987e76,
+ 0x3efb3f01, 0x6f6ee0b9, 0x3f451b3d, 0x6f45018b, 0x3f8ef874, 0x6f1ae0eb, 0x3fd8d620, 0x6ef07edb,
+ 0x4022b3b9, 0x6ec5db5d, 0x406c90b7, 0x6e9af675, 0x40b66c93, 0x6e6fd027, 0x410046c5, 0x6e446879,
+ 0x414a1ec6, 0x6e18bf71, 0x4193f40d, 0x6decd517, 0x41ddc615, 0x6dc0a972, 0x42279455, 0x6d943c8d,
+ 0x42715e45, 0x6d678e71, 0x42bb235f, 0x6d3a9f2a, 0x4304e31a, 0x6d0d6ec5, 0x434e9cf1, 0x6cdffd4f,
+ 0x4398505b, 0x6cb24ad6, 0x43e1fcd1, 0x6c84576b, 0x442ba1cd, 0x6c56231c, 0x44753ec7, 0x6c27adfd,
+ 0x44bed33a, 0x6bf8f81e, 0x45085e9d, 0x6bca0195, 0x4551e06b, 0x6b9aca75, 0x459b581e, 0x6b6b52d5,
+ 0x45e4c52f, 0x6b3b9ac9, 0x462e2717, 0x6b0ba26b, 0x46777d52, 0x6adb69d3, 0x46c0c75a, 0x6aaaf11b,
+ 0x470a04a9, 0x6a7a385c, 0x475334b9, 0x6a493fb3, 0x479c5707, 0x6a18073d, 0x47e56b0c, 0x69e68f17,
+ 0x482e7045, 0x69b4d761, 0x4877662c, 0x6982e039, 0x48c04c3f, 0x6950a9c0, 0x490921f8, 0x691e341a,
+ 0x4951e6d5, 0x68eb7f67, 0x499a9a51, 0x68b88bcd, 0x49e33beb, 0x68855970, 0x4a2bcb1f, 0x6851e875,
+ 0x4a74476b, 0x681e3905, 0x4abcb04c, 0x67ea4b47, 0x4b050541, 0x67b61f63, 0x4b4d45c9, 0x6781b585,
+ 0x4b957162, 0x674d0dd6, 0x4bdd878c, 0x67182883, 0x4c2587c6, 0x66e305b8, 0x4c6d7190, 0x66ada5a5,
+ 0x4cb5446a, 0x66780878, 0x4cfcffd5, 0x66422e60, 0x4d44a353, 0x660c1790, 0x4d8c2e64, 0x65d5c439,
+ 0x4dd3a08c, 0x659f348e, 0x4e1af94b, 0x656868c3, 0x4e623825, 0x6531610d, 0x4ea95c9d, 0x64fa1da3,
+ 0x4ef06637, 0x64c29ebb, 0x4f375477, 0x648ae48d, 0x4f7e26e1, 0x6452ef53, 0x4fc4dcfb, 0x641abf46,
+ 0x500b7649, 0x63e254a2, 0x5051f253, 0x63a9afa2, 0x5098509f, 0x6370d083, 0x50de90b3, 0x6337b784,
+ 0x5124b218, 0x62fe64e3, 0x516ab455, 0x62c4d8e0, 0x51b096f3, 0x628b13bc, 0x51f6597b, 0x625115b8,
+ 0x523bfb78, 0x6216df18, 0x52817c72, 0x61dc701f, 0x52c6dbf5, 0x61a1c912, 0x530c198d, 0x6166ea36,
+ 0x535134c5, 0x612bd3d2, 0x53962d2a, 0x60f0862d, 0x53db024a, 0x60b50190, 0x541fb3b1, 0x60794644,
+ 0x546440ef, 0x603d5494, 0x54a8a992, 0x60012cca, 0x54eced2b, 0x5fc4cf33, 0x55310b48, 0x5f883c1c,
+ 0x5575037c, 0x5f4b73d2, 0x55b8d558, 0x5f0e76a5, 0x55fc806f, 0x5ed144e5, 0x56400452, 0x5e93dee1,
+ 0x56836096, 0x5e5644ec, 0x56c694cf, 0x5e187757, 0x5709a092, 0x5dda7677, 0x574c8374, 0x5d9c429f,
+ 0x578f3d0d, 0x5d5ddc24, 0x57d1ccf2, 0x5d1f435d, 0x581432bd, 0x5ce078a0, 0x58566e04, 0x5ca17c45,
+ 0x58987e63, 0x5c624ea4, 0x58da6372, 0x5c22f016, 0x591c1ccc, 0x5be360f6, 0x595daa0d, 0x5ba3a19f,
+ 0x599f0ad1, 0x5b63b26c, 0x59e03eb6, 0x5b2393ba, 0x5a214558, 0x5ae345e7, 0x5a621e56, 0x5aa2c951,
+};
+
+
+
+/* bit reverse tables for FFT */
+
+const int bitrevtabOffset[NUM_IMDCT_SIZES] = {0, 17};
+
+const unsigned char bitrevtab[17 + 129] = {
+ /* nfft = 64 */
+ 0x01, 0x08, 0x02, 0x04, 0x03, 0x0c, 0x05, 0x0a, 0x07, 0x0e, 0x0b, 0x0d, 0x00, 0x06, 0x09, 0x0f,
+ 0x00,
+
+ /* nfft = 512 */
+ 0x01, 0x40, 0x02, 0x20, 0x03, 0x60, 0x04, 0x10, 0x05, 0x50, 0x06, 0x30, 0x07, 0x70, 0x09, 0x48,
+ 0x0a, 0x28, 0x0b, 0x68, 0x0c, 0x18, 0x0d, 0x58, 0x0e, 0x38, 0x0f, 0x78, 0x11, 0x44, 0x12, 0x24,
+ 0x13, 0x64, 0x15, 0x54, 0x16, 0x34, 0x17, 0x74, 0x19, 0x4c, 0x1a, 0x2c, 0x1b, 0x6c, 0x1d, 0x5c,
+ 0x1e, 0x3c, 0x1f, 0x7c, 0x21, 0x42, 0x23, 0x62, 0x25, 0x52, 0x26, 0x32, 0x27, 0x72, 0x29, 0x4a,
+ 0x2b, 0x6a, 0x2d, 0x5a, 0x2e, 0x3a, 0x2f, 0x7a, 0x31, 0x46, 0x33, 0x66, 0x35, 0x56, 0x37, 0x76,
+ 0x39, 0x4e, 0x3b, 0x6e, 0x3d, 0x5e, 0x3f, 0x7e, 0x43, 0x61, 0x45, 0x51, 0x47, 0x71, 0x4b, 0x69,
+ 0x4d, 0x59, 0x4f, 0x79, 0x53, 0x65, 0x57, 0x75, 0x5b, 0x6d, 0x5f, 0x7d, 0x67, 0x73, 0x6f, 0x7b,
+ 0x00, 0x08, 0x14, 0x1c, 0x22, 0x2a, 0x36, 0x3e, 0x41, 0x49, 0x55, 0x5d, 0x63, 0x6b, 0x77, 0x7f,
+ 0x00,
+
+};
+
+const unsigned char uniqueIDTab[8] = {0x5f, 0x4b, 0x43, 0x5f, 0x5f, 0x4a, 0x52, 0x5f};
+
+/* Twiddle tables for FFT
+ * format = Q30
+ *
+ * for (k = 4; k <= N/4; k <<= 1) {
+ * for (j = 0; j < k; j++) {
+ * double wr1, wi1, wr2, wi2, wr3, wi3;
+ *
+ * wr1 = cos(1.0 * M_PI * j / (2*k));
+ * wi1 = sin(1.0 * M_PI * j / (2*k));
+ * wr1 = (wr1 + wi1);
+ * wi1 = -wi1;
+ *
+ * wr2 = cos(2.0 * M_PI * j / (2*k));
+ * wi2 = sin(2.0 * M_PI * j / (2*k));
+ * wr2 = (wr2 + wi2);
+ * wi2 = -wi2;
+ *
+ * wr3 = cos(3.0 * M_PI * j / (2*k));
+ * wi3 = sin(3.0 * M_PI * j / (2*k));
+ * wr3 = (wr3 + wi3);
+ * wi3 = -wi3;
+ *
+ * if (k & 0xaaaaaaaa) {
+ * w_odd[iodd++] = (float)wr2;
+ * w_odd[iodd++] = (float)wi2;
+ * w_odd[iodd++] = (float)wr1;
+ * w_odd[iodd++] = (float)wi1;
+ * w_odd[iodd++] = (float)wr3;
+ * w_odd[iodd++] = (float)wi3;
+ * } else {
+ * w_even[ieven++] = (float)wr2;
+ * w_even[ieven++] = (float)wi2;
+ * w_even[ieven++] = (float)wr1;
+ * w_even[ieven++] = (float)wi1;
+ * w_even[ieven++] = (float)wr3;
+ * w_even[ieven++] = (float)wi3;
+ * }
+ * }
+ * }
+ */
+const int twidTabOdd[8 * 6 + 32 * 6 + 128 * 6] = {
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x539eba45, 0xe7821d59,
+ 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59,
+ 0x539eba45, 0xc4df2862, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x22a2f4f8, 0xc4df2862,
+ 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862,
+ 0xac6145bb, 0x187de2a7, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52,
+
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x45f704f7, 0xf9ba1651,
+ 0x43103085, 0xfcdc1342, 0x48b2b335, 0xf69bf7c9, 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651,
+ 0x4fd288dc, 0xed6bf9d1, 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9, 0x553805f2, 0xe4a2eff6,
+ 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x569cc31b, 0xe1d4a2c8,
+ 0x4da1fab5, 0xf0730342, 0x5a6690ae, 0xd5052d97, 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1,
+ 0x5a12e720, 0xce86ff2a, 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a, 0x57cc15bc, 0xc91af976,
+ 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a12e720, 0xce86ff2a,
+ 0x553805f2, 0xe4a2eff6, 0x4da1fab5, 0xc1eb0209, 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8,
+ 0x45f704f7, 0xc04ee4b8, 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce, 0x3cc85709, 0xc013bc39,
+ 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x4fd288dc, 0xc2c17d52,
+ 0x5987b08a, 0xd9e01006, 0x26b2a794, 0xc3bdbdf6, 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6,
+ 0x1a4608ab, 0xc78e9a1d, 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97, 0x0d47d096, 0xcc983f70,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x396b3199, 0xc04ee4b8,
+ 0x5a6690ae, 0xd09441bb, 0xf2b82f6a, 0xd9e01006, 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a,
+ 0xe5b9f755, 0xe1d4a2c8, 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70, 0xd94d586c, 0xea70658a,
+ 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x1a4608ab, 0xc78e9a1d,
+ 0x57cc15bc, 0xc91af976, 0xc337a8f7, 0xfcdc1342, 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d,
+ 0xba08fb09, 0x0645e9af, 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18, 0xb25e054b, 0x0f8cfcbe,
+ 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xf720e574, 0xd76619b6,
+ 0x51d1dc80, 0xc3bdbdf6, 0xa833ea44, 0x20e70f32, 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52,
+ 0xa5ed18e0, 0x2899e64a, 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209, 0xa5996f52, 0x2f6bbe45,
+ 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xd5558381, 0xed6bf9d1,
+ 0x48b2b335, 0xc0b15502, 0xaac7fa0e, 0x39daf5e8, 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8,
+ 0xb02d7724, 0x3d3e82ae, 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39, 0xb74d4ccb, 0x3f4eaafe,
+
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x418d2621, 0xfe6deaa1,
+ 0x40c7d2bd, 0xff36f170, 0x424ff28f, 0xfda4f351, 0x43103085, 0xfcdc1342, 0x418d2621, 0xfe6deaa1,
+ 0x4488e37f, 0xfb4ab7db, 0x4488e37f, 0xfb4ab7db, 0x424ff28f, 0xfda4f351, 0x46aa0d6d, 0xf8f21e8e,
+ 0x45f704f7, 0xf9ba1651, 0x43103085, 0xfcdc1342, 0x48b2b335, 0xf69bf7c9, 0x475a5c77, 0xf82a6c6a,
+ 0x43cdd89a, 0xfc135231, 0x4aa22036, 0xf4491311, 0x48b2b335, 0xf69bf7c9, 0x4488e37f, 0xfb4ab7db,
+ 0x4c77a88e, 0xf1fa3ecb, 0x49ffd417, 0xf50ef5de, 0x454149fc, 0xfa824bfd, 0x4e32a956, 0xefb047f2,
+ 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x4c77a88e, 0xf1fa3ecb,
+ 0x46aa0d6d, 0xf8f21e8e, 0x5156b6d9, 0xeb2e1dbe, 0x4da1fab5, 0xf0730342, 0x475a5c77, 0xf82a6c6a,
+ 0x52beac9f, 0xe8f77acf, 0x4ec05432, 0xeeee2d9d, 0x4807eb4b, 0xf7630799, 0x5409ed4b, 0xe6c8d59c,
+ 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9, 0x553805f2, 0xe4a2eff6, 0x50d86e6d, 0xebeca36c,
+ 0x495aada2, 0xf5d544a7, 0x56488dc5, 0xe28688a4, 0x51d1dc80, 0xea70658a, 0x49ffd417, 0xf50ef5de,
+ 0x573b2635, 0xe0745b24, 0x52beac9f, 0xe8f77acf, 0x4aa22036, 0xf4491311, 0x580f7b19, 0xde6d1f65,
+ 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5471e2e6, 0xe61086bc,
+ 0x4bde1089, 0xf2beafed, 0x595c3e2a, 0xda8249b4, 0x553805f2, 0xe4a2eff6, 0x4c77a88e, 0xf1fa3ecb,
+ 0x59d438e5, 0xd8a00bae, 0x55f104dc, 0xe3399167, 0x4d0e4de2, 0xf136580d, 0x5a2d0957, 0xd6cb76c9,
+ 0x569cc31b, 0xe1d4a2c8, 0x4da1fab5, 0xf0730342, 0x5a6690ae, 0xd5052d97, 0x573b2635, 0xe0745b24,
+ 0x4e32a956, 0xefb047f2, 0x5a80baf6, 0xd34dcdb4, 0x57cc15bc, 0xdf18f0ce, 0x4ec05432, 0xeeee2d9d,
+ 0x5a7b7f1a, 0xd1a5ef90, 0x584f7b58, 0xddc29958, 0x4f4af5d1, 0xee2cbbc1, 0x5a56deec, 0xd00e2639,
+ 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a, 0x592d59da, 0xdb25f566,
+ 0x50570819, 0xecabef3d, 0x59afaf4c, 0xcd110216, 0x5987b08a, 0xd9e01006, 0x50d86e6d, 0xebeca36c,
+ 0x592d59da, 0xcbacb0bf, 0x59d438e5, 0xd8a00bae, 0x5156b6d9, 0xeb2e1dbe, 0x588c1404, 0xca5a86c4,
+ 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a, 0x57cc15bc, 0xc91af976, 0x5a43b190, 0xd6326a88,
+ 0x5249daa2, 0xe9b38223, 0x56eda1a0, 0xc7ee77b3, 0x5a6690ae, 0xd5052d97, 0x52beac9f, 0xe8f77acf,
+ 0x55f104dc, 0xc6d569be, 0x5a7b7f1a, 0xd3de9156, 0x53304df6, 0xe83c56cf, 0x54d69714, 0xc5d03118,
+ 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a7b7f1a, 0xd1a5ef90,
+ 0x5409ed4b, 0xe6c8d59c, 0x5249daa2, 0xc402a33c, 0x5a6690ae, 0xd09441bb, 0x5471e2e6, 0xe61086bc,
+ 0x50d86e6d, 0xc33aee27, 0x5a43b190, 0xcf89e3e8, 0x54d69714, 0xe55937d5, 0x4f4af5d1, 0xc2884e6e,
+ 0x5a12e720, 0xce86ff2a, 0x553805f2, 0xe4a2eff6, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xcd8bbb6d,
+ 0x55962bc0, 0xe3edb628, 0x4bde1089, 0xc1633f8a, 0x5987b08a, 0xcc983f70, 0x55f104dc, 0xe3399167,
+ 0x49ffd417, 0xc0f1360b, 0x592d59da, 0xcbacb0bf, 0x56488dc5, 0xe28688a4, 0x4807eb4b, 0xc0950d1d,
+ 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x584f7b58, 0xc9edeb50,
+ 0x56eda1a0, 0xe123e6ad, 0x43cdd89a, 0xc01ed535, 0x57cc15bc, 0xc91af976, 0x573b2635, 0xe0745b24,
+ 0x418d2621, 0xc004ef3f, 0x573b2635, 0xc8507ea7, 0x57854ddd, 0xdfc606f1, 0x3f35b59d, 0xc0013bd3,
+ 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce, 0x3cc85709, 0xc013bc39, 0x55f104dc, 0xc6d569be,
+ 0x580f7b19, 0xde6d1f65, 0x3a45e1f7, 0xc03c6a07, 0x553805f2, 0xc6250a18, 0x584f7b58, 0xddc29958,
+ 0x37af354c, 0xc07b371e, 0x5471e2e6, 0xc57d965d, 0x588c1404, 0xdd196538, 0x350536f1, 0xc0d00db6,
+ 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x52beac9f, 0xc449d892,
+ 0x58fb0568, 0xdbcb0cce, 0x2f7afdfc, 0xc1bb5a11, 0x51d1dc80, 0xc3bdbdf6, 0x592d59da, 0xdb25f566,
+ 0x2c9caf6c, 0xc2517e31, 0x50d86e6d, 0xc33aee27, 0x595c3e2a, 0xda8249b4, 0x29aee694, 0xc2fd08a9,
+ 0x4fd288dc, 0xc2c17d52, 0x5987b08a, 0xd9e01006, 0x26b2a794, 0xc3bdbdf6, 0x4ec05432, 0xc2517e31,
+ 0x59afaf4c, 0xd93f4e9e, 0x23a8fb93, 0xc4935b3c, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xd8a00bae,
+ 0x2092f05f, 0xc57d965d, 0x4c77a88e, 0xc18e18a7, 0x59f54bee, 0xd8024d59, 0x1d719810, 0xc67c1e18,
+ 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d, 0x49ffd417, 0xc0f1360b,
+ 0x5a2d0957, 0xd6cb76c9, 0x17115bc0, 0xc8b4ab32, 0x48b2b335, 0xc0b15502, 0x5a43b190, 0xd6326a88,
+ 0x13d4ae08, 0xc9edeb50, 0x475a5c77, 0xc07b371e, 0x5a56deec, 0xd59afadb, 0x10911f04, 0xcb39edca,
+ 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97, 0x0d47d096, 0xcc983f70, 0x4488e37f, 0xc02c64a6,
+ 0x5a72c63b, 0xd4710883, 0x09f9e6a1, 0xce0866b8, 0x43103085, 0xc013bc39, 0x5a7b7f1a, 0xd3de9156,
+ 0x06a886a0, 0xcf89e3e8, 0x418d2621, 0xc004ef3f, 0x5a80baf6, 0xd34dcdb4, 0x0354d741, 0xd11c3142,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3e68fb62, 0xc004ef3f,
+ 0x5a80baf6, 0xd2317756, 0xfcab28bf, 0xd4710883, 0x3cc85709, 0xc013bc39, 0x5a7b7f1a, 0xd1a5ef90,
+ 0xf9577960, 0xd6326a88, 0x3b1e5335, 0xc02c64a6, 0x5a72c63b, 0xd11c3142, 0xf606195f, 0xd8024d59,
+ 0x396b3199, 0xc04ee4b8, 0x5a6690ae, 0xd09441bb, 0xf2b82f6a, 0xd9e01006, 0x37af354c, 0xc07b371e,
+ 0x5a56deec, 0xd00e2639, 0xef6ee0fc, 0xdbcb0cce, 0x35eaa2c7, 0xc0b15502, 0x5a43b190, 0xcf89e3e8,
+ 0xec2b51f8, 0xddc29958, 0x341dbfd3, 0xc0f1360b, 0x5a2d0957, 0xcf077fe1, 0xe8eea440, 0xdfc606f1,
+ 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x306c2624, 0xc18e18a7,
+ 0x59f54bee, 0xce0866b8, 0xe28e67f0, 0xe3edb628, 0x2e88013a, 0xc1eb0209, 0x59d438e5, 0xcd8bbb6d,
+ 0xdf6d0fa1, 0xe61086bc, 0x2c9caf6c, 0xc2517e31, 0x59afaf4c, 0xcd110216, 0xdc57046d, 0xe83c56cf,
+ 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70, 0xd94d586c, 0xea70658a, 0x28b1b544, 0xc33aee27,
+ 0x595c3e2a, 0xcc217822, 0xd651196c, 0xecabef3d, 0x26b2a794, 0xc3bdbdf6, 0x592d59da, 0xcbacb0bf,
+ 0xd3635094, 0xeeee2d9d, 0x24ada23d, 0xc449d892, 0x58fb0568, 0xcb39edca, 0xd0850204, 0xf136580d,
+ 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x2092f05f, 0xc57d965d,
+ 0x588c1404, 0xca5a86c4, 0xcafac90f, 0xf5d544a7, 0x1e7de5df, 0xc6250a18, 0x584f7b58, 0xc9edeb50,
+ 0xc850cab4, 0xf82a6c6a, 0x1c6427a9, 0xc6d569be, 0x580f7b19, 0xc9836582, 0xc5ba1e09, 0xfa824bfd,
+ 0x1a4608ab, 0xc78e9a1d, 0x57cc15bc, 0xc91af976, 0xc337a8f7, 0xfcdc1342, 0x1823dc7d, 0xc8507ea7,
+ 0x57854ddd, 0xc8b4ab32, 0xc0ca4a63, 0xff36f170, 0x15fdf758, 0xc91af976, 0x573b2635, 0xc8507ea7,
+ 0xbe72d9df, 0x0192155f, 0x13d4ae08, 0xc9edeb50, 0x56eda1a0, 0xc7ee77b3, 0xbc322766, 0x03ecadcf,
+ 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af, 0x0f7944a7, 0xcbacb0bf,
+ 0x56488dc5, 0xc730e997, 0xb7f814b5, 0x089cf867, 0x0d47d096, 0xcc983f70, 0x55f104dc, 0xc6d569be,
+ 0xb6002be9, 0x0af10a22, 0x0b145041, 0xcd8bbb6d, 0x55962bc0, 0xc67c1e18, 0xb421ef77, 0x0d415013,
+ 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18, 0xb25e054b, 0x0f8cfcbe, 0x06a886a0, 0xcf89e3e8,
+ 0x54d69714, 0xc5d03118, 0xb0b50a2f, 0x11d3443f, 0x0470ebdc, 0xd09441bb, 0x5471e2e6, 0xc57d965d,
+ 0xaf279193, 0x14135c94, 0x0238a1c6, 0xd1a5ef90, 0x5409ed4b, 0xc52d3d18, 0xadb6255e, 0x164c7ddd,
+ 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xfdc75e3a, 0xd3de9156,
+ 0x53304df6, 0xc4935b3c, 0xab2968ec, 0x1aa6c82b, 0xfb8f1424, 0xd5052d97, 0x52beac9f, 0xc449d892,
+ 0xaa0efb24, 0x1cc66e99, 0xf9577960, 0xd6326a88, 0x5249daa2, 0xc402a33c, 0xa9125e60, 0x1edc1953,
+ 0xf720e574, 0xd76619b6, 0x51d1dc80, 0xc3bdbdf6, 0xa833ea44, 0x20e70f32, 0xf4ebafbf, 0xd8a00bae,
+ 0x5156b6d9, 0xc37b2b6a, 0xa773ebfc, 0x22e69ac8, 0xf2b82f6a, 0xd9e01006, 0x50d86e6d, 0xc33aee27,
+ 0xa6d2a626, 0x24da0a9a, 0xf086bb59, 0xdb25f566, 0x50570819, 0xc2fd08a9, 0xa65050b4, 0x26c0b162,
+ 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xec2b51f8, 0xddc29958,
+ 0x4f4af5d1, 0xc2884e6e, 0xa5a92114, 0x2a650525, 0xea0208a8, 0xdf18f0ce, 0x4ec05432, 0xc2517e31,
+ 0xa58480e6, 0x2c216eaa, 0xe7dc2383, 0xe0745b24, 0x4e32a956, 0xc21d0eb8, 0xa57f450a, 0x2dce88aa,
+ 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209, 0xa5996f52, 0x2f6bbe45, 0xe39bd857, 0xe3399167,
+ 0x4d0e4de2, 0xc1bb5a11, 0xa5d2f6a9, 0x30f8801f, 0xe1821a21, 0xe4a2eff6, 0x4c77a88e, 0xc18e18a7,
+ 0xa62bc71b, 0x32744493, 0xdf6d0fa1, 0xe61086bc, 0x4bde1089, 0xc1633f8a, 0xa6a3c1d6, 0x33de87de,
+ 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xdb525dc3, 0xe8f77acf,
+ 0x4aa22036, 0xc114ccb9, 0xa7f084e7, 0x367c9a7e, 0xd94d586c, 0xea70658a, 0x49ffd417, 0xc0f1360b,
+ 0xa8c4d9cb, 0x37af8159, 0xd74e4abc, 0xebeca36c, 0x495aada2, 0xc0d00db6, 0xa9b7723b, 0x38cf1669,
+ 0xd5558381, 0xed6bf9d1, 0x48b2b335, 0xc0b15502, 0xaac7fa0e, 0x39daf5e8, 0xd3635094, 0xeeee2d9d,
+ 0x4807eb4b, 0xc0950d1d, 0xabf612b5, 0x3ad2c2e8, 0xd177fec6, 0xf0730342, 0x475a5c77, 0xc07b371e,
+ 0xad415361, 0x3bb6276e, 0xcf93d9dc, 0xf1fa3ecb, 0x46aa0d6d, 0xc063d405, 0xaea94927, 0x3c84d496,
+ 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae, 0xcbe2402d, 0xf50ef5de,
+ 0x454149fc, 0xc03c6a07, 0xb1cd56aa, 0x3de2f148, 0xca155d39, 0xf69bf7c9, 0x4488e37f, 0xc02c64a6,
+ 0xb3885772, 0x3e71e759, 0xc850cab4, 0xf82a6c6a, 0x43cdd89a, 0xc01ed535, 0xb55ddfca, 0x3eeb3347,
+ 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39, 0xb74d4ccb, 0x3f4eaafe, 0xc4e1accb, 0xfb4ab7db,
+ 0x424ff28f, 0xc00b1a20, 0xb955f293, 0x3f9c2bfb, 0xc337a8f7, 0xfcdc1342, 0x418d2621, 0xc004ef3f,
+ 0xbb771c81, 0x3fd39b5a, 0xc197049e, 0xfe6deaa1, 0x40c7d2bd, 0xc0013bd3, 0xbdb00d71, 0x3ff4e5e0,
+};
+
+const int twidTabEven[4 * 6 + 16 * 6 + 64 * 6] = {
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x5a82799a, 0xd2bec333,
+ 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333,
+ 0x00000000, 0xd2bec333, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7,
+
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x4b418bbe, 0xf383a3e2,
+ 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2,
+ 0x58c542c5, 0xdc71898d, 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a,
+ 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xcac933ae,
+ 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d,
+ 0x3248d382, 0xc13ad060, 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3248d382, 0xc13ad060,
+ 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae,
+ 0xcdb72c7e, 0xf383a3e2, 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af,
+ 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xee57aa21, 0xdc71898d,
+ 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060,
+ 0xa73abd3b, 0x3536cc52, 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae,
+
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x43103085, 0xfcdc1342,
+ 0x418d2621, 0xfe6deaa1, 0x4488e37f, 0xfb4ab7db, 0x45f704f7, 0xf9ba1651, 0x43103085, 0xfcdc1342,
+ 0x48b2b335, 0xf69bf7c9, 0x48b2b335, 0xf69bf7c9, 0x4488e37f, 0xfb4ab7db, 0x4c77a88e, 0xf1fa3ecb,
+ 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x4da1fab5, 0xf0730342,
+ 0x475a5c77, 0xf82a6c6a, 0x52beac9f, 0xe8f77acf, 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9,
+ 0x553805f2, 0xe4a2eff6, 0x51d1dc80, 0xea70658a, 0x49ffd417, 0xf50ef5de, 0x573b2635, 0xe0745b24,
+ 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x553805f2, 0xe4a2eff6,
+ 0x4c77a88e, 0xf1fa3ecb, 0x59d438e5, 0xd8a00bae, 0x569cc31b, 0xe1d4a2c8, 0x4da1fab5, 0xf0730342,
+ 0x5a6690ae, 0xd5052d97, 0x57cc15bc, 0xdf18f0ce, 0x4ec05432, 0xeeee2d9d, 0x5a7b7f1a, 0xd1a5ef90,
+ 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a, 0x5987b08a, 0xd9e01006,
+ 0x50d86e6d, 0xebeca36c, 0x592d59da, 0xcbacb0bf, 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a,
+ 0x57cc15bc, 0xc91af976, 0x5a6690ae, 0xd5052d97, 0x52beac9f, 0xe8f77acf, 0x55f104dc, 0xc6d569be,
+ 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a6690ae, 0xd09441bb,
+ 0x5471e2e6, 0xe61086bc, 0x50d86e6d, 0xc33aee27, 0x5a12e720, 0xce86ff2a, 0x553805f2, 0xe4a2eff6,
+ 0x4da1fab5, 0xc1eb0209, 0x5987b08a, 0xcc983f70, 0x55f104dc, 0xe3399167, 0x49ffd417, 0xc0f1360b,
+ 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x57cc15bc, 0xc91af976,
+ 0x573b2635, 0xe0745b24, 0x418d2621, 0xc004ef3f, 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce,
+ 0x3cc85709, 0xc013bc39, 0x553805f2, 0xc6250a18, 0x584f7b58, 0xddc29958, 0x37af354c, 0xc07b371e,
+ 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x51d1dc80, 0xc3bdbdf6,
+ 0x592d59da, 0xdb25f566, 0x2c9caf6c, 0xc2517e31, 0x4fd288dc, 0xc2c17d52, 0x5987b08a, 0xd9e01006,
+ 0x26b2a794, 0xc3bdbdf6, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xd8a00bae, 0x2092f05f, 0xc57d965d,
+ 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d, 0x48b2b335, 0xc0b15502,
+ 0x5a43b190, 0xd6326a88, 0x13d4ae08, 0xc9edeb50, 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97,
+ 0x0d47d096, 0xcc983f70, 0x43103085, 0xc013bc39, 0x5a7b7f1a, 0xd3de9156, 0x06a886a0, 0xcf89e3e8,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3cc85709, 0xc013bc39,
+ 0x5a7b7f1a, 0xd1a5ef90, 0xf9577960, 0xd6326a88, 0x396b3199, 0xc04ee4b8, 0x5a6690ae, 0xd09441bb,
+ 0xf2b82f6a, 0xd9e01006, 0x35eaa2c7, 0xc0b15502, 0x5a43b190, 0xcf89e3e8, 0xec2b51f8, 0xddc29958,
+ 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x2e88013a, 0xc1eb0209,
+ 0x59d438e5, 0xcd8bbb6d, 0xdf6d0fa1, 0xe61086bc, 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70,
+ 0xd94d586c, 0xea70658a, 0x26b2a794, 0xc3bdbdf6, 0x592d59da, 0xcbacb0bf, 0xd3635094, 0xeeee2d9d,
+ 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x1e7de5df, 0xc6250a18,
+ 0x584f7b58, 0xc9edeb50, 0xc850cab4, 0xf82a6c6a, 0x1a4608ab, 0xc78e9a1d, 0x57cc15bc, 0xc91af976,
+ 0xc337a8f7, 0xfcdc1342, 0x15fdf758, 0xc91af976, 0x573b2635, 0xc8507ea7, 0xbe72d9df, 0x0192155f,
+ 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af, 0x0d47d096, 0xcc983f70,
+ 0x55f104dc, 0xc6d569be, 0xb6002be9, 0x0af10a22, 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18,
+ 0xb25e054b, 0x0f8cfcbe, 0x0470ebdc, 0xd09441bb, 0x5471e2e6, 0xc57d965d, 0xaf279193, 0x14135c94,
+ 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xfb8f1424, 0xd5052d97,
+ 0x52beac9f, 0xc449d892, 0xaa0efb24, 0x1cc66e99, 0xf720e574, 0xd76619b6, 0x51d1dc80, 0xc3bdbdf6,
+ 0xa833ea44, 0x20e70f32, 0xf2b82f6a, 0xd9e01006, 0x50d86e6d, 0xc33aee27, 0xa6d2a626, 0x24da0a9a,
+ 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xea0208a8, 0xdf18f0ce,
+ 0x4ec05432, 0xc2517e31, 0xa58480e6, 0x2c216eaa, 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209,
+ 0xa5996f52, 0x2f6bbe45, 0xe1821a21, 0xe4a2eff6, 0x4c77a88e, 0xc18e18a7, 0xa62bc71b, 0x32744493,
+ 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xd94d586c, 0xea70658a,
+ 0x49ffd417, 0xc0f1360b, 0xa8c4d9cb, 0x37af8159, 0xd5558381, 0xed6bf9d1, 0x48b2b335, 0xc0b15502,
+ 0xaac7fa0e, 0x39daf5e8, 0xd177fec6, 0xf0730342, 0x475a5c77, 0xc07b371e, 0xad415361, 0x3bb6276e,
+ 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae, 0xca155d39, 0xf69bf7c9,
+ 0x4488e37f, 0xc02c64a6, 0xb3885772, 0x3e71e759, 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39,
+ 0xb74d4ccb, 0x3f4eaafe, 0xc337a8f7, 0xfcdc1342, 0x418d2621, 0xc004ef3f, 0xbb771c81, 0x3fd39b5a,
+};
+
+/* for reference, here's the code to generate the bitreverse tables
+ short blocks: nbits = 4 (nfft = 64)
+ long blocks: nbits = 7 (nfft = 512)
+
+static int bitrev(int n, int nbits)
+{
+ int r, i;
+
+ r = 0;
+ for (i = 0; i < nbits; i++) {
+ r <<= 1;
+ r |= (n & 1);
+ n >>= 1;
+ }
+
+ return r;
+}
+
+static void InitBitrevTable(unsigned char *out, int nbits)
+{
+ int i, t;
+
+ for (i = 0; i < (1<<nbits); i++) {
+ / *** do not register the same transposition twice *** /
+ t = bitrev(i,nbits);
+ if (i < t) {
+ *out++ = (unsigned char)i;
+ *out++ = (unsigned char)t;
+ }
+ }
+
+ / *** no need to write a sentinel (or rather, the first entry in the
+ * table for symetric codes will be 0, which serves as the sentinel)
+ *** /
+ for (i = 0; i < (1<<nbits); i++) {
+ t = bitrev(i,nbits);
+ if (i == t) / *** symmetric codes get special treatment *** /
+ *out++ = (unsigned char)t;
+ }
+ *out++ = 0; / *** second sentinel is 0, again *** /
+}
+
+*/
+
+/* code to generate KBD window:
+static double CalcI0(double x)
+{
+ int k;
+ double i0, iTmp, iLast, x2, xPow, kFact;
+
+ x2 = x / 2.0;
+ i0 = 0.0;
+ k = 0;
+ kFact = 1;
+ xPow = 1;
+ do {
+ iLast = i0;
+ iTmp = xPow / kFact;
+ i0 += (iTmp*iTmp);
+ k++;
+ kFact *= k;
+ xPow *= x2;
+ } while (fabs(i0 - iLast) > KBD_THRESH);
+
+ return i0;
+}
+
+static double CalcW(double nRef, double n, double a)
+{
+ double i0Base, i0Curr, nTemp;
+
+ i0Base = CalcI0(M_PI * a);
+
+ nTemp = (n - nRef/4) / (nRef/4);
+ i0Curr = CalcI0( M_PI * a * sqrt(1.0 - nTemp*nTemp) );
+
+ return i0Curr / i0Base;
+}
+
+void InitKBDWindow(int nmdct)
+{
+ int n, nRef;
+ double a, wBase, wCurr;
+
+ nRef = nmdct * 2;
+
+ / *** kbd window *** /
+ if (nmdct == 128)
+ a = 6.0;
+ else
+ a = 4.0;
+
+ wBase = 0;
+ for (n = 0; n <= nRef/2; n++)
+ wBase += CalcW(nRef, n, a);
+
+ / *** left *** /
+ wCurr = 0;
+ for (n = 0; n < nRef/2; n++) {
+ wCurr += CalcW(nRef, n, a);
+ kbdWindowRef[n] = sqrt(wCurr / wBase);
+ }
+
+ / ***
+ * symmetry:
+ * kbd_right(n) = kbd_ldef(N_REF - 1 - n), n = [N_REF/2, N_REF - 1]
+ *
+ * wCurr = 0;
+ * for (n = N_REF-1; n >= N_REF/2; n--) {
+ * wCurr += CalcW(N_REF-n-1, a);
+ * kbdWindowRef[n] = sqrt(wCurr / wBase);
+ * }
+ *
+ *** /
+ return;
+}
+*/
diff --git a/audio_codec/libfaad/helixaac/trigtabs_fltgen.c b/audio_codec/libfaad/helixaac/trigtabs_fltgen.c
new file mode 100644
index 0000000..b5ffa8e
--- a/dev/null
+++ b/audio_codec/libfaad/helixaac/trigtabs_fltgen.c
@@ -0,0 +1,357 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: trigtabs_fltgen.c,v 1.2 2006/12/05 03:36:53 ehyche Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * June 2005
+ *
+ * trigtabs_fltgen.c - low-ROM alternative to trigtabs.c
+ * generates large trig tables at runtime using floating-point
+ * math library
+ * MUST VERIFY that runtime-generated tables are bit-exact matches
+ * with ROM tables in trigtabs.c
+ **************************************************************************************/
+#ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT
+
+#include <math.h>
+#include "coder.h"
+
+/* read-only tables */
+const int cos4sin4tabOffset[NUM_IMDCT_SIZES] = {0, 128};
+const int sinWindowOffset[NUM_IMDCT_SIZES] = {0, 128};
+const int kbdWindowOffset[NUM_IMDCT_SIZES] = {0, 128};
+const int bitrevtabOffset[NUM_IMDCT_SIZES] = {0, 17};
+const unsigned char bitrevtab[17 + 129] = {
+ /* nfft = 64 */
+ 0x01, 0x08, 0x02, 0x04, 0x03, 0x0c, 0x05, 0x0a, 0x07, 0x0e, 0x0b, 0x0d, 0x00, 0x06, 0x09, 0x0f,
+ 0x00,
+
+ /* nfft = 512 */
+ 0x01, 0x40, 0x02, 0x20, 0x03, 0x60, 0x04, 0x10, 0x05, 0x50, 0x06, 0x30, 0x07, 0x70, 0x09, 0x48,
+ 0x0a, 0x28, 0x0b, 0x68, 0x0c, 0x18, 0x0d, 0x58, 0x0e, 0x38, 0x0f, 0x78, 0x11, 0x44, 0x12, 0x24,
+ 0x13, 0x64, 0x15, 0x54, 0x16, 0x34, 0x17, 0x74, 0x19, 0x4c, 0x1a, 0x2c, 0x1b, 0x6c, 0x1d, 0x5c,
+ 0x1e, 0x3c, 0x1f, 0x7c, 0x21, 0x42, 0x23, 0x62, 0x25, 0x52, 0x26, 0x32, 0x27, 0x72, 0x29, 0x4a,
+ 0x2b, 0x6a, 0x2d, 0x5a, 0x2e, 0x3a, 0x2f, 0x7a, 0x31, 0x46, 0x33, 0x66, 0x35, 0x56, 0x37, 0x76,
+ 0x39, 0x4e, 0x3b, 0x6e, 0x3d, 0x5e, 0x3f, 0x7e, 0x43, 0x61, 0x45, 0x51, 0x47, 0x71, 0x4b, 0x69,
+ 0x4d, 0x59, 0x4f, 0x79, 0x53, 0x65, 0x57, 0x75, 0x5b, 0x6d, 0x5f, 0x7d, 0x67, 0x73, 0x6f, 0x7b,
+ 0x00, 0x08, 0x14, 0x1c, 0x22, 0x2a, 0x36, 0x3e, 0x41, 0x49, 0x55, 0x5d, 0x63, 0x6b, 0x77, 0x7f,
+ 0x00,
+
+};
+
+/* tables generated at runtime */
+int cos4sin4tab[128 + 1024];
+int cos1sin1tab[514];
+int sinWindow[128 + 1024];
+int kbdWindow[128 + 1024];
+int twidTabEven[4 * 6 + 16 * 6 + 64 * 6];
+int twidTabOdd[8 * 6 + 32 * 6 + 128 * 6];
+
+#define M_PI 3.14159265358979323846
+#define M2_30 1073741824.0
+#define M2_31 2147483648.0
+
+#define MAX_DBL 2147483647.0
+#define MIN_DBL -2147483648.0
+
+static int NormAndRound(double x, double q, double n)
+{
+ if (x >= 0.0) {
+ x = (x * q * n + 0.5);
+ } else {
+ x = (x * q * n - 0.5);
+ }
+
+ /* clip */
+ if (x > MAX_DBL) {
+ x = MAX_DBL;
+ }
+ if (x < MIN_DBL) {
+ x = MIN_DBL;
+ }
+
+ return (int)x;
+}
+
+static void Init_cos4sin4tab(int *tPtr, int nmdct)
+{
+ int i;
+ double angle1, angle2, invM, x1, x2, x3, x4;
+
+ invM = -1.0 / (double)nmdct;
+ for (i = 0; i < nmdct / 4; i++) {
+ angle1 = (i + 0.25) * M_PI / nmdct;
+ angle2 = (nmdct / 2 - 1 - i + 0.25) * M_PI / nmdct;
+
+ x1 = invM * (cos(angle1) + sin(angle1));
+ x2 = invM * sin(angle1);
+ x3 = invM * (cos(angle2) + sin(angle2));
+ x4 = invM * sin(angle2);
+
+ tPtr[0] = NormAndRound(x1, M2_30, nmdct);
+ tPtr[1] = NormAndRound(x2, M2_30, nmdct);
+ tPtr[2] = NormAndRound(x3, M2_30, nmdct);
+ tPtr[3] = NormAndRound(x4, M2_30, nmdct);
+ tPtr += 4;
+ }
+}
+
+static void Init_cos1sin1tab(int *tPtr)
+{
+ int i;
+ double angle, x1, x2;
+
+ for (i = 0; i <= (512 / 2); i++) {
+ angle = i * M_PI / 1024;
+ x1 = (cos(angle) + sin(angle));
+ x2 = sin(angle);
+
+ tPtr[0] = NormAndRound(x1, M2_30, 1);
+ tPtr[1] = NormAndRound(x2, M2_30, 1);
+ tPtr += 2;
+ }
+}
+
+static void Init_sinWindow(int *tPtr, int nmdct)
+{
+ int i;
+ double angle1, angle2, x1, x2;
+
+ for (i = 0; i < nmdct / 2; i++) {
+ angle1 = (i + 0.5) * M_PI / (2.0 * nmdct);
+ angle2 = (nmdct - 1 - i + 0.5) * M_PI / (2.0 * nmdct);
+ x1 = sin(angle1);
+ x2 = sin(angle2);
+
+ tPtr[0] = NormAndRound(x1, M2_31, 1);
+ tPtr[1] = NormAndRound(x2, M2_31, 1);
+ tPtr += 2;
+ }
+}
+
+
+#define KBD_THRESH 1e-12
+
+static double CalcI0(double x)
+{
+ int k;
+ double i0, iTmp, iLast, x2, xPow, kFact;
+
+ x2 = x / 2.0;
+ i0 = 0.0;
+ k = 0;
+ kFact = 1;
+ xPow = 1;
+ do {
+ iLast = i0;
+ iTmp = xPow / kFact;
+ i0 += (iTmp * iTmp);
+ k++;
+ kFact *= k;
+ xPow *= x2;
+ } while (fabs(i0 - iLast) > KBD_THRESH);
+
+ return i0;
+}
+
+static double CalcW(double nRef, double n, double a)
+{
+ double i0Base, i0Curr, nTemp;
+
+ i0Base = CalcI0(M_PI * a);
+
+ nTemp = (n - nRef / 4) / (nRef / 4);
+ i0Curr = CalcI0(M_PI * a * sqrt(1.0 - nTemp * nTemp));
+
+ return i0Curr / i0Base;
+}
+
+static void Init_kbdWindow(int *tPtr, int nmdct)
+{
+ int n, nRef;
+ double a, wBase, wCurr, x1;
+
+ nRef = nmdct * 2;
+
+ /* kbd window */
+ if (nmdct == 128) {
+ a = 6.0;
+ } else {
+ a = 4.0;
+ }
+
+ wBase = 0;
+ for (n = 0; n <= nRef / 2; n++) {
+ wBase += CalcW(nRef, n, a);
+ }
+
+ /* left */
+ wCurr = 0;
+ for (n = 0; n < nmdct / 2; n++) {
+ wCurr += CalcW(nRef, n, a);
+ x1 = sqrt(wCurr / wBase);
+ tPtr[0] = NormAndRound(x1, M2_31, 1);
+ tPtr += 2;
+ }
+ tPtr--;
+
+ /* right */
+ for (n = nmdct / 2; n < nmdct; n++) {
+ wCurr += CalcW(nRef, n, a);
+ x1 = sqrt(wCurr / wBase);
+ tPtr[0] = NormAndRound(x1, M2_31, 1);
+ tPtr -= 2;
+ }
+
+ /* symmetry:
+ * kbd_right(n) = kbd_ldef(N_REF - 1 - n), n = [N_REF/2, N_REF - 1]
+ *
+ * wCurr = 0;
+ * for (n = N_REF-1; n >= N_REF/2; n--) {
+ * wCurr += CalcW(N_REF-n-1, a);
+ * kbdWindowRef[n] = sqrt(wCurr / wBase);
+ * }
+ *
+ */
+ return;
+}
+
+static void Init_twidTabs(int *tPtrEven, int *tPtrOdd, int nfft)
+{
+ int j, k;
+ double wr1, wi1, wr2, wi2, wr3, wi3;
+
+ for (k = 4; k <= nfft / 4; k <<= 1) {
+ for (j = 0; j < k; j++) {
+ wr1 = cos(1.0 * M_PI * j / (2 * k));
+ wi1 = sin(1.0 * M_PI * j / (2 * k));
+ wr1 = (wr1 + wi1);
+ wi1 = -wi1;
+
+ wr2 = cos(2.0 * M_PI * j / (2 * k));
+ wi2 = sin(2.0 * M_PI * j / (2 * k));
+ wr2 = (wr2 + wi2);
+ wi2 = -wi2;
+
+ wr3 = cos(3.0 * M_PI * j / (2 * k));
+ wi3 = sin(3.0 * M_PI * j / (2 * k));
+ wr3 = (wr3 + wi3);
+ wi3 = -wi3;
+
+ if (k & 0xaaaaaaaa) {
+ tPtrOdd[0] = NormAndRound(wr2, M2_30, 1);
+ tPtrOdd[1] = NormAndRound(wi2, M2_30, 1);
+ tPtrOdd[2] = NormAndRound(wr1, M2_30, 1);
+ tPtrOdd[3] = NormAndRound(wi1, M2_30, 1);
+ tPtrOdd[4] = NormAndRound(wr3, M2_30, 1);
+ tPtrOdd[5] = NormAndRound(wi3, M2_30, 1);
+ tPtrOdd += 6;
+ } else {
+ tPtrEven[0] = NormAndRound(wr2, M2_30, 1);
+ tPtrEven[1] = NormAndRound(wi2, M2_30, 1);
+ tPtrEven[2] = NormAndRound(wr1, M2_30, 1);
+ tPtrEven[3] = NormAndRound(wi1, M2_30, 1);
+ tPtrEven[4] = NormAndRound(wr3, M2_30, 1);
+ tPtrEven[5] = NormAndRound(wi3, M2_30, 1);
+ tPtrEven += 6;
+ }
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: AACInitTrigtabsFloat
+ *
+ * Description: generate AAC decoder tables using floating-point math library
+ *
+ * Inputs: none
+ *
+ * Outputs: initialized tables
+ *
+ * Return: 0 on success
+ *
+ * Notes: this function should ONLY be called when double-precision
+ * floating-point math is supported
+ * the generated tables must be bit-exact matches with read-only
+ * tables stored in trigtabs.c
+ * this initializes global tables in RAM, and is NOT thread-safe,
+ * so the caller must ensure that this function is not called
+ * from multiple threads
+ * this should be called exactly once, before the entrypoint function
+ * for the application or DLL is called
+ **************************************************************************************/
+int AACInitTrigtabsFloat(void)
+{
+ /* cos4sin4tab */
+ Init_cos4sin4tab(cos4sin4tab + cos4sin4tabOffset[0], 128);
+ Init_cos4sin4tab(cos4sin4tab + cos4sin4tabOffset[1], 1024);
+
+ /* cos1sin1tab */
+ Init_cos1sin1tab(cos1sin1tab);
+
+ /* sinWindow */
+ Init_sinWindow(sinWindow + sinWindowOffset[0], 128);
+ Init_sinWindow(sinWindow + sinWindowOffset[1], 1024);
+
+ /* kbdWindow */
+ Init_kbdWindow(kbdWindow + kbdWindowOffset[0], 128);
+ Init_kbdWindow(kbdWindow + kbdWindowOffset[1], 1024);
+
+ /* twidTabEven, twidTabOdd */
+ Init_twidTabs(twidTabEven, twidTabOdd, 512);
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: AACFreeTrigtabsFloat
+ *
+ * Description: free any memory allocated by AACInitTrigtabsFloat()
+ *
+ * Inputs: none
+ *
+ * Outputs: none
+ *
+ * Return: none
+ **************************************************************************************/
+void AACFreeTrigtabsFloat(void)
+{
+ return;
+}
+
+#endif /* HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT */
diff --git a/audio_codec/libfaad/huffman.c b/audio_codec/libfaad/huffman.c
new file mode 100644
index 0000000..5702d13
--- a/dev/null
+++ b/audio_codec/libfaad/huffman.c
@@ -0,0 +1,582 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: huffman.c,v 1.26 2007/11/01 12:33:30 menno Exp $
+**/
+#include <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+#ifdef ANALYSIS
+#include <stdio.h>
+#endif
+
+#include "bits.h"
+#include "huffman.h"
+#include "codebook/hcb.h"
+
+
+/* static function declarations */
+static INLINE void huffman_sign_bits(bitfile *ld, int16_t *sp, uint8_t len);
+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 uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp);
+static 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);
+static void vcb11_check_LAV(uint8_t cb, int16_t *sp);
+
+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[] = {
+ 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[] = {
+ 0, hcb1_2, hcb2_2, 0, hcb4_2, 0, 0, 0, 0, 0, 0, 0
+};
+
+hcb_2_pair *hcb_2_pair_table[] = {
+ 0, 0, 0, 0, 0, 0, hcb6_2, 0, hcb8_2, 0, hcb10_2, hcb11_2
+};
+
+hcb_bin_pair *hcb_bin_table[] = {
+ 0, 0, 0, 0, 0, hcb5, 0, hcb7, 0, hcb9, 0, 0
+};
+
+uint8_t hcbN[] = { 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[] = { 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[] = { 0, 114, 86, 0, 185, 0, 0, 0, 0, 0, 0, 0 };
+int hcb_2_pair_table_size[] = { 0, 0, 0, 0, 0, 0, 126, 0, 83, 0, 210, 373 };
+int hcb_bin_table_size[] = { 0, 0, 0, 161, 0, 161, 0, 127, 0, 337, 0, 0 };
+
+static INLINE void huffman_sign_bits(bitfile *ld, int16_t *sp, uint8_t len)
+{
+ uint8_t i;
+
+ for (i = 0; i < len; i++) {
+ if (sp[i]) {
+ if (faad_get1bit(ld
+ DEBUGVAR(1, 5, "huffman_sign_bits(): sign bit")) & 1) {
+ sp[i] = -sp[i];
+ }
+ }
+ }
+}
+
+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 << i);
+ if (neg) {
+ j = -j;
+ }
+
+ return j;
+}
+
+static uint8_t huffman_2step_quad(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_quad_table[cb][offset].bits - hcbN[cb]);
+ } else {
+ faad_flushbits(ld, hcb_2_quad_table[cb][offset].bits);
+ }
+
+ if (offset > 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(ld, sp, QUAD_LEN);
+
+ return err;
+}
+
+static 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 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(ld, sp, PAIR_LEN);
+
+ 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(ld, sp, QUAD_LEN);
+
+ 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(ld, sp, PAIR_LEN);
+
+ 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;
+ }
+}
+
+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;
+ }
+}
+
+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 << i);
+ sp[k] = (int16_t)((neg) ? -j : j);
+ }
+ }
+
+ if (vcb11 != 0) {
+ /* check LAV (Largest Absolute Value) */
+ /* this finds errors in the ESCAPE signal */
+ vcb11_check_LAV(vcb11, sp);
+ }
+ }
+ return ld->len;
+}
+
+#endif
+
diff --git a/audio_codec/libfaad/huffman.h b/audio_codec/libfaad/huffman.h
new file mode 100644
index 0000000..3eaa9fe
--- a/dev/null
+++ b/audio_codec/libfaad/huffman.h
@@ -0,0 +1,47 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: huffman.h,v 1.28 2007/11/01 12:33:30 menno Exp $
+**/
+
+#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);
+#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/audio_codec/libfaad/ic_predict.c b/audio_codec/libfaad/ic_predict.c
new file mode 100644
index 0000000..a85247a
--- a/dev/null
+++ b/audio_codec/libfaad/ic_predict.c
@@ -0,0 +1,258 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: ic_predict.c,v 1.28 2007/11/01 12:33:31 menno Exp $
+**/
+#include <stdlib.h>
+#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;
+ float32_t 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];
+ float32_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];
+ float32_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 = min(ics->swb_offset[sfb + 1], ics->swb_offset_max);
+
+ 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 = min(ics->swb_offset[sfb + 1], ics->swb_offset_max);
+
+ 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/audio_codec/libfaad/ic_predict.h b/audio_codec/libfaad/ic_predict.h
new file mode 100644
index 0000000..6b97907
--- a/dev/null
+++ b/audio_codec/libfaad/ic_predict.h
@@ -0,0 +1,252 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: ic_predict.h,v 1.23 2007/11/01 12:33:31 menno Exp $
+**/
+
+#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);
+
+ ALIGN 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)
+ };
+
+ ALIGN 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/audio_codec/libfaad/iq_table.h b/audio_codec/libfaad/iq_table.h
new file mode 100644
index 0000000..27c44e5
--- a/dev/null
+++ b/audio_codec/libfaad/iq_table.h
@@ -0,0 +1,16456 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: iq_table.h,v 1.20 2007/11/01 12:33:31 menno Exp $
+**/
+
+#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
+
+ ALIGN static const real_t iq_table[IQ_TABLE_SIZE] = {
+ 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
+
+ ALIGN static const real_t iq_table[IQ_TABLE_SIZE] = {
+ 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/audio_codec/libfaad/is.c b/audio_codec/libfaad/is.c
new file mode 100644
index 0000000..dc64cee
--- a/dev/null
+++ b/audio_codec/libfaad/is.c
@@ -0,0 +1,106 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: is.c,v 1.28 2007/11/01 12:33:31 menno Exp $
+**/
+
+#include "common.h"
+#include "structs.h"
+
+#include "syntax.h"
+#include "is.h"
+
+#ifdef FIXED_POINT
+static real_t pow05_table[] = {
+ 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;
+#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 */
+ for (i = icsr->swb_offset[sfb]; i < min(icsr->swb_offset[sfb + 1], ics->swb_offset_max); i++) {
+#ifndef FIXED_POINT
+ r_spec[(group * nshort) + i] = MUL_R(l_spec[(group * nshort) + i], scale);
+#else
+ if (exp < 0) {
+ r_spec[(group * nshort) + i] = l_spec[(group * nshort) + i] << -exp;
+ } else {
+ r_spec[(group * nshort) + i] = l_spec[(group * nshort) + i] >> exp;
+ }
+ r_spec[(group * nshort) + i] = MUL_C(r_spec[(group * nshort) + i], pow05_table[frac + 3]);
+#endif
+ if (is_intensity(icsr, g, sfb) != invert_intensity(ics, g, sfb)) {
+ r_spec[(group * nshort) + i] = -r_spec[(group * nshort) + i];
+ }
+ }
+ }
+ }
+ group++;
+ }
+ }
+}
diff --git a/audio_codec/libfaad/is.h b/audio_codec/libfaad/is.h
new file mode 100644
index 0000000..8dc603d
--- a/dev/null
+++ b/audio_codec/libfaad/is.h
@@ -0,0 +1,67 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: is.h,v 1.20 2007/11/01 12:33:31 menno Exp $
+**/
+
+#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/audio_codec/libfaad/kbd_win.h b/audio_codec/libfaad/kbd_win.h
new file mode 100644
index 0000000..8eabfad
--- a/dev/null
+++ b/audio_codec/libfaad/kbd_win.h
@@ -0,0 +1,2294 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: kbd_win.h,v 1.21 2007/11/01 12:33:31 menno Exp $
+**/
+
+#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
+
+ ALIGN static const real_t kbd_long_1024[] = {
+ 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
+ ALIGN static const real_t kbd_long_960[] = {
+ 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
+
+ ALIGN static const real_t kbd_short_128[] = {
+ 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
+ ALIGN static const real_t kbd_short_120[] = {
+ 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/audio_codec/libfaad/libaacdec.c b/audio_codec/libfaad/libaacdec.c
new file mode 100644
index 0000000..b4acc09
--- a/dev/null
+++ b/audio_codec/libfaad/libaacdec.c
@@ -0,0 +1,544 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: main.c,v 1.85 2008/09/22 17:55:09 menno Exp $
+**/
+
+#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#define off_t __int64
+#else
+#include <time.h>
+#endif
+
+#include "libaacdec.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <sys/time.h>
+#ifndef WIN32
+#include <android/log.h>
+#endif
+
+#define min(a,b) ( (a) < (b) ? (a) : (b) )
+
+/* MicroSoft channel definitions */
+#define SPEAKER_FRONT_LEFT 0x1
+#define SPEAKER_FRONT_RIGHT 0x2
+#define SPEAKER_FRONT_CENTER 0x4
+#define SPEAKER_LOW_FREQUENCY 0x8
+#define SPEAKER_BACK_LEFT 0x10
+#define SPEAKER_BACK_RIGHT 0x20
+#define SPEAKER_FRONT_LEFT_OF_CENTER 0x40
+#define SPEAKER_FRONT_RIGHT_OF_CENTER 0x80
+#define SPEAKER_BACK_CENTER 0x100
+#define SPEAKER_SIDE_LEFT 0x200
+#define SPEAKER_SIDE_RIGHT 0x400
+#define SPEAKER_TOP_CENTER 0x800
+#define SPEAKER_TOP_FRONT_LEFT 0x1000
+#define SPEAKER_TOP_FRONT_CENTER 0x2000
+#define SPEAKER_TOP_FRONT_RIGHT 0x4000
+#define SPEAKER_TOP_BACK_LEFT 0x8000
+#define SPEAKER_TOP_BACK_CENTER 0x10000
+#define SPEAKER_TOP_BACK_RIGHT 0x20000
+#define SPEAKER_RESERVED 0x80000000
+
+#define DefaultReadSize 1024*10 //read count from kernel audio buf one time
+#define DefaultOutBufSize 1024*1024
+#define MAX_CHANNELS 6 /* make this higher to support files with more channels */
+
+//audio decoder buffer 6144 bytes
+#define AAC_INPUTBUF_SIZE 768 /* pick something big enough to hold a bunch of frames */
+
+#define ERROR_RESET_COUNT 40
+#define RSYNC_SKIP_BYTES 1
+#define FRAME_RECORD_NUM 40
+#define FRAME_SIZE_MARGIN 300
+
+enum {
+ AAC_ERROR_NO_ENOUGH_DATA = -1,
+ AAC_ERROR_NEED_RESET_DECODER = -2,
+};
+
+
+typedef struct FaadContext {
+ NeAACDecHandle hDecoder;
+ int init_flag;
+ int header_type;
+ int gSampleRate;
+ int gChannels;
+ int error_count;
+ int frame_length_his[FRAME_RECORD_NUM];
+ unsigned int muted_samples;
+ unsigned int muted_count;
+ unsigned init_cost; // summary init funciton cost bytes
+ unsigned init_start_flag; //start flag to summary data cost
+ int64_t starttime;
+ int64_t endtime;
+} FaadContext;
+
+typedef(*findsyncfunc)(unsigned char *buf, int nBytes);
+static const int adts_sample_rates[] = {96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350, 0, 0, 0};
+
+static int64_t gettime(void)
+{
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
+}
+
+static long aacChannelConfig2wavexChannelMask(NeAACDecFrameInfo *hInfo)
+{
+ if (hInfo->channels == 6 && hInfo->num_lfe_channels) {
+ return SPEAKER_FRONT_LEFT + SPEAKER_FRONT_RIGHT +
+ SPEAKER_FRONT_CENTER + SPEAKER_LOW_FREQUENCY +
+ SPEAKER_BACK_LEFT + SPEAKER_BACK_RIGHT;
+ } else {
+ return 0;
+ }
+}
+
+static char *position2string(int position)
+{
+ switch (position) {
+ case FRONT_CHANNEL_CENTER:
+ return "Center front";
+ case FRONT_CHANNEL_LEFT:
+ return "Left front";
+ case FRONT_CHANNEL_RIGHT:
+ return "Right front";
+ case SIDE_CHANNEL_LEFT:
+ return "Left side";
+ case SIDE_CHANNEL_RIGHT:
+ return "Right side";
+ case BACK_CHANNEL_LEFT:
+ return "Left back";
+ case BACK_CHANNEL_RIGHT:
+ return "Right back";
+ case BACK_CHANNEL_CENTER:
+ return "Center back";
+ case LFE_CHANNEL:
+ return "LFE";
+ case UNKNOWN_CHANNEL:
+ return "Unknown";
+ default:
+ return "";
+ }
+
+ return "";
+}
+
+
+
+static int FindAdtsSRIndex(int sr)
+{
+ int i;
+
+ for (i = 0; i < 16; i++) {
+ if (sr == adts_sample_rates[i]) {
+ return i;
+ }
+ }
+ return 16 - 1;
+}
+
+static unsigned char *MakeAdtsHeader(int *dataSize, NeAACDecFrameInfo *hInfo, int old_format)
+{
+ unsigned char *data;
+ int profile = (hInfo->object_type - 1) & 0x3;
+ int sr_index = ((hInfo->sbr == SBR_UPSAMPLED) || (hInfo->sbr == NO_SBR_UPSAMPLED)) ?
+ FindAdtsSRIndex(hInfo->samplerate / 2) : FindAdtsSRIndex(hInfo->samplerate);
+ int skip = (old_format) ? 8 : 7;
+ int framesize = skip + hInfo->bytesconsumed;
+
+ if (hInfo->header_type == ADTS) {
+ framesize -= skip;
+ }
+
+ *dataSize = 7;
+
+ data = malloc(*dataSize * sizeof(unsigned char));
+ memset(data, 0, *dataSize * sizeof(unsigned char));
+
+ data[0] += 0xFF; /* 8b: syncword */
+
+ data[1] += 0xF0; /* 4b: syncword */
+ /* 1b: mpeg id = 0 */
+ /* 2b: layer = 0 */
+ data[1] += 1; /* 1b: protection absent */
+
+ data[2] += ((profile << 6) & 0xC0); /* 2b: profile */
+ data[2] += ((sr_index << 2) & 0x3C); /* 4b: sampling_frequency_index */
+ /* 1b: private = 0 */
+ data[2] += ((hInfo->channels >> 2) & 0x1); /* 1b: channel_configuration */
+
+ data[3] += ((hInfo->channels << 6) & 0xC0); /* 2b: channel_configuration */
+ /* 1b: original */
+ /* 1b: home */
+ /* 1b: copyright_id */
+ /* 1b: copyright_id_start */
+ data[3] += ((framesize >> 11) & 0x3); /* 2b: aac_frame_length */
+
+ data[4] += ((framesize >> 3) & 0xFF); /* 8b: aac_frame_length */
+
+ data[5] += ((framesize << 5) & 0xE0); /* 3b: aac_frame_length */
+ data[5] += ((0x7FF >> 6) & 0x1F); /* 5b: adts_buffer_fullness */
+
+ data[6] += ((0x7FF << 2) & 0x3F); /* 6b: adts_buffer_fullness */
+ /* 2b: num_raw_data_blocks */
+
+ return data;
+}
+
+static unsigned get_frame_size(FaadContext *gFaadCxt)
+{
+ int i;
+ unsigned sum = 0;
+ unsigned valid_his_num = 0;
+ for (i = 0; i < FRAME_RECORD_NUM; i++) {
+ if (gFaadCxt->frame_length_his[i] > 0) {
+ valid_his_num ++;
+ sum += gFaadCxt->frame_length_his[i];
+ }
+ }
+
+ if (valid_his_num == 0) {
+ return 2048;
+ }
+
+ return sum / valid_his_num;
+}
+static void store_frame_size(FaadContext *gFaadCxt, int lastFrameLen)
+{
+ /* record the frame length into the history buffer */
+ int i = 0;
+ for (i = 0; i < FRAME_RECORD_NUM - 1; i++) {
+ gFaadCxt->frame_length_his[i] = gFaadCxt->frame_length_his[i + 1];
+ }
+ gFaadCxt->frame_length_his[FRAME_RECORD_NUM - 1] = lastFrameLen;
+}
+
+static int AACFindADTSSyncWord(unsigned char *buf, int nBytes)
+{
+ int i;
+ for (i = 0; i < nBytes - 1; i++) {
+ if (((buf[i + 0] & 0xff) == 0xff) && ((buf[i + 1] & 0xf6) == 0xf0)) {
+ break;
+ }
+ }
+ return i;
+}
+//check two latm frames sync header
+static int AACFindLATMSyncWord(unsigned char *buffer, int nBytes)
+{
+ int i;
+ int i_frame_size = 0;
+ for (i = 0; i < nBytes - 2; i++) {
+ if (buffer[i] == 0x56 && (buffer[i + 1] & 0xe0) == 0xe0) {
+ i_frame_size = ((buffer[i + 1] & 0x1f) << 8) + buffer[i + 2];
+ if (i_frame_size > 4608) {
+ audio_codec_print("i_frame_size exceed 4608 ,%d \n", i_frame_size);
+ }
+ if (i_frame_size > 0 && i_frame_size < 4608) {
+ break;
+ }
+ }
+ }
+ return i;
+}
+int audio_dec_init(
+#ifndef WIN32
+ audio_decoder_operations_t *adec_ops
+#endif
+)
+{
+ //audio_codec_print("[%s]BuildDate--%s BuildTime--%s", __FUNCTION__, __DATE__, __TIME__);
+ FaadContext *gFaadCxt = NULL;
+ adec_ops->pdecoder = calloc(1, sizeof(FaadContext));
+ if (!adec_ops->pdecoder) {
+ audio_codec_print("malloc for decoder instance failed\n");
+ return -1;
+ }
+ gFaadCxt = (FaadContext*)adec_ops->pdecoder;
+ memset(gFaadCxt, 0, sizeof(FaadContext));
+ adec_ops->nInBufSize = AAC_INPUTBUF_SIZE; //4608 bytes input buffer size
+ adec_ops->nOutBufSize = 64 * 1024; //3 * adec_ops->channels * adec_ops->samplerate * 16/8; // 3s
+ gFaadCxt->gChannels = adec_ops->channels;
+ gFaadCxt->gSampleRate = adec_ops->samplerate;
+ gFaadCxt->init_flag = 0;
+ gFaadCxt->header_type = 1; //default adts
+ return 0;
+}
+static int audio_decoder_init(
+#ifndef WIN32
+ audio_decoder_operations_t *adec_ops,
+#endif
+ char *outbuf, int *outlen, char *inbuf, int inlen, long *inbuf_consumed)
+{
+ unsigned long samplerate;
+ unsigned char channels;
+ int ret;
+ NeAACDecConfigurationPtr config = NULL;
+ char *in_buf;
+ int inbuf_size;
+ in_buf = inbuf;
+ inbuf_size = inlen;
+ int nReadLen = 0;
+ FaadContext *gFaadCxt = (FaadContext*)adec_ops->pdecoder;
+ int islatm = 0;
+ if (!in_buf || !inbuf_size || !outbuf) {
+ audio_codec_print(" input/output buffer null or input len is 0 \n");
+ }
+retry:
+ //fixed to LATM aac frame header sync to speed up seek speed
+#if 1
+ if (adec_ops->nAudioDecoderType == ACODEC_FMT_AAC_LATM) {
+ islatm = 1;
+ int nSeekNum = AACFindLATMSyncWord(in_buf, inbuf_size);
+ if (nSeekNum == (inbuf_size - 2)) {
+ audio_codec_print("[%s %d]%d bytes data not found latm sync header \n", __FUNCTION__,__LINE__, nSeekNum);
+ } else {
+ audio_codec_print("[%s %d]latm seek sync header cost %d,total %d,left %d \n", __FUNCTION__,__LINE__, nSeekNum, inbuf_size, inbuf_size - nSeekNum);
+ }
+ inbuf_size = inbuf_size - nSeekNum;
+ if (inbuf_size < (get_frame_size(gFaadCxt) + FRAME_SIZE_MARGIN)/*AAC_INPUTBUF_SIZE/2*/) {
+ audio_codec_print("[%s %d]input size %d at least %d ,need more data \n", __FUNCTION__,__LINE__, inbuf_size, (get_frame_size(gFaadCxt) + FRAME_SIZE_MARGIN));
+ *inbuf_consumed = inlen - inbuf_size;
+ return AAC_ERROR_NO_ENOUGH_DATA;
+ }
+ }
+#endif
+ gFaadCxt->hDecoder = NeAACDecOpen();
+ config = NeAACDecGetCurrentConfiguration(gFaadCxt->hDecoder);
+ config->defObjectType = LC;
+ config->outputFormat = FAAD_FMT_16BIT;
+ config->downMatrix = 0x01;
+ config->useOldADTSFormat = 0;
+ //config->dontUpSampleImplicitSBR = 1;
+ NeAACDecSetConfiguration(gFaadCxt->hDecoder, config);
+ int skipbytes=RSYNC_SKIP_BYTES;
+ if ((ret = NeAACDecInit(gFaadCxt->hDecoder, in_buf, inbuf_size, &samplerate, &channels, islatm,&skipbytes)) < 0) {
+ in_buf += skipbytes;
+ inbuf_size -= skipbytes;
+ NeAACDecClose(gFaadCxt->hDecoder);
+ gFaadCxt->hDecoder = NULL;
+ if (inbuf_size < 0) {
+ inbuf_size = 0;
+ }
+ audio_codec_print("init fail,inbuf_size %d \n", inbuf_size);
+
+ if (inbuf_size < (get_frame_size(gFaadCxt) + FRAME_SIZE_MARGIN) || skipbytes == 0) {
+ audio_codec_print("skipbytes/%d inbuf_size/%d get_frame_size()/%d ,need more data \n",skipbytes, inbuf_size, (get_frame_size(gFaadCxt) + FRAME_SIZE_MARGIN));
+ *inbuf_consumed = inlen - inbuf_size;
+ return AAC_ERROR_NO_ENOUGH_DATA;
+ }
+ goto retry;
+ }
+ audio_codec_print("init sucess cost %d\n", ret);
+ in_buf += ret;
+ inbuf_size -= ret;
+ *inbuf_consumed = inlen - inbuf_size;
+ NeAACDecStruct* hDecoder = (NeAACDecStruct*)(gFaadCxt->hDecoder);
+ gFaadCxt->init_flag = 1;
+ gFaadCxt->gChannels = channels;
+ gFaadCxt->gSampleRate = samplerate;
+ audio_codec_print("[%s] Init OK adif_present :%d adts_present:%d latm_present:%d,sr %d,ch %d\n", __FUNCTION__, hDecoder->adif_header_present, hDecoder->adts_header_present, hDecoder->latm_header_present, samplerate, channels);
+ return 0;
+}
+int audio_dec_decode(
+#ifndef WIN32
+ audio_decoder_operations_t *adec_ops,
+#endif
+ char *outbuf, int *outlen, char *inbuf, int inlen)
+{
+ unsigned long samplerate;
+ unsigned char channels;
+ void *sample_buffer;
+ NeAACDecFrameInfo frameInfo;
+ int outmaxlen = 0;
+ char *dec_buf;
+ int dec_bufsize;
+ int inbuf_consumed = 0;
+ int ret = 0;
+ FaadContext *gFaadCxt = (FaadContext*)adec_ops->pdecoder;
+ dec_bufsize = inlen;
+ dec_buf = inbuf;
+ outmaxlen = *outlen ;
+ *outlen = 0;
+ if (!outbuf || !inbuf || !inlen) {
+ audio_codec_print("decoder parameter error,check \n");
+ goto exit;
+ }
+ if (gFaadCxt->init_start_flag == 0) {
+ audio_codec_print("MyFaadDecoder init first in \n");
+ gFaadCxt->starttime = gettime();
+ gFaadCxt->init_start_flag = 1;
+ }
+ if (!gFaadCxt->init_flag) {
+ gFaadCxt->error_count = 0;
+ audio_codec_print("begin audio_decoder_init,buf size %d \n", dec_bufsize);
+ ret = audio_decoder_init(adec_ops, outbuf, outlen, dec_buf, dec_bufsize, &inbuf_consumed);
+ if (ret == AAC_ERROR_NO_ENOUGH_DATA) {
+ audio_codec_print("decoder buf size %d,cost %d byte input data ,but initiation failed.^_^ \n", inlen, inbuf_consumed);
+ dec_bufsize -= inbuf_consumed;
+ goto exit;
+ }
+ gFaadCxt->init_flag = 1;
+ dec_buf += inbuf_consumed;
+ dec_bufsize -= inbuf_consumed;
+ gFaadCxt->init_cost += inbuf_consumed;
+ gFaadCxt->endtime = gettime();
+ audio_codec_print(" MyFaadDecoder decoder init finished total cost %d bytes,consumed time %lld ms \n", gFaadCxt->init_cost, (gFaadCxt->endtime - gFaadCxt->starttime) / 1000);
+ gFaadCxt->init_cost = 0;
+ if (dec_bufsize < 0) {
+ dec_bufsize = 0;
+ }
+ }
+ NeAACDecStruct* hDecoder = (NeAACDecStruct*)(gFaadCxt->hDecoder);
+ //TODO .fix to LATM aac decoder when ffmpeg parser return LATM aac type
+#if 0
+ if (adec_ops->nAudioDecoderType == ACODEC_FMT_AAC_LATM) {
+ hDecoder->latm_header_present = 1;
+ }
+#endif
+ if (hDecoder->adts_header_present) {
+ int nSeekNum = AACFindADTSSyncWord(dec_buf, dec_bufsize);
+ if (nSeekNum == (dec_bufsize - 1)) {
+ audio_codec_print("%d bytes data not found adts sync header \n", nSeekNum);
+ }
+ dec_bufsize = dec_bufsize - nSeekNum;
+ if (dec_bufsize < (get_frame_size(gFaadCxt) + FRAME_SIZE_MARGIN)/*AAC_INPUTBUF_SIZE/2*/) {
+ goto exit;
+ }
+ }
+ if (hDecoder->latm_header_present) {
+ int nSeekNum = AACFindLATMSyncWord(dec_buf, dec_bufsize);
+ if (nSeekNum == (dec_bufsize - 2)) {
+ audio_codec_print("%d bytes data not found latm sync header \n", nSeekNum);
+ }
+ dec_bufsize = dec_bufsize - nSeekNum;
+ if (dec_bufsize < (get_frame_size(gFaadCxt) + FRAME_SIZE_MARGIN)/*AAC_INPUTBUF_SIZE/2*/) {
+ goto exit;
+ }
+ }
+ sample_buffer = NeAACDecDecode(gFaadCxt->hDecoder, &frameInfo, dec_buf, dec_bufsize);
+ dec_bufsize -= frameInfo.bytesconsumed;
+ if (frameInfo.channels < 0 || frameInfo.channels > 8) {
+ audio_codec_print("[%s %d]ERR__Unvalid Nch/%d bytesconsumed/%d error/%d\n",
+ __FUNCTION__,__LINE__,frameInfo.channels,frameInfo.bytesconsumed,frameInfo.error);
+ sample_buffer=NULL;
+ }
+ if (frameInfo.error == 0 && sample_buffer == NULL && hDecoder->latm_header_present) {
+ dec_bufsize -= 3;
+ goto exit;
+ }
+ if ((frameInfo.error == 0) && (frameInfo.samples > 0) && sample_buffer != NULL) {
+ store_frame_size(gFaadCxt, frameInfo.bytesconsumed);
+ gFaadCxt->gSampleRate = frameInfo.samplerate;
+ gFaadCxt->gChannels = frameInfo.channels;
+ //code to mute first 1 s ???
+#define MUTE_S 0.2
+ if (gFaadCxt->muted_samples == 0) {
+ gFaadCxt->muted_samples = gFaadCxt->gSampleRate * gFaadCxt->gChannels * MUTE_S;
+ }
+ if (gFaadCxt->muted_count < gFaadCxt->muted_samples) {
+ memset(sample_buffer, 0, 2 * frameInfo.samples);
+ gFaadCxt->muted_count += frameInfo.samples;
+ }
+ if ((outmaxlen - (*outlen)) >= (2 * frameInfo.samples)) {
+ memcpy(outbuf + (*outlen), sample_buffer, 2 * frameInfo.samples);
+ *outlen += 2 * frameInfo.samples;
+ gFaadCxt->error_count = 0;
+ } else {
+ audio_codec_print("[%s %d]WARNING: no enough space used for pcm!\n", __FUNCTION__, __LINE__);
+ }
+ }
+
+ if (frameInfo.error > 0) { //failed seek to the head
+ if (frameInfo.error != 34 && frameInfo.error != 35) {
+ dec_bufsize -= RSYNC_SKIP_BYTES;
+ audio_codec_print("Error: %s,inlen %d\n", NeAACDecGetErrorMessage(frameInfo.error), inlen);
+ }
+ // sr/ch changed info happened 5 times always,some times error maybe,skip bytes
+ else if (frameInfo.error == 34 && gFaadCxt->error_count > 5) {
+ dec_bufsize -= RSYNC_SKIP_BYTES;
+ audio_codec_print("%s,,inlen %d\n", NeAACDecGetErrorMessage(frameInfo.error), inlen);
+ }
+ gFaadCxt->error_count++;
+ //err 34,means aac profile changed , PS.SBR,LC ....,normally happens when switch audio source
+ if (gFaadCxt->error_count >= ERROR_RESET_COUNT || frameInfo.error == 34) {
+ if (gFaadCxt->hDecoder) {
+ NeAACDecClose(gFaadCxt->hDecoder);
+ gFaadCxt->hDecoder = NULL;
+ }
+ gFaadCxt->init_flag = 0;
+ gFaadCxt->init_start_flag = 0;
+ }
+ }
+exit:
+ if (dec_bufsize < 0) {
+ dec_bufsize = 0;
+ }
+ if (gFaadCxt->init_flag == 0) {
+ gFaadCxt->init_cost += (inlen - dec_bufsize);
+ }
+ return inlen - dec_bufsize;
+}
+
+
+int audio_dec_release(
+#ifndef WIN32
+ audio_decoder_operations_t *adec_ops
+#endif
+)
+{
+ FaadContext *gFaadCxt = (FaadContext*)adec_ops->pdecoder;
+ if (gFaadCxt->hDecoder) {
+ NeAACDecClose(gFaadCxt->hDecoder);
+ }
+ if (adec_ops->pdecoder) {
+ free(adec_ops->pdecoder);
+ adec_ops->pdecoder = NULL;
+ }
+ return 0;
+}
+#ifndef WIN32
+int audio_dec_getinfo(audio_decoder_operations_t *adec_ops, void *pAudioInfo)
+{
+ FaadContext *gFaadCxt = (FaadContext*)adec_ops->pdecoder;
+ NeAACDecStruct* hDecoder = (NeAACDecStruct*)gFaadCxt->hDecoder;
+ adec_ops->NchOriginal = hDecoder->fr_channels;
+ ((AudioInfo *)pAudioInfo)->channels = gFaadCxt->gChannels;
+ ((AudioInfo *)pAudioInfo)->samplerate = gFaadCxt->gSampleRate;
+ return 0;
+}
+#endif
+
+
+
+
diff --git a/audio_codec/libfaad/libaacdec.h b/audio_codec/libfaad/libaacdec.h
new file mode 100644
index 0000000..69d6cb0
--- a/dev/null
+++ b/audio_codec/libfaad/libaacdec.h
@@ -0,0 +1,64 @@
+#ifndef _LIBAACDEC_H_
+#define _LIBAACDEC_H_
+
+//header file
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <getopt.h>
+#include <pthread.h>
+
+// ffmpeg headers
+#include <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+
+#include "neaacdec.h"
+//#include "../../amadec/adec_write.h"
+#include "../../amadec/adec-armdec-mgt.h"
+
+
+#define ACODEC_FMT_NULL -1
+#define ACODEC_FMT_MPEG 0
+#define ACODEC_FMT_PCM_S16LE 1
+#define ACODEC_FMT_AAC 2
+#define ACODEC_FMT_AC3 3
+#define ACODEC_FMT_ALAW 4
+#define ACODEC_FMT_MULAW 5
+#define ACODEC_FMT_DTS 6
+#define ACODEC_FMT_PCM_S16BE 7
+#define ACODEC_FMT_FLAC 8
+#define ACODEC_FMT_COOK 9
+#define ACODEC_FMT_PCM_U8 10
+#define ACODEC_FMT_ADPCM 11
+#define ACODEC_FMT_AMR 12
+#define ACODEC_FMT_RAAC 13
+#define ACODEC_FMT_WMA 14
+#define ACODEC_FMT_WMAPRO 15
+#define ACODEC_FMT_PCM_BLURAY 16
+#define ACODEC_FMT_ALAC 17
+#define ACODEC_FMT_VORBIS 18
+#define ACODEC_FMT_AAC_LATM 19
+#define ACODEC_FMT_APE 20
+#define ACODEC_FMT_EAC3 21
+#define ACODEC_FMT_WIFIDISPLAY 22
+//#include <mp4ff.h>
+//int main(int argc, char *argv[]);
+
+//extern audio_decoder_operations_t AudioAacDecoder;
+int audio_dec_init(audio_decoder_operations_t *adec_ops);
+int audio_dec_decode(audio_decoder_operations_t *adec_ops, char *outbuf, int *outlen, char *inbuf, int inlen);
+int audio_dec_release(audio_decoder_operations_t *adec_ops);
+int audio_dec_getinfo(audio_decoder_operations_t *adec_ops, void *pAudioInfo);
+//void libaacdec(void);
+#endif
+
+
diff --git a/audio_codec/libfaad/libfaad2.def b/audio_codec/libfaad/libfaad2.def
new file mode 100755
index 0000000..6ae934d
--- a/dev/null
+++ b/audio_codec/libfaad/libfaad2.def
@@ -0,0 +1,14 @@
+LIBRARY libfaad2.dll
+EXPORTS
+;
+; libfaad2 exports
+;
+NeAACDecOpen @1
+NeAACDecGetCurrentConfiguration @2
+NeAACDecSetConfiguration @3
+NeAACDecInit @4
+NeAACDecInit2 @5
+NeAACDecDecode @6
+NeAACDecClose @7
+NeAACDecGetErrorMessage @8
+NeAACDecAudioSpecificConfig @9
diff --git a/audio_codec/libfaad/lt_predict.c b/audio_codec/libfaad/lt_predict.c
new file mode 100644
index 0000000..ed9d5ea
--- a/dev/null
+++ b/audio_codec/libfaad/lt_predict.c
@@ -0,0 +1,205 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: lt_predict.c,v 1.27 2007/11/01 12:33:31 menno Exp $
+**/
+
+
+#include "common.h"
+#include "structs.h"
+
+#ifdef LTP_DEC
+
+#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
+ ) {
+ return 1;
+ }
+#endif
+
+ return 0;
+}
+
+ALIGN static const real_t codebook[8] = {
+ 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)
+};
+
+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;
+ ALIGN real_t x_est[2048];
+ ALIGN real_t X_est[2048];
+
+ 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 = min(ics->swb_offset[sfb + 1], ics->swb_offset_max);
+
+ 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/audio_codec/libfaad/lt_predict.h b/audio_codec/libfaad/lt_predict.h
new file mode 100644
index 0000000..30e392c
--- a/dev/null
+++ b/audio_codec/libfaad/lt_predict.h
@@ -0,0 +1,66 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: lt_predict.h,v 1.20 2007/11/01 12:33:31 menno Exp $
+**/
+
+#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/audio_codec/libfaad/mdct.c b/audio_codec/libfaad/mdct.c
new file mode 100644
index 0000000..71273da
--- a/dev/null
+++ b/audio_codec/libfaad/mdct.c
@@ -0,0 +1,307 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: mdct.c,v 1.47 2007/11/01 12:33:31 menno Exp $
+**/
+
+/*
+ * Fast (I)MDCT Implementation using (I)FFT ((Inverse) Fast Fourier Transform)
+ * and consists of three steps: pre-(I)FFT complex multiplication, complex
+ * (I)FFT, post-(I)FFT complex multiplication,
+ *
+ * As described in:
+ * P. Duhamel, Y. Mahieux, and J.P. Petit, "A Fast Algorithm for the
+ * Implementation of Filter Banks Based on 'Time Domain Aliasing
+ * Cancellation’," IEEE Proc. on ICASSP‘91, 1991, pp. 2209-2212.
+ *
+ *
+ * As of April 6th 2002 completely rewritten.
+ * This (I)MDCT can now be used for any data size n, where n is divisible by 8.
+ *
+ */
+#include <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+
+#ifdef _WIN32_WCE
+#define assert(x)
+#else
+#include <assert.h>
+#endif
+
+#include "cfft.h"
+#include "mdct.h"
+#include "mdct_tab.h"
+
+
+mdct_info *faad_mdct_init(uint16_t N)
+{
+ mdct_info *mdct = (mdct_info*)faad_malloc(sizeof(mdct_info));
+
+ assert(N % 8 == 0);
+
+ mdct->N = N;
+
+ /* NOTE: For "small framelengths" in FIXED_POINT the coefficients need to be
+ * scaled by sqrt("(nearest power of 2) > N" / N) */
+
+ /* RE(mdct->sincos[k]) = scale*(real_t)(cos(2.0*M_PI*(k+1./8.) / (real_t)N));
+ * IM(mdct->sincos[k]) = scale*(real_t)(sin(2.0*M_PI*(k+1./8.) / (real_t)N)); */
+ /* scale is 1 for fixed point, sqrt(N) for floating point */
+ switch (N) {
+ case 2048:
+ mdct->sincos = (complex_t*)mdct_tab_2048;
+ break;
+ case 256:
+ mdct->sincos = (complex_t*)mdct_tab_256;
+ break;
+#ifdef LD_DEC
+ case 1024:
+ mdct->sincos = (complex_t*)mdct_tab_1024;
+ break;
+#endif
+#ifdef ALLOW_SMALL_FRAMELENGTH
+ case 1920:
+ mdct->sincos = (complex_t*)mdct_tab_1920;
+ break;
+ case 240:
+ mdct->sincos = (complex_t*)mdct_tab_240;
+ break;
+#ifdef LD_DEC
+ case 960:
+ mdct->sincos = (complex_t*)mdct_tab_960;
+ break;
+#endif
+#endif
+#ifdef SSR_DEC
+ case 512:
+ mdct->sincos = (complex_t*)mdct_tab_512;
+ break;
+ case 64:
+ mdct->sincos = (complex_t*)mdct_tab_64;
+ break;
+#endif
+ }
+
+ /* initialise fft */
+ mdct->cfft = cffti(N / 4);
+
+#ifdef PROFILE
+ mdct->cycles = 0;
+ mdct->fft_cycles = 0;
+#endif
+
+ return mdct;
+}
+
+void faad_mdct_end(mdct_info *mdct)
+{
+ if (mdct != NULL) {
+#ifdef PROFILE
+ printf("MDCT[%.4d]: %I64d cycles\n", mdct->N, mdct->cycles);
+ printf("CFFT[%.4d]: %I64d cycles\n", mdct->N / 4, mdct->fft_cycles);
+#endif
+
+ cfftu(mdct->cfft);
+
+ faad_free(mdct);
+ }
+}
+
+void faad_imdct(mdct_info *mdct, real_t *X_in, real_t *X_out)
+{
+ uint16_t k;
+
+ complex_t x;
+#ifdef ALLOW_SMALL_FRAMELENGTH
+#ifdef FIXED_POINT
+ real_t scale, b_scale = 0;
+#endif
+#endif
+ ALIGN complex_t Z1[512];
+ complex_t *sincos = mdct->sincos;
+
+ uint16_t N = mdct->N;
+ uint16_t N2 = N >> 1;
+ uint16_t N4 = N >> 2;
+ uint16_t N8 = N >> 3;
+
+#ifdef PROFILE
+ int64_t count1, count2 = faad_get_ts();
+#endif
+
+#ifdef ALLOW_SMALL_FRAMELENGTH
+#ifdef FIXED_POINT
+ /* detect non-power of 2 */
+ if (N & (N - 1)) {
+ /* adjust scale for non-power of 2 MDCT */
+ /* 2048/1920 */
+ b_scale = 1;
+ scale = COEF_CONST(1.0666666666666667);
+ }
+#endif
+#endif
+
+ /* pre-IFFT complex multiplication */
+ for (k = 0; k < N4; k++) {
+ ComplexMult(&IM(Z1[k]), &RE(Z1[k]),
+ X_in[2 * k], X_in[N2 - 1 - 2 * k], RE(sincos[k]), IM(sincos[k]));
+ }
+
+#ifdef PROFILE
+ count1 = faad_get_ts();
+#endif
+
+ /* complex IFFT, any non-scaling FFT can be used here */
+ cfftb(mdct->cfft, Z1);
+
+#ifdef PROFILE
+ count1 = faad_get_ts() - count1;
+#endif
+
+ /* post-IFFT complex multiplication */
+ for (k = 0; k < N4; k++) {
+ RE(x) = RE(Z1[k]);
+ IM(x) = IM(Z1[k]);
+ ComplexMult(&IM(Z1[k]), &RE(Z1[k]),
+ IM(x), RE(x), RE(sincos[k]), IM(sincos[k]));
+
+#ifdef ALLOW_SMALL_FRAMELENGTH
+#ifdef FIXED_POINT
+ /* non-power of 2 MDCT scaling */
+ if (b_scale) {
+ RE(Z1[k]) = MUL_C(RE(Z1[k]), scale);
+ IM(Z1[k]) = MUL_C(IM(Z1[k]), scale);
+ }
+#endif
+#endif
+ }
+
+ /* reordering */
+ for (k = 0; k < N8; k += 2) {
+ X_out[ 2 * k] = IM(Z1[N8 + k]);
+ X_out[ 2 + 2 * k] = IM(Z1[N8 + 1 + k]);
+
+ X_out[ 1 + 2 * k] = -RE(Z1[N8 - 1 - k]);
+ X_out[ 3 + 2 * k] = -RE(Z1[N8 - 2 - k]);
+
+ X_out[N4 + 2 * k] = RE(Z1[ k]);
+ X_out[N4 + + 2 + 2 * k] = RE(Z1[ 1 + k]);
+
+ X_out[N4 + 1 + 2 * k] = -IM(Z1[N4 - 1 - k]);
+ X_out[N4 + 3 + 2 * k] = -IM(Z1[N4 - 2 - k]);
+
+ X_out[N2 + 2 * k] = RE(Z1[N8 + k]);
+ X_out[N2 + + 2 + 2 * k] = RE(Z1[N8 + 1 + k]);
+
+ X_out[N2 + 1 + 2 * k] = -IM(Z1[N8 - 1 - k]);
+ X_out[N2 + 3 + 2 * k] = -IM(Z1[N8 - 2 - k]);
+
+ X_out[N2 + N4 + 2 * k] = -IM(Z1[ k]);
+ X_out[N2 + N4 + 2 + 2 * k] = -IM(Z1[ 1 + k]);
+
+ X_out[N2 + N4 + 1 + 2 * k] = RE(Z1[N4 - 1 - k]);
+ X_out[N2 + N4 + 3 + 2 * k] = RE(Z1[N4 - 2 - k]);
+ }
+
+#ifdef PROFILE
+ count2 = faad_get_ts() - count2;
+ mdct->fft_cycles += count1;
+ mdct->cycles += (count2 - count1);
+#endif
+}
+
+#ifdef LTP_DEC
+void faad_mdct(mdct_info *mdct, real_t *X_in, real_t *X_out)
+{
+ uint16_t k;
+
+ complex_t x;
+ ALIGN complex_t Z1[512];
+ complex_t *sincos = mdct->sincos;
+
+ uint16_t N = mdct->N;
+ uint16_t N2 = N >> 1;
+ uint16_t N4 = N >> 2;
+ uint16_t N8 = N >> 3;
+
+#ifndef FIXED_POINT
+ real_t scale = REAL_CONST(N);
+#else
+ real_t scale = REAL_CONST(4.0 / N);
+#endif
+
+#ifdef ALLOW_SMALL_FRAMELENGTH
+#ifdef FIXED_POINT
+ /* detect non-power of 2 */
+ if (N & (N - 1)) {
+ /* adjust scale for non-power of 2 MDCT */
+ /* *= sqrt(2048/1920) */
+ scale = MUL_C(scale, COEF_CONST(1.0327955589886444));
+ }
+#endif
+#endif
+
+ /* pre-FFT complex multiplication */
+ for (k = 0; k < N8; k++) {
+ uint16_t n = k << 1;
+ RE(x) = X_in[N - N4 - 1 - n] + X_in[N - N4 + n];
+ IM(x) = X_in[ N4 + n] - X_in[ N4 - 1 - n];
+
+ ComplexMult(&RE(Z1[k]), &IM(Z1[k]),
+ RE(x), IM(x), RE(sincos[k]), IM(sincos[k]));
+
+ RE(Z1[k]) = MUL_R(RE(Z1[k]), scale);
+ IM(Z1[k]) = MUL_R(IM(Z1[k]), scale);
+
+ RE(x) = X_in[N2 - 1 - n] - X_in[ n];
+ IM(x) = X_in[N2 + n] + X_in[N - 1 - n];
+
+ ComplexMult(&RE(Z1[k + N8]), &IM(Z1[k + N8]),
+ RE(x), IM(x), RE(sincos[k + N8]), IM(sincos[k + N8]));
+
+ RE(Z1[k + N8]) = MUL_R(RE(Z1[k + N8]), scale);
+ IM(Z1[k + N8]) = MUL_R(IM(Z1[k + N8]), scale);
+ }
+
+ /* complex FFT, any non-scaling FFT can be used here */
+ cfftf(mdct->cfft, Z1);
+
+ /* post-FFT complex multiplication */
+ for (k = 0; k < N4; k++) {
+ uint16_t n = k << 1;
+ ComplexMult(&RE(x), &IM(x),
+ RE(Z1[k]), IM(Z1[k]), RE(sincos[k]), IM(sincos[k]));
+
+ X_out[ n] = -RE(x);
+ X_out[N2 - 1 - n] = IM(x);
+ X_out[N2 + n] = -IM(x);
+ X_out[N - 1 - n] = RE(x);
+ }
+}
+#endif
diff --git a/audio_codec/libfaad/mdct.h b/audio_codec/libfaad/mdct.h
new file mode 100644
index 0000000..70aa910
--- a/dev/null
+++ b/audio_codec/libfaad/mdct.h
@@ -0,0 +1,48 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: mdct.h,v 1.30 2007/11/01 12:33:31 menno Exp $
+**/
+
+#ifndef __MDCT_H__
+#define __MDCT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+ mdct_info *faad_mdct_init(uint16_t N);
+ void faad_mdct_end(mdct_info *mdct);
+ void faad_imdct(mdct_info *mdct, real_t *X_in, real_t *X_out);
+ void faad_mdct(mdct_info *mdct, real_t *X_in, real_t *X_out);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/audio_codec/libfaad/mdct_tab.h b/audio_codec/libfaad/mdct_tab.h
new file mode 100644
index 0000000..de5a9d5
--- a/dev/null
+++ b/audio_codec/libfaad/mdct_tab.h
@@ -0,0 +1,3639 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: mdct_tab.h,v 1.7 2007/11/01 12:33:32 menno Exp $
+**/
+
+#ifndef __MDCT_TAB_H__
+#define __MDCT_TAB_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef FIXED_POINT
+
+ /* 256 (N/4) complex twiddle factors */
+ ALIGN static const complex_t mdct_tab_2048[] = {
+ { FRAC_CONST(0.999999926465718), FRAC_CONST(0.000383495187571) },
+ { FRAC_CONST(0.999994043728986), FRAC_CONST(0.003451449920136) },
+ { FRAC_CONST(0.999978748667469), FRAC_CONST(0.006519372166339) },
+ { FRAC_CONST(0.999954041425130), FRAC_CONST(0.009587233049729) },
+ { FRAC_CONST(0.999919922234523), FRAC_CONST(0.012655003694430) },
+ { FRAC_CONST(0.999876391416790), FRAC_CONST(0.015722655225417) },
+ { FRAC_CONST(0.999823449381662), FRAC_CONST(0.018790158768785) },
+ { FRAC_CONST(0.999761096627447), FRAC_CONST(0.021857485452022) },
+ { FRAC_CONST(0.999689333741034), FRAC_CONST(0.024924606404281) },
+ { FRAC_CONST(0.999608161397882), FRAC_CONST(0.027991492756653) },
+ { FRAC_CONST(0.999517580362017), FRAC_CONST(0.031058115642435) },
+ { FRAC_CONST(0.999417591486022), FRAC_CONST(0.034124446197403) },
+ { FRAC_CONST(0.999308195711029), FRAC_CONST(0.037190455560088) },
+ { FRAC_CONST(0.999189394066715), FRAC_CONST(0.040256114872041) },
+ { FRAC_CONST(0.999061187671285), FRAC_CONST(0.043321395278110) },
+ { FRAC_CONST(0.998923577731466), FRAC_CONST(0.046386267926707) },
+ { FRAC_CONST(0.998776565542496), FRAC_CONST(0.049450703970085) },
+ { FRAC_CONST(0.998620152488109), FRAC_CONST(0.052514674564603) },
+ { FRAC_CONST(0.998454340040525), FRAC_CONST(0.055578150871005) },
+ { FRAC_CONST(0.998279129760433), FRAC_CONST(0.058641104054683) },
+ { FRAC_CONST(0.998094523296980), FRAC_CONST(0.061703505285957) },
+ { FRAC_CONST(0.997900522387752), FRAC_CONST(0.064765325740340) },
+ { FRAC_CONST(0.997697128858759), FRAC_CONST(0.067826536598811) },
+ { FRAC_CONST(0.997484344624418), FRAC_CONST(0.070887109048088) },
+ { FRAC_CONST(0.997262171687536), FRAC_CONST(0.073947014280897) },
+ { FRAC_CONST(0.997030612139289), FRAC_CONST(0.077006223496246) },
+ { FRAC_CONST(0.996789668159205), FRAC_CONST(0.080064707899691) },
+ { FRAC_CONST(0.996539342015138), FRAC_CONST(0.083122438703613) },
+ { FRAC_CONST(0.996279636063255), FRAC_CONST(0.086179387127485) },
+ { FRAC_CONST(0.996010552748006), FRAC_CONST(0.089235524398144) },
+ { FRAC_CONST(0.995732094602106), FRAC_CONST(0.092290821750062) },
+ { FRAC_CONST(0.995444264246510), FRAC_CONST(0.095345250425618) },
+ { FRAC_CONST(0.995147064390386), FRAC_CONST(0.098398781675364) },
+ { FRAC_CONST(0.994840497831093), FRAC_CONST(0.101451386758302) },
+ { FRAC_CONST(0.994524567454152), FRAC_CONST(0.104503036942151) },
+ { FRAC_CONST(0.994199276233219), FRAC_CONST(0.107553703503616) },
+ { FRAC_CONST(0.993864627230060), FRAC_CONST(0.110603357728662) },
+ { FRAC_CONST(0.993520623594518), FRAC_CONST(0.113651970912782) },
+ { FRAC_CONST(0.993167268564487), FRAC_CONST(0.116699514361268) },
+ { FRAC_CONST(0.992804565465879), FRAC_CONST(0.119745959389480) },
+ { FRAC_CONST(0.992432517712594), FRAC_CONST(0.122791277323117) },
+ { FRAC_CONST(0.992051128806486), FRAC_CONST(0.125835439498487) },
+ { FRAC_CONST(0.991660402337333), FRAC_CONST(0.128878417262777) },
+ { FRAC_CONST(0.991260341982802), FRAC_CONST(0.131920181974320) },
+ { FRAC_CONST(0.990850951508414), FRAC_CONST(0.134960705002869) },
+ { FRAC_CONST(0.990432234767506), FRAC_CONST(0.137999957729863) },
+ { FRAC_CONST(0.990004195701201), FRAC_CONST(0.141037911548698) },
+ { FRAC_CONST(0.989566838338365), FRAC_CONST(0.144074537864995) },
+ { FRAC_CONST(0.989120166795573), FRAC_CONST(0.147109808096872) },
+ { FRAC_CONST(0.988664185277066), FRAC_CONST(0.150143693675208) },
+ { FRAC_CONST(0.988198898074718), FRAC_CONST(0.153176166043918) },
+ { FRAC_CONST(0.987724309567987), FRAC_CONST(0.156207196660216) },
+ { FRAC_CONST(0.987240424223882), FRAC_CONST(0.159236756994888) },
+ { FRAC_CONST(0.986747246596917), FRAC_CONST(0.162264818532558) },
+ { FRAC_CONST(0.986244781329065), FRAC_CONST(0.165291352771958) },
+ { FRAC_CONST(0.985733033149723), FRAC_CONST(0.168316331226195) },
+ { FRAC_CONST(0.985212006875659), FRAC_CONST(0.171339725423019) },
+ { FRAC_CONST(0.984681707410971), FRAC_CONST(0.174361506905094) },
+ { FRAC_CONST(0.984142139747039), FRAC_CONST(0.177381647230260) },
+ { FRAC_CONST(0.983593308962479), FRAC_CONST(0.180400117971807) },
+ { FRAC_CONST(0.983035220223096), FRAC_CONST(0.183416890718739) },
+ { FRAC_CONST(0.982467878781833), FRAC_CONST(0.186431937076042) },
+ { FRAC_CONST(0.981891289978725), FRAC_CONST(0.189445228664950) },
+ { FRAC_CONST(0.981305459240845), FRAC_CONST(0.192456737123217) },
+ { FRAC_CONST(0.980710392082254), FRAC_CONST(0.195466434105377) },
+ { FRAC_CONST(0.980106094103952), FRAC_CONST(0.198474291283016) },
+ { FRAC_CONST(0.979492570993821), FRAC_CONST(0.201480280345038) },
+ { FRAC_CONST(0.978869828526574), FRAC_CONST(0.204484372997927) },
+ { FRAC_CONST(0.978237872563701), FRAC_CONST(0.207486540966021) },
+ { FRAC_CONST(0.977596709053412), FRAC_CONST(0.210486755991770) },
+ { FRAC_CONST(0.976946344030582), FRAC_CONST(0.213484989836008) },
+ { FRAC_CONST(0.976286783616694), FRAC_CONST(0.216481214278217) },
+ { FRAC_CONST(0.975618034019782), FRAC_CONST(0.219475401116790) },
+ { FRAC_CONST(0.974940101534372), FRAC_CONST(0.222467522169302) },
+ { FRAC_CONST(0.974252992541423), FRAC_CONST(0.225457549272769) },
+ { FRAC_CONST(0.973556713508266), FRAC_CONST(0.228445454283916) },
+ { FRAC_CONST(0.972851270988544), FRAC_CONST(0.231431209079446) },
+ { FRAC_CONST(0.972136671622152), FRAC_CONST(0.234414785556295) },
+ { FRAC_CONST(0.971412922135171), FRAC_CONST(0.237396155631907) },
+ { FRAC_CONST(0.970680029339806), FRAC_CONST(0.240375291244489) },
+ { FRAC_CONST(0.969938000134324), FRAC_CONST(0.243352164353285) },
+ { FRAC_CONST(0.969186841502986), FRAC_CONST(0.246326746938829) },
+ { FRAC_CONST(0.968426560515983), FRAC_CONST(0.249299011003218) },
+ { FRAC_CONST(0.967657164329370), FRAC_CONST(0.252268928570371) },
+ { FRAC_CONST(0.966878660184996), FRAC_CONST(0.255236471686292) },
+ { FRAC_CONST(0.966091055410439), FRAC_CONST(0.258201612419335) },
+ { FRAC_CONST(0.965294357418935), FRAC_CONST(0.261164322860466) },
+ { FRAC_CONST(0.964488573709308), FRAC_CONST(0.264124575123528) },
+ { FRAC_CONST(0.963673711865903), FRAC_CONST(0.267082341345496) },
+ { FRAC_CONST(0.962849779558509), FRAC_CONST(0.270037593686751) },
+ { FRAC_CONST(0.962016784542291), FRAC_CONST(0.272990304331330) },
+ { FRAC_CONST(0.961174734657714), FRAC_CONST(0.275940445487197) },
+ { FRAC_CONST(0.960323637830474), FRAC_CONST(0.278887989386500) },
+ { FRAC_CONST(0.959463502071418), FRAC_CONST(0.281832908285833) },
+ { FRAC_CONST(0.958594335476470), FRAC_CONST(0.284775174466498) },
+ { FRAC_CONST(0.957716146226559), FRAC_CONST(0.287714760234765) },
+ { FRAC_CONST(0.956828942587535), FRAC_CONST(0.290651637922133) },
+ { FRAC_CONST(0.955932732910098), FRAC_CONST(0.293585779885591) },
+ { FRAC_CONST(0.955027525629714), FRAC_CONST(0.296517158507877) },
+ { FRAC_CONST(0.954113329266539), FRAC_CONST(0.299445746197740) },
+ { FRAC_CONST(0.953190152425337), FRAC_CONST(0.302371515390196) },
+ { FRAC_CONST(0.952258003795400), FRAC_CONST(0.305294438546792) },
+ { FRAC_CONST(0.951316892150466), FRAC_CONST(0.308214488155861) },
+ { FRAC_CONST(0.950366826348636), FRAC_CONST(0.311131636732785) },
+ { FRAC_CONST(0.949407815332292), FRAC_CONST(0.314045856820251) },
+ { FRAC_CONST(0.948439868128010), FRAC_CONST(0.316957120988508) },
+ { FRAC_CONST(0.947462993846478), FRAC_CONST(0.319865401835631) },
+ { FRAC_CONST(0.946477201682409), FRAC_CONST(0.322770671987771) },
+ { FRAC_CONST(0.945482500914454), FRAC_CONST(0.325672904099420) },
+ { FRAC_CONST(0.944478900905116), FRAC_CONST(0.328572070853664) },
+ { FRAC_CONST(0.943466411100659), FRAC_CONST(0.331468144962441) },
+ { FRAC_CONST(0.942445041031025), FRAC_CONST(0.334361099166799) },
+ { FRAC_CONST(0.941414800309736), FRAC_CONST(0.337250906237151) },
+ { FRAC_CONST(0.940375698633812), FRAC_CONST(0.340137538973532) },
+ { FRAC_CONST(0.939327745783671), FRAC_CONST(0.343020970205856) },
+ { FRAC_CONST(0.938270951623047), FRAC_CONST(0.345901172794169) },
+ { FRAC_CONST(0.937205326098888), FRAC_CONST(0.348778119628908) },
+ { FRAC_CONST(0.936130879241267), FRAC_CONST(0.351651783631155) },
+ { FRAC_CONST(0.935047621163287), FRAC_CONST(0.354522137752887) },
+ { FRAC_CONST(0.933955562060987), FRAC_CONST(0.357389154977241) },
+ { FRAC_CONST(0.932854712213241), FRAC_CONST(0.360252808318757) },
+ { FRAC_CONST(0.931745081981669), FRAC_CONST(0.363113070823639) },
+ { FRAC_CONST(0.930626681810532), FRAC_CONST(0.365969915570009) },
+ { FRAC_CONST(0.929499522226639), FRAC_CONST(0.368823315668154) },
+ { FRAC_CONST(0.928363613839244), FRAC_CONST(0.371673244260787) },
+ { FRAC_CONST(0.927218967339952), FRAC_CONST(0.374519674523293) },
+ { FRAC_CONST(0.926065593502609), FRAC_CONST(0.377362579663988) },
+ { FRAC_CONST(0.924903503183211), FRAC_CONST(0.380201932924366) },
+ { FRAC_CONST(0.923732707319793), FRAC_CONST(0.383037707579352) },
+ { FRAC_CONST(0.922553216932333), FRAC_CONST(0.385869876937555) },
+ { FRAC_CONST(0.921365043122642), FRAC_CONST(0.388698414341519) },
+ { FRAC_CONST(0.920168197074266), FRAC_CONST(0.391523293167972) },
+ { FRAC_CONST(0.918962690052376), FRAC_CONST(0.394344486828080) },
+ { FRAC_CONST(0.917748533403661), FRAC_CONST(0.397161968767692) },
+ { FRAC_CONST(0.916525738556228), FRAC_CONST(0.399975712467595) },
+ { FRAC_CONST(0.915294317019487), FRAC_CONST(0.402785691443764) },
+ { FRAC_CONST(0.914054280384047), FRAC_CONST(0.405591879247604) },
+ { FRAC_CONST(0.912805640321604), FRAC_CONST(0.408394249466208) },
+ { FRAC_CONST(0.911548408584834), FRAC_CONST(0.411192775722600) },
+ { FRAC_CONST(0.910282597007282), FRAC_CONST(0.413987431675985) },
+ { FRAC_CONST(0.909008217503247), FRAC_CONST(0.416778191021998) },
+ { FRAC_CONST(0.907725282067676), FRAC_CONST(0.419565027492947) },
+ { FRAC_CONST(0.906433802776045), FRAC_CONST(0.422347914858067) },
+ { FRAC_CONST(0.905133791784250), FRAC_CONST(0.425126826923762) },
+ { FRAC_CONST(0.903825261328488), FRAC_CONST(0.427901737533854) },
+ { FRAC_CONST(0.902508223725146), FRAC_CONST(0.430672620569827) },
+ { FRAC_CONST(0.901182691370685), FRAC_CONST(0.433439449951074) },
+ { FRAC_CONST(0.899848676741519), FRAC_CONST(0.436202199635144) },
+ { FRAC_CONST(0.898506192393902), FRAC_CONST(0.438960843617984) },
+ { FRAC_CONST(0.897155250963809), FRAC_CONST(0.441715355934187) },
+ { FRAC_CONST(0.895795865166814), FRAC_CONST(0.444465710657234) },
+ { FRAC_CONST(0.894428047797974), FRAC_CONST(0.447211881899738) },
+ { FRAC_CONST(0.893051811731707), FRAC_CONST(0.449953843813691) },
+ { FRAC_CONST(0.891667169921672), FRAC_CONST(0.452691570590701) },
+ { FRAC_CONST(0.890274135400645), FRAC_CONST(0.455425036462242) },
+ { FRAC_CONST(0.888872721280396), FRAC_CONST(0.458154215699893) },
+ { FRAC_CONST(0.887462940751569), FRAC_CONST(0.460879082615579) },
+ { FRAC_CONST(0.886044807083556), FRAC_CONST(0.463599611561814) },
+ { FRAC_CONST(0.884618333624370), FRAC_CONST(0.466315776931944) },
+ { FRAC_CONST(0.883183533800523), FRAC_CONST(0.469027553160387) },
+ { FRAC_CONST(0.881740421116898), FRAC_CONST(0.471734914722871) },
+ { FRAC_CONST(0.880289009156621), FRAC_CONST(0.474437836136679) },
+ { FRAC_CONST(0.878829311580933), FRAC_CONST(0.477136291960885) },
+ { FRAC_CONST(0.877361342129065), FRAC_CONST(0.479830256796594) },
+ { FRAC_CONST(0.875885114618104), FRAC_CONST(0.482519705287184) },
+ { FRAC_CONST(0.874400642942865), FRAC_CONST(0.485204612118542) },
+ { FRAC_CONST(0.872907941075761), FRAC_CONST(0.487884952019301) },
+ { FRAC_CONST(0.871407023066671), FRAC_CONST(0.490560699761082) },
+ { FRAC_CONST(0.869897903042806), FRAC_CONST(0.493231830158728) },
+ { FRAC_CONST(0.868380595208580), FRAC_CONST(0.495898318070542) },
+ { FRAC_CONST(0.866855113845470), FRAC_CONST(0.498560138398525) },
+ { FRAC_CONST(0.865321473311890), FRAC_CONST(0.501217266088610) },
+ { FRAC_CONST(0.863779688043047), FRAC_CONST(0.503869676130899) },
+ { FRAC_CONST(0.862229772550811), FRAC_CONST(0.506517343559899) },
+ { FRAC_CONST(0.860671741423578), FRAC_CONST(0.509160243454755) },
+ { FRAC_CONST(0.859105609326130), FRAC_CONST(0.511798350939487) },
+ { FRAC_CONST(0.857531390999499), FRAC_CONST(0.514431641183223) },
+ { FRAC_CONST(0.855949101260827), FRAC_CONST(0.517060089400432) },
+ { FRAC_CONST(0.854358755003227), FRAC_CONST(0.519683670851158) },
+ { FRAC_CONST(0.852760367195645), FRAC_CONST(0.522302360841255) },
+ { FRAC_CONST(0.851153952882715), FRAC_CONST(0.524916134722613) },
+ { FRAC_CONST(0.849539527184621), FRAC_CONST(0.527524967893398) },
+ { FRAC_CONST(0.847917105296951), FRAC_CONST(0.530128835798279) },
+ { FRAC_CONST(0.846286702490560), FRAC_CONST(0.532727713928659) },
+ { FRAC_CONST(0.844648334111418), FRAC_CONST(0.535321577822907) },
+ { FRAC_CONST(0.843002015580473), FRAC_CONST(0.537910403066589) },
+ { FRAC_CONST(0.841347762393502), FRAC_CONST(0.540494165292695) },
+ { FRAC_CONST(0.839685590120966), FRAC_CONST(0.543072840181872) },
+ { FRAC_CONST(0.838015514407864), FRAC_CONST(0.545646403462649) },
+ { FRAC_CONST(0.836337550973584), FRAC_CONST(0.548214830911668) },
+ { FRAC_CONST(0.834651715611756), FRAC_CONST(0.550778098353912) },
+ { FRAC_CONST(0.832958024190107), FRAC_CONST(0.553336181662932) },
+ { FRAC_CONST(0.831256492650303), FRAC_CONST(0.555889056761074) },
+ { FRAC_CONST(0.829547137007809), FRAC_CONST(0.558436699619704) },
+ { FRAC_CONST(0.827829973351730), FRAC_CONST(0.560979086259438) },
+ { FRAC_CONST(0.826105017844665), FRAC_CONST(0.563516192750365) },
+ { FRAC_CONST(0.824372286722551), FRAC_CONST(0.566047995212271) },
+ { FRAC_CONST(0.822631796294515), FRAC_CONST(0.568574469814869) },
+ { FRAC_CONST(0.820883562942715), FRAC_CONST(0.571095592778017) },
+ { FRAC_CONST(0.819127603122188), FRAC_CONST(0.573611340371945) },
+ { FRAC_CONST(0.817363933360698), FRAC_CONST(0.576121688917478) },
+ { FRAC_CONST(0.815592570258577), FRAC_CONST(0.578626614786261) },
+ { FRAC_CONST(0.813813530488567), FRAC_CONST(0.581126094400978) },
+ { FRAC_CONST(0.812026830795670), FRAC_CONST(0.583620104235573) },
+ { FRAC_CONST(0.810232487996982), FRAC_CONST(0.586108620815476) },
+ { FRAC_CONST(0.808430518981543), FRAC_CONST(0.588591620717823) },
+ { FRAC_CONST(0.806620940710170), FRAC_CONST(0.591069080571671) },
+ { FRAC_CONST(0.804803770215303), FRAC_CONST(0.593540977058226) },
+ { FRAC_CONST(0.802979024600843), FRAC_CONST(0.596007286911057) },
+ { FRAC_CONST(0.801146721041991), FRAC_CONST(0.598467986916314) },
+ { FRAC_CONST(0.799306876785086), FRAC_CONST(0.600923053912954) },
+ { FRAC_CONST(0.797459509147442), FRAC_CONST(0.603372464792950) },
+ { FRAC_CONST(0.795604635517188), FRAC_CONST(0.605816196501515) },
+ { FRAC_CONST(0.793742273353100), FRAC_CONST(0.608254226037314) },
+ { FRAC_CONST(0.791872440184440), FRAC_CONST(0.610686530452686) },
+ { FRAC_CONST(0.789995153610791), FRAC_CONST(0.613113086853855) },
+ { FRAC_CONST(0.788110431301888), FRAC_CONST(0.615533872401147) },
+ { FRAC_CONST(0.786218290997456), FRAC_CONST(0.617948864309208) },
+ { FRAC_CONST(0.784318750507039), FRAC_CONST(0.620358039847214) },
+ { FRAC_CONST(0.782411827709837), FRAC_CONST(0.622761376339086) },
+ { FRAC_CONST(0.780497540554532), FRAC_CONST(0.625158851163708) },
+ { FRAC_CONST(0.778575907059125), FRAC_CONST(0.627550441755132) },
+ { FRAC_CONST(0.776646945310762), FRAC_CONST(0.629936125602796) },
+ { FRAC_CONST(0.774710673465566), FRAC_CONST(0.632315880251738) },
+ { FRAC_CONST(0.772767109748464), FRAC_CONST(0.634689683302798) },
+ { FRAC_CONST(0.770816272453019), FRAC_CONST(0.637057512412839) },
+ { FRAC_CONST(0.768858179941253), FRAC_CONST(0.639419345294951) },
+ { FRAC_CONST(0.766892850643481), FRAC_CONST(0.641775159718664) },
+ { FRAC_CONST(0.764920303058128), FRAC_CONST(0.644124933510155) },
+ { FRAC_CONST(0.762940555751566), FRAC_CONST(0.646468644552458) },
+ { FRAC_CONST(0.760953627357928), FRAC_CONST(0.648806270785673) },
+ { FRAC_CONST(0.758959536578942), FRAC_CONST(0.651137790207170) },
+ { FRAC_CONST(0.756958302183750), FRAC_CONST(0.653463180871802) },
+ { FRAC_CONST(0.754949943008733), FRAC_CONST(0.655782420892106) },
+ { FRAC_CONST(0.752934477957330), FRAC_CONST(0.658095488438511) },
+ { FRAC_CONST(0.750911925999868), FRAC_CONST(0.660402361739545) },
+ { FRAC_CONST(0.748882306173375), FRAC_CONST(0.662703019082037) },
+ { FRAC_CONST(0.746845637581407), FRAC_CONST(0.664997438811325) },
+ { FRAC_CONST(0.744801939393863), FRAC_CONST(0.667285599331456) },
+ { FRAC_CONST(0.742751230846809), FRAC_CONST(0.669567479105392) },
+ { FRAC_CONST(0.740693531242296), FRAC_CONST(0.671843056655212) },
+ { FRAC_CONST(0.738628859948175), FRAC_CONST(0.674112310562312) },
+ { FRAC_CONST(0.736557236397919), FRAC_CONST(0.676375219467612) },
+ { FRAC_CONST(0.734478680090438), FRAC_CONST(0.678631762071749) },
+ { FRAC_CONST(0.732393210589896), FRAC_CONST(0.680881917135287) },
+ { FRAC_CONST(0.730300847525525), FRAC_CONST(0.683125663478909) },
+ { FRAC_CONST(0.728201610591445), FRAC_CONST(0.685362979983619) },
+ { FRAC_CONST(0.726095519546471), FRAC_CONST(0.687593845590942) },
+ { FRAC_CONST(0.723982594213936), FRAC_CONST(0.689818239303122) },
+ { FRAC_CONST(0.721862854481496), FRAC_CONST(0.692036140183319) },
+ { FRAC_CONST(0.719736320300951), FRAC_CONST(0.694247527355803) },
+ { FRAC_CONST(0.717603011688049), FRAC_CONST(0.696452380006158) },
+ { FRAC_CONST(0.715462948722304), FRAC_CONST(0.698650677381469) },
+ { FRAC_CONST(0.713316151546803), FRAC_CONST(0.700842398790526) },
+ { FRAC_CONST(0.711162640368018), FRAC_CONST(0.703027523604011) },
+ { FRAC_CONST(0.709002435455618), FRAC_CONST(0.705206031254698) },
+ { FRAC_CONST(0.706835557142274), FRAC_CONST(0.707377901237642) },
+ { FRAC_CONST(0.704662025823469), FRAC_CONST(0.709543113110377) },
+ { FRAC_CONST(0.702481861957308), FRAC_CONST(0.711701646493103) },
+ { FRAC_CONST(0.700295086064324), FRAC_CONST(0.713853481068882) },
+ { FRAC_CONST(0.698101718727284), FRAC_CONST(0.715998596583829) },
+ { FRAC_CONST(0.695901780590997), FRAC_CONST(0.718136972847297) },
+ { FRAC_CONST(0.693695292362118), FRAC_CONST(0.720268589732077) },
+ { FRAC_CONST(0.691482274808956), FRAC_CONST(0.722393427174578) },
+ { FRAC_CONST(0.689262748761273), FRAC_CONST(0.724511465175020) },
+ { FRAC_CONST(0.687036735110096), FRAC_CONST(0.726622683797623) },
+ { FRAC_CONST(0.684804254807511), FRAC_CONST(0.728727063170794) },
+ { FRAC_CONST(0.682565328866473), FRAC_CONST(0.730824583487312) },
+ { FRAC_CONST(0.680319978360607), FRAC_CONST(0.732915225004518) },
+ { FRAC_CONST(0.678068224424007), FRAC_CONST(0.734998968044497) },
+ { FRAC_CONST(0.675810088251037), FRAC_CONST(0.737075792994266) },
+ { FRAC_CONST(0.673545591096136), FRAC_CONST(0.739145680305957) },
+ { FRAC_CONST(0.671274754273613), FRAC_CONST(0.741208610497004) },
+ { FRAC_CONST(0.668997599157450), FRAC_CONST(0.743264564150321) },
+ { FRAC_CONST(0.666714147181098), FRAC_CONST(0.745313521914490) },
+ { FRAC_CONST(0.664424419837275), FRAC_CONST(0.747355464503940) },
+ { FRAC_CONST(0.662128438677769), FRAC_CONST(0.749390372699130) },
+ { FRAC_CONST(0.659826225313227), FRAC_CONST(0.751418227346727) },
+ { FRAC_CONST(0.657517801412960), FRAC_CONST(0.753439009359794) },
+ { FRAC_CONST(0.655203188704732), FRAC_CONST(0.755452699717958) },
+ { FRAC_CONST(0.652882408974559), FRAC_CONST(0.757459279467601) },
+ { FRAC_CONST(0.650555484066504), FRAC_CONST(0.759458729722028) },
+ { FRAC_CONST(0.648222435882470), FRAC_CONST(0.761451031661654) },
+ { FRAC_CONST(0.645883286381996), FRAC_CONST(0.763436166534172) },
+ { FRAC_CONST(0.643538057582048), FRAC_CONST(0.765414115654738) },
+ { FRAC_CONST(0.641186771556811), FRAC_CONST(0.767384860406142) },
+ { FRAC_CONST(0.638829450437486), FRAC_CONST(0.769348382238982) },
+ { FRAC_CONST(0.636466116412077), FRAC_CONST(0.771304662671845) },
+ { FRAC_CONST(0.634096791725184), FRAC_CONST(0.773253683291473) },
+ { FRAC_CONST(0.631721498677792), FRAC_CONST(0.775195425752941) },
+ { FRAC_CONST(0.629340259627066), FRAC_CONST(0.777129871779832) },
+ { FRAC_CONST(0.626953096986133), FRAC_CONST(0.779057003164401) },
+ { FRAC_CONST(0.624560033223877), FRAC_CONST(0.780976801767754) },
+ { FRAC_CONST(0.622161090864727), FRAC_CONST(0.782889249520015) },
+ { FRAC_CONST(0.619756292488441), FRAC_CONST(0.784794328420499) },
+ { FRAC_CONST(0.617345660729897), FRAC_CONST(0.786692020537877) },
+ { FRAC_CONST(0.614929218278880), FRAC_CONST(0.788582308010347) },
+ { FRAC_CONST(0.612506987879866), FRAC_CONST(0.790465173045805) },
+ { FRAC_CONST(0.610078992331810), FRAC_CONST(0.792340597922007) },
+ { FRAC_CONST(0.607645254487931), FRAC_CONST(0.794208564986741) },
+ { FRAC_CONST(0.605205797255497), FRAC_CONST(0.796069056657988) },
+ { FRAC_CONST(0.602760643595607), FRAC_CONST(0.797922055424093) },
+ { FRAC_CONST(0.600309816522980), FRAC_CONST(0.799767543843926) },
+ { FRAC_CONST(0.597853339105734), FRAC_CONST(0.801605504547046) },
+ { FRAC_CONST(0.595391234465169), FRAC_CONST(0.803435920233868) },
+ { FRAC_CONST(0.592923525775551), FRAC_CONST(0.805258773675822) },
+ { FRAC_CONST(0.590450236263896), FRAC_CONST(0.807074047715518) },
+ { FRAC_CONST(0.587971389209745), FRAC_CONST(0.808881725266904) },
+ { FRAC_CONST(0.585487007944951), FRAC_CONST(0.810681789315431) },
+ { FRAC_CONST(0.582997115853458), FRAC_CONST(0.812474222918210) },
+ { FRAC_CONST(0.580501736371077), FRAC_CONST(0.814259009204175) },
+ { FRAC_CONST(0.578000892985270), FRAC_CONST(0.816036131374237) },
+ { FRAC_CONST(0.575494609234928), FRAC_CONST(0.817805572701444) },
+ { FRAC_CONST(0.572982908710149), FRAC_CONST(0.819567316531142) },
+ { FRAC_CONST(0.570465815052013), FRAC_CONST(0.821321346281127) },
+ { FRAC_CONST(0.567943351952366), FRAC_CONST(0.823067645441802) },
+ { FRAC_CONST(0.565415543153590), FRAC_CONST(0.824806197576334) },
+ { FRAC_CONST(0.562882412448385), FRAC_CONST(0.826536986320810) },
+ { FRAC_CONST(0.560343983679541), FRAC_CONST(0.828259995384386) },
+ { FRAC_CONST(0.557800280739717), FRAC_CONST(0.829975208549444) },
+ { FRAC_CONST(0.555251327571214), FRAC_CONST(0.831682609671745) },
+ { FRAC_CONST(0.552697148165750), FRAC_CONST(0.833382182680580) },
+ { FRAC_CONST(0.550137766564234), FRAC_CONST(0.835073911578919) },
+ { FRAC_CONST(0.547573206856540), FRAC_CONST(0.836757780443567) },
+ { FRAC_CONST(0.545003493181281), FRAC_CONST(0.838433773425308) },
+ { FRAC_CONST(0.542428649725581), FRAC_CONST(0.840101874749058) },
+ { FRAC_CONST(0.539848700724848), FRAC_CONST(0.841762068714012) },
+ { FRAC_CONST(0.537263670462543), FRAC_CONST(0.843414339693793) },
+ { FRAC_CONST(0.534673583269956), FRAC_CONST(0.845058672136595) },
+ { FRAC_CONST(0.532078463525974), FRAC_CONST(0.846695050565337) },
+ { FRAC_CONST(0.529478335656852), FRAC_CONST(0.848323459577802) },
+ { FRAC_CONST(0.526873224135985), FRAC_CONST(0.849943883846782) },
+ { FRAC_CONST(0.524263153483673), FRAC_CONST(0.851556308120229) },
+ { FRAC_CONST(0.521648148266897), FRAC_CONST(0.853160717221390) },
+ { FRAC_CONST(0.519028233099081), FRAC_CONST(0.854757096048957) },
+ { FRAC_CONST(0.516403432639864), FRAC_CONST(0.856345429577204) },
+ { FRAC_CONST(0.513773771594868), FRAC_CONST(0.857925702856130) },
+ { FRAC_CONST(0.511139274715464), FRAC_CONST(0.859497901011602) },
+ { FRAC_CONST(0.508499966798541), FRAC_CONST(0.861062009245491) },
+ { FRAC_CONST(0.505855872686269), FRAC_CONST(0.862618012835817) },
+ { FRAC_CONST(0.503207017265869), FRAC_CONST(0.864165897136879) },
+ { FRAC_CONST(0.500553425469378), FRAC_CONST(0.865705647579402) },
+ { FRAC_CONST(0.497895122273411), FRAC_CONST(0.867237249670668) },
+ { FRAC_CONST(0.495232132698931), FRAC_CONST(0.868760688994655) },
+ { FRAC_CONST(0.492564481811011), FRAC_CONST(0.870275951212172) },
+ { FRAC_CONST(0.489892194718595), FRAC_CONST(0.871783022060993) },
+ { FRAC_CONST(0.487215296574269), FRAC_CONST(0.873281887355994) },
+ { FRAC_CONST(0.484533812574016), FRAC_CONST(0.874772532989284) },
+ { FRAC_CONST(0.481847767956986), FRAC_CONST(0.876254944930338) },
+ { FRAC_CONST(0.479157188005253), FRAC_CONST(0.877729109226132) },
+ { FRAC_CONST(0.476462098043581), FRAC_CONST(0.879195012001267) },
+ { FRAC_CONST(0.473762523439183), FRAC_CONST(0.880652639458111) },
+ { FRAC_CONST(0.471058489601483), FRAC_CONST(0.882101977876918) },
+ { FRAC_CONST(0.468350021981877), FRAC_CONST(0.883543013615962) },
+ { FRAC_CONST(0.465637146073494), FRAC_CONST(0.884975733111667) },
+ { FRAC_CONST(0.462919887410955), FRAC_CONST(0.886400122878730) },
+ { FRAC_CONST(0.460198271570134), FRAC_CONST(0.887816169510255) },
+ { FRAC_CONST(0.457472324167916), FRAC_CONST(0.889223859677868) },
+ { FRAC_CONST(0.454742070861955), FRAC_CONST(0.890623180131856) },
+ { FRAC_CONST(0.452007537350437), FRAC_CONST(0.892014117701280) },
+ { FRAC_CONST(0.449268749371830), FRAC_CONST(0.893396659294108) },
+ { FRAC_CONST(0.446525732704651), FRAC_CONST(0.894770791897330) },
+ { FRAC_CONST(0.443778513167218), FRAC_CONST(0.896136502577087) },
+ { FRAC_CONST(0.441027116617407), FRAC_CONST(0.897493778478790) },
+ { FRAC_CONST(0.438271568952410), FRAC_CONST(0.898842606827242) },
+ { FRAC_CONST(0.435511896108492), FRAC_CONST(0.900182974926757) },
+ { FRAC_CONST(0.432748124060744), FRAC_CONST(0.901514870161279) },
+ { FRAC_CONST(0.429980278822841), FRAC_CONST(0.902838279994503) },
+ { FRAC_CONST(0.427208386446796), FRAC_CONST(0.904153191969992) },
+ { FRAC_CONST(0.424432473022717), FRAC_CONST(0.905459593711293) },
+ { FRAC_CONST(0.421652564678558), FRAC_CONST(0.906757472922057) },
+ { FRAC_CONST(0.418868687579875), FRAC_CONST(0.908046817386148) },
+ { FRAC_CONST(0.416080867929579), FRAC_CONST(0.909327614967767) },
+ { FRAC_CONST(0.413289131967691), FRAC_CONST(0.910599853611559) },
+ { FRAC_CONST(0.410493505971093), FRAC_CONST(0.911863521342729) },
+ { FRAC_CONST(0.407694016253280), FRAC_CONST(0.913118606267154) },
+ { FRAC_CONST(0.404890689164118), FRAC_CONST(0.914365096571498) },
+ { FRAC_CONST(0.402083551089587), FRAC_CONST(0.915602980523320) },
+ { FRAC_CONST(0.399272628451541), FRAC_CONST(0.916832246471184) },
+ { FRAC_CONST(0.396457947707454), FRAC_CONST(0.918052882844770) },
+ { FRAC_CONST(0.393639535350173), FRAC_CONST(0.919264878154985) },
+ { FRAC_CONST(0.390817417907669), FRAC_CONST(0.920468220994067) },
+ { FRAC_CONST(0.387991621942785), FRAC_CONST(0.921662900035695) },
+ { FRAC_CONST(0.385162174052990), FRAC_CONST(0.922848904035094) },
+ { FRAC_CONST(0.382329100870125), FRAC_CONST(0.924026221829144) },
+ { FRAC_CONST(0.379492429060153), FRAC_CONST(0.925194842336480) },
+ { FRAC_CONST(0.376652185322910), FRAC_CONST(0.926354754557603) },
+ { FRAC_CONST(0.373808396391851), FRAC_CONST(0.927505947574975) },
+ { FRAC_CONST(0.370961089033802), FRAC_CONST(0.928648410553131) },
+ { FRAC_CONST(0.368110290048703), FRAC_CONST(0.929782132738772) },
+ { FRAC_CONST(0.365256026269360), FRAC_CONST(0.930907103460875) },
+ { FRAC_CONST(0.362398324561191), FRAC_CONST(0.932023312130786) },
+ { FRAC_CONST(0.359537211821973), FRAC_CONST(0.933130748242325) },
+ { FRAC_CONST(0.356672714981588), FRAC_CONST(0.934229401371881) },
+ { FRAC_CONST(0.353804861001772), FRAC_CONST(0.935319261178512) },
+ { FRAC_CONST(0.350933676875858), FRAC_CONST(0.936400317404042) },
+ { FRAC_CONST(0.348059189628526), FRAC_CONST(0.937472559873159) },
+ { FRAC_CONST(0.345181426315543), FRAC_CONST(0.938535978493509) },
+ { FRAC_CONST(0.342300414023514), FRAC_CONST(0.939590563255789) },
+ { FRAC_CONST(0.339416179869623), FRAC_CONST(0.940636304233848) },
+ { FRAC_CONST(0.336528751001382), FRAC_CONST(0.941673191584771) },
+ { FRAC_CONST(0.333638154596371), FRAC_CONST(0.942701215548982) },
+ { FRAC_CONST(0.330744417861983), FRAC_CONST(0.943720366450326) },
+ { FRAC_CONST(0.327847568035171), FRAC_CONST(0.944730634696168) },
+ { FRAC_CONST(0.324947632382188), FRAC_CONST(0.945732010777477) },
+ { FRAC_CONST(0.322044638198335), FRAC_CONST(0.946724485268921) },
+ { FRAC_CONST(0.319138612807696), FRAC_CONST(0.947708048828952) },
+ { FRAC_CONST(0.316229583562890), FRAC_CONST(0.948682692199895) },
+ { FRAC_CONST(0.313317577844809), FRAC_CONST(0.949648406208035) },
+ { FRAC_CONST(0.310402623062359), FRAC_CONST(0.950605181763705) },
+ { FRAC_CONST(0.307484746652204), FRAC_CONST(0.951553009861369) },
+ { FRAC_CONST(0.304563976078509), FRAC_CONST(0.952491881579706) },
+ { FRAC_CONST(0.301640338832679), FRAC_CONST(0.953421788081700) },
+ { FRAC_CONST(0.298713862433100), FRAC_CONST(0.954342720614716) },
+ { FRAC_CONST(0.295784574424884), FRAC_CONST(0.955254670510587) },
+ { FRAC_CONST(0.292852502379605), FRAC_CONST(0.956157629185692) },
+ { FRAC_CONST(0.289917673895041), FRAC_CONST(0.957051588141041) },
+ { FRAC_CONST(0.286980116594916), FRAC_CONST(0.957936538962351) },
+ { FRAC_CONST(0.284039858128637), FRAC_CONST(0.958812473320129) },
+ { FRAC_CONST(0.281096926171038), FRAC_CONST(0.959679382969747) },
+ { FRAC_CONST(0.278151348422115), FRAC_CONST(0.960537259751520) },
+ { FRAC_CONST(0.275203152606767), FRAC_CONST(0.961386095590786) },
+ { FRAC_CONST(0.272252366474537), FRAC_CONST(0.962225882497979) },
+ { FRAC_CONST(0.269299017799346), FRAC_CONST(0.963056612568704) },
+ { FRAC_CONST(0.266343134379238), FRAC_CONST(0.963878277983814) },
+ { FRAC_CONST(0.263384744036113), FRAC_CONST(0.964690871009481) },
+ { FRAC_CONST(0.260423874615468), FRAC_CONST(0.965494383997270) },
+ { FRAC_CONST(0.257460553986133), FRAC_CONST(0.966288809384210) },
+ { FRAC_CONST(0.254494810040011), FRAC_CONST(0.967074139692867) },
+ { FRAC_CONST(0.251526670691813), FRAC_CONST(0.967850367531414) },
+ { FRAC_CONST(0.248556163878797), FRAC_CONST(0.968617485593698) },
+ { FRAC_CONST(0.245583317560504), FRAC_CONST(0.969375486659311) },
+ { FRAC_CONST(0.242608159718497), FRAC_CONST(0.970124363593660) },
+ { FRAC_CONST(0.239630718356094), FRAC_CONST(0.970864109348029) },
+ { FRAC_CONST(0.236651021498106), FRAC_CONST(0.971594716959650) },
+ { FRAC_CONST(0.233669097190577), FRAC_CONST(0.972316179551765) },
+ { FRAC_CONST(0.230684973500512), FRAC_CONST(0.973028490333694) },
+ { FRAC_CONST(0.227698678515621), FRAC_CONST(0.973731642600896) },
+ { FRAC_CONST(0.224710240344050), FRAC_CONST(0.974425629735035) },
+ { FRAC_CONST(0.221719687114115), FRAC_CONST(0.975110445204039) },
+ { FRAC_CONST(0.218727046974045), FRAC_CONST(0.975786082562164) },
+ { FRAC_CONST(0.215732348091706), FRAC_CONST(0.976452535450054) },
+ { FRAC_CONST(0.212735618654346), FRAC_CONST(0.977109797594801) },
+ { FRAC_CONST(0.209736886868323), FRAC_CONST(0.977757862810003) },
+ { FRAC_CONST(0.206736180958844), FRAC_CONST(0.978396724995823) },
+ { FRAC_CONST(0.203733529169694), FRAC_CONST(0.979026378139048) },
+ { FRAC_CONST(0.200728959762976), FRAC_CONST(0.979646816313141) },
+ { FRAC_CONST(0.197722501018842), FRAC_CONST(0.980258033678304) },
+ { FRAC_CONST(0.194714181235226), FRAC_CONST(0.980860024481524) },
+ { FRAC_CONST(0.191704028727580), FRAC_CONST(0.981452783056636) },
+ { FRAC_CONST(0.188692071828605), FRAC_CONST(0.982036303824369) },
+ { FRAC_CONST(0.185678338887988), FRAC_CONST(0.982610581292405) },
+ { FRAC_CONST(0.182662858272129), FRAC_CONST(0.983175610055424) },
+ { FRAC_CONST(0.179645658363882), FRAC_CONST(0.983731384795162) },
+ { FRAC_CONST(0.176626767562281), FRAC_CONST(0.984277900280454) },
+ { FRAC_CONST(0.173606214282275), FRAC_CONST(0.984815151367289) },
+ { FRAC_CONST(0.170584026954464), FRAC_CONST(0.985343132998855) },
+ { FRAC_CONST(0.167560234024824), FRAC_CONST(0.985861840205587) },
+ { FRAC_CONST(0.164534863954446), FRAC_CONST(0.986371268105216) },
+ { FRAC_CONST(0.161507945219266), FRAC_CONST(0.986871411902812) },
+ { FRAC_CONST(0.158479506309796), FRAC_CONST(0.987362266890832) },
+ { FRAC_CONST(0.155449575730856), FRAC_CONST(0.987843828449162) },
+ { FRAC_CONST(0.152418182001307), FRAC_CONST(0.988316092045160) },
+ { FRAC_CONST(0.149385353653780), FRAC_CONST(0.988779053233702) },
+ { FRAC_CONST(0.146351119234411), FRAC_CONST(0.989232707657220) },
+ { FRAC_CONST(0.143315507302572), FRAC_CONST(0.989677051045747) },
+ { FRAC_CONST(0.140278546430595), FRAC_CONST(0.990112079216954) },
+ { FRAC_CONST(0.137240265203516), FRAC_CONST(0.990537788076189) },
+ { FRAC_CONST(0.134200692218792), FRAC_CONST(0.990954173616519) },
+ { FRAC_CONST(0.131159856086043), FRAC_CONST(0.991361231918763) },
+ { FRAC_CONST(0.128117785426777), FRAC_CONST(0.991758959151536) },
+ { FRAC_CONST(0.125074508874121), FRAC_CONST(0.992147351571276) },
+ { FRAC_CONST(0.122030055072553), FRAC_CONST(0.992526405522286) },
+ { FRAC_CONST(0.118984452677633), FRAC_CONST(0.992896117436766) },
+ { FRAC_CONST(0.115937730355728), FRAC_CONST(0.993256483834846) },
+ { FRAC_CONST(0.112889916783750), FRAC_CONST(0.993607501324622) },
+ { FRAC_CONST(0.109841040648883), FRAC_CONST(0.993949166602181) },
+ { FRAC_CONST(0.106791130648307), FRAC_CONST(0.994281476451642) },
+ { FRAC_CONST(0.103740215488939), FRAC_CONST(0.994604427745176) },
+ { FRAC_CONST(0.100688323887154), FRAC_CONST(0.994918017443043) },
+ { FRAC_CONST(0.097635484568517), FRAC_CONST(0.995222242593618) },
+ { FRAC_CONST(0.094581726267515), FRAC_CONST(0.995517100333418) },
+ { FRAC_CONST(0.091527077727285), FRAC_CONST(0.995802587887129) },
+ { FRAC_CONST(0.088471567699341), FRAC_CONST(0.996078702567634) },
+ { FRAC_CONST(0.085415224943307), FRAC_CONST(0.996345441776036) },
+ { FRAC_CONST(0.082358078226647), FRAC_CONST(0.996602803001684) },
+ { FRAC_CONST(0.079300156324388), FRAC_CONST(0.996850783822197) },
+ { FRAC_CONST(0.076241488018856), FRAC_CONST(0.997089381903483) },
+ { FRAC_CONST(0.073182102099403), FRAC_CONST(0.997318594999769) },
+ { FRAC_CONST(0.070122027362134), FRAC_CONST(0.997538420953611) },
+ { FRAC_CONST(0.067061292609637), FRAC_CONST(0.997748857695926) },
+ { FRAC_CONST(0.063999926650714), FRAC_CONST(0.997949903246001) },
+ { FRAC_CONST(0.060937958300107), FRAC_CONST(0.998141555711521) },
+ { FRAC_CONST(0.057875416378229), FRAC_CONST(0.998323813288578) },
+ { FRAC_CONST(0.054812329710890), FRAC_CONST(0.998496674261695) },
+ { FRAC_CONST(0.051748727129028), FRAC_CONST(0.998660137003838) },
+ { FRAC_CONST(0.048684637468439), FRAC_CONST(0.998814199976435) },
+ { FRAC_CONST(0.045620089569500), FRAC_CONST(0.998958861729386) },
+ { FRAC_CONST(0.042555112276904), FRAC_CONST(0.999094120901079) },
+ { FRAC_CONST(0.039489734439384), FRAC_CONST(0.999219976218404) },
+ { FRAC_CONST(0.036423984909444), FRAC_CONST(0.999336426496761) },
+ { FRAC_CONST(0.033357892543086), FRAC_CONST(0.999443470640078) },
+ { FRAC_CONST(0.030291486199539), FRAC_CONST(0.999541107640813) },
+ { FRAC_CONST(0.027224794740988), FRAC_CONST(0.999629336579970) },
+ { FRAC_CONST(0.024157847032300), FRAC_CONST(0.999708156627105) },
+ { FRAC_CONST(0.021090671940755), FRAC_CONST(0.999777567040333) },
+ { FRAC_CONST(0.018023298335774), FRAC_CONST(0.999837567166337) },
+ { FRAC_CONST(0.014955755088644), FRAC_CONST(0.999888156440373) },
+ { FRAC_CONST(0.011888071072252), FRAC_CONST(0.999929334386276) },
+ { FRAC_CONST(0.008820275160808), FRAC_CONST(0.999961100616463) },
+ { FRAC_CONST(0.005752396229574), FRAC_CONST(0.999983454831938) },
+ { FRAC_CONST(0.002684463154596), FRAC_CONST(0.999996396822294) }
+ };
+
+ /* 64 (N/4) complex twiddle factors */
+ ALIGN static const complex_t mdct_tab_256[] = {
+ { FRAC_CONST(0.999995293809576), FRAC_CONST(0.003067956762966) },
+ { FRAC_CONST(0.999618822495179), FRAC_CONST(0.027608145778966) },
+ { FRAC_CONST(0.998640218180265), FRAC_CONST(0.052131704680283) },
+ { FRAC_CONST(0.997060070339483), FRAC_CONST(0.076623861392031) },
+ { FRAC_CONST(0.994879330794806), FRAC_CONST(0.101069862754828) },
+ { FRAC_CONST(0.992099313142192), FRAC_CONST(0.125454983411546) },
+ { FRAC_CONST(0.988721691960324), FRAC_CONST(0.149764534677322) },
+ { FRAC_CONST(0.984748501801904), FRAC_CONST(0.173983873387464) },
+ { FRAC_CONST(0.980182135968117), FRAC_CONST(0.198098410717954) },
+ { FRAC_CONST(0.975025345066994), FRAC_CONST(0.222093620973204) },
+ { FRAC_CONST(0.969281235356549), FRAC_CONST(0.245955050335795) },
+ { FRAC_CONST(0.962953266873684), FRAC_CONST(0.269668325572915) },
+ { FRAC_CONST(0.956045251349996), FRAC_CONST(0.293219162694259) },
+ { FRAC_CONST(0.948561349915730), FRAC_CONST(0.316593375556166) },
+ { FRAC_CONST(0.940506070593268), FRAC_CONST(0.339776884406827) },
+ { FRAC_CONST(0.931884265581668), FRAC_CONST(0.362755724367397) },
+ { FRAC_CONST(0.922701128333879), FRAC_CONST(0.385516053843919) },
+ { FRAC_CONST(0.912962190428398), FRAC_CONST(0.408044162864979) },
+ { FRAC_CONST(0.902673318237259), FRAC_CONST(0.430326481340083) },
+ { FRAC_CONST(0.891840709392343), FRAC_CONST(0.452349587233771) },
+ { FRAC_CONST(0.880470889052161), FRAC_CONST(0.474100214650550) },
+ { FRAC_CONST(0.868570705971341), FRAC_CONST(0.495565261825773) },
+ { FRAC_CONST(0.856147328375194), FRAC_CONST(0.516731799017650) },
+ { FRAC_CONST(0.843208239641845), FRAC_CONST(0.537587076295645) },
+ { FRAC_CONST(0.829761233794523), FRAC_CONST(0.558118531220556) },
+ { FRAC_CONST(0.815814410806734), FRAC_CONST(0.578313796411656) },
+ { FRAC_CONST(0.801376171723140), FRAC_CONST(0.598160706996342) },
+ { FRAC_CONST(0.786455213599086), FRAC_CONST(0.617647307937804) },
+ { FRAC_CONST(0.771060524261814), FRAC_CONST(0.636761861236284) },
+ { FRAC_CONST(0.755201376896537), FRAC_CONST(0.655492852999615) },
+ { FRAC_CONST(0.738887324460615), FRAC_CONST(0.673829000378756) },
+ { FRAC_CONST(0.722128193929215), FRAC_CONST(0.691759258364158) },
+ { FRAC_CONST(0.704934080375905), FRAC_CONST(0.709272826438866) },
+ { FRAC_CONST(0.687315340891759), FRAC_CONST(0.726359155084346) },
+ { FRAC_CONST(0.669282588346636), FRAC_CONST(0.743007952135122) },
+ { FRAC_CONST(0.650846684996381), FRAC_CONST(0.759209188978388) },
+ { FRAC_CONST(0.632018735939809), FRAC_CONST(0.774953106594874) },
+ { FRAC_CONST(0.612810082429410), FRAC_CONST(0.790230221437310) },
+ { FRAC_CONST(0.593232295039800), FRAC_CONST(0.805031331142964) },
+ { FRAC_CONST(0.573297166698042), FRAC_CONST(0.819347520076797) },
+ { FRAC_CONST(0.553016705580028), FRAC_CONST(0.833170164701913) },
+ { FRAC_CONST(0.532403127877198), FRAC_CONST(0.846490938774052) },
+ { FRAC_CONST(0.511468850437971), FRAC_CONST(0.859301818357008) },
+ { FRAC_CONST(0.490226483288291), FRAC_CONST(0.871595086655951) },
+ { FRAC_CONST(0.468688822035828), FRAC_CONST(0.883363338665732) },
+ { FRAC_CONST(0.446868840162374), FRAC_CONST(0.894599485631383) },
+ { FRAC_CONST(0.424779681209109), FRAC_CONST(0.905296759318119) },
+ { FRAC_CONST(0.402434650859419), FRAC_CONST(0.915448716088268) },
+ { FRAC_CONST(0.379847208924051), FRAC_CONST(0.925049240782678) },
+ { FRAC_CONST(0.357030961233430), FRAC_CONST(0.934092550404259) },
+ { FRAC_CONST(0.333999651442009), FRAC_CONST(0.942573197601447) },
+ { FRAC_CONST(0.310767152749611), FRAC_CONST(0.950486073949482) },
+ { FRAC_CONST(0.287347459544730), FRAC_CONST(0.957826413027533) },
+ { FRAC_CONST(0.263754678974832), FRAC_CONST(0.964589793289813) },
+ { FRAC_CONST(0.240003022448742), FRAC_CONST(0.970772140728950) },
+ { FRAC_CONST(0.216106797076220), FRAC_CONST(0.976369731330021) },
+ { FRAC_CONST(0.192080397049892), FRAC_CONST(0.981379193313755) },
+ { FRAC_CONST(0.167938294974731), FRAC_CONST(0.985797509167567) },
+ { FRAC_CONST(0.143695033150295), FRAC_CONST(0.989622017463201) },
+ { FRAC_CONST(0.119365214810991), FRAC_CONST(0.992850414459865) },
+ { FRAC_CONST(0.094963495329639), FRAC_CONST(0.995480755491927) },
+ { FRAC_CONST(0.070504573389614), FRAC_CONST(0.997511456140303) },
+ { FRAC_CONST(0.046003182130915), FRAC_CONST(0.998941293186857) },
+ { FRAC_CONST(0.021474080275470), FRAC_CONST(0.999769405351215) }
+ };
+
+#ifdef LD_DEC
+ /* 256 (N/4) complex twiddle factors */
+ ALIGN static const complex_t mdct_tab_1024[] = {
+ { FRAC_CONST(0.999999705862882), FRAC_CONST(0.000766990318743) },
+ { FRAC_CONST(0.999976174986898), FRAC_CONST(0.006902858724730) },
+ { FRAC_CONST(0.999914995573113), FRAC_CONST(0.013038467241987) },
+ { FRAC_CONST(0.999816169924900), FRAC_CONST(0.019173584868323) },
+ { FRAC_CONST(0.999679701762988), FRAC_CONST(0.025307980620025) },
+ { FRAC_CONST(0.999505596225325), FRAC_CONST(0.031441423540560) },
+ { FRAC_CONST(0.999293859866888), FRAC_CONST(0.037573682709270) },
+ { FRAC_CONST(0.999044500659429), FRAC_CONST(0.043704527250063) },
+ { FRAC_CONST(0.998757527991183), FRAC_CONST(0.049833726340107) },
+ { FRAC_CONST(0.998432952666508), FRAC_CONST(0.055961049218521) },
+ { FRAC_CONST(0.998070786905482), FRAC_CONST(0.062086265195060) },
+ { FRAC_CONST(0.997671044343441), FRAC_CONST(0.068209143658806) },
+ { FRAC_CONST(0.997233740030466), FRAC_CONST(0.074329454086846) },
+ { FRAC_CONST(0.996758890430818), FRAC_CONST(0.080446966052950) },
+ { FRAC_CONST(0.996246513422316), FRAC_CONST(0.086561449236251) },
+ { FRAC_CONST(0.995696628295664), FRAC_CONST(0.092672673429913) },
+ { FRAC_CONST(0.995109255753726), FRAC_CONST(0.098780408549800) },
+ { FRAC_CONST(0.994484417910748), FRAC_CONST(0.104884424643135) },
+ { FRAC_CONST(0.993822138291520), FRAC_CONST(0.110984491897163) },
+ { FRAC_CONST(0.993122441830496), FRAC_CONST(0.117080380647801) },
+ { FRAC_CONST(0.992385354870852), FRAC_CONST(0.123171861388280) },
+ { FRAC_CONST(0.991610905163495), FRAC_CONST(0.129258704777796) },
+ { FRAC_CONST(0.990799121866020), FRAC_CONST(0.135340681650134) },
+ { FRAC_CONST(0.989950035541609), FRAC_CONST(0.141417563022303) },
+ { FRAC_CONST(0.989063678157882), FRAC_CONST(0.147489120103154) },
+ { FRAC_CONST(0.988140083085693), FRAC_CONST(0.153555124301993) },
+ { FRAC_CONST(0.987179285097874), FRAC_CONST(0.159615347237193) },
+ { FRAC_CONST(0.986181320367928), FRAC_CONST(0.165669560744784) },
+ { FRAC_CONST(0.985146226468662), FRAC_CONST(0.171717536887050) },
+ { FRAC_CONST(0.984074042370776), FRAC_CONST(0.177759047961107) },
+ { FRAC_CONST(0.982964808441396), FRAC_CONST(0.183793866507478) },
+ { FRAC_CONST(0.981818566442553), FRAC_CONST(0.189821765318656) },
+ { FRAC_CONST(0.980635359529608), FRAC_CONST(0.195842517447658) },
+ { FRAC_CONST(0.979415232249635), FRAC_CONST(0.201855896216568) },
+ { FRAC_CONST(0.978158230539735), FRAC_CONST(0.207861675225075) },
+ { FRAC_CONST(0.976864401725313), FRAC_CONST(0.213859628358994) },
+ { FRAC_CONST(0.975533794518291), FRAC_CONST(0.219849529798779) },
+ { FRAC_CONST(0.974166459015280), FRAC_CONST(0.225831154028026) },
+ { FRAC_CONST(0.972762446695689), FRAC_CONST(0.231804275841965) },
+ { FRAC_CONST(0.971321810419786), FRAC_CONST(0.237768670355934) },
+ { FRAC_CONST(0.969844604426715), FRAC_CONST(0.243724113013852) },
+ { FRAC_CONST(0.968330884332445), FRAC_CONST(0.249670379596669) },
+ { FRAC_CONST(0.966780707127683), FRAC_CONST(0.255607246230807) },
+ { FRAC_CONST(0.965194131175725), FRAC_CONST(0.261534489396596) },
+ { FRAC_CONST(0.963571216210257), FRAC_CONST(0.267451885936678) },
+ { FRAC_CONST(0.961912023333112), FRAC_CONST(0.273359213064419) },
+ { FRAC_CONST(0.960216615011963), FRAC_CONST(0.279256248372291) },
+ { FRAC_CONST(0.958485055077976), FRAC_CONST(0.285142769840249) },
+ { FRAC_CONST(0.956717408723403), FRAC_CONST(0.291018555844085) },
+ { FRAC_CONST(0.954913742499131), FRAC_CONST(0.296883385163778) },
+ { FRAC_CONST(0.953074124312172), FRAC_CONST(0.302737036991819) },
+ { FRAC_CONST(0.951198623423113), FRAC_CONST(0.308579290941525) },
+ { FRAC_CONST(0.949287310443502), FRAC_CONST(0.314409927055337) },
+ { FRAC_CONST(0.947340257333192), FRAC_CONST(0.320228725813100) },
+ { FRAC_CONST(0.945357537397632), FRAC_CONST(0.326035468140330) },
+ { FRAC_CONST(0.943339225285108), FRAC_CONST(0.331829935416461) },
+ { FRAC_CONST(0.941285396983929), FRAC_CONST(0.337611909483075) },
+ { FRAC_CONST(0.939196129819570), FRAC_CONST(0.343381172652115) },
+ { FRAC_CONST(0.937071502451759), FRAC_CONST(0.349137507714085) },
+ { FRAC_CONST(0.934911594871516), FRAC_CONST(0.354880697946223) },
+ { FRAC_CONST(0.932716488398140), FRAC_CONST(0.360610527120662) },
+ { FRAC_CONST(0.930486265676150), FRAC_CONST(0.366326779512574) },
+ { FRAC_CONST(0.928221010672169), FRAC_CONST(0.372029239908285) },
+ { FRAC_CONST(0.925920808671770), FRAC_CONST(0.377717693613386) },
+ { FRAC_CONST(0.923585746276257), FRAC_CONST(0.383391926460809) },
+ { FRAC_CONST(0.921215911399409), FRAC_CONST(0.389051724818894) },
+ { FRAC_CONST(0.918811393264170), FRAC_CONST(0.394696875599434) },
+ { FRAC_CONST(0.916372282399289), FRAC_CONST(0.400327166265690) },
+ { FRAC_CONST(0.913898670635912), FRAC_CONST(0.405942384840403) },
+ { FRAC_CONST(0.911390651104122), FRAC_CONST(0.411542319913765) },
+ { FRAC_CONST(0.908848318229439), FRAC_CONST(0.417126760651388) },
+ { FRAC_CONST(0.906271767729258), FRAC_CONST(0.422695496802233) },
+ { FRAC_CONST(0.903661096609248), FRAC_CONST(0.428248318706532) },
+ { FRAC_CONST(0.901016403159702), FRAC_CONST(0.433785017303679) },
+ { FRAC_CONST(0.898337786951834), FRAC_CONST(0.439305384140100) },
+ { FRAC_CONST(0.895625348834030), FRAC_CONST(0.444809211377105) },
+ { FRAC_CONST(0.892879190928052), FRAC_CONST(0.450296291798709) },
+ { FRAC_CONST(0.890099416625192), FRAC_CONST(0.455766418819435) },
+ { FRAC_CONST(0.887286130582383), FRAC_CONST(0.461219386492092) },
+ { FRAC_CONST(0.884439438718254), FRAC_CONST(0.466654989515531) },
+ { FRAC_CONST(0.881559448209144), FRAC_CONST(0.472073023242369) },
+ { FRAC_CONST(0.878646267485068), FRAC_CONST(0.477473283686698) },
+ { FRAC_CONST(0.875700006225635), FRAC_CONST(0.482855567531766) },
+ { FRAC_CONST(0.872720775355914), FRAC_CONST(0.488219672137627) },
+ { FRAC_CONST(0.869708687042266), FRAC_CONST(0.493565395548775) },
+ { FRAC_CONST(0.866663854688111), FRAC_CONST(0.498892536501745) },
+ { FRAC_CONST(0.863586392929668), FRAC_CONST(0.504200894432690) },
+ { FRAC_CONST(0.860476417631632), FRAC_CONST(0.509490269484936) },
+ { FRAC_CONST(0.857334045882816), FRAC_CONST(0.514760462516501) },
+ { FRAC_CONST(0.854159395991739), FRAC_CONST(0.520011275107596) },
+ { FRAC_CONST(0.850952587482176), FRAC_CONST(0.525242509568095) },
+ { FRAC_CONST(0.847713741088654), FRAC_CONST(0.530453968944976) },
+ { FRAC_CONST(0.844442978751911), FRAC_CONST(0.535645457029741) },
+ { FRAC_CONST(0.841140423614298), FRAC_CONST(0.540816778365797) },
+ { FRAC_CONST(0.837806200015151), FRAC_CONST(0.545967738255818) },
+ { FRAC_CONST(0.834440433486103), FRAC_CONST(0.551098142769075) },
+ { FRAC_CONST(0.831043250746362), FRAC_CONST(0.556207798748740) },
+ { FRAC_CONST(0.827614779697938), FRAC_CONST(0.561296513819151) },
+ { FRAC_CONST(0.824155149420829), FRAC_CONST(0.566364096393064) },
+ { FRAC_CONST(0.820664490168157), FRAC_CONST(0.571410355678857) },
+ { FRAC_CONST(0.817142933361273), FRAC_CONST(0.576435101687722) },
+ { FRAC_CONST(0.813590611584799), FRAC_CONST(0.581438145240810) },
+ { FRAC_CONST(0.810007658581641), FRAC_CONST(0.586419297976361) },
+ { FRAC_CONST(0.806394209247956), FRAC_CONST(0.591378372356788) },
+ { FRAC_CONST(0.802750399628069), FRAC_CONST(0.596315181675744) },
+ { FRAC_CONST(0.799076366909352), FRAC_CONST(0.601229540065149) },
+ { FRAC_CONST(0.795372249417061), FRAC_CONST(0.606121262502186) },
+ { FRAC_CONST(0.791638186609126), FRAC_CONST(0.610990164816272) },
+ { FRAC_CONST(0.787874319070900), FRAC_CONST(0.615836063695985) },
+ { FRAC_CONST(0.784080788509870), FRAC_CONST(0.620658776695972) },
+ { FRAC_CONST(0.780257737750317), FRAC_CONST(0.625458122243814) },
+ { FRAC_CONST(0.776405310727940), FRAC_CONST(0.630233919646864) },
+ { FRAC_CONST(0.772523652484441), FRAC_CONST(0.634985989099049) },
+ { FRAC_CONST(0.768612909162058), FRAC_CONST(0.639714151687640) },
+ { FRAC_CONST(0.764673227998067), FRAC_CONST(0.644418229399988) },
+ { FRAC_CONST(0.760704757319237), FRAC_CONST(0.649098045130226) },
+ { FRAC_CONST(0.756707646536246), FRAC_CONST(0.653753422685936) },
+ { FRAC_CONST(0.752682046138055), FRAC_CONST(0.658384186794785) },
+ { FRAC_CONST(0.748628107686245), FRAC_CONST(0.662990163111121) },
+ { FRAC_CONST(0.744545983809307), FRAC_CONST(0.667571178222540) },
+ { FRAC_CONST(0.740435828196898), FRAC_CONST(0.672127059656412) },
+ { FRAC_CONST(0.736297795594053), FRAC_CONST(0.676657635886375) },
+ { FRAC_CONST(0.732132041795361), FRAC_CONST(0.681162736338795) },
+ { FRAC_CONST(0.727938723639099), FRAC_CONST(0.685642191399187) },
+ { FRAC_CONST(0.723717999001324), FRAC_CONST(0.690095832418600) },
+ { FRAC_CONST(0.719470026789933), FRAC_CONST(0.694523491719966) },
+ { FRAC_CONST(0.715194966938680), FRAC_CONST(0.698925002604414) },
+ { FRAC_CONST(0.710892980401152), FRAC_CONST(0.703300199357549) },
+ { FRAC_CONST(0.706564229144710), FRAC_CONST(0.707648917255684) },
+ { FRAC_CONST(0.702208876144392), FRAC_CONST(0.711970992572050) },
+ { FRAC_CONST(0.697827085376777), FRAC_CONST(0.716266262582953) },
+ { FRAC_CONST(0.693419021813812), FRAC_CONST(0.720534565573905) },
+ { FRAC_CONST(0.688984851416597), FRAC_CONST(0.724775740845711) },
+ { FRAC_CONST(0.684524741129142), FRAC_CONST(0.728989628720519) },
+ { FRAC_CONST(0.680038858872079), FRAC_CONST(0.733176070547833) },
+ { FRAC_CONST(0.675527373536339), FRAC_CONST(0.737334908710483) },
+ { FRAC_CONST(0.670990454976794), FRAC_CONST(0.741465986630563) },
+ { FRAC_CONST(0.666428274005865), FRAC_CONST(0.745569148775325) },
+ { FRAC_CONST(0.661841002387087), FRAC_CONST(0.749644240663033) },
+ { FRAC_CONST(0.657228812828643), FRAC_CONST(0.753691108868781) },
+ { FRAC_CONST(0.652591878976863), FRAC_CONST(0.757709601030268) },
+ { FRAC_CONST(0.647930375409685), FRAC_CONST(0.761699565853535) },
+ { FRAC_CONST(0.643244477630086), FRAC_CONST(0.765660853118662) },
+ { FRAC_CONST(0.638534362059467), FRAC_CONST(0.769593313685423) },
+ { FRAC_CONST(0.633800206031017), FRAC_CONST(0.773496799498899) },
+ { FRAC_CONST(0.629042187783036), FRAC_CONST(0.777371163595056) },
+ { FRAC_CONST(0.624260486452221), FRAC_CONST(0.781216260106276) },
+ { FRAC_CONST(0.619455282066924), FRAC_CONST(0.785031944266848) },
+ { FRAC_CONST(0.614626755540375), FRAC_CONST(0.788818072418420) },
+ { FRAC_CONST(0.609775088663868), FRAC_CONST(0.792574502015408) },
+ { FRAC_CONST(0.604900464099920), FRAC_CONST(0.796301091630359) },
+ { FRAC_CONST(0.600003065375389), FRAC_CONST(0.799997700959282) },
+ { FRAC_CONST(0.595083076874570), FRAC_CONST(0.803664190826924) },
+ { FRAC_CONST(0.590140683832249), FRAC_CONST(0.807300423192014) },
+ { FRAC_CONST(0.585176072326730), FRAC_CONST(0.810906261152460) },
+ { FRAC_CONST(0.580189429272832), FRAC_CONST(0.814481568950499) },
+ { FRAC_CONST(0.575180942414845), FRAC_CONST(0.818026211977813) },
+ { FRAC_CONST(0.570150800319470), FRAC_CONST(0.821540056780598) },
+ { FRAC_CONST(0.565099192368714), FRAC_CONST(0.825022971064580) },
+ { FRAC_CONST(0.560026308752760), FRAC_CONST(0.828474823700007) },
+ { FRAC_CONST(0.554932340462810), FRAC_CONST(0.831895484726578) },
+ { FRAC_CONST(0.549817479283891), FRAC_CONST(0.835284825358337) },
+ { FRAC_CONST(0.544681917787635), FRAC_CONST(0.838642717988527) },
+ { FRAC_CONST(0.539525849325029), FRAC_CONST(0.841969036194388) },
+ { FRAC_CONST(0.534349468019138), FRAC_CONST(0.845263654741918) },
+ { FRAC_CONST(0.529152968757791), FRAC_CONST(0.848526449590593) },
+ { FRAC_CONST(0.523936547186249), FRAC_CONST(0.851757297898029) },
+ { FRAC_CONST(0.518700399699835), FRAC_CONST(0.854956078024615) },
+ { FRAC_CONST(0.513444723436544), FRAC_CONST(0.858122669538086) },
+ { FRAC_CONST(0.508169716269615), FRAC_CONST(0.861256953218062) },
+ { FRAC_CONST(0.502875576800087), FRAC_CONST(0.864358811060534) },
+ { FRAC_CONST(0.497562504349319), FRAC_CONST(0.867428126282307) },
+ { FRAC_CONST(0.492230698951486), FRAC_CONST(0.870464783325398) },
+ { FRAC_CONST(0.486880361346047), FRAC_CONST(0.873468667861385) },
+ { FRAC_CONST(0.481511692970190), FRAC_CONST(0.876439666795714) },
+ { FRAC_CONST(0.476124895951244), FRAC_CONST(0.879377668271953) },
+ { FRAC_CONST(0.470720173099072), FRAC_CONST(0.882282561676009) },
+ { FRAC_CONST(0.465297727898435), FRAC_CONST(0.885154237640285) },
+ { FRAC_CONST(0.459857764501330), FRAC_CONST(0.887992588047806) },
+ { FRAC_CONST(0.454400487719304), FRAC_CONST(0.890797506036281) },
+ { FRAC_CONST(0.448926103015743), FRAC_CONST(0.893568886002136) },
+ { FRAC_CONST(0.443434816498138), FRAC_CONST(0.896306623604480) },
+ { FRAC_CONST(0.437926834910323), FRAC_CONST(0.899010615769039) },
+ { FRAC_CONST(0.432402365624690), FRAC_CONST(0.901680760692038) },
+ { FRAC_CONST(0.426861616634386), FRAC_CONST(0.904316957844028) },
+ { FRAC_CONST(0.421304796545480), FRAC_CONST(0.906919107973678) },
+ { FRAC_CONST(0.415732114569105), FRAC_CONST(0.909487113111505) },
+ { FRAC_CONST(0.410143780513590), FRAC_CONST(0.912020876573568) },
+ { FRAC_CONST(0.404540004776553), FRAC_CONST(0.914520302965104) },
+ { FRAC_CONST(0.398920998336983), FRAC_CONST(0.916985298184123) },
+ { FRAC_CONST(0.393286972747297), FRAC_CONST(0.919415769424947) },
+ { FRAC_CONST(0.387638140125373), FRAC_CONST(0.921811625181708) },
+ { FRAC_CONST(0.381974713146567), FRAC_CONST(0.924172775251791) },
+ { FRAC_CONST(0.376296905035705), FRAC_CONST(0.926499130739231) },
+ { FRAC_CONST(0.370604929559052), FRAC_CONST(0.928790604058057) },
+ { FRAC_CONST(0.364899001016267), FRAC_CONST(0.931047108935595) },
+ { FRAC_CONST(0.359179334232337), FRAC_CONST(0.933268560415712) },
+ { FRAC_CONST(0.353446144549481), FRAC_CONST(0.935454874862015) },
+ { FRAC_CONST(0.347699647819051), FRAC_CONST(0.937605969961000) },
+ { FRAC_CONST(0.341940060393402), FRAC_CONST(0.939721764725153) },
+ { FRAC_CONST(0.336167599117745), FRAC_CONST(0.941802179495998) },
+ { FRAC_CONST(0.330382481321983), FRAC_CONST(0.943847135947093) },
+ { FRAC_CONST(0.324584924812532), FRAC_CONST(0.945856557086984) },
+ { FRAC_CONST(0.318775147864118), FRAC_CONST(0.947830367262101) },
+ { FRAC_CONST(0.312953369211560), FRAC_CONST(0.949768492159607) },
+ { FRAC_CONST(0.307119808041533), FRAC_CONST(0.951670858810194) },
+ { FRAC_CONST(0.301274683984318), FRAC_CONST(0.953537395590833) },
+ { FRAC_CONST(0.295418217105532), FRAC_CONST(0.955368032227470) },
+ { FRAC_CONST(0.289550627897843), FRAC_CONST(0.957162699797670) },
+ { FRAC_CONST(0.283672137272669), FRAC_CONST(0.958921330733213) },
+ { FRAC_CONST(0.277782966551858), FRAC_CONST(0.960643858822638) },
+ { FRAC_CONST(0.271883337459360), FRAC_CONST(0.962330219213737) },
+ { FRAC_CONST(0.265973472112876), FRAC_CONST(0.963980348415994) },
+ { FRAC_CONST(0.260053593015495), FRAC_CONST(0.965594184302977) },
+ { FRAC_CONST(0.254123923047321), FRAC_CONST(0.967171666114677) },
+ { FRAC_CONST(0.248184685457075), FRAC_CONST(0.968712734459795) },
+ { FRAC_CONST(0.242236103853696), FRAC_CONST(0.970217331317979) },
+ { FRAC_CONST(0.236278402197920), FRAC_CONST(0.971685400042009) },
+ { FRAC_CONST(0.230311804793846), FRAC_CONST(0.973116885359925) },
+ { FRAC_CONST(0.224336536280494), FRAC_CONST(0.974511733377116) },
+ { FRAC_CONST(0.218352821623346), FRAC_CONST(0.975869891578341) },
+ { FRAC_CONST(0.212360886105879), FRAC_CONST(0.977191308829712) },
+ { FRAC_CONST(0.206360955321076), FRAC_CONST(0.978475935380617) },
+ { FRAC_CONST(0.200353255162940), FRAC_CONST(0.979723722865591) },
+ { FRAC_CONST(0.194338011817989), FRAC_CONST(0.980934624306142) },
+ { FRAC_CONST(0.188315451756732), FRAC_CONST(0.982108594112514) },
+ { FRAC_CONST(0.182285801725153), FRAC_CONST(0.983245588085407) },
+ { FRAC_CONST(0.176249288736168), FRAC_CONST(0.984345563417642) },
+ { FRAC_CONST(0.170206140061078), FRAC_CONST(0.985408478695768) },
+ { FRAC_CONST(0.164156583221016), FRAC_CONST(0.986434293901627) },
+ { FRAC_CONST(0.158100845978377), FRAC_CONST(0.987422970413855) },
+ { FRAC_CONST(0.152039156328246), FRAC_CONST(0.988374471009341) },
+ { FRAC_CONST(0.145971742489812), FRAC_CONST(0.989288759864625) },
+ { FRAC_CONST(0.139898832897777), FRAC_CONST(0.990165802557248) },
+ { FRAC_CONST(0.133820656193755), FRAC_CONST(0.991005566067049) },
+ { FRAC_CONST(0.127737441217662), FRAC_CONST(0.991808018777406) },
+ { FRAC_CONST(0.121649416999106), FRAC_CONST(0.992573130476429) },
+ { FRAC_CONST(0.115556812748755), FRAC_CONST(0.993300872358093) },
+ { FRAC_CONST(0.109459857849718), FRAC_CONST(0.993991217023329) },
+ { FRAC_CONST(0.103358781848900), FRAC_CONST(0.994644138481051) },
+ { FRAC_CONST(0.097253814448363), FRAC_CONST(0.995259612149133) },
+ { FRAC_CONST(0.091145185496681), FRAC_CONST(0.995837614855342) },
+ { FRAC_CONST(0.085033124980280), FRAC_CONST(0.996378124838200) },
+ { FRAC_CONST(0.078917863014785), FRAC_CONST(0.996881121747814) },
+ { FRAC_CONST(0.072799629836352), FRAC_CONST(0.997346586646633) },
+ { FRAC_CONST(0.066678655793002), FRAC_CONST(0.997774502010168) },
+ { FRAC_CONST(0.060555171335948), FRAC_CONST(0.998164851727646) },
+ { FRAC_CONST(0.054429407010919), FRAC_CONST(0.998517621102622) },
+ { FRAC_CONST(0.048301593449480), FRAC_CONST(0.998832796853528) },
+ { FRAC_CONST(0.042171961360348), FRAC_CONST(0.999110367114175) },
+ { FRAC_CONST(0.036040741520706), FRAC_CONST(0.999350321434199) },
+ { FRAC_CONST(0.029908164767517), FRAC_CONST(0.999552650779457) },
+ { FRAC_CONST(0.023774461988828), FRAC_CONST(0.999717347532362) },
+ { FRAC_CONST(0.017639864115082), FRAC_CONST(0.999844405492175) },
+ { FRAC_CONST(0.011504602110423), FRAC_CONST(0.999933819875236) },
+ { FRAC_CONST(0.005368906963996), FRAC_CONST(0.999985587315143) }
+ };
+#endif // LD_DEC
+
+#ifdef ALLOW_SMALL_FRAMELENGTH
+ /* 480 (N/4) complex twiddle factors */
+ ALIGN static const complex_t mdct_tab_1920[] = {
+ { FRAC_CONST(0.999999916334328), FRAC_CONST(0.000409061532028) },
+ { FRAC_CONST(0.999993223088129), FRAC_CONST(0.003681545574400) },
+ { FRAC_CONST(0.999975820717897), FRAC_CONST(0.006953990190376) },
+ { FRAC_CONST(0.999947709409999), FRAC_CONST(0.010226360334704) },
+ { FRAC_CONST(0.999908889465485), FRAC_CONST(0.013498620962929) },
+ { FRAC_CONST(0.999859361300084), FRAC_CONST(0.016770737031768) },
+ { FRAC_CONST(0.999799125444203), FRAC_CONST(0.020042673499487) },
+ { FRAC_CONST(0.999728182542920), FRAC_CONST(0.023314395326274) },
+ { FRAC_CONST(0.999646533355977), FRAC_CONST(0.026585867474619) },
+ { FRAC_CONST(0.999554178757770), FRAC_CONST(0.029857054909681) },
+ { FRAC_CONST(0.999451119737344), FRAC_CONST(0.033127922599673) },
+ { FRAC_CONST(0.999337357398377), FRAC_CONST(0.036398435516228) },
+ { FRAC_CONST(0.999212892959173), FRAC_CONST(0.039668558634781) },
+ { FRAC_CONST(0.999077727752645), FRAC_CONST(0.042938256934941) },
+ { FRAC_CONST(0.998931863226306), FRAC_CONST(0.046207495400865) },
+ { FRAC_CONST(0.998775300942246), FRAC_CONST(0.049476239021636) },
+ { FRAC_CONST(0.998608042577122), FRAC_CONST(0.052744452791636) },
+ { FRAC_CONST(0.998430089922136), FRAC_CONST(0.056012101710921) },
+ { FRAC_CONST(0.998241444883019), FRAC_CONST(0.059279150785597) },
+ { FRAC_CONST(0.998042109480008), FRAC_CONST(0.062545565028192) },
+ { FRAC_CONST(0.997832085847824), FRAC_CONST(0.065811309458034) },
+ { FRAC_CONST(0.997611376235651), FRAC_CONST(0.069076349101624) },
+ { FRAC_CONST(0.997379983007114), FRAC_CONST(0.072340648993011) },
+ { FRAC_CONST(0.997137908640245), FRAC_CONST(0.075604174174166) },
+ { FRAC_CONST(0.996885155727469), FRAC_CONST(0.078866889695354) },
+ { FRAC_CONST(0.996621726975566), FRAC_CONST(0.082128760615515) },
+ { FRAC_CONST(0.996347625205645), FRAC_CONST(0.085389752002632) },
+ { FRAC_CONST(0.996062853353117), FRAC_CONST(0.088649828934106) },
+ { FRAC_CONST(0.995767414467660), FRAC_CONST(0.091908956497133) },
+ { FRAC_CONST(0.995461311713186), FRAC_CONST(0.095167099789075) },
+ { FRAC_CONST(0.995144548367810), FRAC_CONST(0.098424223917834) },
+ { FRAC_CONST(0.994817127823813), FRAC_CONST(0.101680294002229) },
+ { FRAC_CONST(0.994479053587606), FRAC_CONST(0.104935275172364) },
+ { FRAC_CONST(0.994130329279692), FRAC_CONST(0.108189132570007) },
+ { FRAC_CONST(0.993770958634630), FRAC_CONST(0.111441831348957) },
+ { FRAC_CONST(0.993400945500988), FRAC_CONST(0.114693336675426) },
+ { FRAC_CONST(0.993020293841312), FRAC_CONST(0.117943613728403) },
+ { FRAC_CONST(0.992629007732074), FRAC_CONST(0.121192627700032) },
+ { FRAC_CONST(0.992227091363634), FRAC_CONST(0.124440343795983) },
+ { FRAC_CONST(0.991814549040194), FRAC_CONST(0.127686727235827) },
+ { FRAC_CONST(0.991391385179751), FRAC_CONST(0.130931743253405) },
+ { FRAC_CONST(0.990957604314048), FRAC_CONST(0.134175357097202) },
+ { FRAC_CONST(0.990513211088533), FRAC_CONST(0.137417534030720) },
+ { FRAC_CONST(0.990058210262297), FRAC_CONST(0.140658239332849) },
+ { FRAC_CONST(0.989592606708036), FRAC_CONST(0.143897438298239) },
+ { FRAC_CONST(0.989116405411988), FRAC_CONST(0.147135096237670) },
+ { FRAC_CONST(0.988629611473887), FRAC_CONST(0.150371178478428) },
+ { FRAC_CONST(0.988132230106905), FRAC_CONST(0.153605650364672) },
+ { FRAC_CONST(0.987624266637598), FRAC_CONST(0.156838477257806) },
+ { FRAC_CONST(0.987105726505845), FRAC_CONST(0.160069624536852) },
+ { FRAC_CONST(0.986576615264794), FRAC_CONST(0.163299057598817) },
+ { FRAC_CONST(0.986036938580803), FRAC_CONST(0.166526741859069) },
+ { FRAC_CONST(0.985486702233375), FRAC_CONST(0.169752642751702) },
+ { FRAC_CONST(0.984925912115099), FRAC_CONST(0.172976725729910) },
+ { FRAC_CONST(0.984354574231587), FRAC_CONST(0.176198956266353) },
+ { FRAC_CONST(0.983772694701407), FRAC_CONST(0.179419299853531) },
+ { FRAC_CONST(0.983180279756024), FRAC_CONST(0.182637722004152) },
+ { FRAC_CONST(0.982577335739725), FRAC_CONST(0.185854188251500) },
+ { FRAC_CONST(0.981963869109555), FRAC_CONST(0.189068664149806) },
+ { FRAC_CONST(0.981339886435250), FRAC_CONST(0.192281115274616) },
+ { FRAC_CONST(0.980705394399163), FRAC_CONST(0.195491507223158) },
+ { FRAC_CONST(0.980060399796194), FRAC_CONST(0.198699805614714) },
+ { FRAC_CONST(0.979404909533716), FRAC_CONST(0.201905976090986) },
+ { FRAC_CONST(0.978738930631504), FRAC_CONST(0.205109984316464) },
+ { FRAC_CONST(0.978062470221657), FRAC_CONST(0.208311795978794) },
+ { FRAC_CONST(0.977375535548522), FRAC_CONST(0.211511376789145) },
+ { FRAC_CONST(0.976678133968618), FRAC_CONST(0.214708692482577) },
+ { FRAC_CONST(0.975970272950556), FRAC_CONST(0.217903708818409) },
+ { FRAC_CONST(0.975251960074958), FRAC_CONST(0.221096391580581) },
+ { FRAC_CONST(0.974523203034377), FRAC_CONST(0.224286706578026) },
+ { FRAC_CONST(0.973784009633218), FRAC_CONST(0.227474619645035) },
+ { FRAC_CONST(0.973034387787646), FRAC_CONST(0.230660096641619) },
+ { FRAC_CONST(0.972274345525510), FRAC_CONST(0.233843103453878) },
+ { FRAC_CONST(0.971503890986252), FRAC_CONST(0.237023605994367) },
+ { FRAC_CONST(0.970723032420820), FRAC_CONST(0.240201570202459) },
+ { FRAC_CONST(0.969931778191584), FRAC_CONST(0.243376962044711) },
+ { FRAC_CONST(0.969130136772239), FRAC_CONST(0.246549747515226) },
+ { FRAC_CONST(0.968318116747721), FRAC_CONST(0.249719892636022) },
+ { FRAC_CONST(0.967495726814114), FRAC_CONST(0.252887363457390) },
+ { FRAC_CONST(0.966662975778551), FRAC_CONST(0.256052126058264) },
+ { FRAC_CONST(0.965819872559127), FRAC_CONST(0.259214146546579) },
+ { FRAC_CONST(0.964966426184802), FRAC_CONST(0.262373391059634) },
+ { FRAC_CONST(0.964102645795299), FRAC_CONST(0.265529825764461) },
+ { FRAC_CONST(0.963228540641012), FRAC_CONST(0.268683416858178) },
+ { FRAC_CONST(0.962344120082907), FRAC_CONST(0.271834130568359) },
+ { FRAC_CONST(0.961449393592416), FRAC_CONST(0.274981933153391) },
+ { FRAC_CONST(0.960544370751341), FRAC_CONST(0.278126790902837) },
+ { FRAC_CONST(0.959629061251750), FRAC_CONST(0.281268670137799) },
+ { FRAC_CONST(0.958703474895872), FRAC_CONST(0.284407537211272) },
+ { FRAC_CONST(0.957767621595993), FRAC_CONST(0.287543358508512) },
+ { FRAC_CONST(0.956821511374351), FRAC_CONST(0.290676100447394) },
+ { FRAC_CONST(0.955865154363025), FRAC_CONST(0.293805729478766) },
+ { FRAC_CONST(0.954898560803832), FRAC_CONST(0.296932212086818) },
+ { FRAC_CONST(0.953921741048211), FRAC_CONST(0.300055514789431) },
+ { FRAC_CONST(0.952934705557117), FRAC_CONST(0.303175604138543) },
+ { FRAC_CONST(0.951937464900908), FRAC_CONST(0.306292446720504) },
+ { FRAC_CONST(0.950930029759229), FRAC_CONST(0.309406009156434) },
+ { FRAC_CONST(0.949912410920903), FRAC_CONST(0.312516258102580) },
+ { FRAC_CONST(0.948884619283808), FRAC_CONST(0.315623160250676) },
+ { FRAC_CONST(0.947846665854767), FRAC_CONST(0.318726682328294) },
+ { FRAC_CONST(0.946798561749429), FRAC_CONST(0.321826791099207) },
+ { FRAC_CONST(0.945740318192145), FRAC_CONST(0.324923453363742) },
+ { FRAC_CONST(0.944671946515855), FRAC_CONST(0.328016635959131) },
+ { FRAC_CONST(0.943593458161960), FRAC_CONST(0.331106305759876) },
+ { FRAC_CONST(0.942504864680205), FRAC_CONST(0.334192429678095) },
+ { FRAC_CONST(0.941406177728551), FRAC_CONST(0.337274974663880) },
+ { FRAC_CONST(0.940297409073052), FRAC_CONST(0.340353907705650) },
+ { FRAC_CONST(0.939178570587730), FRAC_CONST(0.343429195830507) },
+ { FRAC_CONST(0.938049674254446), FRAC_CONST(0.346500806104585) },
+ { FRAC_CONST(0.936910732162774), FRAC_CONST(0.349568705633406) },
+ { FRAC_CONST(0.935761756509868), FRAC_CONST(0.352632861562230) },
+ { FRAC_CONST(0.934602759600334), FRAC_CONST(0.355693241076410) },
+ { FRAC_CONST(0.933433753846097), FRAC_CONST(0.358749811401739) },
+ { FRAC_CONST(0.932254751766271), FRAC_CONST(0.361802539804806) },
+ { FRAC_CONST(0.931065765987021), FRAC_CONST(0.364851393593340) },
+ { FRAC_CONST(0.929866809241428), FRAC_CONST(0.367896340116568) },
+ { FRAC_CONST(0.928657894369357), FRAC_CONST(0.370937346765559) },
+ { FRAC_CONST(0.927439034317314), FRAC_CONST(0.373974380973575) },
+ { FRAC_CONST(0.926210242138311), FRAC_CONST(0.377007410216418) },
+ { FRAC_CONST(0.924971530991726), FRAC_CONST(0.380036402012783) },
+ { FRAC_CONST(0.923722914143160), FRAC_CONST(0.383061323924602) },
+ { FRAC_CONST(0.922464404964295), FRAC_CONST(0.386082143557389) },
+ { FRAC_CONST(0.921196016932755), FRAC_CONST(0.389098828560595) },
+ { FRAC_CONST(0.919917763631956), FRAC_CONST(0.392111346627946) },
+ { FRAC_CONST(0.918629658750963), FRAC_CONST(0.395119665497795) },
+ { FRAC_CONST(0.917331716084346), FRAC_CONST(0.398123752953462) },
+ { FRAC_CONST(0.916023949532027), FRAC_CONST(0.401123576823585) },
+ { FRAC_CONST(0.914706373099136), FRAC_CONST(0.404119104982459) },
+ { FRAC_CONST(0.913379000895858), FRAC_CONST(0.407110305350386) },
+ { FRAC_CONST(0.912041847137282), FRAC_CONST(0.410097145894012) },
+ { FRAC_CONST(0.910694926143251), FRAC_CONST(0.413079594626675) },
+ { FRAC_CONST(0.909338252338207), FRAC_CONST(0.416057619608744) },
+ { FRAC_CONST(0.907971840251037), FRAC_CONST(0.419031188947965) },
+ { FRAC_CONST(0.906595704514915), FRAC_CONST(0.422000270799800) },
+ { FRAC_CONST(0.905209859867151), FRAC_CONST(0.424964833367766) },
+ { FRAC_CONST(0.903814321149027), FRAC_CONST(0.427924844903780) },
+ { FRAC_CONST(0.902409103305641), FRAC_CONST(0.430880273708497) },
+ { FRAC_CONST(0.900994221385748), FRAC_CONST(0.433831088131649) },
+ { FRAC_CONST(0.899569690541596), FRAC_CONST(0.436777256572384) },
+ { FRAC_CONST(0.898135526028766), FRAC_CONST(0.439718747479604) },
+ { FRAC_CONST(0.896691743206008), FRAC_CONST(0.442655529352306) },
+ { FRAC_CONST(0.895238357535076), FRAC_CONST(0.445587570739915) },
+ { FRAC_CONST(0.893775384580563), FRAC_CONST(0.448514840242624) },
+ { FRAC_CONST(0.892302840009734), FRAC_CONST(0.451437306511726) },
+ { FRAC_CONST(0.890820739592359), FRAC_CONST(0.454354938249958) },
+ { FRAC_CONST(0.889329099200541), FRAC_CONST(0.457267704211826) },
+ { FRAC_CONST(0.887827934808551), FRAC_CONST(0.460175573203949) },
+ { FRAC_CONST(0.886317262492655), FRAC_CONST(0.463078514085383) },
+ { FRAC_CONST(0.884797098430938), FRAC_CONST(0.465976495767966) },
+ { FRAC_CONST(0.883267458903136), FRAC_CONST(0.468869487216642) },
+ { FRAC_CONST(0.881728360290461), FRAC_CONST(0.471757457449795) },
+ { FRAC_CONST(0.880179819075421), FRAC_CONST(0.474640375539586) },
+ { FRAC_CONST(0.878621851841649), FRAC_CONST(0.477518210612278) },
+ { FRAC_CONST(0.877054475273722), FRAC_CONST(0.480390931848569) },
+ { FRAC_CONST(0.875477706156984), FRAC_CONST(0.483258508483922) },
+ { FRAC_CONST(0.873891561377366), FRAC_CONST(0.486120909808896) },
+ { FRAC_CONST(0.872296057921204), FRAC_CONST(0.488978105169472) },
+ { FRAC_CONST(0.870691212875058), FRAC_CONST(0.491830063967383) },
+ { FRAC_CONST(0.869077043425529), FRAC_CONST(0.494676755660442) },
+ { FRAC_CONST(0.867453566859076), FRAC_CONST(0.497518149762867) },
+ { FRAC_CONST(0.865820800561827), FRAC_CONST(0.500354215845611) },
+ { FRAC_CONST(0.864178762019399), FRAC_CONST(0.503184923536685) },
+ { FRAC_CONST(0.862527468816704), FRAC_CONST(0.506010242521482) },
+ { FRAC_CONST(0.860866938637767), FRAC_CONST(0.508830142543107) },
+ { FRAC_CONST(0.859197189265532), FRAC_CONST(0.511644593402696) },
+ { FRAC_CONST(0.857518238581672), FRAC_CONST(0.514453564959741) },
+ { FRAC_CONST(0.855830104566401), FRAC_CONST(0.517257027132414) },
+ { FRAC_CONST(0.854132805298278), FRAC_CONST(0.520054949897887) },
+ { FRAC_CONST(0.852426358954015), FRAC_CONST(0.522847303292655) },
+ { FRAC_CONST(0.850710783808280), FRAC_CONST(0.525634057412856) },
+ { FRAC_CONST(0.848986098233506), FRAC_CONST(0.528415182414593) },
+ { FRAC_CONST(0.847252320699689), FRAC_CONST(0.531190648514252) },
+ { FRAC_CONST(0.845509469774194), FRAC_CONST(0.533960425988819) },
+ { FRAC_CONST(0.843757564121554), FRAC_CONST(0.536724485176205) },
+ { FRAC_CONST(0.841996622503271), FRAC_CONST(0.539482796475555) },
+ { FRAC_CONST(0.840226663777615), FRAC_CONST(0.542235330347571) },
+ { FRAC_CONST(0.838447706899422), FRAC_CONST(0.544982057314827) },
+ { FRAC_CONST(0.836659770919891), FRAC_CONST(0.547722947962084) },
+ { FRAC_CONST(0.834862874986380), FRAC_CONST(0.550457972936605) },
+ { FRAC_CONST(0.833057038342201), FRAC_CONST(0.553187102948470) },
+ { FRAC_CONST(0.831242280326413), FRAC_CONST(0.555910308770889) },
+ { FRAC_CONST(0.829418620373617), FRAC_CONST(0.558627561240515) },
+ { FRAC_CONST(0.827586078013746), FRAC_CONST(0.561338831257758) },
+ { FRAC_CONST(0.825744672871856), FRAC_CONST(0.564044089787093) },
+ { FRAC_CONST(0.823894424667918), FRAC_CONST(0.566743307857377) },
+ { FRAC_CONST(0.822035353216601), FRAC_CONST(0.569436456562150) },
+ { FRAC_CONST(0.820167478427070), FRAC_CONST(0.572123507059955) },
+ { FRAC_CONST(0.818290820302761), FRAC_CONST(0.574804430574639) },
+ { FRAC_CONST(0.816405398941175), FRAC_CONST(0.577479198395666) },
+ { FRAC_CONST(0.814511234533661), FRAC_CONST(0.580147781878420) },
+ { FRAC_CONST(0.812608347365198), FRAC_CONST(0.582810152444517) },
+ { FRAC_CONST(0.810696757814178), FRAC_CONST(0.585466281582107) },
+ { FRAC_CONST(0.808776486352191), FRAC_CONST(0.588116140846181) },
+ { FRAC_CONST(0.806847553543799), FRAC_CONST(0.590759701858874) },
+ { FRAC_CONST(0.804909980046325), FRAC_CONST(0.593396936309773) },
+ { FRAC_CONST(0.802963786609623), FRAC_CONST(0.596027815956215) },
+ { FRAC_CONST(0.801008994075862), FRAC_CONST(0.598652312623592) },
+ { FRAC_CONST(0.799045623379300), FRAC_CONST(0.601270398205654) },
+ { FRAC_CONST(0.797073695546059), FRAC_CONST(0.603882044664808) },
+ { FRAC_CONST(0.795093231693901), FRAC_CONST(0.606487224032418) },
+ { FRAC_CONST(0.793104253032005), FRAC_CONST(0.609085908409106) },
+ { FRAC_CONST(0.791106780860733), FRAC_CONST(0.611678069965050) },
+ { FRAC_CONST(0.789100836571407), FRAC_CONST(0.614263680940283) },
+ { FRAC_CONST(0.787086441646080), FRAC_CONST(0.616842713644988) },
+ { FRAC_CONST(0.785063617657302), FRAC_CONST(0.619415140459796) },
+ { FRAC_CONST(0.783032386267894), FRAC_CONST(0.621980933836084) },
+ { FRAC_CONST(0.780992769230711), FRAC_CONST(0.624540066296266) },
+ { FRAC_CONST(0.778944788388414), FRAC_CONST(0.627092510434089) },
+ { FRAC_CONST(0.776888465673232), FRAC_CONST(0.629638238914927) },
+ { FRAC_CONST(0.774823823106730), FRAC_CONST(0.632177224476073) },
+ { FRAC_CONST(0.772750882799570), FRAC_CONST(0.634709439927031) },
+ { FRAC_CONST(0.770669666951277), FRAC_CONST(0.637234858149809) },
+ { FRAC_CONST(0.768580197850002), FRAC_CONST(0.639753452099206) },
+ { FRAC_CONST(0.766482497872280), FRAC_CONST(0.642265194803105) },
+ { FRAC_CONST(0.764376589482793), FRAC_CONST(0.644770059362758) },
+ { FRAC_CONST(0.762262495234126), FRAC_CONST(0.647268018953079) },
+ { FRAC_CONST(0.760140237766532), FRAC_CONST(0.649759046822928) },
+ { FRAC_CONST(0.758009839807683), FRAC_CONST(0.652243116295397) },
+ { FRAC_CONST(0.755871324172429), FRAC_CONST(0.654720200768098) },
+ { FRAC_CONST(0.753724713762555), FRAC_CONST(0.657190273713446) },
+ { FRAC_CONST(0.751570031566534), FRAC_CONST(0.659653308678945) },
+ { FRAC_CONST(0.749407300659280), FRAC_CONST(0.662109279287469) },
+ { FRAC_CONST(0.747236544201905), FRAC_CONST(0.664558159237545) },
+ { FRAC_CONST(0.745057785441466), FRAC_CONST(0.666999922303638) },
+ { FRAC_CONST(0.742871047710719), FRAC_CONST(0.669434542336425) },
+ { FRAC_CONST(0.740676354427868), FRAC_CONST(0.671861993263083) },
+ { FRAC_CONST(0.738473729096316), FRAC_CONST(0.674282249087562) },
+ { FRAC_CONST(0.736263195304409), FRAC_CONST(0.676695283890867) },
+ { FRAC_CONST(0.734044776725190), FRAC_CONST(0.679101071831334) },
+ { FRAC_CONST(0.731818497116138), FRAC_CONST(0.681499587144906) },
+ { FRAC_CONST(0.729584380318920), FRAC_CONST(0.683890804145412) },
+ { FRAC_CONST(0.727342450259131), FRAC_CONST(0.686274697224838) },
+ { FRAC_CONST(0.725092730946042), FRAC_CONST(0.688651240853606) },
+ { FRAC_CONST(0.722835246472338), FRAC_CONST(0.691020409580841) },
+ { FRAC_CONST(0.720570021013866), FRAC_CONST(0.693382178034651) },
+ { FRAC_CONST(0.718297078829369), FRAC_CONST(0.695736520922392) },
+ { FRAC_CONST(0.716016444260233), FRAC_CONST(0.698083413030944) },
+ { FRAC_CONST(0.713728141730222), FRAC_CONST(0.700422829226978) },
+ { FRAC_CONST(0.711432195745216), FRAC_CONST(0.702754744457225) },
+ { FRAC_CONST(0.709128630892954), FRAC_CONST(0.705079133748748) },
+ { FRAC_CONST(0.706817471842764), FRAC_CONST(0.707395972209203) },
+ { FRAC_CONST(0.704498743345302), FRAC_CONST(0.709705235027113) },
+ { FRAC_CONST(0.702172470232289), FRAC_CONST(0.712006897472128) },
+ { FRAC_CONST(0.699838677416240), FRAC_CONST(0.714300934895292) },
+ { FRAC_CONST(0.697497389890200), FRAC_CONST(0.716587322729308) },
+ { FRAC_CONST(0.695148632727480), FRAC_CONST(0.718866036488799) },
+ { FRAC_CONST(0.692792431081381), FRAC_CONST(0.721137051770570) },
+ { FRAC_CONST(0.690428810184929), FRAC_CONST(0.723400344253874) },
+ { FRAC_CONST(0.688057795350606), FRAC_CONST(0.725655889700665) },
+ { FRAC_CONST(0.685679411970075), FRAC_CONST(0.727903663955865) },
+ { FRAC_CONST(0.683293685513912), FRAC_CONST(0.730143642947616) },
+ { FRAC_CONST(0.680900641531330), FRAC_CONST(0.732375802687543) },
+ { FRAC_CONST(0.678500305649909), FRAC_CONST(0.734600119271009) },
+ { FRAC_CONST(0.676092703575316), FRAC_CONST(0.736816568877370) },
+ { FRAC_CONST(0.673677861091036), FRAC_CONST(0.739025127770231) },
+ { FRAC_CONST(0.671255804058092), FRAC_CONST(0.741225772297702) },
+ { FRAC_CONST(0.668826558414768), FRAC_CONST(0.743418478892647) },
+ { FRAC_CONST(0.666390150176334), FRAC_CONST(0.745603224072940) },
+ { FRAC_CONST(0.663946605434765), FRAC_CONST(0.747779984441716) },
+ { FRAC_CONST(0.661495950358462), FRAC_CONST(0.749948736687619) },
+ { FRAC_CONST(0.659038211191971), FRAC_CONST(0.752109457585056) },
+ { FRAC_CONST(0.656573414255705), FRAC_CONST(0.754262123994441) },
+ { FRAC_CONST(0.654101585945659), FRAC_CONST(0.756406712862448) },
+ { FRAC_CONST(0.651622752733128), FRAC_CONST(0.758543201222251) },
+ { FRAC_CONST(0.649136941164425), FRAC_CONST(0.760671566193777) },
+ { FRAC_CONST(0.646644177860593), FRAC_CONST(0.762791784983948) },
+ { FRAC_CONST(0.644144489517126), FRAC_CONST(0.764903834886923) },
+ { FRAC_CONST(0.641637902903677), FRAC_CONST(0.767007693284345) },
+ { FRAC_CONST(0.639124444863776), FRAC_CONST(0.769103337645580) },
+ { FRAC_CONST(0.636604142314538), FRAC_CONST(0.771190745527961) },
+ { FRAC_CONST(0.634077022246379), FRAC_CONST(0.773269894577026) },
+ { FRAC_CONST(0.631543111722725), FRAC_CONST(0.775340762526760) },
+ { FRAC_CONST(0.629002437879721), FRAC_CONST(0.777403327199831) },
+ { FRAC_CONST(0.626455027925944), FRAC_CONST(0.779457566507828) },
+ { FRAC_CONST(0.623900909142107), FRAC_CONST(0.781503458451498) },
+ { FRAC_CONST(0.621340108880771), FRAC_CONST(0.783540981120982) },
+ { FRAC_CONST(0.618772654566049), FRAC_CONST(0.785570112696050) },
+ { FRAC_CONST(0.616198573693314), FRAC_CONST(0.787590831446332) },
+ { FRAC_CONST(0.613617893828905), FRAC_CONST(0.789603115731555) },
+ { FRAC_CONST(0.611030642609828), FRAC_CONST(0.791606944001769) },
+ { FRAC_CONST(0.608436847743468), FRAC_CONST(0.793602294797585) },
+ { FRAC_CONST(0.605836537007281), FRAC_CONST(0.795589146750397) },
+ { FRAC_CONST(0.603229738248508), FRAC_CONST(0.797567478582619) },
+ { FRAC_CONST(0.600616479383869), FRAC_CONST(0.799537269107905) },
+ { FRAC_CONST(0.597996788399267), FRAC_CONST(0.801498497231381) },
+ { FRAC_CONST(0.595370693349487), FRAC_CONST(0.803451141949871) },
+ { FRAC_CONST(0.592738222357898), FRAC_CONST(0.805395182352117) },
+ { FRAC_CONST(0.590099403616149), FRAC_CONST(0.807330597619008) },
+ { FRAC_CONST(0.587454265383869), FRAC_CONST(0.809257367023803) },
+ { FRAC_CONST(0.584802835988364), FRAC_CONST(0.811175469932349) },
+ { FRAC_CONST(0.582145143824311), FRAC_CONST(0.813084885803304) },
+ { FRAC_CONST(0.579481217353460), FRAC_CONST(0.814985594188359) },
+ { FRAC_CONST(0.576811085104321), FRAC_CONST(0.816877574732454) },
+ { FRAC_CONST(0.574134775671867), FRAC_CONST(0.818760807173997) },
+ { FRAC_CONST(0.571452317717222), FRAC_CONST(0.820635271345081) },
+ { FRAC_CONST(0.568763739967354), FRAC_CONST(0.822500947171703) },
+ { FRAC_CONST(0.566069071214772), FRAC_CONST(0.824357814673971) },
+ { FRAC_CONST(0.563368340317214), FRAC_CONST(0.826205853966327) },
+ { FRAC_CONST(0.560661576197336), FRAC_CONST(0.828045045257756) },
+ { FRAC_CONST(0.557948807842409), FRAC_CONST(0.829875368851995) },
+ { FRAC_CONST(0.555230064304002), FRAC_CONST(0.831696805147750) },
+ { FRAC_CONST(0.552505374697674), FRAC_CONST(0.833509334638900) },
+ { FRAC_CONST(0.549774768202663), FRAC_CONST(0.835312937914713) },
+ { FRAC_CONST(0.547038274061568), FRAC_CONST(0.837107595660044) },
+ { FRAC_CONST(0.544295921580046), FRAC_CONST(0.838893288655553) },
+ { FRAC_CONST(0.541547740126486), FRAC_CONST(0.840669997777901) },
+ { FRAC_CONST(0.538793759131706), FRAC_CONST(0.842437703999961) },
+ { FRAC_CONST(0.536034008088628), FRAC_CONST(0.844196388391019) },
+ { FRAC_CONST(0.533268516551970), FRAC_CONST(0.845946032116980) },
+ { FRAC_CONST(0.530497314137923), FRAC_CONST(0.847686616440563) },
+ { FRAC_CONST(0.527720430523840), FRAC_CONST(0.849418122721510) },
+ { FRAC_CONST(0.524937895447912), FRAC_CONST(0.851140532416778) },
+ { FRAC_CONST(0.522149738708856), FRAC_CONST(0.852853827080745) },
+ { FRAC_CONST(0.519355990165590), FRAC_CONST(0.854557988365401) },
+ { FRAC_CONST(0.516556679736915), FRAC_CONST(0.856252998020546) },
+ { FRAC_CONST(0.513751837401199), FRAC_CONST(0.857938837893991) },
+ { FRAC_CONST(0.510941493196049), FRAC_CONST(0.859615489931744) },
+ { FRAC_CONST(0.508125677217994), FRAC_CONST(0.861282936178208) },
+ { FRAC_CONST(0.505304419622159), FRAC_CONST(0.862941158776375) },
+ { FRAC_CONST(0.502477750621949), FRAC_CONST(0.864590139968012) },
+ { FRAC_CONST(0.499645700488717), FRAC_CONST(0.866229862093855) },
+ { FRAC_CONST(0.496808299551444), FRAC_CONST(0.867860307593799) },
+ { FRAC_CONST(0.493965578196415), FRAC_CONST(0.869481459007080) },
+ { FRAC_CONST(0.491117566866892), FRAC_CONST(0.871093298972471) },
+ { FRAC_CONST(0.488264296062789), FRAC_CONST(0.872695810228461) },
+ { FRAC_CONST(0.485405796340343), FRAC_CONST(0.874288975613440) },
+ { FRAC_CONST(0.482542098311789), FRAC_CONST(0.875872778065888) },
+ { FRAC_CONST(0.479673232645033), FRAC_CONST(0.877447200624553) },
+ { FRAC_CONST(0.476799230063322), FRAC_CONST(0.879012226428633) },
+ { FRAC_CONST(0.473920121344914), FRAC_CONST(0.880567838717962) },
+ { FRAC_CONST(0.471035937322751), FRAC_CONST(0.882114020833179) },
+ { FRAC_CONST(0.468146708884125), FRAC_CONST(0.883650756215917) },
+ { FRAC_CONST(0.465252466970353), FRAC_CONST(0.885178028408975) },
+ { FRAC_CONST(0.462353242576441), FRAC_CONST(0.886695821056495) },
+ { FRAC_CONST(0.459449066750752), FRAC_CONST(0.888204117904136) },
+ { FRAC_CONST(0.456539970594675), FRAC_CONST(0.889702902799251) },
+ { FRAC_CONST(0.453625985262295), FRAC_CONST(0.891192159691058) },
+ { FRAC_CONST(0.450707141960053), FRAC_CONST(0.892671872630812) },
+ { FRAC_CONST(0.447783471946415), FRAC_CONST(0.894142025771977) },
+ { FRAC_CONST(0.444855006531538), FRAC_CONST(0.895602603370393) },
+ { FRAC_CONST(0.441921777076935), FRAC_CONST(0.897053589784447) },
+ { FRAC_CONST(0.438983814995137), FRAC_CONST(0.898494969475242) },
+ { FRAC_CONST(0.436041151749356), FRAC_CONST(0.899926727006758) },
+ { FRAC_CONST(0.433093818853152), FRAC_CONST(0.901348847046022) },
+ { FRAC_CONST(0.430141847870093), FRAC_CONST(0.902761314363272) },
+ { FRAC_CONST(0.427185270413416), FRAC_CONST(0.904164113832116) },
+ { FRAC_CONST(0.424224118145690), FRAC_CONST(0.905557230429701) },
+ { FRAC_CONST(0.421258422778478), FRAC_CONST(0.906940649236866) },
+ { FRAC_CONST(0.418288216071994), FRAC_CONST(0.908314355438308) },
+ { FRAC_CONST(0.415313529834766), FRAC_CONST(0.909678334322736) },
+ { FRAC_CONST(0.412334395923293), FRAC_CONST(0.911032571283032) },
+ { FRAC_CONST(0.409350846241706), FRAC_CONST(0.912377051816407) },
+ { FRAC_CONST(0.406362912741425), FRAC_CONST(0.913711761524555) },
+ { FRAC_CONST(0.403370627420818), FRAC_CONST(0.915036686113806) },
+ { FRAC_CONST(0.400374022324857), FRAC_CONST(0.916351811395282) },
+ { FRAC_CONST(0.397373129544774), FRAC_CONST(0.917657123285050) },
+ { FRAC_CONST(0.394367981217720), FRAC_CONST(0.918952607804266) },
+ { FRAC_CONST(0.391358609526420), FRAC_CONST(0.920238251079332) },
+ { FRAC_CONST(0.388345046698826), FRAC_CONST(0.921514039342042) },
+ { FRAC_CONST(0.385327325007776), FRAC_CONST(0.922779958929729) },
+ { FRAC_CONST(0.382305476770645), FRAC_CONST(0.924035996285410) },
+ { FRAC_CONST(0.379279534348999), FRAC_CONST(0.925282137957935) },
+ { FRAC_CONST(0.376249530148250), FRAC_CONST(0.926518370602127) },
+ { FRAC_CONST(0.373215496617310), FRAC_CONST(0.927744680978929) },
+ { FRAC_CONST(0.370177466248239), FRAC_CONST(0.928961055955541) },
+ { FRAC_CONST(0.367135471575903), FRAC_CONST(0.930167482505564) },
+ { FRAC_CONST(0.364089545177621), FRAC_CONST(0.931363947709140) },
+ { FRAC_CONST(0.361039719672816), FRAC_CONST(0.932550438753087) },
+ { FRAC_CONST(0.357986027722671), FRAC_CONST(0.933726942931039) },
+ { FRAC_CONST(0.354928502029772), FRAC_CONST(0.934893447643582) },
+ { FRAC_CONST(0.351867175337763), FRAC_CONST(0.936049940398387) },
+ { FRAC_CONST(0.348802080430994), FRAC_CONST(0.937196408810347) },
+ { FRAC_CONST(0.345733250134169), FRAC_CONST(0.938332840601705) },
+ { FRAC_CONST(0.342660717311994), FRAC_CONST(0.939459223602190) },
+ { FRAC_CONST(0.339584514868829), FRAC_CONST(0.940575545749145) },
+ { FRAC_CONST(0.336504675748328), FRAC_CONST(0.941681795087657) },
+ { FRAC_CONST(0.333421232933097), FRAC_CONST(0.942777959770684) },
+ { FRAC_CONST(0.330334219444328), FRAC_CONST(0.943864028059183) },
+ { FRAC_CONST(0.327243668341457), FRAC_CONST(0.944939988322235) },
+ { FRAC_CONST(0.324149612721804), FRAC_CONST(0.946005829037171) },
+ { FRAC_CONST(0.321052085720218), FRAC_CONST(0.947061538789691) },
+ { FRAC_CONST(0.317951120508725), FRAC_CONST(0.948107106273994) },
+ { FRAC_CONST(0.314846750296171), FRAC_CONST(0.949142520292891) },
+ { FRAC_CONST(0.311739008327867), FRAC_CONST(0.950167769757930) },
+ { FRAC_CONST(0.308627927885232), FRAC_CONST(0.951182843689513) },
+ { FRAC_CONST(0.305513542285440), FRAC_CONST(0.952187731217013) },
+ { FRAC_CONST(0.302395884881056), FRAC_CONST(0.953182421578893) },
+ { FRAC_CONST(0.299274989059689), FRAC_CONST(0.954166904122818) },
+ { FRAC_CONST(0.296150888243624), FRAC_CONST(0.955141168305771) },
+ { FRAC_CONST(0.293023615889471), FRAC_CONST(0.956105203694164) },
+ { FRAC_CONST(0.289893205487806), FRAC_CONST(0.957058999963955) },
+ { FRAC_CONST(0.286759690562807), FRAC_CONST(0.958002546900750) },
+ { FRAC_CONST(0.283623104671904), FRAC_CONST(0.958935834399920) },
+ { FRAC_CONST(0.280483481405410), FRAC_CONST(0.959858852466706) },
+ { FRAC_CONST(0.277340854386169), FRAC_CONST(0.960771591216325) },
+ { FRAC_CONST(0.274195257269191), FRAC_CONST(0.961674040874080) },
+ { FRAC_CONST(0.271046723741295), FRAC_CONST(0.962566191775459) },
+ { FRAC_CONST(0.267895287520743), FRAC_CONST(0.963448034366243) },
+ { FRAC_CONST(0.264740982356888), FRAC_CONST(0.964319559202607) },
+ { FRAC_CONST(0.261583842029803), FRAC_CONST(0.965180756951218) },
+ { FRAC_CONST(0.258423900349924), FRAC_CONST(0.966031618389343) },
+ { FRAC_CONST(0.255261191157689), FRAC_CONST(0.966872134404937) },
+ { FRAC_CONST(0.252095748323171), FRAC_CONST(0.967702295996750) },
+ { FRAC_CONST(0.248927605745720), FRAC_CONST(0.968522094274417) },
+ { FRAC_CONST(0.245756797353599), FRAC_CONST(0.969331520458559) },
+ { FRAC_CONST(0.242583357103617), FRAC_CONST(0.970130565880871) },
+ { FRAC_CONST(0.239407318980770), FRAC_CONST(0.970919221984218) },
+ { FRAC_CONST(0.236228716997876), FRAC_CONST(0.971697480322728) },
+ { FRAC_CONST(0.233047585195206), FRAC_CONST(0.972465332561878) },
+ { FRAC_CONST(0.229863957640129), FRAC_CONST(0.973222770478587) },
+ { FRAC_CONST(0.226677868426735), FRAC_CONST(0.973969785961306) },
+ { FRAC_CONST(0.223489351675482), FRAC_CONST(0.974706371010097) },
+ { FRAC_CONST(0.220298441532823), FRAC_CONST(0.975432517736727) },
+ { FRAC_CONST(0.217105172170841), FRAC_CONST(0.976148218364747) },
+ { FRAC_CONST(0.213909577786886), FRAC_CONST(0.976853465229579) },
+ { FRAC_CONST(0.210711692603206), FRAC_CONST(0.977548250778596) },
+ { FRAC_CONST(0.207511550866582), FRAC_CONST(0.978232567571202) },
+ { FRAC_CONST(0.204309186847962), FRAC_CONST(0.978906408278914) },
+ { FRAC_CONST(0.201104634842092), FRAC_CONST(0.979569765685441) },
+ { FRAC_CONST(0.197897929167148), FRAC_CONST(0.980222632686756) },
+ { FRAC_CONST(0.194689104164373), FRAC_CONST(0.980865002291179) },
+ { FRAC_CONST(0.191478194197704), FRAC_CONST(0.981496867619447) },
+ { FRAC_CONST(0.188265233653407), FRAC_CONST(0.982118221904791) },
+ { FRAC_CONST(0.185050256939710), FRAC_CONST(0.982729058493005) },
+ { FRAC_CONST(0.181833298486427), FRAC_CONST(0.983329370842520) },
+ { FRAC_CONST(0.178614392744603), FRAC_CONST(0.983919152524473) },
+ { FRAC_CONST(0.175393574186129), FRAC_CONST(0.984498397222776) },
+ { FRAC_CONST(0.172170877303385), FRAC_CONST(0.985067098734184) },
+ { FRAC_CONST(0.168946336608867), FRAC_CONST(0.985625250968360) },
+ { FRAC_CONST(0.165719986634814), FRAC_CONST(0.986172847947943) },
+ { FRAC_CONST(0.162491861932842), FRAC_CONST(0.986709883808609) },
+ { FRAC_CONST(0.159261997073573), FRAC_CONST(0.987236352799134) },
+ { FRAC_CONST(0.156030426646266), FRAC_CONST(0.987752249281460) },
+ { FRAC_CONST(0.152797185258443), FRAC_CONST(0.988257567730749) },
+ { FRAC_CONST(0.149562307535523), FRAC_CONST(0.988752302735447) },
+ { FRAC_CONST(0.146325828120446), FRAC_CONST(0.989236448997339) },
+ { FRAC_CONST(0.143087781673307), FRAC_CONST(0.989710001331608) },
+ { FRAC_CONST(0.139848202870981), FRAC_CONST(0.990172954666889) },
+ { FRAC_CONST(0.136607126406757), FRAC_CONST(0.990625304045323) },
+ { FRAC_CONST(0.133364586989957), FRAC_CONST(0.991067044622612) },
+ { FRAC_CONST(0.130120619345575), FRAC_CONST(0.991498171668069) },
+ { FRAC_CONST(0.126875258213898), FRAC_CONST(0.991918680564670) },
+ { FRAC_CONST(0.123628538350136), FRAC_CONST(0.992328566809103) },
+ { FRAC_CONST(0.120380494524051), FRAC_CONST(0.992727826011815) },
+ { FRAC_CONST(0.117131161519582), FRAC_CONST(0.993116453897061) },
+ { FRAC_CONST(0.113880574134475), FRAC_CONST(0.993494446302948) },
+ { FRAC_CONST(0.110628767179910), FRAC_CONST(0.993861799181482) },
+ { FRAC_CONST(0.107375775480128), FRAC_CONST(0.994218508598608) },
+ { FRAC_CONST(0.104121633872055), FRAC_CONST(0.994564570734255) },
+ { FRAC_CONST(0.100866377204933), FRAC_CONST(0.994899981882376) },
+ { FRAC_CONST(0.097610040339947), FRAC_CONST(0.995224738450986) },
+ { FRAC_CONST(0.094352658149849), FRAC_CONST(0.995538836962204) },
+ { FRAC_CONST(0.091094265518583), FRAC_CONST(0.995842274052287) },
+ { FRAC_CONST(0.087834897340919), FRAC_CONST(0.996135046471667) },
+ { FRAC_CONST(0.084574588522070), FRAC_CONST(0.996417151084987) },
+ { FRAC_CONST(0.081313373977324), FRAC_CONST(0.996688584871134) },
+ { FRAC_CONST(0.078051288631670), FRAC_CONST(0.996949344923269) },
+ { FRAC_CONST(0.074788367419420), FRAC_CONST(0.997199428448862) },
+ { FRAC_CONST(0.071524645283840), FRAC_CONST(0.997438832769720) },
+ { FRAC_CONST(0.068260157176771), FRAC_CONST(0.997667555322013) },
+ { FRAC_CONST(0.064994938058259), FRAC_CONST(0.997885593656308) },
+ { FRAC_CONST(0.061729022896176), FRAC_CONST(0.998092945437590) },
+ { FRAC_CONST(0.058462446665851), FRAC_CONST(0.998289608445286) },
+ { FRAC_CONST(0.055195244349690), FRAC_CONST(0.998475580573295) },
+ { FRAC_CONST(0.051927450936806), FRAC_CONST(0.998650859830004) },
+ { FRAC_CONST(0.048659101422640), FRAC_CONST(0.998815444338313) },
+ { FRAC_CONST(0.045390230808591), FRAC_CONST(0.998969332335654) },
+ { FRAC_CONST(0.042120874101635), FRAC_CONST(0.999112522174011) },
+ { FRAC_CONST(0.038851066313958), FRAC_CONST(0.999245012319936) },
+ { FRAC_CONST(0.035580842462574), FRAC_CONST(0.999366801354564) },
+ { FRAC_CONST(0.032310237568951), FRAC_CONST(0.999477887973635) },
+ { FRAC_CONST(0.029039286658643), FRAC_CONST(0.999578270987499) },
+ { FRAC_CONST(0.025768024760904), FRAC_CONST(0.999667949321134) },
+ { FRAC_CONST(0.022496486908322), FRAC_CONST(0.999746922014158) },
+ { FRAC_CONST(0.019224708136438), FRAC_CONST(0.999815188220837) },
+ { FRAC_CONST(0.015952723483375), FRAC_CONST(0.999872747210095) },
+ { FRAC_CONST(0.012680567989461), FRAC_CONST(0.999919598365521) },
+ { FRAC_CONST(0.009408276696850), FRAC_CONST(0.999955741185376) },
+ { FRAC_CONST(0.006135884649155), FRAC_CONST(0.999981175282601) },
+ { FRAC_CONST(0.002863426891064), FRAC_CONST(0.999995900384816) }
+ };
+
+#ifdef LD_DEC
+ /* 240 (N/4) complex twiddle factors */
+ ALIGN static const complex_t mdct_tab_960[] = {
+ { FRAC_CONST(0.999999665337326), FRAC_CONST(0.000818122995607) },
+ { FRAC_CONST(0.999972892444367), FRAC_CONST(0.007363041249780) },
+ { FRAC_CONST(0.999903284040864), FRAC_CONST(0.013907644095771) },
+ { FRAC_CONST(0.999790843108610), FRAC_CONST(0.020451651184577) },
+ { FRAC_CONST(0.999635574464198), FRAC_CONST(0.026994782192715) },
+ { FRAC_CONST(0.999437484758823), FRAC_CONST(0.033536756834230) },
+ { FRAC_CONST(0.999196582477986), FRAC_CONST(0.040077294872701) },
+ { FRAC_CONST(0.998912877941140), FRAC_CONST(0.046616116133247) },
+ { FRAC_CONST(0.998586383301244), FRAC_CONST(0.053152940514528) },
+ { FRAC_CONST(0.998217112544241), FRAC_CONST(0.059687488000744) },
+ { FRAC_CONST(0.997805081488460), FRAC_CONST(0.066219478673630) },
+ { FRAC_CONST(0.997350307783942), FRAC_CONST(0.072748632724445) },
+ { FRAC_CONST(0.996852810911678), FRAC_CONST(0.079274670465961) },
+ { FRAC_CONST(0.996312612182778), FRAC_CONST(0.085797312344440) },
+ { FRAC_CONST(0.995729734737558), FRAC_CONST(0.092316278951614) },
+ { FRAC_CONST(0.995104203544548), FRAC_CONST(0.098831291036650) },
+ { FRAC_CONST(0.994436045399422), FRAC_CONST(0.105342069518114) },
+ { FRAC_CONST(0.993725288923851), FRAC_CONST(0.111848335495926) },
+ { FRAC_CONST(0.992971964564277), FRAC_CONST(0.118349810263305) },
+ { FRAC_CONST(0.992176104590608), FRAC_CONST(0.124846215318711) },
+ { FRAC_CONST(0.991337743094838), FRAC_CONST(0.131337272377774) },
+ { FRAC_CONST(0.990456915989581), FRAC_CONST(0.137822703385212) },
+ { FRAC_CONST(0.989533661006540), FRAC_CONST(0.144302230526747) },
+ { FRAC_CONST(0.988568017694885), FRAC_CONST(0.150775576241001) },
+ { FRAC_CONST(0.987560027419562), FRAC_CONST(0.157242463231389) },
+ { FRAC_CONST(0.986509733359519), FRAC_CONST(0.163702614477995) },
+ { FRAC_CONST(0.985417180505858), FRAC_CONST(0.170155753249442) },
+ { FRAC_CONST(0.984282415659907), FRAC_CONST(0.176601603114742) },
+ { FRAC_CONST(0.983105487431216), FRAC_CONST(0.183039887955141) },
+ { FRAC_CONST(0.981886446235473), FRAC_CONST(0.189470331975943) },
+ { FRAC_CONST(0.980625344292344), FRAC_CONST(0.195892659718330) },
+ { FRAC_CONST(0.979322235623241), FRAC_CONST(0.202306596071156) },
+ { FRAC_CONST(0.977977176049000), FRAC_CONST(0.208711866282735) },
+ { FRAC_CONST(0.976590223187499), FRAC_CONST(0.215108195972610) },
+ { FRAC_CONST(0.975161436451181), FRAC_CONST(0.221495311143304) },
+ { FRAC_CONST(0.973690877044515), FRAC_CONST(0.227872938192063) },
+ { FRAC_CONST(0.972178607961371), FRAC_CONST(0.234240803922570) },
+ { FRAC_CONST(0.970624693982323), FRAC_CONST(0.240598635556650) },
+ { FRAC_CONST(0.969029201671875), FRAC_CONST(0.246946160745958) },
+ { FRAC_CONST(0.967392199375607), FRAC_CONST(0.253283107583640) },
+ { FRAC_CONST(0.965713757217249), FRAC_CONST(0.259609204615985) },
+ { FRAC_CONST(0.963993947095677), FRAC_CONST(0.265924180854051) },
+ { FRAC_CONST(0.962232842681832), FRAC_CONST(0.272227765785273) },
+ { FRAC_CONST(0.960430519415566), FRAC_CONST(0.278519689385053) },
+ { FRAC_CONST(0.958587054502409), FRAC_CONST(0.284799682128326) },
+ { FRAC_CONST(0.956702526910263), FRAC_CONST(0.291067475001103) },
+ { FRAC_CONST(0.954777017366017), FRAC_CONST(0.297322799511998) },
+ { FRAC_CONST(0.952810608352092), FRAC_CONST(0.303565387703730) },
+ { FRAC_CONST(0.950803384102905), FRAC_CONST(0.309794972164597) },
+ { FRAC_CONST(0.948755430601263), FRAC_CONST(0.316011286039934) },
+ { FRAC_CONST(0.946666835574676), FRAC_CONST(0.322214063043544) },
+ { FRAC_CONST(0.944537688491606), FRAC_CONST(0.328403037469105) },
+ { FRAC_CONST(0.942368080557626), FRAC_CONST(0.334577944201551) },
+ { FRAC_CONST(0.940158104711519), FRAC_CONST(0.340738518728429) },
+ { FRAC_CONST(0.937907855621296), FRAC_CONST(0.346884497151231) },
+ { FRAC_CONST(0.935617429680138), FRAC_CONST(0.353015616196696) },
+ { FRAC_CONST(0.933286925002268), FRAC_CONST(0.359131613228090) },
+ { FRAC_CONST(0.930916441418752), FRAC_CONST(0.365232226256457) },
+ { FRAC_CONST(0.928506080473216), FRAC_CONST(0.371317193951838) },
+ { FRAC_CONST(0.926055945417500), FRAC_CONST(0.377386255654469) },
+ { FRAC_CONST(0.923566141207236), FRAC_CONST(0.383439151385947) },
+ { FRAC_CONST(0.921036774497350), FRAC_CONST(0.389475621860365) },
+ { FRAC_CONST(0.918467953637492), FRAC_CONST(0.395495408495417) },
+ { FRAC_CONST(0.915859788667400), FRAC_CONST(0.401498253423481) },
+ { FRAC_CONST(0.913212391312179), FRAC_CONST(0.407483899502658) },
+ { FRAC_CONST(0.910525874977521), FRAC_CONST(0.413452090327791) },
+ { FRAC_CONST(0.907800354744844), FRAC_CONST(0.419402570241451) },
+ { FRAC_CONST(0.905035947366364), FRAC_CONST(0.425335084344881) },
+ { FRAC_CONST(0.902232771260093), FRAC_CONST(0.431249378508924) },
+ { FRAC_CONST(0.899390946504764), FRAC_CONST(0.437145199384900) },
+ { FRAC_CONST(0.896510594834693), FRAC_CONST(0.443022294415467) },
+ { FRAC_CONST(0.893591839634558), FRAC_CONST(0.448880411845433) },
+ { FRAC_CONST(0.890634805934118), FRAC_CONST(0.454719300732547) },
+ { FRAC_CONST(0.887639620402854), FRAC_CONST(0.460538710958240) },
+ { FRAC_CONST(0.884606411344546), FRAC_CONST(0.466338393238348) },
+ { FRAC_CONST(0.881535308691775), FRAC_CONST(0.472118099133784) },
+ { FRAC_CONST(0.878426444000357), FRAC_CONST(0.477877581061184) },
+ { FRAC_CONST(0.875279950443708), FRAC_CONST(0.483616592303511) },
+ { FRAC_CONST(0.872095962807140), FRAC_CONST(0.489334887020625) },
+ { FRAC_CONST(0.868874617482085), FRAC_CONST(0.495032220259813) },
+ { FRAC_CONST(0.865616052460258), FRAC_CONST(0.500708347966279) },
+ { FRAC_CONST(0.862320407327736), FRAC_CONST(0.506363026993605) },
+ { FRAC_CONST(0.858987823258990), FRAC_CONST(0.511996015114162) },
+ { FRAC_CONST(0.855618443010829), FRAC_CONST(0.517607071029487) },
+ { FRAC_CONST(0.852212410916289), FRAC_CONST(0.523195954380619) },
+ { FRAC_CONST(0.848769872878448), FRAC_CONST(0.528762425758396) },
+ { FRAC_CONST(0.845290976364179), FRAC_CONST(0.534306246713712) },
+ { FRAC_CONST(0.841775870397828), FRAC_CONST(0.539827179767727) },
+ { FRAC_CONST(0.838224705554838), FRAC_CONST(0.545324988422046) },
+ { FRAC_CONST(0.834637633955290), FRAC_CONST(0.550799437168844) },
+ { FRAC_CONST(0.831014809257393), FRAC_CONST(0.556250291500956) },
+ { FRAC_CONST(0.827356386650900), FRAC_CONST(0.561677317921925) },
+ { FRAC_CONST(0.823662522850458), FRAC_CONST(0.567080283956001) },
+ { FRAC_CONST(0.819933376088899), FRAC_CONST(0.572458958158102) },
+ { FRAC_CONST(0.816169106110459), FRAC_CONST(0.577813110123727) },
+ { FRAC_CONST(0.812369874163934), FRAC_CONST(0.583142510498826) },
+ { FRAC_CONST(0.808535842995778), FRAC_CONST(0.588446930989624) },
+ { FRAC_CONST(0.804667176843123), FRAC_CONST(0.593726144372402) },
+ { FRAC_CONST(0.800764041426753), FRAC_CONST(0.598979924503229) },
+ { FRAC_CONST(0.796826603943998), FRAC_CONST(0.604208046327650) },
+ { FRAC_CONST(0.792855033061574), FRAC_CONST(0.609410285890327) },
+ { FRAC_CONST(0.788849498908361), FRAC_CONST(0.614586420344631) },
+ { FRAC_CONST(0.784810173068109), FRAC_CONST(0.619736227962191) },
+ { FRAC_CONST(0.780737228572094), FRAC_CONST(0.624859488142386) },
+ { FRAC_CONST(0.776630839891703), FRAC_CONST(0.629955981421804) },
+ { FRAC_CONST(0.772491182930959), FRAC_CONST(0.635025489483633) },
+ { FRAC_CONST(0.768318435018988), FRAC_CONST(0.640067795167023) },
+ { FRAC_CONST(0.764112774902423), FRAC_CONST(0.645082682476378) },
+ { FRAC_CONST(0.759874382737746), FRAC_CONST(0.650069936590618) },
+ { FRAC_CONST(0.755603440083571), FRAC_CONST(0.655029343872374) },
+ { FRAC_CONST(0.751300129892866), FRAC_CONST(0.659960691877147) },
+ { FRAC_CONST(0.746964636505118), FRAC_CONST(0.664863769362399) },
+ { FRAC_CONST(0.742597145638433), FRAC_CONST(0.669738366296610) },
+ { FRAC_CONST(0.738197844381584), FRAC_CONST(0.674584273868271) },
+ { FRAC_CONST(0.733766921185995), FRAC_CONST(0.679401284494831) },
+ { FRAC_CONST(0.729304565857668), FRAC_CONST(0.684189191831585) },
+ { FRAC_CONST(0.724810969549055), FRAC_CONST(0.688947790780520) },
+ { FRAC_CONST(0.720286324750863), FRAC_CONST(0.693676877499095) },
+ { FRAC_CONST(0.715730825283819), FRAC_CONST(0.698376249408973) },
+ { FRAC_CONST(0.711144666290356), FRAC_CONST(0.703045705204703) },
+ { FRAC_CONST(0.706528044226263), FRAC_CONST(0.707685044862340) },
+ { FRAC_CONST(0.701881156852263), FRAC_CONST(0.712294069648014) },
+ { FRAC_CONST(0.697204203225545), FRAC_CONST(0.716872582126442) },
+ { FRAC_CONST(0.692497383691237), FRAC_CONST(0.721420386169390) },
+ { FRAC_CONST(0.687760899873822), FRAC_CONST(0.725937286964068) },
+ { FRAC_CONST(0.682994954668502), FRAC_CONST(0.730423091021479) },
+ { FRAC_CONST(0.678199752232508), FRAC_CONST(0.734877606184707) },
+ { FRAC_CONST(0.673375497976352), FRAC_CONST(0.739300641637149) },
+ { FRAC_CONST(0.668522398555031), FRAC_CONST(0.743692007910687) },
+ { FRAC_CONST(0.663640661859171), FRAC_CONST(0.748051516893805) },
+ { FRAC_CONST(0.658730497006124), FRAC_CONST(0.752378981839648) },
+ { FRAC_CONST(0.653792114331011), FRAC_CONST(0.756674217374021) },
+ { FRAC_CONST(0.648825725377709), FRAC_CONST(0.760937039503328) },
+ { FRAC_CONST(0.643831542889792), FRAC_CONST(0.765167265622459) },
+ { FRAC_CONST(0.638809780801414), FRAC_CONST(0.769364714522605) },
+ { FRAC_CONST(0.633760654228152), FRAC_CONST(0.773529206399025) },
+ { FRAC_CONST(0.628684379457781), FRAC_CONST(0.777660562858748) },
+ { FRAC_CONST(0.623581173941019), FRAC_CONST(0.781758606928213) },
+ { FRAC_CONST(0.618451256282204), FRAC_CONST(0.785823163060853) },
+ { FRAC_CONST(0.613294846229936), FRAC_CONST(0.789854057144609) },
+ { FRAC_CONST(0.608112164667659), FRAC_CONST(0.793851116509396) },
+ { FRAC_CONST(0.602903433604202), FRAC_CONST(0.797814169934493) },
+ { FRAC_CONST(0.597668876164268), FRAC_CONST(0.801743047655882) },
+ { FRAC_CONST(0.592408716578875), FRAC_CONST(0.805637581373517) },
+ { FRAC_CONST(0.587123180175754), FRAC_CONST(0.809497604258536) },
+ { FRAC_CONST(0.581812493369691), FRAC_CONST(0.813322950960406) },
+ { FRAC_CONST(0.576476883652835), FRAC_CONST(0.817113457614006) },
+ { FRAC_CONST(0.571116579584947), FRAC_CONST(0.820868961846646) },
+ { FRAC_CONST(0.565731810783613), FRAC_CONST(0.824589302785025) },
+ { FRAC_CONST(0.560322807914407), FRAC_CONST(0.828274321062119) },
+ { FRAC_CONST(0.554889802681009), FRAC_CONST(0.831923858824010) },
+ { FRAC_CONST(0.549433027815281), FRAC_CONST(0.835537759736646) },
+ { FRAC_CONST(0.543952717067296), FRAC_CONST(0.839115868992540) },
+ { FRAC_CONST(0.538449105195327), FRAC_CONST(0.842658033317402) },
+ { FRAC_CONST(0.532922427955790), FRAC_CONST(0.846164100976699) },
+ { FRAC_CONST(0.527372922093142), FRAC_CONST(0.849633921782164) },
+ { FRAC_CONST(0.521800825329746), FRAC_CONST(0.853067347098221) },
+ { FRAC_CONST(0.516206376355680), FRAC_CONST(0.856464229848356) },
+ { FRAC_CONST(0.510589814818519), FRAC_CONST(0.859824424521420) },
+ { FRAC_CONST(0.504951381313066), FRAC_CONST(0.863147787177854) },
+ { FRAC_CONST(0.499291317371047), FRAC_CONST(0.866434175455865) },
+ { FRAC_CONST(0.493609865450762), FRAC_CONST(0.869683448577516) },
+ { FRAC_CONST(0.487907268926702), FRAC_CONST(0.872895467354761) },
+ { FRAC_CONST(0.482183772079123), FRAC_CONST(0.876070094195407) },
+ { FRAC_CONST(0.476439620083580), FRAC_CONST(0.879207193109004) },
+ { FRAC_CONST(0.470675059000427), FRAC_CONST(0.882306629712678) },
+ { FRAC_CONST(0.464890335764274), FRAC_CONST(0.885368271236879) },
+ { FRAC_CONST(0.459085698173413), FRAC_CONST(0.888391986531075) },
+ { FRAC_CONST(0.453261394879198), FRAC_CONST(0.891377646069366) },
+ { FRAC_CONST(0.447417675375397), FRAC_CONST(0.894325121956035) },
+ { FRAC_CONST(0.441554789987504), FRAC_CONST(0.897234287931024) },
+ { FRAC_CONST(0.435672989862017), FRAC_CONST(0.900105019375345) },
+ { FRAC_CONST(0.429772526955677), FRAC_CONST(0.902937193316419) },
+ { FRAC_CONST(0.423853654024676), FRAC_CONST(0.905730688433339) },
+ { FRAC_CONST(0.417916624613831), FRAC_CONST(0.908485385062073) },
+ { FRAC_CONST(0.411961693045722), FRAC_CONST(0.911201165200584) },
+ { FRAC_CONST(0.405989114409798), FRAC_CONST(0.913877912513892) },
+ { FRAC_CONST(0.399999144551449), FRAC_CONST(0.916515512339049) },
+ { FRAC_CONST(0.393992040061048), FRAC_CONST(0.919113851690058) },
+ { FRAC_CONST(0.387968058262959), FRAC_CONST(0.921672819262709) },
+ { FRAC_CONST(0.381927457204511), FRAC_CONST(0.924192305439348) },
+ { FRAC_CONST(0.375870495644949), FRAC_CONST(0.926672202293573) },
+ { FRAC_CONST(0.369797433044349), FRAC_CONST(0.929112403594856) },
+ { FRAC_CONST(0.363708529552499), FRAC_CONST(0.931512804813095) },
+ { FRAC_CONST(0.357604045997758), FRAC_CONST(0.933873303123091) },
+ { FRAC_CONST(0.351484243875885), FRAC_CONST(0.936193797408954) },
+ { FRAC_CONST(0.345349385338836), FRAC_CONST(0.938474188268430) },
+ { FRAC_CONST(0.339199733183530), FRAC_CONST(0.940714378017165) },
+ { FRAC_CONST(0.333035550840599), FRAC_CONST(0.942914270692887) },
+ { FRAC_CONST(0.326857102363098), FRAC_CONST(0.945073772059514) },
+ { FRAC_CONST(0.320664652415198), FRAC_CONST(0.947192789611197) },
+ { FRAC_CONST(0.314458466260842), FRAC_CONST(0.949271232576274) },
+ { FRAC_CONST(0.308238809752391), FRAC_CONST(0.951309011921168) },
+ { FRAC_CONST(0.302005949319228), FRAC_CONST(0.953306040354194) },
+ { FRAC_CONST(0.295760151956351), FRAC_CONST(0.955262232329299) },
+ { FRAC_CONST(0.289501685212929), FRAC_CONST(0.957177504049732) },
+ { FRAC_CONST(0.283230817180850), FRAC_CONST(0.959051773471624) },
+ { FRAC_CONST(0.276947816483228), FRAC_CONST(0.960884960307514) },
+ { FRAC_CONST(0.270652952262902), FRAC_CONST(0.962676986029777) },
+ { FRAC_CONST(0.264346494170904), FRAC_CONST(0.964427773873996) },
+ { FRAC_CONST(0.258028712354909), FRAC_CONST(0.966137248842248) },
+ { FRAC_CONST(0.251699877447663), FRAC_CONST(0.967805337706313) },
+ { FRAC_CONST(0.245360260555389), FRAC_CONST(0.969431969010818) },
+ { FRAC_CONST(0.239010133246176), FRAC_CONST(0.971017073076290) },
+ { FRAC_CONST(0.232649767538342), FRAC_CONST(0.972560582002147) },
+ { FRAC_CONST(0.226279435888785), FRAC_CONST(0.974062429669605) },
+ { FRAC_CONST(0.219899411181310), FRAC_CONST(0.975522551744506) },
+ { FRAC_CONST(0.213509966714943), FRAC_CONST(0.976940885680082) },
+ { FRAC_CONST(0.207111376192219), FRAC_CONST(0.978317370719628) },
+ { FRAC_CONST(0.200703913707458), FRAC_CONST(0.979651947899104) },
+ { FRAC_CONST(0.194287853735029), FRAC_CONST(0.980944560049668) },
+ { FRAC_CONST(0.187863471117585), FRAC_CONST(0.982195151800116) },
+ { FRAC_CONST(0.181431041054297), FRAC_CONST(0.983403669579260) },
+ { FRAC_CONST(0.174990839089060), FRAC_CONST(0.984570061618221) },
+ { FRAC_CONST(0.168543141098691), FRAC_CONST(0.985694277952645) },
+ { FRAC_CONST(0.162088223281113), FRAC_CONST(0.986776270424848) },
+ { FRAC_CONST(0.155626362143520), FRAC_CONST(0.987815992685872) },
+ { FRAC_CONST(0.149157834490539), FRAC_CONST(0.988813400197476) },
+ { FRAC_CONST(0.142682917412363), FRAC_CONST(0.989768450234042) },
+ { FRAC_CONST(0.136201888272891), FRAC_CONST(0.990681101884405) },
+ { FRAC_CONST(0.129715024697841), FRAC_CONST(0.991551316053606) },
+ { FRAC_CONST(0.123222604562857), FRAC_CONST(0.992379055464567) },
+ { FRAC_CONST(0.116724905981611), FRAC_CONST(0.993164284659685) },
+ { FRAC_CONST(0.110222207293883), FRAC_CONST(0.993906970002356) },
+ { FRAC_CONST(0.103714787053643), FRAC_CONST(0.994607079678411) },
+ { FRAC_CONST(0.097202924017115), FRAC_CONST(0.995264583697482) },
+ { FRAC_CONST(0.090686897130838), FRAC_CONST(0.995879453894286) },
+ { FRAC_CONST(0.084166985519718), FRAC_CONST(0.996451663929828) },
+ { FRAC_CONST(0.077643468475068), FRAC_CONST(0.996981189292537) },
+ { FRAC_CONST(0.071116625442645), FRAC_CONST(0.997468007299307) },
+ { FRAC_CONST(0.064586736010684), FRAC_CONST(0.997912097096476) },
+ { FRAC_CONST(0.058054079897912), FRAC_CONST(0.998313439660714) },
+ { FRAC_CONST(0.051518936941578), FRAC_CONST(0.998672017799843) },
+ { FRAC_CONST(0.044981587085452), FRAC_CONST(0.998987816153567) },
+ { FRAC_CONST(0.038442310367847), FRAC_CONST(0.999260821194138) },
+ { FRAC_CONST(0.031901386909611), FRAC_CONST(0.999491021226926) },
+ { FRAC_CONST(0.025359096902136), FRAC_CONST(0.999678406390929) },
+ { FRAC_CONST(0.018815720595351), FRAC_CONST(0.999822968659191) },
+ { FRAC_CONST(0.012271538285720), FRAC_CONST(0.999924701839145) },
+ { FRAC_CONST(0.005726830304231), FRAC_CONST(0.999983601572879) }
+ };
+#endif // LD_DEC
+
+ /* 60 (N/4) complex twiddle factors */
+ ALIGN static const complex_t mdct_tab_240[] = {
+ { FRAC_CONST(0.999994645401696), FRAC_CONST(0.003272486506527) },
+ { FRAC_CONST(0.999566308502021), FRAC_CONST(0.029448173247963) },
+ { FRAC_CONST(0.998452918783950), FRAC_CONST(0.055603677682425) },
+ { FRAC_CONST(0.996655239309180), FRAC_CONST(0.081721074133668) },
+ { FRAC_CONST(0.994174502117428), FRAC_CONST(0.107782463042759) },
+ { FRAC_CONST(0.991012407382049), FRAC_CONST(0.133769983235535) },
+ { FRAC_CONST(0.987171122244825), FRAC_CONST(0.159665824163761) },
+ { FRAC_CONST(0.982653279330712), FRAC_CONST(0.185452238111591) },
+ { FRAC_CONST(0.977461974943572), FRAC_CONST(0.211111552358965) },
+ { FRAC_CONST(0.971600766944121), FRAC_CONST(0.236626181293610) },
+ { FRAC_CONST(0.965073672311547), FRAC_CONST(0.261978638463337) },
+ { FRAC_CONST(0.957885164390477), FRAC_CONST(0.287151548560387) },
+ { FRAC_CONST(0.950040169825165), FRAC_CONST(0.312127659329594) },
+ { FRAC_CONST(0.941544065183021), FRAC_CONST(0.336889853392220) },
+ { FRAC_CONST(0.932402673269775), FRAC_CONST(0.361421159977355) },
+ { FRAC_CONST(0.922622259138823), FRAC_CONST(0.385704766552831) },
+ { FRAC_CONST(0.912209525797468), FRAC_CONST(0.409724030347695) },
+ { FRAC_CONST(0.901171609613013), FRAC_CONST(0.433462489758331) },
+ { FRAC_CONST(0.889516075421856), FRAC_CONST(0.456903875630421) },
+ { FRAC_CONST(0.877250911344924), FRAC_CONST(0.480032122409011) },
+ { FRAC_CONST(0.864384523313017), FRAC_CONST(0.502831379149042) },
+ { FRAC_CONST(0.850925729305802), FRAC_CONST(0.525286020378792) },
+ { FRAC_CONST(0.836883753308409), FRAC_CONST(0.547380656808797) },
+ { FRAC_CONST(0.822268218989775), FRAC_CONST(0.569100145878898) },
+ { FRAC_CONST(0.807089143107059), FRAC_CONST(0.590429602136201) },
+ { FRAC_CONST(0.791356928640660), FRAC_CONST(0.611354407436816) },
+ { FRAC_CONST(0.775082357664531), FRAC_CONST(0.631860220964409) },
+ { FRAC_CONST(0.758276583956687), FRAC_CONST(0.651932989058674) },
+ { FRAC_CONST(0.740951125354959), FRAC_CONST(0.671558954847018) },
+ { FRAC_CONST(0.723117855863248), FRAC_CONST(0.690724667672829) },
+ { FRAC_CONST(0.704788997513670), FRAC_CONST(0.709416992313883) },
+ { FRAC_CONST(0.685977111990193), FRAC_CONST(0.727623117984575) },
+ { FRAC_CONST(0.666695092019479), FRAC_CONST(0.745330567115786) },
+ { FRAC_CONST(0.646956152534857), FRAC_CONST(0.762527203906388) },
+ { FRAC_CONST(0.626773821619469), FRAC_CONST(0.779201242640517) },
+ { FRAC_CONST(0.606161931234795), FRAC_CONST(0.795341255764910) },
+ { FRAC_CONST(0.585134607740916), FRAC_CONST(0.810936181720784) },
+ { FRAC_CONST(0.563706262215017), FRAC_CONST(0.825975332524873) },
+ { FRAC_CONST(0.541891580574752), FRAC_CONST(0.840448401094438) },
+ { FRAC_CONST(0.519705513513249), FRAC_CONST(0.854345468311227) },
+ { FRAC_CONST(0.497163266252654), FRAC_CONST(0.867657009819544) },
+ { FRAC_CONST(0.474280288123229), FRAC_CONST(0.880373902553765) },
+ { FRAC_CONST(0.451072261975153), FRAC_CONST(0.892487430990834) },
+ { FRAC_CONST(0.427555093430282), FRAC_CONST(0.903989293123443) },
+ { FRAC_CONST(0.403744899981227), FRAC_CONST(0.914871606149819) },
+ { FRAC_CONST(0.379657999945233), FRAC_CONST(0.925126911876195) },
+ { FRAC_CONST(0.355310901280416), FRAC_CONST(0.934748181828292) },
+ { FRAC_CONST(0.330720290272038), FRAC_CONST(0.943728822068278) },
+ { FRAC_CONST(0.305903020096554), FRAC_CONST(0.952062677713924) },
+ { FRAC_CONST(0.280876099271292), FRAC_CONST(0.959744037156857) },
+ { FRAC_CONST(0.255656679997665), FRAC_CONST(0.966767635977008) },
+ { FRAC_CONST(0.230262046405902), FRAC_CONST(0.973128660550580) },
+ { FRAC_CONST(0.204709602709380), FRAC_CONST(0.978822751349072) },
+ { FRAC_CONST(0.179016861276633), FRAC_CONST(0.983846005927077) },
+ { FRAC_CONST(0.153201430629259), FRAC_CONST(0.988194981596825) },
+ { FRAC_CONST(0.127281003373913), FRAC_CONST(0.991866697787626) },
+ { FRAC_CONST(0.101273344076683), FRAC_CONST(0.994858638088611) },
+ { FRAC_CONST(0.075196277088140), FRAC_CONST(0.997168751973348) },
+ { FRAC_CONST(0.049067674327418), FRAC_CONST(0.998795456205172) },
+ { FRAC_CONST(0.022905443033697), FRAC_CONST(0.999737635922260) }
+ };
+#endif // ALLOW_SMALL_FRAMELENGTH
+
+#ifdef SSR_DEC
+ /* 128 (N/4) complex twiddle factors */
+ ALIGN static const complex_t mdct_tab_512[] = {
+ { FRAC_CONST(0.999998823451702), FRAC_CONST(0.001533980186285) },
+ { FRAC_CONST(0.999904701082853), FRAC_CONST(0.013805388528060) },
+ { FRAC_CONST(0.999659996743959), FRAC_CONST(0.026074717829104) },
+ { FRAC_CONST(0.999264747286594), FRAC_CONST(0.038340120373553) },
+ { FRAC_CONST(0.998719012233873), FRAC_CONST(0.050599749036899) },
+ { FRAC_CONST(0.998022873771486), FRAC_CONST(0.062851757564161) },
+ { FRAC_CONST(0.997176436735326), FRAC_CONST(0.075094300847921) },
+ { FRAC_CONST(0.996179828595697), FRAC_CONST(0.087325535206192) },
+ { FRAC_CONST(0.995033199438119), FRAC_CONST(0.099543618660069) },
+ { FRAC_CONST(0.993736721940725), FRAC_CONST(0.111746711211127) },
+ { FRAC_CONST(0.992290591348257), FRAC_CONST(0.123932975118512) },
+ { FRAC_CONST(0.990695025442665), FRAC_CONST(0.136100575175706) },
+ { FRAC_CONST(0.988950264510303), FRAC_CONST(0.148247678986896) },
+ { FRAC_CONST(0.987056571305751), FRAC_CONST(0.160372457242928) },
+ { FRAC_CONST(0.985014231012240), FRAC_CONST(0.172473083996796) },
+ { FRAC_CONST(0.982823551198705), FRAC_CONST(0.184547736938620) },
+ { FRAC_CONST(0.980484861773469), FRAC_CONST(0.196594597670080) },
+ { FRAC_CONST(0.977998514934557), FRAC_CONST(0.208611851978263) },
+ { FRAC_CONST(0.975364885116657), FRAC_CONST(0.220597690108874) },
+ { FRAC_CONST(0.972584368934732), FRAC_CONST(0.232550307038775) },
+ { FRAC_CONST(0.969657385124292), FRAC_CONST(0.244467902747824) },
+ { FRAC_CONST(0.966584374478333), FRAC_CONST(0.256348682489943) },
+ { FRAC_CONST(0.963365799780954), FRAC_CONST(0.268190857063403) },
+ { FRAC_CONST(0.960002145737666), FRAC_CONST(0.279992643080273) },
+ { FRAC_CONST(0.956493918902395), FRAC_CONST(0.291752263234989) },
+ { FRAC_CONST(0.952841647601199), FRAC_CONST(0.303467946572011) },
+ { FRAC_CONST(0.949045881852701), FRAC_CONST(0.315137928752522) },
+ { FRAC_CONST(0.945107193285261), FRAC_CONST(0.326760452320132) },
+ { FRAC_CONST(0.941026175050889), FRAC_CONST(0.338333766965541) },
+ { FRAC_CONST(0.936803441735922), FRAC_CONST(0.349856129790135) },
+ { FRAC_CONST(0.932439629268462), FRAC_CONST(0.361325805568454) },
+ { FRAC_CONST(0.927935394822618), FRAC_CONST(0.372741067009516) },
+ { FRAC_CONST(0.923291416719528), FRAC_CONST(0.384100195016935) },
+ { FRAC_CONST(0.918508394325212), FRAC_CONST(0.395401478947816) },
+ { FRAC_CONST(0.913587047945251), FRAC_CONST(0.406643216870369) },
+ { FRAC_CONST(0.908528118716306), FRAC_CONST(0.417823715820212) },
+ { FRAC_CONST(0.903332368494512), FRAC_CONST(0.428941292055329) },
+ { FRAC_CONST(0.898000579740740), FRAC_CONST(0.439994271309633) },
+ { FRAC_CONST(0.892533555402765), FRAC_CONST(0.450980989045104) },
+ { FRAC_CONST(0.886932118794342), FRAC_CONST(0.461899790702463) },
+ { FRAC_CONST(0.881197113471222), FRAC_CONST(0.472749031950343) },
+ { FRAC_CONST(0.875329403104111), FRAC_CONST(0.483527078932919) },
+ { FRAC_CONST(0.869329871348607), FRAC_CONST(0.494232308515960) },
+ { FRAC_CONST(0.863199421712124), FRAC_CONST(0.504863108531268) },
+ { FRAC_CONST(0.856938977417829), FRAC_CONST(0.515417878019463) },
+ { FRAC_CONST(0.850549481265603), FRAC_CONST(0.525895027471085) },
+ { FRAC_CONST(0.844031895490066), FRAC_CONST(0.536292979065963) },
+ { FRAC_CONST(0.837387201615662), FRAC_CONST(0.546610166910835) },
+ { FRAC_CONST(0.830616400308846), FRAC_CONST(0.556845037275160) },
+ { FRAC_CONST(0.823720511227391), FRAC_CONST(0.566996048825109) },
+ { FRAC_CONST(0.816700572866828), FRAC_CONST(0.577061672855679) },
+ { FRAC_CONST(0.809557642404051), FRAC_CONST(0.587040393520918) },
+ { FRAC_CONST(0.802292795538116), FRAC_CONST(0.596930708062197) },
+ { FRAC_CONST(0.794907126328237), FRAC_CONST(0.606731127034524) },
+ { FRAC_CONST(0.787401747029031), FRAC_CONST(0.616440174530854) },
+ { FRAC_CONST(0.779777787923015), FRAC_CONST(0.626056388404344) },
+ { FRAC_CONST(0.772036397150385), FRAC_CONST(0.635578320488556) },
+ { FRAC_CONST(0.764178740536117), FRAC_CONST(0.645004536815544) },
+ { FRAC_CONST(0.756206001414395), FRAC_CONST(0.654333617831800) },
+ { FRAC_CONST(0.748119380450404), FRAC_CONST(0.663564158612040) },
+ { FRAC_CONST(0.739920095459516), FRAC_CONST(0.672694769070773) },
+ { FRAC_CONST(0.731609381223893), FRAC_CONST(0.681724074171650) },
+ { FRAC_CONST(0.723188489306527), FRAC_CONST(0.690650714134535) },
+ { FRAC_CONST(0.714658687862769), FRAC_CONST(0.699473344640284) },
+ { FRAC_CONST(0.706021261449340), FRAC_CONST(0.708190637033195) },
+ { FRAC_CONST(0.697277510830887), FRAC_CONST(0.716801278521100) },
+ { FRAC_CONST(0.688428752784091), FRAC_CONST(0.725303972373061) },
+ { FRAC_CONST(0.679476319899365), FRAC_CONST(0.733697438114660) },
+ { FRAC_CONST(0.670421560380173), FRAC_CONST(0.741980411720831) },
+ { FRAC_CONST(0.661265837839992), FRAC_CONST(0.750151645806215) },
+ { FRAC_CONST(0.652010531096960), FRAC_CONST(0.758209909813015) },
+ { FRAC_CONST(0.642657033966227), FRAC_CONST(0.766153990196313) },
+ { FRAC_CONST(0.633206755050057), FRAC_CONST(0.773982690606823) },
+ { FRAC_CONST(0.623661117525695), FRAC_CONST(0.781694832071059) },
+ { FRAC_CONST(0.614021558931038), FRAC_CONST(0.789289253168886) },
+ { FRAC_CONST(0.604289530948156), FRAC_CONST(0.796764810208419) },
+ { FRAC_CONST(0.594466499184665), FRAC_CONST(0.804120377398266) },
+ { FRAC_CONST(0.584553942953015), FRAC_CONST(0.811354847017064) },
+ { FRAC_CONST(0.574553355047716), FRAC_CONST(0.818467129580299) },
+ { FRAC_CONST(0.564466241520520), FRAC_CONST(0.825456154004377) },
+ { FRAC_CONST(0.554294121453620), FRAC_CONST(0.832320867767930) },
+ { FRAC_CONST(0.544038526730884), FRAC_CONST(0.839060237070313) },
+ { FRAC_CONST(0.533701001807153), FRAC_CONST(0.845673246987299) },
+ { FRAC_CONST(0.523283103475656), FRAC_CONST(0.852158901623920) },
+ { FRAC_CONST(0.512786400633563), FRAC_CONST(0.858516224264443) },
+ { FRAC_CONST(0.502212474045711), FRAC_CONST(0.864744257519462) },
+ { FRAC_CONST(0.491562916106550), FRAC_CONST(0.870842063470079) },
+ { FRAC_CONST(0.480839330600334), FRAC_CONST(0.876808723809146) },
+ { FRAC_CONST(0.470043332459596), FRAC_CONST(0.882643339979563) },
+ { FRAC_CONST(0.459176547521944), FRAC_CONST(0.888345033309596) },
+ { FRAC_CONST(0.448240612285220), FRAC_CONST(0.893912945145203) },
+ { FRAC_CONST(0.437237173661044), FRAC_CONST(0.899346236979341) },
+ { FRAC_CONST(0.426167888726800), FRAC_CONST(0.904644090578246) },
+ { FRAC_CONST(0.415034424476082), FRAC_CONST(0.909805708104652) },
+ { FRAC_CONST(0.403838457567654), FRAC_CONST(0.914830312237946) },
+ { FRAC_CONST(0.392581674072952), FRAC_CONST(0.919717146291227) },
+ { FRAC_CONST(0.381265769222162), FRAC_CONST(0.924465474325263) },
+ { FRAC_CONST(0.369892447148934), FRAC_CONST(0.929074581259316) },
+ { FRAC_CONST(0.358463420633737), FRAC_CONST(0.933543772978836) },
+ { FRAC_CONST(0.346980410845924), FRAC_CONST(0.937872376439990) },
+ { FRAC_CONST(0.335445147084532), FRAC_CONST(0.942059739771017) },
+ { FRAC_CONST(0.323859366517853), FRAC_CONST(0.946105232370403) },
+ { FRAC_CONST(0.312224813921825), FRAC_CONST(0.950008245001843) },
+ { FRAC_CONST(0.300543241417273), FRAC_CONST(0.953768189885990) },
+ { FRAC_CONST(0.288816408206049), FRAC_CONST(0.957384500788976) },
+ { FRAC_CONST(0.277046080306100), FRAC_CONST(0.960856633107680) },
+ { FRAC_CONST(0.265234030285512), FRAC_CONST(0.964184063951746) },
+ { FRAC_CONST(0.253382036995570), FRAC_CONST(0.967366292222329) },
+ { FRAC_CONST(0.241491885302869), FRAC_CONST(0.970402838687556) },
+ { FRAC_CONST(0.229565365820519), FRAC_CONST(0.973293246054698) },
+ { FRAC_CONST(0.217604274638484), FRAC_CONST(0.976037079039039) },
+ { FRAC_CONST(0.205610413053099), FRAC_CONST(0.978633924429423) },
+ { FRAC_CONST(0.193585587295804), FRAC_CONST(0.981083391150487) },
+ { FRAC_CONST(0.181531608261125), FRAC_CONST(0.983385110321551) },
+ { FRAC_CONST(0.169450291233968), FRAC_CONST(0.985538735312176) },
+ { FRAC_CONST(0.157343455616238), FRAC_CONST(0.987543941794359) },
+ { FRAC_CONST(0.145212924652848), FRAC_CONST(0.989400427791380) },
+ { FRAC_CONST(0.133060525157139), FRAC_CONST(0.991107913723277) },
+ { FRAC_CONST(0.120888087235777), FRAC_CONST(0.992666142448948) },
+ { FRAC_CONST(0.108697444013139), FRAC_CONST(0.994074879304879) },
+ { FRAC_CONST(0.096490431355253), FRAC_CONST(0.995333912140482) },
+ { FRAC_CONST(0.084268887593324), FRAC_CONST(0.996443051350043) },
+ { FRAC_CONST(0.072034653246889), FRAC_CONST(0.997402129901275) },
+ { FRAC_CONST(0.059789570746640), FRAC_CONST(0.998211003360478) },
+ { FRAC_CONST(0.047535484156959), FRAC_CONST(0.998869549914284) },
+ { FRAC_CONST(0.035274238898214), FRAC_CONST(0.999377670388003) },
+ { FRAC_CONST(0.023007681468839), FRAC_CONST(0.999735288260562) },
+ { FRAC_CONST(0.010737659167265), FRAC_CONST(0.999942349676024) }
+ };
+
+ /* 16 (N/4) complex twiddle factors */
+ ALIGN static const complex_t mdct_tab_64[] = {
+ { FRAC_CONST(0.999924701839145), FRAC_CONST(0.012271538285720) },
+ { FRAC_CONST(0.993906970002356), FRAC_CONST(0.110222207293883) },
+ { FRAC_CONST(0.978317370719628), FRAC_CONST(0.207111376192219) },
+ { FRAC_CONST(0.953306040354194), FRAC_CONST(0.302005949319228) },
+ { FRAC_CONST(0.919113851690058), FRAC_CONST(0.393992040061048) },
+ { FRAC_CONST(0.876070094195407), FRAC_CONST(0.482183772079123) },
+ { FRAC_CONST(0.824589302785025), FRAC_CONST(0.565731810783613) },
+ { FRAC_CONST(0.765167265622459), FRAC_CONST(0.643831542889791) },
+ { FRAC_CONST(0.698376249408973), FRAC_CONST(0.715730825283819) },
+ { FRAC_CONST(0.624859488142386), FRAC_CONST(0.780737228572094) },
+ { FRAC_CONST(0.545324988422046), FRAC_CONST(0.838224705554838) },
+ { FRAC_CONST(0.460538710958240), FRAC_CONST(0.887639620402854) },
+ { FRAC_CONST(0.371317193951838), FRAC_CONST(0.928506080473215) },
+ { FRAC_CONST(0.278519689385053), FRAC_CONST(0.960430519415566) },
+ { FRAC_CONST(0.183039887955141), FRAC_CONST(0.983105487431216) },
+ { FRAC_CONST(0.085797312344440), FRAC_CONST(0.996312612182778) }
+ };
+#endif // SSR_DEC
+
+#else // FIXED_POINT
+
+ /* 256 (N/4) complex twiddle factors */
+ ALIGN static const complex_t mdct_tab_2048[] = {
+ { FRAC_CONST(0.031249997702054), FRAC_CONST(0.000011984224612) },
+ { FRAC_CONST(0.031249813866531), FRAC_CONST(0.000107857810004) },
+ { FRAC_CONST(0.031249335895858), FRAC_CONST(0.000203730380198) },
+ { FRAC_CONST(0.031248563794535), FRAC_CONST(0.000299601032804) },
+ { FRAC_CONST(0.031247497569829), FRAC_CONST(0.000395468865451) },
+ { FRAC_CONST(0.031246137231775), FRAC_CONST(0.000491332975794) },
+ { FRAC_CONST(0.031244482793177), FRAC_CONST(0.000587192461525) },
+ { FRAC_CONST(0.031242534269608), FRAC_CONST(0.000683046420376) },
+ { FRAC_CONST(0.031240291679407), FRAC_CONST(0.000778893950134) },
+ { FRAC_CONST(0.031237755043684), FRAC_CONST(0.000874734148645) },
+ { FRAC_CONST(0.031234924386313), FRAC_CONST(0.000970566113826) },
+ { FRAC_CONST(0.031231799733938), FRAC_CONST(0.001066388943669) },
+ { FRAC_CONST(0.031228381115970), FRAC_CONST(0.001162201736253) },
+ { FRAC_CONST(0.031224668564585), FRAC_CONST(0.001258003589751) },
+ { FRAC_CONST(0.031220662114728), FRAC_CONST(0.001353793602441) },
+ { FRAC_CONST(0.031216361804108), FRAC_CONST(0.001449570872710) },
+ { FRAC_CONST(0.031211767673203), FRAC_CONST(0.001545334499065) },
+ { FRAC_CONST(0.031206879765253), FRAC_CONST(0.001641083580144) },
+ { FRAC_CONST(0.031201698126266), FRAC_CONST(0.001736817214719) },
+ { FRAC_CONST(0.031196222805014), FRAC_CONST(0.001832534501709) },
+ { FRAC_CONST(0.031190453853031), FRAC_CONST(0.001928234540186) },
+ { FRAC_CONST(0.031184391324617), FRAC_CONST(0.002023916429386) },
+ { FRAC_CONST(0.031178035276836), FRAC_CONST(0.002119579268713) },
+ { FRAC_CONST(0.031171385769513), FRAC_CONST(0.002215222157753) },
+ { FRAC_CONST(0.031164442865236), FRAC_CONST(0.002310844196278) },
+ { FRAC_CONST(0.031157206629353), FRAC_CONST(0.002406444484258) },
+ { FRAC_CONST(0.031149677129975), FRAC_CONST(0.002502022121865) },
+ { FRAC_CONST(0.031141854437973), FRAC_CONST(0.002597576209488) },
+ { FRAC_CONST(0.031133738626977), FRAC_CONST(0.002693105847734) },
+ { FRAC_CONST(0.031125329773375), FRAC_CONST(0.002788610137442) },
+ { FRAC_CONST(0.031116627956316), FRAC_CONST(0.002884088179689) },
+ { FRAC_CONST(0.031107633257703), FRAC_CONST(0.002979539075801) },
+ { FRAC_CONST(0.031098345762200), FRAC_CONST(0.003074961927355) },
+ { FRAC_CONST(0.031088765557222), FRAC_CONST(0.003170355836197) },
+ { FRAC_CONST(0.031078892732942), FRAC_CONST(0.003265719904442) },
+ { FRAC_CONST(0.031068727382288), FRAC_CONST(0.003361053234488) },
+ { FRAC_CONST(0.031058269600939), FRAC_CONST(0.003456354929021) },
+ { FRAC_CONST(0.031047519487329), FRAC_CONST(0.003551624091024) },
+ { FRAC_CONST(0.031036477142640), FRAC_CONST(0.003646859823790) },
+ { FRAC_CONST(0.031025142670809), FRAC_CONST(0.003742061230921) },
+ { FRAC_CONST(0.031013516178519), FRAC_CONST(0.003837227416347) },
+ { FRAC_CONST(0.031001597775203), FRAC_CONST(0.003932357484328) },
+ { FRAC_CONST(0.030989387573042), FRAC_CONST(0.004027450539462) },
+ { FRAC_CONST(0.030976885686963), FRAC_CONST(0.004122505686697) },
+ { FRAC_CONST(0.030964092234638), FRAC_CONST(0.004217522031340) },
+ { FRAC_CONST(0.030951007336485), FRAC_CONST(0.004312498679058) },
+ { FRAC_CONST(0.030937631115663), FRAC_CONST(0.004407434735897) },
+ { FRAC_CONST(0.030923963698074), FRAC_CONST(0.004502329308281) },
+ { FRAC_CONST(0.030910005212362), FRAC_CONST(0.004597181503027) },
+ { FRAC_CONST(0.030895755789908), FRAC_CONST(0.004691990427350) },
+ { FRAC_CONST(0.030881215564835), FRAC_CONST(0.004786755188872) },
+ { FRAC_CONST(0.030866384674000), FRAC_CONST(0.004881474895632) },
+ { FRAC_CONST(0.030851263256996), FRAC_CONST(0.004976148656090) },
+ { FRAC_CONST(0.030835851456154), FRAC_CONST(0.005070775579142) },
+ { FRAC_CONST(0.030820149416533), FRAC_CONST(0.005165354774124) },
+ { FRAC_CONST(0.030804157285929), FRAC_CONST(0.005259885350819) },
+ { FRAC_CONST(0.030787875214864), FRAC_CONST(0.005354366419469) },
+ { FRAC_CONST(0.030771303356593), FRAC_CONST(0.005448797090784) },
+ { FRAC_CONST(0.030754441867095), FRAC_CONST(0.005543176475946) },
+ { FRAC_CONST(0.030737290905077), FRAC_CONST(0.005637503686619) },
+ { FRAC_CONST(0.030719850631972), FRAC_CONST(0.005731777834961) },
+ { FRAC_CONST(0.030702121211932), FRAC_CONST(0.005825998033626) },
+ { FRAC_CONST(0.030684102811835), FRAC_CONST(0.005920163395780) },
+ { FRAC_CONST(0.030665795601276), FRAC_CONST(0.006014273035101) },
+ { FRAC_CONST(0.030647199752570), FRAC_CONST(0.006108326065793) },
+ { FRAC_CONST(0.030628315440748), FRAC_CONST(0.006202321602594) },
+ { FRAC_CONST(0.030609142843557), FRAC_CONST(0.006296258760782) },
+ { FRAC_CONST(0.030589682141455), FRAC_CONST(0.006390136656185) },
+ { FRAC_CONST(0.030569933517616), FRAC_CONST(0.006483954405188) },
+ { FRAC_CONST(0.030549897157919), FRAC_CONST(0.006577711124743) },
+ { FRAC_CONST(0.030529573250956), FRAC_CONST(0.006671405932375) },
+ { FRAC_CONST(0.030508961988022), FRAC_CONST(0.006765037946194) },
+ { FRAC_CONST(0.030488063563118), FRAC_CONST(0.006858606284900) },
+ { FRAC_CONST(0.030466878172949), FRAC_CONST(0.006952110067791) },
+ { FRAC_CONST(0.030445406016919), FRAC_CONST(0.007045548414774) },
+ { FRAC_CONST(0.030423647297133), FRAC_CONST(0.007138920446372) },
+ { FRAC_CONST(0.030401602218392), FRAC_CONST(0.007232225283733) },
+ { FRAC_CONST(0.030379270988192), FRAC_CONST(0.007325462048634) },
+ { FRAC_CONST(0.030356653816724), FRAC_CONST(0.007418629863497) },
+ { FRAC_CONST(0.030333750916869), FRAC_CONST(0.007511727851390) },
+ { FRAC_CONST(0.030310562504198), FRAC_CONST(0.007604755136040) },
+ { FRAC_CONST(0.030287088796968), FRAC_CONST(0.007697710841838) },
+ { FRAC_CONST(0.030263330016124), FRAC_CONST(0.007790594093851) },
+ { FRAC_CONST(0.030239286385293), FRAC_CONST(0.007883404017824) },
+ { FRAC_CONST(0.030214958130781), FRAC_CONST(0.007976139740197) },
+ { FRAC_CONST(0.030190345481576), FRAC_CONST(0.008068800388104) },
+ { FRAC_CONST(0.030165448669342), FRAC_CONST(0.008161385089390) },
+ { FRAC_CONST(0.030140267928416), FRAC_CONST(0.008253892972610) },
+ { FRAC_CONST(0.030114803495809), FRAC_CONST(0.008346323167047) },
+ { FRAC_CONST(0.030089055611203), FRAC_CONST(0.008438674802711) },
+ { FRAC_CONST(0.030063024516947), FRAC_CONST(0.008530947010354) },
+ { FRAC_CONST(0.030036710458054), FRAC_CONST(0.008623138921475) },
+ { FRAC_CONST(0.030010113682202), FRAC_CONST(0.008715249668328) },
+ { FRAC_CONST(0.029983234439732), FRAC_CONST(0.008807278383932) },
+ { FRAC_CONST(0.029956072983640), FRAC_CONST(0.008899224202078) },
+ { FRAC_CONST(0.029928629569580), FRAC_CONST(0.008991086257336) },
+ { FRAC_CONST(0.029900904455860), FRAC_CONST(0.009082863685067) },
+ { FRAC_CONST(0.029872897903441), FRAC_CONST(0.009174555621425) },
+ { FRAC_CONST(0.029844610175929), FRAC_CONST(0.009266161203371) },
+ { FRAC_CONST(0.029816041539579), FRAC_CONST(0.009357679568679) },
+ { FRAC_CONST(0.029787192263292), FRAC_CONST(0.009449109855944) },
+ { FRAC_CONST(0.029758062618606), FRAC_CONST(0.009540451204587) },
+ { FRAC_CONST(0.029728652879702), FRAC_CONST(0.009631702754871) },
+ { FRAC_CONST(0.029698963323395), FRAC_CONST(0.009722863647900) },
+ { FRAC_CONST(0.029668994229134), FRAC_CONST(0.009813933025633) },
+ { FRAC_CONST(0.029638745879000), FRAC_CONST(0.009904910030891) },
+ { FRAC_CONST(0.029608218557702), FRAC_CONST(0.009995793807363) },
+ { FRAC_CONST(0.029577412552575), FRAC_CONST(0.010086583499618) },
+ { FRAC_CONST(0.029546328153577), FRAC_CONST(0.010177278253107) },
+ { FRAC_CONST(0.029514965653285), FRAC_CONST(0.010267877214177) },
+ { FRAC_CONST(0.029483325346896), FRAC_CONST(0.010358379530076) },
+ { FRAC_CONST(0.029451407532220), FRAC_CONST(0.010448784348962) },
+ { FRAC_CONST(0.029419212509679), FRAC_CONST(0.010539090819911) },
+ { FRAC_CONST(0.029386740582307), FRAC_CONST(0.010629298092923) },
+ { FRAC_CONST(0.029353992055740), FRAC_CONST(0.010719405318933) },
+ { FRAC_CONST(0.029320967238220), FRAC_CONST(0.010809411649818) },
+ { FRAC_CONST(0.029287666440590), FRAC_CONST(0.010899316238403) },
+ { FRAC_CONST(0.029254089976290), FRAC_CONST(0.010989118238474) },
+ { FRAC_CONST(0.029220238161353), FRAC_CONST(0.011078816804778) },
+ { FRAC_CONST(0.029186111314406), FRAC_CONST(0.011168411093039) },
+ { FRAC_CONST(0.029151709756664), FRAC_CONST(0.011257900259961) },
+ { FRAC_CONST(0.029117033811927), FRAC_CONST(0.011347283463239) },
+ { FRAC_CONST(0.029082083806579), FRAC_CONST(0.011436559861563) },
+ { FRAC_CONST(0.029046860069582), FRAC_CONST(0.011525728614630) },
+ { FRAC_CONST(0.029011362932476), FRAC_CONST(0.011614788883150) },
+ { FRAC_CONST(0.028975592729373), FRAC_CONST(0.011703739828853) },
+ { FRAC_CONST(0.028939549796957), FRAC_CONST(0.011792580614500) },
+ { FRAC_CONST(0.028903234474475), FRAC_CONST(0.011881310403886) },
+ { FRAC_CONST(0.028866647103744), FRAC_CONST(0.011969928361855) },
+ { FRAC_CONST(0.028829788029135), FRAC_CONST(0.012058433654299) },
+ { FRAC_CONST(0.028792657597583), FRAC_CONST(0.012146825448172) },
+ { FRAC_CONST(0.028755256158571), FRAC_CONST(0.012235102911499) },
+ { FRAC_CONST(0.028717584064137), FRAC_CONST(0.012323265213377) },
+ { FRAC_CONST(0.028679641668864), FRAC_CONST(0.012411311523990) },
+ { FRAC_CONST(0.028641429329882), FRAC_CONST(0.012499241014612) },
+ { FRAC_CONST(0.028602947406859), FRAC_CONST(0.012587052857618) },
+ { FRAC_CONST(0.028564196262001), FRAC_CONST(0.012674746226488) },
+ { FRAC_CONST(0.028525176260050), FRAC_CONST(0.012762320295819) },
+ { FRAC_CONST(0.028485887768276), FRAC_CONST(0.012849774241331) },
+ { FRAC_CONST(0.028446331156478), FRAC_CONST(0.012937107239875) },
+ { FRAC_CONST(0.028406506796976), FRAC_CONST(0.013024318469437) },
+ { FRAC_CONST(0.028366415064615), FRAC_CONST(0.013111407109155) },
+ { FRAC_CONST(0.028326056336751), FRAC_CONST(0.013198372339315) },
+ { FRAC_CONST(0.028285430993258), FRAC_CONST(0.013285213341368) },
+ { FRAC_CONST(0.028244539416515), FRAC_CONST(0.013371929297933) },
+ { FRAC_CONST(0.028203381991411), FRAC_CONST(0.013458519392807) },
+ { FRAC_CONST(0.028161959105334), FRAC_CONST(0.013544982810971) },
+ { FRAC_CONST(0.028120271148172), FRAC_CONST(0.013631318738598) },
+ { FRAC_CONST(0.028078318512309), FRAC_CONST(0.013717526363062) },
+ { FRAC_CONST(0.028036101592619), FRAC_CONST(0.013803604872943) },
+ { FRAC_CONST(0.027993620786463), FRAC_CONST(0.013889553458039) },
+ { FRAC_CONST(0.027950876493687), FRAC_CONST(0.013975371309367) },
+ { FRAC_CONST(0.027907869116616), FRAC_CONST(0.014061057619178) },
+ { FRAC_CONST(0.027864599060052), FRAC_CONST(0.014146611580959) },
+ { FRAC_CONST(0.027821066731270), FRAC_CONST(0.014232032389445) },
+ { FRAC_CONST(0.027777272540012), FRAC_CONST(0.014317319240622) },
+ { FRAC_CONST(0.027733216898487), FRAC_CONST(0.014402471331737) },
+ { FRAC_CONST(0.027688900221361), FRAC_CONST(0.014487487861307) },
+ { FRAC_CONST(0.027644322925762), FRAC_CONST(0.014572368029123) },
+ { FRAC_CONST(0.027599485431266), FRAC_CONST(0.014657111036262) },
+ { FRAC_CONST(0.027554388159903), FRAC_CONST(0.014741716085090) },
+ { FRAC_CONST(0.027509031536144), FRAC_CONST(0.014826182379271) },
+ { FRAC_CONST(0.027463415986904), FRAC_CONST(0.014910509123778) },
+ { FRAC_CONST(0.027417541941533), FRAC_CONST(0.014994695524894) },
+ { FRAC_CONST(0.027371409831816), FRAC_CONST(0.015078740790225) },
+ { FRAC_CONST(0.027325020091965), FRAC_CONST(0.015162644128704) },
+ { FRAC_CONST(0.027278373158618), FRAC_CONST(0.015246404750603) },
+ { FRAC_CONST(0.027231469470833), FRAC_CONST(0.015330021867534) },
+ { FRAC_CONST(0.027184309470088), FRAC_CONST(0.015413494692460) },
+ { FRAC_CONST(0.027136893600268), FRAC_CONST(0.015496822439704) },
+ { FRAC_CONST(0.027089222307671), FRAC_CONST(0.015580004324954) },
+ { FRAC_CONST(0.027041296040997), FRAC_CONST(0.015663039565269) },
+ { FRAC_CONST(0.026993115251345), FRAC_CONST(0.015745927379091) },
+ { FRAC_CONST(0.026944680392213), FRAC_CONST(0.015828666986247) },
+ { FRAC_CONST(0.026895991919487), FRAC_CONST(0.015911257607961) },
+ { FRAC_CONST(0.026847050291442), FRAC_CONST(0.015993698466859) },
+ { FRAC_CONST(0.026797855968734), FRAC_CONST(0.016075988786976) },
+ { FRAC_CONST(0.026748409414401), FRAC_CONST(0.016158127793763) },
+ { FRAC_CONST(0.026698711093851), FRAC_CONST(0.016240114714099) },
+ { FRAC_CONST(0.026648761474864), FRAC_CONST(0.016321948776289) },
+ { FRAC_CONST(0.026598561027585), FRAC_CONST(0.016403629210082) },
+ { FRAC_CONST(0.026548110224519), FRAC_CONST(0.016485155246669) },
+ { FRAC_CONST(0.026497409540530), FRAC_CONST(0.016566526118696) },
+ { FRAC_CONST(0.026446459452830), FRAC_CONST(0.016647741060271) },
+ { FRAC_CONST(0.026395260440982), FRAC_CONST(0.016728799306966) },
+ { FRAC_CONST(0.026343812986890), FRAC_CONST(0.016809700095831) },
+ { FRAC_CONST(0.026292117574797), FRAC_CONST(0.016890442665397) },
+ { FRAC_CONST(0.026240174691280), FRAC_CONST(0.016971026255683) },
+ { FRAC_CONST(0.026187984825246), FRAC_CONST(0.017051450108208) },
+ { FRAC_CONST(0.026135548467924), FRAC_CONST(0.017131713465990) },
+ { FRAC_CONST(0.026082866112867), FRAC_CONST(0.017211815573560) },
+ { FRAC_CONST(0.026029938255941), FRAC_CONST(0.017291755676967) },
+ { FRAC_CONST(0.025976765395322), FRAC_CONST(0.017371533023784) },
+ { FRAC_CONST(0.025923348031494), FRAC_CONST(0.017451146863116) },
+ { FRAC_CONST(0.025869686667242), FRAC_CONST(0.017530596445607) },
+ { FRAC_CONST(0.025815781807646), FRAC_CONST(0.017609881023449) },
+ { FRAC_CONST(0.025761633960080), FRAC_CONST(0.017688999850383) },
+ { FRAC_CONST(0.025707243634204), FRAC_CONST(0.017767952181715) },
+ { FRAC_CONST(0.025652611341960), FRAC_CONST(0.017846737274313) },
+ { FRAC_CONST(0.025597737597568), FRAC_CONST(0.017925354386623) },
+ { FRAC_CONST(0.025542622917522), FRAC_CONST(0.018003802778671) },
+ { FRAC_CONST(0.025487267820581), FRAC_CONST(0.018082081712071) },
+ { FRAC_CONST(0.025431672827768), FRAC_CONST(0.018160190450031) },
+ { FRAC_CONST(0.025375838462365), FRAC_CONST(0.018238128257362) },
+ { FRAC_CONST(0.025319765249906), FRAC_CONST(0.018315894400484) },
+ { FRAC_CONST(0.025263453718173), FRAC_CONST(0.018393488147432) },
+ { FRAC_CONST(0.025206904397193), FRAC_CONST(0.018470908767865) },
+ { FRAC_CONST(0.025150117819228), FRAC_CONST(0.018548155533070) },
+ { FRAC_CONST(0.025093094518776), FRAC_CONST(0.018625227715971) },
+ { FRAC_CONST(0.025035835032562), FRAC_CONST(0.018702124591135) },
+ { FRAC_CONST(0.024978339899534), FRAC_CONST(0.018778845434780) },
+ { FRAC_CONST(0.024920609660858), FRAC_CONST(0.018855389524780) },
+ { FRAC_CONST(0.024862644859912), FRAC_CONST(0.018931756140672) },
+ { FRAC_CONST(0.024804446042284), FRAC_CONST(0.019007944563666) },
+ { FRAC_CONST(0.024746013755764), FRAC_CONST(0.019083954076646) },
+ { FRAC_CONST(0.024687348550337), FRAC_CONST(0.019159783964183) },
+ { FRAC_CONST(0.024628450978184), FRAC_CONST(0.019235433512536) },
+ { FRAC_CONST(0.024569321593670), FRAC_CONST(0.019310902009663) },
+ { FRAC_CONST(0.024509960953345), FRAC_CONST(0.019386188745225) },
+ { FRAC_CONST(0.024450369615932), FRAC_CONST(0.019461293010596) },
+ { FRAC_CONST(0.024390548142329), FRAC_CONST(0.019536214098866) },
+ { FRAC_CONST(0.024330497095598), FRAC_CONST(0.019610951304848) },
+ { FRAC_CONST(0.024270217040961), FRAC_CONST(0.019685503925087) },
+ { FRAC_CONST(0.024209708545799), FRAC_CONST(0.019759871257867) },
+ { FRAC_CONST(0.024148972179639), FRAC_CONST(0.019834052603212) },
+ { FRAC_CONST(0.024088008514157), FRAC_CONST(0.019908047262901) },
+ { FRAC_CONST(0.024026818123164), FRAC_CONST(0.019981854540467) },
+ { FRAC_CONST(0.023965401582609), FRAC_CONST(0.020055473741208) },
+ { FRAC_CONST(0.023903759470567), FRAC_CONST(0.020128904172192) },
+ { FRAC_CONST(0.023841892367236), FRAC_CONST(0.020202145142264) },
+ { FRAC_CONST(0.023779800854935), FRAC_CONST(0.020275195962052) },
+ { FRAC_CONST(0.023717485518092), FRAC_CONST(0.020348055943974) },
+ { FRAC_CONST(0.023654946943242), FRAC_CONST(0.020420724402244) },
+ { FRAC_CONST(0.023592185719023), FRAC_CONST(0.020493200652878) },
+ { FRAC_CONST(0.023529202436167), FRAC_CONST(0.020565484013703) },
+ { FRAC_CONST(0.023465997687496), FRAC_CONST(0.020637573804361) },
+ { FRAC_CONST(0.023402572067918), FRAC_CONST(0.020709469346314) },
+ { FRAC_CONST(0.023338926174419), FRAC_CONST(0.020781169962854) },
+ { FRAC_CONST(0.023275060606058), FRAC_CONST(0.020852674979108) },
+ { FRAC_CONST(0.023210975963963), FRAC_CONST(0.020923983722044) },
+ { FRAC_CONST(0.023146672851322), FRAC_CONST(0.020995095520475) },
+ { FRAC_CONST(0.023082151873380), FRAC_CONST(0.021066009705072) },
+ { FRAC_CONST(0.023017413637435), FRAC_CONST(0.021136725608363) },
+ { FRAC_CONST(0.022952458752826), FRAC_CONST(0.021207242564742) },
+ { FRAC_CONST(0.022887287830934), FRAC_CONST(0.021277559910478) },
+ { FRAC_CONST(0.022821901485173), FRAC_CONST(0.021347676983716) },
+ { FRAC_CONST(0.022756300330983), FRAC_CONST(0.021417593124488) },
+ { FRAC_CONST(0.022690484985827), FRAC_CONST(0.021487307674717) },
+ { FRAC_CONST(0.022624456069185), FRAC_CONST(0.021556819978223) },
+ { FRAC_CONST(0.022558214202547), FRAC_CONST(0.021626129380729) },
+ { FRAC_CONST(0.022491760009405), FRAC_CONST(0.021695235229869) },
+ { FRAC_CONST(0.022425094115252), FRAC_CONST(0.021764136875192) },
+ { FRAC_CONST(0.022358217147572), FRAC_CONST(0.021832833668171) },
+ { FRAC_CONST(0.022291129735838), FRAC_CONST(0.021901324962204) },
+ { FRAC_CONST(0.022223832511501), FRAC_CONST(0.021969610112625) },
+ { FRAC_CONST(0.022156326107988), FRAC_CONST(0.022037688476709) },
+ { FRAC_CONST(0.022088611160696), FRAC_CONST(0.022105559413676) },
+ { FRAC_CONST(0.022020688306983), FRAC_CONST(0.022173222284699) },
+ { FRAC_CONST(0.021952558186166), FRAC_CONST(0.022240676452909) },
+ { FRAC_CONST(0.021884221439510), FRAC_CONST(0.022307921283403) },
+ { FRAC_CONST(0.021815678710228), FRAC_CONST(0.022374956143245) },
+ { FRAC_CONST(0.021746930643469), FRAC_CONST(0.022441780401478) },
+ { FRAC_CONST(0.021677977886316), FRAC_CONST(0.022508393429127) },
+ { FRAC_CONST(0.021608821087780), FRAC_CONST(0.022574794599206) },
+ { FRAC_CONST(0.021539460898790), FRAC_CONST(0.022640983286719) },
+ { FRAC_CONST(0.021469897972190), FRAC_CONST(0.022706958868676) },
+ { FRAC_CONST(0.021400132962735), FRAC_CONST(0.022772720724087) },
+ { FRAC_CONST(0.021330166527077), FRAC_CONST(0.022838268233979) },
+ { FRAC_CONST(0.021259999323769), FRAC_CONST(0.022903600781391) },
+ { FRAC_CONST(0.021189632013250), FRAC_CONST(0.022968717751391) },
+ { FRAC_CONST(0.021119065257845), FRAC_CONST(0.023033618531071) },
+ { FRAC_CONST(0.021048299721754), FRAC_CONST(0.023098302509561) },
+ { FRAC_CONST(0.020977336071050), FRAC_CONST(0.023162769078031) },
+ { FRAC_CONST(0.020906174973670), FRAC_CONST(0.023227017629698) },
+ { FRAC_CONST(0.020834817099409), FRAC_CONST(0.023291047559828) },
+ { FRAC_CONST(0.020763263119915), FRAC_CONST(0.023354858265748) },
+ { FRAC_CONST(0.020691513708680), FRAC_CONST(0.023418449146848) },
+ { FRAC_CONST(0.020619569541038), FRAC_CONST(0.023481819604585) },
+ { FRAC_CONST(0.020547431294155), FRAC_CONST(0.023544969042494) },
+ { FRAC_CONST(0.020475099647023), FRAC_CONST(0.023607896866186) },
+ { FRAC_CONST(0.020402575280455), FRAC_CONST(0.023670602483363) },
+ { FRAC_CONST(0.020329858877078), FRAC_CONST(0.023733085303813) },
+ { FRAC_CONST(0.020256951121327), FRAC_CONST(0.023795344739427) },
+ { FRAC_CONST(0.020183852699437), FRAC_CONST(0.023857380204193) },
+ { FRAC_CONST(0.020110564299439), FRAC_CONST(0.023919191114211) },
+ { FRAC_CONST(0.020037086611150), FRAC_CONST(0.023980776887692) },
+ { FRAC_CONST(0.019963420326171), FRAC_CONST(0.024042136944968) },
+ { FRAC_CONST(0.019889566137877), FRAC_CONST(0.024103270708495) },
+ { FRAC_CONST(0.019815524741412), FRAC_CONST(0.024164177602859) },
+ { FRAC_CONST(0.019741296833681), FRAC_CONST(0.024224857054779) },
+ { FRAC_CONST(0.019666883113346), FRAC_CONST(0.024285308493120) },
+ { FRAC_CONST(0.019592284280817), FRAC_CONST(0.024345531348888) },
+ { FRAC_CONST(0.019517501038246), FRAC_CONST(0.024405525055242) },
+ { FRAC_CONST(0.019442534089523), FRAC_CONST(0.024465289047500) },
+ { FRAC_CONST(0.019367384140264), FRAC_CONST(0.024524822763141) },
+ { FRAC_CONST(0.019292051897809), FRAC_CONST(0.024584125641809) },
+ { FRAC_CONST(0.019216538071215), FRAC_CONST(0.024643197125323) },
+ { FRAC_CONST(0.019140843371246), FRAC_CONST(0.024702036657681) },
+ { FRAC_CONST(0.019064968510369), FRAC_CONST(0.024760643685063) },
+ { FRAC_CONST(0.018988914202748), FRAC_CONST(0.024819017655836) },
+ { FRAC_CONST(0.018912681164234), FRAC_CONST(0.024877158020562) },
+ { FRAC_CONST(0.018836270112363), FRAC_CONST(0.024935064232003) },
+ { FRAC_CONST(0.018759681766343), FRAC_CONST(0.024992735745123) },
+ { FRAC_CONST(0.018682916847054), FRAC_CONST(0.025050172017095) },
+ { FRAC_CONST(0.018605976077037), FRAC_CONST(0.025107372507308) },
+ { FRAC_CONST(0.018528860180486), FRAC_CONST(0.025164336677369) },
+ { FRAC_CONST(0.018451569883247), FRAC_CONST(0.025221063991110) },
+ { FRAC_CONST(0.018374105912805), FRAC_CONST(0.025277553914591) },
+ { FRAC_CONST(0.018296468998280), FRAC_CONST(0.025333805916107) },
+ { FRAC_CONST(0.018218659870421), FRAC_CONST(0.025389819466194) },
+ { FRAC_CONST(0.018140679261596), FRAC_CONST(0.025445594037630) },
+ { FRAC_CONST(0.018062527905790), FRAC_CONST(0.025501129105445) },
+ { FRAC_CONST(0.017984206538592), FRAC_CONST(0.025556424146920) },
+ { FRAC_CONST(0.017905715897192), FRAC_CONST(0.025611478641598) },
+ { FRAC_CONST(0.017827056720375), FRAC_CONST(0.025666292071285) },
+ { FRAC_CONST(0.017748229748511), FRAC_CONST(0.025720863920056) },
+ { FRAC_CONST(0.017669235723550), FRAC_CONST(0.025775193674260) },
+ { FRAC_CONST(0.017590075389012), FRAC_CONST(0.025829280822525) },
+ { FRAC_CONST(0.017510749489986), FRAC_CONST(0.025883124855762) },
+ { FRAC_CONST(0.017431258773116), FRAC_CONST(0.025936725267170) },
+ { FRAC_CONST(0.017351603986600), FRAC_CONST(0.025990081552242) },
+ { FRAC_CONST(0.017271785880180), FRAC_CONST(0.026043193208768) },
+ { FRAC_CONST(0.017191805205132), FRAC_CONST(0.026096059736841) },
+ { FRAC_CONST(0.017111662714267), FRAC_CONST(0.026148680638861) },
+ { FRAC_CONST(0.017031359161915), FRAC_CONST(0.026201055419541) },
+ { FRAC_CONST(0.016950895303924), FRAC_CONST(0.026253183585908) },
+ { FRAC_CONST(0.016870271897651), FRAC_CONST(0.026305064647313) },
+ { FRAC_CONST(0.016789489701954), FRAC_CONST(0.026356698115431) },
+ { FRAC_CONST(0.016708549477186), FRAC_CONST(0.026408083504269) },
+ { FRAC_CONST(0.016627451985187), FRAC_CONST(0.026459220330167) },
+ { FRAC_CONST(0.016546197989277), FRAC_CONST(0.026510108111806) },
+ { FRAC_CONST(0.016464788254250), FRAC_CONST(0.026560746370212) },
+ { FRAC_CONST(0.016383223546365), FRAC_CONST(0.026611134628757) },
+ { FRAC_CONST(0.016301504633341), FRAC_CONST(0.026661272413168) },
+ { FRAC_CONST(0.016219632284346), FRAC_CONST(0.026711159251530) },
+ { FRAC_CONST(0.016137607269996), FRAC_CONST(0.026760794674288) },
+ { FRAC_CONST(0.016055430362340), FRAC_CONST(0.026810178214254) },
+ { FRAC_CONST(0.015973102334858), FRAC_CONST(0.026859309406613) },
+ { FRAC_CONST(0.015890623962454), FRAC_CONST(0.026908187788922) },
+ { FRAC_CONST(0.015807996021446), FRAC_CONST(0.026956812901119) },
+ { FRAC_CONST(0.015725219289558), FRAC_CONST(0.027005184285527) },
+ { FRAC_CONST(0.015642294545918), FRAC_CONST(0.027053301486856) },
+ { FRAC_CONST(0.015559222571044), FRAC_CONST(0.027101164052208) },
+ { FRAC_CONST(0.015476004146842), FRAC_CONST(0.027148771531083) },
+ { FRAC_CONST(0.015392640056594), FRAC_CONST(0.027196123475380) },
+ { FRAC_CONST(0.015309131084956), FRAC_CONST(0.027243219439406) },
+ { FRAC_CONST(0.015225478017946), FRAC_CONST(0.027290058979875) },
+ { FRAC_CONST(0.015141681642938), FRAC_CONST(0.027336641655915) },
+ { FRAC_CONST(0.015057742748656), FRAC_CONST(0.027382967029073) },
+ { FRAC_CONST(0.014973662125164), FRAC_CONST(0.027429034663317) },
+ { FRAC_CONST(0.014889440563862), FRAC_CONST(0.027474844125040) },
+ { FRAC_CONST(0.014805078857474), FRAC_CONST(0.027520394983066) },
+ { FRAC_CONST(0.014720577800046), FRAC_CONST(0.027565686808654) },
+ { FRAC_CONST(0.014635938186934), FRAC_CONST(0.027610719175499) },
+ { FRAC_CONST(0.014551160814797), FRAC_CONST(0.027655491659740) },
+ { FRAC_CONST(0.014466246481592), FRAC_CONST(0.027700003839960) },
+ { FRAC_CONST(0.014381195986567), FRAC_CONST(0.027744255297195) },
+ { FRAC_CONST(0.014296010130247), FRAC_CONST(0.027788245614933) },
+ { FRAC_CONST(0.014210689714436), FRAC_CONST(0.027831974379120) },
+ { FRAC_CONST(0.014125235542201), FRAC_CONST(0.027875441178165) },
+ { FRAC_CONST(0.014039648417870), FRAC_CONST(0.027918645602941) },
+ { FRAC_CONST(0.013953929147020), FRAC_CONST(0.027961587246792) },
+ { FRAC_CONST(0.013868078536476), FRAC_CONST(0.028004265705534) },
+ { FRAC_CONST(0.013782097394294), FRAC_CONST(0.028046680577462) },
+ { FRAC_CONST(0.013695986529763), FRAC_CONST(0.028088831463351) },
+ { FRAC_CONST(0.013609746753390), FRAC_CONST(0.028130717966461) },
+ { FRAC_CONST(0.013523378876898), FRAC_CONST(0.028172339692540) },
+ { FRAC_CONST(0.013436883713214), FRAC_CONST(0.028213696249828) },
+ { FRAC_CONST(0.013350262076462), FRAC_CONST(0.028254787249062) },
+ { FRAC_CONST(0.013263514781960), FRAC_CONST(0.028295612303478) },
+ { FRAC_CONST(0.013176642646205), FRAC_CONST(0.028336171028814) },
+ { FRAC_CONST(0.013089646486871), FRAC_CONST(0.028376463043317) },
+ { FRAC_CONST(0.013002527122799), FRAC_CONST(0.028416487967743) },
+ { FRAC_CONST(0.012915285373990), FRAC_CONST(0.028456245425361) },
+ { FRAC_CONST(0.012827922061597), FRAC_CONST(0.028495735041960) },
+ { FRAC_CONST(0.012740438007915), FRAC_CONST(0.028534956445849) },
+ { FRAC_CONST(0.012652834036379), FRAC_CONST(0.028573909267859) },
+ { FRAC_CONST(0.012565110971550), FRAC_CONST(0.028612593141354) },
+ { FRAC_CONST(0.012477269639111), FRAC_CONST(0.028651007702224) },
+ { FRAC_CONST(0.012389310865858), FRAC_CONST(0.028689152588899) },
+ { FRAC_CONST(0.012301235479693), FRAC_CONST(0.028727027442343) },
+ { FRAC_CONST(0.012213044309615), FRAC_CONST(0.028764631906065) },
+ { FRAC_CONST(0.012124738185712), FRAC_CONST(0.028801965626115) },
+ { FRAC_CONST(0.012036317939156), FRAC_CONST(0.028839028251097) },
+ { FRAC_CONST(0.011947784402191), FRAC_CONST(0.028875819432161) },
+ { FRAC_CONST(0.011859138408130), FRAC_CONST(0.028912338823015) },
+ { FRAC_CONST(0.011770380791341), FRAC_CONST(0.028948586079925) },
+ { FRAC_CONST(0.011681512387245), FRAC_CONST(0.028984560861718) },
+ { FRAC_CONST(0.011592534032306), FRAC_CONST(0.029020262829785) },
+ { FRAC_CONST(0.011503446564022), FRAC_CONST(0.029055691648087) },
+ { FRAC_CONST(0.011414250820918), FRAC_CONST(0.029090846983152) },
+ { FRAC_CONST(0.011324947642537), FRAC_CONST(0.029125728504087) },
+ { FRAC_CONST(0.011235537869437), FRAC_CONST(0.029160335882573) },
+ { FRAC_CONST(0.011146022343175), FRAC_CONST(0.029194668792871) },
+ { FRAC_CONST(0.011056401906305), FRAC_CONST(0.029228726911828) },
+ { FRAC_CONST(0.010966677402371), FRAC_CONST(0.029262509918876) },
+ { FRAC_CONST(0.010876849675891), FRAC_CONST(0.029296017496036) },
+ { FRAC_CONST(0.010786919572361), FRAC_CONST(0.029329249327922) },
+ { FRAC_CONST(0.010696887938235), FRAC_CONST(0.029362205101743) },
+ { FRAC_CONST(0.010606755620926), FRAC_CONST(0.029394884507308) },
+ { FRAC_CONST(0.010516523468793), FRAC_CONST(0.029427287237024) },
+ { FRAC_CONST(0.010426192331137), FRAC_CONST(0.029459412985906) },
+ { FRAC_CONST(0.010335763058187), FRAC_CONST(0.029491261451573) },
+ { FRAC_CONST(0.010245236501099), FRAC_CONST(0.029522832334255) },
+ { FRAC_CONST(0.010154613511943), FRAC_CONST(0.029554125336796) },
+ { FRAC_CONST(0.010063894943698), FRAC_CONST(0.029585140164654) },
+ { FRAC_CONST(0.009973081650240), FRAC_CONST(0.029615876525905) },
+ { FRAC_CONST(0.009882174486340), FRAC_CONST(0.029646334131247) },
+ { FRAC_CONST(0.009791174307650), FRAC_CONST(0.029676512694001) },
+ { FRAC_CONST(0.009700081970699), FRAC_CONST(0.029706411930116) },
+ { FRAC_CONST(0.009608898332881), FRAC_CONST(0.029736031558168) },
+ { FRAC_CONST(0.009517624252453), FRAC_CONST(0.029765371299366) },
+ { FRAC_CONST(0.009426260588521), FRAC_CONST(0.029794430877553) },
+ { FRAC_CONST(0.009334808201034), FRAC_CONST(0.029823210019210) },
+ { FRAC_CONST(0.009243267950778), FRAC_CONST(0.029851708453456) },
+ { FRAC_CONST(0.009151640699363), FRAC_CONST(0.029879925912053) },
+ { FRAC_CONST(0.009059927309220), FRAC_CONST(0.029907862129408) },
+ { FRAC_CONST(0.008968128643591), FRAC_CONST(0.029935516842573) },
+ { FRAC_CONST(0.008876245566520), FRAC_CONST(0.029962889791254) },
+ { FRAC_CONST(0.008784278942845), FRAC_CONST(0.029989980717805) },
+ { FRAC_CONST(0.008692229638191), FRAC_CONST(0.030016789367235) },
+ { FRAC_CONST(0.008600098518961), FRAC_CONST(0.030043315487212) },
+ { FRAC_CONST(0.008507886452329), FRAC_CONST(0.030069558828062) },
+ { FRAC_CONST(0.008415594306230), FRAC_CONST(0.030095519142772) },
+ { FRAC_CONST(0.008323222949351), FRAC_CONST(0.030121196186994) },
+ { FRAC_CONST(0.008230773251129), FRAC_CONST(0.030146589719046) },
+ { FRAC_CONST(0.008138246081733), FRAC_CONST(0.030171699499915) },
+ { FRAC_CONST(0.008045642312067), FRAC_CONST(0.030196525293257) },
+ { FRAC_CONST(0.007952962813750), FRAC_CONST(0.030221066865402) },
+ { FRAC_CONST(0.007860208459119), FRAC_CONST(0.030245323985357) },
+ { FRAC_CONST(0.007767380121212), FRAC_CONST(0.030269296424803) },
+ { FRAC_CONST(0.007674478673766), FRAC_CONST(0.030292983958103) },
+ { FRAC_CONST(0.007581504991203), FRAC_CONST(0.030316386362302) },
+ { FRAC_CONST(0.007488459948628), FRAC_CONST(0.030339503417126) },
+ { FRAC_CONST(0.007395344421816), FRAC_CONST(0.030362334904989) },
+ { FRAC_CONST(0.007302159287206), FRAC_CONST(0.030384880610993) },
+ { FRAC_CONST(0.007208905421891), FRAC_CONST(0.030407140322928) },
+ { FRAC_CONST(0.007115583703613), FRAC_CONST(0.030429113831278) },
+ { FRAC_CONST(0.007022195010752), FRAC_CONST(0.030450800929220) },
+ { FRAC_CONST(0.006928740222316), FRAC_CONST(0.030472201412626) },
+ { FRAC_CONST(0.006835220217939), FRAC_CONST(0.030493315080068) },
+ { FRAC_CONST(0.006741635877866), FRAC_CONST(0.030514141732814) },
+ { FRAC_CONST(0.006647988082948), FRAC_CONST(0.030534681174838) },
+ { FRAC_CONST(0.006554277714635), FRAC_CONST(0.030554933212813) },
+ { FRAC_CONST(0.006460505654964), FRAC_CONST(0.030574897656119) },
+ { FRAC_CONST(0.006366672786553), FRAC_CONST(0.030594574316845) },
+ { FRAC_CONST(0.006272779992593), FRAC_CONST(0.030613963009786) },
+ { FRAC_CONST(0.006178828156839), FRAC_CONST(0.030633063552447) },
+ { FRAC_CONST(0.006084818163601), FRAC_CONST(0.030651875765048) },
+ { FRAC_CONST(0.005990750897737), FRAC_CONST(0.030670399470520) },
+ { FRAC_CONST(0.005896627244644), FRAC_CONST(0.030688634494512) },
+ { FRAC_CONST(0.005802448090250), FRAC_CONST(0.030706580665388) },
+ { FRAC_CONST(0.005708214321004), FRAC_CONST(0.030724237814232) },
+ { FRAC_CONST(0.005613926823871), FRAC_CONST(0.030741605774849) },
+ { FRAC_CONST(0.005519586486321), FRAC_CONST(0.030758684383764) },
+ { FRAC_CONST(0.005425194196321), FRAC_CONST(0.030775473480228) },
+ { FRAC_CONST(0.005330750842327), FRAC_CONST(0.030791972906214) },
+ { FRAC_CONST(0.005236257313276), FRAC_CONST(0.030808182506425) },
+ { FRAC_CONST(0.005141714498576), FRAC_CONST(0.030824102128288) },
+ { FRAC_CONST(0.005047123288102), FRAC_CONST(0.030839731621963) },
+ { FRAC_CONST(0.004952484572181), FRAC_CONST(0.030855070840339) },
+ { FRAC_CONST(0.004857799241589), FRAC_CONST(0.030870119639036) },
+ { FRAC_CONST(0.004763068187541), FRAC_CONST(0.030884877876411) },
+ { FRAC_CONST(0.004668292301681), FRAC_CONST(0.030899345413553) },
+ { FRAC_CONST(0.004573472476075), FRAC_CONST(0.030913522114288) },
+ { FRAC_CONST(0.004478609603205), FRAC_CONST(0.030927407845180) },
+ { FRAC_CONST(0.004383704575956), FRAC_CONST(0.030941002475530) },
+ { FRAC_CONST(0.004288758287610), FRAC_CONST(0.030954305877381) },
+ { FRAC_CONST(0.004193771631837), FRAC_CONST(0.030967317925516) },
+ { FRAC_CONST(0.004098745502689), FRAC_CONST(0.030980038497461) },
+ { FRAC_CONST(0.004003680794587), FRAC_CONST(0.030992467473486) },
+ { FRAC_CONST(0.003908578402316), FRAC_CONST(0.031004604736602) },
+ { FRAC_CONST(0.003813439221017), FRAC_CONST(0.031016450172571) },
+ { FRAC_CONST(0.003718264146176), FRAC_CONST(0.031028003669899) },
+ { FRAC_CONST(0.003623054073616), FRAC_CONST(0.031039265119839) },
+ { FRAC_CONST(0.003527809899492), FRAC_CONST(0.031050234416394) },
+ { FRAC_CONST(0.003432532520278), FRAC_CONST(0.031060911456318) },
+ { FRAC_CONST(0.003337222832760), FRAC_CONST(0.031071296139114) },
+ { FRAC_CONST(0.003241881734029), FRAC_CONST(0.031081388367037) },
+ { FRAC_CONST(0.003146510121474), FRAC_CONST(0.031091188045095) },
+ { FRAC_CONST(0.003051108892766), FRAC_CONST(0.031100695081051) },
+ { FRAC_CONST(0.002955678945860), FRAC_CONST(0.031109909385419) },
+ { FRAC_CONST(0.002860221178978), FRAC_CONST(0.031118830871473) },
+ { FRAC_CONST(0.002764736490604), FRAC_CONST(0.031127459455239) },
+ { FRAC_CONST(0.002669225779478), FRAC_CONST(0.031135795055501) },
+ { FRAC_CONST(0.002573689944583), FRAC_CONST(0.031143837593803) },
+ { FRAC_CONST(0.002478129885137), FRAC_CONST(0.031151586994444) },
+ { FRAC_CONST(0.002382546500589), FRAC_CONST(0.031159043184484) },
+ { FRAC_CONST(0.002286940690606), FRAC_CONST(0.031166206093743) },
+ { FRAC_CONST(0.002191313355067), FRAC_CONST(0.031173075654800) },
+ { FRAC_CONST(0.002095665394051), FRAC_CONST(0.031179651802998) },
+ { FRAC_CONST(0.001999997707835), FRAC_CONST(0.031185934476438) },
+ { FRAC_CONST(0.001904311196878), FRAC_CONST(0.031191923615985) },
+ { FRAC_CONST(0.001808606761820), FRAC_CONST(0.031197619165268) },
+ { FRAC_CONST(0.001712885303465), FRAC_CONST(0.031203021070678) },
+ { FRAC_CONST(0.001617147722782), FRAC_CONST(0.031208129281370) },
+ { FRAC_CONST(0.001521394920889), FRAC_CONST(0.031212943749264) },
+ { FRAC_CONST(0.001425627799047), FRAC_CONST(0.031217464429043) },
+ { FRAC_CONST(0.001329847258653), FRAC_CONST(0.031221691278159) },
+ { FRAC_CONST(0.001234054201231), FRAC_CONST(0.031225624256825) },
+ { FRAC_CONST(0.001138249528420), FRAC_CONST(0.031229263328024) },
+ { FRAC_CONST(0.001042434141971), FRAC_CONST(0.031232608457502) },
+ { FRAC_CONST(0.000946608943736), FRAC_CONST(0.031235659613775) },
+ { FRAC_CONST(0.000850774835656), FRAC_CONST(0.031238416768124) },
+ { FRAC_CONST(0.000754932719759), FRAC_CONST(0.031240879894597) },
+ { FRAC_CONST(0.000659083498149), FRAC_CONST(0.031243048970010) },
+ { FRAC_CONST(0.000563228072993), FRAC_CONST(0.031244923973948) },
+ { FRAC_CONST(0.000467367346520), FRAC_CONST(0.031246504888762) },
+ { FRAC_CONST(0.000371502221008), FRAC_CONST(0.031247791699571) },
+ { FRAC_CONST(0.000275633598775), FRAC_CONST(0.031248784394264) },
+ { FRAC_CONST(0.000179762382174), FRAC_CONST(0.031249482963498) },
+ { FRAC_CONST(0.000083889473581), FRAC_CONST(0.031249887400697) }
+ };
+
+ /* 64 (N/4) complex twiddle factors */
+ ALIGN static const complex_t mdct_tab_256[] = {
+ { FRAC_CONST(0.088387931675923), FRAC_CONST(0.000271171628935) },
+ { FRAC_CONST(0.088354655998507), FRAC_CONST(0.002440238387037) },
+ { FRAC_CONST(0.088268158780110), FRAC_CONST(0.004607835236780) },
+ { FRAC_CONST(0.088128492123423), FRAC_CONST(0.006772656498875) },
+ { FRAC_CONST(0.087935740158418), FRAC_CONST(0.008933398165942) },
+ { FRAC_CONST(0.087690018991670), FRAC_CONST(0.011088758687994) },
+ { FRAC_CONST(0.087391476636423), FRAC_CONST(0.013237439756448) },
+ { FRAC_CONST(0.087040292923427), FRAC_CONST(0.015378147086172) },
+ { FRAC_CONST(0.086636679392621), FRAC_CONST(0.017509591195118) },
+ { FRAC_CONST(0.086180879165703), FRAC_CONST(0.019630488181053) },
+ { FRAC_CONST(0.085673166799686), FRAC_CONST(0.021739560494940) },
+ { FRAC_CONST(0.085113848121515), FRAC_CONST(0.023835537710479) },
+ { FRAC_CONST(0.084503260043847), FRAC_CONST(0.025917157289369) },
+ { FRAC_CONST(0.083841770362110), FRAC_CONST(0.027983165341813) },
+ { FRAC_CONST(0.083129777532952), FRAC_CONST(0.030032317381813) },
+ { FRAC_CONST(0.082367710434230), FRAC_CONST(0.032063379076803) },
+ { FRAC_CONST(0.081556028106671), FRAC_CONST(0.034075126991164) },
+ { FRAC_CONST(0.080695219477356), FRAC_CONST(0.036066349323177) },
+ { FRAC_CONST(0.079785803065216), FRAC_CONST(0.038035846634965) },
+ { FRAC_CONST(0.078828326668693), FRAC_CONST(0.039982432574992) },
+ { FRAC_CONST(0.077823367035766), FRAC_CONST(0.041904934592675) },
+ { FRAC_CONST(0.076771529516540), FRAC_CONST(0.043802194644686) },
+ { FRAC_CONST(0.075673447698606), FRAC_CONST(0.045673069892513) },
+ { FRAC_CONST(0.074529783025390), FRAC_CONST(0.047516433390863) },
+ { FRAC_CONST(0.073341224397728), FRAC_CONST(0.049331174766491) },
+ { FRAC_CONST(0.072108487758894), FRAC_CONST(0.051116200887052) },
+ { FRAC_CONST(0.070832315663343), FRAC_CONST(0.052870436519557) },
+ { FRAC_CONST(0.069513476829429), FRAC_CONST(0.054592824978055) },
+ { FRAC_CONST(0.068152765676348), FRAC_CONST(0.056282328760143) },
+ { FRAC_CONST(0.066751001845620), FRAC_CONST(0.057937930171918) },
+ { FRAC_CONST(0.065309029707361), FRAC_CONST(0.059558631940996) },
+ { FRAC_CONST(0.063827717851668), FRAC_CONST(0.061143457817234) },
+ { FRAC_CONST(0.062307958565413), FRAC_CONST(0.062691453160784) },
+ { FRAC_CONST(0.060750667294763), FRAC_CONST(0.064201685517134) },
+ { FRAC_CONST(0.059156782093749), FRAC_CONST(0.065673245178784) },
+ { FRAC_CONST(0.057527263059216), FRAC_CONST(0.067105245733220) },
+ { FRAC_CONST(0.055863091752499), FRAC_CONST(0.068496824596852) },
+ { FRAC_CONST(0.054165270608165), FRAC_CONST(0.069847143534609) },
+ { FRAC_CONST(0.052434822330188), FRAC_CONST(0.071155389164853) },
+ { FRAC_CONST(0.050672789275903), FRAC_CONST(0.072420773449336) },
+ { FRAC_CONST(0.048880232828135), FRAC_CONST(0.073642534167879) },
+ { FRAC_CONST(0.047058232755862), FRAC_CONST(0.074819935377512) },
+ { FRAC_CONST(0.045207886563797), FRAC_CONST(0.075952267855771) },
+ { FRAC_CONST(0.043330308831298), FRAC_CONST(0.077038849527912) },
+ { FRAC_CONST(0.041426630540984), FRAC_CONST(0.078079025877766) },
+ { FRAC_CONST(0.039497998397473), FRAC_CONST(0.079072170341994) },
+ { FRAC_CONST(0.037545574136653), FRAC_CONST(0.080017684687506) },
+ { FRAC_CONST(0.035570533825892), FRAC_CONST(0.080914999371817) },
+ { FRAC_CONST(0.033574067155622), FRAC_CONST(0.081763573886112) },
+ { FRAC_CONST(0.031557376722714), FRAC_CONST(0.082562897080836) },
+ { FRAC_CONST(0.029521677306074), FRAC_CONST(0.083312487473584) },
+ { FRAC_CONST(0.027468195134911), FRAC_CONST(0.084011893539132) },
+ { FRAC_CONST(0.025398167150101), FRAC_CONST(0.084660693981419) },
+ { FRAC_CONST(0.023312840259098), FRAC_CONST(0.085258497987320) },
+ { FRAC_CONST(0.021213470584847), FRAC_CONST(0.085804945462053) },
+ { FRAC_CONST(0.019101322709138), FRAC_CONST(0.086299707246093) },
+ { FRAC_CONST(0.016977668910873), FRAC_CONST(0.086742485313442) },
+ { FRAC_CONST(0.014843788399692), FRAC_CONST(0.087133012951149) },
+ { FRAC_CONST(0.012700966545425), FRAC_CONST(0.087471054919968) },
+ { FRAC_CONST(0.010550494103830), FRAC_CONST(0.087756407596056) },
+ { FRAC_CONST(0.008393666439096), FRAC_CONST(0.087988899093631) },
+ { FRAC_CONST(0.006231782743558), FRAC_CONST(0.088168389368510) },
+ { FRAC_CONST(0.004066145255116), FRAC_CONST(0.088294770302461) },
+ { FRAC_CONST(0.001898058472816), FRAC_CONST(0.088367965768336) }
+ };
+
+#ifdef LD_DEC
+ /* 128 (N/4) complex twiddle factors */
+ ALIGN static const complex_t mdct_tab_1024[] = {
+ { FRAC_CONST(0.044194160825012), FRAC_CONST(0.000033896503468) },
+ { FRAC_CONST(0.044193120897389), FRAC_CONST(0.000305066138364) },
+ { FRAC_CONST(0.044190417123742), FRAC_CONST(0.000576224287693) },
+ { FRAC_CONST(0.044186049605866), FRAC_CONST(0.000847360742503) },
+ { FRAC_CONST(0.044180018508197), FRAC_CONST(0.001118465294660) },
+ { FRAC_CONST(0.044172324057802), FRAC_CONST(0.001389527737231) },
+ { FRAC_CONST(0.044162966544372), FRAC_CONST(0.001660537864867) },
+ { FRAC_CONST(0.044151946320213), FRAC_CONST(0.001931485474192) },
+ { FRAC_CONST(0.044139263800230), FRAC_CONST(0.002202360364180) },
+ { FRAC_CONST(0.044124919461912), FRAC_CONST(0.002473152336546) },
+ { FRAC_CONST(0.044108913845316), FRAC_CONST(0.002743851196123) },
+ { FRAC_CONST(0.044091247553044), FRAC_CONST(0.003014446751254) },
+ { FRAC_CONST(0.044071921250223), FRAC_CONST(0.003284928814169) },
+ { FRAC_CONST(0.044050935664476), FRAC_CONST(0.003555287201370) },
+ { FRAC_CONST(0.044028291585898), FRAC_CONST(0.003825511734018) },
+ { FRAC_CONST(0.044003989867028), FRAC_CONST(0.004095592238311) },
+ { FRAC_CONST(0.043978031422810), FRAC_CONST(0.004365518545871) },
+ { FRAC_CONST(0.043950417230565), FRAC_CONST(0.004635280494126) },
+ { FRAC_CONST(0.043921148329953), FRAC_CONST(0.004904867926689) },
+ { FRAC_CONST(0.043890225822930), FRAC_CONST(0.005174270693748) },
+ { FRAC_CONST(0.043857650873712), FRAC_CONST(0.005443478652439) },
+ { FRAC_CONST(0.043823424708727), FRAC_CONST(0.005712481667236) },
+ { FRAC_CONST(0.043787548616571), FRAC_CONST(0.005981269610326) },
+ { FRAC_CONST(0.043750023947958), FRAC_CONST(0.006249832361997) },
+ { FRAC_CONST(0.043710852115672), FRAC_CONST(0.006518159811011) },
+ { FRAC_CONST(0.043670034594508), FRAC_CONST(0.006786241854993) },
+ { FRAC_CONST(0.043627572921225), FRAC_CONST(0.007054068400804) },
+ { FRAC_CONST(0.043583468694479), FRAC_CONST(0.007321629364927) },
+ { FRAC_CONST(0.043537723574771), FRAC_CONST(0.007588914673843) },
+ { FRAC_CONST(0.043490339284377), FRAC_CONST(0.007855914264410) },
+ { FRAC_CONST(0.043441317607290), FRAC_CONST(0.008122618084246) },
+ { FRAC_CONST(0.043390660389149), FRAC_CONST(0.008389016092101) },
+ { FRAC_CONST(0.043338369537168), FRAC_CONST(0.008655098258243) },
+ { FRAC_CONST(0.043284447020070), FRAC_CONST(0.008920854564826) },
+ { FRAC_CONST(0.043228894868005), FRAC_CONST(0.009186275006278) },
+ { FRAC_CONST(0.043171715172482), FRAC_CONST(0.009451349589667) },
+ { FRAC_CONST(0.043112910086283), FRAC_CONST(0.009716068335087) },
+ { FRAC_CONST(0.043052481823387), FRAC_CONST(0.009980421276025) },
+ { FRAC_CONST(0.042990432658884), FRAC_CONST(0.010244398459743) },
+ { FRAC_CONST(0.042926764928889), FRAC_CONST(0.010507989947649) },
+ { FRAC_CONST(0.042861481030457), FRAC_CONST(0.010771185815673) },
+ { FRAC_CONST(0.042794583421490), FRAC_CONST(0.011033976154639) },
+ { FRAC_CONST(0.042726074620644), FRAC_CONST(0.011296351070639) },
+ { FRAC_CONST(0.042655957207238), FRAC_CONST(0.011558300685406) },
+ { FRAC_CONST(0.042584233821153), FRAC_CONST(0.011819815136685) },
+ { FRAC_CONST(0.042510907162732), FRAC_CONST(0.012080884578604) },
+ { FRAC_CONST(0.042435979992684), FRAC_CONST(0.012341499182048) },
+ { FRAC_CONST(0.042359455131975), FRAC_CONST(0.012601649135022) },
+ { FRAC_CONST(0.042281335461721), FRAC_CONST(0.012861324643029) },
+ { FRAC_CONST(0.042201623923085), FRAC_CONST(0.013120515929433) },
+ { FRAC_CONST(0.042120323517160), FRAC_CONST(0.013379213235827) },
+ { FRAC_CONST(0.042037437304862), FRAC_CONST(0.013637406822406) },
+ { FRAC_CONST(0.041952968406809), FRAC_CONST(0.013895086968325) },
+ { FRAC_CONST(0.041866920003207), FRAC_CONST(0.014152243972073) },
+ { FRAC_CONST(0.041779295333730), FRAC_CONST(0.014408868151835) },
+ { FRAC_CONST(0.041690097697398), FRAC_CONST(0.014664949845855) },
+ { FRAC_CONST(0.041599330452450), FRAC_CONST(0.014920479412801) },
+ { FRAC_CONST(0.041506997016224), FRAC_CONST(0.015175447232131) },
+ { FRAC_CONST(0.041413100865019), FRAC_CONST(0.015429843704450) },
+ { FRAC_CONST(0.041317645533974), FRAC_CONST(0.015683659251874) },
+ { FRAC_CONST(0.041220634616927), FRAC_CONST(0.015936884318392) },
+ { FRAC_CONST(0.041122071766285), FRAC_CONST(0.016189509370223) },
+ { FRAC_CONST(0.041021960692883), FRAC_CONST(0.016441524896177) },
+ { FRAC_CONST(0.040920305165846), FRAC_CONST(0.016692921408010) },
+ { FRAC_CONST(0.040817109012449), FRAC_CONST(0.016943689440788) },
+ { FRAC_CONST(0.040712376117967), FRAC_CONST(0.017193819553235) },
+ { FRAC_CONST(0.040606110425535), FRAC_CONST(0.017443302328094) },
+ { FRAC_CONST(0.040498315935996), FRAC_CONST(0.017692128372479) },
+ { FRAC_CONST(0.040388996707752), FRAC_CONST(0.017940288318230) },
+ { FRAC_CONST(0.040278156856609), FRAC_CONST(0.018187772822267) },
+ { FRAC_CONST(0.040165800555627), FRAC_CONST(0.018434572566936) },
+ { FRAC_CONST(0.040051932034955), FRAC_CONST(0.018680678260367) },
+ { FRAC_CONST(0.039936555581679), FRAC_CONST(0.018926080636820) },
+ { FRAC_CONST(0.039819675539659), FRAC_CONST(0.019170770457035) },
+ { FRAC_CONST(0.039701296309360), FRAC_CONST(0.019414738508577) },
+ { FRAC_CONST(0.039581422347694), FRAC_CONST(0.019657975606187) },
+ { FRAC_CONST(0.039460058167849), FRAC_CONST(0.019900472592126) },
+ { FRAC_CONST(0.039337208339116), FRAC_CONST(0.020142220336521) },
+ { FRAC_CONST(0.039212877486723), FRAC_CONST(0.020383209737704) },
+ { FRAC_CONST(0.039087070291656), FRAC_CONST(0.020623431722561) },
+ { FRAC_CONST(0.038959791490485), FRAC_CONST(0.020862877246870) },
+ { FRAC_CONST(0.038831045875184), FRAC_CONST(0.021101537295642) },
+ { FRAC_CONST(0.038700838292953), FRAC_CONST(0.021339402883462) },
+ { FRAC_CONST(0.038569173646034), FRAC_CONST(0.021576465054824) },
+ { FRAC_CONST(0.038436056891527), FRAC_CONST(0.021812714884472) },
+ { FRAC_CONST(0.038301493041202), FRAC_CONST(0.022048143477734) },
+ { FRAC_CONST(0.038165487161312), FRAC_CONST(0.022282741970855) },
+ { FRAC_CONST(0.038028044372402), FRAC_CONST(0.022516501531335) },
+ { FRAC_CONST(0.037889169849115), FRAC_CONST(0.022749413358259) },
+ { FRAC_CONST(0.037748868819998), FRAC_CONST(0.022981468682628) },
+ { FRAC_CONST(0.037607146567305), FRAC_CONST(0.023212658767690) },
+ { FRAC_CONST(0.037464008426800), FRAC_CONST(0.023442974909269) },
+ { FRAC_CONST(0.037319459787553), FRAC_CONST(0.023672408436094) },
+ { FRAC_CONST(0.037173506091737), FRAC_CONST(0.023900950710120) },
+ { FRAC_CONST(0.037026152834428), FRAC_CONST(0.024128593126861) },
+ { FRAC_CONST(0.036877405563392), FRAC_CONST(0.024355327115708) },
+ { FRAC_CONST(0.036727269878879), FRAC_CONST(0.024581144140255) },
+ { FRAC_CONST(0.036575751433414), FRAC_CONST(0.024806035698618) },
+ { FRAC_CONST(0.036422855931580), FRAC_CONST(0.025029993323758) },
+ { FRAC_CONST(0.036268589129807), FRAC_CONST(0.025253008583796) },
+ { FRAC_CONST(0.036112956836151), FRAC_CONST(0.025475073082334) },
+ { FRAC_CONST(0.035955964910083), FRAC_CONST(0.025696178458769) },
+ { FRAC_CONST(0.035797619262257), FRAC_CONST(0.025916316388609) },
+ { FRAC_CONST(0.035637925854300), FRAC_CONST(0.026135478583784) },
+ { FRAC_CONST(0.035476890698576), FRAC_CONST(0.026353656792963) },
+ { FRAC_CONST(0.035314519857970), FRAC_CONST(0.026570842801858) },
+ { FRAC_CONST(0.035150819445650), FRAC_CONST(0.026787028433540) },
+ { FRAC_CONST(0.034985795624846), FRAC_CONST(0.027002205548742) },
+ { FRAC_CONST(0.034819454608610), FRAC_CONST(0.027216366046166) },
+ { FRAC_CONST(0.034651802659589), FRAC_CONST(0.027429501862792) },
+ { FRAC_CONST(0.034482846089783), FRAC_CONST(0.027641604974175) },
+ { FRAC_CONST(0.034312591260311), FRAC_CONST(0.027852667394755) },
+ { FRAC_CONST(0.034141044581172), FRAC_CONST(0.028062681178149) },
+ { FRAC_CONST(0.033968212511001), FRAC_CONST(0.028271638417458) },
+ { FRAC_CONST(0.033794101556828), FRAC_CONST(0.028479531245560) },
+ { FRAC_CONST(0.033618718273831), FRAC_CONST(0.028686351835407) },
+ { FRAC_CONST(0.033442069265093), FRAC_CONST(0.028892092400321) },
+ { FRAC_CONST(0.033264161181349), FRAC_CONST(0.029096745194286) },
+ { FRAC_CONST(0.033085000720737), FRAC_CONST(0.029300302512241) },
+ { FRAC_CONST(0.032904594628548), FRAC_CONST(0.029502756690366) },
+ { FRAC_CONST(0.032722949696969), FRAC_CONST(0.029704100106376) },
+ { FRAC_CONST(0.032540072764829), FRAC_CONST(0.029904325179807) },
+ { FRAC_CONST(0.032355970717341), FRAC_CONST(0.030103424372297) },
+ { FRAC_CONST(0.032170650485843), FRAC_CONST(0.030301390187873) },
+ { FRAC_CONST(0.031984119047537), FRAC_CONST(0.030498215173235) },
+ { FRAC_CONST(0.031796383425227), FRAC_CONST(0.030693891918034) },
+ { FRAC_CONST(0.031607450687052), FRAC_CONST(0.030888413055150) },
+ { FRAC_CONST(0.031417327946223), FRAC_CONST(0.031081771260973) },
+ { FRAC_CONST(0.031226022360754), FRAC_CONST(0.031273959255676) },
+ { FRAC_CONST(0.031033541133193), FRAC_CONST(0.031464969803488) },
+ { FRAC_CONST(0.030839891510348), FRAC_CONST(0.031654795712972) },
+ { FRAC_CONST(0.030645080783018), FRAC_CONST(0.031843429837288) },
+ { FRAC_CONST(0.030449116285718), FRAC_CONST(0.032030865074469) },
+ { FRAC_CONST(0.030252005396399), FRAC_CONST(0.032217094367684) },
+ { FRAC_CONST(0.030053755536176), FRAC_CONST(0.032402110705505) },
+ { FRAC_CONST(0.029854374169043), FRAC_CONST(0.032585907122172) },
+ { FRAC_CONST(0.029653868801596), FRAC_CONST(0.032768476697853) },
+ { FRAC_CONST(0.029452246982750), FRAC_CONST(0.032949812558907) },
+ { FRAC_CONST(0.029249516303451), FRAC_CONST(0.033129907878142) },
+ { FRAC_CONST(0.029045684396395), FRAC_CONST(0.033308755875070) },
+ { FRAC_CONST(0.028840758935738), FRAC_CONST(0.033486349816166) },
+ { FRAC_CONST(0.028634747636808), FRAC_CONST(0.033662683015118) },
+ { FRAC_CONST(0.028427658255815), FRAC_CONST(0.033837748833080) },
+ { FRAC_CONST(0.028219498589555), FRAC_CONST(0.034011540678924) },
+ { FRAC_CONST(0.028010276475123), FRAC_CONST(0.034184052009485) },
+ { FRAC_CONST(0.027799999789613), FRAC_CONST(0.034355276329809) },
+ { FRAC_CONST(0.027588676449824), FRAC_CONST(0.034525207193396) },
+ { FRAC_CONST(0.027376314411959), FRAC_CONST(0.034693838202447) },
+ { FRAC_CONST(0.027162921671330), FRAC_CONST(0.034861163008098) },
+ { FRAC_CONST(0.026948506262053), FRAC_CONST(0.035027175310665) },
+ { FRAC_CONST(0.026733076256746), FRAC_CONST(0.035191868859880) },
+ { FRAC_CONST(0.026516639766228), FRAC_CONST(0.035355237455122) },
+ { FRAC_CONST(0.026299204939210), FRAC_CONST(0.035517274945657) },
+ { FRAC_CONST(0.026080779961991), FRAC_CONST(0.035677975230865) },
+ { FRAC_CONST(0.025861373058146), FRAC_CONST(0.035837332260471) },
+ { FRAC_CONST(0.025640992488223), FRAC_CONST(0.035995340034772) },
+ { FRAC_CONST(0.025419646549425), FRAC_CONST(0.036151992604866) },
+ { FRAC_CONST(0.025197343575302), FRAC_CONST(0.036307284072871) },
+ { FRAC_CONST(0.024974091935435), FRAC_CONST(0.036461208592152) },
+ { FRAC_CONST(0.024749900035122), FRAC_CONST(0.036613760367538) },
+ { FRAC_CONST(0.024524776315061), FRAC_CONST(0.036764933655540) },
+ { FRAC_CONST(0.024298729251033), FRAC_CONST(0.036914722764569) },
+ { FRAC_CONST(0.024071767353583), FRAC_CONST(0.037063122055150) },
+ { FRAC_CONST(0.023843899167697), FRAC_CONST(0.037210125940135) },
+ { FRAC_CONST(0.023615133272485), FRAC_CONST(0.037355728884908) },
+ { FRAC_CONST(0.023385478280852), FRAC_CONST(0.037499925407603) },
+ { FRAC_CONST(0.023154942839179), FRAC_CONST(0.037642710079302) },
+ { FRAC_CONST(0.022923535626995), FRAC_CONST(0.037784077524241) },
+ { FRAC_CONST(0.022691265356652), FRAC_CONST(0.037924022420018) },
+ { FRAC_CONST(0.022458140772993), FRAC_CONST(0.038062539497785) },
+ { FRAC_CONST(0.022224170653027), FRAC_CONST(0.038199623542453) },
+ { FRAC_CONST(0.021989363805598), FRAC_CONST(0.038335269392885) },
+ { FRAC_CONST(0.021753729071049), FRAC_CONST(0.038469471942092) },
+ { FRAC_CONST(0.021517275320897), FRAC_CONST(0.038602226137423) },
+ { FRAC_CONST(0.021280011457490), FRAC_CONST(0.038733526980758) },
+ { FRAC_CONST(0.021041946413679), FRAC_CONST(0.038863369528695) },
+ { FRAC_CONST(0.020803089152479), FRAC_CONST(0.038991748892734) },
+ { FRAC_CONST(0.020563448666730), FRAC_CONST(0.039118660239466) },
+ { FRAC_CONST(0.020323033978761), FRAC_CONST(0.039244098790750) },
+ { FRAC_CONST(0.020081854140050), FRAC_CONST(0.039368059823895) },
+ { FRAC_CONST(0.019839918230880), FRAC_CONST(0.039490538671839) },
+ { FRAC_CONST(0.019597235360003), FRAC_CONST(0.039611530723322) },
+ { FRAC_CONST(0.019353814664291), FRAC_CONST(0.039731031423061) },
+ { FRAC_CONST(0.019109665308395), FRAC_CONST(0.039849036271924) },
+ { FRAC_CONST(0.018864796484402), FRAC_CONST(0.039965540827094) },
+ { FRAC_CONST(0.018619217411483), FRAC_CONST(0.040080540702240) },
+ { FRAC_CONST(0.018372937335552), FRAC_CONST(0.040194031567683) },
+ { FRAC_CONST(0.018125965528915), FRAC_CONST(0.040306009150554) },
+ { FRAC_CONST(0.017878311289921), FRAC_CONST(0.040416469234963) },
+ { FRAC_CONST(0.017629983942612), FRAC_CONST(0.040525407662148) },
+ { FRAC_CONST(0.017380992836371), FRAC_CONST(0.040632820330639) },
+ { FRAC_CONST(0.017131347345575), FRAC_CONST(0.040738703196411) },
+ { FRAC_CONST(0.016881056869233), FRAC_CONST(0.040843052273033) },
+ { FRAC_CONST(0.016630130830641), FRAC_CONST(0.040945863631822) },
+ { FRAC_CONST(0.016378578677023), FRAC_CONST(0.041047133401988) },
+ { FRAC_CONST(0.016126409879175), FRAC_CONST(0.041146857770781) },
+ { FRAC_CONST(0.015873633931110), FRAC_CONST(0.041245032983635) },
+ { FRAC_CONST(0.015620260349699), FRAC_CONST(0.041341655344309) },
+ { FRAC_CONST(0.015366298674314), FRAC_CONST(0.041436721215026) },
+ { FRAC_CONST(0.015111758466470), FRAC_CONST(0.041530227016609) },
+ { FRAC_CONST(0.014856649309460), FRAC_CONST(0.041622169228618) },
+ { FRAC_CONST(0.014600980808001), FRAC_CONST(0.041712544389481) },
+ { FRAC_CONST(0.014344762587867), FRAC_CONST(0.041801349096623) },
+ { FRAC_CONST(0.014088004295529), FRAC_CONST(0.041888580006598) },
+ { FRAC_CONST(0.013830715597792), FRAC_CONST(0.041974233835211) },
+ { FRAC_CONST(0.013572906181430), FRAC_CONST(0.042058307357645) },
+ { FRAC_CONST(0.013314585752822), FRAC_CONST(0.042140797408577) },
+ { FRAC_CONST(0.013055764037585), FRAC_CONST(0.042221700882306) },
+ { FRAC_CONST(0.012796450780212), FRAC_CONST(0.042301014732860) },
+ { FRAC_CONST(0.012536655743699), FRAC_CONST(0.042378735974118) },
+ { FRAC_CONST(0.012276388709183), FRAC_CONST(0.042454861679919) },
+ { FRAC_CONST(0.012015659475571), FRAC_CONST(0.042529388984173) },
+ { FRAC_CONST(0.011754477859172), FRAC_CONST(0.042602315080970) },
+ { FRAC_CONST(0.011492853693324), FRAC_CONST(0.042673637224683) },
+ { FRAC_CONST(0.011230796828031), FRAC_CONST(0.042743352730074) },
+ { FRAC_CONST(0.010968317129584), FRAC_CONST(0.042811458972393) },
+ { FRAC_CONST(0.010705424480197), FRAC_CONST(0.042877953387479) },
+ { FRAC_CONST(0.010442128777629), FRAC_CONST(0.042942833471854) },
+ { FRAC_CONST(0.010178439934815), FRAC_CONST(0.043006096782821) },
+ { FRAC_CONST(0.009914367879490), FRAC_CONST(0.043067740938551) },
+ { FRAC_CONST(0.009649922553818), FRAC_CONST(0.043127763618177) },
+ { FRAC_CONST(0.009385113914016), FRAC_CONST(0.043186162561878) },
+ { FRAC_CONST(0.009119951929979), FRAC_CONST(0.043242935570968) },
+ { FRAC_CONST(0.008854446584907), FRAC_CONST(0.043298080507974) },
+ { FRAC_CONST(0.008588607874926), FRAC_CONST(0.043351595296722) },
+ { FRAC_CONST(0.008322445808712), FRAC_CONST(0.043403477922409) },
+ { FRAC_CONST(0.008055970407118), FRAC_CONST(0.043453726431684) },
+ { FRAC_CONST(0.007789191702791), FRAC_CONST(0.043502338932719) },
+ { FRAC_CONST(0.007522119739798), FRAC_CONST(0.043549313595281) },
+ { FRAC_CONST(0.007254764573250), FRAC_CONST(0.043594648650800) },
+ { FRAC_CONST(0.006987136268915), FRAC_CONST(0.043638342392438) },
+ { FRAC_CONST(0.006719244902849), FRAC_CONST(0.043680393175148) },
+ { FRAC_CONST(0.006451100561010), FRAC_CONST(0.043720799415744) },
+ { FRAC_CONST(0.006182713338881), FRAC_CONST(0.043759559592953) },
+ { FRAC_CONST(0.005914093341090), FRAC_CONST(0.043796672247476) },
+ { FRAC_CONST(0.005645250681027), FRAC_CONST(0.043832135982044) },
+ { FRAC_CONST(0.005376195480466), FRAC_CONST(0.043865949461465) },
+ { FRAC_CONST(0.005106937869184), FRAC_CONST(0.043898111412683) },
+ { FRAC_CONST(0.004837487984578), FRAC_CONST(0.043928620624817) },
+ { FRAC_CONST(0.004567855971284), FRAC_CONST(0.043957475949213) },
+ { FRAC_CONST(0.004298051980793), FRAC_CONST(0.043984676299484) },
+ { FRAC_CONST(0.004028086171076), FRAC_CONST(0.044010220651553) },
+ { FRAC_CONST(0.003757968706190), FRAC_CONST(0.044034108043689) },
+ { FRAC_CONST(0.003487709755907), FRAC_CONST(0.044056337576546) },
+ { FRAC_CONST(0.003217319495322), FRAC_CONST(0.044076908413193) },
+ { FRAC_CONST(0.002946808104477), FRAC_CONST(0.044095819779151) },
+ { FRAC_CONST(0.002676185767973), FRAC_CONST(0.044113070962418) },
+ { FRAC_CONST(0.002405462674586), FRAC_CONST(0.044128661313495) },
+ { FRAC_CONST(0.002134649016890), FRAC_CONST(0.044142590245416) },
+ { FRAC_CONST(0.001863754990865), FRAC_CONST(0.044154857233763) },
+ { FRAC_CONST(0.001592790795518), FRAC_CONST(0.044165461816692) },
+ { FRAC_CONST(0.001321766632497), FRAC_CONST(0.044174403594946) },
+ { FRAC_CONST(0.001050692705710), FRAC_CONST(0.044181682231873) },
+ { FRAC_CONST(0.000779579220936), FRAC_CONST(0.044187297453434) },
+ { FRAC_CONST(0.000508436385446), FRAC_CONST(0.044191249048222) },
+ { FRAC_CONST(0.000237274407613), FRAC_CONST(0.044193536867459) }
+ };
+#endif // LD_DEC
+
+#ifdef ALLOW_SMALL_FRAMELENGTH
+ /* 480 (N/4) complex twiddle factors */
+ ALIGN static const complex_t mdct_tab_1920[] = {
+ { FRAC_CONST(0.032274858518097), FRAC_CONST(0.000013202404176) },
+ { FRAC_CONST(0.032274642494505), FRAC_CONST(0.000118821372483) },
+ { FRAC_CONST(0.032274080835421), FRAC_CONST(0.000224439068308) },
+ { FRAC_CONST(0.032273173546860), FRAC_CONST(0.000330054360572) },
+ { FRAC_CONST(0.032271920638538), FRAC_CONST(0.000435666118218) },
+ { FRAC_CONST(0.032270322123873), FRAC_CONST(0.000541273210231) },
+ { FRAC_CONST(0.032268378019984), FRAC_CONST(0.000646874505642) },
+ { FRAC_CONST(0.032266088347691), FRAC_CONST(0.000752468873546) },
+ { FRAC_CONST(0.032263453131514), FRAC_CONST(0.000858055183114) },
+ { FRAC_CONST(0.032260472399674), FRAC_CONST(0.000963632303600) },
+ { FRAC_CONST(0.032257146184092), FRAC_CONST(0.001069199104358) },
+ { FRAC_CONST(0.032253474520390), FRAC_CONST(0.001174754454853) },
+ { FRAC_CONST(0.032249457447888), FRAC_CONST(0.001280297224671) },
+ { FRAC_CONST(0.032245095009606), FRAC_CONST(0.001385826283535) },
+ { FRAC_CONST(0.032240387252262), FRAC_CONST(0.001491340501313) },
+ { FRAC_CONST(0.032235334226272), FRAC_CONST(0.001596838748031) },
+ { FRAC_CONST(0.032229935985750), FRAC_CONST(0.001702319893890) },
+ { FRAC_CONST(0.032224192588507), FRAC_CONST(0.001807782809271) },
+ { FRAC_CONST(0.032218104096050), FRAC_CONST(0.001913226364749) },
+ { FRAC_CONST(0.032211670573582), FRAC_CONST(0.002018649431111) },
+ { FRAC_CONST(0.032204892090000), FRAC_CONST(0.002124050879359) },
+ { FRAC_CONST(0.032197768717898), FRAC_CONST(0.002229429580728) },
+ { FRAC_CONST(0.032190300533560), FRAC_CONST(0.002334784406698) },
+ { FRAC_CONST(0.032182487616965), FRAC_CONST(0.002440114229003) },
+ { FRAC_CONST(0.032174330051782), FRAC_CONST(0.002545417919644) },
+ { FRAC_CONST(0.032165827925374), FRAC_CONST(0.002650694350905) },
+ { FRAC_CONST(0.032156981328790), FRAC_CONST(0.002755942395358) },
+ { FRAC_CONST(0.032147790356771), FRAC_CONST(0.002861160925883) },
+ { FRAC_CONST(0.032138255107744), FRAC_CONST(0.002966348815672) },
+ { FRAC_CONST(0.032128375683825), FRAC_CONST(0.003071504938250) },
+ { FRAC_CONST(0.032118152190814), FRAC_CONST(0.003176628167476) },
+ { FRAC_CONST(0.032107584738196), FRAC_CONST(0.003281717377568) },
+ { FRAC_CONST(0.032096673439141), FRAC_CONST(0.003386771443102) },
+ { FRAC_CONST(0.032085418410500), FRAC_CONST(0.003491789239036) },
+ { FRAC_CONST(0.032073819772804), FRAC_CONST(0.003596769640711) },
+ { FRAC_CONST(0.032061877650267), FRAC_CONST(0.003701711523874) },
+ { FRAC_CONST(0.032049592170778), FRAC_CONST(0.003806613764680) },
+ { FRAC_CONST(0.032036963465906), FRAC_CONST(0.003911475239711) },
+ { FRAC_CONST(0.032023991670893), FRAC_CONST(0.004016294825985) },
+ { FRAC_CONST(0.032010676924657), FRAC_CONST(0.004121071400967) },
+ { FRAC_CONST(0.031997019369789), FRAC_CONST(0.004225803842586) },
+ { FRAC_CONST(0.031983019152549), FRAC_CONST(0.004330491029241) },
+ { FRAC_CONST(0.031968676422869), FRAC_CONST(0.004435131839816) },
+ { FRAC_CONST(0.031953991334348), FRAC_CONST(0.004539725153692) },
+ { FRAC_CONST(0.031938964044252), FRAC_CONST(0.004644269850758) },
+ { FRAC_CONST(0.031923594713510), FRAC_CONST(0.004748764811426) },
+ { FRAC_CONST(0.031907883506716), FRAC_CONST(0.004853208916638) },
+ { FRAC_CONST(0.031891830592124), FRAC_CONST(0.004957601047881) },
+ { FRAC_CONST(0.031875436141648), FRAC_CONST(0.005061940087200) },
+ { FRAC_CONST(0.031858700330859), FRAC_CONST(0.005166224917208) },
+ { FRAC_CONST(0.031841623338985), FRAC_CONST(0.005270454421097) },
+ { FRAC_CONST(0.031824205348907), FRAC_CONST(0.005374627482653) },
+ { FRAC_CONST(0.031806446547156), FRAC_CONST(0.005478742986267) },
+ { FRAC_CONST(0.031788347123916), FRAC_CONST(0.005582799816945) },
+ { FRAC_CONST(0.031769907273017), FRAC_CONST(0.005686796860323) },
+ { FRAC_CONST(0.031751127191935), FRAC_CONST(0.005790733002674) },
+ { FRAC_CONST(0.031732007081789), FRAC_CONST(0.005894607130928) },
+ { FRAC_CONST(0.031712547147340), FRAC_CONST(0.005998418132675) },
+ { FRAC_CONST(0.031692747596989), FRAC_CONST(0.006102164896182) },
+ { FRAC_CONST(0.031672608642773), FRAC_CONST(0.006205846310406) },
+ { FRAC_CONST(0.031652130500364), FRAC_CONST(0.006309461265002) },
+ { FRAC_CONST(0.031631313389067), FRAC_CONST(0.006413008650337) },
+ { FRAC_CONST(0.031610157531816), FRAC_CONST(0.006516487357501) },
+ { FRAC_CONST(0.031588663155172), FRAC_CONST(0.006619896278321) },
+ { FRAC_CONST(0.031566830489325), FRAC_CONST(0.006723234305370) },
+ { FRAC_CONST(0.031544659768083), FRAC_CONST(0.006826500331981) },
+ { FRAC_CONST(0.031522151228878), FRAC_CONST(0.006929693252258) },
+ { FRAC_CONST(0.031499305112758), FRAC_CONST(0.007032811961088) },
+ { FRAC_CONST(0.031476121664387), FRAC_CONST(0.007135855354151) },
+ { FRAC_CONST(0.031452601132040), FRAC_CONST(0.007238822327937) },
+ { FRAC_CONST(0.031428743767604), FRAC_CONST(0.007341711779751) },
+ { FRAC_CONST(0.031404549826572), FRAC_CONST(0.007444522607730) },
+ { FRAC_CONST(0.031380019568042), FRAC_CONST(0.007547253710853) },
+ { FRAC_CONST(0.031355153254712), FRAC_CONST(0.007649903988952) },
+ { FRAC_CONST(0.031329951152882), FRAC_CONST(0.007752472342725) },
+ { FRAC_CONST(0.031304413532445), FRAC_CONST(0.007854957673748) },
+ { FRAC_CONST(0.031278540666888), FRAC_CONST(0.007957358884484) },
+ { FRAC_CONST(0.031252332833290), FRAC_CONST(0.008059674878300) },
+ { FRAC_CONST(0.031225790312316), FRAC_CONST(0.008161904559473) },
+ { FRAC_CONST(0.031198913388214), FRAC_CONST(0.008264046833205) },
+ { FRAC_CONST(0.031171702348814), FRAC_CONST(0.008366100605636) },
+ { FRAC_CONST(0.031144157485525), FRAC_CONST(0.008468064783849) },
+ { FRAC_CONST(0.031116279093331), FRAC_CONST(0.008569938275893) },
+ { FRAC_CONST(0.031088067470786), FRAC_CONST(0.008671719990782) },
+ { FRAC_CONST(0.031059522920014), FRAC_CONST(0.008773408838517) },
+ { FRAC_CONST(0.031030645746705), FRAC_CONST(0.008875003730092) },
+ { FRAC_CONST(0.031001436260110), FRAC_CONST(0.008976503577507) },
+ { FRAC_CONST(0.030971894773039), FRAC_CONST(0.009077907293780) },
+ { FRAC_CONST(0.030942021601857), FRAC_CONST(0.009179213792959) },
+ { FRAC_CONST(0.030911817066483), FRAC_CONST(0.009280421990133) },
+ { FRAC_CONST(0.030881281490382), FRAC_CONST(0.009381530801444) },
+ { FRAC_CONST(0.030850415200566), FRAC_CONST(0.009482539144097) },
+ { FRAC_CONST(0.030819218527589), FRAC_CONST(0.009583445936373) },
+ { FRAC_CONST(0.030787691805541), FRAC_CONST(0.009684250097643) },
+ { FRAC_CONST(0.030755835372048), FRAC_CONST(0.009784950548375) },
+ { FRAC_CONST(0.030723649568268), FRAC_CONST(0.009885546210147) },
+ { FRAC_CONST(0.030691134738883), FRAC_CONST(0.009986036005661) },
+ { FRAC_CONST(0.030658291232103), FRAC_CONST(0.010086418858753) },
+ { FRAC_CONST(0.030625119399655), FRAC_CONST(0.010186693694402) },
+ { FRAC_CONST(0.030591619596781), FRAC_CONST(0.010286859438745) },
+ { FRAC_CONST(0.030557792182239), FRAC_CONST(0.010386915019088) },
+ { FRAC_CONST(0.030523637518292), FRAC_CONST(0.010486859363916) },
+ { FRAC_CONST(0.030489155970710), FRAC_CONST(0.010586691402906) },
+ { FRAC_CONST(0.030454347908763), FRAC_CONST(0.010686410066936) },
+ { FRAC_CONST(0.030419213705216), FRAC_CONST(0.010786014288099) },
+ { FRAC_CONST(0.030383753736329), FRAC_CONST(0.010885502999714) },
+ { FRAC_CONST(0.030347968381849), FRAC_CONST(0.010984875136338) },
+ { FRAC_CONST(0.030311858025010), FRAC_CONST(0.011084129633775) },
+ { FRAC_CONST(0.030275423052523), FRAC_CONST(0.011183265429088) },
+ { FRAC_CONST(0.030238663854579), FRAC_CONST(0.011282281460612) },
+ { FRAC_CONST(0.030201580824838), FRAC_CONST(0.011381176667967) },
+ { FRAC_CONST(0.030164174360430), FRAC_CONST(0.011479949992062) },
+ { FRAC_CONST(0.030126444861948), FRAC_CONST(0.011578600375117) },
+ { FRAC_CONST(0.030088392733446), FRAC_CONST(0.011677126760663) },
+ { FRAC_CONST(0.030050018382430), FRAC_CONST(0.011775528093563) },
+ { FRAC_CONST(0.030011322219859), FRAC_CONST(0.011873803320018) },
+ { FRAC_CONST(0.029972304660138), FRAC_CONST(0.011971951387578) },
+ { FRAC_CONST(0.029932966121114), FRAC_CONST(0.012069971245157) },
+ { FRAC_CONST(0.029893307024070), FRAC_CONST(0.012167861843041) },
+ { FRAC_CONST(0.029853327793724), FRAC_CONST(0.012265622132901) },
+ { FRAC_CONST(0.029813028858222), FRAC_CONST(0.012363251067801) },
+ { FRAC_CONST(0.029772410649132), FRAC_CONST(0.012460747602215) },
+ { FRAC_CONST(0.029731473601443), FRAC_CONST(0.012558110692033) },
+ { FRAC_CONST(0.029690218153558), FRAC_CONST(0.012655339294575) },
+ { FRAC_CONST(0.029648644747289), FRAC_CONST(0.012752432368600) },
+ { FRAC_CONST(0.029606753827855), FRAC_CONST(0.012849388874320) },
+ { FRAC_CONST(0.029564545843872), FRAC_CONST(0.012946207773407) },
+ { FRAC_CONST(0.029522021247356), FRAC_CONST(0.013042888029011) },
+ { FRAC_CONST(0.029479180493710), FRAC_CONST(0.013139428605762) },
+ { FRAC_CONST(0.029436024041725), FRAC_CONST(0.013235828469789) },
+ { FRAC_CONST(0.029392552353570), FRAC_CONST(0.013332086588727) },
+ { FRAC_CONST(0.029348765894794), FRAC_CONST(0.013428201931728) },
+ { FRAC_CONST(0.029304665134313), FRAC_CONST(0.013524173469475) },
+ { FRAC_CONST(0.029260250544412), FRAC_CONST(0.013620000174189) },
+ { FRAC_CONST(0.029215522600735), FRAC_CONST(0.013715681019643) },
+ { FRAC_CONST(0.029170481782283), FRAC_CONST(0.013811214981173) },
+ { FRAC_CONST(0.029125128571406), FRAC_CONST(0.013906601035686) },
+ { FRAC_CONST(0.029079463453801), FRAC_CONST(0.014001838161674) },
+ { FRAC_CONST(0.029033486918505), FRAC_CONST(0.014096925339225) },
+ { FRAC_CONST(0.028987199457889), FRAC_CONST(0.014191861550031) },
+ { FRAC_CONST(0.028940601567655), FRAC_CONST(0.014286645777401) },
+ { FRAC_CONST(0.028893693746829), FRAC_CONST(0.014381277006273) },
+ { FRAC_CONST(0.028846476497755), FRAC_CONST(0.014475754223221) },
+ { FRAC_CONST(0.028798950326094), FRAC_CONST(0.014570076416472) },
+ { FRAC_CONST(0.028751115740811), FRAC_CONST(0.014664242575910) },
+ { FRAC_CONST(0.028702973254178), FRAC_CONST(0.014758251693091) },
+ { FRAC_CONST(0.028654523381760), FRAC_CONST(0.014852102761253) },
+ { FRAC_CONST(0.028605766642418), FRAC_CONST(0.014945794775326) },
+ { FRAC_CONST(0.028556703558297), FRAC_CONST(0.015039326731945) },
+ { FRAC_CONST(0.028507334654823), FRAC_CONST(0.015132697629457) },
+ { FRAC_CONST(0.028457660460698), FRAC_CONST(0.015225906467935) },
+ { FRAC_CONST(0.028407681507891), FRAC_CONST(0.015318952249187) },
+ { FRAC_CONST(0.028357398331639), FRAC_CONST(0.015411833976768) },
+ { FRAC_CONST(0.028306811470432), FRAC_CONST(0.015504550655988) },
+ { FRAC_CONST(0.028255921466016), FRAC_CONST(0.015597101293927) },
+ { FRAC_CONST(0.028204728863381), FRAC_CONST(0.015689484899442) },
+ { FRAC_CONST(0.028153234210760), FRAC_CONST(0.015781700483179) },
+ { FRAC_CONST(0.028101438059619), FRAC_CONST(0.015873747057582) },
+ { FRAC_CONST(0.028049340964652), FRAC_CONST(0.015965623636907) },
+ { FRAC_CONST(0.027996943483779), FRAC_CONST(0.016057329237229) },
+ { FRAC_CONST(0.027944246178133), FRAC_CONST(0.016148862876456) },
+ { FRAC_CONST(0.027891249612061), FRAC_CONST(0.016240223574335) },
+ { FRAC_CONST(0.027837954353113), FRAC_CONST(0.016331410352467) },
+ { FRAC_CONST(0.027784360972039), FRAC_CONST(0.016422422234315) },
+ { FRAC_CONST(0.027730470042780), FRAC_CONST(0.016513258245214) },
+ { FRAC_CONST(0.027676282142466), FRAC_CONST(0.016603917412384) },
+ { FRAC_CONST(0.027621797851405), FRAC_CONST(0.016694398764938) },
+ { FRAC_CONST(0.027567017753080), FRAC_CONST(0.016784701333894) },
+ { FRAC_CONST(0.027511942434143), FRAC_CONST(0.016874824152183) },
+ { FRAC_CONST(0.027456572484404), FRAC_CONST(0.016964766254662) },
+ { FRAC_CONST(0.027400908496833), FRAC_CONST(0.017054526678124) },
+ { FRAC_CONST(0.027344951067546), FRAC_CONST(0.017144104461307) },
+ { FRAC_CONST(0.027288700795801), FRAC_CONST(0.017233498644904) },
+ { FRAC_CONST(0.027232158283994), FRAC_CONST(0.017322708271577) },
+ { FRAC_CONST(0.027175324137651), FRAC_CONST(0.017411732385960) },
+ { FRAC_CONST(0.027118198965418), FRAC_CONST(0.017500570034678) },
+ { FRAC_CONST(0.027060783379060), FRAC_CONST(0.017589220266351) },
+ { FRAC_CONST(0.027003077993454), FRAC_CONST(0.017677682131607) },
+ { FRAC_CONST(0.026945083426576), FRAC_CONST(0.017765954683088) },
+ { FRAC_CONST(0.026886800299502), FRAC_CONST(0.017854036975468) },
+ { FRAC_CONST(0.026828229236397), FRAC_CONST(0.017941928065456) },
+ { FRAC_CONST(0.026769370864511), FRAC_CONST(0.018029627011808) },
+ { FRAC_CONST(0.026710225814170), FRAC_CONST(0.018117132875340) },
+ { FRAC_CONST(0.026650794718768), FRAC_CONST(0.018204444718934) },
+ { FRAC_CONST(0.026591078214767), FRAC_CONST(0.018291561607551) },
+ { FRAC_CONST(0.026531076941680), FRAC_CONST(0.018378482608238) },
+ { FRAC_CONST(0.026470791542075), FRAC_CONST(0.018465206790142) },
+ { FRAC_CONST(0.026410222661558), FRAC_CONST(0.018551733224515) },
+ { FRAC_CONST(0.026349370948775), FRAC_CONST(0.018638060984730) },
+ { FRAC_CONST(0.026288237055398), FRAC_CONST(0.018724189146286) },
+ { FRAC_CONST(0.026226821636121), FRAC_CONST(0.018810116786819) },
+ { FRAC_CONST(0.026165125348656), FRAC_CONST(0.018895842986112) },
+ { FRAC_CONST(0.026103148853718), FRAC_CONST(0.018981366826109) },
+ { FRAC_CONST(0.026040892815028), FRAC_CONST(0.019066687390916) },
+ { FRAC_CONST(0.025978357899296), FRAC_CONST(0.019151803766819) },
+ { FRAC_CONST(0.025915544776223), FRAC_CONST(0.019236715042290) },
+ { FRAC_CONST(0.025852454118485), FRAC_CONST(0.019321420307998) },
+ { FRAC_CONST(0.025789086601733), FRAC_CONST(0.019405918656817) },
+ { FRAC_CONST(0.025725442904582), FRAC_CONST(0.019490209183837) },
+ { FRAC_CONST(0.025661523708606), FRAC_CONST(0.019574290986376) },
+ { FRAC_CONST(0.025597329698327), FRAC_CONST(0.019658163163984) },
+ { FRAC_CONST(0.025532861561211), FRAC_CONST(0.019741824818458) },
+ { FRAC_CONST(0.025468119987662), FRAC_CONST(0.019825275053848) },
+ { FRAC_CONST(0.025403105671008), FRAC_CONST(0.019908512976470) },
+ { FRAC_CONST(0.025337819307501), FRAC_CONST(0.019991537694913) },
+ { FRAC_CONST(0.025272261596305), FRAC_CONST(0.020074348320047) },
+ { FRAC_CONST(0.025206433239491), FRAC_CONST(0.020156943965039) },
+ { FRAC_CONST(0.025140334942028), FRAC_CONST(0.020239323745355) },
+ { FRAC_CONST(0.025073967411776), FRAC_CONST(0.020321486778774) },
+ { FRAC_CONST(0.025007331359476), FRAC_CONST(0.020403432185395) },
+ { FRAC_CONST(0.024940427498748), FRAC_CONST(0.020485159087650) },
+ { FRAC_CONST(0.024873256546079), FRAC_CONST(0.020566666610309) },
+ { FRAC_CONST(0.024805819220816), FRAC_CONST(0.020647953880491) },
+ { FRAC_CONST(0.024738116245157), FRAC_CONST(0.020729020027676) },
+ { FRAC_CONST(0.024670148344147), FRAC_CONST(0.020809864183709) },
+ { FRAC_CONST(0.024601916245669), FRAC_CONST(0.020890485482816) },
+ { FRAC_CONST(0.024533420680433), FRAC_CONST(0.020970883061607) },
+ { FRAC_CONST(0.024464662381971), FRAC_CONST(0.021051056059087) },
+ { FRAC_CONST(0.024395642086630), FRAC_CONST(0.021131003616670) },
+ { FRAC_CONST(0.024326360533561), FRAC_CONST(0.021210724878181) },
+ { FRAC_CONST(0.024256818464715), FRAC_CONST(0.021290218989868) },
+ { FRAC_CONST(0.024187016624830), FRAC_CONST(0.021369485100415) },
+ { FRAC_CONST(0.024116955761430), FRAC_CONST(0.021448522360944) },
+ { FRAC_CONST(0.024046636624808), FRAC_CONST(0.021527329925030) },
+ { FRAC_CONST(0.023976059968027), FRAC_CONST(0.021605906948708) },
+ { FRAC_CONST(0.023905226546906), FRAC_CONST(0.021684252590480) },
+ { FRAC_CONST(0.023834137120014), FRAC_CONST(0.021762366011328) },
+ { FRAC_CONST(0.023762792448662), FRAC_CONST(0.021840246374720) },
+ { FRAC_CONST(0.023691193296893), FRAC_CONST(0.021917892846620) },
+ { FRAC_CONST(0.023619340431478), FRAC_CONST(0.021995304595495) },
+ { FRAC_CONST(0.023547234621902), FRAC_CONST(0.022072480792330) },
+ { FRAC_CONST(0.023474876640361), FRAC_CONST(0.022149420610628) },
+ { FRAC_CONST(0.023402267261751), FRAC_CONST(0.022226123226426) },
+ { FRAC_CONST(0.023329407263659), FRAC_CONST(0.022302587818300) },
+ { FRAC_CONST(0.023256297426359), FRAC_CONST(0.022378813567377) },
+ { FRAC_CONST(0.023182938532797), FRAC_CONST(0.022454799657339) },
+ { FRAC_CONST(0.023109331368588), FRAC_CONST(0.022530545274437) },
+ { FRAC_CONST(0.023035476722006), FRAC_CONST(0.022606049607496) },
+ { FRAC_CONST(0.022961375383975), FRAC_CONST(0.022681311847926) },
+ { FRAC_CONST(0.022887028148061), FRAC_CONST(0.022756331189727) },
+ { FRAC_CONST(0.022812435810462), FRAC_CONST(0.022831106829504) },
+ { FRAC_CONST(0.022737599170003), FRAC_CONST(0.022905637966469) },
+ { FRAC_CONST(0.022662519028125), FRAC_CONST(0.022979923802453) },
+ { FRAC_CONST(0.022587196188874), FRAC_CONST(0.023053963541915) },
+ { FRAC_CONST(0.022511631458899), FRAC_CONST(0.023127756391950) },
+ { FRAC_CONST(0.022435825647437), FRAC_CONST(0.023201301562294) },
+ { FRAC_CONST(0.022359779566306), FRAC_CONST(0.023274598265338) },
+ { FRAC_CONST(0.022283494029900), FRAC_CONST(0.023347645716133) },
+ { FRAC_CONST(0.022206969855176), FRAC_CONST(0.023420443132400) },
+ { FRAC_CONST(0.022130207861645), FRAC_CONST(0.023492989734537) },
+ { FRAC_CONST(0.022053208871367), FRAC_CONST(0.023565284745628) },
+ { FRAC_CONST(0.021975973708940), FRAC_CONST(0.023637327391451) },
+ { FRAC_CONST(0.021898503201489), FRAC_CONST(0.023709116900488) },
+ { FRAC_CONST(0.021820798178663), FRAC_CONST(0.023780652503931) },
+ { FRAC_CONST(0.021742859472618), FRAC_CONST(0.023851933435691) },
+ { FRAC_CONST(0.021664687918017), FRAC_CONST(0.023922958932406) },
+ { FRAC_CONST(0.021586284352013), FRAC_CONST(0.023993728233451) },
+ { FRAC_CONST(0.021507649614247), FRAC_CONST(0.024064240580942) },
+ { FRAC_CONST(0.021428784546832), FRAC_CONST(0.024134495219750) },
+ { FRAC_CONST(0.021349689994350), FRAC_CONST(0.024204491397504) },
+ { FRAC_CONST(0.021270366803840), FRAC_CONST(0.024274228364600) },
+ { FRAC_CONST(0.021190815824791), FRAC_CONST(0.024343705374213) },
+ { FRAC_CONST(0.021111037909128), FRAC_CONST(0.024412921682298) },
+ { FRAC_CONST(0.021031033911210), FRAC_CONST(0.024481876547605) },
+ { FRAC_CONST(0.020950804687815), FRAC_CONST(0.024550569231683) },
+ { FRAC_CONST(0.020870351098134), FRAC_CONST(0.024618998998889) },
+ { FRAC_CONST(0.020789674003759), FRAC_CONST(0.024687165116394) },
+ { FRAC_CONST(0.020708774268678), FRAC_CONST(0.024755066854194) },
+ { FRAC_CONST(0.020627652759262), FRAC_CONST(0.024822703485116) },
+ { FRAC_CONST(0.020546310344257), FRAC_CONST(0.024890074284826) },
+ { FRAC_CONST(0.020464747894775), FRAC_CONST(0.024957178531837) },
+ { FRAC_CONST(0.020382966284284), FRAC_CONST(0.025024015507516) },
+ { FRAC_CONST(0.020300966388600), FRAC_CONST(0.025090584496093) },
+ { FRAC_CONST(0.020218749085876), FRAC_CONST(0.025156884784668) },
+ { FRAC_CONST(0.020136315256592), FRAC_CONST(0.025222915663218) },
+ { FRAC_CONST(0.020053665783549), FRAC_CONST(0.025288676424605) },
+ { FRAC_CONST(0.019970801551857), FRAC_CONST(0.025354166364584) },
+ { FRAC_CONST(0.019887723448925), FRAC_CONST(0.025419384781811) },
+ { FRAC_CONST(0.019804432364452), FRAC_CONST(0.025484330977848) },
+ { FRAC_CONST(0.019720929190419), FRAC_CONST(0.025549004257175) },
+ { FRAC_CONST(0.019637214821078), FRAC_CONST(0.025613403927192) },
+ { FRAC_CONST(0.019553290152943), FRAC_CONST(0.025677529298230) },
+ { FRAC_CONST(0.019469156084779), FRAC_CONST(0.025741379683559) },
+ { FRAC_CONST(0.019384813517595), FRAC_CONST(0.025804954399392) },
+ { FRAC_CONST(0.019300263354632), FRAC_CONST(0.025868252764895) },
+ { FRAC_CONST(0.019215506501354), FRAC_CONST(0.025931274102193) },
+ { FRAC_CONST(0.019130543865439), FRAC_CONST(0.025994017736379) },
+ { FRAC_CONST(0.019045376356769), FRAC_CONST(0.026056482995518) },
+ { FRAC_CONST(0.018960004887419), FRAC_CONST(0.026118669210657) },
+ { FRAC_CONST(0.018874430371648), FRAC_CONST(0.026180575715833) },
+ { FRAC_CONST(0.018788653725892), FRAC_CONST(0.026242201848076) },
+ { FRAC_CONST(0.018702675868750), FRAC_CONST(0.026303546947421) },
+ { FRAC_CONST(0.018616497720974), FRAC_CONST(0.026364610356909) },
+ { FRAC_CONST(0.018530120205464), FRAC_CONST(0.026425391422602) },
+ { FRAC_CONST(0.018443544247254), FRAC_CONST(0.026485889493583) },
+ { FRAC_CONST(0.018356770773502), FRAC_CONST(0.026546103921965) },
+ { FRAC_CONST(0.018269800713483), FRAC_CONST(0.026606034062902) },
+ { FRAC_CONST(0.018182634998576), FRAC_CONST(0.026665679274589) },
+ { FRAC_CONST(0.018095274562256), FRAC_CONST(0.026725038918274) },
+ { FRAC_CONST(0.018007720340083), FRAC_CONST(0.026784112358263) },
+ { FRAC_CONST(0.017919973269692), FRAC_CONST(0.026842898961926) },
+ { FRAC_CONST(0.017832034290785), FRAC_CONST(0.026901398099707) },
+ { FRAC_CONST(0.017743904345116), FRAC_CONST(0.026959609145127) },
+ { FRAC_CONST(0.017655584376488), FRAC_CONST(0.027017531474792) },
+ { FRAC_CONST(0.017567075330734), FRAC_CONST(0.027075164468401) },
+ { FRAC_CONST(0.017478378155718), FRAC_CONST(0.027132507508750) },
+ { FRAC_CONST(0.017389493801313), FRAC_CONST(0.027189559981742) },
+ { FRAC_CONST(0.017300423219401), FRAC_CONST(0.027246321276391) },
+ { FRAC_CONST(0.017211167363854), FRAC_CONST(0.027302790784828) },
+ { FRAC_CONST(0.017121727190533), FRAC_CONST(0.027358967902310) },
+ { FRAC_CONST(0.017032103657269), FRAC_CONST(0.027414852027226) },
+ { FRAC_CONST(0.016942297723858), FRAC_CONST(0.027470442561102) },
+ { FRAC_CONST(0.016852310352050), FRAC_CONST(0.027525738908608) },
+ { FRAC_CONST(0.016762142505537), FRAC_CONST(0.027580740477564) },
+ { FRAC_CONST(0.016671795149944), FRAC_CONST(0.027635446678948) },
+ { FRAC_CONST(0.016581269252819), FRAC_CONST(0.027689856926900) },
+ { FRAC_CONST(0.016490565783622), FRAC_CONST(0.027743970638730) },
+ { FRAC_CONST(0.016399685713714), FRAC_CONST(0.027797787234924) },
+ { FRAC_CONST(0.016308630016347), FRAC_CONST(0.027851306139149) },
+ { FRAC_CONST(0.016217399666655), FRAC_CONST(0.027904526778260) },
+ { FRAC_CONST(0.016125995641641), FRAC_CONST(0.027957448582309) },
+ { FRAC_CONST(0.016034418920170), FRAC_CONST(0.028010070984544) },
+ { FRAC_CONST(0.015942670482954), FRAC_CONST(0.028062393421421) },
+ { FRAC_CONST(0.015850751312545), FRAC_CONST(0.028114415332610) },
+ { FRAC_CONST(0.015758662393324), FRAC_CONST(0.028166136160998) },
+ { FRAC_CONST(0.015666404711489), FRAC_CONST(0.028217555352697) },
+ { FRAC_CONST(0.015573979255046), FRAC_CONST(0.028268672357047) },
+ { FRAC_CONST(0.015481387013797), FRAC_CONST(0.028319486626627) },
+ { FRAC_CONST(0.015388628979331), FRAC_CONST(0.028369997617257) },
+ { FRAC_CONST(0.015295706145012), FRAC_CONST(0.028420204788004) },
+ { FRAC_CONST(0.015202619505968), FRAC_CONST(0.028470107601191) },
+ { FRAC_CONST(0.015109370059084), FRAC_CONST(0.028519705522399) },
+ { FRAC_CONST(0.015015958802984), FRAC_CONST(0.028568998020472) },
+ { FRAC_CONST(0.014922386738030), FRAC_CONST(0.028617984567529) },
+ { FRAC_CONST(0.014828654866302), FRAC_CONST(0.028666664638963) },
+ { FRAC_CONST(0.014734764191593), FRAC_CONST(0.028715037713449) },
+ { FRAC_CONST(0.014640715719398), FRAC_CONST(0.028763103272951) },
+ { FRAC_CONST(0.014546510456900), FRAC_CONST(0.028810860802724) },
+ { FRAC_CONST(0.014452149412962), FRAC_CONST(0.028858309791325) },
+ { FRAC_CONST(0.014357633598114), FRAC_CONST(0.028905449730613) },
+ { FRAC_CONST(0.014262964024545), FRAC_CONST(0.028952280115756) },
+ { FRAC_CONST(0.014168141706090), FRAC_CONST(0.028998800445240) },
+ { FRAC_CONST(0.014073167658220), FRAC_CONST(0.029045010220868) },
+ { FRAC_CONST(0.013978042898030), FRAC_CONST(0.029090908947771) },
+ { FRAC_CONST(0.013882768444231), FRAC_CONST(0.029136496134411) },
+ { FRAC_CONST(0.013787345317136), FRAC_CONST(0.029181771292585) },
+ { FRAC_CONST(0.013691774538648), FRAC_CONST(0.029226733937433) },
+ { FRAC_CONST(0.013596057132255), FRAC_CONST(0.029271383587441) },
+ { FRAC_CONST(0.013500194123014), FRAC_CONST(0.029315719764447) },
+ { FRAC_CONST(0.013404186537539), FRAC_CONST(0.029359741993647) },
+ { FRAC_CONST(0.013308035403995), FRAC_CONST(0.029403449803598) },
+ { FRAC_CONST(0.013211741752084), FRAC_CONST(0.029446842726223) },
+ { FRAC_CONST(0.013115306613032), FRAC_CONST(0.029489920296820) },
+ { FRAC_CONST(0.013018731019584), FRAC_CONST(0.029532682054063) },
+ { FRAC_CONST(0.012922016005985), FRAC_CONST(0.029575127540008) },
+ { FRAC_CONST(0.012825162607977), FRAC_CONST(0.029617256300097) },
+ { FRAC_CONST(0.012728171862781), FRAC_CONST(0.029659067883165) },
+ { FRAC_CONST(0.012631044809089), FRAC_CONST(0.029700561841444) },
+ { FRAC_CONST(0.012533782487056), FRAC_CONST(0.029741737730567) },
+ { FRAC_CONST(0.012436385938281), FRAC_CONST(0.029782595109573) },
+ { FRAC_CONST(0.012338856205805), FRAC_CONST(0.029823133540913) },
+ { FRAC_CONST(0.012241194334091), FRAC_CONST(0.029863352590452) },
+ { FRAC_CONST(0.012143401369021), FRAC_CONST(0.029903251827477) },
+ { FRAC_CONST(0.012045478357878), FRAC_CONST(0.029942830824699) },
+ { FRAC_CONST(0.011947426349339), FRAC_CONST(0.029982089158259) },
+ { FRAC_CONST(0.011849246393462), FRAC_CONST(0.030021026407731) },
+ { FRAC_CONST(0.011750939541676), FRAC_CONST(0.030059642156129) },
+ { FRAC_CONST(0.011652506846768), FRAC_CONST(0.030097935989909) },
+ { FRAC_CONST(0.011553949362874), FRAC_CONST(0.030135907498976) },
+ { FRAC_CONST(0.011455268145464), FRAC_CONST(0.030173556276684) },
+ { FRAC_CONST(0.011356464251335), FRAC_CONST(0.030210881919845) },
+ { FRAC_CONST(0.011257538738598), FRAC_CONST(0.030247884028732) },
+ { FRAC_CONST(0.011158492666665), FRAC_CONST(0.030284562207083) },
+ { FRAC_CONST(0.011059327096240), FRAC_CONST(0.030320916062102) },
+ { FRAC_CONST(0.010960043089307), FRAC_CONST(0.030356945204470) },
+ { FRAC_CONST(0.010860641709118), FRAC_CONST(0.030392649248343) },
+ { FRAC_CONST(0.010761124020182), FRAC_CONST(0.030428027811361) },
+ { FRAC_CONST(0.010661491088253), FRAC_CONST(0.030463080514646) },
+ { FRAC_CONST(0.010561743980319), FRAC_CONST(0.030497806982812) },
+ { FRAC_CONST(0.010461883764593), FRAC_CONST(0.030532206843968) },
+ { FRAC_CONST(0.010361911510496), FRAC_CONST(0.030566279729717) },
+ { FRAC_CONST(0.010261828288652), FRAC_CONST(0.030600025275167) },
+ { FRAC_CONST(0.010161635170872), FRAC_CONST(0.030633443118931) },
+ { FRAC_CONST(0.010061333230142), FRAC_CONST(0.030666532903129) },
+ { FRAC_CONST(0.009960923540617), FRAC_CONST(0.030699294273397) },
+ { FRAC_CONST(0.009860407177603), FRAC_CONST(0.030731726878888) },
+ { FRAC_CONST(0.009759785217550), FRAC_CONST(0.030763830372273) },
+ { FRAC_CONST(0.009659058738038), FRAC_CONST(0.030795604409750) },
+ { FRAC_CONST(0.009558228817767), FRAC_CONST(0.030827048651045) },
+ { FRAC_CONST(0.009457296536545), FRAC_CONST(0.030858162759415) },
+ { FRAC_CONST(0.009356262975275), FRAC_CONST(0.030888946401653) },
+ { FRAC_CONST(0.009255129215945), FRAC_CONST(0.030919399248091) },
+ { FRAC_CONST(0.009153896341616), FRAC_CONST(0.030949520972603) },
+ { FRAC_CONST(0.009052565436412), FRAC_CONST(0.030979311252611) },
+ { FRAC_CONST(0.008951137585505), FRAC_CONST(0.031008769769084) },
+ { FRAC_CONST(0.008849613875105), FRAC_CONST(0.031037896206544) },
+ { FRAC_CONST(0.008747995392451), FRAC_CONST(0.031066690253072) },
+ { FRAC_CONST(0.008646283225794), FRAC_CONST(0.031095151600306) },
+ { FRAC_CONST(0.008544478464390), FRAC_CONST(0.031123279943448) },
+ { FRAC_CONST(0.008442582198486), FRAC_CONST(0.031151074981266) },
+ { FRAC_CONST(0.008340595519310), FRAC_CONST(0.031178536416098) },
+ { FRAC_CONST(0.008238519519057), FRAC_CONST(0.031205663953853) },
+ { FRAC_CONST(0.008136355290878), FRAC_CONST(0.031232457304017) },
+ { FRAC_CONST(0.008034103928871), FRAC_CONST(0.031258916179656) },
+ { FRAC_CONST(0.007931766528065), FRAC_CONST(0.031285040297416) },
+ { FRAC_CONST(0.007829344184412), FRAC_CONST(0.031310829377528) },
+ { FRAC_CONST(0.007726837994772), FRAC_CONST(0.031336283143813) },
+ { FRAC_CONST(0.007624249056906), FRAC_CONST(0.031361401323680) },
+ { FRAC_CONST(0.007521578469457), FRAC_CONST(0.031386183648135) },
+ { FRAC_CONST(0.007418827331946), FRAC_CONST(0.031410629851778) },
+ { FRAC_CONST(0.007315996744755), FRAC_CONST(0.031434739672811) },
+ { FRAC_CONST(0.007213087809115), FRAC_CONST(0.031458512853036) },
+ { FRAC_CONST(0.007110101627101), FRAC_CONST(0.031481949137863) },
+ { FRAC_CONST(0.007007039301610), FRAC_CONST(0.031505048276306) },
+ { FRAC_CONST(0.006903901936357), FRAC_CONST(0.031527810020993) },
+ { FRAC_CONST(0.006800690635862), FRAC_CONST(0.031550234128164) },
+ { FRAC_CONST(0.006697406505433), FRAC_CONST(0.031572320357675) },
+ { FRAC_CONST(0.006594050651161), FRAC_CONST(0.031594068473000) },
+ { FRAC_CONST(0.006490624179905), FRAC_CONST(0.031615478241233) },
+ { FRAC_CONST(0.006387128199278), FRAC_CONST(0.031636549433095) },
+ { FRAC_CONST(0.006283563817639), FRAC_CONST(0.031657281822929) },
+ { FRAC_CONST(0.006179932144080), FRAC_CONST(0.031677675188707) },
+ { FRAC_CONST(0.006076234288412), FRAC_CONST(0.031697729312034) },
+ { FRAC_CONST(0.005972471361157), FRAC_CONST(0.031717443978146) },
+ { FRAC_CONST(0.005868644473532), FRAC_CONST(0.031736818975914) },
+ { FRAC_CONST(0.005764754737440), FRAC_CONST(0.031755854097848) },
+ { FRAC_CONST(0.005660803265456), FRAC_CONST(0.031774549140098) },
+ { FRAC_CONST(0.005556791170816), FRAC_CONST(0.031792903902453) },
+ { FRAC_CONST(0.005452719567407), FRAC_CONST(0.031810918188350) },
+ { FRAC_CONST(0.005348589569753), FRAC_CONST(0.031828591804869) },
+ { FRAC_CONST(0.005244402293001), FRAC_CONST(0.031845924562742) },
+ { FRAC_CONST(0.005140158852914), FRAC_CONST(0.031862916276347) },
+ { FRAC_CONST(0.005035860365855), FRAC_CONST(0.031879566763717) },
+ { FRAC_CONST(0.004931507948778), FRAC_CONST(0.031895875846539) },
+ { FRAC_CONST(0.004827102719212), FRAC_CONST(0.031911843350155) },
+ { FRAC_CONST(0.004722645795254), FRAC_CONST(0.031927469103567) },
+ { FRAC_CONST(0.004618138295554), FRAC_CONST(0.031942752939435) },
+ { FRAC_CONST(0.004513581339303), FRAC_CONST(0.031957694694082) },
+ { FRAC_CONST(0.004408976046222), FRAC_CONST(0.031972294207493) },
+ { FRAC_CONST(0.004304323536549), FRAC_CONST(0.031986551323320) },
+ { FRAC_CONST(0.004199624931030), FRAC_CONST(0.032000465888879) },
+ { FRAC_CONST(0.004094881350902), FRAC_CONST(0.032014037755158) },
+ { FRAC_CONST(0.003990093917884), FRAC_CONST(0.032027266776813) },
+ { FRAC_CONST(0.003885263754166), FRAC_CONST(0.032040152812170) },
+ { FRAC_CONST(0.003780391982394), FRAC_CONST(0.032052695723232) },
+ { FRAC_CONST(0.003675479725661), FRAC_CONST(0.032064895375674) },
+ { FRAC_CONST(0.003570528107494), FRAC_CONST(0.032076751638847) },
+ { FRAC_CONST(0.003465538251839), FRAC_CONST(0.032088264385780) },
+ { FRAC_CONST(0.003360511283053), FRAC_CONST(0.032099433493181) },
+ { FRAC_CONST(0.003255448325892), FRAC_CONST(0.032110258841438) },
+ { FRAC_CONST(0.003150350505494), FRAC_CONST(0.032120740314619) },
+ { FRAC_CONST(0.003045218947373), FRAC_CONST(0.032130877800478) },
+ { FRAC_CONST(0.002940054777404), FRAC_CONST(0.032140671190449) },
+ { FRAC_CONST(0.002834859121810), FRAC_CONST(0.032150120379653) },
+ { FRAC_CONST(0.002729633107153), FRAC_CONST(0.032159225266897) },
+ { FRAC_CONST(0.002624377860318), FRAC_CONST(0.032167985754674) },
+ { FRAC_CONST(0.002519094508504), FRAC_CONST(0.032176401749168) },
+ { FRAC_CONST(0.002413784179212), FRAC_CONST(0.032184473160250) },
+ { FRAC_CONST(0.002308448000231), FRAC_CONST(0.032192199901481) },
+ { FRAC_CONST(0.002203087099626), FRAC_CONST(0.032199581890114) },
+ { FRAC_CONST(0.002097702605728), FRAC_CONST(0.032206619047093) },
+ { FRAC_CONST(0.001992295647121), FRAC_CONST(0.032213311297057) },
+ { FRAC_CONST(0.001886867352628), FRAC_CONST(0.032219658568338) },
+ { FRAC_CONST(0.001781418851302), FRAC_CONST(0.032225660792960) },
+ { FRAC_CONST(0.001675951272410), FRAC_CONST(0.032231317906644) },
+ { FRAC_CONST(0.001570465745428), FRAC_CONST(0.032236629848809) },
+ { FRAC_CONST(0.001464963400018), FRAC_CONST(0.032241596562566) },
+ { FRAC_CONST(0.001359445366028), FRAC_CONST(0.032246217994727) },
+ { FRAC_CONST(0.001253912773470), FRAC_CONST(0.032250494095799) },
+ { FRAC_CONST(0.001148366752513), FRAC_CONST(0.032254424819990) },
+ { FRAC_CONST(0.001042808433471), FRAC_CONST(0.032258010125204) },
+ { FRAC_CONST(0.000937238946789), FRAC_CONST(0.032261249973045) },
+ { FRAC_CONST(0.000831659423030), FRAC_CONST(0.032264144328817) },
+ { FRAC_CONST(0.000726070992868), FRAC_CONST(0.032266693161525) },
+ { FRAC_CONST(0.000620474787068), FRAC_CONST(0.032268896443871) },
+ { FRAC_CONST(0.000514871936481), FRAC_CONST(0.032270754152261) },
+ { FRAC_CONST(0.000409263572030), FRAC_CONST(0.032272266266801) },
+ { FRAC_CONST(0.000303650824695), FRAC_CONST(0.032273432771295) },
+ { FRAC_CONST(0.000198034825504), FRAC_CONST(0.032274253653254) },
+ { FRAC_CONST(0.000092416705518), FRAC_CONST(0.032274728903884) }
+ };
+
+#ifdef LD_DEC
+ /* 240 (N/4) complex twiddle factors */
+ ALIGN static const complex_t mdct_tab_960[] = {
+ { FRAC_CONST(0.045643531183573), FRAC_CONST(0.000037342034959) },
+ { FRAC_CONST(0.045642309173789), FRAC_CONST(0.000336075315362) },
+ { FRAC_CONST(0.045639131999390), FRAC_CONST(0.000634794199417) },
+ { FRAC_CONST(0.045633999796474), FRAC_CONST(0.000933485891002) },
+ { FRAC_CONST(0.045626912784890), FRAC_CONST(0.001232137595157) },
+ { FRAC_CONST(0.045617871268219), FRAC_CONST(0.001530736518639) },
+ { FRAC_CONST(0.045606875633772), FRAC_CONST(0.001829269870464) },
+ { FRAC_CONST(0.045593926352564), FRAC_CONST(0.002127724862455) },
+ { FRAC_CONST(0.045579023979299), FRAC_CONST(0.002426088709795) },
+ { FRAC_CONST(0.045562169152346), FRAC_CONST(0.002724348631569) },
+ { FRAC_CONST(0.045543362593709), FRAC_CONST(0.003022491851315) },
+ { FRAC_CONST(0.045522605108999), FRAC_CONST(0.003320505597570) },
+ { FRAC_CONST(0.045499897587396), FRAC_CONST(0.003618377104416) },
+ { FRAC_CONST(0.045475241001617), FRAC_CONST(0.003916093612031) },
+ { FRAC_CONST(0.045448636407866), FRAC_CONST(0.004213642367228) },
+ { FRAC_CONST(0.045420084945797), FRAC_CONST(0.004511010624011) },
+ { FRAC_CONST(0.045389587838458), FRAC_CONST(0.004808185644112) },
+ { FRAC_CONST(0.045357146392244), FRAC_CONST(0.005105154697544) },
+ { FRAC_CONST(0.045322761996840), FRAC_CONST(0.005401905063139) },
+ { FRAC_CONST(0.045286436125157), FRAC_CONST(0.005698424029100) },
+ { FRAC_CONST(0.045248170333275), FRAC_CONST(0.005994698893542) },
+ { FRAC_CONST(0.045207966260374), FRAC_CONST(0.006290716965035) },
+ { FRAC_CONST(0.045165825628663), FRAC_CONST(0.006586465563151) },
+ { FRAC_CONST(0.045121750243305), FRAC_CONST(0.006881932019003) },
+ { FRAC_CONST(0.045075741992343), FRAC_CONST(0.007177103675792) },
+ { FRAC_CONST(0.045027802846618), FRAC_CONST(0.007471967889347) },
+ { FRAC_CONST(0.044977934859683), FRAC_CONST(0.007766512028667) },
+ { FRAC_CONST(0.044926140167717), FRAC_CONST(0.008060723476460) },
+ { FRAC_CONST(0.044872420989432), FRAC_CONST(0.008354589629687) },
+ { FRAC_CONST(0.044816779625979), FRAC_CONST(0.008648097900101) },
+ { FRAC_CONST(0.044759218460849), FRAC_CONST(0.008941235714784) },
+ { FRAC_CONST(0.044699739959770), FRAC_CONST(0.009233990516688) },
+ { FRAC_CONST(0.044638346670603), FRAC_CONST(0.009526349765171) },
+ { FRAC_CONST(0.044575041223233), FRAC_CONST(0.009818300936537) },
+ { FRAC_CONST(0.044509826329454), FRAC_CONST(0.010109831524568) },
+ { FRAC_CONST(0.044442704782856), FRAC_CONST(0.010400929041064) },
+ { FRAC_CONST(0.044373679458701), FRAC_CONST(0.010691581016378) },
+ { FRAC_CONST(0.044302753313806), FRAC_CONST(0.010981774999945) },
+ { FRAC_CONST(0.044229929386409), FRAC_CONST(0.011271498560822) },
+ { FRAC_CONST(0.044155210796046), FRAC_CONST(0.011560739288214) },
+ { FRAC_CONST(0.044078600743413), FRAC_CONST(0.011849484792012) },
+ { FRAC_CONST(0.044000102510229), FRAC_CONST(0.012137722703321) },
+ { FRAC_CONST(0.043919719459097), FRAC_CONST(0.012425440674986) },
+ { FRAC_CONST(0.043837455033359), FRAC_CONST(0.012712626382127) },
+ { FRAC_CONST(0.043753312756950), FRAC_CONST(0.012999267522665) },
+ { FRAC_CONST(0.043667296234245), FRAC_CONST(0.013285351817848) },
+ { FRAC_CONST(0.043579409149906), FRAC_CONST(0.013570867012776) },
+ { FRAC_CONST(0.043489655268722), FRAC_CONST(0.013855800876928) },
+ { FRAC_CONST(0.043398038435451), FRAC_CONST(0.014140141204686) },
+ { FRAC_CONST(0.043304562574653), FRAC_CONST(0.014423875815857) },
+ { FRAC_CONST(0.043209231690524), FRAC_CONST(0.014706992556195) },
+ { FRAC_CONST(0.043112049866720), FRAC_CONST(0.014989479297920) },
+ { FRAC_CONST(0.043013021266188), FRAC_CONST(0.015271323940241) },
+ { FRAC_CONST(0.042912150130984), FRAC_CONST(0.015552514409871) },
+ { FRAC_CONST(0.042809440782090), FRAC_CONST(0.015833038661547) },
+ { FRAC_CONST(0.042704897619235), FRAC_CONST(0.016112884678543) },
+ { FRAC_CONST(0.042598525120698), FRAC_CONST(0.016392040473187) },
+ { FRAC_CONST(0.042490327843124), FRAC_CONST(0.016670494087374) },
+ { FRAC_CONST(0.042380310421324), FRAC_CONST(0.016948233593079) },
+ { FRAC_CONST(0.042268477568078), FRAC_CONST(0.017225247092864) },
+ { FRAC_CONST(0.042154834073934), FRAC_CONST(0.017501522720393) },
+ { FRAC_CONST(0.042039384807000), FRAC_CONST(0.017777048640940) },
+ { FRAC_CONST(0.041922134712739), FRAC_CONST(0.018051813051888) },
+ { FRAC_CONST(0.041803088813754), FRAC_CONST(0.018325804183247) },
+ { FRAC_CONST(0.041682252209576), FRAC_CONST(0.018599010298148) },
+ { FRAC_CONST(0.041559630076443), FRAC_CONST(0.018871419693350) },
+ { FRAC_CONST(0.041435227667079), FRAC_CONST(0.019143020699741) },
+ { FRAC_CONST(0.041309050310468), FRAC_CONST(0.019413801682838) },
+ { FRAC_CONST(0.041181103411629), FRAC_CONST(0.019683751043285) },
+ { FRAC_CONST(0.041051392451382), FRAC_CONST(0.019952857217350) },
+ { FRAC_CONST(0.040919922986111), FRAC_CONST(0.020221108677421) },
+ { FRAC_CONST(0.040786700647532), FRAC_CONST(0.020488493932496) },
+ { FRAC_CONST(0.040651731142446), FRAC_CONST(0.020755001528683) },
+ { FRAC_CONST(0.040515020252497), FRAC_CONST(0.021020620049682) },
+ { FRAC_CONST(0.040376573833925), FRAC_CONST(0.021285338117280) },
+ { FRAC_CONST(0.040236397817314), FRAC_CONST(0.021549144391836) },
+ { FRAC_CONST(0.040094498207337), FRAC_CONST(0.021812027572768) },
+ { FRAC_CONST(0.039950881082502), FRAC_CONST(0.022073976399034) },
+ { FRAC_CONST(0.039805552594888), FRAC_CONST(0.022334979649620) },
+ { FRAC_CONST(0.039658518969884), FRAC_CONST(0.022595026144014) },
+ { FRAC_CONST(0.039509786505922), FRAC_CONST(0.022854104742690) },
+ { FRAC_CONST(0.039359361574204), FRAC_CONST(0.023112204347583) },
+ { FRAC_CONST(0.039207250618434), FRAC_CONST(0.023369313902565) },
+ { FRAC_CONST(0.039053460154540), FRAC_CONST(0.023625422393919) },
+ { FRAC_CONST(0.038897996770393), FRAC_CONST(0.023880518850809) },
+ { FRAC_CONST(0.038740867125527), FRAC_CONST(0.024134592345752) },
+ { FRAC_CONST(0.038582077950852), FRAC_CONST(0.024387631995085) },
+ { FRAC_CONST(0.038421636048370), FRAC_CONST(0.024639626959432) },
+ { FRAC_CONST(0.038259548290876), FRAC_CONST(0.024890566444167) },
+ { FRAC_CONST(0.038095821621671), FRAC_CONST(0.025140439699877) },
+ { FRAC_CONST(0.037930463054261), FRAC_CONST(0.025389236022825) },
+ { FRAC_CONST(0.037763479672055), FRAC_CONST(0.025636944755403) },
+ { FRAC_CONST(0.037594878628068), FRAC_CONST(0.025883555286595) },
+ { FRAC_CONST(0.037424667144605), FRAC_CONST(0.026129057052425) },
+ { FRAC_CONST(0.037252852512960), FRAC_CONST(0.026373439536415) },
+ { FRAC_CONST(0.037079442093102), FRAC_CONST(0.026616692270033) },
+ { FRAC_CONST(0.036904443313354), FRAC_CONST(0.026858804833142) },
+ { FRAC_CONST(0.036727863670081), FRAC_CONST(0.027099766854444) },
+ { FRAC_CONST(0.036549710727369), FRAC_CONST(0.027339568011930) },
+ { FRAC_CONST(0.036369992116697), FRAC_CONST(0.027578198033315) },
+ { FRAC_CONST(0.036188715536611), FRAC_CONST(0.027815646696484) },
+ { FRAC_CONST(0.036005888752396), FRAC_CONST(0.028051903829926) },
+ { FRAC_CONST(0.035821519595745), FRAC_CONST(0.028286959313171) },
+ { FRAC_CONST(0.035635615964417), FRAC_CONST(0.028520803077226) },
+ { FRAC_CONST(0.035448185821906), FRAC_CONST(0.028753425105002) },
+ { FRAC_CONST(0.035259237197095), FRAC_CONST(0.028984815431745) },
+ { FRAC_CONST(0.035068778183914), FRAC_CONST(0.029214964145465) },
+ { FRAC_CONST(0.034876816940994), FRAC_CONST(0.029443861387355) },
+ { FRAC_CONST(0.034683361691315), FRAC_CONST(0.029671497352220) },
+ { FRAC_CONST(0.034488420721856), FRAC_CONST(0.029897862288892) },
+ { FRAC_CONST(0.034292002383240), FRAC_CONST(0.030122946500652) },
+ { FRAC_CONST(0.034094115089375), FRAC_CONST(0.030346740345641) },
+ { FRAC_CONST(0.033894767317093), FRAC_CONST(0.030569234237276) },
+ { FRAC_CONST(0.033693967605790), FRAC_CONST(0.030790418644658) },
+ { FRAC_CONST(0.033491724557057), FRAC_CONST(0.031010284092984) },
+ { FRAC_CONST(0.033288046834313), FRAC_CONST(0.031228821163949) },
+ { FRAC_CONST(0.033082943162434), FRAC_CONST(0.031446020496153) },
+ { FRAC_CONST(0.032876422327378), FRAC_CONST(0.031661872785500) },
+ { FRAC_CONST(0.032668493175811), FRAC_CONST(0.031876368785596) },
+ { FRAC_CONST(0.032459164614726), FRAC_CONST(0.032089499308145) },
+ { FRAC_CONST(0.032248445611061), FRAC_CONST(0.032301255223347) },
+ { FRAC_CONST(0.032036345191317), FRAC_CONST(0.032511627460281) },
+ { FRAC_CONST(0.031822872441171), FRAC_CONST(0.032720607007302) },
+ { FRAC_CONST(0.031608036505083), FRAC_CONST(0.032928184912422) },
+ { FRAC_CONST(0.031391846585912), FRAC_CONST(0.033134352283693) },
+ { FRAC_CONST(0.031174311944513), FRAC_CONST(0.033339100289593) },
+ { FRAC_CONST(0.030955441899347), FRAC_CONST(0.033542420159397) },
+ { FRAC_CONST(0.030735245826077), FRAC_CONST(0.033744303183559) },
+ { FRAC_CONST(0.030513733157171), FRAC_CONST(0.033944740714083) },
+ { FRAC_CONST(0.030290913381494), FRAC_CONST(0.034143724164891) },
+ { FRAC_CONST(0.030066796043904), FRAC_CONST(0.034341245012195) },
+ { FRAC_CONST(0.029841390744841), FRAC_CONST(0.034537294794860) },
+ { FRAC_CONST(0.029614707139919), FRAC_CONST(0.034731865114764) },
+ { FRAC_CONST(0.029386754939508), FRAC_CONST(0.034924947637164) },
+ { FRAC_CONST(0.029157543908322), FRAC_CONST(0.035116534091046) },
+ { FRAC_CONST(0.028927083864999), FRAC_CONST(0.035306616269485) },
+ { FRAC_CONST(0.028695384681680), FRAC_CONST(0.035495186029992) },
+ { FRAC_CONST(0.028462456283587), FRAC_CONST(0.035682235294866) },
+ { FRAC_CONST(0.028228308648598), FRAC_CONST(0.035867756051541) },
+ { FRAC_CONST(0.027992951806817), FRAC_CONST(0.036051740352923) },
+ { FRAC_CONST(0.027756395840148), FRAC_CONST(0.036234180317738) },
+ { FRAC_CONST(0.027518650881862), FRAC_CONST(0.036415068130865) },
+ { FRAC_CONST(0.027279727116161), FRAC_CONST(0.036594396043672) },
+ { FRAC_CONST(0.027039634777745), FRAC_CONST(0.036772156374348) },
+ { FRAC_CONST(0.026798384151369), FRAC_CONST(0.036948341508233) },
+ { FRAC_CONST(0.026555985571409), FRAC_CONST(0.037122943898140) },
+ { FRAC_CONST(0.026312449421412), FRAC_CONST(0.037295956064686) },
+ { FRAC_CONST(0.026067786133656), FRAC_CONST(0.037467370596605) },
+ { FRAC_CONST(0.025822006188702), FRAC_CONST(0.037637180151068) },
+ { FRAC_CONST(0.025575120114946), FRAC_CONST(0.037805377454000) },
+ { FRAC_CONST(0.025327138488165), FRAC_CONST(0.037971955300388) },
+ { FRAC_CONST(0.025078071931066), FRAC_CONST(0.038136906554591) },
+ { FRAC_CONST(0.024827931112832), FRAC_CONST(0.038300224150647) },
+ { FRAC_CONST(0.024576726748663), FRAC_CONST(0.038461901092573) },
+ { FRAC_CONST(0.024324469599317), FRAC_CONST(0.038621930454668) },
+ { FRAC_CONST(0.024071170470652), FRAC_CONST(0.038780305381806) },
+ { FRAC_CONST(0.023816840213160), FRAC_CONST(0.038937019089732) },
+ { FRAC_CONST(0.023561489721501), FRAC_CONST(0.039092064865353) },
+ { FRAC_CONST(0.023305129934041), FRAC_CONST(0.039245436067023) },
+ { FRAC_CONST(0.023047771832380), FRAC_CONST(0.039397126124832) },
+ { FRAC_CONST(0.022789426440883), FRAC_CONST(0.039547128540881) },
+ { FRAC_CONST(0.022530104826206), FRAC_CONST(0.039695436889566) },
+ { FRAC_CONST(0.022269818096825), FRAC_CONST(0.039842044817851) },
+ { FRAC_CONST(0.022008577402555), FRAC_CONST(0.039986946045542) },
+ { FRAC_CONST(0.021746393934081), FRAC_CONST(0.040130134365550) },
+ { FRAC_CONST(0.021483278922467), FRAC_CONST(0.040271603644166) },
+ { FRAC_CONST(0.021219243638687), FRAC_CONST(0.040411347821316) },
+ { FRAC_CONST(0.020954299393132), FRAC_CONST(0.040549360910825) },
+ { FRAC_CONST(0.020688457535133), FRAC_CONST(0.040685637000671) },
+ { FRAC_CONST(0.020421729452469), FRAC_CONST(0.040820170253240) },
+ { FRAC_CONST(0.020154126570884), FRAC_CONST(0.040952954905576) },
+ { FRAC_CONST(0.019885660353596), FRAC_CONST(0.041083985269625) },
+ { FRAC_CONST(0.019616342300802), FRAC_CONST(0.041213255732484) },
+ { FRAC_CONST(0.019346183949192), FRAC_CONST(0.041340760756635) },
+ { FRAC_CONST(0.019075196871451), FRAC_CONST(0.041466494880189) },
+ { FRAC_CONST(0.018803392675763), FRAC_CONST(0.041590452717113) },
+ { FRAC_CONST(0.018530783005316), FRAC_CONST(0.041712628957466) },
+ { FRAC_CONST(0.018257379537800), FRAC_CONST(0.041833018367625) },
+ { FRAC_CONST(0.017983193984910), FRAC_CONST(0.041951615790509) },
+ { FRAC_CONST(0.017708238091842), FRAC_CONST(0.042068416145797) },
+ { FRAC_CONST(0.017432523636792), FRAC_CONST(0.042183414430153) },
+ { FRAC_CONST(0.017156062430449), FRAC_CONST(0.042296605717432) },
+ { FRAC_CONST(0.016878866315491), FRAC_CONST(0.042407985158896) },
+ { FRAC_CONST(0.016600947166078), FRAC_CONST(0.042517547983420) },
+ { FRAC_CONST(0.016322316887341), FRAC_CONST(0.042625289497698) },
+ { FRAC_CONST(0.016042987414872), FRAC_CONST(0.042731205086442) },
+ { FRAC_CONST(0.015762970714219), FRAC_CONST(0.042835290212581) },
+ { FRAC_CONST(0.015482278780363), FRAC_CONST(0.042937540417454) },
+ { FRAC_CONST(0.015200923637213), FRAC_CONST(0.043037951321002) },
+ { FRAC_CONST(0.014918917337087), FRAC_CONST(0.043136518621958) },
+ { FRAC_CONST(0.014636271960196), FRAC_CONST(0.043233238098025) },
+ { FRAC_CONST(0.014352999614128), FRAC_CONST(0.043328105606063) },
+ { FRAC_CONST(0.014069112433327), FRAC_CONST(0.043421117082265) },
+ { FRAC_CONST(0.013784622578575), FRAC_CONST(0.043512268542327) },
+ { FRAC_CONST(0.013499542236471), FRAC_CONST(0.043601556081625) },
+ { FRAC_CONST(0.013213883618907), FRAC_CONST(0.043688975875378) },
+ { FRAC_CONST(0.012927658962548), FRAC_CONST(0.043774524178812) },
+ { FRAC_CONST(0.012640880528305), FRAC_CONST(0.043858197327323) },
+ { FRAC_CONST(0.012353560600813), FRAC_CONST(0.043939991736633) },
+ { FRAC_CONST(0.012065711487901), FRAC_CONST(0.044019903902940) },
+ { FRAC_CONST(0.011777345520066), FRAC_CONST(0.044097930403073) },
+ { FRAC_CONST(0.011488475049948), FRAC_CONST(0.044174067894638) },
+ { FRAC_CONST(0.011199112451794), FRAC_CONST(0.044248313116156) },
+ { FRAC_CONST(0.010909270120937), FRAC_CONST(0.044320662887211) },
+ { FRAC_CONST(0.010618960473257), FRAC_CONST(0.044391114108577) },
+ { FRAC_CONST(0.010328195944653), FRAC_CONST(0.044459663762361) },
+ { FRAC_CONST(0.010036988990509), FRAC_CONST(0.044526308912122) },
+ { FRAC_CONST(0.009745352085163), FRAC_CONST(0.044591046703005) },
+ { FRAC_CONST(0.009453297721368), FRAC_CONST(0.044653874361857) },
+ { FRAC_CONST(0.009160838409762), FRAC_CONST(0.044714789197351) },
+ { FRAC_CONST(0.008867986678328), FRAC_CONST(0.044773788600099) },
+ { FRAC_CONST(0.008574755071860), FRAC_CONST(0.044830870042761) },
+ { FRAC_CONST(0.008281156151424), FRAC_CONST(0.044886031080160) },
+ { FRAC_CONST(0.007987202493820), FRAC_CONST(0.044939269349379) },
+ { FRAC_CONST(0.007692906691044), FRAC_CONST(0.044990582569869) },
+ { FRAC_CONST(0.007398281349750), FRAC_CONST(0.045039968543542) },
+ { FRAC_CONST(0.007103339090706), FRAC_CONST(0.045087425154868) },
+ { FRAC_CONST(0.006808092548258), FRAC_CONST(0.045132950370962) },
+ { FRAC_CONST(0.006512554369783), FRAC_CONST(0.045176542241676) },
+ { FRAC_CONST(0.006216737215155), FRAC_CONST(0.045218198899680) },
+ { FRAC_CONST(0.005920653756196), FRAC_CONST(0.045257918560541) },
+ { FRAC_CONST(0.005624316676135), FRAC_CONST(0.045295699522801) },
+ { FRAC_CONST(0.005327738669067), FRAC_CONST(0.045331540168049) },
+ { FRAC_CONST(0.005030932439406), FRAC_CONST(0.045365438960992) },
+ { FRAC_CONST(0.004733910701344), FRAC_CONST(0.045397394449517) },
+ { FRAC_CONST(0.004436686178303), FRAC_CONST(0.045427405264758) },
+ { FRAC_CONST(0.004139271602393), FRAC_CONST(0.045455470121152) },
+ { FRAC_CONST(0.003841679713863), FRAC_CONST(0.045481587816494) },
+ { FRAC_CONST(0.003543923260561), FRAC_CONST(0.045505757231988) },
+ { FRAC_CONST(0.003246014997382), FRAC_CONST(0.045527977332297) },
+ { FRAC_CONST(0.002947967685724), FRAC_CONST(0.045548247165585) },
+ { FRAC_CONST(0.002649794092941), FRAC_CONST(0.045566565863562) },
+ { FRAC_CONST(0.002351506991799), FRAC_CONST(0.045582932641515) },
+ { FRAC_CONST(0.002053119159924), FRAC_CONST(0.045597346798344) },
+ { FRAC_CONST(0.001754643379257), FRAC_CONST(0.045609807716597) },
+ { FRAC_CONST(0.001456092435508), FRAC_CONST(0.045620314862489) },
+ { FRAC_CONST(0.001157479117605), FRAC_CONST(0.045628867785927) },
+ { FRAC_CONST(0.000858816217149), FRAC_CONST(0.045635466120535) },
+ { FRAC_CONST(0.000560116527865), FRAC_CONST(0.045640109583661) },
+ { FRAC_CONST(0.000261392845053), FRAC_CONST(0.045642797976394) }
+ };
+#endif // LD_DEC
+
+ /* 60 (N/4) complex twiddle factors */
+ ALIGN static const complex_t mdct_tab_240[] = {
+ { FRAC_CONST(0.091286604111815), FRAC_CONST(0.000298735779793) },
+ { FRAC_CONST(0.091247502481454), FRAC_CONST(0.002688238127538) },
+ { FRAC_CONST(0.091145864370807), FRAC_CONST(0.005075898091152) },
+ { FRAC_CONST(0.090981759437558), FRAC_CONST(0.007460079287760) },
+ { FRAC_CONST(0.090755300151030), FRAC_CONST(0.009839147718664) },
+ { FRAC_CONST(0.090466641715108), FRAC_CONST(0.012211472889198) },
+ { FRAC_CONST(0.090115981961863), FRAC_CONST(0.014575428926191) },
+ { FRAC_CONST(0.089703561215976), FRAC_CONST(0.016929395692256) },
+ { FRAC_CONST(0.089229662130024), FRAC_CONST(0.019271759896156) },
+ { FRAC_CONST(0.088694609490769), FRAC_CONST(0.021600916198470) },
+ { FRAC_CONST(0.088098769996564), FRAC_CONST(0.023915268311810) },
+ { FRAC_CONST(0.087442552006035), FRAC_CONST(0.026213230094844) },
+ { FRAC_CONST(0.086726405258214), FRAC_CONST(0.028493226639351) },
+ { FRAC_CONST(0.085950820564309), FRAC_CONST(0.030753695349588) },
+ { FRAC_CONST(0.085116329471329), FRAC_CONST(0.032993087013213) },
+ { FRAC_CONST(0.084223503897785), FRAC_CONST(0.035209866863042) },
+ { FRAC_CONST(0.083272955741727), FRAC_CONST(0.037402515628894) },
+ { FRAC_CONST(0.082265336461381), FRAC_CONST(0.039569530578832) },
+ { FRAC_CONST(0.081201336628670), FRAC_CONST(0.041709426549053) },
+ { FRAC_CONST(0.080081685455930), FRAC_CONST(0.043820736961749) },
+ { FRAC_CONST(0.078907150296148), FRAC_CONST(0.045902014830227) },
+ { FRAC_CONST(0.077678536117054), FRAC_CONST(0.047951833750597) },
+ { FRAC_CONST(0.076396684949434), FRAC_CONST(0.049968788879362) },
+ { FRAC_CONST(0.075062475310050), FRAC_CONST(0.051951497896226) },
+ { FRAC_CONST(0.073676821599542), FRAC_CONST(0.053898601951466) },
+ { FRAC_CONST(0.072240673475749), FRAC_CONST(0.055808766597225) },
+ { FRAC_CONST(0.070755015202858), FRAC_CONST(0.057680682702068) },
+ { FRAC_CONST(0.069220864976840), FRAC_CONST(0.059513067348201) },
+ { FRAC_CONST(0.067639274227625), FRAC_CONST(0.061304664710718) },
+ { FRAC_CONST(0.066011326898512), FRAC_CONST(0.063054246918278) },
+ { FRAC_CONST(0.064338138703282), FRAC_CONST(0.064760614894630) },
+ { FRAC_CONST(0.062620856361546), FRAC_CONST(0.066422599180399) },
+ { FRAC_CONST(0.060860656812842), FRAC_CONST(0.068039060734572) },
+ { FRAC_CONST(0.059058746410016), FRAC_CONST(0.069608891715145) },
+ { FRAC_CONST(0.057216360092450), FRAC_CONST(0.071131016238378) },
+ { FRAC_CONST(0.055334760539699), FRAC_CONST(0.072604391116154) },
+ { FRAC_CONST(0.053415237306106), FRAC_CONST(0.074028006570930) },
+ { FRAC_CONST(0.051459105937014), FRAC_CONST(0.075400886927784) },
+ { FRAC_CONST(0.049467707067153), FRAC_CONST(0.076722091283096) },
+ { FRAC_CONST(0.047442405501835), FRAC_CONST(0.077990714149396) },
+ { FRAC_CONST(0.045384589281588), FRAC_CONST(0.079205886075941) },
+ { FRAC_CONST(0.043295668730857), FRAC_CONST(0.080366774244592) },
+ { FRAC_CONST(0.041177075491445), FRAC_CONST(0.081472583040586) },
+ { FRAC_CONST(0.039030261541332), FRAC_CONST(0.082522554597810) },
+ { FRAC_CONST(0.036856698199564), FRAC_CONST(0.083515969318206) },
+ { FRAC_CONST(0.034657875117883), FRAC_CONST(0.084452146364948) },
+ { FRAC_CONST(0.032435299259796), FRAC_CONST(0.085330444129049) },
+ { FRAC_CONST(0.030190493867775), FRAC_CONST(0.086150260669096) },
+ { FRAC_CONST(0.027924997419306), FRAC_CONST(0.086911034123781) },
+ { FRAC_CONST(0.025640362572491), FRAC_CONST(0.087612243096981) },
+ { FRAC_CONST(0.023338155101933), FRAC_CONST(0.088253407015092) },
+ { FRAC_CONST(0.021019952825636), FRAC_CONST(0.088834086456390) },
+ { FRAC_CONST(0.018687344523641), FRAC_CONST(0.089353883452193) },
+ { FRAC_CONST(0.016341928849164), FRAC_CONST(0.089812441759604) },
+ { FRAC_CONST(0.013985313232951), FRAC_CONST(0.090209447105664) },
+ { FRAC_CONST(0.011619112781631), FRAC_CONST(0.090544627402740) },
+ { FRAC_CONST(0.009244949170797), FRAC_CONST(0.090817752935000) },
+ { FRAC_CONST(0.006864449533597), FRAC_CONST(0.091028636515846) },
+ { FRAC_CONST(0.004479245345574), FRAC_CONST(0.091177133616206) },
+ { FRAC_CONST(0.002090971306534), FRAC_CONST(0.091263142463585) }
+ };
+#endif // ALLOW_SMALL_FRAMELENGTH
+
+#ifdef SSR_DEC
+ /* 128 (N/4) complex twiddle factors */
+ ALIGN static const complex_t mdct_tab_512[] = {
+ { FRAC_CONST(0.062499926465731), FRAC_CONST(0.000095873761643) },
+ { FRAC_CONST(0.062494043817678), FRAC_CONST(0.000862836783004) },
+ { FRAC_CONST(0.062478749796497), FRAC_CONST(0.001629669864319) },
+ { FRAC_CONST(0.062454046705412), FRAC_CONST(0.002396257523347) },
+ { FRAC_CONST(0.062419938264617), FRAC_CONST(0.003162484314806) },
+ { FRAC_CONST(0.062376429610718), FRAC_CONST(0.003928234847760) },
+ { FRAC_CONST(0.062323527295958), FRAC_CONST(0.004693393802995) },
+ { FRAC_CONST(0.062261239287231), FRAC_CONST(0.005457845950387) },
+ { FRAC_CONST(0.062189574964882), FRAC_CONST(0.006221476166254) },
+ { FRAC_CONST(0.062108545121295), FRAC_CONST(0.006984169450695) },
+ { FRAC_CONST(0.062018161959266), FRAC_CONST(0.007745810944907) },
+ { FRAC_CONST(0.061918439090167), FRAC_CONST(0.008506285948482) },
+ { FRAC_CONST(0.061809391531894), FRAC_CONST(0.009265479936681) },
+ { FRAC_CONST(0.061691035706609), FRAC_CONST(0.010023278577683) },
+ { FRAC_CONST(0.061563389438265), FRAC_CONST(0.010779567749800) },
+ { FRAC_CONST(0.061426471949919), FRAC_CONST(0.011534233558664) },
+ { FRAC_CONST(0.061280303860842), FRAC_CONST(0.012287162354380) },
+ { FRAC_CONST(0.061124907183410), FRAC_CONST(0.013038240748641) },
+ { FRAC_CONST(0.060960305319791), FRAC_CONST(0.013787355631805) },
+ { FRAC_CONST(0.060786523058421), FRAC_CONST(0.014534394189923) },
+ { FRAC_CONST(0.060603586570268), FRAC_CONST(0.015279243921739) },
+ { FRAC_CONST(0.060411523404896), FRAC_CONST(0.016021792655621) },
+ { FRAC_CONST(0.060210362486310), FRAC_CONST(0.016761928566463) },
+ { FRAC_CONST(0.060000134108604), FRAC_CONST(0.017499540192517) },
+ { FRAC_CONST(0.059780869931400), FRAC_CONST(0.018234516452187) },
+ { FRAC_CONST(0.059552602975075), FRAC_CONST(0.018966746660751) },
+ { FRAC_CONST(0.059315367615794), FRAC_CONST(0.019696120547033) },
+ { FRAC_CONST(0.059069199580329), FRAC_CONST(0.020422528270008) },
+ { FRAC_CONST(0.058814135940681), FRAC_CONST(0.021145860435346) },
+ { FRAC_CONST(0.058550215108495), FRAC_CONST(0.021866008111883) },
+ { FRAC_CONST(0.058277476829279), FRAC_CONST(0.022582862848028) },
+ { FRAC_CONST(0.057995962176414), FRAC_CONST(0.023296316688095) },
+ { FRAC_CONST(0.057705713544970), FRAC_CONST(0.024006262188558) },
+ { FRAC_CONST(0.057406774645326), FRAC_CONST(0.024712592434239) },
+ { FRAC_CONST(0.057099190496578), FRAC_CONST(0.025415201054398) },
+ { FRAC_CONST(0.056783007419769), FRAC_CONST(0.026113982238763) },
+ { FRAC_CONST(0.056458273030907), FRAC_CONST(0.026808830753458) },
+ { FRAC_CONST(0.056125036233796), FRAC_CONST(0.027499641956852) },
+ { FRAC_CONST(0.055783347212673), FRAC_CONST(0.028186311815319) },
+ { FRAC_CONST(0.055433257424646), FRAC_CONST(0.028868736918904) },
+ { FRAC_CONST(0.055074819591951), FRAC_CONST(0.029546814496896) },
+ { FRAC_CONST(0.054708087694007), FRAC_CONST(0.030220442433307) },
+ { FRAC_CONST(0.054333116959288), FRAC_CONST(0.030889519282247) },
+ { FRAC_CONST(0.053949963857008), FRAC_CONST(0.031553944283204) },
+ { FRAC_CONST(0.053558686088614), FRAC_CONST(0.032213617376216) },
+ { FRAC_CONST(0.053159342579100), FRAC_CONST(0.032868439216943) },
+ { FRAC_CONST(0.052751993468129), FRAC_CONST(0.033518311191623) },
+ { FRAC_CONST(0.052336700100979), FRAC_CONST(0.034163135431927) },
+ { FRAC_CONST(0.051913525019303), FRAC_CONST(0.034802814829698) },
+ { FRAC_CONST(0.051482531951712), FRAC_CONST(0.035437253051569) },
+ { FRAC_CONST(0.051043785804177), FRAC_CONST(0.036066354553480) },
+ { FRAC_CONST(0.050597352650253), FRAC_CONST(0.036690024595057) },
+ { FRAC_CONST(0.050143299721132), FRAC_CONST(0.037308169253887) },
+ { FRAC_CONST(0.049681695395515), FRAC_CONST(0.037920695439658) },
+ { FRAC_CONST(0.049212609189314), FRAC_CONST(0.038527510908178) },
+ { FRAC_CONST(0.048736111745188), FRAC_CONST(0.039128524275271) },
+ { FRAC_CONST(0.048252274821899), FRAC_CONST(0.039723645030535) },
+ { FRAC_CONST(0.047761171283507), FRAC_CONST(0.040312783550971) },
+ { FRAC_CONST(0.047262875088400), FRAC_CONST(0.040895851114488) },
+ { FRAC_CONST(0.046757461278150), FRAC_CONST(0.041472759913252) },
+ { FRAC_CONST(0.046245005966220), FRAC_CONST(0.042043423066923) },
+ { FRAC_CONST(0.045725586326493), FRAC_CONST(0.042607754635728) },
+ { FRAC_CONST(0.045199280581658), FRAC_CONST(0.043165669633408) },
+ { FRAC_CONST(0.044666167991423), FRAC_CONST(0.043717084040018) },
+ { FRAC_CONST(0.044126328840584), FRAC_CONST(0.044261914814575) },
+ { FRAC_CONST(0.043579844426930), FRAC_CONST(0.044800079907569) },
+ { FRAC_CONST(0.043026797049006), FRAC_CONST(0.045331498273316) },
+ { FRAC_CONST(0.042467269993710), FRAC_CONST(0.045856089882166) },
+ { FRAC_CONST(0.041901347523761), FRAC_CONST(0.046373775732552) },
+ { FRAC_CONST(0.041329114865000), FRAC_CONST(0.046884477862888) },
+ { FRAC_CONST(0.040750658193560), FRAC_CONST(0.047388119363313) },
+ { FRAC_CONST(0.040166064622889), FRAC_CONST(0.047884624387270) },
+ { FRAC_CONST(0.039575422190629), FRAC_CONST(0.048373918162926) },
+ { FRAC_CONST(0.038978819845356), FRAC_CONST(0.048855927004441) },
+ { FRAC_CONST(0.038376347433190), FRAC_CONST(0.049330578323055) },
+ { FRAC_CONST(0.037768095684260), FRAC_CONST(0.049797800638026) },
+ { FRAC_CONST(0.037154156199042), FRAC_CONST(0.050257523587392) },
+ { FRAC_CONST(0.036534621434563), FRAC_CONST(0.050709677938566) },
+ { FRAC_CONST(0.035909584690482), FRAC_CONST(0.051154195598769) },
+ { FRAC_CONST(0.035279140095032), FRAC_CONST(0.051591009625274) },
+ { FRAC_CONST(0.034643382590851), FRAC_CONST(0.052020054235496) },
+ { FRAC_CONST(0.034002407920680), FRAC_CONST(0.052441264816895) },
+ { FRAC_CONST(0.033356312612947), FRAC_CONST(0.052854577936706) },
+ { FRAC_CONST(0.032705193967229), FRAC_CONST(0.053259931351495) },
+ { FRAC_CONST(0.032049150039598), FRAC_CONST(0.053657264016528) },
+ { FRAC_CONST(0.031388279627857), FRAC_CONST(0.054046516094966) },
+ { FRAC_CONST(0.030722682256659), FRAC_CONST(0.054427628966880) },
+ { FRAC_CONST(0.030052458162521), FRAC_CONST(0.054800545238072) },
+ { FRAC_CONST(0.029377708278725), FRAC_CONST(0.055165208748723) },
+ { FRAC_CONST(0.028698534220122), FRAC_CONST(0.055521564581850) },
+ { FRAC_CONST(0.028015038267826), FRAC_CONST(0.055869559071575) },
+ { FRAC_CONST(0.027327323353815), FRAC_CONST(0.056209139811209) },
+ { FRAC_CONST(0.026635493045425), FRAC_CONST(0.056540255661140) },
+ { FRAC_CONST(0.025939651529755), FRAC_CONST(0.056862856756541) },
+ { FRAC_CONST(0.025239903597978), FRAC_CONST(0.057176894514872) },
+ { FRAC_CONST(0.024536354629559), FRAC_CONST(0.057482321643202) },
+ { FRAC_CONST(0.023829110576385), FRAC_CONST(0.057779092145329) },
+ { FRAC_CONST(0.023118277946808), FRAC_CONST(0.058067161328707) },
+ { FRAC_CONST(0.022403963789609), FRAC_CONST(0.058346485811177) },
+ { FRAC_CONST(0.021686275677870), FRAC_CONST(0.058617023527499) },
+ { FRAC_CONST(0.020965321692783), FRAC_CONST(0.058878733735689) },
+ { FRAC_CONST(0.020241210407366), FRAC_CONST(0.059131577023150) },
+ { FRAC_CONST(0.019514050870114), FRAC_CONST(0.059375515312615) },
+ { FRAC_CONST(0.018783952588580), FRAC_CONST(0.059610511867874) },
+ { FRAC_CONST(0.018051025512878), FRAC_CONST(0.059836531299311) },
+ { FRAC_CONST(0.017315380019131), FRAC_CONST(0.060053539569230) },
+ { FRAC_CONST(0.016577126892844), FRAC_CONST(0.060261503996984) },
+ { FRAC_CONST(0.015836377312223), FRAC_CONST(0.060460393263896) },
+ { FRAC_CONST(0.015093242831429), FRAC_CONST(0.060650177417972) },
+ { FRAC_CONST(0.014347835363782), FRAC_CONST(0.060830827878419) },
+ { FRAC_CONST(0.013600267164905), FRAC_CONST(0.061002317439940) },
+ { FRAC_CONST(0.012850650815819), FRAC_CONST(0.061164620276839) },
+ { FRAC_CONST(0.012099099205988), FRAC_CONST(0.061317711946905) },
+ { FRAC_CONST(0.011345725516320), FRAC_CONST(0.061461569395097) },
+ { FRAC_CONST(0.010590643202123), FRAC_CONST(0.061596170957011) },
+ { FRAC_CONST(0.009833965976015), FRAC_CONST(0.061721496362147) },
+ { FRAC_CONST(0.009075807790803), FRAC_CONST(0.061837526736961) },
+ { FRAC_CONST(0.008316282822321), FRAC_CONST(0.061944244607705) },
+ { FRAC_CONST(0.007555505452236), FRAC_CONST(0.062041633903059) },
+ { FRAC_CONST(0.006793590250821), FRAC_CONST(0.062129679956555) },
+ { FRAC_CONST(0.006030651959703), FRAC_CONST(0.062208369508780) },
+ { FRAC_CONST(0.005266805474583), FRAC_CONST(0.062277690709378) },
+ { FRAC_CONST(0.004502165827931), FRAC_CONST(0.062337633118830) },
+ { FRAC_CONST(0.003736848171665), FRAC_CONST(0.062388187710030) },
+ { FRAC_CONST(0.002970967759810), FRAC_CONST(0.062429346869643) },
+ { FRAC_CONST(0.002204639931138), FRAC_CONST(0.062461104399250) },
+ { FRAC_CONST(0.001437980091802), FRAC_CONST(0.062483455516285) },
+ { FRAC_CONST(0.000671103697954), FRAC_CONST(0.062496396854751) }
+ };
+
+ /* 16 (N/4) complex twiddle factors */
+ ALIGN static const complex_t mdct_tab_64[] = {
+ { FRAC_CONST(0.176763384336599), FRAC_CONST(0.002169321984356) },
+ { FRAC_CONST(0.175699589589310), FRAC_CONST(0.019484717553714) },
+ { FRAC_CONST(0.172943711747111), FRAC_CONST(0.036612464641599) },
+ { FRAC_CONST(0.168522291420137), FRAC_CONST(0.053387613680577) },
+ { FRAC_CONST(0.162477909303132), FRAC_CONST(0.069648610815172) },
+ { FRAC_CONST(0.154868776100077), FRAC_CONST(0.085238853753814) },
+ { FRAC_CONST(0.145768171923295), FRAC_CONST(0.100008199934509) },
+ { FRAC_CONST(0.135263740565902), FRAC_CONST(0.113814412479792) },
+ { FRAC_CONST(0.123456645444178), FRAC_CONST(0.126524530015608) },
+ { FRAC_CONST(0.110460595338559), FRAC_CONST(0.138016147162030) },
+ { FRAC_CONST(0.096400749315926), FRAC_CONST(0.148178593363981) },
+ { FRAC_CONST(0.081412511379371), FRAC_CONST(0.156913998709178) },
+ { FRAC_CONST(0.065640226453626), FRAC_CONST(0.164138236468888) },
+ { FRAC_CONST(0.049235790264535), FRAC_CONST(0.169781733284316) },
+ { FRAC_CONST(0.032357186500177), FRAC_CONST(0.173790139196080) },
+ { FRAC_CONST(0.015166965341583), FRAC_CONST(0.176124851064031) }
+ };
+#endif // SSR_DEC
+
+#endif // FIXED_POINT
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/audio_codec/libfaad/mp4.c b/audio_codec/libfaad/mp4.c
new file mode 100644
index 0000000..3b18f0f
--- a/dev/null
+++ b/audio_codec/libfaad/mp4.c
@@ -0,0 +1,307 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: mp4.c,v 1.40 2009/02/06 03:39:58 menno Exp $
+**/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include "common.h"
+#include "structs.h"
+
+
+#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
+ 0, /* 6 AAC Scalable */
+ 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
+ 0, /* 20 ER AAC scalable */
+ 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) */
+ 1, /* 29 PS*/
+ 0, /* 30 (Reserved) */
+ 0 /* 31 (Reserved) */
+};
+
+/* Table 1.6.1 */
+char NEAACDECAPI NeAACDecAudioSpecificConfig(unsigned char *pBuffer,
+ unsigned long buffer_size,
+ mp4AudioSpecificConfig *mp4ASC)
+{
+ return AudioSpecificConfig2(pBuffer, buffer_size, mp4ASC, NULL, 0);
+}
+
+int AudioSpecificConfigFromBitfile(bitfile *ld,
+ mp4AudioSpecificConfig *mp4ASC,
+ program_config *pce, uint32_t buffer_size, uint8_t short_form)
+{
+ int8_t result = 0;
+ uint32_t startpos = faad_get_processed_bits(ld);
+#ifdef SBR_DEC
+ int8_t bits_to_decode = 0;
+#endif
+
+ if (mp4ASC == NULL) {
+ return -8;
+ }
+
+ memset(mp4ASC, 0, sizeof(mp4AudioSpecificConfig));
+
+ mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(ld, 5
+ DEBUGVAR(1, 1, "parse_audio_decoder_specific_info(): ObjectTypeIndex"));
+ if (mp4ASC->objectTypeIndex == /*AOT_ESCAPE*/31) {
+ mp4ASC->objectTypeIndex = 32 + faad_getbits(ld, 6);
+ }
+ //audio_codec_print("object type %x \n", mp4ASC->objectTypeIndex);
+ mp4ASC->samplingFrequencyIndex = (uint8_t)faad_getbits(ld, 4
+ DEBUGVAR(1, 2, "parse_audio_decoder_specific_info(): SamplingFrequencyIndex"));
+ if (mp4ASC->samplingFrequencyIndex == 0x0f) {
+ faad_getbits(ld, 24);
+ }
+
+ 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) {
+ return -1;
+ }
+
+ if (mp4ASC->samplingFrequency == 0) {
+ return -2;
+ }
+
+ if (mp4ASC->channelsConfiguration > 7) {
+ 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) || (mp4ASC->objectTypeIndex == 29 && !(faad_showbits(ld, 3) & 0x03 && !(faad_showbits(ld, 9) & 0x3F)))) {
+ 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
+ if (short_form) {
+ bits_to_decode = 0;
+ } else {
+ bits_to_decode = (int8_t)(buffer_size * 8 - (startpos - 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) {
+ uint8_t tmp_OTi = (uint8_t)faad_getbits(ld, 5
+ DEBUGVAR(1, 10, "parse_audio_decoder_specific_info(): extensionAudioObjectType"));
+
+ if (tmp_OTi == 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;
+
+ /* Don't set OT to SBR until checked that it is actually there */
+ mp4ASC->objectTypeIndex = tmp_OTi;
+
+ 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;
+}
+
+int AudioSpecificConfig2(uint8_t *pBuffer,
+ uint32_t buffer_size,
+ mp4AudioSpecificConfig *mp4ASC,
+ program_config *pce,
+ uint8_t short_form)
+{
+ uint8_t ret = 0;
+ bitfile ld;
+ faad_initbits(&ld, pBuffer, buffer_size);
+ faad_byte_align(&ld);
+ ret = AudioSpecificConfigFromBitfile(&ld, mp4ASC, pce, buffer_size, short_form);
+ faad_endbits(&ld);
+ return ret;
+}
diff --git a/audio_codec/libfaad/mp4.h b/audio_codec/libfaad/mp4.h
new file mode 100644
index 0000000..70689ce
--- a/dev/null
+++ b/audio_codec/libfaad/mp4.h
@@ -0,0 +1,52 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: mp4.h,v 1.28 2009/02/05 00:51:03 menno Exp $
+**/
+
+#ifndef __MP4_H__
+#define __MP4_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "neaacdec.h"
+
+ int AudioSpecificConfig2(uint8_t *pBuffer,
+ uint32_t buffer_size,
+ mp4AudioSpecificConfig *mp4ASC,
+ program_config *pce, uint8_t short_form);
+
+ int AudioSpecificConfigFromBitfile(bitfile *ld,
+ mp4AudioSpecificConfig *mp4ASC,
+ program_config *pce, uint32_t bsize, uint8_t short_form);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/audio_codec/libfaad/ms.c b/audio_codec/libfaad/ms.c
new file mode 100644
index 0000000..7eaa4c6
--- a/dev/null
+++ b/audio_codec/libfaad/ms.c
@@ -0,0 +1,71 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: ms.c,v 1.21 2007/11/01 12:33:32 menno Exp $
+**/
+
+#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;
+ real_t tmp;
+
+ 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)) {
+ for (i = ics->swb_offset[sfb]; i < min(ics->swb_offset[sfb + 1], ics->swb_offset_max); i++) {
+ k = (group * nshort) + i;
+ tmp = l_spec[k] - r_spec[k];
+ l_spec[k] = l_spec[k] + r_spec[k];
+ r_spec[k] = tmp;
+ }
+ }
+ }
+ group++;
+ }
+ }
+ }
+}
diff --git a/audio_codec/libfaad/ms.h b/audio_codec/libfaad/ms.h
new file mode 100644
index 0000000..d37eff4
--- a/dev/null
+++ b/audio_codec/libfaad/ms.h
@@ -0,0 +1,44 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: ms.h,v 1.19 2007/11/01 12:33:32 menno Exp $
+**/
+
+#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/audio_codec/libfaad/neaacdec.h b/audio_codec/libfaad/neaacdec.h
new file mode 100644
index 0000000..d6e01d2
--- a/dev/null
+++ b/audio_codec/libfaad/neaacdec.h
@@ -0,0 +1,257 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: neaacdec.h,v 1.13 2009/01/26 23:51:15 menno Exp $
+**/
+
+#ifndef __NEAACDEC_H__
+#define __NEAACDEC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+#if 1
+ /* MACROS FOR BACKWARDS COMPATIBILITY */
+ /* structs */
+#define faacDecHandle NeAACDecHandle
+#define faacDecConfiguration NeAACDecConfiguration
+#define faacDecConfigurationPtr NeAACDecConfigurationPtr
+#define faacDecFrameInfo NeAACDecFrameInfo
+ /* functions */
+#define faacDecGetErrorMessage NeAACDecGetErrorMessage
+#define faacDecSetConfiguration NeAACDecSetConfiguration
+#define faacDecGetCurrentConfiguration NeAACDecGetCurrentConfiguration
+#define faacDecInit NeAACDecInit
+#define faacDecInit2 NeAACDecInit2
+#define faacDecInitDRM NeAACDecInitDRM
+#define faacDecPostSeekReset NeAACDecPostSeekReset
+#define faacDecOpen NeAACDecOpen
+#define faacDecClose NeAACDecClose
+#define faacDecDecode NeAACDecDecode
+#define AudioSpecificConfig NeAACDecAudioSpecificConfig
+#endif
+
+
+#ifdef _WIN32
+#pragma pack(push, 8)
+#ifndef NEAACDECAPI
+#define NEAACDECAPI __cdecl
+#endif
+#else
+#ifndef NEAACDECAPI
+#define NEAACDECAPI
+#endif
+#endif
+
+#define FAAD2_VERSION "2.7"
+
+ /* object types for AAC */
+#define MAIN 1
+#define LC 2
+#define SSR 3
+#define LTP 4
+#define HE_AAC 5
+#define ER_LC 17
+#define ER_LTP 19
+#define LD 23
+#define DRM_ER_LC 27 /* special object type for DRM */
+
+ /* header types */
+#define RAW 0
+#define ADIF 1
+#define ADTS 2
+#define LATM 3
+
+ /* SBR signalling */
+#define NO_SBR 0
+#define SBR_UPSAMPLED 1
+#define SBR_DOWNSAMPLED 2
+#define NO_SBR_UPSAMPLED 3
+
+ /* 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
+
+ /* Capabilities */
+#define LC_DEC_CAP (1<<0) /* Can decode LC */
+#define MAIN_DEC_CAP (1<<1) /* Can decode MAIN */
+#define LTP_DEC_CAP (1<<2) /* Can decode LTP */
+#define LD_DEC_CAP (1<<3) /* Can decode LD */
+#define ERROR_RESILIENCE_CAP (1<<4) /* Can decode ER */
+#define FIXED_POINT_CAP (1<<5) /* Fixed point */
+
+ /* Channel definitions */
+#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)
+
+ /* 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
+
+
+ /* A decode call can eat up to FAAD_MIN_STREAMSIZE bytes per decoded channel,
+ so at least so much bytes per channel should be available in this stream */
+#define FAAD_MIN_STREAMSIZE 768 /* 6144 bits/channel */
+
+
+ typedef void *NeAACDecHandle;
+
+ typedef struct mp4AudioSpecificConfig {
+ /* Audio Specific Info */
+ unsigned char objectTypeIndex;
+ unsigned char samplingFrequencyIndex;
+ unsigned long samplingFrequency;
+ unsigned char channelsConfiguration;
+
+ /* GA Specific Info */
+ unsigned char frameLengthFlag;
+ unsigned char dependsOnCoreCoder;
+ unsigned short coreCoderDelay;
+ unsigned char extensionFlag;
+ unsigned char aacSectionDataResilienceFlag;
+ unsigned char aacScalefactorDataResilienceFlag;
+ unsigned char aacSpectralDataResilienceFlag;
+ unsigned char epConfig;
+
+ char sbr_present_flag;
+ char forceUpSampling;
+ char downSampledSBR;
+ } mp4AudioSpecificConfig;
+
+ typedef struct NeAACDecConfiguration {
+ unsigned char defObjectType;
+ unsigned long defSampleRate;
+ unsigned char outputFormat;
+ unsigned char downMatrix;
+ unsigned char useOldADTSFormat;
+ unsigned char dontUpSampleImplicitSBR;
+ } NeAACDecConfiguration, *NeAACDecConfigurationPtr;
+
+ typedef struct NeAACDecFrameInfo {
+ unsigned long bytesconsumed;
+ unsigned long samples;
+ unsigned char channels;
+ unsigned char error;
+ unsigned long samplerate;
+
+ /* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */
+ unsigned char sbr;
+
+ /* MPEG-4 ObjectType */
+ unsigned char object_type;
+
+ /* AAC header type; MP4 will be signalled as RAW also */
+ unsigned char header_type;
+
+ /* multichannel configuration */
+ unsigned char num_front_channels;
+ unsigned char num_side_channels;
+ unsigned char num_back_channels;
+ unsigned char num_lfe_channels;
+ unsigned char channel_position[64];
+
+ /* PS: 0: off, 1: on */
+ unsigned char ps;
+ } NeAACDecFrameInfo;
+
+ char* NEAACDECAPI NeAACDecGetErrorMessage(unsigned char errcode);
+
+ unsigned long NEAACDECAPI NeAACDecGetCapabilities(void);
+
+ NeAACDecHandle NEAACDECAPI NeAACDecOpen(void);
+
+ NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder);
+
+ unsigned char NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder,
+ NeAACDecConfigurationPtr config);
+
+ /* Init the library based on info from the AAC file (ADTS/ADIF) */
+ long NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder,
+ unsigned char *buffer,
+ unsigned long buffer_size,
+ unsigned long *samplerate,
+ unsigned char *channels,
+ int is_latm_external,
+ int *skipbytes);
+
+ /* Init the library using a DecoderSpecificInfo */
+ int NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder,
+ unsigned char *pBuffer,
+ unsigned long SizeOfDecoderSpecificInfo,
+ unsigned long *samplerate,
+ unsigned char *channels);
+
+ /* Init the library for DRM */
+ char NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, unsigned long samplerate,
+ unsigned char channels);
+
+ void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, long frame);
+
+ void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder);
+
+ void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder,
+ NeAACDecFrameInfo *hInfo,
+ unsigned char *buffer,
+ unsigned long buffer_size);
+
+ void* NEAACDECAPI NeAACDecDecode2(NeAACDecHandle hDecoder,
+ NeAACDecFrameInfo *hInfo,
+ unsigned char *buffer,
+ unsigned long buffer_size,
+ void **sample_buffer,
+ unsigned long sample_buffer_size);
+
+ char NEAACDECAPI NeAACDecAudioSpecificConfig(unsigned char *pBuffer,
+ unsigned long buffer_size,
+ mp4AudioSpecificConfig *mp4ASC);
+
+#ifdef _WIN32
+#pragma pack(pop)
+#endif
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
diff --git a/audio_codec/libfaad/output.c b/audio_codec/libfaad/output.c
new file mode 100644
index 0000000..dc7c37d
--- a/dev/null
+++ b/audio_codec/libfaad/output.c
@@ -0,0 +1,583 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: output.c,v 1.47 2009/01/26 23:51:15 menno Exp $
+**/
+
+#include "common.h"
+#include "structs.h"
+
+#include "output.h"
+
+#ifndef FIXED_POINT
+
+
+#define FLOAT_SCALE (1.0f/(1<<15))
+
+#define DM_MUL 1//REAL_CONST(0.3203772410170407) // 1/(1+sqrt(2) + 1/sqrt(2))
+#define RSQRT2 REAL_CONST(0.7071067811865475244) // 1/sqrt(2)
+
+/*
+
+There are two types of down-mix to stereo:
+1. Lt/Rt downmix:
+Lt = L + (0.707*C) - (0.707*Ls) - (0.707*Rs)
+Rt = R + (0.707*C) + (0.707*Ls) + (0.707*Rs)
+2. Lo/Ro downmix:
+Lo = L + (0.707*C) + (0.707*Ls)
+Ro = R + (0.707*C) + (0.707*Rs)
+
+*/
+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];
+ }
+
+ // for multi-channel( > 2ch ) downmix to 2ch case
+#if 0 //LoRo downmix mode
+ 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);
+ }
+#else //LtRt downmix mode
+ if (channel == 0) {
+ return DM_MUL * (input[internal_channel[1]][sample] +
+ input[internal_channel[0]][sample] * RSQRT2 -
+ input[internal_channel[3]][sample] * RSQRT2 - input[internal_channel[4]][sample] * RSQRT2);
+ } else {
+ return DM_MUL * (input[internal_channel[2]][sample] +
+ input[internal_channel[0]][sample] * RSQRT2 +
+ input[internal_channel[3]][sample] * RSQRT2 +
+ input[internal_channel[4]][sample] * RSQRT2);
+ }
+#endif
+}
+
+#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(NeAACDecStruct *hDecoder, real_t **input,
+ uint8_t channels, uint16_t frame_len,
+ int16_t **sample_buffer)
+{
+ uint8_t ch, ch1;
+ uint16_t i;
+ uint16_t k;
+
+ 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:
+#if 0
+ 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);
+ }
+ }
+#endif
+ if (channels == 6) {
+ for (ch = 0; ch < channels; ch += 6) {
+ for (i = 0; i < frame_len; i++) {
+ real_t inp[6];
+ real_t Lt, Rt;
+ for (k = 0; k < 6; k++) {
+ inp[k] = get_sample(input, ch + k, i, hDecoder->downMatrix, hDecoder->internal_channel);
+
+ CLIP(inp[k], 32767.0f, -32768.0f);
+ }
+
+ Lt = 1.0 * inp[1] + 0.707 * inp[0] - 0.707 * inp[3] - 0.707 * inp[4];
+ Rt = 1.0 * inp[2] + 0.707 * inp[0] + 0.707 * inp[3] - 0.707 * inp[4];
+
+ (*sample_buffer)[(i * channels) + ch] = (int16_t)lrintf(Lt);
+ (*sample_buffer)[(i * channels) + ch + 1] = (int16_t)lrintf(Rt);
+ }
+ }
+ } else if (4 == channels) {
+ for (ch = 0; ch < channels; ch++) {
+ if (ch % 2 != 0) {
+ continue;
+ }
+ 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);
+ if (ch > 0) {
+ ch = 1;
+ }
+
+ (*sample_buffer)[(i * channels) + ch] = (int16_t)lrintf(inp);
+ }
+ }
+ } else {
+ 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(NeAACDecStruct *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(NeAACDecStruct *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(NeAACDecStruct *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(NeAACDecStruct *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(NeAACDecStruct *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(NeAACDecStruct *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/audio_codec/libfaad/output.h b/audio_codec/libfaad/output.h
new file mode 100644
index 0000000..b4e2a63
--- a/dev/null
+++ b/audio_codec/libfaad/output.h
@@ -0,0 +1,48 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: output.h,v 1.26 2009/01/26 23:51:15 menno Exp $
+**/
+
+#ifndef __OUTPUT_H__
+#define __OUTPUT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ void* output_to_PCM(NeAACDecStruct *hDecoder,
+ real_t **input,
+ void *samplebuffer,
+ uint8_t channels,
+ uint16_t frame_len,
+ uint8_t format);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/audio_codec/libfaad/pns.c b/audio_codec/libfaad/pns.c
new file mode 100644
index 0000000..0aa0bd7
--- a/dev/null
+++ b/audio_codec/libfaad/pns.c
@@ -0,0 +1,273 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: pns.c,v 1.38 2007/11/01 12:33:32 menno Exp $
+**/
+
+#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,
+ /* RNG states */ uint32_t *__r1, uint32_t *__r2);
+
+
+#ifdef FIXED_POINT
+
+#define DIV(A, B) (((int64_t)A << REAL_BITS)/B)
+
+#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% !!!! */
+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 const 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
+ <size> 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,
+ /* RNG states */ uint32_t *__r1, uint32_t *__r2)
+{
+#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)ne_rng(__r1, __r2);
+ 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)ne_rng(__r1, __r2);
+ 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(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,
+ /* RNG states */ uint32_t *__r1, uint32_t *__r2)
+{
+ 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 = min(ics_left->swb_offset[sfb + 1], ics_left->swb_offset_max) - offs;
+
+ /* Generate random vector */
+ gen_rand_vector(&spec_left[(group * nshort) + offs],
+ ics_left->scale_factors[g][sfb], size, sub, __r1, __r2);
+ }
+
+ /* 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 = min(ics_right->swb_offset[sfb + 1], ics_right->swb_offset_max) - 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 = min(ics_right->swb_offset[sfb + 1], ics_right->swb_offset_max) - offs;
+
+ /* Generate random vector */
+ gen_rand_vector(&spec_right[(group * nshort) + offs],
+ ics_right->scale_factors[g][sfb], size, sub, __r1, __r2);
+ }
+ }
+ }
+ } /* sfb */
+ group++;
+ } /* b */
+ } /* g */
+}
diff --git a/audio_codec/libfaad/pns.h b/audio_codec/libfaad/pns.h
new file mode 100644
index 0000000..540de60
--- a/dev/null
+++ b/audio_codec/libfaad/pns.h
@@ -0,0 +1,58 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: pns.h,v 1.27 2007/11/01 12:33:33 menno Exp $
+**/
+
+#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,
+ /* RNG states */ uint32_t *__r1, uint32_t *__r2);
+
+ 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/audio_codec/libfaad/ps_dec.c b/audio_codec/libfaad/ps_dec.c
new file mode 100644
index 0000000..2cd2e5e
--- a/dev/null
+++ b/audio_codec/libfaad/ps_dec.c
@@ -0,0 +1,1905 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: ps_dec.c,v 1.16 2009/01/26 22:32:31 menno Exp $
+**/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include "common.h"
+
+#ifdef PS_DEC
+
+#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
+};
+
+/* type definitions */
+typedef struct {
+ uint8_t frame_len;
+ uint8_t resolution20[3];
+ uint8_t resolution34[5];
+
+ qmf_t *work;
+ qmf_t **buffer;
+ qmf_t **temp;
+} hyb_info;
+
+/* static function declarations */
+static void ps_data_decode(ps_info *ps);
+static hyb_info *hybrid_init(uint8_t numTimeSlotsRate);
+static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter,
+ qmf_t *buffer, qmf_t **X_hybrid);
+static void INLINE 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);
+static void hybrid_analysis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32],
+ uint8_t use34, uint8_t numTimeSlotsRate);
+static void hybrid_synthesis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32],
+ uint8_t use34, uint8_t numTimeSlotsRate);
+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 and_modulo);
+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[38][64], qmf_t X_right[38][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[38][64], qmf_t X_right[38][64],
+ qmf_t X_hybrid_left[32][32], qmf_t X_hybrid_right[32][32]);
+
+/* */
+
+
+static hyb_info *hybrid_init(uint8_t numTimeSlotsRate)
+{
+ uint8_t i;
+
+ hyb_info *hyb = (hyb_info*)faad_malloc(sizeof(hyb_info));
+
+ 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 = numTimeSlotsRate;
+
+ hyb->work = (qmf_t*)faad_malloc((hyb->frame_len + 12) * sizeof(qmf_t));
+ memset(hyb->work, 0, (hyb->frame_len + 12) * sizeof(qmf_t));
+
+ hyb->buffer = (qmf_t**)faad_malloc(5 * sizeof(qmf_t*));
+ for (i = 0; i < 5; i++) {
+ hyb->buffer[i] = (qmf_t*)faad_malloc(hyb->frame_len * sizeof(qmf_t));
+ memset(hyb->buffer[i], 0, hyb->frame_len * sizeof(qmf_t));
+ }
+
+ hyb->temp = (qmf_t**)faad_malloc(hyb->frame_len * sizeof(qmf_t*));
+ for (i = 0; i < hyb->frame_len; i++) {
+ hyb->temp[i] = (qmf_t*)faad_malloc(12 /*max*/ * sizeof(qmf_t));
+ }
+
+ return hyb;
+}
+
+static void hybrid_free(hyb_info *hyb)
+{
+ uint8_t i;
+
+ if (!hyb) {
+ return;
+ }
+
+ if (hyb->work) {
+ faad_free(hyb->work);
+ }
+
+ for (i = 0; i < 5; i++) {
+ if (hyb->buffer[i]) {
+ faad_free(hyb->buffer[i]);
+ }
+ }
+ if (hyb->buffer) {
+ faad_free(hyb->buffer);
+ }
+
+ for (i = 0; i < hyb->frame_len; i++) {
+ if (hyb->temp[i]) {
+ faad_free(hyb->temp[i]);
+ }
+ }
+ if (hyb->temp) {
+ faad_free(hyb->temp);
+ }
+
+ faad_free(hyb);
+}
+
+/* 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)
+{
+ uint8_t i;
+
+ 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)
+{
+ uint8_t i;
+ real_t input_re1[2], input_re2[2], input_im1[2], input_im2[2];
+
+ 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 void INLINE 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)
+{
+ uint8_t i, n;
+ real_t input_re1[4], input_re2[4], input_im1[4], input_im2[4];
+ real_t x[4];
+
+ 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 void INLINE 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)
+{
+ 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];
+
+ 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 numTimeSlotsRate)
+{
+ 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 < numTimeSlotsRate; 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 numTimeSlotsRate)
+{
+ 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 and_modulo)
+{
+ int8_t i;
+
+ if (enable == 1) {
+ if (dt_flag == 0) {
+ /* delta coded in frequency direction */
+ index[0] = 0 + index[0];
+ index[0] &= and_modulo;
+
+ for (i = 1; i < nr_par; i++) {
+ index[i] = index[i - 1] + index[i];
+ index[i] &= and_modulo;
+ }
+ } else {
+ /* delta coded in time direction */
+ for (i = 0; i < nr_par; i++) {
+ index[i] = index_prev[i * stride] + index[i];
+ index[i] &= and_modulo;
+ }
+ }
+ } 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, 7);
+
+ /* 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, 7);
+ }
+
+ /* 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 * ps->numTimeSlotsRate) / ps->num_env;
+ }
+ ps->border_position[ps->num_env] = ps->numTimeSlotsRate;
+ } else {
+ ps->border_position[0] = 0;
+
+ if (ps->border_position[ps->num_env] < ps->numTimeSlotsRate) {
+ 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];
+ }
+ ps->num_env++;
+ ps->border_position[ps->num_env] = ps->numTimeSlotsRate;
+ }
+
+ for (env = 1; env < ps->num_env; env++) {
+ int8_t thr = ps->numTimeSlotsRate - (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[38][64], qmf_t X_right[38][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;
+ uint8_t sb, maxsb;
+ const complex_t *Phi_Fract_SubQmf;
+ uint8_t temp_delay_ser[NO_ALLPASS_LINKS];
+ real_t P_SmoothPeakDecayDiffNrg, nrg;
+ real_t P[32][34];
+ real_t G_TransientRatio[32][34] = {{0}};
+ complex_t inputLeft;
+
+
+ /* 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 real_t magnitude_c(complex_t c)
+{
+#ifdef FIXED_POINT
+#define ps_abs(A) (((A) > 0) ? (A) : (-(A)))
+#define ALPHA FRAC_CONST(0.948059448969)
+#define BETA FRAC_CONST(0.392699081699)
+
+ real_t abs_inphase = ps_abs(RE(c));
+ real_t abs_quadrature = ps_abs(IM(c));
+
+ if (abs_inphase > abs_quadrature) {
+ return MUL_F(abs_inphase, ALPHA) + MUL_F(abs_quadrature, BETA);
+ } else {
+ return MUL_F(abs_quadrature, ALPHA) + MUL_F(abs_inphase, BETA);
+ }
+#else
+ return sqrt(RE(c) * RE(c) + IM(c) * IM(c));
+#endif
+}
+
+static void ps_mix_phase(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][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, h12, h21, h22;
+ complex_t H11, H12, H21, H22;
+ complex_t deltaH11, deltaH12, deltaH21, deltaH22;
+ 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 xy, pq, xypq;
+
+ /* 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)) = y/sqrt((x*x) + (y*y))
+ // sin(atan2(x,y)) = x/sqrt((x*x) + (y*y))
+ // cos(atan2(x,y)-atan2(p,q)) = (y*q + x*p) / ( sqrt((x*x) + (y*y)) * sqrt((p*p) + (q*q)) );
+ // sin(atan2(x,y)-atan2(p,q)) = (x*q - y*p) / ( sqrt((x*x) + (y*y)) * sqrt((p*p) + (q*q)) );
+
+ xy = magnitude_c(tempRight);
+ pq = magnitude_c(tempLeft);
+
+ if (xy != 0) {
+ RE(phaseLeft) = DIV_R(RE(tempRight), xy);
+ IM(phaseLeft) = DIV_R(IM(tempRight), xy);
+ } else {
+ RE(phaseLeft) = 0;
+ IM(phaseLeft) = 0;
+ }
+
+ xypq = MUL_R(xy, pq);
+
+ if (xypq != 0) {
+ real_t tmp1 = MUL_R(RE(tempRight), RE(tempLeft)) + MUL_R(IM(tempRight), IM(tempLeft));
+ real_t tmp2 = MUL_R(IM(tempRight), RE(tempLeft)) - MUL_R(RE(tempRight), IM(tempLeft));
+
+ RE(phaseRight) = DIV_R(tmp1, xypq);
+ IM(phaseRight) = DIV_R(tmp2, xypq);
+ } else {
+ RE(phaseRight) = 0;
+ IM(phaseRight) = 0;
+ }
+
+#endif
+
+ /* MUL_F(COEF, REAL) = COEF */
+ IM(h11) = MUL_R(RE(h11), IM(phaseLeft));
+ IM(h12) = MUL_R(RE(h12), IM(phaseRight));
+ IM(h21) = MUL_R(RE(h21), IM(phaseLeft));
+ IM(h22) = MUL_R(RE(h22), IM(phaseRight));
+
+ RE(h11) = MUL_R(RE(h11), RE(phaseLeft));
+ RE(h12) = MUL_R(RE(h12), RE(phaseRight));
+ RE(h21) = MUL_R(RE(h21), RE(phaseLeft));
+ RE(h22) = MUL_R(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_free(ps_info *ps)
+{
+ /* free hybrid filterbank structures */
+ hybrid_free(ps->hyb);
+
+ faad_free(ps);
+}
+
+ps_info *ps_init(uint8_t sr_index, uint8_t numTimeSlotsRate)
+{
+ uint8_t i;
+ uint8_t short_delay_band;
+
+ ps_info *ps = (ps_info*)faad_malloc(sizeof(ps_info));
+ memset(ps, 0, sizeof(ps_info));
+
+ ps->hyb = hybrid_init(numTimeSlotsRate);
+ ps->numTimeSlotsRate = numTimeSlotsRate;
+
+ 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;
+ }
+
+ return ps;
+}
+
+/* main Parametric Stereo decoding function */
+uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64])
+{
+ qmf_t X_hybrid_left[32][32] = {{0}};
+ qmf_t X_hybrid_right[32][32] = {{0}};
+
+ /* 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((hyb_info*)ps->hyb, X_left, X_hybrid_left,
+ ps->use34hybrid_bands, ps->numTimeSlotsRate);
+
+ /* 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((hyb_info*)ps->hyb, X_left, X_hybrid_left,
+ ps->use34hybrid_bands, ps->numTimeSlotsRate);
+
+ hybrid_synthesis((hyb_info*)ps->hyb, X_right, X_hybrid_right,
+ ps->use34hybrid_bands, ps->numTimeSlotsRate);
+
+ return 0;
+}
+
+#endif
+
diff --git a/audio_codec/libfaad/ps_dec.h b/audio_codec/libfaad/ps_dec.h
new file mode 100644
index 0000000..9b112f3
--- a/dev/null
+++ b/audio_codec/libfaad/ps_dec.h
@@ -0,0 +1,151 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: ps_dec.h,v 1.13 2009/01/26 22:32:31 menno Exp $
+**/
+
+#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
+
+ 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 */
+ void *hyb;
+ uint8_t use34hybrid_bands;
+ uint8_t numTimeSlotsRate;
+
+ /**/
+ 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 */
+ ps_info *ps_init(uint8_t sr_index, uint8_t numTimeSlotsRate);
+ void ps_free(ps_info *ps);
+
+ uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64]);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/audio_codec/libfaad/ps_syntax.c b/audio_codec/libfaad/ps_syntax.c
new file mode 100644
index 0000000..23ce7a9
--- a/dev/null
+++ b/audio_codec/libfaad/ps_syntax.c
@@ -0,0 +1,532 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: ps_syntax.c,v 1.11 2007/11/01 12:33:33 menno Exp $
+**/
+
+#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, /*2*/ -29 }, /* index 4: 4 bits: 000x */
+ { /*6*/ -25, 6 }, /* index 5: 4 bits: 001x */
+ { /*4*/ -27, /*3*/ -28 } /* index 6: 5 bits: 0011x */
+};
+
+/* 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) {
+ ps->ps_data_available = 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")) + 1;
+ }
+ }
+
+ 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);
+
+ 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/audio_codec/libfaad/ps_tables.h b/audio_codec/libfaad/ps_tables.h
new file mode 100644
index 0000000..69326f7
--- a/dev/null
+++ b/audio_codec/libfaad/ps_tables.h
@@ -0,0 +1,547 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: ps_tables.h,v 1.8 2007/11/01 12:33:33 menno Exp $
+**/
+
+#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/audio_codec/libfaad/pulse.c b/audio_codec/libfaad/pulse.c
new file mode 100644
index 0000000..feefe3b
--- a/dev/null
+++ b/audio_codec/libfaad/pulse.c
@@ -0,0 +1,59 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: pulse.c,v 1.21 2007/11/01 12:33:34 menno Exp $
+**/
+#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 = min(ics->swb_offset[pul->pulse_start_sfb], ics->swb_offset_max);
+
+ 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/audio_codec/libfaad/pulse.h b/audio_codec/libfaad/pulse.h
new file mode 100644
index 0000000..e74409c
--- a/dev/null
+++ b/audio_codec/libfaad/pulse.h
@@ -0,0 +1,43 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: pulse.h,v 1.20 2007/11/01 12:33:34 menno Exp $
+**/
+
+#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/audio_codec/libfaad/rvlc.c b/audio_codec/libfaad/rvlc.c
new file mode 100644
index 0000000..156bc00
--- a/dev/null
+++ b/audio_codec/libfaad/rvlc.c
@@ -0,0 +1,524 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: rvlc.c,v 1.21 2007/11/01 12:33:34 menno Exp $
+**/
+
+/* 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 <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+
+#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/audio_codec/libfaad/rvlc.h b/audio_codec/libfaad/rvlc.h
new file mode 100644
index 0000000..3ed0e9c
--- a/dev/null
+++ b/audio_codec/libfaad/rvlc.h
@@ -0,0 +1,55 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: rvlc.h,v 1.17 2007/11/01 12:33:34 menno Exp $
+**/
+
+#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/audio_codec/libfaad/sbr_dct.c b/audio_codec/libfaad/sbr_dct.c
new file mode 100644
index 0000000..1f1ca7a
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_dct.c
@@ -0,0 +1,2267 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_dct.c,v 1.20 2007/11/01 12:33:34 menno Exp $
+**/
+
+
+/* Most of the DCT/DST codes here are generated using Spiral which is GPL
+ * For more info see: http://www.spiral.net/
+ */
+
+#include "common.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;
+}
+
+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);
+}
+
+#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
+
+
+#define n 32
+#define log2n 5
+
+// w_array_real[i] = cos(2*M_PI*i/32)
+static const real_t w_array_real[] = {
+ FRAC_CONST(1.000000000000000), FRAC_CONST(0.980785279337272),
+ FRAC_CONST(0.923879528329380), FRAC_CONST(0.831469603195765),
+ FRAC_CONST(0.707106765732237), FRAC_CONST(0.555570210304169),
+ FRAC_CONST(0.382683402077046), FRAC_CONST(0.195090284503576),
+ FRAC_CONST(0.000000000000000), FRAC_CONST(-0.195090370246552),
+ FRAC_CONST(-0.382683482845162), FRAC_CONST(-0.555570282993553),
+ FRAC_CONST(-0.707106827549476), FRAC_CONST(-0.831469651765257),
+ FRAC_CONST(-0.923879561784627), FRAC_CONST(-0.980785296392607)
+};
+
+// w_array_imag[i] = sin(-2*M_PI*i/32)
+static const real_t w_array_imag[] = {
+ FRAC_CONST(0.000000000000000), FRAC_CONST(-0.195090327375064),
+ FRAC_CONST(-0.382683442461104), FRAC_CONST(-0.555570246648862),
+ FRAC_CONST(-0.707106796640858), FRAC_CONST(-0.831469627480512),
+ FRAC_CONST(-0.923879545057005), FRAC_CONST(-0.980785287864940),
+ FRAC_CONST(-1.000000000000000), FRAC_CONST(-0.980785270809601),
+ FRAC_CONST(-0.923879511601754), FRAC_CONST(-0.831469578911016),
+ FRAC_CONST(-0.707106734823616), FRAC_CONST(-0.555570173959476),
+ FRAC_CONST(-0.382683361692986), FRAC_CONST(-0.195090241632088)
+};
+
+// FFT decimation in frequency
+// 4*16*2+16=128+16=144 multiplications
+// 6*16*2+10*8+4*16*2=192+80+128=400 additions
+static void fft_dif(real_t * Real, real_t * Imag)
+{
+ real_t w_real, w_imag; // For faster access
+ real_t point1_real, point1_imag, point2_real, point2_imag; // For faster access
+ uint32_t j, i, i2, w_index; // Counters
+
+ // First 2 stages of 32 point FFT decimation in frequency
+ // 4*16*2=64*2=128 multiplications
+ // 6*16*2=96*2=192 additions
+ // Stage 1 of 32 point FFT decimation in frequency
+ for (i = 0; i < 16; i++) {
+ point1_real = Real[i];
+ point1_imag = Imag[i];
+ i2 = i + 16;
+ point2_real = Real[i2];
+ point2_imag = Imag[i2];
+
+ w_real = w_array_real[i];
+ w_imag = w_array_imag[i];
+
+ // temp1 = x[i] - x[i2]
+ point1_real -= point2_real;
+ point1_imag -= point2_imag;
+
+ // x[i1] = x[i] + x[i2]
+ Real[i] += point2_real;
+ Imag[i] += point2_imag;
+
+ // x[i2] = (x[i] - x[i2]) * w
+ Real[i2] = (MUL_F(point1_real, w_real) - MUL_F(point1_imag, w_imag));
+ Imag[i2] = (MUL_F(point1_real, w_imag) + MUL_F(point1_imag, w_real));
+ }
+ // Stage 2 of 32 point FFT decimation in frequency
+ for (j = 0, w_index = 0; j < 8; j++, w_index += 2) {
+ w_real = w_array_real[w_index];
+ w_imag = w_array_imag[w_index];
+
+ i = j;
+ point1_real = Real[i];
+ point1_imag = Imag[i];
+ i2 = i + 8;
+ point2_real = Real[i2];
+ point2_imag = Imag[i2];
+
+ // temp1 = x[i] - x[i2]
+ point1_real -= point2_real;
+ point1_imag -= point2_imag;
+
+ // x[i1] = x[i] + x[i2]
+ Real[i] += point2_real;
+ Imag[i] += point2_imag;
+
+ // x[i2] = (x[i] - x[i2]) * w
+ Real[i2] = (MUL_F(point1_real, w_real) - MUL_F(point1_imag, w_imag));
+ Imag[i2] = (MUL_F(point1_real, w_imag) + MUL_F(point1_imag, w_real));
+
+ i = j + 16;
+ point1_real = Real[i];
+ point1_imag = Imag[i];
+ i2 = i + 8;
+ point2_real = Real[i2];
+ point2_imag = Imag[i2];
+
+ // temp1 = x[i] - x[i2]
+ point1_real -= point2_real;
+ point1_imag -= point2_imag;
+
+ // x[i1] = x[i] + x[i2]
+ Real[i] += point2_real;
+ Imag[i] += point2_imag;
+
+ // x[i2] = (x[i] - x[i2]) * w
+ Real[i2] = (MUL_F(point1_real, w_real) - MUL_F(point1_imag, w_imag));
+ Imag[i2] = (MUL_F(point1_real, w_imag) + MUL_F(point1_imag, w_real));
+ }
+
+ // Stage 3 of 32 point FFT decimation in frequency
+ // 2*4*2=16 multiplications
+ // 4*4*2+6*4*2=10*8=80 additions
+ for (i = 0; i < n; i += 8) {
+ i2 = i + 4;
+ point1_real = Real[i];
+ point1_imag = Imag[i];
+
+ point2_real = Real[i2];
+ point2_imag = Imag[i2];
+
+ // out[i1] = point1 + point2
+ Real[i] += point2_real;
+ Imag[i] += point2_imag;
+
+ // out[i2] = point1 - point2
+ Real[i2] = point1_real - point2_real;
+ Imag[i2] = point1_imag - point2_imag;
+ }
+ w_real = w_array_real[4]; // = sqrt(2)/2
+ // w_imag = -w_real; // = w_array_imag[4]; // = -sqrt(2)/2
+ for (i = 1; i < n; i += 8) {
+ i2 = i + 4;
+ point1_real = Real[i];
+ point1_imag = Imag[i];
+
+ point2_real = Real[i2];
+ point2_imag = Imag[i2];
+
+ // temp1 = x[i] - x[i2]
+ point1_real -= point2_real;
+ point1_imag -= point2_imag;
+
+ // x[i1] = x[i] + x[i2]
+ Real[i] += point2_real;
+ Imag[i] += point2_imag;
+
+ // x[i2] = (x[i] - x[i2]) * w
+ Real[i2] = MUL_F(point1_real + point1_imag, w_real);
+ Imag[i2] = MUL_F(point1_imag - point1_real, w_real);
+ }
+ for (i = 2; i < n; i += 8) {
+ i2 = i + 4;
+ point1_real = Real[i];
+ point1_imag = Imag[i];
+
+ point2_real = Real[i2];
+ point2_imag = Imag[i2];
+
+ // x[i] = x[i] + x[i2]
+ Real[i] += point2_real;
+ Imag[i] += point2_imag;
+
+ // x[i2] = (x[i] - x[i2]) * (-i)
+ Real[i2] = point1_imag - point2_imag;
+ Imag[i2] = point2_real - point1_real;
+ }
+ w_real = w_array_real[12]; // = -sqrt(2)/2
+ // w_imag = w_real; // = w_array_imag[12]; // = -sqrt(2)/2
+ for (i = 3; i < n; i += 8) {
+ i2 = i + 4;
+ point1_real = Real[i];
+ point1_imag = Imag[i];
+
+ point2_real = Real[i2];
+ point2_imag = Imag[i2];
+
+ // temp1 = x[i] - x[i2]
+ point1_real -= point2_real;
+ point1_imag -= point2_imag;
+
+ // x[i1] = x[i] + x[i2]
+ Real[i] += point2_real;
+ Imag[i] += point2_imag;
+
+ // x[i2] = (x[i] - x[i2]) * w
+ Real[i2] = MUL_F(point1_real - point1_imag, w_real);
+ Imag[i2] = MUL_F(point1_real + point1_imag, w_real);
+ }
+
+
+ // Stage 4 of 32 point FFT decimation in frequency (no multiplications)
+ // 16*4=64 additions
+ for (i = 0; i < n; i += 4) {
+ i2 = i + 2;
+ point1_real = Real[i];
+ point1_imag = Imag[i];
+
+ point2_real = Real[i2];
+ point2_imag = Imag[i2];
+
+ // x[i1] = x[i] + x[i2]
+ Real[i] += point2_real;
+ Imag[i] += point2_imag;
+
+ // x[i2] = x[i] - x[i2]
+ Real[i2] = point1_real - point2_real;
+ Imag[i2] = point1_imag - point2_imag;
+ }
+ for (i = 1; i < n; i += 4) {
+ i2 = i + 2;
+ point1_real = Real[i];
+ point1_imag = Imag[i];
+
+ point2_real = Real[i2];
+ point2_imag = Imag[i2];
+
+ // x[i] = x[i] + x[i2]
+ Real[i] += point2_real;
+ Imag[i] += point2_imag;
+
+ // x[i2] = (x[i] - x[i2]) * (-i)
+ Real[i2] = point1_imag - point2_imag;
+ Imag[i2] = point2_real - point1_real;
+ }
+
+ // Stage 5 of 32 point FFT decimation in frequency (no multiplications)
+ // 16*4=64 additions
+ for (i = 0; i < n; i += 2) {
+ i2 = i + 1;
+ point1_real = Real[i];
+ point1_imag = Imag[i];
+
+ point2_real = Real[i2];
+ point2_imag = Imag[i2];
+
+ // out[i1] = point1 + point2
+ Real[i] += point2_real;
+ Imag[i] += point2_imag;
+
+ // out[i2] = point1 - point2
+ Real[i2] = point1_real - point2_real;
+ Imag[i2] = point1_imag - point2_imag;
+ }
+
+#ifdef REORDER_IN_FFT
+ FFTReorder(Real, Imag);
+#endif // #ifdef REORDER_IN_FFT
+}
+#undef n
+#undef log2n
+
+static const real_t dct4_64_tab[] = {
+ COEF_CONST(0.999924719333649), COEF_CONST(0.998118102550507),
+ COEF_CONST(0.993906974792480), COEF_CONST(0.987301409244537),
+ COEF_CONST(0.978317379951477), COEF_CONST(0.966976463794708),
+ COEF_CONST(0.953306019306183), COEF_CONST(0.937339007854462),
+ COEF_CONST(0.919113874435425), COEF_CONST(0.898674488067627),
+ COEF_CONST(0.876070082187653), COEF_CONST(0.851355195045471),
+ COEF_CONST(0.824589252471924), COEF_CONST(0.795836925506592),
+ COEF_CONST(0.765167236328125), COEF_CONST(0.732654273509979),
+ COEF_CONST(0.698376238346100), COEF_CONST(0.662415742874146),
+ COEF_CONST(0.624859452247620), COEF_CONST(0.585797846317291),
+ COEF_CONST(0.545324981212616), COEF_CONST(0.503538429737091),
+ COEF_CONST(0.460538715124130), COEF_CONST(0.416429549455643),
+ COEF_CONST(0.371317148208618), COEF_CONST(0.325310230255127),
+ COEF_CONST(0.278519600629807), COEF_CONST(0.231058135628700),
+ COEF_CONST(0.183039888739586), COEF_CONST(0.134580686688423),
+ COEF_CONST(0.085797272622585), COEF_CONST(0.036807164549828),
+ COEF_CONST(-1.012196302413940), COEF_CONST(-1.059438824653626),
+ COEF_CONST(-1.104129195213318), COEF_CONST(-1.146159529685974),
+ COEF_CONST(-1.185428738594055), COEF_CONST(-1.221842169761658),
+ COEF_CONST(-1.255311965942383), COEF_CONST(-1.285757660865784),
+ COEF_CONST(-1.313105940818787), COEF_CONST(-1.337290763854981),
+ COEF_CONST(-1.358253836631775), COEF_CONST(-1.375944852828980),
+ COEF_CONST(-1.390321016311646), COEF_CONST(-1.401347875595093),
+ COEF_CONST(-1.408998727798462), COEF_CONST(-1.413255214691162),
+ COEF_CONST(-1.414107084274292), COEF_CONST(-1.411552190780640),
+ COEF_CONST(-1.405596733093262), COEF_CONST(-1.396255016326904),
+ COEF_CONST(-1.383549690246582), COEF_CONST(-1.367511272430420),
+ COEF_CONST(-1.348178386688232), COEF_CONST(-1.325597524642944),
+ COEF_CONST(-1.299823284149170), COEF_CONST(-1.270917654037476),
+ COEF_CONST(-1.238950133323669), COEF_CONST(-1.203998088836670),
+ COEF_CONST(-1.166145324707031), COEF_CONST(-1.125483393669128),
+ COEF_CONST(-1.082109928131104), COEF_CONST(-1.036129593849182),
+ COEF_CONST(-0.987653195858002), COEF_CONST(-0.936797380447388),
+ COEF_CONST(-0.883684754371643), COEF_CONST(-0.828443288803101),
+ COEF_CONST(-0.771206021308899), COEF_CONST(-0.712110757827759),
+ COEF_CONST(-0.651300072669983), COEF_CONST(-0.588920354843140),
+ COEF_CONST(-0.525121808052063), COEF_CONST(-0.460058242082596),
+ COEF_CONST(-0.393886327743530), COEF_CONST(-0.326765477657318),
+ COEF_CONST(-0.258857429027557), COEF_CONST(-0.190325915813446),
+ COEF_CONST(-0.121335685253143), COEF_CONST(-0.052053272724152),
+ COEF_CONST(0.017354607582092), COEF_CONST(0.086720645427704),
+ COEF_CONST(0.155877828598022), COEF_CONST(0.224659323692322),
+ COEF_CONST(0.292899727821350), COEF_CONST(0.360434412956238),
+ COEF_CONST(0.427100926637650), COEF_CONST(0.492738455533981),
+ COEF_CONST(0.557188928127289), COEF_CONST(0.620297133922577),
+ COEF_CONST(0.681910991668701), COEF_CONST(0.741881847381592),
+ COEF_CONST(0.800065577030182), COEF_CONST(0.856321990489960),
+ COEF_CONST(0.910515367984772), COEF_CONST(0.962515234947205),
+ COEF_CONST(1.000000000000000), COEF_CONST(0.998795449733734),
+ COEF_CONST(0.995184719562531), COEF_CONST(0.989176511764526),
+ COEF_CONST(0.980785250663757), COEF_CONST(0.970031261444092),
+ COEF_CONST(0.956940352916718), COEF_CONST(0.941544055938721),
+ COEF_CONST(0.923879504203796), COEF_CONST(0.903989315032959),
+ COEF_CONST(0.881921231746674), COEF_CONST(0.857728600502014),
+ COEF_CONST(0.831469595432281), COEF_CONST(0.803207516670227),
+ COEF_CONST(0.773010432720184), COEF_CONST(0.740951120853424),
+ COEF_CONST(0.707106769084930), COEF_CONST(0.671558916568756),
+ COEF_CONST(0.634393274784088), COEF_CONST(0.595699310302734),
+ COEF_CONST(0.555570185184479), COEF_CONST(0.514102697372437),
+ COEF_CONST(0.471396654844284), COEF_CONST(0.427555114030838),
+ COEF_CONST(0.382683426141739), COEF_CONST(0.336889833211899),
+ COEF_CONST(0.290284633636475), COEF_CONST(0.242980122566223),
+ COEF_CONST(0.195090234279633), COEF_CONST(0.146730497479439),
+ COEF_CONST(0.098017133772373), COEF_CONST(0.049067649990320),
+ COEF_CONST(-1.000000000000000), COEF_CONST(-1.047863125801086),
+ COEF_CONST(-1.093201875686646), COEF_CONST(-1.135906934738159),
+ COEF_CONST(-1.175875544548035), COEF_CONST(-1.213011503219605),
+ COEF_CONST(-1.247225046157837), COEF_CONST(-1.278433918952942),
+ COEF_CONST(-1.306562900543213), COEF_CONST(-1.331544399261475),
+ COEF_CONST(-1.353317975997925), COEF_CONST(-1.371831417083740),
+ COEF_CONST(-1.387039899826050), COEF_CONST(-1.398906826972961),
+ COEF_CONST(-1.407403707504273), COEF_CONST(-1.412510156631470),
+ COEF_CONST(0), COEF_CONST(-1.412510156631470),
+ COEF_CONST(-1.407403707504273), COEF_CONST(-1.398906826972961),
+ COEF_CONST(-1.387039899826050), COEF_CONST(-1.371831417083740),
+ COEF_CONST(-1.353317975997925), COEF_CONST(-1.331544399261475),
+ COEF_CONST(-1.306562900543213), COEF_CONST(-1.278433918952942),
+ COEF_CONST(-1.247225046157837), COEF_CONST(-1.213011384010315),
+ COEF_CONST(-1.175875544548035), COEF_CONST(-1.135907053947449),
+ COEF_CONST(-1.093201875686646), COEF_CONST(-1.047863125801086),
+ COEF_CONST(-1.000000000000000), COEF_CONST(-0.949727773666382),
+ COEF_CONST(-0.897167563438416), COEF_CONST(-0.842446029186249),
+ COEF_CONST(-0.785694956779480), COEF_CONST(-0.727051079273224),
+ COEF_CONST(-0.666655659675598), COEF_CONST(-0.604654192924500),
+ COEF_CONST(-0.541196048259735), COEF_CONST(-0.476434230804443),
+ COEF_CONST(-0.410524487495422), COEF_CONST(-0.343625843524933),
+ COEF_CONST(-0.275899350643158), COEF_CONST(-0.207508206367493),
+ COEF_CONST(-0.138617098331451), COEF_CONST(-0.069392144680023),
+ COEF_CONST(0), COEF_CONST(0.069392263889313),
+ COEF_CONST(0.138617157936096), COEF_CONST(0.207508206367493),
+ COEF_CONST(0.275899469852448), COEF_CONST(0.343625962734222),
+ COEF_CONST(0.410524636507034), COEF_CONST(0.476434201002121),
+ COEF_CONST(0.541196107864380), COEF_CONST(0.604654192924500),
+ COEF_CONST(0.666655719280243), COEF_CONST(0.727051138877869),
+ COEF_CONST(0.785695075988770), COEF_CONST(0.842446029186249),
+ COEF_CONST(0.897167563438416), COEF_CONST(0.949727773666382)
+};
+
+/* size 64 only! */
+void dct4_kernel(real_t * in_real, real_t * in_imag, real_t * out_real, real_t * out_imag)
+{
+ // Tables with bit reverse values for 5 bits, bit reverse of i at i-th position
+ const uint8_t bit_rev_tab[32] = { 0, 16, 8, 24, 4, 20, 12, 28, 2, 18, 10, 26, 6, 22, 14, 30, 1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23, 15, 31 };
+ uint32_t i, i_rev;
+
+ /* Step 2: modulate */
+ // 3*32=96 multiplications
+ // 3*32=96 additions
+ for (i = 0; i < 32; i++) {
+ real_t x_re, x_im, tmp;
+ x_re = in_real[i];
+ x_im = in_imag[i];
+ tmp = MUL_C(x_re + x_im, dct4_64_tab[i]);
+ in_real[i] = MUL_C(x_im, dct4_64_tab[i + 64]) + tmp;
+ in_imag[i] = MUL_C(x_re, dct4_64_tab[i + 32]) + tmp;
+ }
+
+ /* Step 3: FFT, but with output in bit reverse order */
+ fft_dif(in_real, in_imag);
+
+ /* Step 4: modulate + bitreverse reordering */
+ // 3*31+2=95 multiplications
+ // 3*31+2=95 additions
+ for (i = 0; i < 16; i++) {
+ real_t x_re, x_im, tmp;
+ i_rev = bit_rev_tab[i];
+ x_re = in_real[i_rev];
+ x_im = in_imag[i_rev];
+
+ tmp = MUL_C(x_re + x_im, dct4_64_tab[i + 3 * 32]);
+ out_real[i] = MUL_C(x_im, dct4_64_tab[i + 5 * 32]) + tmp;
+ out_imag[i] = MUL_C(x_re, dct4_64_tab[i + 4 * 32]) + tmp;
+ }
+ // i = 16, i_rev = 1 = rev(16);
+ out_imag[16] = MUL_C(in_imag[1] - in_real[1], dct4_64_tab[16 + 3 * 32]);
+ out_real[16] = MUL_C(in_real[1] + in_imag[1], dct4_64_tab[16 + 3 * 32]);
+ for (i = 17; i < 32; i++) {
+ real_t x_re, x_im, tmp;
+ i_rev = bit_rev_tab[i];
+ x_re = in_real[i_rev];
+ x_im = in_imag[i_rev];
+ tmp = MUL_C(x_re + x_im, dct4_64_tab[i + 3 * 32]);
+ out_real[i] = MUL_C(x_im, dct4_64_tab[i + 5 * 32]) + tmp;
+ out_imag[i] = MUL_C(x_re, dct4_64_tab[i + 4 * 32]) + tmp;
+ }
+
+}
+
+#endif
+
+#endif
diff --git a/audio_codec/libfaad/sbr_dct.h b/audio_codec/libfaad/sbr_dct.h
new file mode 100644
index 0000000..5ef1d8c
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_dct.h
@@ -0,0 +1,52 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_dct.h,v 1.19 2007/11/01 12:33:34 menno Exp $
+**/
+
+#ifndef __SBR_DCT_H__
+#define __SBR_DCT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ void dct4_kernel(real_t * in_real, real_t * in_imag, real_t * out_real, real_t * out_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/audio_codec/libfaad/sbr_dec.c b/audio_codec/libfaad/sbr_dec.c
new file mode 100644
index 0000000..7ae5659
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_dec.c
@@ -0,0 +1,679 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_dec.c,v 1.44 2009/01/26 22:32:31 menno Exp $
+**/
+
+#include <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+#ifdef SBR_DEC
+
+#include <string.h>
+
+#include "syntax.h"
+#include "bits.h"
+#include "sbr_syntax.h"
+#include "sbr_qmf.h"
+#include "sbr_hfgen.h"
+#include "sbr_hfadj.h"
+
+
+/* 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,
+ uint32_t sample_rate, uint8_t downSampledSBR
+#ifdef DRM
+ , uint8_t IsDRM
+#endif
+ )
+{
+ sbr_info *sbr = faad_malloc(sizeof(sbr_info));
+ memset(sbr, 0, sizeof(sbr_info));
+
+ /* 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;
+
+ if (id_aac == ID_CPE) {
+ /* stereo */
+ uint8_t j;
+ sbr->qmfa[0] = qmfa_init(32);
+ sbr->qmfa[1] = qmfa_init(32);
+ sbr->qmfs[0] = qmfs_init((downSampledSBR) ? 32 : 64);
+ sbr->qmfs[1] = qmfs_init((downSampledSBR) ? 32 : 64);
+
+ for (j = 0; j < 5; j++) {
+ sbr->G_temp_prev[0][j] = faad_malloc(64 * sizeof(real_t));
+ sbr->G_temp_prev[1][j] = faad_malloc(64 * sizeof(real_t));
+ sbr->Q_temp_prev[0][j] = faad_malloc(64 * sizeof(real_t));
+ sbr->Q_temp_prev[1][j] = faad_malloc(64 * sizeof(real_t));
+ }
+
+ 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));
+ } else {
+ /* mono */
+ uint8_t j;
+ sbr->qmfa[0] = qmfa_init(32);
+ sbr->qmfs[0] = qmfs_init((downSampledSBR) ? 32 : 64);
+ sbr->qmfs[1] = NULL;
+
+ for (j = 0; j < 5; j++) {
+ sbr->G_temp_prev[0][j] = faad_malloc(64 * sizeof(real_t));
+ sbr->Q_temp_prev[0][j] = faad_malloc(64 * sizeof(real_t));
+ }
+
+ memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate + sbr->tHFGen) * 64 * sizeof(qmf_t));
+ }
+
+ return sbr;
+}
+
+void sbrDecodeEnd(sbr_info *sbr)
+{
+ uint8_t j;
+
+ if (sbr) {
+ qmfa_end(sbr->qmfa[0]);
+ qmfs_end(sbr->qmfs[0]);
+ if (sbr->qmfs[1] != NULL) {
+ qmfa_end(sbr->qmfa[1]);
+ qmfs_end(sbr->qmfs[1]);
+ }
+
+ for (j = 0; j < 5; j++) {
+ if (sbr->G_temp_prev[0][j]) {
+ faad_free(sbr->G_temp_prev[0][j]);
+ }
+ if (sbr->Q_temp_prev[0][j]) {
+ faad_free(sbr->Q_temp_prev[0][j]);
+ }
+ if (sbr->G_temp_prev[1][j]) {
+ faad_free(sbr->G_temp_prev[1][j]);
+ }
+ if (sbr->Q_temp_prev[1][j]) {
+ faad_free(sbr->Q_temp_prev[1][j]);
+ }
+ }
+
+#ifdef PS_DEC
+ if (sbr->ps != NULL) {
+ ps_free(sbr->ps);
+ }
+#endif
+
+#ifdef DRM_PS
+ if (sbr->drm_ps != NULL) {
+ drm_ps_free(sbr->drm_ps);
+ }
+#endif
+
+ faad_free(sbr);
+ }
+}
+
+void sbrReset(sbr_info *sbr)
+{
+ uint8_t j;
+ if (sbr->qmfa[0] != NULL) {
+ memset(sbr->qmfa[0]->x, 0, 2 * sbr->qmfa[0]->channels * 10 * sizeof(real_t));
+ }
+ if (sbr->qmfa[1] != NULL) {
+ memset(sbr->qmfa[1]->x, 0, 2 * sbr->qmfa[1]->channels * 10 * sizeof(real_t));
+ }
+ if (sbr->qmfs[0] != NULL) {
+ memset(sbr->qmfs[0]->v, 0, 2 * sbr->qmfs[0]->channels * 20 * sizeof(real_t));
+ }
+ if (sbr->qmfs[1] != NULL) {
+ memset(sbr->qmfs[1]->v, 0, 2 * sbr->qmfs[1]->channels * 20 * sizeof(real_t));
+ }
+
+ for (j = 0; j < 5; j++) {
+ if (sbr->G_temp_prev[0][j] != NULL) {
+ memset(sbr->G_temp_prev[0][j], 0, 64 * sizeof(real_t));
+ }
+ if (sbr->G_temp_prev[1][j] != NULL) {
+ memset(sbr->G_temp_prev[1][j], 0, 64 * sizeof(real_t));
+ }
+ if (sbr->Q_temp_prev[0][j] != NULL) {
+ memset(sbr->Q_temp_prev[0][j], 0, 64 * sizeof(real_t));
+ }
+ if (sbr->Q_temp_prev[1][j] != NULL) {
+ memset(sbr->Q_temp_prev[1][j], 0, 64 * sizeof(real_t));
+ }
+ }
+
+ 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));
+
+ sbr->GQ_ringbuf_index[0] = 0;
+ sbr->GQ_ringbuf_index[1] = 0;
+ sbr->header_count = 0;
+ sbr->Reset = 1;
+
+ sbr->L_E_prev[0] = 0;
+ sbr->L_E_prev[1] = 0;
+ 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->bsco = 0;
+ sbr->bsco_prev = 0;
+ sbr->M_prev = 0;
+ sbr->bs_start_freq_prev = -1;
+
+ sbr->f_prev[0] = 0;
+ sbr->f_prev[1] = 0;
+ for (j = 0; j < MAX_M; j++) {
+ sbr->E_prev[0][j] = 0;
+ sbr->Q_prev[0][j] = 0;
+ sbr->E_prev[1][j] = 0;
+ sbr->Q_prev[1][j] = 0;
+ sbr->bs_add_harmonic_prev[0][j] = 0;
+ sbr->bs_add_harmonic_prev[1][j] = 0;
+ }
+ sbr->bs_add_harmonic_flag_prev[0] = 0;
+ sbr->bs_add_harmonic_flag_prev[1] = 0;
+}
+
+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 uint8_t 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;
+ uint8_t ret = 0;
+
+#ifdef SBR_LOW_POWER
+ ALIGN real_t deg[64];
+#endif
+
+#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
+
+#if 0 //def 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 */
+ ret = hf_adjustment(sbr, sbr->Xsbr[ch]
+#ifdef SBR_LOW_POWER
+ , deg
+#endif
+ , ch);
+#endif
+ if (ret > 0) {
+ dont_process = 1;
+ }
+ }
+
+ 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
+ }
+ }
+
+ return ret;
+}
+
+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;
+ ALIGN qmf_t X[MAX_NTSR][64];
+
+ 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->ret += sbr_process_channel(sbr, left_chan, X, 0, dont_process, downSampledSBR);
+ /* subband synthesis */
+ if (downSampledSBR) {
+ sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X, left_chan);
+ } else {
+ sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X, left_chan);
+ }
+
+ sbr->ret += sbr_process_channel(sbr, right_chan, X, 1, dont_process, downSampledSBR);
+ /* subband synthesis */
+ if (downSampledSBR) {
+ sbr_qmf_synthesis_32(sbr, sbr->qmfs[1], X, right_chan);
+ } else {
+ sbr_qmf_synthesis_64(sbr, sbr->qmfs[1], X, 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;
+ ALIGN qmf_t X[MAX_NTSR][64];
+
+ 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->ret += sbr_process_channel(sbr, channel, X, 0, dont_process, downSampledSBR);
+ /* subband synthesis */
+ if (downSampledSBR) {
+ sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X, channel);
+ } else {
+ sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X, 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;
+ ALIGN qmf_t X_left[38][64] = {{0}};
+ ALIGN qmf_t X_right[38][64] = {{0}}; /* must set this to 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;
+ }
+
+ if (sbr->qmfs[1] == NULL) {
+ sbr->qmfs[1] = qmfs_init((downSampledSBR) ? 32 : 64);
+ }
+
+ sbr->ret += sbr_process_channel(sbr, left_channel, X_left, 0, dont_process, downSampledSBR);
+
+ /* copy some extra data for PS */
+ for (l = sbr->numTimeSlotsRate; l < sbr->numTimeSlotsRate + 6; l++) {
+ for (k = 0; k < 5; k++) {
+ QMF_RE(X_left[l][k]) = QMF_RE(sbr->Xsbr[0][sbr->tHFAdj + l][k]);
+ QMF_IM(X_left[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), X_left, X_right);
+ } else {
+#endif
+#ifdef PS_DEC
+ ps_decode(sbr->ps, X_left, X_right);
+#endif
+#ifdef DRM_PS
+ }
+#endif
+
+ /* subband synthesis */
+ if (downSampledSBR) {
+ sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X_left, left_channel);
+ sbr_qmf_synthesis_32(sbr, sbr->qmfs[1], X_right, right_channel);
+ } else {
+ sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X_left, left_channel);
+ sbr_qmf_synthesis_64(sbr, sbr->qmfs[1], X_right, 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/audio_codec/libfaad/sbr_dec.h b/audio_codec/libfaad/sbr_dec.h
new file mode 100644
index 0000000..ec6dd2b
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_dec.h
@@ -0,0 +1,253 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_dec.h,v 1.39 2007/11/01 12:33:34 menno Exp $
+**/
+
+#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
+
+ /* MAX_NTSRHFG: maximum of number_time_slots * rate + HFGen. 16*2+8 */
+#define MAX_NTSRHFG 40
+#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;
+ int16_t x_index;
+ uint8_t channels;
+ } qmfa_info;
+
+ typedef struct {
+ real_t *v;
+ int16_t v_index;
+ uint8_t channels;
+ } 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];
+ real_t *Q_temp_prev[2][5];
+ 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];
+ qmfs_info *qmfs[2];
+
+ qmf_t Xsbr[2][MAX_NTSRHFG][64];
+
+#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;
+ uint8_t psResetFlag;
+#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,
+ uint32_t sample_rate, uint8_t downSampledSBR
+#ifdef DRM
+ , uint8_t IsDRM
+#endif
+ );
+ void sbrDecodeEnd(sbr_info *sbr);
+ void sbrReset(sbr_info *sbr);
+
+ 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/audio_codec/libfaad/sbr_e_nf.c b/audio_codec/libfaad/sbr_e_nf.c
new file mode 100644
index 0000000..84a5f61
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_e_nf.c
@@ -0,0 +1,475 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_e_nf.c,v 1.22 2008/03/23 23:03:29 menno Exp $
+**/
+#include <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+#ifdef SBR_DEC
+
+
+#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/audio_codec/libfaad/sbr_e_nf.h b/audio_codec/libfaad/sbr_e_nf.h
new file mode 100644
index 0000000..21115c6
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_e_nf.h
@@ -0,0 +1,50 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_e_nf.h,v 1.18 2007/11/01 12:33:35 menno Exp $
+**/
+
+#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/audio_codec/libfaad/sbr_fbt.c b/audio_codec/libfaad/sbr_fbt.c
new file mode 100644
index 0000000..6bf5d13
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_fbt.c
@@ -0,0 +1,737 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_fbt.c,v 1.21 2007/11/01 12:33:35 menno Exp $
+**/
+
+/* Calculate frequency band tables */
+#include <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+#ifdef SBR_DEC
+
+#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
+
+ /* 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;
+ 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] << REAL_BITS), REAL_CONST(limTable[k - 1]));
+#else
+ nOctaves = (real_t)limTable[k] / (real_t)limTable[k - 1];
+#endif
+#endif
+ else {
+ nOctaves = 0;
+ }
+
+#if 0
+ if ((MUL_R(nOctaves, limBands)) < REAL_CONST(0.49))
+#else
+ if (nOctaves < limiterBandsCompare[s - 1])
+#endif
+ {
+ uint8_t i;
+ if (limTable[k] != limTable[k - 1]) {
+ uint8_t found = 0, found2 = 0;
+ for (i = 0; i <= sbr->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/audio_codec/libfaad/sbr_fbt.h b/audio_codec/libfaad/sbr_fbt.h
new file mode 100644
index 0000000..ca57985
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_fbt.h
@@ -0,0 +1,55 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_fbt.h,v 1.18 2007/11/01 12:33:35 menno Exp $
+**/
+
+#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/audio_codec/libfaad/sbr_hfadj.c b/audio_codec/libfaad/sbr_hfadj.c
new file mode 100644
index 0000000..3f29f32
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_hfadj.c
@@ -0,0 +1,1644 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_hfadj.c,v 1.23 2008/09/19 22:50:20 menno Exp $
+**/
+
+/* High Frequency adjustment */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include "common.h"
+#include "structs.h"
+
+#ifdef SBR_DEC
+
+#include "sbr_syntax.h"
+#include "sbr_hfadj.h"
+
+#include "sbr_noise.h"
+
+
+/* static function declarations */
+static uint8_t 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);
+
+
+uint8_t hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64]
+#ifdef SBR_LOW_POWER
+ , real_t *deg /* aliasing degree */
+#endif
+ , uint8_t ch)
+{
+ ALIGN sbr_hfadj_info adj = {{{0}}};
+ uint8_t ret = 0;
+
+ 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] = sbr->bs_pointer[ch] - 1;
+ } else {
+ sbr->l_A[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];
+ }
+ }
+
+ ret = estimate_current_envelope(sbr, &adj, Xsbr, ch);
+ if (ret > 0) {
+ return 1;
+ }
+
+ 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);
+
+ return 0;
+}
+
+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 uint8_t 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;
+
+ 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);
+
+ if (div == 0) {
+ div = 1;
+ }
+
+ for (m = 0; m < sbr->M; m++) {
+ nrg = 0;
+
+ for (i = l_i + sbr->tHFAdj; i < u_i + sbr->tHFAdj; i++) {
+#ifdef FIXED_POINT
+#ifdef SBR_LOW_POWER
+ nrg += ((QMF_RE(Xsbr[i][m + sbr->kx]) + (1 << (REAL_BITS - 1))) >> REAL_BITS) * ((QMF_RE(Xsbr[i][m + sbr->kx]) + (1 << (REAL_BITS - 1))) >> REAL_BITS);
+#else
+ nrg += ((QMF_RE(Xsbr[i][m + sbr->kx]) + (1 << (REAL_BITS - 1))) >> REAL_BITS) * ((QMF_RE(Xsbr[i][m + sbr->kx]) + (1 << (REAL_BITS - 1))) >> REAL_BITS) +
+ ((QMF_IM(Xsbr[i][m + sbr->kx]) + (1 << (REAL_BITS - 1))) >> REAL_BITS) * ((QMF_IM(Xsbr[i][m + sbr->kx]) + (1 << (REAL_BITS - 1))) >> REAL_BITS);
+#endif
+#else
+ nrg += MUL_R(QMF_RE(Xsbr[i][m + sbr->kx]), QMF_RE(Xsbr[i][m + sbr->kx]))
+#ifndef SBR_LOW_POWER
+ + MUL_R(QMF_IM(Xsbr[i][m + sbr->kx]), QMF_IM(Xsbr[i][m + sbr->kx]))
+#endif
+ ;
+#endif
+ }
+
+ sbr->E_curr[ch][m][l] = nrg / div;
+#ifdef SBR_LOW_POWER
+#ifdef FIXED_POINT
+ sbr->E_curr[ch][m][l] <<= 1;
+#else
+ sbr->E_curr[ch][m][l] *= 2;
+#endif
+#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));
+
+ if (div == 0) {
+ div = 1;
+ }
+
+ for (i = l_i + sbr->tHFAdj; i < u_i + sbr->tHFAdj; i++) {
+ for (j = k_l; j < k_h; j++) {
+#ifdef FIXED_POINT
+#ifdef SBR_LOW_POWER
+ nrg += ((QMF_RE(Xsbr[i][j]) + (1 << (REAL_BITS - 1))) >> REAL_BITS) * ((QMF_RE(Xsbr[i][j]) + (1 << (REAL_BITS - 1))) >> REAL_BITS);
+#else
+ nrg += ((QMF_RE(Xsbr[i][j]) + (1 << (REAL_BITS - 1))) >> REAL_BITS) * ((QMF_RE(Xsbr[i][j]) + (1 << (REAL_BITS - 1))) >> REAL_BITS) +
+ ((QMF_IM(Xsbr[i][j]) + (1 << (REAL_BITS - 1))) >> REAL_BITS) * ((QMF_IM(Xsbr[i][j]) + (1 << (REAL_BITS - 1))) >> REAL_BITS);
+#endif
+#else
+ nrg += MUL_R(QMF_RE(Xsbr[i][j]), QMF_RE(Xsbr[i][j]))
+#ifndef SBR_LOW_POWER
+ + MUL_R(QMF_IM(Xsbr[i][j]), QMF_IM(Xsbr[i][j]))
+#endif
+ ;
+#endif
+ }
+ }
+
+ sbr->E_curr[ch][k - sbr->kx][l] = nrg / div;
+#ifdef SBR_LOW_POWER
+#ifdef FIXED_POINT
+ sbr->E_curr[ch][k - sbr->kx][l] <<= 1;
+#else
+ sbr->E_curr[ch][k - sbr->kx][l] *= 2;
+#endif
+#endif
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+#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) << REAL_BITS);
+ }
+ } else {
+ if (E < 12) {
+ /* negative */
+ pan = pan_log2_tab[-E + 12];
+ } else {
+ /* positive */
+ pan = pan_log2_tab[E - 12] + ((E - 12) << REAL_BITS);
+ }
+ }
+
+ /* tmp / pan in log2 */
+ return tmp - pan;
+ } else {
+ uint8_t amp = (sbr->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) << REAL_BITS);
+ }
+ } else {
+ if (Q < 12) {
+ /* negative */
+ pan = pan_log2_tab[-Q + 12];
+ } else {
+ /* positive */
+ pan = pan_log2_tab[Q - 12] + ((Q - 12) << REAL_BITS);
+ }
+ }
+
+ /* tmp / pan in log2 */
+ return tmp - pan;
+ } else {
+ return (6 << REAL_BITS) - (sbr->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;
+
+ ALIGN real_t Q_M_lim[MAX_M];
+ ALIGN real_t G_lim[MAX_M];
+ ALIGN real_t G_boost;
+ ALIGN real_t S_M[MAX_M];
+
+
+ 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 << RB));
+ return (float)ival / (float)((1 << RB));
+}
+
+float QUANTISE2INT(float val)
+{
+ return floor(val);
+}
+
+/* log2 values of [0..63] */
+static const real_t log2_int_tab[] = {
+ LOG2_MIN_INF, 0.000000000000000, 1.000000000000000, 1.584962500721156,
+ 2.000000000000000, 2.321928094887362, 2.584962500721156, 2.807354922057604,
+ 3.000000000000000, 3.169925001442313, 3.321928094887363, 3.459431618637297,
+ 3.584962500721156, 3.700439718141092, 3.807354922057604, 3.906890595608519,
+ 4.000000000000000, 4.087462841250339, 4.169925001442312, 4.247927513443585,
+ 4.321928094887362, 4.392317422778761, 4.459431618637297, 4.523561956057013,
+ 4.584962500721156, 4.643856189774724, 4.700439718141093, 4.754887502163468,
+ 4.807354922057604, 4.857980995127572, 4.906890595608519, 4.954196310386875,
+ 5.000000000000000, 5.044394119358453, 5.087462841250340, 5.129283016944966,
+ 5.169925001442312, 5.209453365628949, 5.247927513443585, 5.285402218862248,
+ 5.321928094887363, 5.357552004618084, 5.392317422778761, 5.426264754702098,
+ 5.459431618637297, 5.491853096329675, 5.523561956057013, 5.554588851677637,
+ 5.584962500721156, 5.614709844115208, 5.643856189774724, 5.672425341971495,
+ 5.700439718141093, 5.727920454563200, 5.754887502163469, 5.781359713524660,
+ 5.807354922057605, 5.832890014164742, 5.857980995127572, 5.882643049361842,
+ 5.906890595608518, 5.930737337562887, 5.954196310386876, 5.977279923499916
+};
+
+static const real_t pan_log2_tab[] = {
+ 1.000000000000000, 0.584962500721156, 0.321928094887362, 0.169925001442312, 0.087462841250339,
+ 0.044394119358453, 0.022367813028455, 0.011227255423254, 0.005624549193878, 0.002815015607054,
+ 0.001408194392808, 0.000704269011247, 0.000352177480301, 0.000176099486443, 0.000088052430122,
+ 0.000044026886827, 0.000022013611360, 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) {
+ 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;
+
+ ALIGN real_t Q_M_lim[MAX_M];
+ ALIGN real_t G_lim[MAX_M];
+ ALIGN real_t G_boost;
+ ALIGN real_t S_M[MAX_M];
+
+
+ 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;
+
+ ALIGN real_t Q_M_lim[MAX_M];
+ ALIGN real_t G_lim[MAX_M];
+ ALIGN real_t G_boost;
+ ALIGN real_t S_M[MAX_M];
+
+ 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 current_res_band_size = 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;
+ uint8_t S_mapped;
+
+ for (l = 0; l < sbr->L_E[ch]; l++) {
+ uint8_t current_res_band = 0;
+ i = 0;
+ grouping = 0;
+
+ S_mapped = get_S_mapped(sbr, ch, l, current_res_band);
+
+ for (k = sbr->kx; k < sbr->kx + sbr->M - 1; k++) {
+ if (k == sbr->f_table_res[sbr->f[ch][l]][current_res_band + 1]) {
+ /* step to next resolution band */
+ current_res_band++;
+
+ S_mapped = get_S_mapped(sbr, ch, l, current_res_band);
+ }
+
+ if (deg[k + 1] && S_mapped == 0) {
+ if (grouping == 0) {
+ sbr->f_group[l][i] = k;
+ grouping = 1;
+ i++;
+ }
+ } else {
+ if (grouping) {
+ if (S_mapped) {
+ 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];
+#ifdef FIXED_POINT
+ E_total += MUL_Q2(sbr->E_curr[ch][m - sbr->kx][l], adj->G_lim_boost[l][m - sbr->kx]);
+#else
+ E_total += sbr->E_curr[ch][m - sbr->kx][l] * adj->G_lim_boost[l][m - sbr->kx];
+#endif
+ }
+
+ /* G_target: fixed point */
+ if ((E_total_est + EPS) == 0) {
+ G_target = 0;
+ } else {
+#ifdef FIXED_POINT
+ G_target = (((int64_t)(E_total)) << Q2_BITS) / (E_total_est + EPS);
+#else
+ G_target = E_total / (E_total_est + EPS);
+#endif
+ }
+ 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 */
+#ifdef FIXED_POINT
+ acc += MUL_Q2(adj->G_lim_boost[l][m - sbr->kx], sbr->E_curr[ch][m - sbr->kx][l]);
+#else
+ acc += adj->G_lim_boost[l][m - sbr->kx] * sbr->E_curr[ch][m - sbr->kx][l];
+#endif
+ }
+
+ /* acc: fixed point */
+ if (acc + EPS == 0) {
+ acc = 0;
+ } else {
+#ifdef FIXED_POINT
+ acc = (((int64_t)(E_total)) << Q2_BITS) / (acc + EPS);
+#else
+ acc = E_total / (acc + EPS);
+#endif
+ }
+ for (m = sbr->f_group[l][(k << 1)]; m < sbr->f_group[l][(k << 1) + 1]; m++) {
+#ifdef FIXED_POINT
+ adj->G_lim_boost[l][m - sbr->kx] = MUL_Q2(acc, adj->G_lim_boost[l][m - sbr->kx]);
+#else
+ adj->G_lim_boost[l][m - sbr->kx] = acc * adj->G_lim_boost[l][m - sbr->kx];
+#endif
+ }
+ }
+ }
+
+ 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 */
+#ifndef FIXED_POINT
+ QMF_RE(Xsbr[i + sbr->tHFAdj][m + sbr->kx]) = G_filt * QMF_RE(Xsbr[i + sbr->tHFAdj][m + sbr->kx])
+ + MUL_F(Q_filt, RE(V[fIndexNoise]));
+#else
+ //QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = MUL_Q2(G_filt, QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]))
+ // + MUL_F(Q_filt, RE(V[fIndexNoise]));
+ 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]));
+#endif
+ 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
+#ifndef FIXED_POINT
+ QMF_IM(Xsbr[i + sbr->tHFAdj][m + sbr->kx]) = G_filt * QMF_IM(Xsbr[i + sbr->tHFAdj][m + sbr->kx])
+ + MUL_F(Q_filt, IM(V[fIndexNoise]));
+#else
+ //QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = MUL_Q2(G_filt, QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]))
+ // + MUL_F(Q_filt, IM(V[fIndexNoise]));
+ 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
+#endif
+
+ {
+ int8_t rev = (((m + sbr->kx) & 1) ? -1 : 1);
+ QMF_RE(psi) = adj->S_M_boost[l][m] * phi_re[fIndexSine];
+#ifdef FIXED_POINT
+ QMF_RE(Xsbr[i + sbr->tHFAdj][m + sbr->kx]) += (QMF_RE(psi) << REAL_BITS);
+#else
+ QMF_RE(Xsbr[i + sbr->tHFAdj][m + sbr->kx]) += QMF_RE(psi);
+#endif
+
+#ifndef SBR_LOW_POWER
+ QMF_IM(psi) = rev * adj->S_M_boost[l][m] * phi_im[fIndexSine];
+#ifdef FIXED_POINT
+ QMF_IM(Xsbr[i + sbr->tHFAdj][m + sbr->kx]) += (QMF_IM(psi) << REAL_BITS);
+#else
+ QMF_IM(Xsbr[i + sbr->tHFAdj][m + sbr->kx]) += QMF_IM(psi);
+#endif
+#else
+
+ i_min1 = (fIndexSine - 1) & 3;
+ i_plus1 = (fIndexSine + 1) & 3;
+
+#ifndef FIXED_POINT
+ if ((m == 0) && (phi_re[i_plus1] != 0)) {
+ QMF_RE(Xsbr[i + sbr->tHFAdj][m + sbr->kx - 1]) +=
+ (rev * phi_re[i_plus1] * MUL_F(adj->S_M_boost[l][0], FRAC_CONST(0.00815)));
+ if (sbr->M != 0) {
+ QMF_RE(Xsbr[i + sbr->tHFAdj][m + sbr->kx]) -=
+ (rev * phi_re[i_plus1] * MUL_F(adj->S_M_boost[l][1], FRAC_CONST(0.00815)));
+ }
+ }
+ if ((m > 0) && (m < sbr->M - 1) && (sinusoids < 16) && (phi_re[i_min1] != 0)) {
+ QMF_RE(Xsbr[i + sbr->tHFAdj][m + sbr->kx]) -=
+ (rev * phi_re[i_min1] * MUL_F(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)) {
+ QMF_RE(Xsbr[i + sbr->tHFAdj][m + sbr->kx]) -=
+ (rev * phi_re[i_plus1] * MUL_F(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) {
+ QMF_RE(Xsbr[i + sbr->tHFAdj][m + sbr->kx]) -=
+ (rev * phi_re[i_min1] * MUL_F(adj->S_M_boost[l][m - 1], FRAC_CONST(0.00815)));
+ }
+ if (m + sbr->kx < 64) {
+ QMF_RE(Xsbr[i + sbr->tHFAdj][m + sbr->kx + 1]) +=
+ (rev * phi_re[i_min1] * MUL_F(adj->S_M_boost[l][m], FRAC_CONST(0.00815)));
+ }
+ }
+#else
+ if ((m == 0) && (phi_re[i_plus1] != 0)) {
+ QMF_RE(Xsbr[i + sbr->tHFAdj][m + sbr->kx - 1]) +=
+ (rev * phi_re[i_plus1] * MUL_F((adj->S_M_boost[l][0] << REAL_BITS), FRAC_CONST(0.00815)));
+ if (sbr->M != 0) {
+ QMF_RE(Xsbr[i + sbr->tHFAdj][m + sbr->kx]) -=
+ (rev * phi_re[i_plus1] * MUL_F((adj->S_M_boost[l][1] << REAL_BITS), FRAC_CONST(0.00815)));
+ }
+ }
+ if ((m > 0) && (m < sbr->M - 1) && (sinusoids < 16) && (phi_re[i_min1] != 0)) {
+ QMF_RE(Xsbr[i + sbr->tHFAdj][m + sbr->kx]) -=
+ (rev * phi_re[i_min1] * MUL_F((adj->S_M_boost[l][m - 1] << REAL_BITS), FRAC_CONST(0.00815)));
+ }
+ if ((m > 0) && (m < sbr->M - 1) && (sinusoids < 16) && (phi_re[i_plus1] != 0)) {
+ QMF_RE(Xsbr[i + sbr->tHFAdj][m + sbr->kx]) -=
+ (rev * phi_re[i_plus1] * MUL_F((adj->S_M_boost[l][m + 1] << REAL_BITS), FRAC_CONST(0.00815)));
+ }
+ if ((m == sbr->M - 1) && (sinusoids < 16) && (phi_re[i_min1] != 0)) {
+ if (m > 0) {
+ QMF_RE(Xsbr[i + sbr->tHFAdj][m + sbr->kx]) -=
+ (rev * phi_re[i_min1] * MUL_F((adj->S_M_boost[l][m - 1] << REAL_BITS), FRAC_CONST(0.00815)));
+ }
+ if (m + sbr->kx < 64) {
+ QMF_RE(Xsbr[i + sbr->tHFAdj][m + sbr->kx + 1]) +=
+ (rev * phi_re[i_min1] * MUL_F((adj->S_M_boost[l][m] << REAL_BITS), FRAC_CONST(0.00815)));
+ }
+ }
+#endif
+
+ 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/audio_codec/libfaad/sbr_hfadj.h b/audio_codec/libfaad/sbr_hfadj.h
new file mode 100644
index 0000000..d527e17
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_hfadj.h
@@ -0,0 +1,56 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_hfadj.h,v 1.19 2007/11/01 12:33:35 menno Exp $
+**/
+
+#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;
+
+
+ uint8_t 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/audio_codec/libfaad/sbr_hfgen.c b/audio_codec/libfaad/sbr_hfgen.c
new file mode 100644
index 0000000..4932439
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_hfgen.c
@@ -0,0 +1,647 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_hfgen.c,v 1.26 2007/11/01 12:33:35 menno Exp $
+**/
+
+/* 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;
+ ALIGN complex_t alpha_0[64], alpha_1[64];
+#ifdef SBR_LOW_POWER
+ ALIGN 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;
+
+#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;
+ int8_t j;
+ uint8_t offset = sbr->tHFAdj;
+#ifdef FIXED_POINT
+ const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f);
+ uint32_t maxi = 0;
+ uint32_t pow2, exp;
+#else
+ const real_t rel = 1 / (1 + 1e-6f);
+#endif
+
+
+#ifdef FIXED_POINT
+ mask = 0;
+
+ for (j = (offset - 2); j < (len + offset); j++) {
+ real_t x;
+ x = QMF_RE(buffer[j][bd]) >> REAL_BITS;
+ mask |= x ^(x >> 31);
+ }
+
+ exp = wl_min_lzc(mask);
+
+ /* improves accuracy */
+ if (exp > 0) {
+ exp -= 1;
+ }
+
+ for (j = offset; j < len + offset; j++) {
+ real_t buf_j = ((QMF_RE(buffer[j][bd]) + (1 << (exp - 1))) >> exp);
+ real_t buf_j_1 = ((QMF_RE(buffer[j - 1][bd]) + (1 << (exp - 1))) >> exp);
+ real_t buf_j_2 = ((QMF_RE(buffer[j - 2][bd]) + (1 << (exp - 1))) >> exp);
+
+ /* normalisation with rounding */
+ r01 += MUL_R(buf_j, buf_j_1);
+ r02 += MUL_R(buf_j, buf_j_2);
+ r11 += MUL_R(buf_j_1, buf_j_1);
+ }
+ RE(ac->r12) = r01 -
+ MUL_R(((QMF_RE(buffer[len + offset - 1][bd]) + (1 << (exp - 1))) >> exp), ((QMF_RE(buffer[len + offset - 2][bd]) + (1 << (exp - 1))) >> exp)) +
+ MUL_R(((QMF_RE(buffer[offset - 1][bd]) + (1 << (exp - 1))) >> exp), ((QMF_RE(buffer[offset - 2][bd]) + (1 << (exp - 1))) >> exp));
+ RE(ac->r22) = r11 -
+ MUL_R(((QMF_RE(buffer[len + offset - 2][bd]) + (1 << (exp - 1))) >> exp), ((QMF_RE(buffer[len + offset - 2][bd]) + (1 << (exp - 1))) >> exp)) +
+ MUL_R(((QMF_RE(buffer[offset - 2][bd]) + (1 << (exp - 1))) >> exp), ((QMF_RE(buffer[offset - 2][bd]) + (1 << (exp - 1))) >> exp));
+#else
+ for (j = offset; j < len + offset; j++) {
+ r01 += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j - 1][bd]);
+ r02 += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j - 2][bd]);
+ r11 += QMF_RE(buffer[j - 1][bd]) * QMF_RE(buffer[j - 1][bd]);
+ }
+ RE(ac->r12) = r01 -
+ QMF_RE(buffer[len + offset - 1][bd]) * QMF_RE(buffer[len + offset - 2][bd]) +
+ QMF_RE(buffer[offset - 1][bd]) * QMF_RE(buffer[offset - 2][bd]);
+ RE(ac->r22) = r11 -
+ QMF_RE(buffer[len + offset - 2][bd]) * QMF_RE(buffer[len + offset - 2][bd]) +
+ QMF_RE(buffer[offset - 2][bd]) * QMF_RE(buffer[offset - 2][bd]);
+#endif
+ RE(ac->r01) = r01;
+ RE(ac->r02) = r02;
+ RE(ac->r11) = r11;
+
+ ac->det = MUL_R(RE(ac->r11), RE(ac->r22)) - MUL_F(MUL_R(RE(ac->r12), RE(ac->r12)), rel);
+}
+#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, temp4_r, temp4_i, temp5_r, temp5_i;
+#ifdef FIXED_POINT
+ const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f);
+ uint32_t mask, exp;
+ real_t pow2_to_exp;
+#else
+ const real_t rel = 1 / (1 + 1e-6f);
+#endif
+ int8_t j;
+ uint8_t offset = sbr->tHFAdj;
+
+#ifdef FIXED_POINT
+ mask = 0;
+
+ for (j = (offset - 2); j < (len + offset); j++) {
+ real_t x;
+ x = QMF_RE(buffer[j][bd]) >> REAL_BITS;
+ mask |= x ^(x >> 31);
+ x = QMF_IM(buffer[j][bd]) >> REAL_BITS;
+ mask |= x ^(x >> 31);
+ }
+
+ exp = wl_min_lzc(mask);
+
+ /* improves accuracy */
+ if (exp > 0) {
+ exp -= 1;
+ }
+
+ pow2_to_exp = 1 << (exp - 1);
+
+ temp2_r = (QMF_RE(buffer[offset - 2][bd]) + pow2_to_exp) >> exp;
+ temp2_i = (QMF_IM(buffer[offset - 2][bd]) + pow2_to_exp) >> exp;
+ temp3_r = (QMF_RE(buffer[offset - 1][bd]) + pow2_to_exp) >> exp;
+ temp3_i = (QMF_IM(buffer[offset - 1][bd]) + pow2_to_exp) >> exp;
+ // 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_r = (QMF_RE(buffer[offset-2][bd] + (1<<(exp-1))) >> exp;
+ temp1_i = temp2_i; // temp1_i = (QMF_IM(buffer[offset-2][bd] + (1<<(exp-1))) >> exp;
+ temp2_r = temp3_r; // temp2_r = (QMF_RE(buffer[offset-1][bd] + (1<<(exp-1))) >> exp;
+ temp2_i = temp3_i; // temp2_i = (QMF_IM(buffer[offset-1][bd] + (1<<(exp-1))) >> exp;
+ temp3_r = (QMF_RE(buffer[j][bd]) + pow2_to_exp) >> exp;
+ temp3_i = (QMF_IM(buffer[j][bd]) + pow2_to_exp) >> exp;
+ r01r += MUL_R(temp3_r, temp2_r) + MUL_R(temp3_i, temp2_i);
+ r01i += MUL_R(temp3_i, temp2_r) - MUL_R(temp3_r, temp2_i);
+ r02r += MUL_R(temp3_r, temp1_r) + MUL_R(temp3_i, temp1_i);
+ r02i += MUL_R(temp3_i, temp1_r) - MUL_R(temp3_r, temp1_i);
+ r11r += MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i);
+ }
+
+ // These are actual values in temporary variable at this point
+ // temp1_r = (QMF_RE(buffer[len+offset-1-2][bd] + (1<<(exp-1))) >> exp;
+ // temp1_i = (QMF_IM(buffer[len+offset-1-2][bd] + (1<<(exp-1))) >> exp;
+ // temp2_r = (QMF_RE(buffer[len+offset-1-1][bd] + (1<<(exp-1))) >> exp;
+ // temp2_i = (QMF_IM(buffer[len+offset-1-1][bd] + (1<<(exp-1))) >> exp;
+ // temp3_r = (QMF_RE(buffer[len+offset-1][bd]) + (1<<(exp-1))) >> exp;
+ // temp3_i = (QMF_IM(buffer[len+offset-1][bd]) + (1<<(exp-1))) >> exp;
+ // temp4_r = (QMF_RE(buffer[offset-2][bd]) + (1<<(exp-1))) >> exp;
+ // temp4_i = (QMF_IM(buffer[offset-2][bd]) + (1<<(exp-1))) >> exp;
+ // temp5_r = (QMF_RE(buffer[offset-1][bd]) + (1<<(exp-1))) >> exp;
+ // temp5_i = (QMF_IM(buffer[offset-1][bd]) + (1<<(exp-1))) >> exp;
+
+ RE(ac->r12) = r01r -
+ (MUL_R(temp3_r, temp2_r) + MUL_R(temp3_i, temp2_i)) +
+ (MUL_R(temp5_r, temp4_r) + MUL_R(temp5_i, temp4_i));
+ IM(ac->r12) = r01i -
+ (MUL_R(temp3_i, temp2_r) - MUL_R(temp3_r, temp2_i)) +
+ (MUL_R(temp5_i, temp4_r) - MUL_R(temp5_r, temp4_i));
+ RE(ac->r22) = r11r -
+ (MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i)) +
+ (MUL_R(temp4_r, temp4_r) + MUL_R(temp4_i, temp4_i));
+
+#else
+
+ temp2_r = QMF_RE(buffer[offset - 2][bd]);
+ temp2_i = QMF_IM(buffer[offset - 2][bd]);
+ temp3_r = QMF_RE(buffer[offset - 1][bd]);
+ temp3_i = 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_r = QMF_RE(buffer[j-2][bd];
+ temp1_i = temp2_i; // temp1_i = QMF_IM(buffer[j-2][bd];
+ temp2_r = temp3_r; // temp2_r = QMF_RE(buffer[j-1][bd];
+ temp2_i = temp3_i; // temp2_i = QMF_IM(buffer[j-1][bd];
+ temp3_r = QMF_RE(buffer[j][bd]);
+ temp3_i = QMF_IM(buffer[j][bd]);
+ r01r += temp3_r * temp2_r + temp3_i * temp2_i;
+ r01i += temp3_i * temp2_r - temp3_r * temp2_i;
+ r02r += temp3_r * temp1_r + temp3_i * temp1_i;
+ r02i += temp3_i * temp1_r - temp3_r * temp1_i;
+ r11r += temp2_r * temp2_r + temp2_i * temp2_i;
+ }
+
+ // These are actual values in temporary variable at this point
+ // temp1_r = QMF_RE(buffer[len+offset-1-2][bd];
+ // temp1_i = QMF_IM(buffer[len+offset-1-2][bd];
+ // temp2_r = QMF_RE(buffer[len+offset-1-1][bd];
+ // temp2_i = QMF_IM(buffer[len+offset-1-1][bd];
+ // temp3_r = QMF_RE(buffer[len+offset-1][bd]);
+ // temp3_i = QMF_IM(buffer[len+offset-1][bd]);
+ // temp4_r = QMF_RE(buffer[offset-2][bd]);
+ // temp4_i = QMF_IM(buffer[offset-2][bd]);
+ // temp5_r = QMF_RE(buffer[offset-1][bd]);
+ // temp5_i = QMF_IM(buffer[offset-1][bd]);
+
+ RE(ac->r12) = r01r -
+ (temp3_r * temp2_r + temp3_i * temp2_i) +
+ (temp5_r * temp4_r + temp5_i * temp4_i);
+ IM(ac->r12) = r01i -
+ (temp3_i * temp2_r - temp3_r * temp2_i) +
+ (temp5_i * temp4_r - temp5_r * temp4_i);
+ RE(ac->r22) = r11r -
+ (temp2_r * temp2_r + temp2_i * temp2_i) +
+ (temp4_r * temp4_r + temp4_i * temp4_i);
+
+#endif
+
+ RE(ac->r01) = r01r;
+ IM(ac->r01) = r01i;
+ RE(ac->r02) = r02r;
+ IM(ac->r02) = r02i;
+ RE(ac->r11) = r11r;
+
+ ac->det = MUL_R(RE(ac->r11), RE(ac->r22)) - MUL_F(rel, (MUL_R(RE(ac->r12), RE(ac->r12)) + MUL_R(IM(ac->r12), IM(ac->r12))));
+}
+#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;
+ 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 {
+#ifdef FIXED_POINT
+ 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]) = DIV_R(tmp, ac.det);
+ 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]) = DIV_R(tmp, ac.det);
+#else
+ tmp = REAL_CONST(1.0) / ac.det;
+ RE(alpha_1[k]) = (MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(IM(ac.r01), IM(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11))) * tmp;
+ IM(alpha_1[k]) = (MUL_R(IM(ac.r01), RE(ac.r12)) + MUL_R(RE(ac.r01), IM(ac.r12)) - MUL_R(IM(ac.r02), RE(ac.r11))) * tmp;
+#endif
+ }
+
+ if (RE(ac.r11) == 0) {
+ RE(alpha_0[k]) = 0;
+ IM(alpha_0[k]) = 0;
+ } else {
+#ifdef FIXED_POINT
+ 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]) = DIV_R(tmp, RE(ac.r11));
+ 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]) = DIV_R(tmp, RE(ac.r11));
+#else
+ tmp = 1.0f / RE(ac.r11);
+ RE(alpha_0[k]) = -(RE(ac.r01) + MUL_R(RE(alpha_1[k]), RE(ac.r12)) + MUL_R(IM(alpha_1[k]), IM(ac.r12))) * tmp;
+ IM(alpha_0[k]) = -(IM(ac.r01) + MUL_R(IM(alpha_1[k]), RE(ac.r12)) - MUL_R(RE(alpha_1[k]), IM(ac.r12))) * tmp;
+#endif
+ }
+
+ 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;
+ 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 {
+ tmp = MUL_R(RE(ac.r01), RE(ac.r22)) - MUL_R(RE(ac.r12), RE(ac.r02));
+ RE(alpha_0[k]) = DIV_R(tmp, (-ac.det));
+
+ tmp = MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11));
+ RE(alpha_1[k]) = DIV_R(tmp, ac.det);
+ }
+
+ 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] = 0.0;
+
+ if ((k % 2 == 0) && (rxx[k] < COEF_CONST(0.0))) {
+ if (rxx[k - 1] < 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 {
+ uint8_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/audio_codec/libfaad/sbr_hfgen.h b/audio_codec/libfaad/sbr_hfgen.h
new file mode 100644
index 0000000..a8f1c82
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_hfgen.h
@@ -0,0 +1,49 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_hfgen.h,v 1.20 2007/11/01 12:33:35 menno Exp $
+**/
+
+#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/audio_codec/libfaad/sbr_huff.c b/audio_codec/libfaad/sbr_huff.c
new file mode 100644
index 0000000..c7cce59
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_huff.c
@@ -0,0 +1,344 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_huff.c,v 1.21 2007/11/01 12:33:35 menno Exp $
+**/
+
+#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/audio_codec/libfaad/sbr_huff.h b/audio_codec/libfaad/sbr_huff.h
new file mode 100644
index 0000000..24d9ab8
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_huff.h
@@ -0,0 +1,46 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_huff.h,v 1.21 2007/11/01 12:33:35 menno Exp $
+**/
+
+#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/audio_codec/libfaad/sbr_noise.h b/audio_codec/libfaad/sbr_noise.h
new file mode 100644
index 0000000..256f568
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_noise.h
@@ -0,0 +1,564 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_noise.h,v 1.17 2007/11/01 12:33:35 menno Exp $
+**/
+
+#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 */
+ ALIGN static const complex_t V[] = {
+ { 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/audio_codec/libfaad/sbr_qmf.c b/audio_codec/libfaad/sbr_qmf.c
new file mode 100644
index 0000000..0131a39
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_qmf.c
@@ -0,0 +1,614 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_qmf.c,v 1.32 2007/11/01 12:33:36 menno Exp $
+**/
+#include <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+#ifdef SBR_DEC
+
+
+#include <string.h>
+#include "sbr_dct.h"
+#include "sbr_qmf.h"
+#include "sbr_qmf_c.h"
+#include "sbr_syntax.h"
+
+qmfa_info *qmfa_init(uint8_t channels)
+{
+ qmfa_info *qmfa = (qmfa_info*)faad_malloc(sizeof(qmfa_info));
+
+ /* x is implemented as double ringbuffer */
+ qmfa->x = (real_t*)faad_malloc(2 * channels * 10 * sizeof(real_t));
+ memset(qmfa->x, 0, 2 * channels * 10 * sizeof(real_t));
+
+ /* ringbuffer index */
+ qmfa->x_index = 0;
+
+ qmfa->channels = channels;
+
+ return qmfa;
+}
+
+void qmfa_end(qmfa_info *qmfa)
+{
+ if (qmfa) {
+ if (qmfa->x) {
+ faad_free(qmfa->x);
+ }
+ faad_free(qmfa);
+ }
+}
+
+void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
+ qmf_t X[MAX_NTSRHFG][64], uint8_t offset, uint8_t kx)
+{
+ ALIGN real_t u[64];
+#ifndef SBR_LOW_POWER
+ ALIGN real_t in_real[32], in_imag[32], out_real[32], out_imag[32];
+#else
+ ALIGN real_t y[32];
+#endif
+ uint32_t in = 0;
+ uint8_t l;
+
+ /* qmf subsample l */
+ for (l = 0; l < sbr->numTimeSlotsRate; l++) {
+ int16_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 */
+ for (n = 32 - 1; n >= 0; n--) {
+#ifdef FIXED_POINT
+ qmfa->x[qmfa->x_index + n] = qmfa->x[qmfa->x_index + n + 320] = (input[in++]) >> 4;
+#else
+ qmfa->x[qmfa->x_index + n] = qmfa->x[qmfa->x_index + n + 320] = input[in++];
+#endif
+ }
+
+ /* window and summation to create array u */
+ for (n = 0; n < 64; n++) {
+ u[n] = MUL_F(qmfa->x[qmfa->x_index + n], qmf_c[2 * n]) +
+ MUL_F(qmfa->x[qmfa->x_index + n + 64], qmf_c[2 * (n + 64)]) +
+ MUL_F(qmfa->x[qmfa->x_index + n + 128], qmf_c[2 * (n + 128)]) +
+ MUL_F(qmfa->x[qmfa->x_index + n + 192], qmf_c[2 * (n + 192)]) +
+ MUL_F(qmfa->x[qmfa->x_index + n + 256], qmf_c[2 * (n + 256)]);
+ }
+
+ /* 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) {
+#ifdef FIXED_POINT
+ QMF_RE(X[l + offset][n]) = u[n] /*<< 1*/;
+#else
+ QMF_RE(X[l + offset][n]) = 2. * u[n];
+#endif
+ } else {
+ QMF_RE(X[l + offset][n]) = 0;
+ }
+ }
+#else
+
+ // Reordering of data moved from DCT_IV to here
+ in_imag[31] = u[1];
+ in_real[0] = u[0];
+ for (n = 1; n < 31; n++) {
+ in_imag[31 - n] = u[n + 1];
+ in_real[n] = -u[64 - n];
+ }
+ in_imag[0] = u[32];
+ in_real[31] = -u[33];
+
+ // dct4_kernel is DCT_IV without reordering which is done before and after FFT
+ dct4_kernel(in_real, in_imag, out_real, out_imag);
+
+ // Reordering of data moved from DCT_IV to here
+ for (n = 0; n < 16; n++) {
+ if (2 * n + 1 < kx) {
+#ifdef FIXED_POINT
+ QMF_RE(X[l + offset][2 * n]) = out_real[n];
+ QMF_IM(X[l + offset][2 * n]) = out_imag[n];
+ QMF_RE(X[l + offset][2 * n + 1]) = -out_imag[31 - n];
+ QMF_IM(X[l + offset][2 * n + 1]) = -out_real[31 - n];
+#else
+ QMF_RE(X[l + offset][2 * n]) = 2. * out_real[n];
+ QMF_IM(X[l + offset][2 * n]) = 2. * out_imag[n];
+ QMF_RE(X[l + offset][2 * n + 1]) = -2. * out_imag[31 - n];
+ QMF_IM(X[l + offset][2 * n + 1]) = -2. * out_real[31 - n];
+#endif
+ } else {
+ if (2 * n < kx) {
+#ifdef FIXED_POINT
+ QMF_RE(X[l + offset][2 * n]) = out_real[n];
+ QMF_IM(X[l + offset][2 * n]) = out_imag[n];
+#else
+ QMF_RE(X[l + offset][2 * n]) = 2. * out_real[n];
+ QMF_IM(X[l + offset][2 * n]) = 2. * out_imag[n];
+#endif
+ } else {
+ QMF_RE(X[l + offset][2 * n]) = 0;
+ QMF_IM(X[l + offset][2 * n]) = 0;
+ }
+ QMF_RE(X[l + offset][2 * n + 1]) = 0;
+ QMF_IM(X[l + offset][2 * n + 1]) = 0;
+ }
+ }
+#endif
+ }
+}
+
+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) }
+};
+
+qmfs_info *qmfs_init(uint8_t channels)
+{
+ qmfs_info *qmfs = (qmfs_info*)faad_malloc(sizeof(qmfs_info));
+
+ /* v is a double ringbuffer */
+ qmfs->v = (real_t*)faad_malloc(2 * channels * 20 * sizeof(real_t));
+ memset(qmfs->v, 0, 2 * channels * 20 * sizeof(real_t));
+
+ qmfs->v_index = 0;
+
+ qmfs->channels = channels;
+
+ return qmfs;
+}
+
+void qmfs_end(qmfs_info *qmfs)
+{
+ if (qmfs) {
+ if (qmfs->v) {
+ faad_free(qmfs->v);
+ }
+ faad_free(qmfs);
+ }
+}
+
+#ifdef SBR_LOW_POWER
+
+void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
+ real_t *output)
+{
+ ALIGN real_t x[16];
+ ALIGN real_t y[16];
+ int32_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++) {
+#ifdef FIXED_POINT
+ y[k] = (QMF_RE(X[l][k]) - QMF_RE(X[l][31 - k]));
+ x[k] = (QMF_RE(X[l][k]) + QMF_RE(X[l][31 - k]));
+#else
+ y[k] = (QMF_RE(X[l][k]) - QMF_RE(X[l][31 - k])) / 32.0;
+ x[k] = (QMF_RE(X[l][k]) + QMF_RE(X[l][31 - k])) / 32.0;
+#endif
+ }
+
+ /* 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]) +
+ MUL_F(qmfs->v[qmfs->v_index + 96 + k], qmf_c[64 + 2 * k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 128 + k], qmf_c[128 + 2 * k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 224 + k], qmf_c[192 + 2 * k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 256 + k], qmf_c[256 + 2 * k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 352 + k], qmf_c[320 + 2 * k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 384 + k], qmf_c[384 + 2 * k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 480 + k], qmf_c[448 + 2 * k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 512 + k], qmf_c[512 + 2 * k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 608 + k], qmf_c[576 + 2 * k]);
+ }
+
+ /* 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_NTSRHFG][64],
+ real_t *output)
+{
+ ALIGN real_t x[64];
+ ALIGN real_t y[64];
+ int32_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++) {
+#ifdef FIXED_POINT
+ y[k] = (QMF_RE(X[l][k]) - QMF_RE(X[l][63 - k]));
+ x[k] = (QMF_RE(X[l][k]) + QMF_RE(X[l][63 - k]));
+#else
+ y[k] = (QMF_RE(X[l][k]) - QMF_RE(X[l][63 - k])) / 32.0;
+ x[k] = (QMF_RE(X[l][k]) + QMF_RE(X[l][63 - k])) / 32.0;
+#endif
+ }
+
+ /* 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]) +
+ MUL_F(qmfs->v[qmfs->v_index + 192 + k], qmf_c[64 + k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 256 + k], qmf_c[128 + k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 256 + 192 + k], qmf_c[128 + 64 + k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 512 + k], qmf_c[256 + k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 512 + 192 + k], qmf_c[256 + 64 + k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 768 + k], qmf_c[384 + k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 768 + 192 + k], qmf_c[384 + 64 + k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 1024 + k], qmf_c[512 + k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 1024 + 192 + k], qmf_c[512 + 64 + k]);
+ }
+
+ /* update the ringbuffer index */
+ qmfs->v_index -= 128;
+ if (qmfs->v_index < 0) {
+ qmfs->v_index = (1280 - 128);
+ }
+ }
+}
+#else
+void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
+ real_t *output)
+{
+ ALIGN real_t x1[32], x2[32];
+#ifndef FIXED_POINT
+ real_t scale = 1.f / 64.f;
+#endif
+ int32_t n, k, out = 0;
+ uint8_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; k++) {
+ x1[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]));
+ x2[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]));
+
+#ifndef FIXED_POINT
+ x1[k] *= scale;
+ x2[k] *= scale;
+#else
+ x1[k] >>= 1;
+ x2[k] >>= 1;
+#endif
+ }
+
+ /* transform */
+ DCT4_32(x1, x1);
+ DST4_32(x2, x2);
+
+ for (n = 0; n < 32; n++) {
+ qmfs->v[qmfs->v_index + n] = qmfs->v[qmfs->v_index + 640 + n] = -x1[n] + x2[n];
+ qmfs->v[qmfs->v_index + 63 - n] = qmfs->v[qmfs->v_index + 640 + 63 - n] = x1[n] + x2[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]) +
+ MUL_F(qmfs->v[qmfs->v_index + 96 + k], qmf_c[64 + 2 * k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 128 + k], qmf_c[128 + 2 * k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 224 + k], qmf_c[192 + 2 * k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 256 + k], qmf_c[256 + 2 * k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 352 + k], qmf_c[320 + 2 * k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 384 + k], qmf_c[384 + 2 * k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 480 + k], qmf_c[448 + 2 * k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 512 + k], qmf_c[512 + 2 * k]) +
+ MUL_F(qmfs->v[qmfs->v_index + 608 + k], qmf_c[576 + 2 * k]);
+ }
+
+ /* 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_NTSRHFG][64],
+ real_t *output)
+{
+ // ALIGN real_t x1[64], x2[64];
+#ifndef SBR_LOW_POWER
+ ALIGN real_t in_real1[32], in_imag1[32], out_real1[32], out_imag1[32];
+ ALIGN real_t in_real2[32], in_imag2[32], out_real2[32], out_imag2[32];
+#endif
+ qmf_t * pX;
+ real_t * pring_buffer_1, * pring_buffer_3;
+ // real_t * ptemp_1, * ptemp_2;
+#ifdef PREFER_POINTERS
+ // These pointers are used if target platform has autoinc address generators
+ real_t * pring_buffer_2, * pring_buffer_4;
+ real_t * pring_buffer_5, * pring_buffer_6;
+ real_t * pring_buffer_7, * pring_buffer_8;
+ real_t * pring_buffer_9, * pring_buffer_10;
+ const real_t * pqmf_c_1, * pqmf_c_2, * pqmf_c_3, * pqmf_c_4;
+ const real_t * pqmf_c_5, * pqmf_c_6, * pqmf_c_7, * pqmf_c_8;
+ const real_t * pqmf_c_9, * pqmf_c_10;
+#endif // #ifdef PREFER_POINTERS
+#ifndef FIXED_POINT
+ real_t scale = 1.f / 64.f;
+#endif
+ int32_t n, k, out = 0;
+ uint8_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 */
+#ifndef FIXED_POINT
+
+ pX = X[l];
+
+ in_imag1[31] = scale * QMF_RE(pX[1]);
+ in_real1[0] = scale * QMF_RE(pX[0]);
+ in_imag2[31] = scale * QMF_IM(pX[63 - 1]);
+ in_real2[0] = scale * QMF_IM(pX[63 - 0]);
+ for (k = 1; k < 31; k++) {
+ in_imag1[31 - k] = scale * QMF_RE(pX[2 * k + 1]);
+ in_real1[ k] = scale * QMF_RE(pX[2 * k ]);
+ in_imag2[31 - k] = scale * QMF_IM(pX[63 - (2 * k + 1)]);
+ in_real2[ k] = scale * QMF_IM(pX[63 - (2 * k)]);
+ }
+ in_imag1[0] = scale * QMF_RE(pX[63]);
+ in_real1[31] = scale * QMF_RE(pX[62]);
+ in_imag2[0] = scale * QMF_IM(pX[63 - 63]);
+ in_real2[31] = scale * QMF_IM(pX[63 - 62]);
+
+#else
+
+ pX = X[l];
+
+ in_imag1[31] = QMF_RE(pX[1]) >> 1;
+ in_real1[0] = QMF_RE(pX[0]) >> 1;
+ in_imag2[31] = QMF_IM(pX[62]) >> 1;
+ in_real2[0] = QMF_IM(pX[63]) >> 1;
+ for (k = 1; k < 31; k++) {
+ in_imag1[31 - k] = QMF_RE(pX[2 * k + 1]) >> 1;
+ in_real1[ k] = QMF_RE(pX[2 * k ]) >> 1;
+ in_imag2[31 - k] = QMF_IM(pX[63 - (2 * k + 1)]) >> 1;
+ in_real2[ k] = QMF_IM(pX[63 - (2 * k)]) >> 1;
+ }
+ in_imag1[0] = QMF_RE(pX[63]) >> 1;
+ in_real1[31] = QMF_RE(pX[62]) >> 1;
+ in_imag2[0] = QMF_IM(pX[0]) >> 1;
+ in_real2[31] = QMF_IM(pX[1]) >> 1;
+
+#endif
+
+
+ // dct4_kernel is DCT_IV without reordering which is done before and after FFT
+ dct4_kernel(in_real1, in_imag1, out_real1, out_imag1);
+ dct4_kernel(in_real2, in_imag2, out_real2, out_imag2);
+
+
+ pring_buffer_1 = qmfs->v + qmfs->v_index;
+ pring_buffer_3 = pring_buffer_1 + 1280;
+#ifdef PREFER_POINTERS
+ pring_buffer_2 = pring_buffer_1 + 127;
+ pring_buffer_4 = pring_buffer_1 + (1280 + 127);
+#endif // #ifdef PREFER_POINTERS
+ // ptemp_1 = x1;
+ // ptemp_2 = x2;
+#ifdef PREFER_POINTERS
+ for (n = 0; n < 32; n ++) {
+ //real_t x1 = *ptemp_1++;
+ //real_t x2 = *ptemp_2++;
+ // pring_buffer_3 and pring_buffer_4 are needed only for double ring buffer
+ *pring_buffer_1++ = *pring_buffer_3++ = out_real2[n] - out_real1[n];
+ *pring_buffer_2-- = *pring_buffer_4-- = out_real2[n] + out_real1[n];
+ //x1 = *ptemp_1++;
+ //x2 = *ptemp_2++;
+ *pring_buffer_1++ = *pring_buffer_3++ = out_imag2[31 - n] + out_imag1[31 - n];
+ *pring_buffer_2-- = *pring_buffer_4-- = out_imag2[31 - n] - out_imag1[31 - n];
+ }
+#else // #ifdef PREFER_POINTERS
+
+ for (n = 0; n < 32; n++) {
+ // pring_buffer_3 and pring_buffer_4 are needed only for double ring buffer
+ pring_buffer_1[2 * n] = pring_buffer_3[2 * n] = out_real2[n] - out_real1[n];
+ pring_buffer_1[127 - 2 * n] = pring_buffer_3[127 - 2 * n] = out_real2[n] + out_real1[n];
+ pring_buffer_1[2 * n + 1] = pring_buffer_3[2 * n + 1] = out_imag2[31 - n] + out_imag1[31 - n];
+ pring_buffer_1[127 - (2 * n + 1)] = pring_buffer_3[127 - (2 * n + 1)] = out_imag2[31 - n] - out_imag1[31 - n];
+ }
+
+#endif // #ifdef PREFER_POINTERS
+
+ pring_buffer_1 = qmfs->v + qmfs->v_index;
+#ifdef PREFER_POINTERS
+ pring_buffer_2 = pring_buffer_1 + 192;
+ pring_buffer_3 = pring_buffer_1 + 256;
+ pring_buffer_4 = pring_buffer_1 + (256 + 192);
+ pring_buffer_5 = pring_buffer_1 + 512;
+ pring_buffer_6 = pring_buffer_1 + (512 + 192);
+ pring_buffer_7 = pring_buffer_1 + 768;
+ pring_buffer_8 = pring_buffer_1 + (768 + 192);
+ pring_buffer_9 = pring_buffer_1 + 1024;
+ pring_buffer_10 = pring_buffer_1 + (1024 + 192);
+ pqmf_c_1 = qmf_c;
+ pqmf_c_2 = qmf_c + 64;
+ pqmf_c_3 = qmf_c + 128;
+ pqmf_c_4 = qmf_c + 192;
+ pqmf_c_5 = qmf_c + 256;
+ pqmf_c_6 = qmf_c + 320;
+ pqmf_c_7 = qmf_c + 384;
+ pqmf_c_8 = qmf_c + 448;
+ pqmf_c_9 = qmf_c + 512;
+ pqmf_c_10 = qmf_c + 576;
+#endif // #ifdef PREFER_POINTERS
+
+ /* calculate 64 output samples and window */
+ for (k = 0; k < 64; k++) {
+#ifdef PREFER_POINTERS
+ output[out++] =
+ MUL_F(*pring_buffer_1++, *pqmf_c_1++) +
+ MUL_F(*pring_buffer_2++, *pqmf_c_2++) +
+ MUL_F(*pring_buffer_3++, *pqmf_c_3++) +
+ MUL_F(*pring_buffer_4++, *pqmf_c_4++) +
+ MUL_F(*pring_buffer_5++, *pqmf_c_5++) +
+ MUL_F(*pring_buffer_6++, *pqmf_c_6++) +
+ MUL_F(*pring_buffer_7++, *pqmf_c_7++) +
+ MUL_F(*pring_buffer_8++, *pqmf_c_8++) +
+ MUL_F(*pring_buffer_9++, *pqmf_c_9++) +
+ MUL_F(*pring_buffer_10++, *pqmf_c_10++);
+#else // #ifdef PREFER_POINTERS
+ output[out++] =
+ MUL_F(pring_buffer_1[k + 0], qmf_c[k + 0]) +
+ MUL_F(pring_buffer_1[k + 192], qmf_c[k + 64]) +
+ MUL_F(pring_buffer_1[k + 256], qmf_c[k + 128]) +
+ MUL_F(pring_buffer_1[k + (256 + 192)], qmf_c[k + 192]) +
+ MUL_F(pring_buffer_1[k + 512], qmf_c[k + 256]) +
+ MUL_F(pring_buffer_1[k + (512 + 192)], qmf_c[k + 320]) +
+ MUL_F(pring_buffer_1[k + 768], qmf_c[k + 384]) +
+ MUL_F(pring_buffer_1[k + (768 + 192)], qmf_c[k + 448]) +
+ MUL_F(pring_buffer_1[k + 1024], qmf_c[k + 512]) +
+ MUL_F(pring_buffer_1[k + (1024 + 192)], qmf_c[k + 576]);
+#endif // #ifdef PREFER_POINTERS
+ }
+
+ /* update ringbuffer index */
+ qmfs->v_index -= 128;
+ if (qmfs->v_index < 0) {
+ qmfs->v_index = (1280 - 128);
+ }
+ }
+}
+#endif
+
+#endif
diff --git a/audio_codec/libfaad/sbr_qmf.h b/audio_codec/libfaad/sbr_qmf.h
new file mode 100644
index 0000000..b4b8a8b
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_qmf.h
@@ -0,0 +1,55 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_qmf.h,v 1.25 2007/11/01 12:33:36 menno Exp $
+**/
+
+#ifndef __SBR_QMF_H__
+#define __SBR_QMF_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ qmfa_info *qmfa_init(uint8_t channels);
+ void qmfa_end(qmfa_info *qmfa);
+ qmfs_info *qmfs_init(uint8_t channels);
+ void qmfs_end(qmfs_info *qmfs);
+
+ void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
+ qmf_t X[MAX_NTSRHFG][64], uint8_t offset, uint8_t kx);
+ void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
+ real_t *output);
+ void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][64],
+ real_t *output);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/audio_codec/libfaad/sbr_qmf_c.h b/audio_codec/libfaad/sbr_qmf_c.h
new file mode 100644
index 0000000..e3bfdfd
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_qmf_c.h
@@ -0,0 +1,368 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_qmf_c.h,v 1.17 2007/11/01 12:33:36 menno Exp $
+**/
+
+#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
+
+ ALIGN static const real_t qmf_c[640] = {
+ FRAC_CONST(0), FRAC_CONST(-0.00055252865047),
+ FRAC_CONST(-0.00056176925738), FRAC_CONST(-0.00049475180896),
+ FRAC_CONST(-0.00048752279712), FRAC_CONST(-0.00048937912498),
+ FRAC_CONST(-0.00050407143497), FRAC_CONST(-0.00052265642972),
+ FRAC_CONST(-0.00054665656337), FRAC_CONST(-0.00056778025613),
+ FRAC_CONST(-0.00058709304852), FRAC_CONST(-0.00061327473938),
+ FRAC_CONST(-0.00063124935319), FRAC_CONST(-0.00065403333621),
+ FRAC_CONST(-0.00067776907764), FRAC_CONST(-0.00069416146273),
+ FRAC_CONST(-0.00071577364744), FRAC_CONST(-0.00072550431222),
+ FRAC_CONST(-0.00074409418541), FRAC_CONST(-0.00074905980532),
+ FRAC_CONST(-0.0007681371927), FRAC_CONST(-0.00077248485949),
+ FRAC_CONST(-0.00078343322877), FRAC_CONST(-0.00077798694927),
+ FRAC_CONST(-0.000780366471), FRAC_CONST(-0.00078014496257),
+ FRAC_CONST(-0.0007757977331), FRAC_CONST(-0.00076307935757),
+ FRAC_CONST(-0.00075300014201), FRAC_CONST(-0.00073193571525),
+ FRAC_CONST(-0.00072153919876), FRAC_CONST(-0.00069179375372),
+ FRAC_CONST(-0.00066504150893), FRAC_CONST(-0.00063415949025),
+ FRAC_CONST(-0.0005946118933), FRAC_CONST(-0.00055645763906),
+ FRAC_CONST(-0.00051455722108), FRAC_CONST(-0.00046063254803),
+ FRAC_CONST(-0.00040951214522), FRAC_CONST(-0.00035011758756),
+ FRAC_CONST(-0.00028969811748), FRAC_CONST(-0.0002098337344),
+ FRAC_CONST(-0.00014463809349), FRAC_CONST(-6.173344072E-005),
+ FRAC_CONST(1.349497418E-005), FRAC_CONST(0.00010943831274),
+ FRAC_CONST(0.00020430170688), FRAC_CONST(0.00029495311041),
+ FRAC_CONST(0.0004026540216), FRAC_CONST(0.00051073884952),
+ FRAC_CONST(0.00062393761391), FRAC_CONST(0.00074580258865),
+ FRAC_CONST(0.00086084433262), FRAC_CONST(0.00098859883015),
+ FRAC_CONST(0.00112501551307), FRAC_CONST(0.00125778846475),
+ FRAC_CONST(0.00139024948272), FRAC_CONST(0.00154432198471),
+ FRAC_CONST(0.00168680832531), FRAC_CONST(0.00183482654224),
+ FRAC_CONST(0.00198411407369), FRAC_CONST(0.00214615835557),
+ FRAC_CONST(0.00230172547746), FRAC_CONST(0.00246256169126),
+ FRAC_CONST(0.00262017586902), FRAC_CONST(0.00278704643465),
+ FRAC_CONST(0.00294694477165), FRAC_CONST(0.00311254206525),
+ FRAC_CONST(0.00327396134847), FRAC_CONST(0.00344188741828),
+ FRAC_CONST(0.00360082681231), FRAC_CONST(0.00376039229104),
+ FRAC_CONST(0.00392074323703), FRAC_CONST(0.00408197531935),
+ FRAC_CONST(0.0042264269227), FRAC_CONST(0.00437307196781),
+ FRAC_CONST(0.00452098527825), FRAC_CONST(0.00466064606118),
+ FRAC_CONST(0.00479325608498), FRAC_CONST(0.00491376035745),
+ FRAC_CONST(0.00503930226013), FRAC_CONST(0.00514073539032),
+ FRAC_CONST(0.00524611661324), FRAC_CONST(0.00534716811982),
+ FRAC_CONST(0.00541967759307), FRAC_CONST(0.00548760401507),
+ FRAC_CONST(0.00554757145088), FRAC_CONST(0.00559380230045),
+ FRAC_CONST(0.00562206432097), FRAC_CONST(0.00564551969164),
+ FRAC_CONST(0.00563891995151), FRAC_CONST(0.00562661141932),
+ FRAC_CONST(0.0055917128663), FRAC_CONST(0.005540436394),
+ FRAC_CONST(0.0054753783077), FRAC_CONST(0.0053838975897),
+ FRAC_CONST(0.00527157587272), FRAC_CONST(0.00513822754514),
+ FRAC_CONST(0.00498396877629), FRAC_CONST(0.004810946906),
+ FRAC_CONST(0.00460395301471), FRAC_CONST(0.00438018617447),
+ FRAC_CONST(0.0041251642327), FRAC_CONST(0.00384564081246),
+ FRAC_CONST(0.00354012465507), FRAC_CONST(0.00320918858098),
+ FRAC_CONST(0.00284467578623), FRAC_CONST(0.00245085400321),
+ FRAC_CONST(0.0020274176185), FRAC_CONST(0.00157846825768),
+ FRAC_CONST(0.00109023290512), FRAC_CONST(0.0005832264248),
+ FRAC_CONST(2.760451905E-005), FRAC_CONST(-0.00054642808664),
+ FRAC_CONST(-0.00115681355227), FRAC_CONST(-0.00180394725893),
+ FRAC_CONST(-0.00248267236449), FRAC_CONST(-0.003193377839),
+ FRAC_CONST(-0.00394011240522), FRAC_CONST(-0.004722259624),
+ FRAC_CONST(-0.00553372111088), FRAC_CONST(-0.00637922932685),
+ FRAC_CONST(-0.00726158168517), FRAC_CONST(-0.00817982333726),
+ FRAC_CONST(-0.00913253296085), FRAC_CONST(-0.01011502154986),
+ FRAC_CONST(-0.01113155480321), FRAC_CONST(-0.01218499959508),
+ FRAC_CONST(0.01327182200351), FRAC_CONST(0.01439046660792),
+ FRAC_CONST(0.01554055533423), FRAC_CONST(0.01673247129989),
+ FRAC_CONST(0.01794333813443), FRAC_CONST(0.01918724313698),
+ FRAC_CONST(0.02045317933555), FRAC_CONST(0.02174675502535),
+ FRAC_CONST(0.02306801692862), FRAC_CONST(0.02441609920285),
+ FRAC_CONST(0.02578758475467), FRAC_CONST(0.02718594296329),
+ FRAC_CONST(0.02860721736385), FRAC_CONST(0.03005026574279),
+ FRAC_CONST(0.03150176087389), FRAC_CONST(0.03297540810337),
+ FRAC_CONST(0.03446209487686), FRAC_CONST(0.03596975605542),
+ FRAC_CONST(0.03748128504252), FRAC_CONST(0.03900536794745),
+ FRAC_CONST(0.04053491705584), FRAC_CONST(0.04206490946367),
+ FRAC_CONST(0.04360975421304), FRAC_CONST(0.04514884056413),
+ FRAC_CONST(0.04668430272642), FRAC_CONST(0.04821657200672),
+ FRAC_CONST(0.04973857556014), FRAC_CONST(0.05125561555216),
+ FRAC_CONST(0.05276307465207), FRAC_CONST(0.05424527683589),
+ FRAC_CONST(0.05571736482138), FRAC_CONST(0.05716164501299),
+ FRAC_CONST(0.0585915683626), FRAC_CONST(0.05998374801761),
+ FRAC_CONST(0.06134551717207), FRAC_CONST(0.06268578081172),
+ FRAC_CONST(0.06397158980681), FRAC_CONST(0.0652247106438),
+ FRAC_CONST(0.06643675122104), FRAC_CONST(0.06760759851228),
+ FRAC_CONST(0.06870438283512), FRAC_CONST(0.06976302447127),
+ FRAC_CONST(0.07076287107266), FRAC_CONST(0.07170026731102),
+ FRAC_CONST(0.07256825833083), FRAC_CONST(0.07336202550803),
+ FRAC_CONST(0.07410036424342), FRAC_CONST(0.07474525581194),
+ FRAC_CONST(0.07531373362019), FRAC_CONST(0.07580083586584),
+ FRAC_CONST(0.07619924793396), FRAC_CONST(0.07649921704119),
+ FRAC_CONST(0.07670934904245), FRAC_CONST(0.07681739756964),
+ FRAC_CONST(0.07682300113923), FRAC_CONST(0.07672049241746),
+ FRAC_CONST(0.07650507183194), FRAC_CONST(0.07617483218536),
+ FRAC_CONST(0.07573057565061), FRAC_CONST(0.0751576255287),
+ FRAC_CONST(0.07446643947564), FRAC_CONST(0.0736406005762),
+ FRAC_CONST(0.07267746427299), FRAC_CONST(0.07158263647903),
+ FRAC_CONST(0.07035330735093), FRAC_CONST(0.06896640131951),
+ FRAC_CONST(0.06745250215166), FRAC_CONST(0.06576906686508),
+ FRAC_CONST(0.06394448059633), FRAC_CONST(0.06196027790387),
+ FRAC_CONST(0.0598166570809), FRAC_CONST(0.05751526919867),
+ FRAC_CONST(0.05504600343009), FRAC_CONST(0.05240938217366),
+ FRAC_CONST(0.04959786763445), FRAC_CONST(0.04663033051701),
+ FRAC_CONST(0.04347687821958), FRAC_CONST(0.04014582784127),
+ FRAC_CONST(0.03664181168133), FRAC_CONST(0.03295839306691),
+ FRAC_CONST(0.02908240060125), FRAC_CONST(0.02503075618909),
+ FRAC_CONST(0.02079970728622), FRAC_CONST(0.01637012582228),
+ FRAC_CONST(0.01176238327857), FRAC_CONST(0.00696368621617),
+ FRAC_CONST(0.00197656014503), FRAC_CONST(-0.00320868968304),
+ FRAC_CONST(-0.00857117491366), FRAC_CONST(-0.01412888273558),
+ FRAC_CONST(-0.01988341292573), FRAC_CONST(-0.02582272888064),
+ FRAC_CONST(-0.03195312745332), FRAC_CONST(-0.03827765720822),
+ FRAC_CONST(-0.04478068215856), FRAC_CONST(-0.05148041767934),
+ FRAC_CONST(-0.05837053268336), FRAC_CONST(-0.06544098531359),
+ FRAC_CONST(-0.07269433008129), FRAC_CONST(-0.08013729344279),
+ FRAC_CONST(-0.08775475365593), FRAC_CONST(-0.09555333528914),
+ FRAC_CONST(-0.10353295311463), FRAC_CONST(-0.1116826931773),
+ FRAC_CONST(-0.120007798468), FRAC_CONST(-0.12850028503878),
+ FRAC_CONST(-0.13715517611934), FRAC_CONST(-0.1459766491187),
+ FRAC_CONST(-0.15496070710605), FRAC_CONST(-0.16409588556669),
+ FRAC_CONST(-0.17338081721706), FRAC_CONST(-0.18281725485142),
+ FRAC_CONST(-0.19239667457267), FRAC_CONST(-0.20212501768103),
+ FRAC_CONST(-0.21197358538056), FRAC_CONST(-0.22196526964149),
+ FRAC_CONST(-0.23206908706791), FRAC_CONST(-0.24230168845974),
+ FRAC_CONST(-0.25264803095722), FRAC_CONST(-0.26310532994603),
+ FRAC_CONST(-0.27366340405625), FRAC_CONST(-0.28432141891085),
+ FRAC_CONST(-0.29507167170646), FRAC_CONST(-0.30590985751916),
+ FRAC_CONST(-0.31682789136456), FRAC_CONST(-0.32781137272105),
+ FRAC_CONST(-0.33887226938665), FRAC_CONST(-0.3499914122931),
+ FRAC_CONST(0.36115899031355), FRAC_CONST(0.37237955463061),
+ FRAC_CONST(0.38363500139043), FRAC_CONST(0.39492117615675),
+ FRAC_CONST(0.40623176767625), FRAC_CONST(0.41756968968409),
+ FRAC_CONST(0.42891199207373), FRAC_CONST(0.44025537543665),
+ FRAC_CONST(0.45159965356824), FRAC_CONST(0.46293080852757),
+ FRAC_CONST(0.47424532146115), FRAC_CONST(0.48552530911099),
+ FRAC_CONST(0.49677082545707), FRAC_CONST(0.50798175000434),
+ FRAC_CONST(0.51912349702391), FRAC_CONST(0.53022408956855),
+ FRAC_CONST(0.54125534487322), FRAC_CONST(0.55220512585061),
+ FRAC_CONST(0.5630789140137), FRAC_CONST(0.57385241316923),
+ FRAC_CONST(0.58454032354679), FRAC_CONST(0.59511230862496),
+ FRAC_CONST(0.6055783538918), FRAC_CONST(0.61591099320291),
+ FRAC_CONST(0.62612426956055), FRAC_CONST(0.63619801077286),
+ FRAC_CONST(0.64612696959461), FRAC_CONST(0.65590163024671),
+ FRAC_CONST(0.66551398801627), FRAC_CONST(0.67496631901712),
+ FRAC_CONST(0.68423532934598), FRAC_CONST(0.69332823767032),
+ FRAC_CONST(0.70223887193539), FRAC_CONST(0.71094104263095),
+ FRAC_CONST(0.71944626349561), FRAC_CONST(0.72774489002994),
+ FRAC_CONST(0.73582117582769), FRAC_CONST(0.74368278636488),
+ FRAC_CONST(0.75131374561237), FRAC_CONST(0.75870807608242),
+ FRAC_CONST(0.76586748650939), FRAC_CONST(0.77277808813327),
+ FRAC_CONST(0.77942875190216), FRAC_CONST(0.7858353120392),
+ FRAC_CONST(0.79197358416424), FRAC_CONST(0.797846641377),
+ FRAC_CONST(0.80344857518505), FRAC_CONST(0.80876950044491),
+ FRAC_CONST(0.81381912706217), FRAC_CONST(0.81857760046468),
+ FRAC_CONST(0.82304198905409), FRAC_CONST(0.8272275347336),
+ FRAC_CONST(0.8311038457152), FRAC_CONST(0.83469373618402),
+ FRAC_CONST(0.83797173378865), FRAC_CONST(0.84095413924722),
+ FRAC_CONST(0.84362382812005), FRAC_CONST(0.84598184698206),
+ FRAC_CONST(0.84803157770763), FRAC_CONST(0.84978051984268),
+ FRAC_CONST(0.85119715249343), FRAC_CONST(0.85230470352147),
+ FRAC_CONST(0.85310209497017), FRAC_CONST(0.85357205739107),
+ FRAC_CONST(0.85373856005937 /*max*/), FRAC_CONST(0.85357205739107),
+ FRAC_CONST(0.85310209497017), FRAC_CONST(0.85230470352147),
+ FRAC_CONST(0.85119715249343), FRAC_CONST(0.84978051984268),
+ FRAC_CONST(0.84803157770763), FRAC_CONST(0.84598184698206),
+ FRAC_CONST(0.84362382812005), FRAC_CONST(0.84095413924722),
+ FRAC_CONST(0.83797173378865), FRAC_CONST(0.83469373618402),
+ FRAC_CONST(0.8311038457152), FRAC_CONST(0.8272275347336),
+ FRAC_CONST(0.82304198905409), FRAC_CONST(0.81857760046468),
+ FRAC_CONST(0.81381912706217), FRAC_CONST(0.80876950044491),
+ FRAC_CONST(0.80344857518505), FRAC_CONST(0.797846641377),
+ FRAC_CONST(0.79197358416424), FRAC_CONST(0.7858353120392),
+ FRAC_CONST(0.77942875190216), FRAC_CONST(0.77277808813327),
+ FRAC_CONST(0.76586748650939), FRAC_CONST(0.75870807608242),
+ FRAC_CONST(0.75131374561237), FRAC_CONST(0.74368278636488),
+ FRAC_CONST(0.73582117582769), FRAC_CONST(0.72774489002994),
+ FRAC_CONST(0.71944626349561), FRAC_CONST(0.71094104263095),
+ FRAC_CONST(0.70223887193539), FRAC_CONST(0.69332823767032),
+ FRAC_CONST(0.68423532934598), FRAC_CONST(0.67496631901712),
+ FRAC_CONST(0.66551398801627), FRAC_CONST(0.65590163024671),
+ FRAC_CONST(0.64612696959461), FRAC_CONST(0.63619801077286),
+ FRAC_CONST(0.62612426956055), FRAC_CONST(0.61591099320291),
+ FRAC_CONST(0.6055783538918), FRAC_CONST(0.59511230862496),
+ FRAC_CONST(0.58454032354679), FRAC_CONST(0.57385241316923),
+ FRAC_CONST(0.5630789140137), FRAC_CONST(0.55220512585061),
+ FRAC_CONST(0.54125534487322), FRAC_CONST(0.53022408956855),
+ FRAC_CONST(0.51912349702391), FRAC_CONST(0.50798175000434),
+ FRAC_CONST(0.49677082545707), FRAC_CONST(0.48552530911099),
+ FRAC_CONST(0.47424532146115), FRAC_CONST(0.46293080852757),
+ FRAC_CONST(0.45159965356824), FRAC_CONST(0.44025537543665),
+ FRAC_CONST(0.42891199207373), FRAC_CONST(0.41756968968409),
+ FRAC_CONST(0.40623176767625), FRAC_CONST(0.39492117615675),
+ FRAC_CONST(0.38363500139043), FRAC_CONST(0.37237955463061),
+ FRAC_CONST(-0.36115899031355), FRAC_CONST(-0.3499914122931),
+ FRAC_CONST(-0.33887226938665), FRAC_CONST(-0.32781137272105),
+ FRAC_CONST(-0.31682789136456), FRAC_CONST(-0.30590985751916),
+ FRAC_CONST(-0.29507167170646), FRAC_CONST(-0.28432141891085),
+ FRAC_CONST(-0.27366340405625), FRAC_CONST(-0.26310532994603),
+ FRAC_CONST(-0.25264803095722), FRAC_CONST(-0.24230168845974),
+ FRAC_CONST(-0.23206908706791), FRAC_CONST(-0.22196526964149),
+ FRAC_CONST(-0.21197358538056), FRAC_CONST(-0.20212501768103),
+ FRAC_CONST(-0.19239667457267), FRAC_CONST(-0.18281725485142),
+ FRAC_CONST(-0.17338081721706), FRAC_CONST(-0.16409588556669),
+ FRAC_CONST(-0.15496070710605), FRAC_CONST(-0.1459766491187),
+ FRAC_CONST(-0.13715517611934), FRAC_CONST(-0.12850028503878),
+ FRAC_CONST(-0.120007798468), FRAC_CONST(-0.1116826931773),
+ FRAC_CONST(-0.10353295311463), FRAC_CONST(-0.09555333528914),
+ FRAC_CONST(-0.08775475365593), FRAC_CONST(-0.08013729344279),
+ FRAC_CONST(-0.07269433008129), FRAC_CONST(-0.06544098531359),
+ FRAC_CONST(-0.05837053268336), FRAC_CONST(-0.05148041767934),
+ FRAC_CONST(-0.04478068215856), FRAC_CONST(-0.03827765720822),
+ FRAC_CONST(-0.03195312745332), FRAC_CONST(-0.02582272888064),
+ FRAC_CONST(-0.01988341292573), FRAC_CONST(-0.01412888273558),
+ FRAC_CONST(-0.00857117491366), FRAC_CONST(-0.00320868968304),
+ FRAC_CONST(0.00197656014503), FRAC_CONST(0.00696368621617),
+ FRAC_CONST(0.01176238327857), FRAC_CONST(0.01637012582228),
+ FRAC_CONST(0.02079970728622), FRAC_CONST(0.02503075618909),
+ FRAC_CONST(0.02908240060125), FRAC_CONST(0.03295839306691),
+ FRAC_CONST(0.03664181168133), FRAC_CONST(0.04014582784127),
+ FRAC_CONST(0.04347687821958), FRAC_CONST(0.04663033051701),
+ FRAC_CONST(0.04959786763445), FRAC_CONST(0.05240938217366),
+ FRAC_CONST(0.05504600343009), FRAC_CONST(0.05751526919867),
+ FRAC_CONST(0.0598166570809), FRAC_CONST(0.06196027790387),
+ FRAC_CONST(0.06394448059633), FRAC_CONST(0.06576906686508),
+ FRAC_CONST(0.06745250215166), FRAC_CONST(0.06896640131951),
+ FRAC_CONST(0.07035330735093), FRAC_CONST(0.07158263647903),
+ FRAC_CONST(0.07267746427299), FRAC_CONST(0.0736406005762),
+ FRAC_CONST(0.07446643947564), FRAC_CONST(0.0751576255287),
+ FRAC_CONST(0.07573057565061), FRAC_CONST(0.07617483218536),
+ FRAC_CONST(0.07650507183194), FRAC_CONST(0.07672049241746),
+ FRAC_CONST(0.07682300113923), FRAC_CONST(0.07681739756964),
+ FRAC_CONST(0.07670934904245), FRAC_CONST(0.07649921704119),
+ FRAC_CONST(0.07619924793396), FRAC_CONST(0.07580083586584),
+ FRAC_CONST(0.07531373362019), FRAC_CONST(0.07474525581194),
+ FRAC_CONST(0.07410036424342), FRAC_CONST(0.07336202550803),
+ FRAC_CONST(0.07256825833083), FRAC_CONST(0.07170026731102),
+ FRAC_CONST(0.07076287107266), FRAC_CONST(0.06976302447127),
+ FRAC_CONST(0.06870438283512), FRAC_CONST(0.06760759851228),
+ FRAC_CONST(0.06643675122104), FRAC_CONST(0.0652247106438),
+ FRAC_CONST(0.06397158980681), FRAC_CONST(0.06268578081172),
+ FRAC_CONST(0.06134551717207), FRAC_CONST(0.05998374801761),
+ FRAC_CONST(0.0585915683626), FRAC_CONST(0.05716164501299),
+ FRAC_CONST(0.05571736482138), FRAC_CONST(0.05424527683589),
+ FRAC_CONST(0.05276307465207), FRAC_CONST(0.05125561555216),
+ FRAC_CONST(0.04973857556014), FRAC_CONST(0.04821657200672),
+ FRAC_CONST(0.04668430272642), FRAC_CONST(0.04514884056413),
+ FRAC_CONST(0.04360975421304), FRAC_CONST(0.04206490946367),
+ FRAC_CONST(0.04053491705584), FRAC_CONST(0.03900536794745),
+ FRAC_CONST(0.03748128504252), FRAC_CONST(0.03596975605542),
+ FRAC_CONST(0.03446209487686), FRAC_CONST(0.03297540810337),
+ FRAC_CONST(0.03150176087389), FRAC_CONST(0.03005026574279),
+ FRAC_CONST(0.02860721736385), FRAC_CONST(0.02718594296329),
+ FRAC_CONST(0.02578758475467), FRAC_CONST(0.02441609920285),
+ FRAC_CONST(0.02306801692862), FRAC_CONST(0.02174675502535),
+ FRAC_CONST(0.02045317933555), FRAC_CONST(0.01918724313698),
+ FRAC_CONST(0.01794333813443), FRAC_CONST(0.01673247129989),
+ FRAC_CONST(0.01554055533423), FRAC_CONST(0.01439046660792),
+ FRAC_CONST(-0.01327182200351), FRAC_CONST(-0.01218499959508),
+ FRAC_CONST(-0.01113155480321), FRAC_CONST(-0.01011502154986),
+ FRAC_CONST(-0.00913253296085), FRAC_CONST(-0.00817982333726),
+ FRAC_CONST(-0.00726158168517), FRAC_CONST(-0.00637922932685),
+ FRAC_CONST(-0.00553372111088), FRAC_CONST(-0.004722259624),
+ FRAC_CONST(-0.00394011240522), FRAC_CONST(-0.003193377839),
+ FRAC_CONST(-0.00248267236449), FRAC_CONST(-0.00180394725893),
+ FRAC_CONST(-0.00115681355227), FRAC_CONST(-0.00054642808664),
+ FRAC_CONST(2.760451905E-005), FRAC_CONST(0.0005832264248),
+ FRAC_CONST(0.00109023290512), FRAC_CONST(0.00157846825768),
+ FRAC_CONST(0.0020274176185), FRAC_CONST(0.00245085400321),
+ FRAC_CONST(0.00284467578623), FRAC_CONST(0.00320918858098),
+ FRAC_CONST(0.00354012465507), FRAC_CONST(0.00384564081246),
+ FRAC_CONST(0.0041251642327), FRAC_CONST(0.00438018617447),
+ FRAC_CONST(0.00460395301471), FRAC_CONST(0.004810946906),
+ FRAC_CONST(0.00498396877629), FRAC_CONST(0.00513822754514),
+ FRAC_CONST(0.00527157587272), FRAC_CONST(0.0053838975897),
+ FRAC_CONST(0.0054753783077), FRAC_CONST(0.005540436394),
+ FRAC_CONST(0.0055917128663), FRAC_CONST(0.00562661141932),
+ FRAC_CONST(0.00563891995151), FRAC_CONST(0.00564551969164),
+ FRAC_CONST(0.00562206432097), FRAC_CONST(0.00559380230045),
+ FRAC_CONST(0.00554757145088), FRAC_CONST(0.00548760401507),
+ FRAC_CONST(0.00541967759307), FRAC_CONST(0.00534716811982),
+ FRAC_CONST(0.00524611661324), FRAC_CONST(0.00514073539032),
+ FRAC_CONST(0.00503930226013), FRAC_CONST(0.00491376035745),
+ FRAC_CONST(0.00479325608498), FRAC_CONST(0.00466064606118),
+ FRAC_CONST(0.00452098527825), FRAC_CONST(0.00437307196781),
+ FRAC_CONST(0.0042264269227), FRAC_CONST(0.00408197531935),
+ FRAC_CONST(0.00392074323703), FRAC_CONST(0.00376039229104),
+ FRAC_CONST(0.00360082681231), FRAC_CONST(0.00344188741828),
+ FRAC_CONST(0.00327396134847), FRAC_CONST(0.00311254206525),
+ FRAC_CONST(0.00294694477165), FRAC_CONST(0.00278704643465),
+ FRAC_CONST(0.00262017586902), FRAC_CONST(0.00246256169126),
+ FRAC_CONST(0.00230172547746), FRAC_CONST(0.00214615835557),
+ FRAC_CONST(0.00198411407369), FRAC_CONST(0.00183482654224),
+ FRAC_CONST(0.00168680832531), FRAC_CONST(0.00154432198471),
+ FRAC_CONST(0.00139024948272), FRAC_CONST(0.00125778846475),
+ FRAC_CONST(0.00112501551307), FRAC_CONST(0.00098859883015),
+ FRAC_CONST(0.00086084433262), FRAC_CONST(0.00074580258865),
+ FRAC_CONST(0.00062393761391), FRAC_CONST(0.00051073884952),
+ FRAC_CONST(0.0004026540216), FRAC_CONST(0.00029495311041),
+ FRAC_CONST(0.00020430170688), FRAC_CONST(0.00010943831274),
+ FRAC_CONST(1.349497418E-005), FRAC_CONST(-6.173344072E-005),
+ FRAC_CONST(-0.00014463809349), FRAC_CONST(-0.0002098337344),
+ FRAC_CONST(-0.00028969811748), FRAC_CONST(-0.00035011758756),
+ FRAC_CONST(-0.00040951214522), FRAC_CONST(-0.00046063254803),
+ FRAC_CONST(-0.00051455722108), FRAC_CONST(-0.00055645763906),
+ FRAC_CONST(-0.0005946118933), FRAC_CONST(-0.00063415949025),
+ FRAC_CONST(-0.00066504150893), FRAC_CONST(-0.00069179375372),
+ FRAC_CONST(-0.00072153919876), FRAC_CONST(-0.00073193571525),
+ FRAC_CONST(-0.00075300014201), FRAC_CONST(-0.00076307935757),
+ FRAC_CONST(-0.0007757977331), FRAC_CONST(-0.00078014496257),
+ FRAC_CONST(-0.000780366471), FRAC_CONST(-0.00077798694927),
+ FRAC_CONST(-0.00078343322877), FRAC_CONST(-0.00077248485949),
+ FRAC_CONST(-0.0007681371927), FRAC_CONST(-0.00074905980532),
+ FRAC_CONST(-0.00074409418541), FRAC_CONST(-0.00072550431222),
+ FRAC_CONST(-0.00071577364744), FRAC_CONST(-0.00069416146273),
+ FRAC_CONST(-0.00067776907764), FRAC_CONST(-0.00065403333621),
+ FRAC_CONST(-0.00063124935319), FRAC_CONST(-0.00061327473938),
+ FRAC_CONST(-0.00058709304852), FRAC_CONST(-0.00056778025613),
+ FRAC_CONST(-0.00054665656337), FRAC_CONST(-0.00052265642972),
+ FRAC_CONST(-0.00050407143497), FRAC_CONST(-0.00048937912498),
+ FRAC_CONST(-0.00048752279712), FRAC_CONST(-0.00049475180896),
+ FRAC_CONST(-0.00056176925738), FRAC_CONST(-0.00055252865047)
+ };
+
+#endif
+
diff --git a/audio_codec/libfaad/sbr_syntax.c b/audio_codec/libfaad/sbr_syntax.c
new file mode 100644
index 0000000..833c917
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_syntax.c
@@ -0,0 +1,893 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_syntax.c,v 1.39 2009/01/26 22:32:31 menno Exp $
+**/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+
+#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 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 psResetFlag)
+{
+ uint8_t result = 0;
+ uint16_t num_align_bits = 0;
+ uint16_t num_sbr_bits1 = (uint16_t)faad_get_processed_bits(ld);
+ uint16_t num_sbr_bits2;
+
+ uint8_t saved_start_freq, saved_samplerate_mode;
+ uint8_t saved_stop_freq, saved_freq_scale;
+ uint8_t saved_alter_scale, saved_xover_band;
+
+#if (defined(PS_DEC) || defined(DRM_PS))
+ if (psResetFlag) {
+ sbr->psResetFlag = psResetFlag;
+ }
+#endif
+
+#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, */
+ /* but practise indicates this doesn't work well */
+ }
+ } else {
+ result = 1;
+ }
+
+ num_sbr_bits2 = (uint16_t)faad_get_processed_bits(ld) - num_sbr_bits1;
+
+ /* check if we read more bits then were available for sbr */
+ if (8 * cnt < num_sbr_bits2) {
+ faad_resetbits(ld, num_sbr_bits1 + 8 * cnt);
+ num_sbr_bits2 = 8 * cnt;
+
+#ifdef PS_DEC
+ /* turn off PS for the unfortunate case that we randomly read some
+ * PS data that looks correct */
+ sbr->ps_used = 0;
+#endif
+
+ /* Make sure it doesn't decode SBR in this frame, or we'll get glitches */
+ return 1;
+ }
+
+#ifdef DRM
+ if (!sbr->Is_DRM_SBR)
+#endif
+ {
+ /* -4 does not apply, bs_extension_type is re-read in this function */
+ num_align_bits = 8 * cnt /*- 4*/ - num_sbr_bits2;
+
+ 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() */
+#ifdef DRM
+ return 1;
+#else
+ sbr->bs_extension_id = 3;
+#endif
+ }
+ }
+#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
+
+ switch (bs_extension_id) {
+#ifdef PS_DEC
+ case EXTENSION_ID_PS:
+ if (!sbr->ps) {
+ sbr->ps = ps_init(get_sr_index(sbr->sample_rate), sbr->numTimeSlotsRate);
+ }
+ if (sbr->psResetFlag) {
+ sbr->ps->header_read = 0;
+ }
+ 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;
+ }
+
+ if (header == 1) {
+ sbr->psResetFlag = 0;
+ }
+
+ 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/audio_codec/libfaad/sbr_syntax.h b/audio_codec/libfaad/sbr_syntax.h
new file mode 100644
index 0000000..fd39934
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_syntax.h
@@ -0,0 +1,68 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_syntax.h,v 1.23 2007/11/01 12:33:36 menno Exp $
+**/
+
+#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,
+ uint8_t resetFlag);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __SBR_SYNTAX_H__ */
+
diff --git a/audio_codec/libfaad/sbr_tf_grid.c b/audio_codec/libfaad/sbr_tf_grid.c
new file mode 100644
index 0000000..00fcc16
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_tf_grid.c
@@ -0,0 +1,247 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_tf_grid.c,v 1.20 2008/09/19 22:50:20 menno Exp $
+**/
+
+/* Time/Frequency grid */
+#include <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+#ifdef SBR_DEC
+
+
+#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, border, temp;
+ 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 = (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 * (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/audio_codec/libfaad/sbr_tf_grid.h b/audio_codec/libfaad/sbr_tf_grid.h
new file mode 100644
index 0000000..009e095
--- a/dev/null
+++ b/audio_codec/libfaad/sbr_tf_grid.h
@@ -0,0 +1,47 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_tf_grid.h,v 1.17 2007/11/01 12:33:36 menno Exp $
+**/
+
+#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/audio_codec/libfaad/sine_win.h b/audio_codec/libfaad/sine_win.h
new file mode 100644
index 0000000..e0eec0c
--- a/dev/null
+++ b/audio_codec/libfaad/sine_win.h
@@ -0,0 +1,4296 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sine_win.h,v 1.19 2007/11/01 12:33:36 menno Exp $
+**/
+
+#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
+
+ ALIGN static const real_t sine_long_1024[] = {
+ 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
+ ALIGN static const real_t sine_long_960[] = {
+ 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
+
+ ALIGN static const real_t sine_short_128[] = {
+ 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
+ ALIGN static const real_t sine_short_120[] = {
+ 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
+ ALIGN static const real_t sine_mid_512[] = {
+ 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
+ ALIGN static const real_t sine_mid_480[] = {
+ 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
+
+ ALIGN static const real_t ld_mid_512[] = {
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ 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
+ ALIGN static const real_t ld_mid_480[] = {
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ FRAC_CONST(0),
+ 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/audio_codec/libfaad/specrec.c b/audio_codec/libfaad/specrec.c
new file mode 100644
index 0000000..cc09800
--- a/dev/null
+++ b/audio_codec/libfaad/specrec.c
@@ -0,0 +1,1249 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: specrec.c,v 1.62 2009/01/26 23:51:15 menno Exp $
+**/
+
+/*
+ Spectral reconstruction:
+ - grouping/sectioning
+ - inverse quantization
+ - applying scalefactors
+*/
+#include <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+#include <string.h>
+#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(NeAACDecStruct *hDecoder,
+ ic_stream *ics, int16_t *quant_data,
+ real_t *spec_data, uint16_t frame_len);
+
+
+#ifdef LD_DEC
+ALIGN static const uint8_t num_swb_512_window[] = {
+ 0, 0, 0, 36, 36, 37, 31, 31, 0, 0, 0, 0
+};
+ALIGN static const uint8_t num_swb_480_window[] = {
+ 0, 0, 0, 35, 35, 37, 30, 30, 0, 0, 0, 0
+};
+#endif
+
+ALIGN static const uint8_t num_swb_960_window[] = {
+ 40, 40, 45, 49, 49, 49, 46, 46, 42, 42, 42, 40
+};
+
+ALIGN static const uint8_t num_swb_1024_window[] = {
+ 41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40
+};
+
+ALIGN static const uint8_t num_swb_128_window[] = {
+ 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15
+};
+
+ALIGN 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
+};
+
+ALIGN static const uint16_t swb_offset_128_96[] = {
+ 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128
+};
+
+ALIGN 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
+};
+
+ALIGN static const uint16_t swb_offset_128_64[] = {
+ 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128
+};
+
+ALIGN static const uint16_t swb_offset_1024_48[] = {
+ 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
+ALIGN 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
+};
+
+ALIGN 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
+
+ALIGN static const uint16_t swb_offset_128_48[] = {
+ 0, 4, 8, 12, 16, 20, 28, 36, 44, 56, 68, 80, 96, 112, 128
+};
+
+ALIGN static const uint16_t swb_offset_1024_32[] = {
+ 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
+ALIGN 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
+};
+
+ALIGN 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
+
+ALIGN static const uint16_t swb_offset_1024_24[] = {
+ 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
+ALIGN 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
+};
+
+ALIGN 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
+
+ALIGN static const uint16_t swb_offset_128_24[] = {
+ 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 64, 76, 92, 108, 128
+};
+
+ALIGN static const uint16_t swb_offset_1024_16[] = {
+ 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
+};
+
+ALIGN static const uint16_t swb_offset_128_16[] = {
+ 0, 4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 60, 72, 88, 108, 128
+};
+
+ALIGN static const uint16_t swb_offset_1024_8[] = {
+ 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
+};
+
+ALIGN static const uint16_t swb_offset_128_8[] = {
+ 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 128
+};
+
+ALIGN static const uint16_t *swb_offset_1024_window[] = {
+ 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
+ALIGN 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 */
+};
+
+ALIGN 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
+
+ALIGN static const uint16_t *swb_offset_128_window[] = {
+ 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)))
+
+/* 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(NeAACDecStruct *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
+
+ if (ics->max_sfb > ics->num_swb) {
+ return 32;
+ }
+
+ /* 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;
+ ics->swb_offset_max = 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;
+ ics->swb_offset_max = 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];
+
+ if (ics->max_sfb > ics->num_swb) {
+ return 32;
+ }
+
+ 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;
+ ics->swb_offset_max = 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 32;
+ }
+}
+
+/* iquant() *
+/* output = sign(input)*abs(input)^(4/3) */
+/**/
+static INLINE real_t iquant(int16_t q, const real_t *tab, uint8_t *error)
+{
+#ifdef FIXED_POINT
+ /* 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
+ */
+#ifndef BIG_IQ_TABLE
+ 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;
+#endif
+ 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];
+ }
+
+#ifndef BIG_IQ_TABLE
+ 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
+ *error = 17;
+ return 0;
+#endif
+
+#else
+ if (q < 0) {
+ /* tab contains a value for all possible q [0,8192] */
+ if (-q < IQ_TABLE_SIZE) {
+ return -tab[-q];
+ }
+
+ *error = 17;
+ return 0;
+ } else {
+ /* tab contains a value for all possible q [0,8192] */
+ if (q < IQ_TABLE_SIZE) {
+ return tab[q];
+ }
+
+ *error = 17;
+ return 0;
+ }
+#endif
+}
+
+#ifndef FIXED_POINT
+ALIGN 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 uint8_t quant_to_spec(NeAACDecStruct *hDecoder,
+ ic_stream *ics, int16_t *quant_data,
+ real_t *spec_data, uint16_t frame_len)
+{
+ ALIGN static const real_t pow2_table[] = {
+ COEF_CONST(1.0),
+ COEF_CONST(1.1892071150027210667174999705605), /* 2^0.25 */
+ COEF_CONST(1.4142135623730950488016887242097), /* 2^0.5 */
+ COEF_CONST(1.6817928305074290860622509524664) /* 2^0.75 */
+ };
+ const real_t *tab = iq_table;
+
+ uint8_t g, sfb, win;
+ uint16_t width, bin, k, gindex, wa, wb;
+ uint8_t error = 0; /* Init error flag */
+#ifndef FIXED_POINT
+ real_t scf;
+#endif
+
+ 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];
+#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
+ real_t iq0 = iquant(quant_data[k + 0], tab, &error);
+ real_t iq1 = iquant(quant_data[k + 1], tab, &error);
+ real_t iq2 = iquant(quant_data[k + 2], tab, &error);
+ real_t iq3 = iquant(quant_data[k + 3], tab, &error);
+
+ wb = wa + bin;
+
+ if (exp < 0) {
+ spec_data[wb + 0] = iq0 >>= -exp;
+ spec_data[wb + 1] = iq1 >>= -exp;
+ spec_data[wb + 2] = iq2 >>= -exp;
+ spec_data[wb + 3] = iq3 >>= -exp;
+ } else {
+ spec_data[wb + 0] = iq0 <<= exp;
+ spec_data[wb + 1] = iq1 <<= exp;
+ spec_data[wb + 2] = iq2 <<= exp;
+ spec_data[wb + 3] = iq3 <<= exp;
+ }
+ if (frac != 0) {
+ spec_data[wb + 0] = MUL_C(spec_data[wb + 0], pow2_table[frac]);
+ spec_data[wb + 1] = MUL_C(spec_data[wb + 1], pow2_table[frac]);
+ spec_data[wb + 2] = MUL_C(spec_data[wb + 2], pow2_table[frac]);
+ spec_data[wb + 3] = MUL_C(spec_data[wb + 3], pow2_table[frac]);
+ }
+
+ //#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(NeAACDecStruct *hDecoder, uint8_t channel,
+ uint8_t output_channels)
+{
+ int mul = 1;
+
+#ifdef MAIN_DEC
+ /* MAIN object type prediction */
+ if (hDecoder->object_type == MAIN) {
+ /* allocate the state only when needed */
+ if (hDecoder->pred_stat[channel] != NULL) {
+ faad_free(hDecoder->pred_stat[channel]);
+ hDecoder->pred_stat[channel] = NULL;
+ }
+
+ hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state));
+ reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength);
+ }
+#endif
+
+#ifdef LTP_DEC
+ if (is_ltp_ot(hDecoder->object_type)) {
+ /* allocate the state only when needed */
+ if (hDecoder->lt_pred_stat[channel] != NULL) {
+ faad_free(hDecoder->lt_pred_stat[channel]);
+ hDecoder->lt_pred_stat[channel] = NULL;
+ }
+
+ hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength * 4 * sizeof(int16_t));
+ memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength * 4 * sizeof(int16_t));
+ }
+#endif
+
+ if (hDecoder->time_out[channel] != NULL) {
+ faad_free(hDecoder->time_out[channel]);
+ hDecoder->time_out[channel] = NULL;
+ }
+
+ {
+ mul = 1;
+#ifdef SBR_DEC
+ hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0;
+ if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) {
+ /* SBR requires 2 times as much output data */
+ mul = 2;
+ hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
+ }
+#endif
+ hDecoder->time_out[channel] = (real_t*)faad_malloc(mul * hDecoder->frameLength * sizeof(real_t));
+ memset(hDecoder->time_out[channel], 0, mul * hDecoder->frameLength * sizeof(real_t));
+ }
+
+#if (defined(PS_DEC) || defined(DRM_PS))
+ if (output_channels == 2) {
+ if (hDecoder->time_out[channel + 1] != NULL) {
+ faad_free(hDecoder->time_out[channel + 1]);
+ hDecoder->time_out[channel + 1] = NULL;
+ }
+
+ hDecoder->time_out[channel + 1] = (real_t*)faad_malloc(mul * hDecoder->frameLength * sizeof(real_t));
+ memset(hDecoder->time_out[channel + 1], 0, mul * hDecoder->frameLength * sizeof(real_t));
+ }
+#endif
+
+ if (hDecoder->fb_intermed[channel] != NULL) {
+ faad_free(hDecoder->fb_intermed[channel]);
+ hDecoder->fb_intermed[channel] = NULL;
+ }
+
+ hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength * sizeof(real_t));
+ memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength * sizeof(real_t));
+
+#ifdef SSR_DEC
+ if (hDecoder->object_type == SSR) {
+ if (hDecoder->ssr_overlap[channel] == NULL) {
+ hDecoder->ssr_overlap[channel] = (real_t*)faad_malloc(2 * hDecoder->frameLength * sizeof(real_t));
+ memset(hDecoder->ssr_overlap[channel], 0, 2 * hDecoder->frameLength * sizeof(real_t));
+ }
+ if (hDecoder->prev_fmd[channel] == NULL) {
+ uint16_t k;
+ hDecoder->prev_fmd[channel] = (real_t*)faad_malloc(2 * hDecoder->frameLength * sizeof(real_t));
+ for (k = 0; k < 2 * hDecoder->frameLength; k++) {
+ hDecoder->prev_fmd[channel][k] = REAL_CONST(-1);
+ }
+ }
+ }
+#endif
+
+ return 0;
+}
+
+static uint8_t allocate_channel_pair(NeAACDecStruct *hDecoder,
+ uint8_t channel, uint8_t paired_channel)
+{
+ int mul = 1;
+
+#ifdef MAIN_DEC
+ /* MAIN object type prediction */
+ if (hDecoder->object_type == MAIN) {
+ /* allocate the state only when needed */
+ if (hDecoder->pred_stat[channel] == NULL) {
+ hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state));
+ reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength);
+ }
+ if (hDecoder->pred_stat[paired_channel] == NULL) {
+ hDecoder->pred_stat[paired_channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state));
+ reset_all_predictors(hDecoder->pred_stat[paired_channel], hDecoder->frameLength);
+ }
+ }
+#endif
+
+#ifdef LTP_DEC
+ if (is_ltp_ot(hDecoder->object_type)) {
+ /* allocate the state only when needed */
+ if (hDecoder->lt_pred_stat[channel] == NULL) {
+ hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength * 4 * sizeof(int16_t));
+ memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength * 4 * sizeof(int16_t));
+ }
+ if (hDecoder->lt_pred_stat[paired_channel] == NULL) {
+ hDecoder->lt_pred_stat[paired_channel] = (int16_t*)faad_malloc(hDecoder->frameLength * 4 * sizeof(int16_t));
+ memset(hDecoder->lt_pred_stat[paired_channel], 0, hDecoder->frameLength * 4 * sizeof(int16_t));
+ }
+ }
+#endif
+
+ if (hDecoder->time_out[channel] == NULL) {
+ mul = 1;
+#ifdef SBR_DEC
+ hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0;
+ if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) {
+ /* SBR requires 2 times as much output data */
+ mul = 2;
+ hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
+ }
+#endif
+ hDecoder->time_out[channel] = (real_t*)faad_malloc(mul * hDecoder->frameLength * sizeof(real_t));
+ memset(hDecoder->time_out[channel], 0, mul * hDecoder->frameLength * sizeof(real_t));
+ }
+ if (hDecoder->time_out[paired_channel] == NULL) {
+ hDecoder->time_out[paired_channel] = (real_t*)faad_malloc(mul * hDecoder->frameLength * sizeof(real_t));
+ memset(hDecoder->time_out[paired_channel], 0, mul * hDecoder->frameLength * sizeof(real_t));
+ }
+
+ if (hDecoder->fb_intermed[channel] == NULL) {
+ hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength * sizeof(real_t));
+ memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength * sizeof(real_t));
+ }
+ if (hDecoder->fb_intermed[paired_channel] == NULL) {
+ hDecoder->fb_intermed[paired_channel] = (real_t*)faad_malloc(hDecoder->frameLength * sizeof(real_t));
+ memset(hDecoder->fb_intermed[paired_channel], 0, hDecoder->frameLength * sizeof(real_t));
+ }
+
+#ifdef SSR_DEC
+ if (hDecoder->object_type == SSR) {
+ if (hDecoder->ssr_overlap[cpe->channel] == NULL) {
+ hDecoder->ssr_overlap[cpe->channel] = (real_t*)faad_malloc(2 * hDecoder->frameLength * sizeof(real_t));
+ memset(hDecoder->ssr_overlap[cpe->channel], 0, 2 * hDecoder->frameLength * sizeof(real_t));
+ }
+ if (hDecoder->ssr_overlap[cpe->paired_channel] == NULL) {
+ hDecoder->ssr_overlap[cpe->paired_channel] = (real_t*)faad_malloc(2 * hDecoder->frameLength * sizeof(real_t));
+ memset(hDecoder->ssr_overlap[cpe->paired_channel], 0, 2 * hDecoder->frameLength * sizeof(real_t));
+ }
+ if (hDecoder->prev_fmd[cpe->channel] == NULL) {
+ uint16_t k;
+ hDecoder->prev_fmd[cpe->channel] = (real_t*)faad_malloc(2 * hDecoder->frameLength * sizeof(real_t));
+ for (k = 0; k < 2 * hDecoder->frameLength; k++) {
+ hDecoder->prev_fmd[cpe->channel][k] = REAL_CONST(-1);
+ }
+ }
+ if (hDecoder->prev_fmd[cpe->paired_channel] == NULL) {
+ uint16_t k;
+ hDecoder->prev_fmd[cpe->paired_channel] = (real_t*)faad_malloc(2 * hDecoder->frameLength * sizeof(real_t));
+ for (k = 0; k < 2 * hDecoder->frameLength; k++) {
+ hDecoder->prev_fmd[cpe->paired_channel][k] = REAL_CONST(-1);
+ }
+ }
+ }
+#endif
+
+ return 0;
+}
+
+uint8_t reconstruct_single_channel(NeAACDecStruct *hDecoder, ic_stream *ics,
+ element *sce, int16_t *spec_data)
+{
+ uint8_t retval;
+ int output_channels;
+ ALIGN real_t spec_coef[1024];
+
+#ifdef PROFILE
+ int64_t count = faad_get_ts();
+#endif
+
+
+ /* always allocate 2 channels, PS can always "suddenly" turn up */
+#if ( (defined(DRM) && defined(DRM_PS)) )
+ output_channels = 2;
+#elif defined(PS_DEC)
+ if (hDecoder->ps_used[hDecoder->fr_ch_ele]) {
+ output_channels = 2;
+ } else {
+ output_channels = 1;
+ }
+#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 */
+
+ /* this only happens if PS is actually found but not in the first frame
+ * this means that there is only 1 bitstream element!
+ */
+
+ /* reset the allocation */
+ hDecoder->element_alloced[hDecoder->fr_ch_ele] = 0;
+
+ hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels;
+
+ //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_coef, 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_coef, NULL, hDecoder->frameLength, 0, hDecoder->object_type,
+ &(hDecoder->__r1), &(hDecoder->__r2));
+
+#ifdef MAIN_DEC
+ /* MAIN object type prediction */
+ if (hDecoder->object_type == MAIN) {
+ if (!hDecoder->pred_stat[sce->channel]) {
+ return 33;
+ }
+
+ /* intra channel prediction */
+ ic_prediction(ics, spec_coef, 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_coef, 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_coef, 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_coef);
+ }
+ }
+
+ /* filter bank */
+#ifdef SSR_DEC
+ if (hDecoder->object_type != SSR) {
+#endif
+ ifilter_bank(hDecoder->fb, ics->window_sequence, ics->window_shape,
+ hDecoder->window_shape_prev[sce->channel], spec_coef,
+ 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_coef, 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]) {
+ int ele = hDecoder->fr_ch_ele;
+ int 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], 2 * get_sample_rate(hDecoder->sf_index),
+ hDecoder->downSampledSBR
+#ifdef DRM
+ , 0
+#endif
+ );
+ }
+
+ if (sce->ics1.window_sequence == EIGHT_SHORT_SEQUENCE) {
+ hDecoder->sbr[ele]->maxAACLine = 8 * min(sce->ics1.swb_offset[max(sce->ics1.max_sfb - 1, 0)], sce->ics1.swb_offset_max);
+ } else {
+ hDecoder->sbr[ele]->maxAACLine = min(sce->ics1.swb_offset[max(sce->ics1.max_sfb - 1, 0)], sce->ics1.swb_offset_max);
+ }
+
+ /* 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) &&
+ (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 2)) {
+ int ele = hDecoder->fr_ch_ele;
+ int ch = sce->channel;
+ int 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(NeAACDecStruct *hDecoder, ic_stream *ics1, ic_stream *ics2,
+ element *cpe, int16_t *spec_data1, int16_t *spec_data2)
+{
+ uint8_t retval;
+ ALIGN real_t spec_coef1[1024];
+ ALIGN real_t spec_coef2[1024];
+
+#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;
+ } else {
+ // 1ch --> 2ch aac stream, channel configuration mapping changed ,need reset decoder .mostly happened when channel num changed
+ if (hDecoder->fb_intermed[(uint8_t)cpe->paired_channel] == NULL) {
+ audio_codec_print("channel configure changed,need re-alloc the buffer\n");
+ return 34;
+ }
+ }
+
+ /* 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,
+ &(hDecoder->__r1), &(hDecoder->__r2));
+ } else {
+ pns_decode(ics1, NULL, spec_coef1, NULL, hDecoder->frameLength, 0, hDecoder->object_type,
+ &(hDecoder->__r1), &(hDecoder->__r2));
+ pns_decode(ics2, NULL, spec_coef2, NULL, hDecoder->frameLength, 0, hDecoder->object_type,
+ &(hDecoder->__r1), &(hDecoder->__r2));
+ }
+
+ /* 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(hDecoder->fb, 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(hDecoder->fb, 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]) {
+ int ele = hDecoder->fr_ch_ele;
+ int ch0 = cpe->channel;
+ int 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], 2 * get_sample_rate(hDecoder->sf_index),
+ hDecoder->downSampledSBR
+#ifdef DRM
+ , 0
+#endif
+ );
+ }
+
+ if (cpe->ics1.window_sequence == EIGHT_SHORT_SEQUENCE) {
+ hDecoder->sbr[ele]->maxAACLine = 8 * min(cpe->ics1.swb_offset[max(cpe->ics1.max_sfb - 1, 0)], cpe->ics1.swb_offset_max);
+ } else {
+ hDecoder->sbr[ele]->maxAACLine = min(cpe->ics1.swb_offset[max(cpe->ics1.max_sfb - 1, 0)], cpe->ics1.swb_offset_max);
+ }
+
+ 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/audio_codec/libfaad/specrec.h b/audio_codec/libfaad/specrec.h
new file mode 100644
index 0000000..e81537e
--- a/dev/null
+++ b/audio_codec/libfaad/specrec.h
@@ -0,0 +1,49 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: specrec.h,v 1.33 2009/01/26 23:51:15 menno Exp $
+**/
+
+#ifndef __SPECREC_H__
+#define __SPECREC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "syntax.h"
+
+ uint8_t window_grouping_info(NeAACDecStruct *hDecoder, ic_stream *ics);
+ uint8_t reconstruct_channel_pair(NeAACDecStruct *hDecoder, ic_stream *ics1, ic_stream *ics2,
+ element *cpe, int16_t *spec_data1, int16_t *spec_data2);
+ uint8_t reconstruct_single_channel(NeAACDecStruct *hDecoder, ic_stream *ics, element *sce,
+ int16_t *spec_data);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/audio_codec/libfaad/ssr.c b/audio_codec/libfaad/ssr.c
new file mode 100644
index 0000000..d8bc2ed
--- a/dev/null
+++ b/audio_codec/libfaad/ssr.c
@@ -0,0 +1,170 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: ssr.c,v 1.19 2007/11/01 12:33:36 menno Exp $
+**/
+
+#include "common.h"
+#include "structs.h"
+
+#ifdef SSR_DEC
+
+#include "syntax.h"
+#include "filtbank.h"
+#include "ssr.h"
+#include "ssr_fb.h"
+
+void ssr_decode(ssr_info *ssr, fb_info *fb, uint8_t window_sequence,
+ uint8_t window_shape, uint8_t window_shape_prev,
+ real_t *freq_in, real_t *time_out, real_t *overlap,
+ real_t ipqf_buffer[SSR_BANDS][96 / 4],
+ real_t *prev_fmd, uint16_t frame_len)
+{
+ uint8_t band;
+ uint16_t ssr_frame_len = frame_len / SSR_BANDS;
+ real_t time_tmp[2048] = {0};
+ real_t output[1024] = {0};
+
+ for (band = 0; band < SSR_BANDS; band++) {
+ int16_t j;
+
+ /* uneven bands have inverted frequency scale */
+ if (band == 1 || band == 3) {
+ for (j = 0; j < ssr_frame_len / 2; j++) {
+ real_t tmp;
+ tmp = freq_in[j + ssr_frame_len * band];
+ freq_in[j + ssr_frame_len * band] =
+ freq_in[ssr_frame_len - j - 1 + ssr_frame_len * band];
+ freq_in[ssr_frame_len - j - 1 + ssr_frame_len * band] = tmp;
+ }
+ }
+
+ /* non-overlapping inverse filterbank for SSR */
+ ssr_ifilter_bank(fb, window_sequence, window_shape, window_shape_prev,
+ freq_in + band * ssr_frame_len, time_tmp + band * ssr_frame_len,
+ ssr_frame_len);
+
+ /* gain control */
+ ssr_gain_control(ssr, time_tmp, output, overlap, prev_fmd,
+ band, window_sequence, ssr_frame_len);
+ }
+
+ /* inverse pqf to bring subbands together again */
+ ssr_ipqf(ssr, output, time_out, ipqf_buffer, frame_len, SSR_BANDS);
+}
+
+static void ssr_gain_control(ssr_info *ssr, real_t *data, real_t *output,
+ real_t *overlap, real_t *prev_fmd, uint8_t band,
+ uint8_t window_sequence, uint16_t frame_len)
+{
+ uint16_t i;
+ real_t gc_function[2 * 1024 / SSR_BANDS];
+
+ if (window_sequence != EIGHT_SHORT_SEQUENCE) {
+ ssr_gc_function(ssr, &prev_fmd[band * frame_len * 2],
+ gc_function, window_sequence, band, frame_len);
+
+ for (i = 0; i < frame_len * 2; i++) {
+ data[band * frame_len * 2 + i] *= gc_function[i];
+ }
+ for (i = 0; i < frame_len; i++) {
+ output[band * frame_len + i] = overlap[band * frame_len + i] +
+ data[band * frame_len * 2 + i];
+ }
+ for (i = 0; i < frame_len; i++) {
+ overlap[band * frame_len + i] =
+ data[band * frame_len * 2 + frame_len + i];
+ }
+ } else {
+ uint8_t w;
+ for (w = 0; w < 8; w++) {
+ uint16_t frame_len8 = frame_len / 8;
+ uint16_t frame_len16 = frame_len / 16;
+
+ ssr_gc_function(ssr, &prev_fmd[band * frame_len * 2 + w * frame_len * 2 / 8],
+ gc_function, window_sequence, frame_len);
+
+ for (i = 0; i < frame_len8 * 2; i++) {
+ data[band * frame_len * 2 + w * frame_len8 * 2 + i] *= gc_function[i];
+ }
+ for (i = 0; i < frame_len8; i++) {
+ overlap[band * frame_len + i + 7 * frame_len16 + w * frame_len8] +=
+ data[band * frame_len * 2 + 2 * w * frame_len8 + i];
+ }
+ for (i = 0; i < frame_len8; i++) {
+ overlap[band * frame_len + i + 7 * frame_len16 + (w + 1)*frame_len8] =
+ data[band * frame_len * 2 + 2 * w * frame_len8 + frame_len8 + i];
+ }
+ }
+ for (i = 0; i < frame_len; i++) {
+ output[band * frame_len + i] = overlap[band * frame_len + i];
+ }
+ for (i = 0; i < frame_len; i++) {
+ overlap[band * frame_len + i] = overlap[band * frame_len + i + frame_len];
+ }
+ }
+}
+
+static void ssr_gc_function(ssr_info *ssr, real_t *prev_fmd,
+ real_t *gc_function, uint8_t window_sequence,
+ uint8_t band, uint16_t frame_len)
+{
+ uint16_t i;
+ uint16_t len_area1, len_area2;
+ int32_t aloc[10];
+ real_t alev[10];
+
+ switch (window_sequence) {
+ case ONLY_LONG_SEQUENCE:
+ len_area1 = frame_len / SSR_BANDS;
+ len_area2 = 0;
+ break;
+ case LONG_START_SEQUENCE:
+ len_area1 = (frame_len / SSR_BANDS) * 7 / 32;
+ len_area2 = (frame_len / SSR_BANDS) / 16;
+ break;
+ case EIGHT_SHORT_SEQUENCE:
+ len_area1 = (frame_len / 8) / SSR_BANDS;
+ len_area2 = 0;
+ break;
+ case LONG_STOP_SEQUENCE:
+ len_area1 = (frame_len / SSR_BANDS);
+ len_area2 = 0;
+ break;
+ }
+
+ /* decode bitstream information */
+
+ /* build array M */
+
+
+ for (i = 0; i < frame_len * 2; i++) {
+ gc_function[i] = 1;
+ }
+}
+
+#endif
diff --git a/audio_codec/libfaad/ssr.h b/audio_codec/libfaad/ssr.h
new file mode 100644
index 0000000..faaa963
--- a/dev/null
+++ b/audio_codec/libfaad/ssr.h
@@ -0,0 +1,59 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: ssr.h,v 1.19 2007/11/01 12:33:36 menno Exp $
+**/
+
+#ifndef __SSR_H__
+#define __SSR_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SSR_BANDS 4
+#define PQFTAPS 96
+
+ void ssr_decode(ssr_info *ssr, fb_info *fb, uint8_t window_sequence,
+ uint8_t window_shape, uint8_t window_shape_prev,
+ real_t *freq_in, real_t *time_out, real_t *overlap,
+ real_t ipqf_buffer[SSR_BANDS][96 / 4],
+ real_t *prev_fmd, uint16_t frame_len);
+
+
+ static void ssr_gain_control(ssr_info *ssr, real_t *data, real_t *output,
+ real_t *overlap, real_t *prev_fmd, uint8_t band,
+ uint8_t window_sequence, uint16_t frame_len);
+ static void ssr_gc_function(ssr_info *ssr, real_t *prev_fmd,
+ real_t *gc_function, uint8_t window_sequence,
+ uint16_t frame_len);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/audio_codec/libfaad/ssr_fb.c b/audio_codec/libfaad/ssr_fb.c
new file mode 100644
index 0000000..15e7b92
--- a/dev/null
+++ b/audio_codec/libfaad/ssr_fb.c
@@ -0,0 +1,191 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: ssr_fb.c,v 1.17 2007/11/01 12:33:36 menno Exp $
+**/
+
+#include "common.h"
+#include "structs.h"
+
+#ifdef SSR_DEC
+
+#include <string.h>
+#include <stdlib.h>
+#include "syntax.h"
+#include "filtbank.h"
+#include "mdct.h"
+#include "ssr_fb.h"
+#include "ssr_win.h"
+
+fb_info *ssr_filter_bank_init(uint16_t frame_len)
+{
+ uint16_t nshort = frame_len / 8;
+
+ fb_info *fb = (fb_info*)faad_malloc(sizeof(fb_info));
+ memset(fb, 0, sizeof(fb_info));
+
+ /* normal */
+ fb->mdct256 = faad_mdct_init(2 * nshort);
+ fb->mdct2048 = faad_mdct_init(2 * frame_len);
+
+ fb->long_window[0] = sine_long_256;
+ fb->short_window[0] = sine_short_32;
+ fb->long_window[1] = kbd_long_256;
+ fb->short_window[1] = kbd_short_32;
+
+ return fb;
+}
+
+void ssr_filter_bank_end(fb_info *fb)
+{
+ faad_mdct_end(fb->mdct256);
+ faad_mdct_end(fb->mdct2048);
+
+ if (fb) {
+ faad_free(fb);
+ }
+}
+
+static INLINE void imdct_ssr(fb_info *fb, real_t *in_data,
+ real_t *out_data, uint16_t len)
+{
+ mdct_info *mdct;
+
+ switch (len) {
+ case 512:
+ mdct = fb->mdct2048;
+ break;
+ case 64:
+ mdct = fb->mdct256;
+ break;
+ }
+
+ faad_imdct(mdct, in_data, out_data);
+}
+
+/* NON-overlapping inverse filterbank for use with SSR */
+void ssr_ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
+ uint8_t window_shape_prev, real_t *freq_in,
+ real_t *time_out, uint16_t frame_len)
+{
+ int16_t i;
+ real_t *transf_buf;
+
+ real_t *window_long;
+ real_t *window_long_prev;
+ real_t *window_short;
+ real_t *window_short_prev;
+
+ uint16_t nlong = frame_len;
+ uint16_t nshort = frame_len / 8;
+ uint16_t trans = nshort / 2;
+
+ uint16_t nflat_ls = (nlong - nshort) / 2;
+
+ transf_buf = (real_t*)faad_malloc(2 * nlong * sizeof(real_t));
+
+ 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];
+
+ switch (window_sequence) {
+ case ONLY_LONG_SEQUENCE:
+ imdct_ssr(fb, freq_in, transf_buf, 2 * nlong);
+ for (i = nlong - 1; i >= 0; i--) {
+ time_out[i] = MUL_R_C(transf_buf[i], window_long_prev[i]);
+ time_out[nlong + i] = MUL_R_C(transf_buf[nlong + i], window_long[nlong - 1 - i]);
+ }
+ break;
+
+ case LONG_START_SEQUENCE:
+ imdct_ssr(fb, freq_in, transf_buf, 2 * nlong);
+ for (i = 0; i < nlong; i++) {
+ time_out[i] = MUL_R_C(transf_buf[i], window_long_prev[i]);
+ }
+ for (i = 0; i < nflat_ls; i++) {
+ time_out[nlong + i] = transf_buf[nlong + i];
+ }
+ for (i = 0; i < nshort; i++) {
+ time_out[nlong + nflat_ls + i] = MUL_R_C(transf_buf[nlong + nflat_ls + i], window_short[nshort - i - 1]);
+ }
+ for (i = 0; i < nflat_ls; i++) {
+ time_out[nlong + nflat_ls + nshort + i] = 0;
+ }
+ break;
+
+ case EIGHT_SHORT_SEQUENCE:
+ imdct_ssr(fb, freq_in + 0 * nshort, transf_buf + 2 * nshort * 0, 2 * nshort);
+ imdct_ssr(fb, freq_in + 1 * nshort, transf_buf + 2 * nshort * 1, 2 * nshort);
+ imdct_ssr(fb, freq_in + 2 * nshort, transf_buf + 2 * nshort * 2, 2 * nshort);
+ imdct_ssr(fb, freq_in + 3 * nshort, transf_buf + 2 * nshort * 3, 2 * nshort);
+ imdct_ssr(fb, freq_in + 4 * nshort, transf_buf + 2 * nshort * 4, 2 * nshort);
+ imdct_ssr(fb, freq_in + 5 * nshort, transf_buf + 2 * nshort * 5, 2 * nshort);
+ imdct_ssr(fb, freq_in + 6 * nshort, transf_buf + 2 * nshort * 6, 2 * nshort);
+ imdct_ssr(fb, freq_in + 7 * nshort, transf_buf + 2 * nshort * 7, 2 * nshort);
+ for (i = nshort - 1; i >= 0; i--) {
+ time_out[i + 0 * nshort] = MUL_R_C(transf_buf[nshort * 0 + i], window_short_prev[i]);
+ time_out[i + 1 * nshort] = MUL_R_C(transf_buf[nshort * 1 + i], window_short[i]);
+ time_out[i + 2 * nshort] = MUL_R_C(transf_buf[nshort * 2 + i], window_short_prev[i]);
+ time_out[i + 3 * nshort] = MUL_R_C(transf_buf[nshort * 3 + i], window_short[i]);
+ time_out[i + 4 * nshort] = MUL_R_C(transf_buf[nshort * 4 + i], window_short_prev[i]);
+ time_out[i + 5 * nshort] = MUL_R_C(transf_buf[nshort * 5 + i], window_short[i]);
+ time_out[i + 6 * nshort] = MUL_R_C(transf_buf[nshort * 6 + i], window_short_prev[i]);
+ time_out[i + 7 * nshort] = MUL_R_C(transf_buf[nshort * 7 + i], window_short[i]);
+ time_out[i + 8 * nshort] = MUL_R_C(transf_buf[nshort * 8 + i], window_short_prev[i]);
+ time_out[i + 9 * nshort] = MUL_R_C(transf_buf[nshort * 9 + i], window_short[i]);
+ time_out[i + 10 * nshort] = MUL_R_C(transf_buf[nshort * 10 + i], window_short_prev[i]);
+ time_out[i + 11 * nshort] = MUL_R_C(transf_buf[nshort * 11 + i], window_short[i]);
+ time_out[i + 12 * nshort] = MUL_R_C(transf_buf[nshort * 12 + i], window_short_prev[i]);
+ time_out[i + 13 * nshort] = MUL_R_C(transf_buf[nshort * 13 + i], window_short[i]);
+ time_out[i + 14 * nshort] = MUL_R_C(transf_buf[nshort * 14 + i], window_short_prev[i]);
+ time_out[i + 15 * nshort] = MUL_R_C(transf_buf[nshort * 15 + i], window_short[i]);
+ }
+ break;
+
+ case LONG_STOP_SEQUENCE:
+ imdct_ssr(fb, freq_in, transf_buf, 2 * nlong);
+ for (i = 0; i < nflat_ls; i++) {
+ time_out[i] = 0;
+ }
+ for (i = 0; i < nshort; i++) {
+ time_out[nflat_ls + i] = MUL_R_C(transf_buf[nflat_ls + i], window_short_prev[i]);
+ }
+ for (i = 0; i < nflat_ls; i++) {
+ time_out[nflat_ls + nshort + i] = transf_buf[nflat_ls + nshort + i];
+ }
+ for (i = 0; i < nlong; i++) {
+ time_out[nlong + i] = MUL_R_C(transf_buf[nlong + i], window_long[nlong - 1 - i]);
+ }
+ break;
+ }
+
+ faad_free(transf_buf);
+}
+
+
+#endif
diff --git a/audio_codec/libfaad/ssr_fb.h b/audio_codec/libfaad/ssr_fb.h
new file mode 100644
index 0000000..7140224
--- a/dev/null
+++ b/audio_codec/libfaad/ssr_fb.h
@@ -0,0 +1,53 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+**
+** $Id: ssr_fb.h,v 1.16 2007/11/01 12:33:36 menno Exp $
+**/
+
+#ifndef __SSR_FB_H__
+#define __SSR_FB_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ fb_info *ssr_filter_bank_init(uint16_t frame_len);
+ void ssr_filter_bank_end(fb_info *fb);
+
+ /*non overlapping inverse filterbank */
+ void ssr_ifilter_bank(fb_info *fb,
+ uint8_t window_sequence,
+ uint8_t window_shape,
+ uint8_t window_shape_prev,
+ real_t *freq_in,
+ real_t *time_out,
+ uint16_t frame_len);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/audio_codec/libfaad/ssr_ipqf.c b/audio_codec/libfaad/ssr_ipqf.c
new file mode 100644
index 0000000..a192277
--- a/dev/null
+++ b/audio_codec/libfaad/ssr_ipqf.c
@@ -0,0 +1,171 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: ssr_ipqf.c,v 1.18 2007/11/01 12:33:39 menno Exp $
+**/
+
+#include "common.h"
+#include "structs.h"
+
+#ifdef SSR_DEC
+
+#include "ssr.h"
+#include "ssr_ipqf.h"
+
+static real_t **app_pqfbuf;
+static real_t **pp_q0, **pp_t0, **pp_t1;
+
+void gc_set_protopqf(real_t *p_proto)
+{
+ int j;
+ static real_t a_half[48] = {
+ 1.2206911375946939E-05, 1.7261986723798209E-05, 1.2300093657077942E-05,
+ -1.0833943097791965E-05, -5.7772498639901686E-05, -1.2764767618947719E-04,
+ -2.0965186675013334E-04, -2.8166673689263850E-04, -3.1234860429017460E-04,
+ -2.6738519958452353E-04, -1.1949424681824722E-04, 1.3965139412648678E-04,
+ 4.8864136409185725E-04, 8.7044629275148344E-04, 1.1949430269934793E-03,
+ 1.3519708175026700E-03, 1.2346314373964412E-03, 7.6953209114159191E-04,
+ -5.2242432579537141E-05, -1.1516092887213454E-03, -2.3538469841711277E-03,
+ -3.4033123072127277E-03, -4.0028551071986133E-03, -3.8745415659693259E-03,
+ -2.8321073426874310E-03, -8.5038892323704195E-04, 1.8856751185350931E-03,
+ 4.9688741735340923E-03, 7.8056704536795926E-03, 9.7027909685901654E-03,
+ 9.9960423120166159E-03, 8.2019366335594487E-03, 4.1642072876103365E-03,
+ -1.8364453822737758E-03, -9.0384863094167686E-03, -1.6241528177129844E-02,
+ -2.1939551286300665E-02, -2.4533179947088161E-02, -2.2591663337768787E-02,
+ -1.5122066420044672E-02, -1.7971713448186293E-03, 1.6903413428575379E-02,
+ 3.9672315874127042E-02, 6.4487527248102796E-02, 8.8850025474701726E-02,
+ 0.1101132906105560 , 0.1258540205143761 , 0.1342239368467012
+ };
+
+ for (j = 0; j < 48; ++j) {
+ p_proto[j] = p_proto[95 - j] = a_half[j];
+ }
+}
+
+void gc_setcoef_eff_pqfsyn(int mm,
+ int kk,
+ real_t *p_proto,
+ real_t ***ppp_q0,
+ real_t ***ppp_t0,
+ real_t ***ppp_t1)
+{
+ int i, k, n;
+ real_t w;
+
+ /* Set 1st Mul&Acc Coef's */
+ *ppp_q0 = (real_t **) calloc(mm, sizeof(real_t *));
+ for (n = 0; n < mm; ++n) {
+ (*ppp_q0)[n] = (real_t *) calloc(mm, sizeof(real_t));
+ }
+ for (n = 0; n < mm / 2; ++n) {
+ for (i = 0; i < mm; ++i) {
+ w = (2 * i + 1) * (2 * n + 1 - mm) * M_PI / (4 * mm);
+ (*ppp_q0)[n][i] = 2.0 * cos((real_t) w);
+
+ w = (2 * i + 1) * (2 * (mm + n) + 1 - mm) * M_PI / (4 * mm);
+ (*ppp_q0)[n + mm / 2][i] = 2.0 * cos((real_t) w);
+ }
+ }
+
+ /* Set 2nd Mul&Acc Coef's */
+ *ppp_t0 = (real_t **) calloc(mm, sizeof(real_t *));
+ *ppp_t1 = (real_t **) calloc(mm, sizeof(real_t *));
+ for (n = 0; n < mm; ++n) {
+ (*ppp_t0)[n] = (real_t *) calloc(kk, sizeof(real_t));
+ (*ppp_t1)[n] = (real_t *) calloc(kk, sizeof(real_t));
+ }
+ for (n = 0; n < mm; ++n) {
+ for (k = 0; k < kk; ++k) {
+ (*ppp_t0)[n][k] = mm * p_proto[2 * k * mm + n];
+ (*ppp_t1)[n][k] = mm * p_proto[(2 * k + 1) * mm + n];
+
+ if (k % 2 != 0) {
+ (*ppp_t0)[n][k] = -(*ppp_t0)[n][k];
+ (*ppp_t1)[n][k] = -(*ppp_t1)[n][k];
+ }
+ }
+ }
+}
+
+void ssr_ipqf(ssr_info *ssr, real_t *in_data, real_t *out_data,
+ real_t buffer[SSR_BANDS][96 / 4],
+ uint16_t frame_len, uint8_t bands)
+{
+ static int initFlag = 0;
+ real_t a_pqfproto[PQFTAPS];
+
+ int i;
+
+ if (initFlag == 0) {
+ gc_set_protopqf(a_pqfproto);
+ gc_setcoef_eff_pqfsyn(SSR_BANDS, PQFTAPS / (2 * SSR_BANDS), a_pqfproto,
+ &pp_q0, &pp_t0, &pp_t1);
+ initFlag = 1;
+ }
+
+ for (i = 0; i < frame_len / SSR_BANDS; i++) {
+ int l, n, k;
+ int mm = SSR_BANDS;
+ int kk = PQFTAPS / (2 * SSR_BANDS);
+
+ for (n = 0; n < mm; n++) {
+ for (k = 0; k < 2 * kk - 1; k++) {
+ buffer[n][k] = buffer[n][k + 1];
+ }
+ }
+
+ for (n = 0; n < mm; n++) {
+ real_t acc = 0.0;
+ for (l = 0; l < mm; l++) {
+ acc += pp_q0[n][l] * in_data[l * frame_len / SSR_BANDS + i];
+ }
+ buffer[n][2 * kk - 1] = acc;
+ }
+
+ for (n = 0; n < mm / 2; n++) {
+ real_t acc = 0.0;
+ for (k = 0; k < kk; k++) {
+ acc += pp_t0[n][k] * buffer[n][2 * kk - 1 - 2 * k];
+ }
+ for (k = 0; k < kk; ++k) {
+ acc += pp_t1[n][k] * buffer[n + mm / 2][2 * kk - 2 - 2 * k];
+ }
+ out_data[i * SSR_BANDS + n] = acc;
+
+ acc = 0.0;
+ for (k = 0; k < kk; k++) {
+ acc += pp_t0[mm - 1 - n][k] * buffer[n][2 * kk - 1 - 2 * k];
+ }
+ for (k = 0; k < kk; k++) {
+ acc -= pp_t1[mm - 1 - n][k] * buffer[n + mm / 2][2 * kk - 2 - 2 * k];
+ }
+ out_data[i * SSR_BANDS + mm - 1 - n] = acc;
+ }
+ }
+}
+
+#endif
diff --git a/audio_codec/libfaad/ssr_ipqf.h b/audio_codec/libfaad/ssr_ipqf.h
new file mode 100644
index 0000000..3a86a53
--- a/dev/null
+++ b/audio_codec/libfaad/ssr_ipqf.h
@@ -0,0 +1,46 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+**
+** $Id: ssr_ipqf.h,v 1.17 2007/11/01 12:33:39 menno Exp $
+**/
+
+#ifndef __SSR_IPQF_H__
+#define __SSR_IPQF_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ void ssr_ipqf(ssr_info *ssr, real_t *in_data, real_t *out_data,
+ real_t buffer[SSR_BANDS][96 / 4],
+ uint16_t frame_len, uint8_t bands);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/audio_codec/libfaad/ssr_win.h b/audio_codec/libfaad/ssr_win.h
new file mode 100644
index 0000000..6683815
--- a/dev/null
+++ b/audio_codec/libfaad/ssr_win.h
@@ -0,0 +1,635 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+**
+** $Id: ssr_win.h,v 1.16 2007/11/01 12:33:39 menno Exp $
+**/
+
+#ifndef __SSR_WIN_H__
+#define __SSR_WIN_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef _MSC_VER
+#pragma warning(disable:4305)
+#pragma warning(disable:4244)
+#endif
+
+ static real_t sine_short_32[] = {
+ 0.0245412290,
+ 0.0735645667,
+ 0.1224106774,
+ 0.1709618866,
+ 0.2191012502,
+ 0.2667127550,
+ 0.3136817515,
+ 0.3598950505,
+ 0.4052413106,
+ 0.4496113360,
+ 0.4928981960,
+ 0.5349976420,
+ 0.5758082271,
+ 0.6152316332,
+ 0.6531728506,
+ 0.6895405650,
+ 0.7242470980,
+ 0.7572088838,
+ 0.7883464694,
+ 0.8175848126,
+ 0.8448535800,
+ 0.8700870275,
+ 0.8932242990,
+ 0.9142097831,
+ 0.9329928160,
+ 0.9495282173,
+ 0.9637760520,
+ 0.9757021666,
+ 0.9852776527,
+ 0.9924795628,
+ 0.9972904325,
+ 0.9996988177
+ };
+
+ static real_t sine_long_256[] = {
+ 0.0030679568,
+ 0.0092037553,
+ 0.0153392069,
+ 0.0214740802,
+ 0.0276081469,
+ 0.0337411724,
+ 0.0398729295,
+ 0.0460031852,
+ 0.0521317050,
+ 0.0582582653,
+ 0.0643826351,
+ 0.0705045760,
+ 0.0766238645,
+ 0.0827402696,
+ 0.0888535529,
+ 0.0949634984,
+ 0.1010698676,
+ 0.1071724296,
+ 0.1132709533,
+ 0.1193652153,
+ 0.1254549921,
+ 0.1315400302,
+ 0.1376201212,
+ 0.1436950415,
+ 0.1497645378,
+ 0.1558284014,
+ 0.1618863940,
+ 0.1679383069,
+ 0.1739838719,
+ 0.1800229102,
+ 0.1860551536,
+ 0.1920804083,
+ 0.1980984211,
+ 0.2041089684,
+ 0.2101118416,
+ 0.2161068022,
+ 0.2220936269,
+ 0.2280720919,
+ 0.2340419590,
+ 0.2400030345,
+ 0.2459550500,
+ 0.2518978119,
+ 0.2578310966,
+ 0.2637546957,
+ 0.2696683407,
+ 0.2755718231,
+ 0.2814649343,
+ 0.2873474658,
+ 0.2932191789,
+ 0.2990798354,
+ 0.3049292266,
+ 0.3107671738,
+ 0.3165933788,
+ 0.3224076927,
+ 0.3282098472,
+ 0.3339996636,
+ 0.3397769034,
+ 0.3455413282,
+ 0.3512927592,
+ 0.3570309579,
+ 0.3627557456,
+ 0.3684668541,
+ 0.3741640747,
+ 0.3798472285,
+ 0.3855160773,
+ 0.3911703825,
+ 0.3968099952,
+ 0.4024346471,
+ 0.4080441594,
+ 0.4136383235,
+ 0.4192169011,
+ 0.4247796834,
+ 0.4303264916,
+ 0.4358570874,
+ 0.4413712919,
+ 0.4468688369,
+ 0.4523496032,
+ 0.4578133225,
+ 0.4632597864,
+ 0.4686888456,
+ 0.4741002321,
+ 0.4794937670,
+ 0.4848692715,
+ 0.4902265072,
+ 0.4955652654,
+ 0.5008853674,
+ 0.5061866641,
+ 0.5114688873,
+ 0.5167317986,
+ 0.5219752789,
+ 0.5271991491,
+ 0.5324031115,
+ 0.5375871062,
+ 0.5427507758,
+ 0.5478940606,
+ 0.5530167222,
+ 0.5581185222,
+ 0.5631993413,
+ 0.5682589412,
+ 0.5732972026,
+ 0.5783138275,
+ 0.5833086967,
+ 0.5882815719,
+ 0.5932323337,
+ 0.5981607437,
+ 0.6030666232,
+ 0.6079497933,
+ 0.6128100753,
+ 0.6176473498,
+ 0.6224613190,
+ 0.6272518039,
+ 0.6320187449,
+ 0.6367619038,
+ 0.6414810419,
+ 0.6461760402,
+ 0.6508467197,
+ 0.6554928422,
+ 0.6601143479,
+ 0.6647109985,
+ 0.6692826152,
+ 0.6738290191,
+ 0.6783500314,
+ 0.6828455329,
+ 0.6873153448,
+ 0.6917592883,
+ 0.6961771250,
+ 0.7005687952,
+ 0.7049341202,
+ 0.7092728615,
+ 0.7135848999,
+ 0.7178700566,
+ 0.7221282125,
+ 0.7263591886,
+ 0.7305628061,
+ 0.7347388864,
+ 0.7388873696,
+ 0.7430079579,
+ 0.7471006513,
+ 0.7511651516,
+ 0.7552013993,
+ 0.7592092156,
+ 0.7631884217,
+ 0.7671388984,
+ 0.7710605264,
+ 0.7749531269,
+ 0.7788165212,
+ 0.7826505899,
+ 0.7864552140,
+ 0.7902302146,
+ 0.7939754725,
+ 0.7976908684,
+ 0.8013761640,
+ 0.8050313592,
+ 0.8086562157,
+ 0.8122506142,
+ 0.8158144355,
+ 0.8193475604,
+ 0.8228498101,
+ 0.8263210654,
+ 0.8297612667,
+ 0.8331701756,
+ 0.8365477324,
+ 0.8398938179,
+ 0.8432082534,
+ 0.8464909792,
+ 0.8497417569,
+ 0.8529606462,
+ 0.8561473489,
+ 0.8593018055,
+ 0.8624239564,
+ 0.8655136228,
+ 0.8685707450,
+ 0.8715950847,
+ 0.8745866418,
+ 0.8775452971,
+ 0.8804709315,
+ 0.8833633661,
+ 0.8862225413,
+ 0.8890483975,
+ 0.8918406963,
+ 0.8945994973,
+ 0.8973246217,
+ 0.9000158906,
+ 0.9026733041,
+ 0.9052967429,
+ 0.9078861475,
+ 0.9104412794,
+ 0.9129621983,
+ 0.9154487252,
+ 0.9179008007,
+ 0.9203183055,
+ 0.9227011204,
+ 0.9250492454,
+ 0.9273625612,
+ 0.9296408892,
+ 0.9318842888,
+ 0.9340925813,
+ 0.9362657070,
+ 0.9384035468,
+ 0.9405061007,
+ 0.9425731897,
+ 0.9446048737,
+ 0.9466009140,
+ 0.9485613704,
+ 0.9504860640,
+ 0.9523749948,
+ 0.9542281032,
+ 0.9560452700,
+ 0.9578264356,
+ 0.9595715404,
+ 0.9612805247,
+ 0.9629532695,
+ 0.9645897746,
+ 0.9661900401,
+ 0.9677538276,
+ 0.9692812562,
+ 0.9707721472,
+ 0.9722265005,
+ 0.9736442566,
+ 0.9750253558,
+ 0.9763697386,
+ 0.9776773453,
+ 0.9789481759,
+ 0.9801821709,
+ 0.9813792109,
+ 0.9825392962,
+ 0.9836624265,
+ 0.9847484827,
+ 0.9857975245,
+ 0.9868094325,
+ 0.9877841473,
+ 0.9887216687,
+ 0.9896219969,
+ 0.9904850721,
+ 0.9913108945,
+ 0.9920993447,
+ 0.9928504229,
+ 0.9935641289,
+ 0.9942404628,
+ 0.9948793054,
+ 0.9954807758,
+ 0.9960446954,
+ 0.9965711236,
+ 0.9970600605,
+ 0.9975114465,
+ 0.9979252815,
+ 0.9983015656,
+ 0.9986402392,
+ 0.9989413023,
+ 0.9992047548,
+ 0.9994305968,
+ 0.9996188283,
+ 0.9997693896,
+ 0.9998823404,
+ 0.9999576211,
+ 0.9999952912
+ };
+
+ static real_t kbd_short_32[] = {
+ 0.0000875914060105,
+ 0.0009321760265333,
+ 0.0032114611466596,
+ 0.0081009893216786,
+ 0.0171240286619181,
+ 0.0320720743527833,
+ 0.0548307856028528,
+ 0.0871361822564870,
+ 0.1302923415174603,
+ 0.1848955425508276,
+ 0.2506163195331889,
+ 0.3260874142923209,
+ 0.4089316830907141,
+ 0.4959414909423747,
+ 0.5833939894958904,
+ 0.6674601983218376,
+ 0.7446454751465113,
+ 0.8121892962974020,
+ 0.8683559394406505,
+ 0.9125649996381605,
+ 0.9453396205809574,
+ 0.9680864942677585,
+ 0.9827581789763112,
+ 0.9914756203467121,
+ 0.9961964092194694,
+ 0.9984956609571091,
+ 0.9994855586984285,
+ 0.9998533730714648,
+ 0.9999671864476404,
+ 0.9999948432453556,
+ 0.9999995655238333,
+ 0.9999999961638728
+ };
+
+
+ static real_t kbd_long_256[] = {
+ 0.0005851230124487,
+ 0.0009642149851497,
+ 0.0013558207534965,
+ 0.0017771849644394,
+ 0.0022352533849672,
+ 0.0027342299070304,
+ 0.0032773001022195,
+ 0.0038671998069216,
+ 0.0045064443384152,
+ 0.0051974336885144,
+ 0.0059425050016407,
+ 0.0067439602523141,
+ 0.0076040812644888,
+ 0.0085251378135895,
+ 0.0095093917383048,
+ 0.0105590986429280,
+ 0.0116765080854300,
+ 0.0128638627792770,
+ 0.0141233971318631,
+ 0.0154573353235409,
+ 0.0168678890600951,
+ 0.0183572550877256,
+ 0.0199276125319803,
+ 0.0215811201042484,
+ 0.0233199132076965,
+ 0.0251461009666641,
+ 0.0270617631981826,
+ 0.0290689473405856,
+ 0.0311696653515848,
+ 0.0333658905863535,
+ 0.0356595546648444,
+ 0.0380525443366107,
+ 0.0405466983507029,
+ 0.0431438043376910,
+ 0.0458455957104702,
+ 0.0486537485902075,
+ 0.0515698787635492,
+ 0.0545955386770205,
+ 0.0577322144743916,
+ 0.0609813230826460,
+ 0.0643442093520723,
+ 0.0678221432558827,
+ 0.0714163171546603,
+ 0.0751278431308314,
+ 0.0789577503982528,
+ 0.0829069827918993,
+ 0.0869763963425241,
+ 0.0911667569410503,
+ 0.0954787380973307,
+ 0.0999129187977865,
+ 0.1044697814663005,
+ 0.1091497100326053,
+ 0.1139529881122542,
+ 0.1188797973021148,
+ 0.1239302155951605,
+ 0.1291042159181728,
+ 0.1344016647957880,
+ 0.1398223211441467,
+ 0.1453658351972151,
+ 0.1510317475686540,
+ 0.1568194884519144,
+ 0.1627283769610327,
+ 0.1687576206143887,
+ 0.1749063149634756,
+ 0.1811734433685097,
+ 0.1875578769224857,
+ 0.1940583745250518,
+ 0.2006735831073503,
+ 0.2074020380087318,
+ 0.2142421635060113,
+ 0.2211922734956977,
+ 0.2282505723293797,
+ 0.2354151558022098,
+ 0.2426840122941792,
+ 0.2500550240636293,
+ 0.2575259686921987,
+ 0.2650945206801527,
+ 0.2727582531907993,
+ 0.2805146399424422,
+ 0.2883610572460804,
+ 0.2962947861868143,
+ 0.3043130149466800,
+ 0.3124128412663888,
+ 0.3205912750432127,
+ 0.3288452410620226,
+ 0.3371715818562547,
+ 0.3455670606953511,
+ 0.3540283646950029,
+ 0.3625521080463003,
+ 0.3711348353596863,
+ 0.3797730251194006,
+ 0.3884630932439016,
+ 0.3972013967475546,
+ 0.4059842374986933,
+ 0.4148078660689724,
+ 0.4236684856687616,
+ 0.4325622561631607,
+ 0.4414852981630577,
+ 0.4504336971855032,
+ 0.4594035078775303,
+ 0.4683907582974173,
+ 0.4773914542472655,
+ 0.4864015836506502,
+ 0.4954171209689973,
+ 0.5044340316502417,
+ 0.5134482766032377,
+ 0.5224558166913167,
+ 0.5314526172383208,
+ 0.5404346525403849,
+ 0.5493979103766972,
+ 0.5583383965124314,
+ 0.5672521391870222,
+ 0.5761351935809411,
+ 0.5849836462541291,
+ 0.5937936195492526,
+ 0.6025612759529649,
+ 0.6112828224083939,
+ 0.6199545145721097,
+ 0.6285726610088878,
+ 0.6371336273176413,
+ 0.6456338401819751,
+ 0.6540697913388968,
+ 0.6624380414593221,
+ 0.6707352239341151,
+ 0.6789580485595255,
+ 0.6871033051160131,
+ 0.6951678668345944,
+ 0.7031486937449871,
+ 0.7110428359000029,
+ 0.7188474364707993,
+ 0.7265597347077880,
+ 0.7341770687621900,
+ 0.7416968783634273,
+ 0.7491167073477523,
+ 0.7564342060337386,
+ 0.7636471334404891,
+ 0.7707533593446514,
+ 0.7777508661725849,
+ 0.7846377507242818,
+ 0.7914122257259034,
+ 0.7980726212080798,
+ 0.8046173857073919,
+ 0.8110450872887550,
+ 0.8173544143867162,
+ 0.8235441764639875,
+ 0.8296133044858474,
+ 0.8355608512093652,
+ 0.8413859912867303,
+ 0.8470880211822968,
+ 0.8526663589032990,
+ 0.8581205435445334,
+ 0.8634502346476508,
+ 0.8686552113760616,
+ 0.8737353715068081,
+ 0.8786907302411250,
+ 0.8835214188357692,
+ 0.8882276830575707,
+ 0.8928098814640207,
+ 0.8972684835130879,
+ 0.9016040675058185,
+ 0.9058173183656508,
+ 0.9099090252587376,
+ 0.9138800790599416,
+ 0.9177314696695282,
+ 0.9214642831859411,
+ 0.9250796989403991,
+ 0.9285789863994010,
+ 0.9319635019415643,
+ 0.9352346855155568,
+ 0.9383940571861993,
+ 0.9414432135761304,
+ 0.9443838242107182,
+ 0.9472176277741918,
+ 0.9499464282852282,
+ 0.9525720912004834,
+ 0.9550965394547873,
+ 0.9575217494469370,
+ 0.9598497469802043,
+ 0.9620826031668507,
+ 0.9642224303060783,
+ 0.9662713777449607,
+ 0.9682316277319895,
+ 0.9701053912729269,
+ 0.9718949039986892,
+ 0.9736024220549734,
+ 0.9752302180233160,
+ 0.9767805768831932,
+ 0.9782557920246753,
+ 0.9796581613210076,
+ 0.9809899832703159,
+ 0.9822535532154261,
+ 0.9834511596505429,
+ 0.9845850806232530,
+ 0.9856575802399989,
+ 0.9866709052828243,
+ 0.9876272819448033,
+ 0.9885289126911557,
+ 0.9893779732525968,
+ 0.9901766097569984,
+ 0.9909269360049311,
+ 0.9916310308941294,
+ 0.9922909359973702,
+ 0.9929086532976777,
+ 0.9934861430841844,
+ 0.9940253220113651,
+ 0.9945280613237534,
+ 0.9949961852476154,
+ 0.9954314695504363,
+ 0.9958356402684387,
+ 0.9962103726017252,
+ 0.9965572899760172,
+ 0.9968779632693499,
+ 0.9971739102014799,
+ 0.9974465948831872,
+ 0.9976974275220812,
+ 0.9979277642809907,
+ 0.9981389072844972,
+ 0.9983321047686901,
+ 0.9985085513687731,
+ 0.9986693885387259,
+ 0.9988157050968516,
+ 0.9989485378906924,
+ 0.9990688725744943,
+ 0.9991776444921379,
+ 0.9992757396582338,
+ 0.9993639958299003,
+ 0.9994432036616085,
+ 0.9995141079353859,
+ 0.9995774088586188,
+ 0.9996337634216871,
+ 0.9996837868076957,
+ 0.9997280538466377,
+ 0.9997671005064359,
+ 0.9998014254134544,
+ 0.9998314913952471,
+ 0.9998577270385304,
+ 0.9998805282555989,
+ 0.9999002598526793,
+ 0.9999172570940037,
+ 0.9999318272557038,
+ 0.9999442511639580,
+ 0.9999547847121726,
+ 0.9999636603523446,
+ 0.9999710885561258,
+ 0.9999772592414866,
+ 0.9999823431612708,
+ 0.9999864932503106,
+ 0.9999898459281599,
+ 0.9999925223548691,
+ 0.9999946296375997,
+ 0.9999962619864214,
+ 0.9999975018180320,
+ 0.9999984208055542,
+ 0.9999990808746198,
+ 0.9999995351446231,
+ 0.9999998288155155
+ };
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/audio_codec/libfaad/structs.h b/audio_codec/libfaad/structs.h
new file mode 100644
index 0000000..73f81cc
--- a/dev/null
+++ b/audio_codec/libfaad/structs.h
@@ -0,0 +1,513 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: structs.h,v 1.49 2009/01/26 23:51:15 menno Exp $
+**/
+
+#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 64
+#define MAX_SYNTAX_ELEMENTS 48
+#define MAX_WINDOW_GROUPS 8
+#define MAX_SFB 51
+#define MAX_LTP_SFB 40
+#define MAX_LTP_SFB_S 8
+
+ /* 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[MAX_CHANNELS];
+ uint8_t additional_excluded_chns[MAX_CHANNELS];
+
+ 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];
+ uint16_t swb_offset_max;
+
+ 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 is_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) */
+
+#define MAX_ASC_BYTES 64
+ typedef struct {
+ int inited;
+ int version, versionA;
+ int framelen_type;
+ int useSameStreamMux;
+ int allStreamsSameTimeFraming;
+ int numSubFrames;
+ int numPrograms;
+ int numLayers;
+ int otherDataPresent;
+ uint32_t otherDataLenBits;
+ uint32_t frameLength;
+ uint8_t ASC[MAX_ASC_BYTES];
+ uint32_t ASCbits;
+ } latm_header;
+
+#define NEW_CODE_CHECK_LATM
+#ifdef NEW_CODE_CHECK_LATM
+#define LOAS_HEADER_SIZE 3
+ /****************************************************************************
+ * LOAS helpers
+ ****************************************************************************/
+#define LATM_MAX_EXTRA_SIZE 64
+ typedef struct {
+ int i_object_type;
+ int i_samplerate;
+ int i_channel;
+ int i_sbr; // 0: no sbr, 1: sbr, -1: unknown
+ int i_ps; // 0: no ps, 1: ps, -1: unknown
+
+ struct {
+ int i_object_type;
+ int i_samplerate;
+ } extension;
+
+ /* GASpecific */
+ int i_frame_length; // 1024 or 960
+
+ } mpeg4_cfg_t;
+ typedef struct {
+ int i_program;
+ int i_layer;
+
+ int i_frame_length_type;
+ int i_frame_length; // type 1
+ int i_frame_length_index; // type 3 4 5 6 7
+
+ mpeg4_cfg_t cfg;
+
+ /* Raw configuration */
+ int i_extra;
+ uint8_t extra[LATM_MAX_EXTRA_SIZE];
+
+ } latm_stream_t;
+
+#define LATM_MAX_LAYER (8)
+#define LATM_MAX_PROGRAM (16)
+ typedef struct {
+ int b_same_time_framing;
+ int i_sub_frames;
+ int i_programs;
+
+ int pi_layers[LATM_MAX_PROGRAM];
+
+ int pi_stream[LATM_MAX_PROGRAM][LATM_MAX_LAYER];
+
+ int i_streams;
+ latm_stream_t stream[LATM_MAX_PROGRAM*LATM_MAX_LAYER];
+
+ int i_other_data;
+ int i_crc; /* -1 if not set */
+ } latm_mux_t;
+
+ typedef struct {
+ /*
+ * Input properties
+ */
+ int i_state;
+ int i_type;
+ int i_frame_size;
+ unsigned int i_channels;
+ unsigned int i_rate, i_frame_length, i_header_size;
+ int i_input_rate;
+ /* LOAS */
+ unsigned char b_latm_cfg;
+ latm_mux_t latm;
+ } decoder_sys_t;
+
+#endif
+ typedef struct {
+ uint8_t adts_header_present;
+ uint8_t adif_header_present;
+ uint8_t latm_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;
+
+ /* output data buffer */
+ void *sample_buffer;
+
+ /*add for loas sub frame large than one*/
+ void *sample_buffer_all;
+
+ 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
+
+#ifdef DRM
+ uint8_t error_state;
+#endif
+
+ /* RNG states */
+ uint32_t __r1;
+ uint32_t __r2;
+
+ /* 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
+ latm_header latm_config;
+ const unsigned char *cmes;
+#ifdef NEW_CODE_CHECK_LATM
+ decoder_sys_t dec_sys;
+#endif
+ int last_sf_index;
+ int last_ch_configure;
+ } NeAACDecStruct;
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/audio_codec/libfaad/syntax.c b/audio_codec/libfaad/syntax.c
new file mode 100644
index 0000000..a2d0f4b
--- a/dev/null
+++ b/audio_codec/libfaad/syntax.c
@@ -0,0 +1,2539 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: syntax.c,v 1.93 2009/01/26 23:51:15 menno Exp $
+**/
+
+/*
+ Reads the AAC bitstream as defined in 14496-3 (MPEG-4 Audio)
+*/
+#include <stdlib.h>
+#include "common.h"
+#include "structs.h"
+
+#include <stdio.h>
+#include <string.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
+#include "mp4.h"
+
+
+/* static function declarations */
+static void decode_sce_lfe(NeAACDecStruct *hDecoder, NeAACDecFrameInfo *hInfo, bitfile *ld,
+ uint8_t id_syn_ele);
+static void decode_cpe(NeAACDecStruct *hDecoder, NeAACDecFrameInfo *hInfo, bitfile *ld,
+ uint8_t id_syn_ele);
+static uint8_t single_lfe_channel_element(NeAACDecStruct *hDecoder, bitfile *ld,
+ uint8_t channel, uint8_t *tag);
+static uint8_t channel_pair_element(NeAACDecStruct *hDecoder, bitfile *ld,
+ uint8_t channel, uint8_t *tag);
+#ifdef COUPLING_DEC
+static uint8_t coupling_channel_element(NeAACDecStruct *hDecoder, bitfile *ld);
+#endif
+static uint16_t data_stream_element(NeAACDecStruct *hDecoder, bitfile *ld);
+static uint8_t program_config_element(program_config *pce, bitfile *ld);
+static uint8_t fill_element(NeAACDecStruct *hDecoder, bitfile *ld, drc_info *drc
+#ifdef SBR_DEC
+ , uint8_t sbr_ele
+#endif
+ );
+static uint8_t individual_channel_stream(NeAACDecStruct *hDecoder, element *ele,
+ bitfile *ld, ic_stream *ics, uint8_t scal_flag,
+ int16_t *spec_data);
+static uint8_t ics_info(NeAACDecStruct *hDecoder, ic_stream *ics, bitfile *ld,
+ uint8_t common_window);
+static uint8_t section_data(NeAACDecStruct *hDecoder, ic_stream *ics, bitfile *ld);
+static uint8_t scale_factor_data(NeAACDecStruct *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(NeAACDecStruct *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(NeAACDecStruct *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);
+static uint8_t side_info(NeAACDecStruct *hDecoder, element *ele,
+ bitfile *ld, ic_stream *ics, uint8_t scal_flag);
+#ifdef DRM
+static int8_t DRM_aac_scalable_main_header(NeAACDecStruct *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 */
+ faad_getbits(ld, 1);
+ }
+#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(NeAACDecStruct *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(NeAACDecStruct *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(NeAACDecStruct *hDecoder, NeAACDecFrameInfo *hInfo,
+ bitfile *ld, program_config *pce, drc_info *drc)
+{
+ uint8_t id_syn_ele;
+ uint8_t ele_this_frame = 0;
+
+ 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:
+ ele_this_frame++;
+ 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:
+ ele_this_frame++;
+ 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:
+#ifdef DRM
+ hInfo->error = 32;
+#else
+ ele_this_frame++;
+ hDecoder->has_lfe++;
+ decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele);
+#endif
+ if (hInfo->error > 0) {
+ return;
+ }
+ break;
+ case ID_CCE: /* not implemented yet, but skip the bits */
+#ifdef DRM
+ hInfo->error = 32;
+#else
+ ele_this_frame++;
+#ifdef COUPLING_DEC
+ hInfo->error = coupling_channel_element(hDecoder, ld);
+#else
+ hInfo->error = 6;
+#endif
+#endif
+ if (hInfo->error > 0) {
+ return;
+ }
+ break;
+ case ID_DSE:
+ ele_this_frame++;
+ data_stream_element(hDecoder, ld);
+ break;
+ case ID_PCE:
+ if (ele_this_frame != 0) {
+ hInfo->error = 31;
+ return;
+ }
+ ele_this_frame++;
+ /* 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:
+ ele_this_frame++;
+ /* 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
+#if 0
+ && !hDecoder->latm_header_present
+#endif
+ )
+#endif
+ {
+ faad_byte_align(ld);
+ }
+
+ return;
+}
+
+/* Table 4.4.4 and */
+/* Table 4.4.9 */
+static uint8_t single_lfe_channel_element(NeAACDecStruct *hDecoder, bitfile *ld,
+ uint8_t channel, uint8_t *tag)
+{
+ uint8_t retval = 0;
+ element sce = {0};
+ ic_stream *ics = &(sce.ics1);
+ ALIGN int16_t spec_data[1024] = {0};
+
+ 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;
+ }
+
+ /* IS not allowed in single channel */
+ if (ics->is_used) {
+ return 32;
+ }
+
+#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 */
+static uint8_t channel_pair_element(NeAACDecStruct *hDecoder, bitfile *ld,
+ uint8_t channels, uint8_t *tag)
+{
+ ALIGN int16_t spec_data1[1024] = {0};
+ ALIGN int16_t spec_data2[1024] = {0};
+ element cpe = {0};
+ ic_stream *ics1 = &(cpe.ics1);
+ ic_stream *ics2 = &(cpe.ics2);
+ uint8_t result;
+
+ 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 == 3) {
+ /* bitstream error */
+ return 32;
+ }
+ 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(NeAACDecStruct *hDecoder, ic_stream *ics, bitfile *ld,
+ uint8_t common_window)
+{
+ uint8_t retval = 0;
+ uint8_t ics_reserved_bit;
+
+ ics_reserved_bit = faad_get1bit(ld
+ DEBUGVAR(1, 43, "ics_info(): ics_reserved_bit"));
+ if (ics_reserved_bit != 0) {
+ return 32;
+ }
+ 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"));
+
+#ifdef LD_DEC
+ /* No block switching in LD */
+ if ((hDecoder->object_type == LD) && (ics->window_sequence != ONLY_LONG_SEQUENCE)) {
+ return 32;
+ }
+#endif
+
+ 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 =
+#endif
+ (uint8_t)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
+ }
+#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(NeAACDecStruct *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};
+ int16_t sh_data[1024];
+
+ 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;
+ }
+
+ /* IS not allowed in single channel */
+ if (ics->is_used) {
+ return 32;
+ }
+
+ 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(NeAACDecStruct *hDecoder, bitfile *ld)
+{
+ uint8_t byte_aligned;
+ uint16_t i, count;
+
+ /* 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(NeAACDecStruct *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], 2 * get_sample_rate(hDecoder->sf_index),
+ hDecoder->downSampledSBR
+#ifdef DRM
+ , 0
+#endif
+ );
+ }
+#ifdef DISABLE_SBR
+ if (hDecoder->latm_header_present) {
+ unsigned cnt_1 = count << 3;
+ while (cnt_1 > 7) {
+ faad_getbits(ld, 8
+ DEBUGVAR(1, 999, "sbr_bitstream(): num_align_bits"));
+ cnt_1 -= 8;
+ }
+ faad_getbits(ld, cnt_1);
+ return 0;//
+ }
+#endif
+ hDecoder->sbr_present_flag = 1;
+
+ /* parse the SBR data */
+ hDecoder->sbr[sbr_ele]->ret = sbr_extension_data(ld, hDecoder->sbr[sbr_ele], count,
+ hDecoder->postSeekResetFlag);
+
+#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 {
+#endif
+#ifndef DRM
+ while (count > 0) {
+ count -= extension_payload(ld, drc, count);
+ }
+#else
+ return 30;
+#endif
+#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 DRM
+/* Table 4.4.13 ASME */
+void DRM_aac_scalable_main_element(NeAACDecStruct *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;
+ ALIGN int16_t spec_data1[1024] = {0};
+ ALIGN int16_t spec_data2[1024] = {0};
+
+ hDecoder->fr_ch_ele = 0;
+
+ hInfo->error = DRM_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;
+ }
+
+ if (this_layer_stereo) {
+ cpe.channel = 0;
+ cpe.paired_channel = 1;
+ }
+
+
+ /* Stereo2 / Mono1 */
+ ics1->tns_data_present = faad_get1bit(ld);
+
+#if defined(LTP_DEC)
+ ics1->ltp.data_present = faad_get1bit(ld);
+#elif defined (DRM)
+ if (faad_get1bit(ld)) {
+ hInfo->error = 26;
+ return;
+ }
+#else
+ faad_get1bit(ld);
+#endif
+
+ hInfo->error = side_info(hDecoder, &cpe, ld, ics1, 1);
+ if (hInfo->error > 0) {
+ return;
+ }
+ if (this_layer_stereo) {
+ /* Stereo3 */
+ ics2->tns_data_present = faad_get1bit(ld);
+#ifdef LTP_DEC
+ ics1->ltp.data_present =
+#endif
+ faad_get1bit(ld);
+ hInfo->error = side_info(hDecoder, &cpe, ld, ics2, 1);
+ if (hInfo->error > 0) {
+ return;
+ }
+ }
+ /* Stereo4 / Mono2 */
+ if (ics1->tns_data_present) {
+ tns_data(ics1, &(ics1->tns), ld);
+ }
+ if (this_layer_stereo) {
+ /* Stereo5 */
+ if (ics2->tns_data_present) {
+ tns_data(ics2, &(ics2->tns), ld);
+ }
+ }
+
+#ifdef DRM
+ /* CRC check */
+ if (hDecoder->object_type == DRM_ER_LC) {
+ if ((hInfo->error = (uint8_t)faad_check_CRC(ld, (uint16_t)faad_get_processed_bits(ld) - 8)) > 0) {
+ return;
+ }
+ }
+#endif
+
+ /* Stereo6 / Mono3 */
+ /* error resilient spectral data decoding */
+ if ((hInfo->error = reordered_spectral_data(hDecoder, ics1, ld, spec_data1)) > 0) {
+ return;
+ }
+ if (this_layer_stereo) {
+ /* Stereo7 */
+ /* error resilient spectral data decoding */
+ if ((hInfo->error = reordered_spectral_data(hDecoder, ics2, ld, spec_data2)) > 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);
+ }
+
+ /* Reverse bit reading of SBR data in DRM audio frame */
+ revbuffer = (uint8_t*)faad_malloc(buffer_size * sizeof(uint8_t));
+ 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 */
+ /* SBR buffer size is original buffer size minus AAC buffer size */
+ 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, hDecoder->postSeekResetFlag);
+#if (defined(PS_DEC) || defined(DRM_PS))
+ if (hDecoder->sbr[0]->ps_used) {
+ hDecoder->ps_used[0] = 1;
+ hDecoder->ps_used_global = 1;
+ }
+#endif
+
+ if (ld_sbr.error) {
+ hDecoder->sbr[0]->ret = 1;
+ }
+
+ /* 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 DRM_aac_scalable_main_header(NeAACDecStruct *hDecoder, ic_stream *ics1, ic_stream *ics2,
+ bitfile *ld, uint8_t this_layer_stereo)
+{
+ uint8_t retval = 0;
+ uint8_t ch;
+ ic_stream *ics;
+ uint8_t ics_reserved_bit;
+
+ ics_reserved_bit = faad_get1bit(ld
+ DEBUGVAR(1, 300, "aac_scalable_main_header(): ics_reserved_bits"));
+ if (ics_reserved_bit != 0) {
+ return 32;
+ }
+ 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 == 3) {
+ /* bitstream error */
+ return 32;
+ }
+ 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;
+ }
+
+ return 0;
+}
+#endif
+
+static uint8_t side_info(NeAACDecStruct *hDecoder, element *ele,
+ bitfile *ld, ic_stream *ics, uint8_t scal_flag)
+{
+ 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;
+ }
+ }
+#endif
+
+ return 0;
+}
+
+/* Table 4.4.24 */
+static uint8_t individual_channel_stream(NeAACDecStruct *hDecoder, element *ele,
+ bitfile *ld, ic_stream *ics, uint8_t scal_flag,
+ int16_t *spec_data)
+{
+ uint8_t result;
+
+ result = side_info(hDecoder, ele, ld, ics, scal_flag);
+ if (result > 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
+
+#ifdef ERROR_RESILIENCE
+ 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(NeAACDecStruct *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 << sect_bits) - 1;
+
+#if 0
+ printf("\ntotal sfb %d\n", ics->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) {
+ return 14;
+ }
+
+#ifdef ERROR_RESILIENCE
+ if (hDecoder->aacSectionDataResilienceFlag) {
+ sect_cb_bits = 5;
+ }
+#endif
+
+ ics->sect_cb[g][i] = (uint8_t)faad_getbits(ld, sect_cb_bits
+ DEBUGVAR(1, 71, "section_data(): sect_cb"));
+
+ if (ics->sect_cb[g][i] == 12) {
+ return 32;
+ }
+
+#if 0
+ printf("%d\n", ics->sect_cb[g][i]);
+#endif
+
+#ifndef DRM
+ if (ics->sect_cb[g][i] == NOISE_HCB) {
+ ics->noise_used = 1;
+ }
+#else
+ /* PNS not allowed in DRM */
+ if (ics->sect_cb[g][i] == NOISE_HCB) {
+ return 29;
+ }
+#endif
+ if (ics->sect_cb[g][i] == INTENSITY_HCB2 || ics->sect_cb[g][i] == INTENSITY_HCB) {
+ ics->is_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 (ics->window_sequence == EIGHT_SHORT_SEQUENCE) {
+ if (k + sect_len > 8 * 15) {
+ return 15;
+ }
+ if (i >= 8 * 15) {
+ return 15;
+ }
+ } else {
+ if (k + sect_len > MAX_SFB) {
+ return 15;
+ }
+ if (i >= MAX_SFB) {
+ 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;
+
+ /* the sum of all sect_len_incr elements for a given window
+ * group shall equal max_sfb */
+ if (k != ics->max_sfb) {
+ return 32;
+ }
+#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 */
+
+#ifndef DRM
+ /* 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
+#else
+ /* PNS not allowed in DRM */
+ return 29;
+#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(NeAACDecStruct *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) {
+#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, 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(NeAACDecStruct *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(NeAACDecStruct *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"));
+ }
+}
+
+/* LATM parsing functions */
+
+static uint32_t latm_get_value(bitfile *ld)
+{
+ uint32_t l, value;
+ uint8_t bytesForValue;
+
+ bytesForValue = (uint8_t)faad_getbits(ld, 2);
+ value = 0;
+ for (l = 0; l < bytesForValue; l++) {
+ value = (value << 8) | (uint8_t)faad_getbits(ld, 8);
+ }
+
+ return value;
+}
+
+
+static uint32_t latmParsePayload(latm_header *latm, bitfile *ld)
+{
+ //assuming there's only one program with a single layer and 1 subFrame,
+ //allStreamsSametimeframing is set,
+ uint32_t framelen;
+ uint8_t tmp;
+
+ //this should be the payload length field for the current configuration
+ framelen = 0;
+ if (latm->framelen_type == 0) {
+ do {
+ tmp = (uint8_t)faad_getbits(ld, 8);
+ framelen += tmp;
+ } while (tmp == 0xff);
+ } else if (latm->framelen_type == 1) {
+ framelen = latm->frameLength;
+ }
+
+ return framelen;
+}
+
+
+static uint32_t latmAudioMuxElement(latm_header *latm, bitfile *ld)
+{
+ uint32_t ascLen, asc_bits = 0;
+ uint32_t x1, y1, m, n, i;
+ program_config pce;
+ mp4AudioSpecificConfig mp4ASC;
+
+ latm->useSameStreamMux = (uint8_t)faad_getbits(ld, 1);
+ if (!latm->useSameStreamMux) {
+ //parseSameStreamMuxConfig
+ latm->version = (uint8_t) faad_getbits(ld, 1);
+ if (latm->version) {
+ latm->versionA = (uint8_t) faad_getbits(ld, 1);
+ }
+ if (latm->versionA) {
+ //dunno the payload format for versionA
+ fprintf(stderr, "versionA not supported\n");
+ return 0;
+ }
+ if (latm->version) { //read taraBufferFullness
+ latm_get_value(ld);
+ }
+ latm->allStreamsSameTimeFraming = (uint8_t)faad_getbits(ld, 1);
+ latm->numSubFrames = (uint8_t)faad_getbits(ld, 6) + 1;
+ latm->numPrograms = (uint8_t)faad_getbits(ld, 4) + 1;
+ latm->numLayers = faad_getbits(ld, 3) + 1;
+ if (latm->numPrograms > 1 || !latm->allStreamsSameTimeFraming || latm->numSubFrames > 1 || latm->numLayers > 1) {
+ fprintf(stderr, "\r\nUnsupported LATM configuration: %d programs/ %d subframes, %d layers, allstreams: %d\n",
+ latm->numPrograms, latm->numSubFrames, latm->numLayers, latm->allStreamsSameTimeFraming);
+ return 0;
+ }
+ ascLen = 0;
+ if (latm->version) {
+ ascLen = latm_get_value(ld);
+ }
+
+ x1 = faad_get_processed_bits(ld);
+ if (AudioSpecificConfigFromBitfile(ld, &mp4ASC, &pce, 0, 1) < 0) {
+ return 0;
+ }
+
+ //horrid hack to unread the ASC bits and store them in latm->ASC
+ //the correct code would rely on an ideal faad_ungetbits()
+ y1 = faad_get_processed_bits(ld);
+ if ((y1 - x1) <= MAX_ASC_BYTES * 8) {
+ faad_rewindbits(ld);
+ m = x1;
+ while (m > 0) {
+ n = min(m, 32);
+ faad_getbits(ld, n);
+ m -= n;
+ }
+
+ i = 0;
+ m = latm->ASCbits = y1 - x1;
+ while (m > 0) {
+ n = min(m, 8);
+ latm->ASC[i++] = (uint8_t) faad_getbits(ld, n);
+ m -= n;
+ }
+ }
+
+ asc_bits = y1 - x1;
+
+ if (ascLen > asc_bits) {
+ faad_getbits(ld, ascLen - asc_bits);
+ }
+
+ latm->framelen_type = (uint8_t) faad_getbits(ld, 3);
+ if (latm->framelen_type == 0) {
+ latm->frameLength = 0;
+ faad_getbits(ld, 8); //buffer fullness for frame_len_type==0, useless
+ } else if (latm->framelen_type == 1) {
+ latm->frameLength = faad_getbits(ld, 9);
+ if (latm->frameLength == 0) {
+ fprintf(stderr, "Invalid frameLength: 0\r\n");
+ return 0;
+ }
+ latm->frameLength = (latm->frameLength + 20) * 8;
+ } else {
+ //hellish CELP or HCVX stuff, discard
+ fprintf(stderr, "Unsupported CELP/HCVX framelentype: %d\n", latm->framelen_type);
+ return 0;
+ }
+
+ latm->otherDataLenBits = 0;
+ if (faad_getbits(ld, 1)) {
+ //other data present
+ int esc, tmp;
+ if (latm->version) {
+ latm->otherDataLenBits = latm_get_value(ld);
+ } else do {
+ esc = faad_getbits(ld, 1);
+ tmp = faad_getbits(ld, 8);
+ latm->otherDataLenBits = (latm->otherDataLenBits << 8) + tmp;
+ } while (esc);
+ }
+ if (faad_getbits(ld, 1)) { //crc
+ faad_getbits(ld, 8);
+ }
+ latm->inited = 1;
+ }
+
+ //read payload
+ if (latm->inited) {
+ return latmParsePayload(latm, ld);
+ } else {
+ return 0;
+ }
+}
+
+
+uint32_t faad_latm_frame(latm_header *latm, bitfile *ld)
+{
+ uint16_t len;
+ uint32_t initpos, endpos, firstpos, ret;
+
+ firstpos = faad_get_processed_bits(ld);
+ while (ld->bytes_left) {
+ faad_byte_align(ld);
+ if (faad_showbits(ld, 11) != 0x2B7) {
+ faad_getbits(ld, 8);
+ continue;
+ }
+ faad_getbits(ld, 11);
+ len = faad_getbits(ld, 13);
+ if (!len) {
+ continue;
+ }
+ initpos = faad_get_processed_bits(ld);
+ ret = latmAudioMuxElement(latm, ld);
+ endpos = faad_get_processed_bits(ld);
+ if (ret > 0) {
+ return (len * 8) - (endpos - initpos);
+ }
+ //faad_getbits(ld, initpos-endpos); //go back to initpos, but is valid a getbits(-N) ?
+ }
+ return -1U;
+}
diff --git a/audio_codec/libfaad/syntax.h b/audio_codec/libfaad/syntax.h
new file mode 100644
index 0000000..35d79f8
--- a/dev/null
+++ b/audio_codec/libfaad/syntax.h
@@ -0,0 +1,129 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: syntax.h,v 1.60 2009/01/26 23:51:17 menno Exp $
+**/
+
+#ifndef __SYNTAX_H__
+#define __SYNTAX_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#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
+#define LATM 3
+
+ /* 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(NeAACDecStruct *hDecoder, NeAACDecFrameInfo *hInfo,
+ bitfile *ld, program_config *pce, drc_info *drc);
+ uint8_t reordered_spectral_data(NeAACDecStruct *hDecoder, ic_stream *ics, bitfile *ld,
+ int16_t *spectral_data);
+#ifdef DRM
+ void DRM_aac_scalable_main_element(NeAACDecStruct *hDecoder, NeAACDecFrameInfo *hInfo,
+ bitfile *ld, program_config *pce, drc_info *drc);
+#endif
+ uint32_t faad_latm_frame(latm_header *latm, bitfile *ld);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/audio_codec/libfaad/tns.c b/audio_codec/libfaad/tns.c
new file mode 100644
index 0000000..a0718eb
--- a/dev/null
+++ b/audio_codec/libfaad/tns.c
@@ -0,0 +1,304 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: tns.c,v 1.40 2007/11/01 12:33:40 menno Exp $
+**/
+
+#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,
+ uint8_t order);
+static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc,
+ uint8_t order);
+
+
+#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 = min(ics->swb_offset[start], ics->swb_offset_max);
+
+ end = min(top, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE)));
+ end = min(end, ics->max_sfb);
+ end = min(ics->swb_offset[end], ics->swb_offset_max);
+
+ 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);
+ }
+ }
+}
+
+/* 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 = min(ics->swb_offset[start], ics->swb_offset_max);
+
+ end = min(top, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE)));
+ end = min(end, ics->max_sfb);
+ end = min(ics->swb_offset[end], ics->swb_offset_max);
+
+ 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);
+ }
+ }
+}
+
+/* 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<m */
+ b[i] = a[i] + MUL_C(tmp2[m - 1], a[m - i]);
+ }
+
+ for (i = 1; i < m; i++) { /* loop only while i<m */
+ a[i] = b[i];
+ }
+
+ a[m] = tmp2[m - 1]; /* changed */
+ }
+}
+
+static void tns_ar_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc,
+ uint8_t order)
+{
+ /*
+ - Simple all-pole filter of order "order" defined by
+ y(n) = x(n) - lpc[1]*y(n-1) - ... - lpc[order]*y(n-order)
+ - The state variables of the filter are initialized to zero every time
+ - The output data is written over the input data ("in-place operation")
+ - An input vector of "size" samples is processed and the index increment
+ to the next data sample is given by "inc"
+ */
+
+ uint8_t j;
+ uint16_t i;
+ real_t y;
+ /* state is stored as a double ringbuffer */
+ real_t state[2 * TNS_MAX_ORDER] = {0};
+ int8_t state_index = 0;
+
+ for (i = 0; i < size; i++) {
+ y = *spectrum;
+
+ for (j = 0; j < order; j++) {
+ y -= MUL_C(state[state_index + j], lpc[j + 1]);
+ }
+
+ /* double ringbuffer state */
+ state_index--;
+ if (state_index < 0) {
+ state_index = order - 1;
+ }
+ state[state_index] = state[state_index + order] = y;
+
+ *spectrum = y;
+ spectrum += inc;
+
+ //#define TNS_PRINT
+#ifdef TNS_PRINT
+ //printf("%d\n", y);
+ printf("0x%.8X\n", y);
+#endif
+ }
+}
+
+static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc,
+ uint8_t order)
+{
+ /*
+ - Simple all-zero filter of order "order" defined by
+ y(n) = x(n) + a(2)*x(n-1) + ... + a(order+1)*x(n-order)
+ - The state variables of the filter are initialized to zero every time
+ - The output data is written over the input data ("in-place operation")
+ - An input vector of "size" samples is processed and the index increment
+ to the next data sample is given by "inc"
+ */
+
+ uint8_t j;
+ uint16_t i;
+ real_t y;
+ /* state is stored as a double ringbuffer */
+ real_t state[2 * TNS_MAX_ORDER] = {0};
+ int8_t state_index = 0;
+
+ for (i = 0; i < size; i++) {
+ y = *spectrum;
+
+ for (j = 0; j < order; j++) {
+ y += MUL_C(state[state_index + j], lpc[j + 1]);
+ }
+
+ /* double ringbuffer state */
+ state_index--;
+ if (state_index < 0) {
+ state_index = order - 1;
+ }
+ state[state_index] = state[state_index + order] = *spectrum;
+
+ *spectrum = y;
+ spectrum += inc;
+ }
+}
diff --git a/audio_codec/libfaad/tns.h b/audio_codec/libfaad/tns.h
new file mode 100644
index 0000000..851bd78
--- a/dev/null
+++ b/audio_codec/libfaad/tns.h
@@ -0,0 +1,51 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 M. Bakker, Nero 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.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: tns.h,v 1.23 2007/11/01 12:33:41 menno Exp $
+**/
+
+#ifndef __TNS_H__
+#define __TNS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define TNS_MAX_ORDER 20
+
+
+ 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);
+ 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);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/audio_codec/libflac/Android.mk b/audio_codec/libflac/Android.mk
new file mode 100755
index 0000000..47d5d5a
--- a/dev/null
+++ b/audio_codec/libflac/Android.mk
@@ -0,0 +1,22 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libflac
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+LOCAL_ARM_MODE := arm
+LOCAL_C_INCLUDES := $(LOCAL_PATH) \
+
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_SHARED_LIBRARIES += libutils libmedia libz libbinder libdl libcutils libc
+
+LOCAL_MODULE := libflac
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+LOCAL_ARM_MODE := arm
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := $(LOCAL_PATH) \
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/audio_codec/libflac/avcodec.h b/audio_codec/libflac/avcodec.h
new file mode 100644
index 0000000..1bdcb3c
--- a/dev/null
+++ b/audio_codec/libflac/avcodec.h
@@ -0,0 +1,337 @@
+/*
+ * 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
+
+#ifndef __MW__
+#include <inttypes.h>
+#else
+#include <core/types.h>
+#endif
+
+
+#define FF_INPUT_BUFFER_PADDING_SIZE 8
+
+enum CodecID {
+ CODEC_ID_NONE,
+
+ /* 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,
+
+ /* 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,
+
+ /* 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) */
+};
+
+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
+};
+
+enum CodecType {
+ CODEC_TYPE_UNKNOWN = -1,
+ CODEC_TYPE_VIDEO,
+ CODEC_TYPE_AUDIO,
+ CODEC_TYPE_DATA,
+ CODEC_TYPE_SUBTITLE,
+ CODEC_TYPE_ATTACHMENT,
+ CODEC_TYPE_NB
+};
+
+/* 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.
+
+/* 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
+
+typedef struct AVCodecContext {
+ /**
+ * 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;
+
+ /* 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
+
+ char codec_name[32];
+ enum CodecType codec_type; /* see CODEC_TYPE_xxx */
+ enum CodecID codec_id; /* see CODEC_ID_xxx */
+
+ /**
+ * 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;
+
+ int block_align;
+
+ /**
+ * Audio channel layout.
+ * - encoding: set by user.
+ * - decoding: set by libavcodec.
+ */
+ int64_t channel_layout;
+} AVCodecContext;
+
+#endif /* AVCODEC_AVCODEC_H */
diff --git a/audio_codec/libflac/bswap.h b/audio_codec/libflac/bswap.h
new file mode 100644
index 0000000..3614057
--- a/dev/null
+++ b/audio_codec/libflac/bswap.h
@@ -0,0 +1,94 @@
+/*
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * 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 libavutil/bswap.h
+ * byte swapping routines
+ */
+
+#ifndef AVUTIL_BSWAP_H
+#define AVUTIL_BSWAP_H
+
+#ifdef __MW__
+#define inline __inline
+#include <core/types.h>
+#else
+#include <stdint.h>
+#endif
+#include "common.h"
+#include <stdint.h>
+
+#ifndef bswap_16
+static av_always_inline av_const uint16_t bswap_16(uint16_t x)
+{
+ x = (x >> 8) | (x << 8);
+ return x;
+}
+#endif
+
+#ifndef bswap_32
+static av_always_inline av_const uint32_t bswap_32(uint32_t x)
+{
+ x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0x00FF00FF);
+ x = (x >> 16) | (x << 16);
+ return x;
+}
+#endif
+
+#ifndef bswap_64
+static inline uint64_t av_const bswap_64(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] = bswap_32(w.l[1]);
+ r.l[1] = bswap_32(w.l[0]);
+ return r.ll;
+#endif
+}
+#endif
+
+// be2me ... big-endian to machine-endian
+// le2me ... little-endian to machine-endian
+
+#if HAVE_BIGENDIAN
+#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 /* AVUTIL_BSWAP_H */
diff --git a/audio_codec/libflac/codec.h b/audio_codec/libflac/codec.h
new file mode 100644
index 0000000..97d6fbc
--- a/dev/null
+++ b/audio_codec/libflac/codec.h
@@ -0,0 +1,36 @@
+#ifndef DSP_CODEC_HEADER
+#define DSP_CODEC_HEADER
+#include "codec_message.h"
+
+struct codec_type {
+ char *name;
+ int (*init)(struct frame_fmt *);
+ int (*release)(void);
+ // return BYTEs number for the samples
+ int (*decode_frame)(unsigned char *, int, struct frame_fmt *);
+};
+
+/*data in*/
+int read_bits(int bits);
+int bits_left(void);
+int reset_bits(void);
+int read_byte(void);
+int read_buffer(unsigned char *buffer, int size);
+int get_inbuf_data_size(void);
+unsigned long get_stream_in_offset(void);
+int stream_in_buffer_init(void);
+
+/*data out*/
+int write_buffer(unsigned char *buf, int size);
+int get_outbuf_space(void);
+int out_buffer_init(void);
+
+/*mgt*/
+int codec_start(void);
+int codec_resume(void);
+int codec_pause(void);
+int register_codec(const struct codec_type *mc);
+void decode_error_msg(int error);
+void trans_err_code(error_code_t error);
+
+#endif
diff --git a/audio_codec/libflac/codec_message.h b/audio_codec/libflac/codec_message.h
new file mode 100644
index 0000000..0301283
--- a/dev/null
+++ b/audio_codec/libflac/codec_message.h
@@ -0,0 +1,109 @@
+#ifndef _CODEC_MESSAGE_HEADERS
+#define _CODEC_MESSAGE_HEADERS
+
+
+#define SUB_FMT_VALID (1<<1)
+#define CHANNEL_VALID (1<<2)
+#define SAMPLE_RATE_VALID (1<<3)
+#define DATA_WIDTH_VALID (1<<4)
+
+#define AUDIO_EXTRA_DATA_SIZE (2048*2)
+
+struct digit_raw_output_info {
+ int framelength;
+ unsigned char* framebuf;
+ int frame_size;
+ int frame_samples;
+ unsigned char* rawptr;
+ //for AC3
+ int sampleratecode;
+ int bsmod;
+
+ int bpf;
+ int brst;
+ int length;
+ int padsize;
+ int mode;
+ unsigned int syncword1;
+ unsigned int syncword2;
+ unsigned int syncword3;
+
+ unsigned int syncword1_mask;
+ unsigned int syncword2_mask;
+ unsigned int syncword3_mask;
+
+ unsigned chstat0_l;
+ unsigned chstat0_r;
+ unsigned chstat1_l;
+ unsigned chstat1_r;
+
+ unsigned can_bypass;
+};
+struct frame_fmt {
+ int valid;
+ int sub_fmt;
+ int channel_num;
+ int sample_rate;
+ int data_width;
+ int buffered_len;/*dsp codec,buffered origan data len*/
+ int format;
+ unsigned int total_byte_parsed;
+ union {
+ unsigned int total_sample_decoded;
+ void *pcm_encoded_info; //used for encoded pcm info
+ } data;
+ unsigned int bps;
+ void* private_data;
+ struct digit_raw_output_info * digit_raw_output_info;
+};
+
+typedef struct pcm51_encoded_info_s {
+ unsigned int InfoValidFlag; //only if InfoValidFlag==1 can userspace start reading the data in 51pcm_buf;
+ unsigned int SampFs; //sampling frequency
+ unsigned int NumCh; //total output valid channels( including LFE channel if LFE is valid)
+ unsigned int AcMode; //audio coding mode
+ unsigned int LFEFlag; //indicating the output buffers cotains LFE components if LFEFlag==1
+ unsigned int BitsPerSamp; //bits count used to indicates a pcm_samples
+} pcm51_encoded_info_t;
+
+
+struct frame_info {
+ int len;
+ unsigned long offset;/*steam start to here*/
+ unsigned long buffered_len;/*data buffer in dsp,pcm datalen*/
+ int reversed[1];/*for cache aligned 32 bytes*/
+};
+
+struct audio_info {
+ int valid;
+ int sample_rate;
+ int channels;
+ int bitrate;
+ int codec_id;
+ int block_align;
+ int extradata_size;
+ char extradata[AUDIO_EXTRA_DATA_SIZE];
+};
+
+typedef enum {
+ DECODE_INIT_ERR,
+ DECODE_FATAL_ERR,
+} error_code_t;
+
+struct dsp_working_info {
+ int status;
+ int sp;
+ int pc;
+ int ilink1;
+ int ilink2;
+ int blink;
+ int jeffies;
+ int out_wp;
+ int out_rp;
+ int buffered_len;//pcm buffered at the dsp side
+ int es_offset;//stream read offset since start decoder
+ int reserved[5];
+};
+
+#endif
+
diff --git a/audio_codec/libflac/common.h b/audio_codec/libflac/common.h
new file mode 100644
index 0000000..7c5497e
--- a/dev/null
+++ b/audio_codec/libflac/common.h
@@ -0,0 +1,356 @@
+/*
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * 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 libavutil/common.h
+ * common internal and external API header
+ */
+
+#ifndef AVUTIL_COMMON_H
+#define AVUTIL_COMMON_H
+
+#include <string.h>
+#ifdef __MW__
+#include "types.h"
+#endif
+
+#ifndef __MW__
+#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
+#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_uninit
+#if defined(__GNUC__) && !defined(__ICC)
+# define av_uninit(x) x=x
+#else
+# define av_uninit(x) x
+#endif
+#endif
+#ifndef inline
+#define inline
+#endif
+//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 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
+};
+
+static inline av_const int av_log2(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(unsigned int v)
+{
+ int n = 0;
+ if (v & 0xff00) {
+ v >>= 8;
+ n += 8;
+ }
+ n += ff_log2_tab[v];
+
+ return n;
+}
+
+/**
+ * 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 av_const int av_clip(int a, int amin, int amax)
+{
+ if (a < amin) {
+ return amin;
+ } else if (a > amax) {
+ return amax;
+ } else {
+ return a;
+ }
+}
+
+/**
+ * Clips 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(int a)
+{
+ if (a & (~255)) {
+ return (-a) >> 31;
+ } else {
+ return a;
+ }
+}
+
+/**
+ * Clips 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(int a)
+{
+ if (a & (~65535)) {
+ return (-a) >> 31;
+ } else {
+ return a;
+ }
+}
+
+/**
+ * Clips 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(int a)
+{
+ if ((a + 32768) & ~65535) {
+ return (a >> 31) ^ 32767;
+ } else {
+ return a;
+ }
+}
+
+/**
+ * Clips 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(float a, float amin, float amax)
+{
+ if (a < amin) {
+ return amin;
+ } else if (a > amax) {
+ return amax;
+ } else {
+ return a;
+ }
+}
+
+/** Computes 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(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))
+
+/*!
+ * \def GET_UTF8(val, GET_BYTE, ERROR)
+ * Converts a UTF-8 character (up to 4 bytes long) to its 32-bit UCS-4 encoded form
+ * \param val is the output and should be of type uint32_t. It holds the converted
+ * UCS-4 character and should be a left value.
+ * \param GET_BYTE gets UTF-8 encoded bytes from any proper source. It can be
+ * a function or a statement whose return value or evaluated value is of type
+ * uint8_t. It will be executed up to 4 times for values in the valid UTF-8 range,
+ * and up to 7 times in the general case.
+ * \param ERROR action that should be taken when an invalid UTF-8 byte is returned
+ * from GET_BYTE. It should be a statement that jumps out of the macro,
+ * like exit(), goto, return, break, or continue.
+ */
+#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;\
+ }\
+ }
+
+/*!
+ * \def GET_UTF16(val, GET_16BIT, ERROR)
+ * Converts a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form
+ * \param val is the output and should be of type uint32_t. It holds the converted
+ * UCS-4 character and should be a left value.
+ * \param GET_16BIT gets two bytes of UTF-16 encoded data converted to native endianness.
+ * It can be a function or a statement whose return value or evaluated value is of type
+ * uint16_t. It will be executed up to 2 times.
+ * \param ERROR action that should be taken when an invalid UTF-16 surrogate is
+ * returned from GET_BYTE. It should be a statement that jumps out of the macro,
+ * like exit(), goto, return, break, or continue.
+ */
+#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)
+ * Converts 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\
+ }\
+ }\
+ }
+
+//#include "mem.h"
+
+#endif /* AVUTIL_COMMON_H */
diff --git a/audio_codec/libflac/crc.c b/audio_codec/libflac/crc.c
new file mode 100644
index 0000000..97221df
--- a/dev/null
+++ b/audio_codec/libflac/crc.c
@@ -0,0 +1,146 @@
+/*
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * 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 "bswap.h"
+#include "crc.h"
+
+#if CONFIG_HARDCODED_TABLES
+#include "crc_data.h"
+#else
+static struct {
+ uint8_t le;
+ uint8_t bits;
+ uint32_t poly;
+} av_crc_table_params[AV_CRC_MAX] = {
+ [AV_CRC_8_ATM] = { 0, 8, 0x07 },
+ [AV_CRC_16_ANSI] = { 0, 16, 0x8005 },
+ [AV_CRC_16_CCITT] = { 0, 16, 0x1021 },
+ [AV_CRC_32_IEEE] = { 0, 32, 0x04C11DB7 },
+ [AV_CRC_32_IEEE_LE] = { 1, 32, 0xEDB88320 },
+};
+static AVCRC av_crc_table[AV_CRC_MAX][257];
+#endif
+
+/**
+ * Initializes a CRC table.
+ * @param ctx must be an array of size sizeof(AVCRC)*257 or sizeof(AVCRC)*1024
+ * @param cts_size size of ctx in bytes
+ * @param le If 1, the lowest bit represents the coefficient for the highest
+ * exponent of the corresponding polynomial (both for poly and
+ * actual CRC).
+ * If 0, you must swap the CRC parameter and the result of av_crc
+ * if you need the standard representation (can be simplified in
+ * most cases to e.g. bswap16):
+ * bswap_32(crc << (32-bits))
+ * @param bits number of bits for the CRC
+ * @param poly generator polynomial without the x**bits coefficient, in the
+ * representation as specified by le
+ * @return <0 on failure
+ */
+int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size)
+{
+ int i, j;
+ uint32_t c;
+
+ if (bits < 8 || bits > 32 || poly >= (1LL << bits)) {
+ return -1;
+ }
+ if (ctx_size != sizeof(AVCRC) * 257 && ctx_size != sizeof(AVCRC) * 1024) {
+ return -1;
+ }
+
+ for (i = 0; i < 256; i++) {
+ if (le) {
+ for (c = i, j = 0; j < 8; j++) {
+ c = (c >> 1) ^(poly & (-(c & 1)));
+ }
+ ctx[i] = c;
+ } else {
+ for (c = i << 24, j = 0; j < 8; j++) {
+ c = (c << 1) ^((poly << (32 - bits)) & (((int32_t)c) >> 31));
+ }
+ ctx[i] = bswap_32(c);
+ }
+ }
+ ctx[256] = 1;
+ //#if !CONFIG_SMALL
+ if (ctx_size >= sizeof(AVCRC) * 1024)
+ for (i = 0; i < 256; i++)
+ for (j = 0; j < 3; j++) {
+ ctx[256 * (j + 1) + i] = (ctx[256 * j + i] >> 8) ^ ctx[ ctx[256 * j + i] & 0xFF ];
+ }
+ //#endif
+
+ return 0;
+}
+
+/**
+ * Gets an initialized standard CRC table.
+ * @param crc_id ID of a standard CRC
+ * @return a pointer to the CRC table or NULL on failure
+ */
+const AVCRC *av_crc_get_table(AVCRCId crc_id)
+{
+ //#if !CONFIG_HARDCODED_TABLES
+ if (!av_crc_table[crc_id][FF_ARRAY_ELEMS(av_crc_table[crc_id]) - 1])
+ if (av_crc_init(av_crc_table[crc_id],
+ av_crc_table_params[crc_id].le,
+ av_crc_table_params[crc_id].bits,
+ av_crc_table_params[crc_id].poly,
+ sizeof(av_crc_table[crc_id])) < 0) {
+ return NULL;
+ }
+ //#endif
+ return av_crc_table[crc_id];
+}
+
+/**
+ * Calculates the CRC of a block.
+ * @param crc CRC of previous blocks if any or initial value for CRC
+ * @return CRC updated with the data from the given block
+ *
+ * @see av_crc_init() "le" parameter
+ */
+uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
+{
+ const uint8_t *end = buffer + length;
+
+ //#if !CONFIG_SMALL
+ if (!ctx[256]) {
+ while (((intptr_t) buffer & 3) && buffer < end) {
+ crc = ctx[((uint8_t)crc) ^ *buffer++] ^(crc >> 8);
+ }
+
+ while (buffer < end - 3) {
+ crc ^= le2me_32(*(const uint32_t*)buffer);
+ buffer += 4;
+ crc = ctx[3 * 256 + (crc & 0xFF)]
+ ^ ctx[2 * 256 + ((crc >> 8) & 0xFF)]
+ ^ ctx[1 * 256 + ((crc >> 16) & 0xFF)]
+ ^ ctx[0 * 256 + ((crc >> 24))];
+ }
+ }
+ //#endif
+ while (buffer < end) {
+ crc = ctx[((uint8_t)crc) ^ *buffer++] ^(crc >> 8);
+ }
+
+ return crc;
+}
diff --git a/audio_codec/libflac/crc.h b/audio_codec/libflac/crc.h
new file mode 100644
index 0000000..f8ed581
--- a/dev/null
+++ b/audio_codec/libflac/crc.h
@@ -0,0 +1,46 @@
+/*
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * 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_CRC_H
+#define AVUTIL_CRC_H
+#if 1
+#include <stdint.h>
+#else
+typedef int intptr_t;
+#endif
+#include <stddef.h>
+#include "common.h"
+typedef uint32_t AVCRC;
+
+typedef enum {
+ AV_CRC_8_ATM,
+ AV_CRC_16_ANSI,
+ AV_CRC_16_CCITT,
+ AV_CRC_32_IEEE,
+ AV_CRC_32_IEEE_LE, /*< reversed bitorder version of AV_CRC_32_IEEE */
+ AV_CRC_MAX, /*< Not part of public API! Do not use outside libavutil. */
+} AVCRCId;
+
+int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size);
+const AVCRC *av_crc_get_table(AVCRCId crc_id);
+uint32_t av_crc(const AVCRC *ctx, uint32_t start_crc, const uint8_t *buffer, size_t length) av_pure;
+
+#endif /* AVUTIL_CRC_H */
+
diff --git a/audio_codec/libflac/flac.c b/audio_codec/libflac/flac.c
new file mode 100644
index 0000000..d606494
--- a/dev/null
+++ b/audio_codec/libflac/flac.c
@@ -0,0 +1,43 @@
+/*
+ * FLAC common code
+ * Copyright (c) 2009 Justin Ruggles
+ *
+ * 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 "flac.h"
+
+int ff_flac_get_max_frame_size(int blocksize, int ch, int bps)
+{
+ /* Technically, there is no limit to FLAC frame size, but an encoder
+ should not write a frame that is larger than if verbatim encoding mode
+ were to be used. */
+
+ int count;
+
+ count = 16; /* frame header */
+ count += ch * ((7 + bps + 7) / 8); /* subframe headers */
+ if (ch == 2) {
+ /* for stereo, need to account for using decorrelation */
+ count += ((2 * bps + 1) * blocksize + 7) / 8;
+ } else {
+ count += (ch * bps * blocksize + 7) / 8;
+ }
+ count += 2; /* frame footer */
+
+ return count;
+}
diff --git a/audio_codec/libflac/flac.h b/audio_codec/libflac/flac.h
new file mode 100644
index 0000000..115c06e
--- a/dev/null
+++ b/audio_codec/libflac/flac.h
@@ -0,0 +1,124 @@
+/*
+ * FLAC (Free Lossless Audio Codec) decoder/demuxer common functions
+ * Copyright (c) 2008 Justin Ruggles
+ *
+ * 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/flac.h
+ * FLAC (Free Lossless Audio Codec) decoder/demuxer common functions
+ */
+
+#ifndef AVCODEC_FLAC_H
+#define AVCODEC_FLAC_H
+
+#include "avcodec.h"
+
+#define FLAC_STREAMINFO_SIZE 34
+#define FLAC_MAX_CHANNELS 8
+#define FLAC_MIN_BLOCKSIZE 16
+#define FLAC_MAX_BLOCKSIZE 65535
+#define FLAC_MIN_FRAME_SIZE 11
+
+enum {
+ FLAC_CHMODE_INDEPENDENT = 0,
+ FLAC_CHMODE_LEFT_SIDE = 8,
+ FLAC_CHMODE_RIGHT_SIDE = 9,
+ FLAC_CHMODE_MID_SIDE = 10,
+};
+
+enum {
+ FLAC_METADATA_TYPE_STREAMINFO = 0,
+ FLAC_METADATA_TYPE_PADDING,
+ FLAC_METADATA_TYPE_APPLICATION,
+ FLAC_METADATA_TYPE_SEEKTABLE,
+ FLAC_METADATA_TYPE_VORBIS_COMMENT,
+ FLAC_METADATA_TYPE_CUESHEET,
+ FLAC_METADATA_TYPE_PICTURE,
+ FLAC_METADATA_TYPE_INVALID = 127
+};
+
+enum FLACExtradataFormat {
+ FLAC_EXTRADATA_FORMAT_STREAMINFO = 0,
+ FLAC_EXTRADATA_FORMAT_FULL_HEADER = 1
+};
+
+#define FLACCOMMONINFO \
+ int samplerate; /**< sample rate */\
+ int channels; /**< number of channels */\
+ int bps; /**< bits-per-sample */\
+
+/**
+ * Data needed from the Streaminfo header for use by the raw FLAC demuxer
+ * and/or the FLAC decoder.
+ */
+#define FLACSTREAMINFO \
+ FLACCOMMONINFO \
+ int max_blocksize; /**< maximum block size, in samples */\
+ int max_framesize; /**< maximum frame size, in bytes */\
+ int64_t samples; /**< total number of samples */\
+
+typedef struct FLACStreaminfo {
+ FLACSTREAMINFO
+} FLACStreaminfo;
+
+typedef struct FLACFrameInfo {
+ FLACCOMMONINFO
+ int blocksize; /**< block size of the frame */
+ int ch_mode; /**< channel decorrelation mode */
+} FLACFrameInfo;
+
+/**
+ * Parse the Streaminfo metadata block
+ * @param[out] avctx codec context to set basic stream parameters
+ * @param[out] s where parsed information is stored
+ * @param[in] buffer pointer to start of 34-byte streaminfo data
+ */
+void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
+ const uint8_t *buffer);
+
+/**
+ * Validate the FLAC extradata.
+ * @param[in] avctx codec context containing the extradata.
+ * @param[out] format extradata format.
+ * @param[out] streaminfo_start pointer to start of 34-byte STREAMINFO data.
+ * @return 1 if valid, 0 if not valid.
+ */
+int ff_flac_is_extradata_valid(AVCodecContext *avctx,
+ enum FLACExtradataFormat *format,
+ uint8_t **streaminfo_start);
+
+/**
+ * Parse the metadata block parameters from the header.
+ * @param[in] block_header header data, at least 4 bytes
+ * @param[out] last indicator for last metadata block
+ * @param[out] type metadata block type
+ * @param[out] size metadata block size
+ */
+void ff_flac_parse_block_header(const uint8_t *block_header,
+ int *last, int *type, int *size);
+
+/**
+ * Calculate an estimate for the maximum frame size based on verbatim mode.
+ * @param blocksize block size, in samples
+ * @param ch number of channels
+ * @param bps bits-per-sample
+ */
+int ff_flac_get_max_frame_size(int blocksize, int ch, int bps);
+
+#endif /* AVCODEC_FLAC_H */
diff --git a/audio_codec/libflac/flac_decode.c b/audio_codec/libflac/flac_decode.c
new file mode 100644
index 0000000..e1ddaaf
--- a/dev/null
+++ b/audio_codec/libflac/flac_decode.c
@@ -0,0 +1,943 @@
+/*
+* filename: flac_decode.c
+*
+*
+*
+*
+*
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include "codec.h"
+#ifndef __MW__
+#include <inttypes.h>
+#else
+#include "types.h"
+#endif
+#include "crc.h"
+#include "avcodec.h"
+#include "get_bits.h"
+#include "golomb.h"
+
+#include "flac.h"
+#include "flacdata.h"
+#include "../../amadec/adec-armdec-mgt.h"
+
+#include <android/log.h>
+
+#define LOG_TAG "FlacDecoder"
+#define audio_codec_print(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+#define DefaultReadSize 1024*10 //read count from kernel audio buf one time
+#define DefaultOutBufSize 1024*1024
+
+typedef struct OutData {
+ uint8_t * outb;
+ int byte;
+ int index;
+} OutData;
+
+typedef struct FLACContext {
+ FLACSTREAMINFO
+
+ AVCodecContext *avctx; ///< parent AVCodecContext
+ GetBitContext gb; ///< GetBitContext initialized to start at the current frame
+
+ int blocksize; ///< number of samples in the current frame
+ int curr_bps; ///< bps for current subframe, adjusted for channel correlation and wasted bits
+ int sample_shift; ///< shift required to make output samples 16-bit or 32-bit
+ int is32; ///< flag to indicate if output should be 32-bit instead of 16-bit
+ int ch_mode; ///< channel decorrelation type in the current frame
+ int got_streaminfo; ///< indicates if the STREAMINFO has been read
+
+ int32_t *decoded[FLAC_MAX_CHANNELS]; ///< decoded samples
+ uint8_t *bitstream;
+ unsigned int bitstream_size;
+ unsigned int bitstream_index;
+ unsigned int allocated_bitstream_size;
+} FLACContext;
+
+static const int sample_size_table[] =
+{ 0, 8, 12, 0, 16, 20, 24, 0 };
+
+static AVCodecContext acodec;
+static FLACContext flactext;
+static OutData outbuffer;
+#define INPUT_BUF_SIZE 32768
+static int64_t get_utf8(GetBitContext *gb)
+{
+ int64_t val;
+ GET_UTF8(val, get_bits(gb, 8), return -1;)
+ return val;
+}
+
+void *av_malloc(unsigned int size)
+{
+ void *ptr = NULL;
+
+ ptr = malloc(size);
+ return ptr;
+}
+
+void *av_realloc(void *ptr, unsigned int size)
+{
+ return realloc(ptr, size);
+}
+
+void av_freep(void **arg)
+{
+ if (*arg) {
+ free(*arg);
+ }
+ *arg = NULL;
+}
+void av_free(void *arg)
+{
+ if (arg) {
+ free(arg);
+ }
+}
+void *av_mallocz(unsigned int size)
+{
+ void *ptr = malloc(size);
+ if (ptr) {
+ memset(ptr, 0, size);
+ }
+ return ptr;
+}
+
+static inline uint32_t bytestream_get_be32(const uint8_t** ptr)
+{
+ uint32_t tmp;
+ tmp = (*ptr)[3] | ((*ptr)[2] << 8) | ((*ptr)[1] << 16) | ((*ptr)[0] << 24);
+ *ptr += 4;
+ return tmp;
+}
+
+static inline uint32_t bytestream_get_be24(const uint8_t** ptr)
+{
+ uint32_t tmp;
+ tmp = (*ptr)[2] | ((*ptr)[1] << 8) | ((*ptr)[0] << 16) ;
+ *ptr += 3;
+ return tmp;
+}
+
+static inline uint8_t bytestream_get_byte(const uint8_t** ptr)
+{
+ uint8_t tmp;
+ tmp = **ptr;
+ *ptr += 1;
+ return tmp;
+}
+
+
+
+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;
+}
+
+static void allocate_buffers(FLACContext *s)
+{
+ int i;
+
+ if (s->max_framesize == 0 && s->max_blocksize) {
+ s->max_framesize = ff_flac_get_max_frame_size(s->max_blocksize,
+ s->channels, s->bps);
+ }
+
+ for (i = 0; i < s->channels; i++) {
+ s->decoded[i] = av_realloc(s->decoded[i],
+ sizeof(int32_t) * s->max_blocksize);
+ }
+}
+
+
+/**
+ * Parse the STREAMINFO from an inline header.
+ * @param s the flac decoding context
+ * @param buf input buffer, starting with the "fLaC" marker
+ * @param buf_size buffer size
+ * @return non-zero if metadata is invalid
+ */
+static int parse_streaminfo(FLACContext *s, const uint8_t *buf, int buf_size)
+{
+ int metadata_type, metadata_size;
+
+ if (buf_size < FLAC_STREAMINFO_SIZE + 8) {
+ /* need more data */
+ return 0;
+ }
+ ff_flac_parse_block_header(&buf[4], NULL, &metadata_type, &metadata_size);
+ if (metadata_type != FLAC_METADATA_TYPE_STREAMINFO ||
+ metadata_size != FLAC_STREAMINFO_SIZE) {
+ return -1;//AVERROR_INVALIDDATA;
+ }
+ ff_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s, &buf[8]);
+ allocate_buffers(s);
+ s->got_streaminfo = 1;
+
+ return 0;
+}
+/**
+ * Determine the size of an inline header.
+ * @param buf input buffer, starting with the "fLaC" marker
+ * @param buf_size buffer size
+ * @return number of bytes in the header, or 0 if more data is needed
+ */
+static int get_metadata_size(const uint8_t *buf, int buf_size)
+{
+ int metadata_last, metadata_size;
+ const uint8_t *buf_end = buf + buf_size;
+
+ buf += 4;
+ do {
+ ff_flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size);
+ buf += 4;
+ if (buf + metadata_size > buf_end) {
+ /* need more data in order to read the complete header */
+ return 0;
+ }
+ buf += metadata_size;
+ } while (!metadata_last);
+
+ return buf_size - (buf_end - buf);
+}
+void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
+ const uint8_t *buffer)
+{
+ GetBitContext gb;
+ init_get_bits(&gb, buffer, FLAC_STREAMINFO_SIZE * 8);
+
+ skip_bits(&gb, 16); /* skip min blocksize */
+ s->max_blocksize = get_bits(&gb, 16);
+ if (s->max_blocksize < FLAC_MIN_BLOCKSIZE) {
+ audio_codec_print("invalid max blocksize: %d\n", s->max_blocksize);
+ s->max_blocksize = 16;
+ }
+
+ skip_bits(&gb, 24); /* skip min frame size */
+ s->max_framesize = get_bits_long(&gb, 24);
+
+ s->samplerate = get_bits_long(&gb, 20);
+ s->channels = get_bits(&gb, 3) + 1;
+ s->bps = get_bits(&gb, 5) + 1;
+
+ audio_codec_print("## METADATA sp=%d, ch=%d, bps=%d,-------------\n",
+ s->samplerate, s->channels, s->bps);
+
+ avctx->channels = s->channels;
+ avctx->sample_rate = s->samplerate;
+ avctx->bits_per_raw_sample = s->bps;
+
+ s->samples = get_bits_long(&gb, 32) << 4;
+ s->samples |= get_bits(&gb, 4);
+
+ skip_bits_long(&gb, 64); /* md5 sum */
+ skip_bits_long(&gb, 64); /* md5 sum */
+
+}
+static void allocate_buffers(FLACContext *s);
+
+int ff_flac_is_extradata_valid(AVCodecContext *avctx,
+ enum FLACExtradataFormat *format,
+ uint8_t **streaminfo_start)
+{
+ if (!avctx->extradata || avctx->extradata_size < FLAC_STREAMINFO_SIZE) {
+ audio_codec_print("extradata NULL or too small.\n");
+ return 0;
+ }
+ if (AV_RL32(avctx->extradata) != MKTAG('f', 'L', 'a', 'C')) {
+ /* extradata contains STREAMINFO only */
+ if (avctx->extradata_size != FLAC_STREAMINFO_SIZE) {
+ audio_codec_print("extradata contains %d bytes too many.\n",
+ FLAC_STREAMINFO_SIZE - avctx->extradata_size);
+ }
+ *format = FLAC_EXTRADATA_FORMAT_STREAMINFO;
+ *streaminfo_start = avctx->extradata;
+ } else {
+ if (avctx->extradata_size < 8 + FLAC_STREAMINFO_SIZE) {
+ audio_codec_print("extradata too small.\n");
+ return 0;
+ }
+ *format = FLAC_EXTRADATA_FORMAT_FULL_HEADER;
+ *streaminfo_start = &avctx->extradata[8];
+ }
+ return 1;
+}
+static int decode_residuals(FLACContext *s, int channel, int pred_order)
+{
+ int i, tmp, partition, method_type, rice_order;
+ int sample = 0, samples;
+
+ method_type = get_bits(&s->gb, 2);
+ if (method_type > 1) {
+ audio_codec_print("illegal residual coding method %d\n", method_type);
+ return -1;
+ }
+
+ rice_order = get_bits(&s->gb, 4);
+
+ samples = s->blocksize >> rice_order;
+ if (pred_order > samples) {
+ audio_codec_print("invalid predictor order: %i > %i\n", pred_order, samples);
+ return -1;
+ }
+
+ 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)) {
+ tmp = get_bits(&s->gb, 5);
+ for (; i < samples; i++, sample++) {
+ s->decoded[channel][sample] = get_sbits_long(&s->gb, tmp);
+ }
+ } else {
+ for (; i < samples; i++, sample++) {
+ s->decoded[channel][sample] = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0);
+ }
+ }
+ i = 0;
+ }
+
+ return 0;
+}
+
+
+static int decode_subframe_fixed(FLACContext *s, int channel, int pred_order)
+{
+ const int blocksize = s->blocksize;
+ int32_t *decoded = s->decoded[channel];
+ int av_uninit(a), av_uninit(b), av_uninit(c), av_uninit(d), i;
+
+ /* warm up samples */
+ for (i = 0; i < pred_order; i++) {
+ decoded[i] = get_sbits_long(&s->gb, s->curr_bps);
+ }
+
+ if (decode_residuals(s, channel, pred_order) < 0) {
+ return -1;
+ }
+
+ if (pred_order > 0) {
+ a = decoded[pred_order - 1];
+ }
+ if (pred_order > 1) {
+ b = a - decoded[pred_order - 2];
+ }
+ if (pred_order > 2) {
+ c = b - decoded[pred_order - 2] + decoded[pred_order - 3];
+ }
+ if (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:
+ audio_codec_print("illegal pred order %d\n", pred_order);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order)
+{
+ int i, j;
+ int coeff_prec, qlevel;
+ int coeffs[32];
+ int32_t *decoded = s->decoded[channel];
+
+ /* warm up samples */
+ for (i = 0; i < pred_order; i++) {
+ decoded[i] = get_sbits_long(&s->gb, s->curr_bps);
+ }
+
+ coeff_prec = get_bits(&s->gb, 4) + 1;
+ if (coeff_prec == 16) {
+ audio_codec_print("invalid coeff precision\n");
+ return -1;
+ }
+ qlevel = get_sbits(&s->gb, 5);
+ if (qlevel < 0) {
+ audio_codec_print("qlevel %d not supported, maybe buggy stream\n", qlevel);
+ return -1;
+ }
+
+ for (i = 0; i < pred_order; i++) {
+ coeffs[i] = get_sbits(&s->gb, coeff_prec);
+ }
+
+ if (decode_residuals(s, channel, pred_order) < 0) {
+ return -1;
+ }
+
+ if (s->bps > 16) {
+ int64_t sum;
+ for (i = pred_order; i < s->blocksize; i++) {
+ sum = 0;
+ for (j = 0; j < pred_order; j++) {
+ sum += (int64_t)coeffs[j] * decoded[i - j - 1];
+ }
+ decoded[i] += sum >> qlevel;
+ }
+ } else {
+ for (i = pred_order; i < s->blocksize - 1; i += 2) {
+ int c;
+ int d = decoded[i - pred_order];
+ int s0 = 0, s1 = 0;
+ for (j = pred_order - 1; j > 0; j--) {
+ c = coeffs[j];
+ s0 += c * d;
+ d = decoded[i - j];
+ s1 += c * d;
+ }
+ c = coeffs[0];
+ s0 += c * d;
+ d = decoded[i] += s0 >> qlevel;
+ s1 += c * d;
+ decoded[i + 1] += s1 >> qlevel;
+ }
+ if (i < s->blocksize) {
+ int sum = 0;
+ for (j = 0; j < pred_order; j++) {
+ sum += coeffs[j] * decoded[i - j - 1];
+ }
+ decoded[i] += sum >> qlevel;
+ }
+ }
+
+ return 0;
+}
+
+void ff_flac_parse_block_header(const uint8_t *block_header,
+ int *last, int *type, int *size)
+{
+ int tmp = bytestream_get_byte(&block_header);
+ if (last) {
+ *last = tmp & 0x80;
+ }
+ if (type) {
+ *type = tmp & 0x7F;
+ }
+ if (size) {
+ *size = bytestream_get_be24(&block_header);
+ }
+}
+
+static inline int decode_subframe(FLACContext *s, int channel)
+{
+ int type, wasted = 0;
+ int i, tmp;
+
+ s->curr_bps = s->bps;
+ if (channel == 0) {
+ if (s->ch_mode == FLAC_CHMODE_RIGHT_SIDE) {
+ s->curr_bps++;
+ }
+ } else {
+ if (s->ch_mode == FLAC_CHMODE_LEFT_SIDE || s->ch_mode == FLAC_CHMODE_MID_SIDE) {
+ s->curr_bps++;
+ }
+ }
+
+ if (get_bits1(&s->gb)) {
+ audio_codec_print("invalid subframe padding\n");
+ return -1;
+ }
+ type = get_bits(&s->gb, 6);
+
+ if (get_bits1(&s->gb)) {
+ wasted = 1;
+ while (!get_bits1(&s->gb)) {
+ wasted++;
+ }
+ s->curr_bps -= wasted;
+ }
+ if (s->curr_bps > 32) {
+ audio_codec_print("decorrelated bit depth > 32");
+ return -1;
+ }
+
+ //FIXME use av_log2 for types
+ if (type == 0) {
+ tmp = get_sbits_long(&s->gb, s->curr_bps);
+ for (i = 0; i < s->blocksize; i++) {
+ s->decoded[channel][i] = tmp;
+ }
+ } else if (type == 1) {
+ for (i = 0; i < s->blocksize; i++) {
+ s->decoded[channel][i] = get_sbits_long(&s->gb, s->curr_bps);
+ }
+ } else if ((type >= 8) && (type <= 12)) {
+ if (decode_subframe_fixed(s, channel, type & ~0x8) < 0) {
+ return -1;
+ }
+ } else if (type >= 32) {
+ if (decode_subframe_lpc(s, channel, (type & ~0x20) + 1) < 0) {
+ return -1;
+ }
+ } else {
+ audio_codec_print("invalid coding type\n");
+ return -1;
+ }
+
+ if (wasted) {
+ int i;
+ for (i = 0; i < s->blocksize; i++) {
+ s->decoded[channel][i] <<= wasted;
+ }
+ }
+
+ return 0;
+}
+
+static int decode_frame_header(GetBitContext *gb, FLACFrameInfo *fi)
+{
+ int bs_code, sr_code, bps_code;
+
+ /* frame sync code */
+ //skip_bits(gb, 16);
+ if ((get_bits(gb, 15) & 0x7FFF) != 0x7FFC) {
+ audio_codec_print("invalid sync code-----------------------\n");
+ return -1;
+ }
+ skip_bits(gb, 1);
+
+ /* block size and sample rate codes */
+ bs_code = get_bits(gb, 4);
+ sr_code = get_bits(gb, 4);
+
+ /* channels and decorrelation */
+ fi->ch_mode = get_bits(gb, 4);
+ if (fi->ch_mode < FLAC_MAX_CHANNELS) {
+ fi->channels = fi->ch_mode + 1;
+ fi->ch_mode = FLAC_CHMODE_INDEPENDENT;
+ } else if (fi->ch_mode <= FLAC_CHMODE_MID_SIDE) {
+ fi->channels = 2;
+ } else {
+ audio_codec_print("invalid channel mode: %d\n", fi->ch_mode);
+ return -1;
+ }
+
+ /* bits per sample */
+ bps_code = get_bits(gb, 3);
+ if (bps_code == 3 || bps_code == 7) {
+ audio_codec_print("invalid sample size code (%d)\n", bps_code);
+ return -1;
+ }
+ fi->bps = sample_size_table[bps_code];
+
+ /* reserved bit */
+ if (get_bits1(gb)) {
+ audio_codec_print("broken stream, invalid padding\n");
+ return -1;
+ }
+
+ /* sample or frame count */
+ if (get_utf8(gb) < 0) {
+ audio_codec_print("utf8 fscked\n");
+ return -1;
+ }
+
+ /* blocksize */
+ if (bs_code == 0) {
+ audio_codec_print("reserved blocksize code: 0\n");
+ return -1;
+ } else if (bs_code == 6) {
+ fi->blocksize = get_bits(gb, 8) + 1;
+ } else if (bs_code == 7) {
+ fi->blocksize = get_bits(gb, 16) + 1;
+ } else {
+ fi->blocksize = ff_flac_blocksize_table[bs_code];
+ }
+
+ /* sample rate */
+ if (sr_code < 12) {
+ fi->samplerate = ff_flac_sample_rate_table[sr_code];
+ } else if (sr_code == 12) {
+ fi->samplerate = get_bits(gb, 8) * 1000;
+ } else if (sr_code == 13) {
+ fi->samplerate = get_bits(gb, 16);
+ } else if (sr_code == 14) {
+ fi->samplerate = get_bits(gb, 16) * 10;
+ } else {
+ audio_codec_print("illegal sample rate code %d\n", sr_code);
+ return -1;
+ }
+
+ /* header CRC-8 check */
+ skip_bits(gb, 8);
+ if (av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, gb->buffer,
+ get_bits_count(gb) / 8)) {
+ audio_codec_print("header crc mismatch\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int decode_frame(FLACContext *s)
+{
+ int i;
+ GetBitContext *gb = &s->gb;
+ FLACFrameInfo fi;
+
+ if (decode_frame_header(gb, &fi)) {
+ //audio_codec_print("invalid frame header\n");
+ return -1;
+ }
+
+ if (fi.channels != s->channels) {
+ audio_codec_print("switching channel layout mid-stream is not supported\n");
+ return -1;
+ }
+ s->ch_mode = fi.ch_mode;
+
+ if (fi.bps && fi.bps != s->bps) {
+ audio_codec_print("switching bps mid-stream is not supported\n");
+ return -1;
+ }
+ if (0/*s->bps > 16*/) {
+ s->avctx->sample_fmt = SAMPLE_FMT_S32;
+ s->sample_shift = 32 - s->bps;
+ s->is32 = 1;
+ } else {
+ // s->avctx->sample_fmt = SAMPLE_FMT_S16;
+ s->sample_shift = 16 - s->bps;
+ s->is32 = 0;
+ }
+
+ if (fi.blocksize > s->max_blocksize) {
+ audio_codec_print("blocksize %d > %d\n", fi.blocksize, s->max_blocksize);
+ return -1;
+ }
+ s->blocksize = fi.blocksize;
+
+ if (fi.samplerate == 0) {
+ fi.samplerate = s->samplerate;
+ } else if (fi.samplerate != s->samplerate) {
+ audio_codec_print("sample rate changed from %d to %d\n", s->samplerate, fi.samplerate);
+ }
+ s->samplerate = s->avctx->sample_rate = fi.samplerate;
+
+
+ /* subframes */
+ for (i = 0; i < s->channels; i++) {
+ if (decode_subframe(s, i) < 0) {
+ return -1;
+ }
+ }
+
+ align_get_bits(gb);
+
+ /* frame footer */
+ skip_bits(gb, 16); /* data crc */
+
+ return 0;
+}
+
+static inline int av_clipf1(float a, int amin, int amax)
+{
+ if (a < amin) {
+ return (int)amin;
+ } else if (a > amax) {
+ return (int)amax;
+ } else {
+ return (int)a;
+ }
+}
+int audio_dec_decode(audio_decoder_operations_t *adec_ops, char *outbuf, int *outlen, char *inbuf, int inlen)
+{
+ AVCodecContext *avctx = &acodec;
+ FLACContext *s = &flactext;
+ int i, j = 0, input_buf_size = 0, bytes_read = 0;
+ int16_t *samples_16 = (int16_t*)outbuf;
+ int32_t *samples_32 = (int32_t*)outbuf;
+ int output_size = 0;
+ unsigned char *buf;
+ unsigned buf_size;
+ int last_sync_pos = 0;
+
+ unsigned int max_framesize = FFMAX(17 * s->max_framesize / 16 + 32, s->max_framesize);
+ if (inlen < max_framesize) {
+ int inbufindex = 0;
+ char *pinbufptr = inbuf;
+ char para = *(pinbufptr + 2);
+ int frame_num = 0;
+
+ inbufindex += 11;
+ pinbufptr += 11;
+ while (inbufindex < inlen - FLAC_MIN_FRAME_SIZE + 2) {
+ if ((AV_RB16(pinbufptr) & 0xFFFF) != 0xFFF8 || AV_RB8(pinbufptr + 2) != para) {
+ pinbufptr++;
+ inbufindex++;
+ } else {
+ inlen = inbufindex;
+ frame_num++;
+ if (frame_num > 1) {
+ audio_codec_print("## next frame found, inbufindex=%d, frame_num=%d,-------\n", inbufindex, frame_num);
+ goto decodecontinue;
+ }
+ }
+ }
+ //audio_codec_print("##inlen=%d, diff=%d,-------------------\n", inlen, pinbufptr-inbuf);
+ return -1;
+ }
+
+decodecontinue:
+ s->bitstream = inbuf;
+ s->bitstream_size = inlen;
+ s->bitstream_index = 0;
+
+ buf = s->bitstream;
+ buf_size = s->bitstream_size;
+
+ /* check for inline header */
+ if (AV_RB32(buf) == MKBETAG('f', 'L', 'a', 'C')) {
+ if (!s->got_streaminfo && parse_streaminfo(s, buf, buf_size)) {
+ audio_codec_print("invalid header\n");
+ return -1;
+ }
+ bytes_read = get_metadata_size(buf, buf_size);
+ goto end;
+ }
+FIND_SYNC_WORD:
+ /* check for frame sync code and resync stream if necessary */
+ if ((AV_RB16(buf) & 0xFFFE) != 0xFFF8) {
+ const uint8_t *buf_end = buf + buf_size;
+ // av_log(s->avctx, AV_LOG_ERROR, "FRAME HEADER not here\n");
+ while (buf + 2 < buf_end && (AV_RB16(buf) & 0xFFFE) != 0xFFF8) {
+ buf++;
+ last_sync_pos++;
+ }
+ bytes_read = buf_size - (buf_end - buf);
+ goto end; // we may not have enough bits left to decode a frame, so try next time
+ }
+
+ /* decode frame */
+ init_get_bits(&s->gb, buf, buf_size * 8);
+ if (decode_frame(s) < 0) {
+ audio_codec_print("decode_frame() failed\n");
+ //some times , flac may seek to fake sync word pos, caused decode failed
+ //call resync to fix this issue
+ buf = s->bitstream + last_sync_pos + 1;
+ buf_size = s->bitstream_size - (last_sync_pos + 1);
+ last_sync_pos++;
+ goto FIND_SYNC_WORD;
+ }
+ bytes_read = (get_bits_count(&s->gb) + 7) / 8;
+
+ /* check if allocated data size is large enough for output */
+ output_size = s->blocksize * (s->channels > 2 ? 2 : s->channels) * (s->is32 ? 4 : 2);
+ if (output_size > DefaultOutBufSize) {
+ audio_codec_print("output data size is larger than allocated data size\n");
+ goto end;
+ }
+
+#define DECORRELATE(left, right)\
+ for (i = 0; i < s->blocksize; i++) {\
+ int a= s->decoded[0][i];\
+ int b= s->decoded[1][i];\
+ if (s->is32) {\
+ *samples_32++ = (left) << s->sample_shift;\
+ *samples_32++ = (right) << s->sample_shift;\
+ } else {\
+ if (s->sample_shift >= 0) \
+ {\
+ *samples_16++ = (left) << s->sample_shift;\
+ *samples_16++ = (right) << s->sample_shift;\
+ }\
+ else\
+ {\
+ *samples_16++ = (left) >> (-1*s->sample_shift);\
+ *samples_16++ = (right) >> (-1*s->sample_shift);\
+ }\
+ }\
+ }\
+ break;
+
+ switch (s->ch_mode) {
+ case FLAC_CHMODE_INDEPENDENT:
+ if (s->channels <= 2) {
+ for (j = 0; j < s->blocksize; j++) {
+ for (i = 0; i < s->channels; i++) {
+ if (s->is32) {
+ *samples_32++ = s->decoded[i][j] << s->sample_shift;
+ } else {
+ if (s->sample_shift >= 0) {
+ *samples_16++ = s->decoded[i][j] << s->sample_shift;
+ } else {
+ *samples_16++ = s->decoded[i][j] >> (-1 * s->sample_shift);
+ }
+ }
+ }
+ }
+ } else {
+ float sum0 = 0, sum1 = 0;
+ //downmix here
+ //FL + (sum of other surround channels >> 1)
+ //FR + (sum of other surround channels >> 1)
+ for (j = 0; j < s->blocksize; j++) {
+ if (s->is32) {
+ sum0 = s->decoded[0][j] << s->sample_shift;
+ sum1 = s->decoded[1][j] << s->sample_shift;
+ } else {
+ if (s->sample_shift >= 0) {
+ sum0 = s->decoded[0][j] << s->sample_shift;
+ sum1 = s->decoded[1][j] << s->sample_shift;
+ } else {
+ sum0 = s->decoded[0][j] >> (-1 * s->sample_shift);
+ sum1 = s->decoded[1][j] >> (-1 * s->sample_shift);
+ }
+ }
+ for (i = 2; i < s->channels; i++) {
+ if (s->is32) {
+ sum0 += (s->decoded[i][j] << s->sample_shift) >> 1;
+ sum1 += (s->decoded[i][j] << s->sample_shift) >> 1;
+ } else {
+ if (s->sample_shift >= 0) {
+ sum0 += (s->decoded[i][j] << s->sample_shift) >> 1;
+ sum1 += (s->decoded[i][j] << s->sample_shift) >> 1;
+ } else {
+ sum0 += (s->decoded[i][j] >> (-1 * s->sample_shift)) >> 1;
+ sum1 += (s->decoded[i][j] >> (-1 * s->sample_shift)) >> 1;
+ }
+ }
+ }
+
+ if (s->is32) {
+ *samples_32++ = av_clipf1(sum0, -0x80000000, 0x7fffffff);
+ *samples_32++ = av_clipf1(sum1, -0x80000000, 0x7fffffff);
+ } else {
+ *samples_16++ = av_clipf1(sum0, -32768, 32767);
+ *samples_16++ = av_clipf1(sum1, -32768, 32767);
+ }
+ }
+ }
+ break;
+ case FLAC_CHMODE_LEFT_SIDE:
+ DECORRELATE(a, a - b)
+ case FLAC_CHMODE_RIGHT_SIDE:
+ DECORRELATE(a + b, b)
+ case FLAC_CHMODE_MID_SIDE:
+ DECORRELATE((a -= b >> 1) + b, a)
+ }
+
+end:
+ if (bytes_read > inlen) {
+ // av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", bytes_read - buf_size);
+ s->bitstream_size = 0;
+ s->bitstream_index = 0;
+ return -1;
+ }
+
+ if (s->bitstream_size) {
+ s->bitstream_index += bytes_read;
+ s->bitstream_size -= bytes_read;
+ }
+
+ *outlen = output_size;
+
+ return bytes_read;
+}
+
+int audio_dec_init(audio_decoder_operations_t *adec_ops)
+{
+ memset(&flactext , 0, sizeof(flactext));
+ memset(&acodec, 0, sizeof(acodec));
+ enum FLACExtradataFormat format;
+ uint8_t *streaminfo;
+ AVCodecContext *avctx = &acodec;
+ FLACContext *s = &flactext;
+ s->avctx = &acodec;
+ //audio_codec_print("\n\n[%s]BuildDate--%s BuildTime--%s", __FUNCTION__, __DATE__, __TIME__);
+ avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->extradata = adec_ops->extradata;
+ avctx->extradata_size = adec_ops->extradata_size;
+
+ if (!avctx->extradata_size) {
+ return 0;
+ }
+ if (!ff_flac_is_extradata_valid(avctx, &format, &streaminfo)) {
+ return -1;
+ }
+
+ /* initialize based on the demuxer-supplied streamdata header */
+ ff_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s, streaminfo);
+ if (s->bps > 16) {
+ avctx->sample_fmt = SAMPLE_FMT_S32;
+ } else {
+ avctx->sample_fmt = SAMPLE_FMT_S16;
+ }
+ allocate_buffers(s);
+ s->got_streaminfo = 1;
+ avctx->channels = (avctx->channels > 2 ? 2 : avctx->channels);
+ audio_codec_print("applied flac sr %d,ch num %d\n", avctx->sample_rate, avctx->channels);
+
+ adec_ops->nInBufSize = DefaultReadSize;
+ adec_ops->nOutBufSize = DefaultOutBufSize;
+ audio_codec_print("ape_Init.--------------------------------\n");
+
+ return 0;
+}
+
+int audio_dec_release(audio_decoder_operations_t *adec_ops)
+{
+ int i;
+ audio_codec_print("audio_dec_release.--------------------------------\n");
+
+ if (outbuffer.outb == NULL) {
+ av_freep(&outbuffer.outb);
+ }
+
+ for (i = 0; i < flactext.channels; i++) {
+ av_freep(&flactext.decoded[i]);
+ }
+ // av_free(flactext.bitstream);
+
+ return 0;
+}
+
+int audio_dec_getinfo(audio_decoder_operations_t *adec_ops, void *pAudioInfo)
+{
+ return 0;
+}
+
diff --git a/audio_codec/libflac/flacdata.c b/audio_codec/libflac/flacdata.c
new file mode 100644
index 0000000..2787e7b
--- a/dev/null
+++ b/audio_codec/libflac/flacdata.c
@@ -0,0 +1,38 @@
+/*
+ * FLAC data
+ * Copyright (c) 2003 Alex Beregszaszi
+ *
+ * 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 __MW__
+#include <inttypes.h>
+#else
+#include <core/types.h>
+#endif
+
+
+const int ff_flac_sample_rate_table[16] = {
+ 0,
+ 88200, 176400, 192000,
+ 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000,
+ 0, 0, 0, 0
+};
+
+const int16_t ff_flac_blocksize_table[16] = {
+ 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
+};
diff --git a/audio_codec/libflac/flacdata.h b/audio_codec/libflac/flacdata.h
new file mode 100644
index 0000000..4dcd420
--- a/dev/null
+++ b/audio_codec/libflac/flacdata.h
@@ -0,0 +1,29 @@
+/*
+ * FLAC data header
+ * Copyright (c) 2003 Alex Beregszaszi
+ *
+ * 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_FLACDATA_H
+#define AVCODEC_FLACDATA_H
+
+extern const int ff_flac_sample_rate_table[16];
+
+extern const int16_t ff_flac_blocksize_table[16];
+
+#endif /* AVCODEC_FLACDATA_H */
diff --git a/audio_codec/libflac/get_bits.h b/audio_codec/libflac/get_bits.h
new file mode 100644
index 0000000..f1f6027
--- a/dev/null
+++ b/audio_codec/libflac/get_bits.h
@@ -0,0 +1,564 @@
+/*
+ * copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * 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/get_bits.h
+ * bitstream reader API header.
+ */
+
+#ifndef AVCODEC_GET_BITS_H
+#define AVCODEC_GET_BITS_H
+
+#include "mathops.h"
+#include "bswap.h"
+//#include <ffmpeg/libavutil/common.h>
+#include "intreadwrite.h"
+//#include <core/dsp.h>
+
+#include <android/log.h>
+
+#define LOG_TAG "get_bits"
+
+#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
+#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
+
+//goes the A32_BITSTREAM_READER passage
+#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 defined(ARCH_ARM) && !defined(HAVE_FAST_UNALIGNED)
+#define A32_BITSTREAM_READER
+#else
+#define ALT_BITSTREAM_READER
+//#define LIBMPEG2_BITSTREAM_READER
+//#define A32_BITSTREAM_READER
+#endif
+#endif
+
+#define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s)))
+#define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s)))
+
+/* 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;
+
+
+/* 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)\
+ 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)\
+ ((name##_cache) & (NEG_USR32(0xffffffff,num)))
+
+#define SHOW_SBITS(name, gb, num)\
+ NEG_SSR32((name##_cache)<<(32-(num)), 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(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(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= be2me_32( *name##_buffer_ptr );\
+ name##_cache0 |= NEG_USR32(next,name##_bit_count);\
+ name##_cache1 |= next<<name##_bit_count;\
+ name##_buffer_ptr++;\
+ name##_bit_count-= 32;\
+ }\
+
+#if ARCH_X86
+#define SKIP_CACHE(name, gb, num)\
+ __asm__(\
+ "shldl %2, %1, %0 \n\t"\
+ "shll %2, %1 \n\t"\
+ : "+r" (name##_cache0), "+r" (name##_cache1)\
+ : "Ic" ((uint8_t)(num))\
+ );
+#else
+#define SKIP_CACHE(name, gb, num)\
+ name##_cache0 <<= (num);\
+ name##_cache0 |= NEG_USR32(name##_cache1,num);\
+ name##_cache1 <<= (num);
+#endif
+
+#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##_cache0, num)
+
+#define SHOW_SBITS(name, gb, num)\
+ NEG_SSR32(name##_cache0, num)
+
+#define GET_CACHE(name, gb)\
+ (name##_cache0)
+
+static inline int get_bits_count(GetBitContext *s)
+{
+ return ((uint8_t*)s->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 = be2me_32(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
+ 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 <= 17) {
+ 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 <= 17) {
+ 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) {
+ LOGD("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 TRACE
+
+#ifdef TRACE
+static inline void print_bin(int bits, int n)
+{
+ int i;
+
+ for (i = n - 1; i >= 0; i--) {
+ LOGD("%d", (bits >> i) & 1);
+ }
+ for (i = n; i < 24; i++) {
+ LOGD(" ");
+ }
+}
+
+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);
+ LOGD("%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_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);
+ LOGD("%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__)
+#endif
+
+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/audio_codec/libflac/golomb.h b/audio_codec/libflac/golomb.h
new file mode 100644
index 0000000..248bfc2
--- a/dev/null
+++ b/audio_codec/libflac/golomb.h
@@ -0,0 +1,585 @@
+/*
+ * exp golomb vlc stuff
+ * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
+ * Copyright (c) 2004 Alex Beregszaszi
+ *
+ * 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/golomb.h
+ * @brief
+ * exp golomb vlc stuff
+ * @author Michael Niedermayer <michaelni@gmx.at> and Alex Beregszaszi
+ */
+
+#ifndef AVCODEC_GOLOMB_H
+#define AVCODEC_GOLOMB_H
+
+#ifndef __MW__
+#include <stdint.h>
+#endif
+#include "get_bits.h"
+//#include "put_bits.h"
+
+#include <assert.h>
+
+#define INVALID_VLC 0x80000000
+#ifndef __MW__
+extern const uint8_t ff_golomb_vlc_len[512];
+extern const uint8_t ff_ue_golomb_vlc_code[512];
+extern const int8_t ff_se_golomb_vlc_code[512];
+extern const uint8_t ff_ue_golomb_len[256];
+
+extern const uint8_t ff_interleaved_golomb_vlc_len[256];
+extern const uint8_t ff_interleaved_ue_golomb_vlc_code[256];
+extern const int8_t ff_interleaved_se_golomb_vlc_code[256];
+extern const uint8_t ff_interleaved_dirac_golomb_vlc_code[256];
+
+
+/**
+* read unsigned exp golomb code.
+*/
+static inline int get_ue_golomb(GetBitContext *gb)
+{
+ unsigned int buf;
+ int log;
+
+ OPEN_READER(re, gb);
+ UPDATE_CACHE(re, gb);
+ buf = GET_CACHE(re, gb);
+
+ if (buf >= (1 << 27)) {
+ buf >>= 32 - 9;
+ LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]);
+ CLOSE_READER(re, gb);
+
+ return ff_ue_golomb_vlc_code[buf];
+ } else {
+ log = 2 * av_log2(buf) - 31;
+ buf >>= log;
+ buf--;
+ LAST_SKIP_BITS(re, gb, 32 - log);
+ CLOSE_READER(re, gb);
+
+ return buf;
+ }
+}
+
+/**
+* read unsigned exp golomb code, constraint to a max of 31.
+* the return value is undefined if the stored value exceeds 31.
+*/
+static inline int get_ue_golomb_31(GetBitContext *gb)
+{
+ unsigned int buf;
+
+ OPEN_READER(re, gb);
+ UPDATE_CACHE(re, gb);
+ buf = GET_CACHE(re, gb);
+
+ buf >>= 32 - 9;
+ LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]);
+ CLOSE_READER(re, gb);
+
+ return ff_ue_golomb_vlc_code[buf];
+}
+
+static inline int svq3_get_ue_golomb(GetBitContext *gb)
+{
+ uint32_t buf;
+
+ OPEN_READER(re, gb);
+ UPDATE_CACHE(re, gb);
+ buf = GET_CACHE(re, gb);
+
+ if (buf & 0xAA800000) {
+ buf >>= 32 - 8;
+ LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
+ CLOSE_READER(re, gb);
+
+ return ff_interleaved_ue_golomb_vlc_code[buf];
+ } else {
+ int ret = 1;
+
+ while (1) {
+ buf >>= 32 - 8;
+ LAST_SKIP_BITS(re, gb, FFMIN(ff_interleaved_golomb_vlc_len[buf], 8));
+
+ if (ff_interleaved_golomb_vlc_len[buf] != 9) {
+ ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1;
+ ret |= ff_interleaved_dirac_golomb_vlc_code[buf];
+ break;
+ }
+ ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf];
+ UPDATE_CACHE(re, gb);
+ buf = GET_CACHE(re, gb);
+ }
+
+ CLOSE_READER(re, gb);
+ return ret - 1;
+ }
+}
+
+/**
+ * read unsigned truncated exp golomb code.
+ */
+static inline int get_te0_golomb(GetBitContext *gb, int range)
+{
+ assert(range >= 1);
+
+ if (range == 1) {
+ return 0;
+ } else if (range == 2) {
+ return get_bits1(gb) ^ 1;
+ } else {
+ return get_ue_golomb(gb);
+ }
+}
+
+/**
+ * read unsigned truncated exp golomb code.
+ */
+static inline int get_te_golomb(GetBitContext *gb, int range)
+{
+ assert(range >= 1);
+
+ if (range == 2) {
+ return get_bits1(gb) ^ 1;
+ } else {
+ return get_ue_golomb(gb);
+ }
+}
+
+
+/**
+ * read signed exp golomb code.
+ */
+static inline int get_se_golomb(GetBitContext *gb)
+{
+ unsigned int buf;
+ int log;
+
+ OPEN_READER(re, gb);
+ UPDATE_CACHE(re, gb);
+ buf = GET_CACHE(re, gb);
+
+ if (buf >= (1 << 27)) {
+ buf >>= 32 - 9;
+ LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]);
+ CLOSE_READER(re, gb);
+
+ return ff_se_golomb_vlc_code[buf];
+ } else {
+ log = 2 * av_log2(buf) - 31;
+ buf >>= log;
+
+ LAST_SKIP_BITS(re, gb, 32 - log);
+ CLOSE_READER(re, gb);
+
+ if (buf & 1) {
+ buf = -(buf >> 1);
+ } else {
+ buf = (buf >> 1);
+ }
+
+ return buf;
+ }
+}
+
+static inline int svq3_get_se_golomb(GetBitContext *gb)
+{
+ unsigned int buf;
+ int log;
+
+ OPEN_READER(re, gb);
+ UPDATE_CACHE(re, gb);
+ buf = GET_CACHE(re, gb);
+
+ if (buf & 0xAA800000) {
+ buf >>= 32 - 8;
+ LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
+ CLOSE_READER(re, gb);
+
+ return ff_interleaved_se_golomb_vlc_code[buf];
+ } else {
+ LAST_SKIP_BITS(re, gb, 8);
+ UPDATE_CACHE(re, gb);
+ buf |= 1 | (GET_CACHE(re, gb) >> 8);
+
+ if ((buf & 0xAAAAAAAA) == 0) {
+ return INVALID_VLC;
+ }
+
+ for (log = 31; (buf & 0x80000000) == 0; log--) {
+ buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30);
+ }
+
+ LAST_SKIP_BITS(re, gb, 63 - 2 * log - 8);
+ CLOSE_READER(re, gb);
+
+ return (signed)(((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1;
+ }
+}
+
+static inline int dirac_get_se_golomb(GetBitContext *gb)
+{
+ uint32_t buf;
+ uint32_t ret;
+
+ ret = svq3_get_ue_golomb(gb);
+
+ if (ret) {
+ OPEN_READER(re, gb);
+ UPDATE_CACHE(re, gb);
+ buf = SHOW_SBITS(re, gb, 1);
+ LAST_SKIP_BITS(re, gb, 1);
+ ret = (ret ^ buf) - buf;
+ CLOSE_READER(re, gb);
+ }
+
+ return ret;
+}
+#endif
+
+/**
+ * read unsigned golomb rice code (ffv1).
+ */
+static inline int get_ur_golomb(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 > 31 - limit) {
+ buf >>= log - k;
+ buf += (30 - log) << k;
+ LAST_SKIP_BITS(re, gb, 32 + k - log);
+ CLOSE_READER(re, gb);
+
+ return buf;
+ } else {
+ LAST_SKIP_BITS(re, gb, limit);
+ UPDATE_CACHE(re, gb);
+
+ buf = SHOW_UBITS(re, gb, esc_len);
+
+ LAST_SKIP_BITS(re, gb, esc_len);
+ CLOSE_READER(re, gb);
+
+ return buf + limit - 1;
+ }
+}
+
+/**
+ * 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) << k;
+ LAST_SKIP_BITS(re, gb, 32 + k - log);
+ CLOSE_READER(re, gb);
+
+ return buf;
+ } else {
+ int i;
+ for (i = 0; SHOW_UBITS(re, gb, 1) == 0; i++) {
+ LAST_SKIP_BITS(re, gb, 1);
+ UPDATE_CACHE(re, gb);
+ }
+ SKIP_BITS(re, gb, 1);
+
+ if (i < limit - 1) {
+ if (k) {
+ buf = SHOW_UBITS(re, gb, k);
+ LAST_SKIP_BITS(re, gb, k);
+ } else {
+ buf = 0;
+ }
+
+ CLOSE_READER(re, gb);
+ return buf + (i << k);
+ } else if (i == limit - 1) {
+ buf = SHOW_UBITS(re, gb, esc_len);
+ LAST_SKIP_BITS(re, gb, esc_len);
+ CLOSE_READER(re, gb);
+
+ return buf + 1;
+ } else {
+ return -1;
+ }
+ }
+}
+
+/**
+ * read signed golomb rice code (ffv1).
+ */
+static inline int get_sr_golomb(GetBitContext *gb, int k, int limit, int esc_len)
+{
+ int v = get_ur_golomb(gb, k, limit, esc_len);
+
+ v++;
+ if (v & 1) {
+ return v >> 1;
+ } else {
+ return -(v >> 1);
+ }
+
+ // return (v>>1) ^ -(v&1);
+}
+
+/**
+ * read signed golomb rice code (flac).
+ */
+static inline int get_sr_golomb_flac(GetBitContext *gb, int k, int limit, int esc_len)
+{
+ int v = get_ur_golomb_jpegls(gb, k, limit, esc_len);
+ return (v >> 1) ^ -(v & 1);
+}
+
+/**
+ * read unsigned golomb rice code (shorten).
+ */
+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;
+ }
+}
+
+
+
+#ifdef TRACE
+
+static inline int get_ue(GetBitContext *s, char *file, const char *func, int line)
+{
+ int show = show_bits(s, 24);
+ int pos = get_bits_count(s);
+ int i = get_ue_golomb(s);
+ int len = get_bits_count(s) - pos;
+ int bits = show >> (24 - len);
+
+ print_bin(bits, len);
+
+ av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d ue @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
+
+ return i;
+}
+
+static inline int get_se(GetBitContext *s, char *file, const char *func, int line)
+{
+ int show = show_bits(s, 24);
+ int pos = get_bits_count(s);
+ int i = get_se_golomb(s);
+ int len = get_bits_count(s) - pos;
+ int bits = show >> (24 - len);
+
+ print_bin(bits, len);
+
+ av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d se @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
+
+ return i;
+}
+
+static inline int get_te(GetBitContext *s, int r, char *file, const char *func, int line)
+{
+ int show = show_bits(s, 24);
+ int pos = get_bits_count(s);
+ int i = get_te0_golomb(s, r);
+ int len = get_bits_count(s) - pos;
+ int bits = show >> (24 - len);
+
+ print_bin(bits, len);
+
+ av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d te @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
+
+ return i;
+}
+
+#define get_ue_golomb(a) get_ue(a, __FILE__, __PRETTY_FUNCTION__, __LINE__)
+#define get_se_golomb(a) get_se(a, __FILE__, __PRETTY_FUNCTION__, __LINE__)
+#define get_te_golomb(a, r) get_te(a, r, __FILE__, __PRETTY_FUNCTION__, __LINE__)
+#define get_te0_golomb(a, r) get_te(a, r, __FILE__, __PRETTY_FUNCTION__, __LINE__)
+
+#endif
+
+#if 0
+/**
+ * write unsigned exp golomb code.
+ */
+static inline void set_ue_golomb(PutBitContext *pb, int i)
+{
+ int e;
+
+ assert(i >= 0);
+
+#if 0
+ if (i = 0) {
+ put_bits(pb, 1, 1);
+ return;
+ }
+#endif
+ if (i < 256) {
+ put_bits(pb, ff_ue_golomb_len[i], i + 1);
+ } else {
+ e = av_log2(i + 1);
+
+ put_bits(pb, 2 * e + 1, i + 1);
+ }
+}
+
+/**
+ * write truncated unsigned exp golomb code.
+ */
+static inline void set_te_golomb(PutBitContext *pb, int i, int range)
+{
+ assert(range >= 1);
+ assert(i <= range);
+
+ if (range == 2) {
+ put_bits(pb, 1, i ^ 1);
+ } else {
+ set_ue_golomb(pb, i);
+ }
+}
+
+/**
+ * write signed exp golomb code. 16 bits at most.
+ */
+static inline void set_se_golomb(PutBitContext *pb, int i)
+{
+ // if (i>32767 || i<-32767)
+ // av_log(NULL,AV_LOG_ERROR,"value out of range %d\n", i);
+#if 0
+ if (i <= 0) {
+ i = -2 * i;
+ } else {
+ i = 2 * i - 1;
+ }
+#elif 1
+ i = 2 * i - 1;
+ if (i < 0) {
+ i ^= -1; //FIXME check if gcc does the right thing
+ }
+#else
+ i = 2 * i - 1;
+ i ^= (i >> 31);
+#endif
+ set_ue_golomb(pb, i);
+}
+
+/**
+ * write unsigned golomb rice code (ffv1).
+ */
+static inline void set_ur_golomb(PutBitContext *pb, int i, int k, int limit, int esc_len)
+{
+ int e;
+
+ assert(i >= 0);
+
+ e = i >> k;
+ if (e < limit) {
+ put_bits(pb, e + k + 1, (1 << k) + (i & ((1 << k) - 1)));
+ } else {
+ put_bits(pb, limit + esc_len, i - limit + 1);
+ }
+}
+
+/**
+ * write unsigned golomb rice code (jpegls).
+ */
+static inline void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k, int limit, int esc_len)
+{
+ int e;
+
+ assert(i >= 0);
+
+ e = (i >> k) + 1;
+ if (e < limit) {
+ while (e > 31) {
+ put_bits(pb, 31, 0);
+ e -= 31;
+ }
+ put_bits(pb, e, 1);
+ if (k) {
+ put_sbits(pb, k, i);
+ }
+ } else {
+ while (limit > 31) {
+ put_bits(pb, 31, 0);
+ limit -= 31;
+ }
+ put_bits(pb, limit , 1);
+ put_bits(pb, esc_len, i - 1);
+ }
+}
+
+/**
+ * write signed golomb rice code (ffv1).
+ */
+static inline void set_sr_golomb(PutBitContext *pb, int i, int k, int limit, int esc_len)
+{
+ int v;
+
+ v = -2 * i - 1;
+ v ^= (v >> 31);
+
+ set_ur_golomb(pb, v, k, limit, esc_len);
+}
+
+/**
+ * write signed golomb rice code (flac).
+ */
+static inline void set_sr_golomb_flac(PutBitContext *pb, int i, int k, int limit, int esc_len)
+{
+ int v;
+
+ v = -2 * i - 1;
+ v ^= (v >> 31);
+
+ set_ur_golomb_jpegls(pb, v, k, limit, esc_len);
+}
+#endif
+
+#endif /* AVCODEC_GOLOMB_H */
diff --git a/audio_codec/libflac/internal.h b/audio_codec/libflac/internal.h
new file mode 100644
index 0000000..daa5a61
--- a/dev/null
+++ b/audio_codec/libflac/internal.h
@@ -0,0 +1,195 @@
+/*
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * 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 libavutil/internal.h
+ * common internal API header
+ */
+
+#ifndef AVUTIL_INTERNAL_H
+#define AVUTIL_INTERNAL_H
+
+#if !defined(DEBUG) && !defined(NDEBUG)
+# define NDEBUG
+#endif
+
+#include <limits.h>
+#include "common.h"
+
+#ifndef attribute_align_arg
+#if (!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
+
+#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)
+
+/* math */
+
+extern const uint32_t ff_inverse[257];
+
+#if CONFIG_FASTDIV
+#define FASTDIV(a,b) ((uint32_t)((((uint64_t)a) * ff_inverse[b]) >> 32))
+#else
+#define FASTDIV(a,b) ((a) / (b))
+#endif
+
+extern const uint8_t ff_sqrt_tab[256];
+
+static inline av_const unsigned int ff_sqrt(unsigned int a)
+{
+ unsigned int b;
+
+ if (a < 255) {
+ return (ff_sqrt_tab[a + 1] - 1) >> 4;
+ } else if (a < (1 << 12)) {
+ b = ff_sqrt_tab[a >> 4] >> 2;
+ }
+#if !CONFIG_SMALL
+ else if (a < (1 << 14)) {
+ b = ff_sqrt_tab[a >> 6] >> 1;
+ } else if (a < (1 << 16)) {
+ b = ff_sqrt_tab[a >> 8] ;
+ }
+#endif
+ else {
+ int s = av_log2_16bit(a >> 16) >> 1;
+ unsigned int c = a >> (s + 2);
+ b = ff_sqrt_tab[c >> (s + 8)];
+ b = FASTDIV(c, b) + (b << s);
+ }
+
+ return b - (a < b * b);
+}
+
+#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
+
+#if HAVE_CMOV
+#define COPY3_IF_LT(x, y, a, b, c, d)\
+__asm__ volatile(\
+ "cmpl %0, %3 \n\t"\
+ "cmovl %3, %0 \n\t"\
+ "cmovl %4, %1 \n\t"\
+ "cmovl %5, %2 \n\t"\
+ : "+&r" (x), "+&r" (a), "+r" (c)\
+ : "r" (y), "r" (b), "r" (d)\
+);
+#else
+#define COPY3_IF_LT(x, y, a, b, c, d)\
+if ((y) < (x)) {\
+ (x) = (y);\
+ (a) = (b);\
+ (c) = (d);\
+}
+#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;\
+ }\
+}
+
+#define NULL_IF_CONFIG_SMALL(x) x
+
+#endif /* AVUTIL_INTERNAL_H */
diff --git a/audio_codec/libflac/intreadwrite.h b/audio_codec/libflac/intreadwrite.h
new file mode 100644
index 0000000..57eaf30
--- a/dev/null
+++ b/audio_codec/libflac/intreadwrite.h
@@ -0,0 +1,390 @@
+/*
+ * 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
+#ifndef __MW__
+#include <stdint.h>
+#endif
+#include "bswap.h"
+
+/*
+ * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers.
+ */
+
+#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 AV_[RW]N helper macros to simplify definitions not provided
+ * by per-arch headers.
+ */
+
+#if HAVE_ATTRIBUTE_PACKED
+
+struct unaligned_64 {
+ uint64_t l;
+} __attribute__((packed));
+struct unaligned_32 {
+ uint32_t l;
+} __attribute__((packed));
+struct unaligned_16 {
+ uint16_t l;
+} __attribute__((packed));
+
+# define AV_RN(s, p) (((const struct unaligned_##s *) (p))->l)
+# define AV_WN(s, p, v) (((struct 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 uint##s##_t*)(p)))
+# define AV_WN(s, p, v) *((uint##s##_t*)(p)) = (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 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
+
+#endif /* AVUTIL_INTREADWRITE_H */
diff --git a/audio_codec/libflac/mathops.h b/audio_codec/libflac/mathops.h
new file mode 100644
index 0000000..6f4a5f4
--- a/dev/null
+++ b/audio_codec/libflac/mathops.h
@@ -0,0 +1,78 @@
+/*
+ * simple math operations
+ * Copyright (c) 2001, 2002 Fabrice Bellard
+ * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> 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 "common.h"
+#include "internal.h"
+
+/* 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 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
+
+#ifndef sign_extend
+static inline av_const int sign_extend(int val, unsigned bits)
+{
+ return (val << (INT_BIT - bits)) >> (INT_BIT - bits);
+}
+#endif
+
+#endif /* AVCODEC_MATHOPS_H */
+
diff --git a/audio_codec/libflac/types.h b/audio_codec/libflac/types.h
new file mode 100644
index 0000000..10d7202
--- a/dev/null
+++ b/audio_codec/libflac/types.h
@@ -0,0 +1,49 @@
+
+#ifndef _DSP_TYPES_H
+#define _DSP_TYPES_H
+/* bsd */
+typedef unsigned char u_char;
+typedef unsigned short u_short;
+typedef unsigned int u_int;
+typedef unsigned long u_long;
+
+/* sysv */
+typedef unsigned char unchar;
+typedef unsigned short ushort;
+typedef unsigned int uint;
+typedef unsigned long ulong;
+
+typedef unsigned char __u8;
+typedef unsigned short __u16;
+typedef unsigned int __u32;
+typedef unsigned long long __u64;
+
+
+typedef signed char __s8;
+typedef short __s16;
+typedef int __s32;
+typedef long long __s64;
+
+typedef __u8 u_int8_t;
+typedef __s8 int8_t;
+typedef __u16 u_int16_t;
+typedef __s16 int16_t;
+typedef __u32 u_int32_t;
+typedef __s32 int32_t;
+
+
+typedef __u8 uint8_t;
+typedef __u16 uint16_t;
+typedef __u32 uint32_t;
+
+typedef __u64 uint64_t;
+typedef __u64 u_int64_t;
+typedef __s64 int64_t;
+typedef float float32_t;
+
+
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
+#endif
diff --git a/audio_codec/liblpcm/Android.mk b/audio_codec/liblpcm/Android.mk
new file mode 100755
index 0000000..8b9545b
--- a/dev/null
+++ b/audio_codec/liblpcm/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SHARED_LIBRARIES += libcutils libc liblog
+LOCAL_MODULE := libpcm_wfd
+LOCAL_SRC_FILES := lpcm_decode.c
+#$(notdir $(wildcard $(LOCAL_PATH)/*.c))
+LOCAL_ARM_MODE := arm
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/../../amadec/include $(LOCAL_PATH)/../../amadec/
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/audio_codec/liblpcm/lpcm_decode.c b/audio_codec/liblpcm/lpcm_decode.c
new file mode 100644
index 0000000..3a078ef
--- a/dev/null
+++ b/audio_codec/liblpcm/lpcm_decode.c
@@ -0,0 +1,437 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <dlfcn.h>
+#include <sys/mman.h>
+#include <android/log.h>
+#include <cutils/properties.h>
+#include <unistd.h>
+#include "../../amadec/adec-armdec-mgt.h"
+
+#define LOG_TAG "LPCMDEC"
+#define printk(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define audio_codec_print(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+
+#define ASTREAM_DEV "/dev/uio0"
+#define ASTREAM_ADDR "/sys/class/astream/astream-dev/uio0/maps/map0/addr"
+#define ASTREAM_SIZE "/sys/class/astream/astream-dev/uio0/maps/map0/size"
+#define ASTREAM_OFFSET "/sys/class/astream/astream-dev/uio0/maps/map0/offset"
+
+
+
+#define AIU_AIFIFO_CTRL 0x1580
+#define AIU_AIFIFO_STATUS 0x1581
+#define AIU_AIFIFO_GBIT 0x1582
+#define AIU_AIFIFO_CLB 0x1583
+#define AIU_MEM_AIFIFO_START_PTR 0x1584
+#define AIU_MEM_AIFIFO_CURR_PTR 0x1585
+#define AIU_MEM_AIFIFO_END_PTR 0x1586
+#define AIU_MEM_AIFIFO_BYTES_AVAIL 0x1587
+#define AIU_MEM_AIFIFO_CONTROL 0x1588
+#define AIU_MEM_AIFIFO_MAN_WP 0x1589
+#define AIU_MEM_AIFIFO_MAN_RP 0x158a
+#define AIU_MEM_AIFIFO_LEVEL 0x158b
+#define AIU_MEM_AIFIFO_BUF_CNTL 0x158c
+#define AIU_MEM_AIFIFO_BUF_WRAP_COUNT 0x158d
+#define AIU_MEM_AIFIFO2_BUF_WRAP_COUNT 0x158e
+#define AIU_MEM_AIFIFO_MEM_CTL 0x158f
+
+volatile unsigned* reg_base = 0;
+#define READ_MPEG_REG(reg) reg_base[reg-AIU_AIFIFO_CTRL]
+#define WRITE_MPEG_REG(reg, val) reg_base[reg-AIU_AIFIFO_CTRL]=val
+#define AIFIFO_READY (((READ_MPEG_REG(AIU_MEM_AIFIFO_CONTROL)&(1<<9))))
+#define min(x,y) ((x<y)?(x):(y))
+static int fd_uio = -1;
+static volatile int exit_flag = 0;
+static char *memmap = MAP_FAILED;
+static int phys_size;
+static unsigned enable_debug_print = 0;
+
+static unsigned long amsysfs_get_sysfs_ulong(const char *path)
+{
+ int fd;
+ char bcmd[24] = "";
+ unsigned long num = 0;
+ if ((fd = open(path, O_RDONLY)) >= 0) {
+ read(fd, bcmd, sizeof(bcmd));
+ num = strtoul(bcmd, NULL, 0);
+ close(fd);
+ } else {
+ audio_codec_print("unable to open file %s", path);
+ }
+ return num;
+}
+static unsigned long get_num_infile(char *file)
+{
+ return amsysfs_get_sysfs_ulong(file);
+}
+
+static int uio_init()
+{
+ int pagesize = getpagesize();
+ int phys_start;
+ int phys_offset;
+
+
+ fd_uio = open(ASTREAM_DEV, O_RDWR);
+ if (fd_uio < 0) {
+ audio_codec_print("error open UIO 0\n");
+ return -1;
+ }
+ phys_start = get_num_infile(ASTREAM_ADDR);
+ phys_size = get_num_infile(ASTREAM_SIZE);
+ phys_offset = get_num_infile(ASTREAM_OFFSET);
+
+ audio_codec_print("add=%08x, size=%08x, offset=%08x\n", phys_start, phys_size, phys_offset);
+
+ phys_size = (phys_size + pagesize - 1) & (~(pagesize - 1));
+ memmap = mmap(NULL, phys_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_uio, 0 * pagesize);
+
+ audio_codec_print("memmap = %x , pagesize = %x\n", memmap, pagesize);
+ if (memmap == MAP_FAILED) {
+ audio_codec_print("map /dev/uio0 failed\n");
+ return -1;
+ }
+ if (phys_offset == 0)
+ phys_offset = (AIU_AIFIFO_CTRL*4)&(pagesize-1);
+ reg_base = memmap + phys_offset;
+ return 0;
+}
+
+#define EXTRA_DATA_SIZE 128
+
+static inline void waiting_bits(int bits)
+{
+ int bytes;
+ bytes = READ_MPEG_REG(AIU_MEM_AIFIFO_BYTES_AVAIL);
+ while (bytes * 8 < bits && !exit_flag) {
+ printk("waiting_bits \n");
+ usleep(1000);
+ bytes = READ_MPEG_REG(AIU_MEM_AIFIFO_BYTES_AVAIL);
+ }
+}
+static unsigned stream_in_offset = 0;
+
+int read_buffer(unsigned char *buffer, int size)
+{
+ int bytes;
+ int len;
+ unsigned char *p = buffer;
+ int tmp;
+ int space;
+ int i;
+ int wait_times = 0, fifo_ready_wait = 0;
+
+ int iii;
+
+ iii = READ_MPEG_REG(AIU_MEM_AIFIFO_LEVEL) - EXTRA_DATA_SIZE;
+ while (size > iii && (!exit_flag)) {
+ iii = READ_MPEG_REG(AIU_MEM_AIFIFO_LEVEL) - EXTRA_DATA_SIZE;
+
+ }
+ if (exit_flag) {
+ printk("exit flag set.exit dec\n");
+ return 0;
+ }
+ //if(( size >= iii))
+ // return 0;
+
+ // adec_print("read_buffer start while iii= %d!!\n", iii);
+ for (len = 0; len < size;) {
+ space = (size - len);
+ bytes = READ_MPEG_REG(AIU_MEM_AIFIFO_BYTES_AVAIL);
+ //printk("read_buffer start AIU_MEM_AIFIFO_BYTES_AVAIL bytes= %d!!,exit %d \n", bytes,exit_flag);
+ if (exit_flag) {
+ printk("exit 1 \n");
+ return 0;
+ }
+ wait_times = 0;
+ while (bytes == 0) {
+ waiting_bits((space > 128) ? 128 * 8 : (space * 8)); /*wait 32 bytes,if the space is less than 32 bytes,wait the space bits*/
+ bytes = READ_MPEG_REG(AIU_MEM_AIFIFO_BYTES_AVAIL);
+
+ // audio_codec_print("read_buffer while AIU_MEM_AIFIFO_BYTES_AVAIL = %d!!\n", bytes);
+ wait_times++;
+ if (wait_times > 10 || exit_flag) {
+ audio_codec_print("goto out!!\n");
+ goto out;
+ }
+ }
+ bytes = min(space, bytes);
+
+ //adec_print("read_buffer while bytes = %d!!\n", bytes);
+ for (i = 0; i < bytes; i++) {
+ if (exit_flag) {
+ printk("exit 2 \n");
+
+ return 0;
+ }
+ while (!AIFIFO_READY) {
+ fifo_ready_wait++;
+ usleep(1000);
+ printk("fifo not ready \n");
+ if (fifo_ready_wait > 100) {
+ audio_codec_print("FATAL err,AIFIFO is not ready,check!!\n");
+ return 0;
+ }
+ }
+ WRITE_MPEG_REG(AIU_AIFIFO_GBIT, 8);
+ tmp = READ_MPEG_REG(AIU_AIFIFO_GBIT);
+ //adec_print("read_buffer while tmp = %d!!\n", tmp);
+
+ *p++ = tmp & 0xff;
+ fifo_ready_wait = 0;
+
+ }
+ len += bytes;
+ }
+out:
+ stream_in_offset += len;
+ return len;
+}
+int get_audiobuf_level()
+{
+ int level = 0;
+ level = READ_MPEG_REG(AIU_MEM_AIFIFO_LEVEL) - EXTRA_DATA_SIZE;
+ if (level < 0) {
+ level = 0;
+ }
+ return level;
+}
+
+
+
+#define pcm_buffer_size (1024*6)
+#define bluray_pcm_size (1024*17)
+
+
+static short table[256];
+static unsigned char pcm_buffer[bluray_pcm_size];
+
+#define LOCAL inline
+
+#define SIGN_BIT (0x80)
+#define QUANT_MASK (0xf)
+#define NSEGS (8)
+#define SEG_SHIFT (4)
+#define SEG_MASK (0x70)
+
+#define BIAS (0x84)
+
+static int pcm_channels = 0;
+static int pcm_samplerate = 0;
+static int pcm_datewidth = 16;
+static int pcm_bluray_header = 0;
+static int pcm_bluray_size = 0;
+
+static struct audio_info *pcm_info;
+
+
+#define Emphasis_Off 0
+#define Emphasis_On 1
+#define Quantization_Word_16bit 0
+#define Quantization_Word_Reserved 0xff
+#define Audio_Sampling_44_1 1
+#define Audio_Sampling_48 2
+#define Audio_Sampling_Reserved 0xff
+#define Audio_channel_Dual_Mono 0
+#define Audio_channel_Stero 1
+#define Audio_channel_Reserved 0xff
+#define FramesPerAU 80 //according to spec of wifi display
+#define Wifi_Display_Private_Header_Size 4
+
+static int lpcm_header_parsed = 0;
+static int parse_wifi_display_pcm_header(char *header, int *bps)
+{
+ char number_of_frame_header, audio_emphasis, quant, sample, channel;
+ int frame_size = -1;
+
+ //check sub id
+ if (header[0] == 0xa0) {
+ number_of_frame_header = header[1];
+ audio_emphasis = header[2] & 1;
+ quant = header[3] >> 6;
+ sample = (header[3] >> 3) & 7;
+ channel = header[3] & 7;
+
+ if (quant == Quantization_Word_16bit) {
+ *bps = 16;
+ } else {
+ printk("using reserved bps %d\n", *bps);
+ }
+
+ if (sample == Audio_Sampling_44_1) {
+ pcm_samplerate = 44100;
+ } else if (sample == Audio_Sampling_48) {
+ pcm_samplerate = 48000;
+ } else {
+ printk("using reserved sample_rate %d\n", pcm_samplerate);
+ }
+
+ if (channel == Audio_channel_Dual_Mono) {
+ pcm_channels = 1; //note: this is not sure
+ } else if (channel == Audio_channel_Stero) {
+ pcm_channels = 2;
+ } else {
+ printk("using reserved channel %d\n", pcm_channels);
+ }
+
+
+ frame_size = FramesPerAU * (*bps >> 3) * pcm_channels * number_of_frame_header;
+
+ } else {
+ printk("unknown sub id\n");
+ }
+
+ return frame_size;
+}
+
+int frame_size_check_flag = 0;
+int frame_size_check = 0;
+int jump_read_head_flag = 0;
+int audio_dec_init(audio_decoder_operations_t *adp)
+{
+ //printk("\n\n[%s]WFD LPCMDEC BuildDate--%s BuildTime--%s", __FUNCTION__, __DATE__, __TIME__);
+ char value[PROPERTY_VALUE_MAX];
+ if (property_get("media.wfd.debug_dec", value, NULL) > 0) {
+ enable_debug_print = atoi(value);
+ }
+ stream_in_offset = 0;
+ exit_flag = 0;
+ int err;
+ err = uio_init();
+ if (err) {
+ return -1;
+ }
+ printk("LPCM--- audio_dec_init done \n");
+ return 0;
+}
+
+
+
+
+int audio_dec_decode(audio_decoder_operations_t *adec_ops, char *buf, int *outlen, char *inbuf, int inlen)
+{
+ short *sample;
+ unsigned char *src;
+ int size, n, i, j, bps, wifi_display_drop_header = 0;
+ int sample_size;
+ unsigned int header;
+ int16_t *dst_int16_t;
+ int32_t *dst_int32_t;
+ int64_t *dst_int64_t;
+ uint16_t *dst_uint16_t;
+ uint32_t *dst_uint32_t;
+ int frame_size;
+ int skip_bytes = 0;
+ sample = (short *)buf;
+ src = pcm_buffer;
+ *outlen = 0;
+
+ //check audio info for wifi display LPCM
+ size = read_buffer(pcm_buffer, Wifi_Display_Private_Header_Size);
+resync:
+ /*
+ while (get_audiobuf_level()*1000 /(4*48000) > 300) {
+ printk("skip byte buffer level %d \n",get_audiobuf_level());
+ read_buffer(pcm_buffer,1024);
+ }
+ */
+ if (exit_flag == 1) {
+ printk("exit flag set.exit dec1\n");
+ return 0;
+ }
+ if (enable_debug_print) {
+ printk("wifi display: pcm read size%d %x-%x-%x-%x\n", size, pcm_buffer[0], pcm_buffer[1], pcm_buffer[2], pcm_buffer[3]);
+ }
+
+ if (pcm_buffer[0] == 0xa0) {
+ frame_size = parse_wifi_display_pcm_header(pcm_buffer, &bps);
+ if (frame_size > 1920) {
+ printk("frame size error ??? %d \n", frame_size);
+ goto skipbyte;
+ }
+ size = read_buffer(pcm_buffer, frame_size);
+
+ } else {
+skipbyte:
+ pcm_buffer[0] = pcm_buffer[1];
+ pcm_buffer[1] = pcm_buffer[2];
+ pcm_buffer[2] = pcm_buffer[3];
+ read_buffer(&pcm_buffer[3], 1);
+ skip_bytes++;
+ goto resync;
+ frame_size = Wifi_Display_Private_Header_Size; //transimit error or something?
+ }
+ if (enable_debug_print) {
+ printk("wifi display: pcm read size%d %x-%x-%x-%x,skip bytes %d \n", size, pcm_buffer[0], pcm_buffer[1], pcm_buffer[2], pcm_buffer[3], skip_bytes);
+ }
+
+ if (bps == 16) {
+ if (pcm_channels == 1) {
+ for (i = 0, j = 0; i < frame_size;) {
+ sample[j + 1] = sample[j] = (pcm_buffer[i] << 8) | pcm_buffer[i + 1];
+ i += 2;
+ j += 2;
+ }
+ } else if (pcm_channels == 2) {
+ for (i = 0, j = 0; i < frame_size;) {
+ sample[j++] = (pcm_buffer[i] << 8) | pcm_buffer[i + 1];
+ i += 2;
+ sample[j++] = (pcm_buffer[i] << 8) | pcm_buffer[i + 1];
+ i += 2;
+ }
+ }
+ *outlen = frame_size;
+
+
+ /*
+ before output the audio frame,check the audio buffer level to see if we need drop pcm
+
+ */
+ unsigned audio_latency = get_audiobuf_level() * 1000 / (48000 * 4);
+ // printk("audio latency %d \n",audio_latency);
+ memcpy(inbuf, &audio_latency, sizeof(audio_latency));
+ if (enable_debug_print) {
+ printk("sample rate %d, ch %d \n", pcm_samplerate, pcm_channels);
+ }
+ if (pcm_samplerate > 0 && pcm_channels > 0) {
+ adec_ops->channels = pcm_channels;
+ adec_ops->samplerate = pcm_samplerate;
+ }
+ return stream_in_offset;
+ } else {
+ printk("wifi display:unimplemented bps %d\n", bps);
+ }
+
+
+ return stream_in_offset;
+}
+
+int audio_dec_release(audio_decoder_operations_t *adec_ops)
+{
+ if (fd_uio >= 0) {
+ close(fd_uio);
+ }
+ fd_uio = -1;
+ if (memmap != NULL && memmap != MAP_FAILED) {
+ munmap(memmap, phys_size);
+ }
+ printk("audio_dec_release done \n");
+ return 0;
+}
+
+
+int audio_dec_getinfo(audio_decoder_operations_t *adec_ops)
+{
+ return 0;
+}
+void audio_set_exit_flag()
+{
+ exit_flag = 1;
+ printk("adec decode exit flag set \n");
+}
diff --git a/audio_codec/libmad/Android.mk b/audio_codec/libmad/Android.mk
new file mode 100755
index 0000000..3aa1e20
--- a/dev/null
+++ b/audio_codec/libmad/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SHARED_LIBRARIES += libutils libmedia libz libbinder libdl libcutils libc
+
+LOCAL_MODULE := libmad
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+LOCAL_ARM_MODE := arm
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := $(LOCAL_PATH) \
+LOCAL_PRELINK_MODULE := false
+include $(BUILD_SHARED_LIBRARY)
diff --git a/audio_codec/libmad/D.dat b/audio_codec/libmad/D.dat
new file mode 100755
index 0000000..4a7fa4f
--- a/dev/null
+++ b/audio_codec/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: D.dat,v 1.9 2004/01/23 09:41:32 rob Exp $
+ */
+
+/*
+ * 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/audio_codec/libmad/bit.c b/audio_codec/libmad/bit.c
new file mode 100644
index 0000000..b5550ec
--- a/dev/null
+++ b/audio_codec/libmad/bit.c
@@ -0,0 +1,244 @@
+/*
+ * 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: bit.c,v 1.12 2004/01/23 09:41:32 rob Exp $
+ */
+
+# ifdef HAVE_CONFIG_H
+# include "config.h"
+# endif
+
+# include "global.h"
+
+# ifdef HAVE_LIMITS_H
+# include <limits.h>
+# else
+# 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
+
+/*
+ * NAME: bit->init()
+ * DESCRIPTION: initialize bit pointer struct
+ */
+void mad_bit_init(struct mad_bitptr *bitptr, unsigned char const *byte)
+{
+ bitptr->byte = byte;
+ bitptr->cache = 0;
+ bitptr->left = CHAR_BIT;
+}
+
+/*
+ * 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 begin->left +
+ CHAR_BIT * (end->byte - (begin->byte + 1)) + (CHAR_BIT - end->left);
+}
+
+/*
+ * NAME: bit->nextbyte()
+ * DESCRIPTION: return pointer to next unprocessed byte
+ */
+unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *bitptr)
+{
+ return bitptr->left == CHAR_BIT ? bitptr->byte : bitptr->byte + 1;
+}
+
+/*
+ * NAME: bit->skip()
+ * DESCRIPTION: advance bit pointer
+ */
+void mad_bit_skip(struct mad_bitptr *bitptr, unsigned int len)
+{
+ bitptr->byte += len / CHAR_BIT;
+ bitptr->left -= len % CHAR_BIT;
+
+ if (bitptr->left > CHAR_BIT) {
+ bitptr->byte++;
+ bitptr->left += CHAR_BIT;
+ }
+
+ if (bitptr->left < CHAR_BIT) {
+ bitptr->cache = *bitptr->byte;
+ }
+}
+
+/*
+ * NAME: bit->read()
+ * DESCRIPTION: read an arbitrary number of bits and return their UIMSBF value
+ */
+unsigned long mad_bit_read(struct mad_bitptr *bitptr, unsigned int len)
+{
+ register unsigned long value;
+
+ if (bitptr->left == CHAR_BIT) {
+ bitptr->cache = *bitptr->byte;
+ }
+
+ if (len < bitptr->left) {
+ value = (bitptr->cache & ((1 << bitptr->left) - 1)) >>
+ (bitptr->left - len);
+ bitptr->left -= len;
+
+ return value;
+ }
+
+ /* remaining bits in current byte */
+
+ value = bitptr->cache & ((1 << bitptr->left) - 1);
+ len -= bitptr->left;
+
+ bitptr->byte++;
+ bitptr->left = CHAR_BIT;
+
+ /* more bytes */
+
+ while (len >= CHAR_BIT) {
+ value = (value << CHAR_BIT) | *bitptr->byte++;
+ len -= CHAR_BIT;
+ }
+
+ if (len > 0) {
+ bitptr->cache = *bitptr->byte;
+
+ value = (value << len) | (bitptr->cache >> (CHAR_BIT - len));
+ bitptr->left -= len;
+ }
+
+ return value;
+}
+
+# if 0
+/*
+ * NAME: bit->write()
+ * DESCRIPTION: write an arbitrary number of bits
+ */
+void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len,
+ unsigned long 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 unsigned long 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/audio_codec/libmad/bit.h b/audio_codec/libmad/bit.h
new file mode 100644
index 0000000..db6092a
--- a/dev/null
+++ b/audio_codec/libmad/bit.h
@@ -0,0 +1,47 @@
+/*
+ * 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: bit.h,v 1.12 2004/01/23 09:41:32 rob Exp $
+ */
+
+# ifndef LIBMAD_BIT_H
+# define LIBMAD_BIT_H
+
+struct mad_bitptr {
+ unsigned char const *byte;
+ unsigned short cache;
+ unsigned short left;
+};
+
+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 *);
+
+# define mad_bit_bitsleft(bitptr) ((bitptr)->left)
+unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *);
+
+void mad_bit_skip(struct mad_bitptr *, unsigned int);
+unsigned long mad_bit_read(struct mad_bitptr *, unsigned int);
+void mad_bit_write(struct mad_bitptr *, unsigned int, unsigned long);
+
+unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short);
+
+# endif
diff --git a/audio_codec/libmad/config.h b/audio_codec/libmad/config.h
new file mode 100644
index 0000000..c17238c
--- a/dev/null
+++ b/audio_codec/libmad/config.h
@@ -0,0 +1,133 @@
+/* config.h. Generated by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+#define FPM_DEFAULT
+#define HAVE_CONFIG_H
+
+/* Define to enable diagnostic debugging support. */
+/* #undef DEBUG */
+
+/* Define to enable experimental code. */
+/* #undef EXPERIMENTAL */
+
+/* Define to 1 if you have the <assert.h> header file. */
+#define HAVE_ASSERT_H 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+/* #undef HAVE_DLFCN_H */
+
+/* Define to 1 if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define to 1 if you have the `fcntl' function. */
+/* #undef HAVE_FCNTL */
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the `fork' function. */
+/* #undef HAVE_FORK */
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define if your MIPS CPU supports a 2-operand MADD16 instruction. */
+/* #undef HAVE_MADD16_ASM */
+
+/* Define if your MIPS CPU supports a 2-operand MADD instruction. */
+/* #undef HAVE_MADD_ASM */
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `pipe' function. */
+/* #undef HAVE_PIPE */
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+/* #undef HAVE_SYS_WAIT_H */
+
+/* Define to 1 if you have the <unistd.h> header file. */
+/* #undef HAVE_UNISTD_H */
+
+/* Define to 1 if you have the `waitpid' function. */
+/* #undef HAVE_WAITPID */
+
+/* Define to disable debugging assertions. */
+/* #undef NDEBUG */
+
+/* Define to optimize for accuracy over speed. */
+/* #undef OPT_ACCURACY */
+
+/* Define to optimize for speed over accuracy. */
+/* #undef OPT_SPEED */
+
+/* Define to enable a fast subband synthesis approximation optimization. */
+/* #undef OPT_SSO */
+
+/* Define to influence a strict interpretation of the ISO/IEC standards, even
+ if this is in opposition with best accepted practices. */
+/* #undef OPT_STRICT */
+
+/* Name of package */
+#define PACKAGE "libmad"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "support@underbit.com"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "MPEG Audio Decoder"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "MPEG Audio Decoder 0.15.1b"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "libmad"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "0.15.1b"
+
+/* The size of a `int', as computed by sizeof. */
+#define SIZEOF_INT 4
+
+/* The size of a `long', as computed by sizeof. */
+#define SIZEOF_LONG 4
+
+/* The size of a `long long', as computed by sizeof. */
+#define SIZEOF_LONG_LONG 8
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION "0.15.1b"
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define as `__inline' if that's what the C compiler calls it, or to nothing
+ if it is not supported. */
+#define inline __inline
+
+/* Define to `int' if <sys/types.h> does not define. */
+/* #undef pid_t */
diff --git a/audio_codec/libmad/decoder.c b/audio_codec/libmad/decoder.c
new file mode 100644
index 0000000..fbc7135
--- a/dev/null
+++ b/audio_codec/libmad/decoder.c
@@ -0,0 +1,1102 @@
+/*
+* 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: decoder.c,v 1.22 2004/01/23 09:41:32 rob Exp $
+*/
+
+#include<stdlib.h>
+# include <stdio.h>
+#include <string.h>
+
+# ifdef HAVE_CONFIG_H
+# include "config.h"
+# endif
+
+# include "global.h"
+
+# ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+# endif
+
+# ifdef HAVE_SYS_WAIT_H
+# include <sys/wait.h>
+# endif
+
+# ifdef HAVE_UNISTD_H
+# include <unistd.h>
+# endif
+
+# ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+# endif
+
+# include <stdlib.h>
+
+# ifdef HAVE_ERRNO_H
+# include <errno.h>
+# endif
+
+# include "stream.h"
+# include "frame.h"
+# include "synth.h"
+# include "decoder.h"
+
+#ifndef _WIN32
+#include "../../amadec/adec-armdec-mgt.h"
+#include <android/log.h>
+#define LOG_TAG "MadDecoder"
+#define audio_codec_print(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#else
+#define audio_codec_print printf
+#endif
+
+#define MUTE_S 0.08
+
+
+struct mad_decoder decoder;
+char *pcm_out_data;
+int *pcm_out_len;
+enum mad_flow(*error_func)(void *, struct mad_stream *, struct mad_frame *);
+void *error_data;
+int bad_last_frame = 0;
+struct mad_stream *stream;
+struct mad_frame *frame;
+struct mad_synth *synth;
+int result = 0;
+static int last_sr = -1;
+static int last_ch_num = -1;
+
+/*
+* This is a private message structure. A generic pointer to this structure
+* is passed to each of the callback functions. Put here any data you need
+* to access from within the callbacks.
+*/
+
+struct buffer {
+ unsigned char *start;
+ unsigned long length;
+};
+
+
+enum tagtype {
+ TAGTYPE_NONE = 0,
+ TAGTYPE_ID3V1,
+ TAGTYPE_ID3V2,
+ TAGTYPE_ID3V2_FOOTER
+};
+
+unsigned long id3_parse_uint(char **ptr, unsigned int bytes)
+{
+ unsigned long value = 0;
+
+ switch (bytes) {
+ case 4:
+ value = (value << 8) | *(*ptr)++;
+ case 3:
+ value = (value << 8) | *(*ptr)++;
+ case 2:
+ value = (value << 8) | *(*ptr)++;
+ case 1:
+ value = (value << 8) | *(*ptr)++;
+ }
+
+ return value;
+}
+
+unsigned long id3_parse_syncsafe(char **ptr, unsigned int bytes)
+{
+ unsigned long value = 0;
+
+ switch (bytes) {
+ case 5:
+ value = (value << 4) | (*(*ptr)++ & 0x0f);
+ case 4:
+ value = (value << 7) | (*(*ptr)++ & 0x7f);
+ value = (value << 7) | (*(*ptr)++ & 0x7f);
+ value = (value << 7) | (*(*ptr)++ & 0x7f);
+ value = (value << 7) | (*(*ptr)++ & 0x7f);
+ }
+
+ return value;
+}
+static
+void parse_header(char **ptr,
+ unsigned int *version, int *flags, int *size)
+{
+ *ptr += 3;
+
+ *version = id3_parse_uint(ptr, 2);
+ *flags = id3_parse_uint(ptr, 1);
+ *size = id3_parse_syncsafe(ptr, 4);
+}
+
+enum tagtype tagtype(char *data, int length)
+{
+ if (length >= 3 &&
+ data[0] == 'T' && data[1] == 'A' && data[2] == 'G') {
+ return TAGTYPE_ID3V1;
+ }
+
+ if (length >= 10 &&
+ ((data[0] == 'I' && data[1] == 'D' && data[2] == '3') ||
+ (data[0] == '3' && data[1] == 'D' && data[2] == 'I')) &&
+ data[3] < 0xff && data[4] < 0xff &&
+ data[6] < 0x80 && data[7] < 0x80 && data[8] < 0x80 && data[9] < 0x80) {
+ return data[0] == 'I' ? TAGTYPE_ID3V2 : TAGTYPE_ID3V2_FOOTER;
+ }
+
+ return TAGTYPE_NONE;
+}
+
+int id3_tag_query(char *data, int length)
+{
+ unsigned int version;
+ int flags;
+ int size;
+
+ switch (tagtype(data, length)) {
+ case TAGTYPE_ID3V1:
+ return 128;
+
+ case TAGTYPE_ID3V2:
+ parse_header(&data, &version, &flags, &size);
+
+ if (flags) {
+ size += 10;
+ }
+
+ return 10 + size;
+
+ case TAGTYPE_ID3V2_FOOTER:
+ parse_header(&data, &version, &flags, &size);
+ return -size - 10;
+
+ case TAGTYPE_NONE:
+ break;
+ }
+
+ return 0;
+}
+
+
+/*
+* NAME: decoder->init()
+* DESCRIPTION: initialize a decoder object with callback routines
+*/
+void mad_decoder_init(struct mad_decoder *decoder, void *data,
+ enum mad_flow(*input_func)(void *,
+ struct mad_stream *),
+ enum mad_flow(*header_func)(void *,
+ struct mad_header const *),
+ enum mad_flow(*filter_func)(void *,
+ struct mad_stream const *,
+ struct mad_frame *),
+ enum mad_flow(*output_func)(void *,
+ struct mad_header const *,
+ struct mad_pcm *),
+ enum mad_flow(*error_func)(void *,
+ struct mad_stream *,
+ struct mad_frame *),
+ enum mad_flow(*message_func)(void *,
+ void *, unsigned int *))
+{
+ decoder->mode = -1;
+
+ decoder->options = 0;
+
+ decoder->async.pid = 0;
+ decoder->async.in = -1;
+ decoder->async.out = -1;
+
+ decoder->sync = 0;
+
+ decoder->cb_data = 0;//data;
+
+ decoder->input_func = input_func;
+ decoder->header_func = header_func;
+ decoder->filter_func = filter_func;
+ decoder->output_func = output_func;
+ decoder->error_func = error_func;
+ decoder->message_func = message_func;
+}
+
+int mad_decoder_finish(struct mad_decoder *decoder)
+{
+# if defined(USE_ASYNC)
+ if (decoder->mode == MAD_DECODER_MODE_ASYNC && decoder->async.pid) {
+ pid_t pid;
+ int status;
+
+ close(decoder->async.in);
+
+ do {
+ pid = waitpid(decoder->async.pid, &status, 0);
+ } while (pid == -1 && errno == EINTR);
+
+ decoder->mode = -1;
+
+ close(decoder->async.out);
+
+ decoder->async.pid = 0;
+ decoder->async.in = -1;
+ decoder->async.out = -1;
+
+ if (pid == -1) {
+ return -1;
+ }
+
+ return (!WIFEXITED(status) || WEXITSTATUS(status)) ? -1 : 0;
+ }
+# endif
+
+ return 0;
+}
+
+# if defined(USE_ASYNC)
+static
+enum mad_flow send_io(int fd, void const *data, size_t len)
+{
+ char const *ptr = data;
+ ssize_t count;
+
+ while (len) {
+ do {
+ count = write(fd, ptr, len);
+ } while (count == -1 && errno == EINTR);
+
+ if (count == -1) {
+ return MAD_FLOW_BREAK;
+ }
+
+ len -= count;
+ ptr += count;
+ }
+
+ return MAD_FLOW_CONTINUE;
+}
+
+static
+enum mad_flow receive_io(int fd, void *buffer, size_t len)
+{
+ char *ptr = buffer;
+ ssize_t count;
+
+ while (len) {
+ do {
+ count = read(fd, ptr, len);
+ } while (count == -1 && errno == EINTR);
+
+ if (count == -1) {
+ return (errno == EAGAIN) ? MAD_FLOW_IGNORE : MAD_FLOW_BREAK;
+ } else if (count == 0) {
+ return MAD_FLOW_STOP;
+ }
+
+ len -= count;
+ ptr += count;
+ }
+
+ return MAD_FLOW_CONTINUE;
+}
+
+static
+enum mad_flow receive_io_blocking(int fd, void *buffer, size_t len)
+{
+ int flags, blocking;
+ enum mad_flow result;
+
+ flags = fcntl(fd, F_GETFL);
+ if (flags == -1) {
+ return MAD_FLOW_BREAK;
+ }
+
+ blocking = flags & ~O_NONBLOCK;
+
+ if (blocking != flags &&
+ fcntl(fd, F_SETFL, blocking) == -1) {
+ return MAD_FLOW_BREAK;
+ }
+
+ result = receive_io(fd, buffer, len);
+
+ if (flags != blocking &&
+ fcntl(fd, F_SETFL, flags) == -1) {
+ return MAD_FLOW_BREAK;
+ }
+
+ return result;
+}
+
+static
+enum mad_flow send(int fd, void const *message, unsigned int size)
+{
+ enum mad_flow result;
+
+ /* send size */
+
+ result = send_io(fd, &size, sizeof(size));
+
+ /* send message */
+
+ if (result == MAD_FLOW_CONTINUE) {
+ result = send_io(fd, message, size);
+ }
+
+ return result;
+}
+
+static
+enum mad_flow receive(int fd, void **message, unsigned int *size)
+{
+ enum mad_flow result;
+ unsigned int actual;
+
+ if (*message == 0) {
+ *size = 0;
+ }
+
+ /* receive size */
+
+ result = receive_io(fd, &actual, sizeof(actual));
+
+ /* receive message */
+
+ if (result == MAD_FLOW_CONTINUE) {
+ if (actual > *size) {
+ actual -= *size;
+ } else {
+ *size = actual;
+ actual = 0;
+ }
+
+ if (*size > 0) {
+ if (*message == 0) {
+ *message = malloc(*size);
+ if (*message == 0) {
+ return MAD_FLOW_BREAK;
+ }
+ }
+
+ result = receive_io_blocking(fd, *message, *size);
+ }
+
+ /* throw away remainder of message */
+
+ while (actual && result == MAD_FLOW_CONTINUE) {
+ char sink[256];
+ unsigned int len;
+
+ len = actual > sizeof(sink) ? sizeof(sink) : actual;
+
+ result = receive_io_blocking(fd, sink, len);
+
+ actual -= len;
+ }
+ }
+
+ return result;
+}
+
+static
+enum mad_flow check_message(struct mad_decoder *decoder)
+{
+ enum mad_flow result;
+ void *message = 0;
+ unsigned int size;
+
+ result = receive(decoder->async.in, &message, &size);
+
+ if (result == MAD_FLOW_CONTINUE) {
+ if (decoder->message_func == 0) {
+ size = 0;
+ } else {
+ result = decoder->message_func(decoder->cb_data, message, &size);
+
+ if (result == MAD_FLOW_IGNORE ||
+ result == MAD_FLOW_BREAK) {
+ size = 0;
+ }
+ }
+
+ if (send(decoder->async.out, message, size) != MAD_FLOW_CONTINUE) {
+ result = MAD_FLOW_BREAK;
+ }
+ }
+
+ if (message) {
+ free(message);
+ }
+
+ return result;
+}
+# endif
+
+static
+enum mad_flow error_default(void *data, struct mad_stream *stream,
+ struct mad_frame *frame)
+{
+ int *bad_last_frame = data;
+
+ switch (stream->error) {
+ case MAD_ERROR_BADCRC:
+ if (*bad_last_frame) {
+ mad_frame_mute(frame);
+ } else {
+ *bad_last_frame = 1;
+ }
+
+ return MAD_FLOW_IGNORE;
+
+ default:
+ return MAD_FLOW_CONTINUE;
+ }
+}
+
+static
+int run_sync(struct mad_decoder *decoder)
+{
+
+ /*
+ if (decoder->input_func == 0)
+ return 0;
+
+ if (decoder->error_func) {
+ error_func = decoder->error_func;
+ //error_data = decoder->cb_data;
+ }
+ else {
+ error_func = error_default;
+ error_data = &bad_last_frame;
+ }
+
+ stream = &decoder->sync->stream;
+ frame = &decoder->sync->frame;
+ synth = &decoder->sync->synth;
+
+ mad_stream_init(stream);
+ mad_frame_init(frame);
+ mad_synth_init(synth);
+
+ mad_stream_options(stream, decoder->options);
+ */
+ do {
+ switch (decoder->input_func(decoder->cb_data, stream)) {
+ case MAD_FLOW_STOP:
+ goto done;
+ case MAD_FLOW_BREAK:
+ goto fail;
+ case MAD_FLOW_IGNORE:
+ continue;
+ case MAD_FLOW_CONTINUE:
+ break;
+ }
+
+ while (1) {
+# if defined(USE_ASYNC)
+ if (decoder->mode == MAD_DECODER_MODE_ASYNC) {
+ switch (check_message(decoder)) {
+ case MAD_FLOW_IGNORE:
+ case MAD_FLOW_CONTINUE:
+ break;
+ case MAD_FLOW_BREAK:
+ goto fail;
+ case MAD_FLOW_STOP:
+ goto done;
+ }
+ }
+# endif
+
+ if (decoder->header_func) {
+ if (mad_header_decode(&frame->header, stream) == -1) {
+ if (!MAD_RECOVERABLE(stream->error)) {
+ break;
+ }
+
+ switch (error_func(decoder->cb_data, stream, frame)) {
+ case MAD_FLOW_STOP:
+ goto done;
+ case MAD_FLOW_BREAK:
+ goto fail;
+ case MAD_FLOW_IGNORE:
+ case MAD_FLOW_CONTINUE:
+ default:
+ continue;
+ }
+ }
+
+ switch (decoder->header_func(decoder->cb_data, &frame->header)) {
+ case MAD_FLOW_STOP:
+ goto done;
+ case MAD_FLOW_BREAK:
+ goto fail;
+ case MAD_FLOW_IGNORE:
+ continue;
+ case MAD_FLOW_CONTINUE:
+ break;
+ }
+ }
+
+ if (mad_frame_decode(frame, stream) == -1) {
+ if (!MAD_RECOVERABLE(stream->error)) {
+ break;
+ }
+
+ switch (error_func(decoder->cb_data, stream, frame)) {
+ case MAD_FLOW_STOP:
+ goto done;
+ case MAD_FLOW_BREAK:
+ goto fail;
+ case MAD_FLOW_IGNORE:
+ // for this error,we should skip one bytes for another frame sync,otherwise no chance to cosume data again
+ if (stream->this_frame == stream->buffer) {
+ stream->this_frame = stream->buffer + 1;
+ }
+ audio_codec_print("[%s,%d] MAD_FLOW_IGNORE\n", __FUNCTION__, __LINE__);
+ goto fail;
+ break;
+ case MAD_FLOW_CONTINUE:
+ default:
+ continue;
+ }
+ } else {
+ bad_last_frame = 0;
+ }
+
+ if (decoder->filter_func) {
+ switch (decoder->filter_func(decoder->cb_data, stream, frame)) {
+ case MAD_FLOW_STOP:
+ goto done;
+ case MAD_FLOW_BREAK:
+ goto fail;
+ case MAD_FLOW_IGNORE:
+ continue;
+ case MAD_FLOW_CONTINUE:
+ break;
+ }
+ }
+
+ mad_synth_frame(synth, frame);
+
+ if (decoder->output_func) {
+ switch (decoder->output_func(decoder->cb_data,
+ &frame->header, &synth->pcm)) {
+ case MAD_FLOW_STOP:
+ goto done;
+ case MAD_FLOW_BREAK:
+ goto fail;
+ case MAD_FLOW_IGNORE:
+ case MAD_FLOW_CONTINUE:
+ break;
+ }
+ }
+ }
+ } while (stream->error == MAD_ERROR_BUFLEN);
+
+fail:
+ result = -1;
+
+done:
+ /*
+ mad_synth_finish(synth);
+ mad_frame_finish(frame);
+ mad_stream_finish(stream);
+ */
+ //return result;
+ return stream->this_frame - stream->buffer;
+}
+
+# if defined(USE_ASYNC)
+static
+int run_async(struct mad_decoder *decoder)
+{
+ pid_t pid;
+ int ptoc[2], ctop[2], flags;
+
+ if (pipe(ptoc) == -1) {
+ return -1;
+ }
+
+ if (pipe(ctop) == -1) {
+ close(ptoc[0]);
+ close(ptoc[1]);
+ return -1;
+ }
+
+ flags = fcntl(ptoc[0], F_GETFL);
+ if (flags == -1 ||
+ fcntl(ptoc[0], F_SETFL, flags | O_NONBLOCK) == -1) {
+ close(ctop[0]);
+ close(ctop[1]);
+ close(ptoc[0]);
+ close(ptoc[1]);
+ return -1;
+ }
+
+ pid = fork();
+ if (pid == -1) {
+ close(ctop[0]);
+ close(ctop[1]);
+ close(ptoc[0]);
+ close(ptoc[1]);
+ return -1;
+ }
+
+ decoder->async.pid = pid;
+
+ if (pid) {
+ /* parent */
+
+ close(ptoc[0]);
+ close(ctop[1]);
+
+ decoder->async.in = ctop[0];
+ decoder->async.out = ptoc[1];
+
+ return 0;
+ }
+
+ /* child */
+
+ close(ptoc[1]);
+ close(ctop[0]);
+
+ decoder->async.in = ptoc[0];
+ decoder->async.out = ctop[1];
+
+ _exit(run_sync(decoder));
+
+ /* not reached */
+ return -1;
+}
+# endif
+
+/*
+* NAME: decoder->run()
+* DESCRIPTION: run the decoder thread either synchronously or asynchronously
+*/
+int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode)
+{
+ int result;
+ int (*run)(struct mad_decoder *) = 0;
+
+ switch (decoder->mode = mode) {
+ case MAD_DECODER_MODE_SYNC:
+ run = run_sync;
+ break;
+
+ case MAD_DECODER_MODE_ASYNC:
+# if defined(USE_ASYNC)
+ run = run_async;
+# endif
+ break;
+ }
+
+ if (run == 0) {
+ return -1;
+ }
+
+ //decoder->sync = malloc(sizeof(*decoder->sync));
+ if (decoder->sync == 0) {
+ return -1;
+ }
+
+ result = run(decoder);
+
+ //free(decoder->sync);
+ //decoder->sync = 0;
+
+ return result;
+}
+
+/*
+* NAME: decoder->message()
+* DESCRIPTION: send a message to and receive a reply from the decoder process
+*/
+int mad_decoder_message(struct mad_decoder *decoder,
+ void *message, unsigned int *len)
+{
+# if defined(USE_ASYNC)
+ if (decoder->mode != MAD_DECODER_MODE_ASYNC ||
+ send(decoder->async.out, message, *len) != MAD_FLOW_CONTINUE ||
+ receive(decoder->async.in, &message, len) != MAD_FLOW_CONTINUE) {
+ return -1;
+ }
+
+ return 0;
+# else
+ return -1;
+# endif
+}
+
+
+/*
+* This is the input callback. The purpose of this callback is to (re)fill
+* the stream buffer which is to be decoded. In this example, an entire file
+* has been mapped into memory, so we just call mad_stream_buffer() with the
+* address and length of the mapping. When this callback is called a second
+* time, we are finished decoding.
+*/
+
+static
+enum mad_flow input(void *data,
+ struct mad_stream *stream)
+{
+ struct buffer *buffer = data;
+
+ if (!buffer->length) {
+ return MAD_FLOW_STOP;
+ }
+
+ mad_stream_buffer(stream, buffer->start, buffer->length);
+
+ buffer->length = 0;
+
+ return MAD_FLOW_CONTINUE;
+}
+
+/*
+* The following utility routine performs simple rounding, clipping, and
+* scaling of MAD's high-resolution samples down to 16 bits. It does not
+* perform any dithering or noise shaping, which would be recommended to
+* obtain any exceptional audio quality. It is therefore not recommended to
+* use this routine if high-quality output is desired.
+*/
+
+static
+signed int scale(mad_fixed_t sample)
+{
+ /* round */
+ sample += (1L << (MAD_F_FRACBITS - 16));
+
+ /* clip */
+ if (sample >= MAD_F_ONE) {
+ sample = MAD_F_ONE - 1;
+ } else if (sample < -MAD_F_ONE) {
+ sample = -MAD_F_ONE;
+ }
+
+ /* quantize */
+ return sample >> (MAD_F_FRACBITS + 1 - 16);
+}
+
+/*
+* This is the output callback function. It is called after each frame of
+* MPEG audio data has been completely decoded. The purpose of this callback
+* is to output (or play) the decoded PCM audio.
+*/
+
+static
+enum mad_flow output(void *data,
+ struct mad_header const *header,
+ struct mad_pcm *pcm)
+{
+ unsigned int nchannels, nsamples;
+ mad_fixed_t const *left_ch, *right_ch;
+
+ /* pcm->samplerate contains the sampling frequency */
+
+ nchannels = pcm->channels;
+ nsamples = pcm->length;
+ left_ch = pcm->samples[0];
+ right_ch = pcm->samples[1];
+ //*pcm_out_len += 4608;
+ /*store the last channel num and sr info */
+ if (last_ch_num != nchannels) {
+ last_ch_num = nchannels;
+ }
+ if (last_sr != pcm->samplerate) {
+ last_sr = pcm->samplerate;
+ }
+ *pcm_out_len += pcm->length * 2 * (header->mode > 0 ? 2 : 1);;
+
+ if (stream->muted_samples == 0) {
+ stream->muted_samples = pcm->samplerate * pcm->channels * MUTE_S;
+ }
+ if (stream->muted_count < stream->muted_samples) {
+ memset(pcm_out_data, 0, 2 * nsamples);
+ stream->muted_count += nsamples;
+ goto output1;
+ }
+
+ while (nsamples--) {
+ signed int sample_l;
+ signed int sample_r;
+
+ /* output sample(s) in 16-bit signed little-endian PCM */
+
+ sample_l = scale(*left_ch++);
+ //putchar((sample >> 0) & 0xff);
+ //putchar((sample >> 8) & 0xff);
+ pcm_out_data[0] = sample_l >> 0;
+ pcm_out_data[1] = sample_l >> 8;
+ pcm_out_data += 2;
+ if (nchannels == 2) {
+ sample_r = scale(*right_ch++);
+ //putchar((sample >> 0) & 0xff);
+ //putchar((sample >> 8) & 0xff);
+ pcm_out_data[0] = sample_r >> 0;
+ pcm_out_data[1] = sample_r >> 8;
+ pcm_out_data += 2;
+ }
+
+ }
+output1:
+ stream->this_frame = stream->next_frame;
+ return MAD_FLOW_STOP;
+ //return MAD_FLOW_CONTINUE;
+}
+
+/*
+* This is the error callback function. It is called whenever a decoding
+* error occurs. The error is indicated by stream->error; the list of
+* possible MAD_ERROR_* errors can be found in the mad.h (or stream.h)
+* header file.
+*/
+
+static
+enum mad_flow error(void *data,
+ struct mad_stream *stream,
+ struct mad_frame *frame)
+{
+ struct buffer *buffer = data;
+ int tagsize;
+ switch (stream->error) {
+ case MAD_ERROR_LOSTSYNC:
+ tagsize = id3_tag_query(stream->this_frame,
+ stream->bufend - stream->this_frame);
+ if (tagsize > 0) {
+ stream->skiplen = tagsize;
+
+ audio_codec_print("id3 info, size = %d, just skip it!\n", tagsize);
+
+ return MAD_FLOW_CONTINUE;
+ }
+
+ /* fall through */
+
+ default:
+ break;
+ }
+ audio_codec_print("decoding error 0x%04x (%s) at byte offset %u\n",
+ stream->error, mad_stream_errorstr(stream),
+ stream->this_frame - stream->buffer);
+
+ /* return MAD_FLOW_BREAK here to stop decoding (and propagate an error) */
+ if (stream->error == MAD_ERROR_BADBITALLOC) {
+ return MAD_FLOW_IGNORE;
+ }
+
+ return MAD_FLOW_CONTINUE;
+}
+
+/*
+* This is the function called by main() above to perform all the decoding.
+* It instantiates a decoder object and configures it with the input,
+* output, and error callback functions above. A single call to
+* mad_decoder_run() continues until a callback function returns
+* MAD_FLOW_STOP (to stop decoding) or MAD_FLOW_BREAK (to stop decoding and
+* signal an error).
+*/
+
+int audio_dec_decode(
+#ifndef _WIN32
+ audio_decoder_operations_t *adec_ops,
+#endif
+ char *outbuf, int *outlen, char *inbuf, int inlen/*unsigned char const *start, unsigned long length*/)
+{
+ int result;
+ struct buffer buffer;
+
+ buffer.start = inbuf;
+ buffer.length = inlen;
+
+ /* initialize our private message structure */
+
+ pcm_out_data = outbuf;
+ pcm_out_len = outlen;
+ *pcm_out_len = 0;
+
+ /* configure input, output, and error functions */
+ decoder.cb_data = &buffer;
+
+ /* start decoding */
+ result = mad_decoder_run(&decoder, MAD_DECODER_MODE_SYNC);
+
+ /* release the decoder */
+
+ return result;
+}
+
+int audio_dec_init(
+#ifndef _WIN32
+ audio_decoder_operations_t *adec_ops
+#endif
+)
+{
+ //audio_codec_print("\n\n[%s]BuildDate--%s BuildTime--%s", __FUNCTION__, __DATE__, __TIME__);
+ memset(&decoder, 0, sizeof(struct mad_decoder));
+
+ mad_decoder_init(&decoder, 0/*&buffer*/,
+ input, 0 /* header */, 0 /* filter */, output,
+ error, 0 /* message */);
+
+ if (decoder.input_func == 0) {
+ return -1;
+ }
+
+ if (decoder.error_func) {
+ error_func = decoder.error_func;
+ //error_data = decoder->cb_data;
+ } else {
+ error_func = error_default;
+ error_data = &bad_last_frame;
+ }
+
+ decoder.sync = malloc(sizeof(*decoder.sync));
+ stream = &decoder.sync->stream;
+ frame = &decoder.sync->frame;
+ synth = &decoder.sync->synth;
+
+ mad_stream_init(stream);
+ mad_frame_init(frame);
+ mad_synth_init(synth);
+
+ mad_stream_options(stream, decoder.options);
+
+#ifndef _WIN32
+ adec_ops->nInBufSize = 5 * 1024;
+ adec_ops->nOutBufSize = 64 * 1024;
+#endif
+
+ stream->muted_samples = 0;
+ stream->muted_count = 0;
+ audio_codec_print("libmad init ok!\n");
+
+ return 0;
+}
+
+#ifndef _WIN32
+int audio_dec_getinfo(audio_decoder_operations_t *adec_ops, void *pAudioInfo)
+{
+ if (last_ch_num <= 0 || last_sr <= 0) {
+ return 0;
+ }
+ ((AudioInfo *)pAudioInfo)->channels = last_ch_num;
+ ((AudioInfo *)pAudioInfo)->samplerate = last_sr;
+ adec_ops->NchOriginal = last_ch_num;
+ return 0;
+}
+#endif
+
+int audio_dec_release(
+#ifndef _WIN32
+ audio_decoder_operations_t *adec_ops
+#endif
+)
+{
+
+
+ mad_synth_finish(synth);
+ mad_frame_finish(frame);
+ mad_stream_finish(stream);
+
+ free(decoder.sync);
+
+ mad_decoder_finish(&decoder);
+
+ stream->muted_samples = 0;
+ stream->muted_count = 0;
+
+ audio_codec_print("libmad release ok!\n");
+
+ return 0;
+}
+// win test
+#ifdef _WIN32
+char *filename = "mnjr.mp3";
+char *filename2 = "mnjr.pcm";
+FILE *fp;
+FILE *fp2;
+int main(int argc, char *argv[])
+{
+ char *outbuf;
+ int *outlen;
+ char *inbuf;
+ int inlen;
+ int size;
+ int rlen;
+
+ size = 0;
+ inlen = 0;
+ inbuf = (char *)malloc(50001);
+ outbuf = (char *)malloc(1920000);
+ outlen = (int *)malloc(5);
+
+ //init
+ fp = fopen(filename, "rb");
+ if (fp == NULL) {
+ printf("open input file failed!\n");
+ return 0;
+ }
+ fp2 = fopen(filename2, "wb");
+
+ audio_dec_init();
+
+ do {
+ //input
+ if (size) {
+ memmove(inbuf, inbuf + size, 20000 - size);
+ rlen = size;
+ } else {
+ rlen = 20000;
+ }
+
+ inlen = fread(inbuf + 20000 - rlen, 1, rlen, fp);
+
+ if (inlen == rlen) {
+ inlen = 20000;
+ }
+
+ //decode
+ size = audio_dec_decode(
+#ifndef _WIN32
+ adec_ops,
+#endif
+ outbuf, outlen, inbuf, inlen);
+
+ //output
+ fwrite(outbuf, 1, *outlen, fp2);
+
+ } while (inlen == 20000);
+
+ //release
+ audio_dec_release();
+ *pcm_out_data = NULL;
+ *pcm_out_len = NULL;
+ free(inbuf);
+ free(outbuf);
+ free(outlen);
+ fclose(fp);
+ fclose(fp2);
+ inbuf = NULL;
+ outbuf = NULL;
+ outlen = NULL;
+
+ return size;
+}
+#endif
diff --git a/audio_codec/libmad/decoder.h b/audio_codec/libmad/decoder.h
new file mode 100644
index 0000000..9d95d2d
--- a/dev/null
+++ b/audio_codec/libmad/decoder.h
@@ -0,0 +1,91 @@
+/*
+ * 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: decoder.h,v 1.17 2004/01/23 09:41:32 rob Exp $
+ */
+
+# ifndef LIBMAD_DECODER_H
+# define LIBMAD_DECODER_H
+
+# include "stream.h"
+# include "frame.h"
+# include "synth.h"
+
+enum mad_decoder_mode {
+ MAD_DECODER_MODE_SYNC = 0,
+ MAD_DECODER_MODE_ASYNC
+};
+
+enum mad_flow {
+ MAD_FLOW_CONTINUE = 0x0000, /* continue normally */
+ MAD_FLOW_STOP = 0x0010, /* stop decoding normally */
+ MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */
+ MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */
+};
+
+struct mad_decoder {
+ enum mad_decoder_mode mode;
+
+ int options;
+
+ struct {
+ long pid;
+ int in;
+ int out;
+ } async;
+
+ struct {
+ struct mad_stream stream;
+ struct mad_frame frame;
+ struct mad_synth synth;
+ } *sync;
+
+ void *cb_data;
+
+ enum mad_flow(*input_func)(void *, struct mad_stream *);
+ enum mad_flow(*header_func)(void *, struct mad_header const *);
+ enum mad_flow(*filter_func)(void *,
+ struct mad_stream const *, struct mad_frame *);
+ enum mad_flow(*output_func)(void *,
+ struct mad_header const *, struct mad_pcm *);
+ enum mad_flow(*error_func)(void *, struct mad_stream *, struct mad_frame *);
+ enum mad_flow(*message_func)(void *, void *, unsigned int *);
+};
+
+void mad_decoder_init(struct mad_decoder *, void *,
+ enum mad_flow(*)(void *, struct mad_stream *),
+ enum mad_flow(*)(void *, struct mad_header const *),
+ enum mad_flow(*)(void *,
+ struct mad_stream const *,
+ struct mad_frame *),
+ enum mad_flow(*)(void *,
+ struct mad_header const *,
+ struct mad_pcm *),
+ enum mad_flow(*)(void *,
+ struct mad_stream *,
+ struct mad_frame *),
+ enum mad_flow(*)(void *, void *, unsigned int *));
+int mad_decoder_finish(struct mad_decoder *);
+
+# define mad_decoder_options(decoder, opts) \
+ ((void) ((decoder)->options = (opts)))
+
+int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode);
+int mad_decoder_message(struct mad_decoder *, void *, unsigned int *);
+
+# endif
diff --git a/audio_codec/libmad/fixed.c b/audio_codec/libmad/fixed.c
new file mode 100644
index 0000000..9dbe588
--- a/dev/null
+++ b/audio_codec/libmad/fixed.c
@@ -0,0 +1,85 @@
+/*
+ * 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: fixed.c,v 1.13 2004/01/23 09:41:32 rob Exp $
+ */
+
+# ifdef HAVE_CONFIG_H
+# include "config.h"
+# endif
+
+# include "global.h"
+
+# include "fixed.h"
+
+/*
+ * NAME: fixed->abs()
+ * DESCRIPTION: return absolute value of a fixed-point number
+ */
+mad_fixed_t mad_f_abs(mad_fixed_t x)
+{
+ return x < 0 ? -x : x;
+}
+
+/*
+ * NAME: fixed->div()
+ * DESCRIPTION: perform division using fixed-point math
+ */
+mad_fixed_t mad_f_div(mad_fixed_t x, mad_fixed_t y)
+{
+ mad_fixed_t q, r;
+ unsigned int bits;
+
+ q = mad_f_abs(x / y);
+
+ if (x < 0) {
+ x = -x;
+ y = -y;
+ }
+
+ r = x % y;
+
+ if (y < 0) {
+ x = -x;
+ y = -y;
+ }
+
+ if (q > mad_f_intpart(MAD_F_MAX) &&
+ !(q == -mad_f_intpart(MAD_F_MIN) && r == 0 && (x < 0) != (y < 0))) {
+ return 0;
+ }
+
+ for (bits = MAD_F_FRACBITS; bits && r; --bits) {
+ q <<= 1, r <<= 1;
+ if (r >= y) {
+ r -= y, ++q;
+ }
+ }
+
+ /* round */
+ if (2 * r >= y) {
+ ++q;
+ }
+
+ /* fix sign */
+ if ((x < 0) != (y < 0)) {
+ q = -q;
+ }
+
+ return q << bits;
+}
diff --git a/audio_codec/libmad/fixed.h b/audio_codec/libmad/fixed.h
new file mode 100644
index 0000000..5556e15
--- a/dev/null
+++ b/audio_codec/libmad/fixed.h
@@ -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: fixed.h,v 1.38 2004/02/17 02:02:03 rob Exp $
+ */
+
+# ifndef LIBMAD_FIXED_H
+# define LIBMAD_FIXED_H
+#include "config.h"
+# if SIZEOF_INT >= 4
+typedef signed int mad_fixed_t;
+
+typedef signed int mad_fixed64hi_t;
+typedef unsigned int mad_fixed64lo_t;
+# else
+typedef signed long mad_fixed_t;
+
+typedef signed long mad_fixed64hi_t;
+typedef unsigned long mad_fixed64lo_t;
+# endif
+
+# 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
+
+# undef ASO_ZEROCHECK
+
+# 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
+
+/* --- 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
+
+/* C routines */
+
+mad_fixed_t mad_f_abs(mad_fixed_t);
+mad_fixed_t mad_f_div(mad_fixed_t, mad_fixed_t);
+
+# endif
diff --git a/audio_codec/libmad/frame.c b/audio_codec/libmad/frame.c
new file mode 100644
index 0000000..e588d5c
--- a/dev/null
+++ b/audio_codec/libmad/frame.c
@@ -0,0 +1,525 @@
+/*
+ * 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: frame.c,v 1.29 2004/02/04 22:59:19 rob Exp $
+ */
+
+# ifdef HAVE_CONFIG_H
+# include "config.h"
+# endif
+
+# include "global.h"
+
+# include <stdlib.h>
+
+# include "bit.h"
+# include "stream.h"
+# include "frame.h"
+# include "timer.h"
+# include "layer12.h"
+# include "layer3.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;
+
+ 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;
+
+ frame->overlap = 0;
+ mad_frame_mute(frame);
+}
+
+/*
+ * NAME: frame->finish()
+ * DESCRIPTION: deallocate any dynamic memory associated with frame
+ */
+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 */
+ if (stream->skiplen) {
+ if (!stream->sync) {
+ ptr = stream->this_frame;
+ }
+
+ if (end - ptr < 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 */
+ 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 (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)
+{
+ unsigned int s, sb;
+
+ for (s = 0; s < 36; ++s) {
+ for (sb = 0; sb < 32; ++sb) {
+ frame->sbsample[0][s][sb] =
+ frame->sbsample[1][s][sb] = 0;
+ }
+ }
+
+ if (frame->overlap) {
+ for (s = 0; s < 18; ++s) {
+ for (sb = 0; sb < 32; ++sb) {
+ (*frame->overlap)[0][sb][s] =
+ (*frame->overlap)[1][sb][s] = 0;
+ }
+ }
+ }
+}
diff --git a/audio_codec/libmad/frame.h b/audio_codec/libmad/frame.h
new file mode 100644
index 0000000..e8f53bf
--- a/dev/null
+++ b/audio_codec/libmad/frame.h
@@ -0,0 +1,118 @@
+/*
+ * 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: frame.h,v 1.20 2004/01/23 09:41:32 rob Exp $
+ */
+
+# 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) */
+
+ mad_timer_t duration; /* audio playing time of frame */
+};
+
+struct mad_frame {
+ struct mad_header header; /* MPEG audio header */
+
+ int options; /* decoding options (from stream) */
+
+ mad_fixed_t sbsample[2][36][32]; /* synthesis subband filter samples */
+ mad_fixed_t (*overlap)[2][32][18]; /* 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 *);
+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/audio_codec/libmad/global.h b/audio_codec/libmad/global.h
new file mode 100644
index 0000000..aa81918
--- a/dev/null
+++ b/audio_codec/libmad/global.h
@@ -0,0 +1,58 @@
+/*
+ * 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: global.h,v 1.11 2004/01/23 09:41:32 rob Exp $
+ */
+
+# ifndef LIBMAD_GLOBAL_H
+# define LIBMAD_GLOBAL_H
+
+/* conditional debugging */
+
+# if defined(DEBUG) && defined(NDEBUG)
+# error "cannot define both DEBUG and NDEBUG"
+# endif
+
+# if defined(DEBUG)
+# include <stdio.h>
+# 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/audio_codec/libmad/huffman.c b/audio_codec/libmad/huffman.c
new file mode 100644
index 0000000..5c4e3d7
--- a/dev/null
+++ b/audio_codec/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: huffman.c,v 1.10 2004/01/23 09:41:32 rob Exp $
+ */
+
+# 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[] = {
+ /* 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[] = {
+ /* 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[] = {
+ /* */ V(0, 0, 0)
+};
+
+static
+union huffpair const hufftab1[] = {
+ /* 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[] = {
+ /* 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[] = {
+ /* 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[] = {
+ /* 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[] = {
+ /* 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[] = {
+ /* 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[] = {
+ /* 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[] = {
+ /* 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[] = {
+ /* 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[] = {
+ /* 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[] = {
+ /* 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[] = {
+ /* 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[] = {
+ /* 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[] = {
+ /* 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[] = {
+ /* 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[] = {
+ /* 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 */ { 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 */ { 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/audio_codec/libmad/huffman.h b/audio_codec/libmad/huffman.h
new file mode 100644
index 0000000..8eb604d
--- a/dev/null
+++ b/audio_codec/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: huffman.h,v 1.11 2004/01/23 09:41:32 rob Exp $
+ */
+
+# 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/audio_codec/libmad/imdct_l_arm.S b/audio_codec/libmad/imdct_l_arm.S
new file mode 100755
index 0000000..badec5b
--- a/dev/null
+++ b/audio_codec/libmad/imdct_l_arm.S
@@ -0,0 +1,1000 @@
+/*****************************************************************************
+* Copyright (C) 2000-2001 Andre McCurdy <armccurdy@yahoo.co.uk>
+*
+* This program is free software. you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation@ either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY, without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You 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: imdct_l_arm.S,v 1.7 2001/03/25 20:03:34 rob Rel $
+*
+* 2001/03/24: Andre McCurdy <armccurdy@yahoo.co.uk>
+* - Corrected PIC unsafe loading of address of 'imdct36_long_karray'
+*
+* 2000/09/20: Robert Leslie <rob@mars.org>
+* - 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 <rob@mars.org>
+* - Fixed a small bug where flags were changed before a conditional branch.
+*
+* 2000/09/15: Andre McCurdy <armccurdy@yahoo.co.uk>
+* - Applied Nicolas Pitre's rounding optimisation in all remaining places.
+*
+* 2000/09/09: Nicolas Pitre <nico@cam.org>
+* - Optimized rounding + scaling operations.
+*
+* 2000/08/09: Andre McCurdy <armccurdy@yahoo.co.uk>
+* - Original created.
+*
+****************************************************************************/
+
+
+/*
+ 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
+ ldmia sp!, { r4 - r11, pc } @ 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
+ ldmia sp!, { r4 - r11, pc } @ restore callee saved regs, and return
+
+ @----
+ @END
+ @----
+
diff --git a/audio_codec/libmad/imdct_s.dat b/audio_codec/libmad/imdct_s.dat
new file mode 100755
index 0000000..476710e
--- a/dev/null
+++ b/audio_codec/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: imdct_s.dat,v 1.8 2004/01/23 09:41:32 rob Exp $
+ */
+
+ /* 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/audio_codec/libmad/layer12.c b/audio_codec/libmad/layer12.c
new file mode 100644
index 0000000..d52f200
--- a/dev/null
+++ b/audio_codec/libmad/layer12.c
@@ -0,0 +1,552 @@
+/*
+ * 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: layer12.c,v 1.17 2004/02/05 09:02:39 rob Exp $
+ */
+
+# ifdef HAVE_CONFIG_H
+# include "config.h"
+# endif
+
+# include "global.h"
+
+# ifdef HAVE_LIMITS_H
+# include <limits.h>
+# else
+# 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] = {
+# include "sf_table.dat"
+};
+
+/* --- Layer I ------------------------------------------------------------- */
+
+/* linear scaling table */
+static
+mad_fixed_t const linear_table[14] = {
+ 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
+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] = {
+# 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 0
+ 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;
+ }
+#endif
+ }
+
+ 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])) {
+ index = offset_table[bitalloc_table[offsets[sb]].offset][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])) {
+ index = offset_table[bitalloc_table[offsets[sb]].offset][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/audio_codec/libmad/layer12.h b/audio_codec/libmad/layer12.h
new file mode 100755
index 0000000..e1c4996
--- a/dev/null
+++ b/audio_codec/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: layer12.h,v 1.10 2004/01/23 09:41:32 rob Exp $
+ */
+
+# 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/audio_codec/libmad/layer3.c b/audio_codec/libmad/layer3.c
new file mode 100644
index 0000000..fc4b0fb
--- a/dev/null
+++ b/audio_codec/libmad/layer3.c
@@ -0,0 +1,2742 @@
+/*
+ * 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: layer3.c,v 1.43 2004/01/23 09:41:32 rob Exp $
+ */
+
+# ifdef HAVE_CONFIG_H
+# include "config.h"
+# endif
+
+# include "global.h"
+
+# include <stdlib.h>
+# include <string.h>
+
+# ifdef HAVE_ASSERT_H
+# include <assert.h>
+# endif
+
+# ifdef HAVE_LIMITS_H
+# include <limits.h>
+# else
+# define CHAR_BIT 8
+# endif
+
+# include "fixed.h"
+# include "bit.h"
+# include "stream.h"
+# include "frame.h"
+# include "huffman.h"
+# include "layer3.h"
+
+/* --- 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)
+ */
+static
+struct fixedfloat {
+ unsigned long mantissa : 27;
+ unsigned short exponent : 5;
+} 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)
+ */
+static
+mad_fixed_t const root_table[7] = {
+ 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)
+ */
+static
+mad_fixed_t const cs[8] = {
+ +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 */
+};
+
+static
+mad_fixed_t const ca[8] = {
+ -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))
+ */
+static
+mad_fixed_t const imdct_s[6][6] = {
+# include "imdct_s.dat"
+};
+
+# if !defined(ASO_IMDCT)
+/*
+ * 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] = {
+ 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 /* ASO_IMDCT */
+
+/*
+ * 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))
+ */
+static
+mad_fixed_t const window_s[12] = {
+ 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);
+
+ l += 3 * sfbwidth[sfbi];
+ 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;
+ struct fixedfloat const *power;
+
+ frac = exp % 4; /* assumes sign(frac) == sign(exp) */
+ exp /= 4;
+
+ power = &rq_table[value];
+ requantized = power->mantissa;
+ exp += power->exponent;
+
+ if (exp < 0) {
+ if (-exp >= 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 */
+# define MASK(cache, sz, bits) \
+ (((cache) >> ((sz) - (bits))) & ((1 << (bits)) - 1))
+# 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 xr[576],
+ struct channel *channel,
+ unsigned char const *sfbwidth,
+ unsigned int part2_length)
+{
+ signed int exponents[39], exp;
+ signed int const *expptr;
+ struct mad_bitptr peek;
+ signed int bits_left, cachesz;
+ register mad_fixed_t *xrptr;
+ 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;
+ mad_bit_skip(ptr, bits_left);
+
+ /* align bit reads to byte boundaries */
+ cachesz = mad_bit_bitsleft(&peek);
+ cachesz += ((32 - 1 - 24) + (24 - cachesz)) & ~7;
+
+ bitcache = mad_bit_read(&peek, cachesz);
+ bits_left -= cachesz;
+
+ xrptr = &xr[0];
+
+ /* big_values */
+ {
+ unsigned int region, rcount;
+ struct hufftable const *entry;
+ union huffpair const *table;
+ unsigned int linbits, startbits, big_values, reqhits;
+ mad_fixed_t reqcache[16];
+
+ sfbound = xrptr + *sfbwidth++;
+ rcount = channel->region0_count + 1;
+
+ entry = &mad_huff_pair_table[channel->table_select[region = 0]];
+ table = entry->table;
+ linbits = entry->linbits;
+ startbits = entry->startbits;
+
+ if (table == 0) {
+ return MAD_ERROR_BADHUFFTABLE;
+ }
+
+ expptr = &exponents[0];
+ exp = *expptr++;
+ reqhits = 0;
+
+ big_values = channel->big_values;
+
+ while (big_values-- && cachesz + bits_left > 0) {
+ union huffpair const *pair;
+ unsigned int clumpsz, value;
+ register mad_fixed_t requantized;
+
+ if (xrptr == sfbound) {
+ sfbound += *sfbwidth++;
+
+ /* change table if region boundary */
+
+ if (--rcount == 0) {
+ 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;
+ reqhits = 0;
+ }
+
+ ++expptr;
+ }
+
+ if (cachesz < 21) {
+ unsigned int bits;
+
+ bits = ((32 - 1 - 21) + (21 - cachesz)) & ~7;
+ bitcache = (bitcache << bits) | mad_bit_read(&peek, bits);
+ cachesz += bits;
+ bits_left -= bits;
+ }
+
+ /* hcod (0..19) */
+
+ clumpsz = startbits;
+ pair = &table[MASK(bitcache, cachesz, clumpsz)];
+
+ while (!pair->final) {
+ cachesz -= clumpsz;
+
+ clumpsz = pair->ptr.bits;
+ pair = &table[pair->ptr.offset + MASK(bitcache, cachesz, clumpsz)];
+ }
+
+ cachesz -= pair->value.hlen;
+
+ if (linbits) {
+ /* x (0..14) */
+
+ value = pair->value.x;
+
+ switch (value) {
+ case 0:
+ xrptr[0] = 0;
+ break;
+
+ case 15:
+ if (cachesz < linbits + 2) {
+ bitcache = (bitcache << 16) | mad_bit_read(&peek, 16);
+ cachesz += 16;
+ bits_left -= 16;
+ }
+
+ value += MASK(bitcache, cachesz, linbits);
+ cachesz -= linbits;
+
+ requantized = III_requantize(value, exp);
+ goto x_final;
+
+ default:
+ if (reqhits & (1 << value)) {
+ requantized = reqcache[value];
+ } else {
+ reqhits |= (1 << value);
+ requantized = reqcache[value] = III_requantize(value, exp);
+ }
+
+x_final:
+ xrptr[0] = MASK1BIT(bitcache, cachesz--) ?
+ -requantized : requantized;
+ }
+
+ /* y (0..14) */
+
+ value = pair->value.y;
+
+ switch (value) {
+ case 0:
+ xrptr[1] = 0;
+ break;
+
+ case 15:
+ if (cachesz < linbits + 1) {
+ bitcache = (bitcache << 16) | mad_bit_read(&peek, 16);
+ cachesz += 16;
+ bits_left -= 16;
+ }
+
+ value += MASK(bitcache, cachesz, linbits);
+ cachesz -= linbits;
+
+ requantized = III_requantize(value, exp);
+ goto y_final;
+
+ default:
+ if (reqhits & (1 << value)) {
+ requantized = reqcache[value];
+ } else {
+ reqhits |= (1 << value);
+ requantized = reqcache[value] = III_requantize(value, exp);
+ }
+
+y_final:
+ xrptr[1] = MASK1BIT(bitcache, cachesz--) ?
+ -requantized : requantized;
+ }
+ } else {
+ /* x (0..1) */
+
+ value = pair->value.x;
+
+ if (value == 0) {
+ xrptr[0] = 0;
+ } else {
+ if (reqhits & (1 << value)) {
+ requantized = reqcache[value];
+ } else {
+ reqhits |= (1 << value);
+ requantized = reqcache[value] = III_requantize(value, exp);
+ }
+
+ xrptr[0] = MASK1BIT(bitcache, cachesz--) ?
+ -requantized : requantized;
+ }
+
+ /* y (0..1) */
+
+ value = pair->value.y;
+
+ if (value == 0) {
+ xrptr[1] = 0;
+ } else {
+ if (reqhits & (1 << value)) {
+ requantized = reqcache[value];
+ } else {
+ reqhits |= (1 << value);
+ requantized = reqcache[value] = III_requantize(value, exp);
+ }
+
+ xrptr[1] = MASK1BIT(bitcache, cachesz--) ?
+ -requantized : requantized;
+ }
+ }
+
+ xrptr += 2;
+ }
+ }
+
+ if (cachesz + bits_left < 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 (cachesz + bits_left > 0 && xrptr <= &xr[572]) {
+ union huffquad const *quad;
+
+ /* hcod (1..6) */
+
+ if (cachesz < 10) {
+ bitcache = (bitcache << 16) | mad_bit_read(&peek, 16);
+ cachesz += 16;
+ bits_left -= 16;
+ }
+
+ 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 (xrptr == sfbound) {
+ sfbound += *sfbwidth++;
+
+ if (exp != *expptr) {
+ exp = *expptr;
+ requantized = III_requantize(1, exp);
+ }
+
+ ++expptr;
+ }
+
+ /* v (0..1) */
+
+ xrptr[0] = quad->value.v ?
+ (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0;
+
+ /* w (0..1) */
+
+ xrptr[1] = quad->value.w ?
+ (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0;
+
+ xrptr += 2;
+
+ if (xrptr == sfbound) {
+ sfbound += *sfbwidth++;
+
+ if (exp != *expptr) {
+ exp = *expptr;
+ requantized = III_requantize(1, exp);
+ }
+
+ ++expptr;
+ }
+
+ /* x (0..1) */
+
+ xrptr[0] = quad->value.x ?
+ (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0;
+
+ /* y (0..1) */
+
+ xrptr[1] = quad->value.y ?
+ (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0;
+
+ xrptr += 2;
+ }
+
+ if (cachesz + bits_left < 0) {
+# if 0 && defined(DEBUG)
+ fprintf(stderr, "huffman count1 overrun (%d bits)\n",
+ -(cachesz + bits_left));
+# endif
+
+ /* technically the bitstream is misformatted, but apparently
+ some encoders are just a bit sloppy with stuffing bits */
+
+ xrptr -= 4;
+ }
+ }
+
+ assert(-bits_left <= MAD_BUFFER_GUARD * CHAR_BIT);
+
+# if 0 && defined(DEBUG)
+ if (bits_left < 0) {
+ fprintf(stderr, "read %d bits too many\n", -bits_left);
+ } else if (cachesz + bits_left > 0) {
+ fprintf(stderr, "%d stuffing bits\n", cachesz + bits_left);
+ }
+# endif
+
+ /* rzero */
+ while (xrptr < &xr[576]) {
+ xrptr[0] = 0;
+ xrptr[1] = 0;
+
+ xrptr += 2;
+ }
+
+ 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;
+ }
+
+ tmp[sbw[w]][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;
+}
+
+/*
+ * 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(ASO_ZEROCHECK)
+ if (a | b) {
+# endif
+ 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);
+# if defined(ASO_ZEROCHECK)
+ }
+# endif
+ }
+ }
+}
+
+# if defined(ASO_IMDCT)
+void III_imdct_l(mad_fixed_t const [18], mad_fixed_t [36], unsigned int);
+# else
+# if 1
+static
+void fastsdct(mad_fixed_t const x[9], mad_fixed_t y[18])
+{
+ mad_fixed_t a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12;
+ mad_fixed_t a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25;
+ mad_fixed_t m0, m1, m2, m3, m4, m5, m6, m7;
+
+ enum {
+ c0 = MAD_F(0x1f838b8d), /* 2 * cos( 1 * PI / 18) */
+ c1 = MAD_F(0x1bb67ae8), /* 2 * cos( 3 * PI / 18) */
+ c2 = MAD_F(0x18836fa3), /* 2 * cos( 4 * PI / 18) */
+ c3 = MAD_F(0x1491b752), /* 2 * cos( 5 * PI / 18) */
+ c4 = MAD_F(0x0af1d43a), /* 2 * cos( 7 * PI / 18) */
+ c5 = MAD_F(0x058e86a0), /* 2 * cos( 8 * PI / 18) */
+ c6 = -MAD_F(0x1e11f642) /* 2 * cos(16 * PI / 18) */
+ };
+
+ a0 = x[3] + x[5];
+ a1 = x[3] - x[5];
+ a2 = x[6] + x[2];
+ a3 = x[6] - x[2];
+ a4 = x[1] + x[7];
+ a5 = x[1] - x[7];
+ a6 = x[8] + x[0];
+ a7 = x[8] - x[0];
+
+ a8 = a0 + a2;
+ a9 = a0 - a2;
+ a10 = a0 - a6;
+ a11 = a2 - a6;
+ a12 = a8 + a6;
+ a13 = a1 - a3;
+ a14 = a13 + a7;
+ a15 = a3 + a7;
+ a16 = a1 - a7;
+ a17 = a1 + a3;
+
+ m0 = mad_f_mul(a17, -c3);
+ m1 = mad_f_mul(a16, -c0);
+ m2 = mad_f_mul(a15, -c4);
+ m3 = mad_f_mul(a14, -c1);
+ m4 = mad_f_mul(a5, -c1);
+ m5 = mad_f_mul(a11, -c6);
+ m6 = mad_f_mul(a10, -c5);
+ m7 = mad_f_mul(a9, -c2);
+
+ a18 = x[4] + a4;
+ a19 = 2 * x[4] - a4;
+ a20 = a19 + m5;
+ a21 = a19 - m5;
+ a22 = a19 + m6;
+ a23 = m4 + m2;
+ a24 = m4 - m2;
+ a25 = m4 + m1;
+
+ /* output to every other slot for convenience */
+
+ y[ 0] = a18 + a12;
+ y[ 2] = m0 - a25;
+ y[ 4] = m7 - a20;
+ y[ 6] = m3;
+ y[ 8] = a21 - m6;
+ y[10] = a24 - m1;
+ y[12] = a12 - 2 * a18;
+ y[14] = a23 + m0;
+ y[16] = a22 + m7;
+}
+
+static inline
+void sdctII(mad_fixed_t const x[18], mad_fixed_t X[18])
+{
+ mad_fixed_t tmp[9];
+ int i;
+
+ /* scale[i] = 2 * cos(PI * (2 * i + 1) / (2 * 18)) */
+ static mad_fixed_t const scale[9] = {
+ MAD_F(0x1fe0d3b4), MAD_F(0x1ee8dd47), MAD_F(0x1d007930),
+ MAD_F(0x1a367e59), MAD_F(0x16a09e66), MAD_F(0x125abcf8),
+ MAD_F(0x0d8616bc), MAD_F(0x08483ee1), MAD_F(0x02c9fad7)
+ };
+
+ /* divide the 18-point SDCT-II into two 9-point SDCT-IIs */
+
+ /* even input butterfly */
+
+ for (i = 0; i < 9; i += 3) {
+ tmp[i + 0] = x[i + 0] + x[18 - (i + 0) - 1];
+ tmp[i + 1] = x[i + 1] + x[18 - (i + 1) - 1];
+ tmp[i + 2] = x[i + 2] + x[18 - (i + 2) - 1];
+ }
+
+ fastsdct(tmp, &X[0]);
+
+ /* odd input butterfly and scaling */
+
+ for (i = 0; i < 9; i += 3) {
+ tmp[i + 0] = mad_f_mul(x[i + 0] - x[18 - (i + 0) - 1], scale[i + 0]);
+ tmp[i + 1] = mad_f_mul(x[i + 1] - x[18 - (i + 1) - 1], scale[i + 1]);
+ tmp[i + 2] = mad_f_mul(x[i + 2] - x[18 - (i + 2) - 1], scale[i + 2]);
+ }
+
+ fastsdct(tmp, &X[1]);
+
+ /* output accumulation */
+
+ for (i = 3; i < 18; i += 8) {
+ X[i + 0] -= X[(i + 0) - 2];
+ X[i + 2] -= X[(i + 2) - 2];
+ X[i + 4] -= X[(i + 4) - 2];
+ X[i + 6] -= X[(i + 6) - 2];
+ }
+}
+
+static inline
+void dctIV(mad_fixed_t const y[18], mad_fixed_t X[18])
+{
+ mad_fixed_t tmp[18];
+ int i;
+
+ /* scale[i] = 2 * cos(PI * (2 * i + 1) / (4 * 18)) */
+ static mad_fixed_t const scale[18] = {
+ MAD_F(0x1ff833fa), MAD_F(0x1fb9ea93), MAD_F(0x1f3dd120),
+ MAD_F(0x1e84d969), MAD_F(0x1d906bcf), MAD_F(0x1c62648b),
+ MAD_F(0x1afd100f), MAD_F(0x1963268b), MAD_F(0x1797c6a4),
+ MAD_F(0x159e6f5b), MAD_F(0x137af940), MAD_F(0x11318ef3),
+ MAD_F(0x0ec6a507), MAD_F(0x0c3ef153), MAD_F(0x099f61c5),
+ MAD_F(0x06ed12c5), MAD_F(0x042d4544), MAD_F(0x0165547c)
+ };
+
+ /* scaling */
+
+ for (i = 0; i < 18; i += 3) {
+ tmp[i + 0] = mad_f_mul(y[i + 0], scale[i + 0]);
+ tmp[i + 1] = mad_f_mul(y[i + 1], scale[i + 1]);
+ tmp[i + 2] = mad_f_mul(y[i + 2], scale[i + 2]);
+ }
+
+ /* SDCT-II */
+
+ sdctII(tmp, X);
+
+ /* scale reduction and output accumulation */
+
+ X[0] /= 2;
+ for (i = 1; i < 17; i += 4) {
+ X[i + 0] = X[i + 0] / 2 - X[(i + 0) - 1];
+ X[i + 1] = X[i + 1] / 2 - X[(i + 1) - 1];
+ X[i + 2] = X[i + 2] / 2 - X[(i + 2) - 1];
+ X[i + 3] = X[i + 3] / 2 - X[(i + 3) - 1];
+ }
+ X[17] = X[17] / 2 - X[16];
+}
+
+/*
+ * NAME: imdct36
+ * DESCRIPTION: perform X[18]->x[36] IMDCT using Szu-Wei Lee's fast algorithm
+ */
+static inline
+void imdct36(mad_fixed_t const x[18], mad_fixed_t y[36])
+{
+ mad_fixed_t tmp[18];
+ int i;
+
+ /* DCT-IV */
+
+ dctIV(x, tmp);
+
+ /* convert 18-point DCT-IV to 36-point IMDCT */
+
+ for (i = 0; i < 9; i += 3) {
+ y[i + 0] = tmp[9 + (i + 0)];
+ y[i + 1] = tmp[9 + (i + 1)];
+ y[i + 2] = tmp[9 + (i + 2)];
+ }
+ for (i = 9; i < 27; i += 3) {
+ y[i + 0] = -tmp[36 - (9 + (i + 0)) - 1];
+ y[i + 1] = -tmp[36 - (9 + (i + 1)) - 1];
+ y[i + 2] = -tmp[36 - (9 + (i + 2)) - 1];
+ }
+ for (i = 27; i < 36; i += 3) {
+ y[i + 0] = -tmp[(i + 0) - 27];
+ y[i + 1] = -tmp[(i + 1) - 27];
+ y[i + 2] = -tmp[(i + 2) - 27];
+ }
+}
+# else
+/*
+ * NAME: imdct36
+ * DESCRIPTION: perform X[18]->x[36] IMDCT
+ */
+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, 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 = X[1] - X[10]), -MAD_F(0x061f78aa));
+ MAD_F_MLA(hi, lo, (t15 = X[7] + X[16]), -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[7] = MAD_F_MLZ(hi, lo);
+ x[10] = -x[7];
+
+ 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;
+
+ t12 = X[0] - X[3] + X[8] - X[11] - X[12] + X[15];
+ t13 = X[2] + X[5] - X[6] - X[9] - X[14] - X[17];
+
+ 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, 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[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[6] = MAD_F_MLZ(hi, lo) + t1;
+ x[11] = -x[6];
+
+ 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));
+
+ t7 = MAD_F_MLZ(hi, lo);
+
+ 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[5] = MAD_F_MLZ(hi, lo);
+ x[12] = -x[5];
+
+ 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[0] = MAD_F_MLZ(hi, lo) + t2;
+ x[17] = -x[0];
+
+ 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[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) + t7;
+
+ 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[8] = MAD_F_MLZ(hi, lo) + t3;
+ x[9] = -x[8];
+
+ 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, t14, -MAD_F(0x0ec835e8));
+ MAD_F_MLA(hi, lo, t15, MAD_F(0x061f78aa));
+
+ t4 = MAD_F_MLZ(hi, lo) - t7;
+
+ MAD_F_ML0(hi, lo, t12, MAD_F(0x061f78aa));
+ MAD_F_MLA(hi, lo, t13, MAD_F(0x0ec835e8));
+
+ x[4] = MAD_F_MLZ(hi, lo) + t4;
+ x[13] = -x[4];
+
+ 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) + t4;
+ x[16] = -x[1];
+
+ 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] = x[28] = MAD_F_MLZ(hi, lo) + t4;
+
+ 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(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[2] = MAD_F_MLZ(hi, lo) + t5;
+ x[15] = -x[2];
+
+ 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[3] = MAD_F_MLZ(hi, lo) + t5;
+ x[14] = -x[3];
+
+ 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
+
+/*
+ * 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 defined(ASO_INTERLEAVE1)
+ {
+ register mad_fixed_t tmp1, tmp2;
+
+ tmp1 = window_l[0];
+ tmp2 = window_l[1];
+
+ for (i = 0; i < 34; i += 2) {
+ z[i + 0] = mad_f_mul(z[i + 0], tmp1);
+ tmp1 = window_l[i + 2];
+ z[i + 1] = mad_f_mul(z[i + 1], tmp2);
+ tmp2 = window_l[i + 3];
+ }
+
+ z[34] = mad_f_mul(z[34], tmp1);
+ z[35] = mad_f_mul(z[35], tmp2);
+ }
+# elif defined(ASO_INTERLEAVE2)
+ {
+ register mad_fixed_t tmp1, tmp2;
+
+ tmp1 = z[0];
+ tmp2 = window_l[0];
+
+ for (i = 0; i < 35; ++i) {
+ z[i] = mad_f_mul(tmp1, tmp2);
+ tmp1 = z[i + 1];
+ tmp2 = window_l[i + 1];
+ }
+
+ z[35] = mad_f_mul(tmp1, tmp2);
+ }
+# elif 1
+ 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
+ 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 /* ASO_IMDCT */
+
+/*
+ * NAME: III_imdct_s()
+ * DESCRIPTION: perform IMDCT and windowing for short blocks
+ */
+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;
+ }
+}
+
+/*
+ * 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;
+
+# if defined(ASO_INTERLEAVE2)
+ {
+ register mad_fixed_t tmp1, tmp2;
+
+ tmp1 = overlap[0];
+ tmp2 = overlap[1];
+
+ for (i = 0; i < 16; i += 2) {
+ sample[i + 0][sb] = output[i + 0 + 0] + tmp1;
+ overlap[i + 0] = output[i + 0 + 18];
+ tmp1 = overlap[i + 2];
+
+ sample[i + 1][sb] = output[i + 1 + 0] + tmp2;
+ overlap[i + 1] = output[i + 1 + 18];
+ tmp2 = overlap[i + 3];
+ }
+
+ sample[16][sb] = output[16 + 0] + tmp1;
+ overlap[16] = output[16 + 18];
+ sample[17][sb] = output[17 + 0] + tmp2;
+ overlap[17] = output[17 + 18];
+ }
+# elif 0
+ for (i = 0; i < 18; i += 2) {
+ sample[i + 0][sb] = output[i + 0 + 0] + overlap[i + 0];
+ overlap[i + 0] = output[i + 0 + 18];
+
+ sample[i + 1][sb] = output[i + 1 + 0] + overlap[i + 1];
+ overlap[i + 1] = output[i + 1 + 18];
+ }
+# else
+ 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;
+
+# if defined(ASO_INTERLEAVE2)
+ {
+ register mad_fixed_t tmp1, tmp2;
+
+ tmp1 = overlap[0];
+ tmp2 = overlap[1];
+
+ for (i = 0; i < 16; i += 2) {
+ sample[i + 0][sb] = tmp1;
+ overlap[i + 0] = 0;
+ tmp1 = overlap[i + 2];
+
+ sample[i + 1][sb] = tmp2;
+ overlap[i + 1] = 0;
+ tmp2 = overlap[i + 3];
+ }
+
+ sample[16][sb] = tmp1;
+ overlap[16] = 0;
+ sample[17][sb] = tmp2;
+ overlap[17] = 0;
+ }
+# else
+ for (i = 0; i < 18; ++i) {
+ sample[i][sb] = overlap[i];
+ overlap[i] = 0;
+ }
+# endif
+}
+
+/*
+ * 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;
+
+# if 1 || defined(ASO_INTERLEAVE1) || defined(ASO_INTERLEAVE2)
+ {
+ register mad_fixed_t tmp1, tmp2;
+
+ tmp1 = sample[1][sb];
+ tmp2 = sample[3][sb];
+
+ for (i = 1; i < 13; i += 4) {
+ sample[i + 0][sb] = -tmp1;
+ tmp1 = sample[i + 4][sb];
+ sample[i + 2][sb] = -tmp2;
+ tmp2 = sample[i + 6][sb];
+ }
+
+ sample[13][sb] = -tmp1;
+ tmp1 = sample[17][sb];
+ sample[15][sb] = -tmp2;
+ sample[17][sb] = -tmp1;
+ }
+# else
+ for (i = 1; i < 18; i += 2) {
+ sample[i][sb] = -sample[i][sb];
+ }
+# endif
+}
+
+/*
+ * 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;
+ }
+
+ 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;
+
+ /* allocate Layer III dynamic structures */
+
+ 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;
+ }
+ }
+
+ 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/audio_codec/libmad/layer3.h b/audio_codec/libmad/layer3.h
new file mode 100755
index 0000000..2504d46
--- a/dev/null
+++ b/audio_codec/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: layer3.h,v 1.10 2004/01/23 09:41:32 rob Exp $
+ */
+
+# 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/audio_codec/libmad/mad.h b/audio_codec/libmad/mad.h
new file mode 100644
index 0000000..c7d373a
--- a/dev/null
+++ b/audio_codec/libmad/mad.h
@@ -0,0 +1,966 @@
+/*
+ * 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. <info@underbit.com>
+ */
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# define FPM_INTEL
+
+
+
+# define SIZEOF_INT 4
+# define SIZEOF_LONG 4
+# define SIZEOF_LONG_LONG 8
+
+
+ /* Id: version.h,v 1.26 2004/01/23 09:41:33 rob Exp */
+
+# ifndef LIBMAD_VERSION_H
+# define LIBMAD_VERSION_H
+
+# define MAD_VERSION_MAJOR 0
+# define MAD_VERSION_MINOR 15
+# define MAD_VERSION_PATCH 1
+# define MAD_VERSION_EXTRA " (beta)"
+
+# define MAD_VERSION_STRINGIZE(str) #str
+# define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num)
+
+# define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \
+ MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \
+ MAD_VERSION_STRING(MAD_VERSION_PATCH) \
+ MAD_VERSION_EXTRA
+
+# define MAD_PUBLISHYEAR "2000-2004"
+# define MAD_AUTHOR "Underbit Technologies, Inc."
+# define MAD_EMAIL "info@underbit.com"
+
+ extern char const mad_version[];
+ extern char const mad_copyright[];
+ extern char const mad_author[];
+ extern char const mad_build[];
+
+# endif
+
+ /* Id: fixed.h,v 1.38 2004/02/17 02:02:03 rob Exp */
+
+# ifndef LIBMAD_FIXED_H
+# define LIBMAD_FIXED_H
+
+# if SIZEOF_INT >= 4
+ typedef signed int mad_fixed_t;
+
+ typedef signed int mad_fixed64hi_t;
+ typedef unsigned int mad_fixed64lo_t;
+# else
+ typedef signed long mad_fixed_t;
+
+ typedef signed long mad_fixed64hi_t;
+ typedef unsigned long mad_fixed64lo_t;
+# endif
+
+# 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
+
+# undef ASO_ZEROCHECK
+
+# 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
+
+ /* --- 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
+
+ /* C routines */
+
+ mad_fixed_t mad_f_abs(mad_fixed_t);
+ mad_fixed_t mad_f_div(mad_fixed_t, mad_fixed_t);
+
+# endif
+
+ /* Id: bit.h,v 1.12 2004/01/23 09:41:32 rob Exp */
+
+# ifndef LIBMAD_BIT_H
+# define LIBMAD_BIT_H
+
+ struct mad_bitptr {
+ unsigned char const *byte;
+ unsigned short cache;
+ unsigned short left;
+ };
+
+ 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 *);
+
+# define mad_bit_bitsleft(bitptr) ((bitptr)->left)
+ unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *);
+
+ void mad_bit_skip(struct mad_bitptr *, unsigned int);
+ unsigned long mad_bit_read(struct mad_bitptr *, unsigned int);
+ void mad_bit_write(struct mad_bitptr *, unsigned int, unsigned long);
+
+ unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short);
+
+# endif
+
+ /* Id: timer.h,v 1.16 2004/01/23 09:41:33 rob Exp */
+
+# ifndef LIBMAD_TIMER_H
+# define LIBMAD_TIMER_H
+
+ typedef struct {
+ signed long seconds; /* whole seconds */
+ unsigned long fraction; /* 1/MAD_TIMER_RESOLUTION seconds */
+ } mad_timer_t;
+
+ extern mad_timer_t const mad_timer_zero;
+
+# define MAD_TIMER_RESOLUTION 352800000UL
+
+ enum mad_units {
+ MAD_UNITS_HOURS = -2,
+ MAD_UNITS_MINUTES = -1,
+ MAD_UNITS_SECONDS = 0,
+
+ /* metric units */
+
+ MAD_UNITS_DECISECONDS = 10,
+ MAD_UNITS_CENTISECONDS = 100,
+ MAD_UNITS_MILLISECONDS = 1000,
+
+ /* audio sample units */
+
+ MAD_UNITS_8000_HZ = 8000,
+ MAD_UNITS_11025_HZ = 11025,
+ MAD_UNITS_12000_HZ = 12000,
+
+ MAD_UNITS_16000_HZ = 16000,
+ MAD_UNITS_22050_HZ = 22050,
+ MAD_UNITS_24000_HZ = 24000,
+
+ MAD_UNITS_32000_HZ = 32000,
+ MAD_UNITS_44100_HZ = 44100,
+ MAD_UNITS_48000_HZ = 48000,
+
+ /* video frame/field units */
+
+ MAD_UNITS_24_FPS = 24,
+ MAD_UNITS_25_FPS = 25,
+ MAD_UNITS_30_FPS = 30,
+ MAD_UNITS_48_FPS = 48,
+ MAD_UNITS_50_FPS = 50,
+ MAD_UNITS_60_FPS = 60,
+
+ /* CD audio frames */
+
+ MAD_UNITS_75_FPS = 75,
+
+ /* video drop-frame units */
+
+ MAD_UNITS_23_976_FPS = -24,
+ MAD_UNITS_24_975_FPS = -25,
+ MAD_UNITS_29_97_FPS = -30,
+ MAD_UNITS_47_952_FPS = -48,
+ MAD_UNITS_49_95_FPS = -50,
+ MAD_UNITS_59_94_FPS = -60
+ };
+
+# define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero))
+
+ int mad_timer_compare(mad_timer_t, mad_timer_t);
+
+# define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero)
+
+ void mad_timer_negate(mad_timer_t *);
+ mad_timer_t mad_timer_abs(mad_timer_t);
+
+ void mad_timer_set(mad_timer_t *, unsigned long, unsigned long, unsigned long);
+ void mad_timer_add(mad_timer_t *, mad_timer_t);
+ void mad_timer_multiply(mad_timer_t *, signed long);
+
+ signed long mad_timer_count(mad_timer_t, enum mad_units);
+ unsigned long mad_timer_fraction(mad_timer_t, unsigned long);
+ void mad_timer_string(mad_timer_t, char *, char const *,
+ enum mad_units, enum mad_units, unsigned long);
+
+# endif
+
+ /* Id: stream.h,v 1.20 2004/02/05 09:02:39 rob Exp */
+
+# ifndef LIBMAD_STREAM_H
+# define LIBMAD_STREAM_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 */
+ 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];
+ /* 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) */
+ unsigned int muted_samples;
+ unsigned int muted_count;
+ };
+
+ enum {
+ MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */
+ MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */
+# 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 *);
+ 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);
+ 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
+
+ /* Id: frame.h,v 1.20 2004/01/23 09:41:32 rob Exp */
+
+# ifndef LIBMAD_FRAME_H
+# define LIBMAD_FRAME_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) */
+
+ mad_timer_t duration; /* audio playing time of frame */
+ };
+
+ struct mad_frame {
+ struct mad_header header; /* MPEG audio header */
+
+ int options; /* decoding options (from stream) */
+
+ mad_fixed_t sbsample[2][36][32]; /* synthesis subband filter samples */
+ mad_fixed_t (*overlap)[2][32][18]; /* 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 *);
+ 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
+
+ /* Id: synth.h,v 1.15 2004/01/23 09:41:33 rob Exp */
+
+# ifndef LIBMAD_SYNTH_H
+# define LIBMAD_SYNTH_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]; /* PCM output samples [ch][sample] */
+ };
+
+ struct mad_synth {
+ mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */
+ /* [ch][eo][peo][s][v] */
+
+ unsigned int phase; /* current processing phase */
+
+ struct mad_pcm pcm; /* PCM output */
+ };
+
+ /* single channel PCM selector */
+ enum {
+ MAD_PCM_CHANNEL_SINGLE = 0
+ };
+
+ /* dual channel PCM selector */
+ enum {
+ MAD_PCM_CHANNEL_DUAL_1 = 0,
+ MAD_PCM_CHANNEL_DUAL_2 = 1
+ };
+
+ /* stereo PCM selector */
+ enum {
+ MAD_PCM_CHANNEL_STEREO_LEFT = 0,
+ MAD_PCM_CHANNEL_STEREO_RIGHT = 1
+ };
+
+ 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
+
+ /* Id: decoder.h,v 1.17 2004/01/23 09:41:32 rob Exp */
+
+# ifndef LIBMAD_DECODER_H
+# define LIBMAD_DECODER_H
+
+
+ enum mad_decoder_mode {
+ MAD_DECODER_MODE_SYNC = 0,
+ MAD_DECODER_MODE_ASYNC
+ };
+
+ enum mad_flow {
+ MAD_FLOW_CONTINUE = 0x0000, /* continue normally */
+ MAD_FLOW_STOP = 0x0010, /* stop decoding normally */
+ MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */
+ MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */
+ };
+
+ struct mad_decoder {
+ enum mad_decoder_mode mode;
+
+ int options;
+
+ struct {
+ long pid;
+ int in;
+ int out;
+ } async;
+
+ struct {
+ struct mad_stream stream;
+ struct mad_frame frame;
+ struct mad_synth synth;
+ } *sync;
+
+ void *cb_data;
+
+ enum mad_flow(*input_func)(void *, struct mad_stream *);
+ enum mad_flow(*header_func)(void *, struct mad_header const *);
+ enum mad_flow(*filter_func)(void *,
+ struct mad_stream const *, struct mad_frame *);
+ enum mad_flow(*output_func)(void *,
+ struct mad_header const *, struct mad_pcm *);
+ enum mad_flow(*error_func)(void *, struct mad_stream *, struct mad_frame *);
+ enum mad_flow(*message_func)(void *, void *, unsigned int *);
+ };
+
+ void mad_decoder_init(struct mad_decoder *, void *,
+ enum mad_flow(*)(void *, struct mad_stream *),
+ enum mad_flow(*)(void *, struct mad_header const *),
+ enum mad_flow(*)(void *,
+ struct mad_stream const *,
+ struct mad_frame *),
+ enum mad_flow(*)(void *,
+ struct mad_header const *,
+ struct mad_pcm *),
+ enum mad_flow(*)(void *,
+ struct mad_stream *,
+ struct mad_frame *),
+ enum mad_flow(*)(void *, void *, unsigned int *));
+ int mad_decoder_finish(struct mad_decoder *);
+
+# define mad_decoder_options(decoder, opts) \
+ ((void) ((decoder)->options = (opts)))
+
+ int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode);
+ int mad_decoder_message(struct mad_decoder *, void *, unsigned int *);
+
+# endif
+
+# ifdef __cplusplus
+}
+# endif
diff --git a/audio_codec/libmad/qc_table.dat b/audio_codec/libmad/qc_table.dat
new file mode 100755
index 0000000..35a2223
--- a/dev/null
+++ b/audio_codec/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: qc_table.dat,v 1.7 2004/01/23 09:41:32 rob Exp $
+ */
+
+/*
+ * 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/audio_codec/libmad/rq_table.dat b/audio_codec/libmad/rq_table.dat
new file mode 100755
index 0000000..059c4f3
--- a/dev/null
+++ b/audio_codec/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: rq_table.dat,v 1.7 2004/01/23 09:41:32 rob Exp $
+ */
+
+/*
+ * 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 */ { MAD_F(0x00000000) /* 0.000000000 */, 0 },
+ /* 1 */ { MAD_F(0x04000000) /* 0.250000000 */, 2 },
+ /* 2 */ { MAD_F(0x050a28be) /* 0.314980262 */, 3 },
+ /* 3 */ { MAD_F(0x0453a5cd) /* 0.270421794 */, 4 },
+ /* 4 */ { MAD_F(0x06597fa9) /* 0.396850263 */, 4 },
+ /* 5 */ { MAD_F(0x04466275) /* 0.267183742 */, 5 },
+ /* 6 */ { MAD_F(0x05738c72) /* 0.340710111 */, 5 },
+ /* 7 */ { MAD_F(0x06b1fc81) /* 0.418453696 */, 5 },
+ /* 8 */ { MAD_F(0x04000000) /* 0.250000000 */, 6 },
+ /* 9 */ { MAD_F(0x04ae20d7) /* 0.292511788 */, 6 },
+ /* 10 */ { MAD_F(0x0562d694) /* 0.336630420 */, 6 },
+ /* 11 */ { MAD_F(0x061dae96) /* 0.382246578 */, 6 },
+ /* 12 */ { MAD_F(0x06de47f4) /* 0.429267841 */, 6 },
+ /* 13 */ { MAD_F(0x07a44f7a) /* 0.477614858 */, 6 },
+ /* 14 */ { MAD_F(0x0437be65) /* 0.263609310 */, 7 },
+ /* 15 */ { MAD_F(0x049fc824) /* 0.289009227 */, 7 },
+
+ /* 16 */ { MAD_F(0x050a28be) /* 0.314980262 */, 7 },
+ /* 17 */ { MAD_F(0x0576c6f5) /* 0.341498336 */, 7 },
+ /* 18 */ { MAD_F(0x05e58c0b) /* 0.368541759 */, 7 },
+ /* 19 */ { MAD_F(0x06566361) /* 0.396090870 */, 7 },
+ /* 20 */ { MAD_F(0x06c93a2e) /* 0.424127753 */, 7 },
+ /* 21 */ { MAD_F(0x073dff3e) /* 0.452635998 */, 7 },
+ /* 22 */ { MAD_F(0x07b4a2bc) /* 0.481600510 */, 7 },
+ /* 23 */ { MAD_F(0x04168b05) /* 0.255503674 */, 8 },
+ /* 24 */ { MAD_F(0x0453a5cd) /* 0.270421794 */, 8 },
+ /* 25 */ { MAD_F(0x04919b6a) /* 0.285548607 */, 8 },
+ /* 26 */ { MAD_F(0x04d065fb) /* 0.300878507 */, 8 },
+ /* 27 */ { MAD_F(0x05100000) /* 0.316406250 */, 8 },
+ /* 28 */ { MAD_F(0x05506451) /* 0.332126919 */, 8 },
+ /* 29 */ { MAD_F(0x05918e15) /* 0.348035890 */, 8 },
+ /* 30 */ { MAD_F(0x05d378bb) /* 0.364128809 */, 8 },
+ /* 31 */ { MAD_F(0x06161ff3) /* 0.380401563 */, 8 },
+
+ /* 32 */ { MAD_F(0x06597fa9) /* 0.396850263 */, 8 },
+ /* 33 */ { MAD_F(0x069d9400) /* 0.413471222 */, 8 },
+ /* 34 */ { MAD_F(0x06e2594c) /* 0.430260942 */, 8 },
+ /* 35 */ { MAD_F(0x0727cc11) /* 0.447216097 */, 8 },
+ /* 36 */ { MAD_F(0x076de8fc) /* 0.464333519 */, 8 },
+ /* 37 */ { MAD_F(0x07b4ace3) /* 0.481610189 */, 8 },
+ /* 38 */ { MAD_F(0x07fc14bf) /* 0.499043224 */, 8 },
+ /* 39 */ { MAD_F(0x04220ed7) /* 0.258314934 */, 9 },
+ /* 40 */ { MAD_F(0x04466275) /* 0.267183742 */, 9 },
+ /* 41 */ { MAD_F(0x046b03e7) /* 0.276126771 */, 9 },
+ /* 42 */ { MAD_F(0x048ff1e8) /* 0.285142811 */, 9 },
+ /* 43 */ { MAD_F(0x04b52b3f) /* 0.294230696 */, 9 },
+ /* 44 */ { MAD_F(0x04daaec0) /* 0.303389310 */, 9 },
+ /* 45 */ { MAD_F(0x05007b49) /* 0.312617576 */, 9 },
+ /* 46 */ { MAD_F(0x05268fc6) /* 0.321914457 */, 9 },
+ /* 47 */ { MAD_F(0x054ceb2a) /* 0.331278957 */, 9 },
+
+ /* 48 */ { MAD_F(0x05738c72) /* 0.340710111 */, 9 },
+ /* 49 */ { MAD_F(0x059a72a5) /* 0.350206992 */, 9 },
+ /* 50 */ { MAD_F(0x05c19cd3) /* 0.359768701 */, 9 },
+ /* 51 */ { MAD_F(0x05e90a12) /* 0.369394372 */, 9 },
+ /* 52 */ { MAD_F(0x0610b982) /* 0.379083164 */, 9 },
+ /* 53 */ { MAD_F(0x0638aa48) /* 0.388834268 */, 9 },
+ /* 54 */ { MAD_F(0x0660db91) /* 0.398646895 */, 9 },
+ /* 55 */ { MAD_F(0x06894c90) /* 0.408520284 */, 9 },
+ /* 56 */ { MAD_F(0x06b1fc81) /* 0.418453696 */, 9 },
+ /* 57 */ { MAD_F(0x06daeaa1) /* 0.428446415 */, 9 },
+ /* 58 */ { MAD_F(0x07041636) /* 0.438497744 */, 9 },
+ /* 59 */ { MAD_F(0x072d7e8b) /* 0.448607009 */, 9 },
+ /* 60 */ { MAD_F(0x075722ef) /* 0.458773552 */, 9 },
+ /* 61 */ { MAD_F(0x078102b8) /* 0.468996735 */, 9 },
+ /* 62 */ { MAD_F(0x07ab1d3e) /* 0.479275937 */, 9 },
+ /* 63 */ { MAD_F(0x07d571e0) /* 0.489610555 */, 9 },
+
+ /* 64 */ { MAD_F(0x04000000) /* 0.250000000 */, 10 },
+ /* 65 */ { MAD_F(0x04156381) /* 0.255221850 */, 10 },
+ /* 66 */ { MAD_F(0x042ae32a) /* 0.260470548 */, 10 },
+ /* 67 */ { MAD_F(0x04407eb1) /* 0.265745823 */, 10 },
+ /* 68 */ { MAD_F(0x045635cf) /* 0.271047409 */, 10 },
+ /* 69 */ { MAD_F(0x046c083e) /* 0.276375048 */, 10 },
+ /* 70 */ { MAD_F(0x0481f5bb) /* 0.281728487 */, 10 },
+ /* 71 */ { MAD_F(0x0497fe03) /* 0.287107481 */, 10 },
+ /* 72 */ { MAD_F(0x04ae20d7) /* 0.292511788 */, 10 },
+ /* 73 */ { MAD_F(0x04c45df6) /* 0.297941173 */, 10 },
+ /* 74 */ { MAD_F(0x04dab524) /* 0.303395408 */, 10 },
+ /* 75 */ { MAD_F(0x04f12624) /* 0.308874267 */, 10 },
+ /* 76 */ { MAD_F(0x0507b0bc) /* 0.314377532 */, 10 },
+ /* 77 */ { MAD_F(0x051e54b1) /* 0.319904987 */, 10 },
+ /* 78 */ { MAD_F(0x053511cb) /* 0.325456423 */, 10 },
+ /* 79 */ { MAD_F(0x054be7d4) /* 0.331031635 */, 10 },
+
+ /* 80 */ { MAD_F(0x0562d694) /* 0.336630420 */, 10 },
+ /* 81 */ { MAD_F(0x0579ddd8) /* 0.342252584 */, 10 },
+ /* 82 */ { MAD_F(0x0590fd6c) /* 0.347897931 */, 10 },
+ /* 83 */ { MAD_F(0x05a8351c) /* 0.353566275 */, 10 },
+ /* 84 */ { MAD_F(0x05bf84b8) /* 0.359257429 */, 10 },
+ /* 85 */ { MAD_F(0x05d6ec0e) /* 0.364971213 */, 10 },
+ /* 86 */ { MAD_F(0x05ee6aef) /* 0.370707448 */, 10 },
+ /* 87 */ { MAD_F(0x0606012b) /* 0.376465960 */, 10 },
+ /* 88 */ { MAD_F(0x061dae96) /* 0.382246578 */, 10 },
+ /* 89 */ { MAD_F(0x06357302) /* 0.388049134 */, 10 },
+ /* 90 */ { MAD_F(0x064d4e43) /* 0.393873464 */, 10 },
+ /* 91 */ { MAD_F(0x0665402d) /* 0.399719406 */, 10 },
+ /* 92 */ { MAD_F(0x067d4896) /* 0.405586801 */, 10 },
+ /* 93 */ { MAD_F(0x06956753) /* 0.411475493 */, 10 },
+ /* 94 */ { MAD_F(0x06ad9c3d) /* 0.417385331 */, 10 },
+ /* 95 */ { MAD_F(0x06c5e72b) /* 0.423316162 */, 10 },
+
+ /* 96 */ { MAD_F(0x06de47f4) /* 0.429267841 */, 10 },
+ /* 97 */ { MAD_F(0x06f6be73) /* 0.435240221 */, 10 },
+ /* 98 */ { MAD_F(0x070f4a80) /* 0.441233161 */, 10 },
+ /* 99 */ { MAD_F(0x0727ebf7) /* 0.447246519 */, 10 },
+ /* 100 */ { MAD_F(0x0740a2b2) /* 0.453280160 */, 10 },
+ /* 101 */ { MAD_F(0x07596e8d) /* 0.459333946 */, 10 },
+ /* 102 */ { MAD_F(0x07724f64) /* 0.465407744 */, 10 },
+ /* 103 */ { MAD_F(0x078b4514) /* 0.471501425 */, 10 },
+ /* 104 */ { MAD_F(0x07a44f7a) /* 0.477614858 */, 10 },
+ /* 105 */ { MAD_F(0x07bd6e75) /* 0.483747918 */, 10 },
+ /* 106 */ { MAD_F(0x07d6a1e2) /* 0.489900479 */, 10 },
+ /* 107 */ { MAD_F(0x07efe9a1) /* 0.496072418 */, 10 },
+ /* 108 */ { MAD_F(0x0404a2c9) /* 0.251131807 */, 11 },
+ /* 109 */ { MAD_F(0x04115aca) /* 0.254236974 */, 11 },
+ /* 110 */ { MAD_F(0x041e1cc4) /* 0.257351652 */, 11 },
+ /* 111 */ { MAD_F(0x042ae8a7) /* 0.260475783 */, 11 },
+
+ /* 112 */ { MAD_F(0x0437be65) /* 0.263609310 */, 11 },
+ /* 113 */ { MAD_F(0x04449dee) /* 0.266752177 */, 11 },
+ /* 114 */ { MAD_F(0x04518733) /* 0.269904329 */, 11 },
+ /* 115 */ { MAD_F(0x045e7a26) /* 0.273065710 */, 11 },
+ /* 116 */ { MAD_F(0x046b76b9) /* 0.276236269 */, 11 },
+ /* 117 */ { MAD_F(0x04787cdc) /* 0.279415952 */, 11 },
+ /* 118 */ { MAD_F(0x04858c83) /* 0.282604707 */, 11 },
+ /* 119 */ { MAD_F(0x0492a59f) /* 0.285802482 */, 11 },
+ /* 120 */ { MAD_F(0x049fc824) /* 0.289009227 */, 11 },
+ /* 121 */ { MAD_F(0x04acf402) /* 0.292224893 */, 11 },
+ /* 122 */ { MAD_F(0x04ba292e) /* 0.295449429 */, 11 },
+ /* 123 */ { MAD_F(0x04c7679a) /* 0.298682788 */, 11 },
+ /* 124 */ { MAD_F(0x04d4af3a) /* 0.301924921 */, 11 },
+ /* 125 */ { MAD_F(0x04e20000) /* 0.305175781 */, 11 },
+ /* 126 */ { MAD_F(0x04ef59e0) /* 0.308435322 */, 11 },
+ /* 127 */ { MAD_F(0x04fcbcce) /* 0.311703498 */, 11 },
+
+ /* 128 */ { MAD_F(0x050a28be) /* 0.314980262 */, 11 },
+ /* 129 */ { MAD_F(0x05179da4) /* 0.318265572 */, 11 },
+ /* 130 */ { MAD_F(0x05251b73) /* 0.321559381 */, 11 },
+ /* 131 */ { MAD_F(0x0532a220) /* 0.324861647 */, 11 },
+ /* 132 */ { MAD_F(0x054031a0) /* 0.328172327 */, 11 },
+ /* 133 */ { MAD_F(0x054dc9e7) /* 0.331491377 */, 11 },
+ /* 134 */ { MAD_F(0x055b6ae9) /* 0.334818756 */, 11 },
+ /* 135 */ { MAD_F(0x0569149c) /* 0.338154423 */, 11 },
+ /* 136 */ { MAD_F(0x0576c6f5) /* 0.341498336 */, 11 },
+ /* 137 */ { MAD_F(0x058481e9) /* 0.344850455 */, 11 },
+ /* 138 */ { MAD_F(0x0592456d) /* 0.348210741 */, 11 },
+ /* 139 */ { MAD_F(0x05a01176) /* 0.351579152 */, 11 },
+ /* 140 */ { MAD_F(0x05ade5fa) /* 0.354955651 */, 11 },
+ /* 141 */ { MAD_F(0x05bbc2ef) /* 0.358340200 */, 11 },
+ /* 142 */ { MAD_F(0x05c9a84a) /* 0.361732758 */, 11 },
+ /* 143 */ { MAD_F(0x05d79601) /* 0.365133291 */, 11 },
+
+ /* 144 */ { MAD_F(0x05e58c0b) /* 0.368541759 */, 11 },
+ /* 145 */ { MAD_F(0x05f38a5d) /* 0.371958126 */, 11 },
+ /* 146 */ { MAD_F(0x060190ee) /* 0.375382356 */, 11 },
+ /* 147 */ { MAD_F(0x060f9fb3) /* 0.378814413 */, 11 },
+ /* 148 */ { MAD_F(0x061db6a5) /* 0.382254261 */, 11 },
+ /* 149 */ { MAD_F(0x062bd5b8) /* 0.385701865 */, 11 },
+ /* 150 */ { MAD_F(0x0639fce4) /* 0.389157191 */, 11 },
+ /* 151 */ { MAD_F(0x06482c1f) /* 0.392620204 */, 11 },
+ /* 152 */ { MAD_F(0x06566361) /* 0.396090870 */, 11 },
+ /* 153 */ { MAD_F(0x0664a2a0) /* 0.399569155 */, 11 },
+ /* 154 */ { MAD_F(0x0672e9d4) /* 0.403055027 */, 11 },
+ /* 155 */ { MAD_F(0x068138f3) /* 0.406548452 */, 11 },
+ /* 156 */ { MAD_F(0x068f8ff5) /* 0.410049398 */, 11 },
+ /* 157 */ { MAD_F(0x069deed1) /* 0.413557833 */, 11 },
+ /* 158 */ { MAD_F(0x06ac557f) /* 0.417073724 */, 11 },
+ /* 159 */ { MAD_F(0x06bac3f6) /* 0.420597041 */, 11 },
+
+ /* 160 */ { MAD_F(0x06c93a2e) /* 0.424127753 */, 11 },
+ /* 161 */ { MAD_F(0x06d7b81f) /* 0.427665827 */, 11 },
+ /* 162 */ { MAD_F(0x06e63dc0) /* 0.431211234 */, 11 },
+ /* 163 */ { MAD_F(0x06f4cb09) /* 0.434763944 */, 11 },
+ /* 164 */ { MAD_F(0x07035ff3) /* 0.438323927 */, 11 },
+ /* 165 */ { MAD_F(0x0711fc75) /* 0.441891153 */, 11 },
+ /* 166 */ { MAD_F(0x0720a087) /* 0.445465593 */, 11 },
+ /* 167 */ { MAD_F(0x072f4c22) /* 0.449047217 */, 11 },
+ /* 168 */ { MAD_F(0x073dff3e) /* 0.452635998 */, 11 },
+ /* 169 */ { MAD_F(0x074cb9d3) /* 0.456231906 */, 11 },
+ /* 170 */ { MAD_F(0x075b7bdb) /* 0.459834914 */, 11 },
+ /* 171 */ { MAD_F(0x076a454c) /* 0.463444993 */, 11 },
+ /* 172 */ { MAD_F(0x07791620) /* 0.467062117 */, 11 },
+ /* 173 */ { MAD_F(0x0787ee50) /* 0.470686258 */, 11 },
+ /* 174 */ { MAD_F(0x0796cdd4) /* 0.474317388 */, 11 },
+ /* 175 */ { MAD_F(0x07a5b4a5) /* 0.477955481 */, 11 },
+
+ /* 176 */ { MAD_F(0x07b4a2bc) /* 0.481600510 */, 11 },
+ /* 177 */ { MAD_F(0x07c39812) /* 0.485252449 */, 11 },
+ /* 178 */ { MAD_F(0x07d294a0) /* 0.488911273 */, 11 },
+ /* 179 */ { MAD_F(0x07e1985f) /* 0.492576954 */, 11 },
+ /* 180 */ { MAD_F(0x07f0a348) /* 0.496249468 */, 11 },
+ /* 181 */ { MAD_F(0x07ffb554) /* 0.499928790 */, 11 },
+ /* 182 */ { MAD_F(0x0407673f) /* 0.251807447 */, 12 },
+ /* 183 */ { MAD_F(0x040ef75e) /* 0.253653877 */, 12 },
+ /* 184 */ { MAD_F(0x04168b05) /* 0.255503674 */, 12 },
+ /* 185 */ { MAD_F(0x041e2230) /* 0.257356825 */, 12 },
+ /* 186 */ { MAD_F(0x0425bcdd) /* 0.259213318 */, 12 },
+ /* 187 */ { MAD_F(0x042d5b07) /* 0.261073141 */, 12 },
+ /* 188 */ { MAD_F(0x0434fcad) /* 0.262936282 */, 12 },
+ /* 189 */ { MAD_F(0x043ca1c9) /* 0.264802730 */, 12 },
+ /* 190 */ { MAD_F(0x04444a5a) /* 0.266672472 */, 12 },
+ /* 191 */ { MAD_F(0x044bf65d) /* 0.268545497 */, 12 },
+
+ /* 192 */ { MAD_F(0x0453a5cd) /* 0.270421794 */, 12 },
+ /* 193 */ { MAD_F(0x045b58a9) /* 0.272301352 */, 12 },
+ /* 194 */ { MAD_F(0x04630eed) /* 0.274184158 */, 12 },
+ /* 195 */ { MAD_F(0x046ac896) /* 0.276070203 */, 12 },
+ /* 196 */ { MAD_F(0x047285a2) /* 0.277959474 */, 12 },
+ /* 197 */ { MAD_F(0x047a460c) /* 0.279851960 */, 12 },
+ /* 198 */ { MAD_F(0x048209d3) /* 0.281747652 */, 12 },
+ /* 199 */ { MAD_F(0x0489d0f4) /* 0.283646538 */, 12 },
+ /* 200 */ { MAD_F(0x04919b6a) /* 0.285548607 */, 12 },
+ /* 201 */ { MAD_F(0x04996935) /* 0.287453849 */, 12 },
+ /* 202 */ { MAD_F(0x04a13a50) /* 0.289362253 */, 12 },
+ /* 203 */ { MAD_F(0x04a90eba) /* 0.291273810 */, 12 },
+ /* 204 */ { MAD_F(0x04b0e66e) /* 0.293188507 */, 12 },
+ /* 205 */ { MAD_F(0x04b8c16c) /* 0.295106336 */, 12 },
+ /* 206 */ { MAD_F(0x04c09faf) /* 0.297027285 */, 12 },
+ /* 207 */ { MAD_F(0x04c88135) /* 0.298951346 */, 12 },
+
+ /* 208 */ { MAD_F(0x04d065fb) /* 0.300878507 */, 12 },
+ /* 209 */ { MAD_F(0x04d84dff) /* 0.302808759 */, 12 },
+ /* 210 */ { MAD_F(0x04e0393e) /* 0.304742092 */, 12 },
+ /* 211 */ { MAD_F(0x04e827b6) /* 0.306678497 */, 12 },
+ /* 212 */ { MAD_F(0x04f01963) /* 0.308617963 */, 12 },
+ /* 213 */ { MAD_F(0x04f80e44) /* 0.310560480 */, 12 },
+ /* 214 */ { MAD_F(0x05000655) /* 0.312506041 */, 12 },
+ /* 215 */ { MAD_F(0x05080195) /* 0.314454634 */, 12 },
+ /* 216 */ { MAD_F(0x05100000) /* 0.316406250 */, 12 },
+ /* 217 */ { MAD_F(0x05180194) /* 0.318360880 */, 12 },
+ /* 218 */ { MAD_F(0x0520064f) /* 0.320318516 */, 12 },
+ /* 219 */ { MAD_F(0x05280e2d) /* 0.322279147 */, 12 },
+ /* 220 */ { MAD_F(0x0530192e) /* 0.324242764 */, 12 },
+ /* 221 */ { MAD_F(0x0538274e) /* 0.326209359 */, 12 },
+ /* 222 */ { MAD_F(0x0540388a) /* 0.328178922 */, 12 },
+ /* 223 */ { MAD_F(0x05484ce2) /* 0.330151445 */, 12 },
+
+ /* 224 */ { MAD_F(0x05506451) /* 0.332126919 */, 12 },
+ /* 225 */ { MAD_F(0x05587ed5) /* 0.334105334 */, 12 },
+ /* 226 */ { MAD_F(0x05609c6e) /* 0.336086683 */, 12 },
+ /* 227 */ { MAD_F(0x0568bd17) /* 0.338070956 */, 12 },
+ /* 228 */ { MAD_F(0x0570e0cf) /* 0.340058145 */, 12 },
+ /* 229 */ { MAD_F(0x05790793) /* 0.342048241 */, 12 },
+ /* 230 */ { MAD_F(0x05813162) /* 0.344041237 */, 12 },
+ /* 231 */ { MAD_F(0x05895e39) /* 0.346037122 */, 12 },
+ /* 232 */ { MAD_F(0x05918e15) /* 0.348035890 */, 12 },
+ /* 233 */ { MAD_F(0x0599c0f4) /* 0.350037532 */, 12 },
+ /* 234 */ { MAD_F(0x05a1f6d5) /* 0.352042040 */, 12 },
+ /* 235 */ { MAD_F(0x05aa2fb5) /* 0.354049405 */, 12 },
+ /* 236 */ { MAD_F(0x05b26b92) /* 0.356059619 */, 12 },
+ /* 237 */ { MAD_F(0x05baaa69) /* 0.358072674 */, 12 },
+ /* 238 */ { MAD_F(0x05c2ec39) /* 0.360088563 */, 12 },
+ /* 239 */ { MAD_F(0x05cb3100) /* 0.362107278 */, 12 },
+
+ /* 240 */ { MAD_F(0x05d378bb) /* 0.364128809 */, 12 },
+ /* 241 */ { MAD_F(0x05dbc368) /* 0.366153151 */, 12 },
+ /* 242 */ { MAD_F(0x05e41105) /* 0.368180294 */, 12 },
+ /* 243 */ { MAD_F(0x05ec6190) /* 0.370210231 */, 12 },
+ /* 244 */ { MAD_F(0x05f4b507) /* 0.372242955 */, 12 },
+ /* 245 */ { MAD_F(0x05fd0b68) /* 0.374278458 */, 12 },
+ /* 246 */ { MAD_F(0x060564b1) /* 0.376316732 */, 12 },
+ /* 247 */ { MAD_F(0x060dc0e0) /* 0.378357769 */, 12 },
+ /* 248 */ { MAD_F(0x06161ff3) /* 0.380401563 */, 12 },
+ /* 249 */ { MAD_F(0x061e81e8) /* 0.382448106 */, 12 },
+ /* 250 */ { MAD_F(0x0626e6bc) /* 0.384497391 */, 12 },
+ /* 251 */ { MAD_F(0x062f4e6f) /* 0.386549409 */, 12 },
+ /* 252 */ { MAD_F(0x0637b8fd) /* 0.388604155 */, 12 },
+ /* 253 */ { MAD_F(0x06402666) /* 0.390661620 */, 12 },
+ /* 254 */ { MAD_F(0x064896a7) /* 0.392721798 */, 12 },
+ /* 255 */ { MAD_F(0x065109be) /* 0.394784681 */, 12 },
+
+ /* 256 */ { MAD_F(0x06597fa9) /* 0.396850263 */, 12 },
+ /* 257 */ { MAD_F(0x0661f867) /* 0.398918536 */, 12 },
+ /* 258 */ { MAD_F(0x066a73f5) /* 0.400989493 */, 12 },
+ /* 259 */ { MAD_F(0x0672f252) /* 0.403063128 */, 12 },
+ /* 260 */ { MAD_F(0x067b737c) /* 0.405139433 */, 12 },
+ /* 261 */ { MAD_F(0x0683f771) /* 0.407218402 */, 12 },
+ /* 262 */ { MAD_F(0x068c7e2f) /* 0.409300027 */, 12 },
+ /* 263 */ { MAD_F(0x069507b5) /* 0.411384303 */, 12 },
+ /* 264 */ { MAD_F(0x069d9400) /* 0.413471222 */, 12 },
+ /* 265 */ { MAD_F(0x06a6230f) /* 0.415560778 */, 12 },
+ /* 266 */ { MAD_F(0x06aeb4e0) /* 0.417652964 */, 12 },
+ /* 267 */ { MAD_F(0x06b74971) /* 0.419747773 */, 12 },
+ /* 268 */ { MAD_F(0x06bfe0c0) /* 0.421845199 */, 12 },
+ /* 269 */ { MAD_F(0x06c87acc) /* 0.423945235 */, 12 },
+ /* 270 */ { MAD_F(0x06d11794) /* 0.426047876 */, 12 },
+ /* 271 */ { MAD_F(0x06d9b714) /* 0.428153114 */, 12 },
+
+ /* 272 */ { MAD_F(0x06e2594c) /* 0.430260942 */, 12 },
+ /* 273 */ { MAD_F(0x06eafe3a) /* 0.432371356 */, 12 },
+ /* 274 */ { MAD_F(0x06f3a5dc) /* 0.434484348 */, 12 },
+ /* 275 */ { MAD_F(0x06fc5030) /* 0.436599912 */, 12 },
+ /* 276 */ { MAD_F(0x0704fd35) /* 0.438718042 */, 12 },
+ /* 277 */ { MAD_F(0x070dacea) /* 0.440838732 */, 12 },
+ /* 278 */ { MAD_F(0x07165f4b) /* 0.442961975 */, 12 },
+ /* 279 */ { MAD_F(0x071f1459) /* 0.445087765 */, 12 },
+ /* 280 */ { MAD_F(0x0727cc11) /* 0.447216097 */, 12 },
+ /* 281 */ { MAD_F(0x07308671) /* 0.449346964 */, 12 },
+ /* 282 */ { MAD_F(0x07394378) /* 0.451480360 */, 12 },
+ /* 283 */ { MAD_F(0x07420325) /* 0.453616280 */, 12 },
+ /* 284 */ { MAD_F(0x074ac575) /* 0.455754717 */, 12 },
+ /* 285 */ { MAD_F(0x07538a67) /* 0.457895665 */, 12 },
+ /* 286 */ { MAD_F(0x075c51fa) /* 0.460039119 */, 12 },
+ /* 287 */ { MAD_F(0x07651c2c) /* 0.462185072 */, 12 },
+
+ /* 288 */ { MAD_F(0x076de8fc) /* 0.464333519 */, 12 },
+ /* 289 */ { MAD_F(0x0776b867) /* 0.466484455 */, 12 },
+ /* 290 */ { MAD_F(0x077f8a6d) /* 0.468637872 */, 12 },
+ /* 291 */ { MAD_F(0x07885f0b) /* 0.470793767 */, 12 },
+ /* 292 */ { MAD_F(0x07913641) /* 0.472952132 */, 12 },
+ /* 293 */ { MAD_F(0x079a100c) /* 0.475112962 */, 12 },
+ /* 294 */ { MAD_F(0x07a2ec6c) /* 0.477276252 */, 12 },
+ /* 295 */ { MAD_F(0x07abcb5f) /* 0.479441997 */, 12 },
+ /* 296 */ { MAD_F(0x07b4ace3) /* 0.481610189 */, 12 },
+ /* 297 */ { MAD_F(0x07bd90f6) /* 0.483780825 */, 12 },
+ /* 298 */ { MAD_F(0x07c67798) /* 0.485953899 */, 12 },
+ /* 299 */ { MAD_F(0x07cf60c7) /* 0.488129404 */, 12 },
+ /* 300 */ { MAD_F(0x07d84c81) /* 0.490307336 */, 12 },
+ /* 301 */ { MAD_F(0x07e13ac5) /* 0.492487690 */, 12 },
+ /* 302 */ { MAD_F(0x07ea2b92) /* 0.494670459 */, 12 },
+ /* 303 */ { MAD_F(0x07f31ee6) /* 0.496855639 */, 12 },
+
+ /* 304 */ { MAD_F(0x07fc14bf) /* 0.499043224 */, 12 },
+ /* 305 */ { MAD_F(0x0402868e) /* 0.250616605 */, 13 },
+ /* 306 */ { MAD_F(0x040703ff) /* 0.251712795 */, 13 },
+ /* 307 */ { MAD_F(0x040b82b0) /* 0.252810180 */, 13 },
+ /* 308 */ { MAD_F(0x041002a1) /* 0.253908756 */, 13 },
+ /* 309 */ { MAD_F(0x041483d1) /* 0.255008523 */, 13 },
+ /* 310 */ { MAD_F(0x04190640) /* 0.256109476 */, 13 },
+ /* 311 */ { MAD_F(0x041d89ed) /* 0.257211614 */, 13 },
+ /* 312 */ { MAD_F(0x04220ed7) /* 0.258314934 */, 13 },
+ /* 313 */ { MAD_F(0x042694fe) /* 0.259419433 */, 13 },
+ /* 314 */ { MAD_F(0x042b1c60) /* 0.260525110 */, 13 },
+ /* 315 */ { MAD_F(0x042fa4fe) /* 0.261631960 */, 13 },
+ /* 316 */ { MAD_F(0x04342ed7) /* 0.262739982 */, 13 },
+ /* 317 */ { MAD_F(0x0438b9e9) /* 0.263849174 */, 13 },
+ /* 318 */ { MAD_F(0x043d4635) /* 0.264959533 */, 13 },
+ /* 319 */ { MAD_F(0x0441d3b9) /* 0.266071056 */, 13 },
+
+ /* 320 */ { MAD_F(0x04466275) /* 0.267183742 */, 13 },
+ /* 321 */ { MAD_F(0x044af269) /* 0.268297587 */, 13 },
+ /* 322 */ { MAD_F(0x044f8393) /* 0.269412589 */, 13 },
+ /* 323 */ { MAD_F(0x045415f3) /* 0.270528746 */, 13 },
+ /* 324 */ { MAD_F(0x0458a989) /* 0.271646056 */, 13 },
+ /* 325 */ { MAD_F(0x045d3e53) /* 0.272764515 */, 13 },
+ /* 326 */ { MAD_F(0x0461d451) /* 0.273884123 */, 13 },
+ /* 327 */ { MAD_F(0x04666b83) /* 0.275004875 */, 13 },
+ /* 328 */ { MAD_F(0x046b03e7) /* 0.276126771 */, 13 },
+ /* 329 */ { MAD_F(0x046f9d7e) /* 0.277249808 */, 13 },
+ /* 330 */ { MAD_F(0x04743847) /* 0.278373983 */, 13 },
+ /* 331 */ { MAD_F(0x0478d440) /* 0.279499294 */, 13 },
+ /* 332 */ { MAD_F(0x047d716a) /* 0.280625739 */, 13 },
+ /* 333 */ { MAD_F(0x04820fc3) /* 0.281753315 */, 13 },
+ /* 334 */ { MAD_F(0x0486af4c) /* 0.282882021 */, 13 },
+ /* 335 */ { MAD_F(0x048b5003) /* 0.284011853 */, 13 },
+
+ /* 336 */ { MAD_F(0x048ff1e8) /* 0.285142811 */, 13 },
+ /* 337 */ { MAD_F(0x049494fb) /* 0.286274891 */, 13 },
+ /* 338 */ { MAD_F(0x0499393a) /* 0.287408091 */, 13 },
+ /* 339 */ { MAD_F(0x049ddea5) /* 0.288542409 */, 13 },
+ /* 340 */ { MAD_F(0x04a2853c) /* 0.289677844 */, 13 },
+ /* 341 */ { MAD_F(0x04a72cfe) /* 0.290814392 */, 13 },
+ /* 342 */ { MAD_F(0x04abd5ea) /* 0.291952051 */, 13 },
+ /* 343 */ { MAD_F(0x04b08000) /* 0.293090820 */, 13 },
+ /* 344 */ { MAD_F(0x04b52b3f) /* 0.294230696 */, 13 },
+ /* 345 */ { MAD_F(0x04b9d7a7) /* 0.295371678 */, 13 },
+ /* 346 */ { MAD_F(0x04be8537) /* 0.296513762 */, 13 },
+ /* 347 */ { MAD_F(0x04c333ee) /* 0.297656947 */, 13 },
+ /* 348 */ { MAD_F(0x04c7e3cc) /* 0.298801231 */, 13 },
+ /* 349 */ { MAD_F(0x04cc94d1) /* 0.299946611 */, 13 },
+ /* 350 */ { MAD_F(0x04d146fb) /* 0.301093085 */, 13 },
+ /* 351 */ { MAD_F(0x04d5fa4b) /* 0.302240653 */, 13 },
+
+ /* 352 */ { MAD_F(0x04daaec0) /* 0.303389310 */, 13 },
+ /* 353 */ { MAD_F(0x04df6458) /* 0.304539056 */, 13 },
+ /* 354 */ { MAD_F(0x04e41b14) /* 0.305689888 */, 13 },
+ /* 355 */ { MAD_F(0x04e8d2f3) /* 0.306841804 */, 13 },
+ /* 356 */ { MAD_F(0x04ed8bf5) /* 0.307994802 */, 13 },
+ /* 357 */ { MAD_F(0x04f24618) /* 0.309148880 */, 13 },
+ /* 358 */ { MAD_F(0x04f7015d) /* 0.310304037 */, 13 },
+ /* 359 */ { MAD_F(0x04fbbdc3) /* 0.311460269 */, 13 },
+ /* 360 */ { MAD_F(0x05007b49) /* 0.312617576 */, 13 },
+ /* 361 */ { MAD_F(0x050539ef) /* 0.313775954 */, 13 },
+ /* 362 */ { MAD_F(0x0509f9b4) /* 0.314935403 */, 13 },
+ /* 363 */ { MAD_F(0x050eba98) /* 0.316095920 */, 13 },
+ /* 364 */ { MAD_F(0x05137c9a) /* 0.317257503 */, 13 },
+ /* 365 */ { MAD_F(0x05183fba) /* 0.318420150 */, 13 },
+ /* 366 */ { MAD_F(0x051d03f7) /* 0.319583859 */, 13 },
+ /* 367 */ { MAD_F(0x0521c950) /* 0.320748629 */, 13 },
+
+ /* 368 */ { MAD_F(0x05268fc6) /* 0.321914457 */, 13 },
+ /* 369 */ { MAD_F(0x052b5757) /* 0.323081342 */, 13 },
+ /* 370 */ { MAD_F(0x05302003) /* 0.324249281 */, 13 },
+ /* 371 */ { MAD_F(0x0534e9ca) /* 0.325418273 */, 13 },
+ /* 372 */ { MAD_F(0x0539b4ab) /* 0.326588316 */, 13 },
+ /* 373 */ { MAD_F(0x053e80a6) /* 0.327759407 */, 13 },
+ /* 374 */ { MAD_F(0x05434db9) /* 0.328931546 */, 13 },
+ /* 375 */ { MAD_F(0x05481be5) /* 0.330104730 */, 13 },
+ /* 376 */ { MAD_F(0x054ceb2a) /* 0.331278957 */, 13 },
+ /* 377 */ { MAD_F(0x0551bb85) /* 0.332454225 */, 13 },
+ /* 378 */ { MAD_F(0x05568cf8) /* 0.333630533 */, 13 },
+ /* 379 */ { MAD_F(0x055b5f81) /* 0.334807879 */, 13 },
+ /* 380 */ { MAD_F(0x05603321) /* 0.335986261 */, 13 },
+ /* 381 */ { MAD_F(0x056507d6) /* 0.337165677 */, 13 },
+ /* 382 */ { MAD_F(0x0569dda0) /* 0.338346125 */, 13 },
+ /* 383 */ { MAD_F(0x056eb47f) /* 0.339527604 */, 13 },
+
+ /* 384 */ { MAD_F(0x05738c72) /* 0.340710111 */, 13 },
+ /* 385 */ { MAD_F(0x05786578) /* 0.341893646 */, 13 },
+ /* 386 */ { MAD_F(0x057d3f92) /* 0.343078205 */, 13 },
+ /* 387 */ { MAD_F(0x05821abf) /* 0.344263788 */, 13 },
+ /* 388 */ { MAD_F(0x0586f6fd) /* 0.345450393 */, 13 },
+ /* 389 */ { MAD_F(0x058bd44e) /* 0.346638017 */, 13 },
+ /* 390 */ { MAD_F(0x0590b2b0) /* 0.347826659 */, 13 },
+ /* 391 */ { MAD_F(0x05959222) /* 0.349016318 */, 13 },
+ /* 392 */ { MAD_F(0x059a72a5) /* 0.350206992 */, 13 },
+ /* 393 */ { MAD_F(0x059f5438) /* 0.351398678 */, 13 },
+ /* 394 */ { MAD_F(0x05a436da) /* 0.352591376 */, 13 },
+ /* 395 */ { MAD_F(0x05a91a8c) /* 0.353785083 */, 13 },
+ /* 396 */ { MAD_F(0x05adff4c) /* 0.354979798 */, 13 },
+ /* 397 */ { MAD_F(0x05b2e51a) /* 0.356175519 */, 13 },
+ /* 398 */ { MAD_F(0x05b7cbf5) /* 0.357372244 */, 13 },
+ /* 399 */ { MAD_F(0x05bcb3de) /* 0.358569972 */, 13 },
+
+ /* 400 */ { MAD_F(0x05c19cd3) /* 0.359768701 */, 13 },
+ /* 401 */ { MAD_F(0x05c686d5) /* 0.360968429 */, 13 },
+ /* 402 */ { MAD_F(0x05cb71e2) /* 0.362169156 */, 13 },
+ /* 403 */ { MAD_F(0x05d05dfb) /* 0.363370878 */, 13 },
+ /* 404 */ { MAD_F(0x05d54b1f) /* 0.364573594 */, 13 },
+ /* 405 */ { MAD_F(0x05da394d) /* 0.365777304 */, 13 },
+ /* 406 */ { MAD_F(0x05df2885) /* 0.366982004 */, 13 },
+ /* 407 */ { MAD_F(0x05e418c7) /* 0.368187694 */, 13 },
+ /* 408 */ { MAD_F(0x05e90a12) /* 0.369394372 */, 13 },
+ /* 409 */ { MAD_F(0x05edfc66) /* 0.370602036 */, 13 },
+ /* 410 */ { MAD_F(0x05f2efc2) /* 0.371810684 */, 13 },
+ /* 411 */ { MAD_F(0x05f7e426) /* 0.373020316 */, 13 },
+ /* 412 */ { MAD_F(0x05fcd992) /* 0.374230929 */, 13 },
+ /* 413 */ { MAD_F(0x0601d004) /* 0.375442522 */, 13 },
+ /* 414 */ { MAD_F(0x0606c77d) /* 0.376655093 */, 13 },
+ /* 415 */ { MAD_F(0x060bbffd) /* 0.377868641 */, 13 },
+
+ /* 416 */ { MAD_F(0x0610b982) /* 0.379083164 */, 13 },
+ /* 417 */ { MAD_F(0x0615b40c) /* 0.380298661 */, 13 },
+ /* 418 */ { MAD_F(0x061aaf9c) /* 0.381515130 */, 13 },
+ /* 419 */ { MAD_F(0x061fac2f) /* 0.382732569 */, 13 },
+ /* 420 */ { MAD_F(0x0624a9c7) /* 0.383950977 */, 13 },
+ /* 421 */ { MAD_F(0x0629a863) /* 0.385170352 */, 13 },
+ /* 422 */ { MAD_F(0x062ea802) /* 0.386390694 */, 13 },
+ /* 423 */ { MAD_F(0x0633a8a3) /* 0.387611999 */, 13 },
+ /* 424 */ { MAD_F(0x0638aa48) /* 0.388834268 */, 13 },
+ /* 425 */ { MAD_F(0x063dacee) /* 0.390057497 */, 13 },
+ /* 426 */ { MAD_F(0x0642b096) /* 0.391281687 */, 13 },
+ /* 427 */ { MAD_F(0x0647b53f) /* 0.392506834 */, 13 },
+ /* 428 */ { MAD_F(0x064cbae9) /* 0.393732939 */, 13 },
+ /* 429 */ { MAD_F(0x0651c193) /* 0.394959999 */, 13 },
+ /* 430 */ { MAD_F(0x0656c93d) /* 0.396188012 */, 13 },
+ /* 431 */ { MAD_F(0x065bd1e7) /* 0.397416978 */, 13 },
+
+ /* 432 */ { MAD_F(0x0660db91) /* 0.398646895 */, 13 },
+ /* 433 */ { MAD_F(0x0665e639) /* 0.399877761 */, 13 },
+ /* 434 */ { MAD_F(0x066af1df) /* 0.401109575 */, 13 },
+ /* 435 */ { MAD_F(0x066ffe84) /* 0.402342335 */, 13 },
+ /* 436 */ { MAD_F(0x06750c26) /* 0.403576041 */, 13 },
+ /* 437 */ { MAD_F(0x067a1ac6) /* 0.404810690 */, 13 },
+ /* 438 */ { MAD_F(0x067f2a62) /* 0.406046281 */, 13 },
+ /* 439 */ { MAD_F(0x06843afb) /* 0.407282813 */, 13 },
+ /* 440 */ { MAD_F(0x06894c90) /* 0.408520284 */, 13 },
+ /* 441 */ { MAD_F(0x068e5f21) /* 0.409758693 */, 13 },
+ /* 442 */ { MAD_F(0x069372ae) /* 0.410998038 */, 13 },
+ /* 443 */ { MAD_F(0x06988735) /* 0.412238319 */, 13 },
+ /* 444 */ { MAD_F(0x069d9cb7) /* 0.413479532 */, 13 },
+ /* 445 */ { MAD_F(0x06a2b333) /* 0.414721679 */, 13 },
+ /* 446 */ { MAD_F(0x06a7caa9) /* 0.415964756 */, 13 },
+ /* 447 */ { MAD_F(0x06ace318) /* 0.417208762 */, 13 },
+
+ /* 448 */ { MAD_F(0x06b1fc81) /* 0.418453696 */, 13 },
+ /* 449 */ { MAD_F(0x06b716e2) /* 0.419699557 */, 13 },
+ /* 450 */ { MAD_F(0x06bc323b) /* 0.420946343 */, 13 },
+ /* 451 */ { MAD_F(0x06c14e8d) /* 0.422194054 */, 13 },
+ /* 452 */ { MAD_F(0x06c66bd6) /* 0.423442686 */, 13 },
+ /* 453 */ { MAD_F(0x06cb8a17) /* 0.424692240 */, 13 },
+ /* 454 */ { MAD_F(0x06d0a94e) /* 0.425942714 */, 13 },
+ /* 455 */ { MAD_F(0x06d5c97c) /* 0.427194106 */, 13 },
+ /* 456 */ { MAD_F(0x06daeaa1) /* 0.428446415 */, 13 },
+ /* 457 */ { MAD_F(0x06e00cbb) /* 0.429699640 */, 13 },
+ /* 458 */ { MAD_F(0x06e52fca) /* 0.430953779 */, 13 },
+ /* 459 */ { MAD_F(0x06ea53cf) /* 0.432208832 */, 13 },
+ /* 460 */ { MAD_F(0x06ef78c8) /* 0.433464796 */, 13 },
+ /* 461 */ { MAD_F(0x06f49eb6) /* 0.434721671 */, 13 },
+ /* 462 */ { MAD_F(0x06f9c597) /* 0.435979455 */, 13 },
+ /* 463 */ { MAD_F(0x06feed6d) /* 0.437238146 */, 13 },
+
+ /* 464 */ { MAD_F(0x07041636) /* 0.438497744 */, 13 },
+ /* 465 */ { MAD_F(0x07093ff2) /* 0.439758248 */, 13 },
+ /* 466 */ { MAD_F(0x070e6aa0) /* 0.441019655 */, 13 },
+ /* 467 */ { MAD_F(0x07139641) /* 0.442281965 */, 13 },
+ /* 468 */ { MAD_F(0x0718c2d3) /* 0.443545176 */, 13 },
+ /* 469 */ { MAD_F(0x071df058) /* 0.444809288 */, 13 },
+ /* 470 */ { MAD_F(0x07231ecd) /* 0.446074298 */, 13 },
+ /* 471 */ { MAD_F(0x07284e34) /* 0.447340205 */, 13 },
+ /* 472 */ { MAD_F(0x072d7e8b) /* 0.448607009 */, 13 },
+ /* 473 */ { MAD_F(0x0732afd2) /* 0.449874708 */, 13 },
+ /* 474 */ { MAD_F(0x0737e209) /* 0.451143300 */, 13 },
+ /* 475 */ { MAD_F(0x073d1530) /* 0.452412785 */, 13 },
+ /* 476 */ { MAD_F(0x07424946) /* 0.453683161 */, 13 },
+ /* 477 */ { MAD_F(0x07477e4b) /* 0.454954427 */, 13 },
+ /* 478 */ { MAD_F(0x074cb43e) /* 0.456226581 */, 13 },
+ /* 479 */ { MAD_F(0x0751eb20) /* 0.457499623 */, 13 },
+
+ /* 480 */ { MAD_F(0x075722ef) /* 0.458773552 */, 13 },
+ /* 481 */ { MAD_F(0x075c5bac) /* 0.460048365 */, 13 },
+ /* 482 */ { MAD_F(0x07619557) /* 0.461324062 */, 13 },
+ /* 483 */ { MAD_F(0x0766cfee) /* 0.462600642 */, 13 },
+ /* 484 */ { MAD_F(0x076c0b72) /* 0.463878102 */, 13 },
+ /* 485 */ { MAD_F(0x077147e2) /* 0.465156443 */, 13 },
+ /* 486 */ { MAD_F(0x0776853e) /* 0.466435663 */, 13 },
+ /* 487 */ { MAD_F(0x077bc385) /* 0.467715761 */, 13 },
+ /* 488 */ { MAD_F(0x078102b8) /* 0.468996735 */, 13 },
+ /* 489 */ { MAD_F(0x078642d6) /* 0.470278584 */, 13 },
+ /* 490 */ { MAD_F(0x078b83de) /* 0.471561307 */, 13 },
+ /* 491 */ { MAD_F(0x0790c5d1) /* 0.472844904 */, 13 },
+ /* 492 */ { MAD_F(0x079608ae) /* 0.474129372 */, 13 },
+ /* 493 */ { MAD_F(0x079b4c74) /* 0.475414710 */, 13 },
+ /* 494 */ { MAD_F(0x07a09124) /* 0.476700918 */, 13 },
+ /* 495 */ { MAD_F(0x07a5d6bd) /* 0.477987994 */, 13 },
+
+ /* 496 */ { MAD_F(0x07ab1d3e) /* 0.479275937 */, 13 },
+ /* 497 */ { MAD_F(0x07b064a8) /* 0.480564746 */, 13 },
+ /* 498 */ { MAD_F(0x07b5acfb) /* 0.481854420 */, 13 },
+ /* 499 */ { MAD_F(0x07baf635) /* 0.483144957 */, 13 },
+ /* 500 */ { MAD_F(0x07c04056) /* 0.484436356 */, 13 },
+ /* 501 */ { MAD_F(0x07c58b5f) /* 0.485728617 */, 13 },
+ /* 502 */ { MAD_F(0x07cad74e) /* 0.487021738 */, 13 },
+ /* 503 */ { MAD_F(0x07d02424) /* 0.488315717 */, 13 },
+ /* 504 */ { MAD_F(0x07d571e0) /* 0.489610555 */, 13 },
+ /* 505 */ { MAD_F(0x07dac083) /* 0.490906249 */, 13 },
+ /* 506 */ { MAD_F(0x07e0100a) /* 0.492202799 */, 13 },
+ /* 507 */ { MAD_F(0x07e56078) /* 0.493500203 */, 13 },
+ /* 508 */ { MAD_F(0x07eab1ca) /* 0.494798460 */, 13 },
+ /* 509 */ { MAD_F(0x07f00401) /* 0.496097570 */, 13 },
+ /* 510 */ { MAD_F(0x07f5571d) /* 0.497397530 */, 13 },
+ /* 511 */ { MAD_F(0x07faab1c) /* 0.498698341 */, 13 },
+
+ /* 512 */ { MAD_F(0x04000000) /* 0.250000000 */, 14 },
+ /* 513 */ { MAD_F(0x0402aae3) /* 0.250651254 */, 14 },
+ /* 514 */ { MAD_F(0x04055638) /* 0.251302930 */, 14 },
+ /* 515 */ { MAD_F(0x040801ff) /* 0.251955030 */, 14 },
+ /* 516 */ { MAD_F(0x040aae37) /* 0.252607552 */, 14 },
+ /* 517 */ { MAD_F(0x040d5ae0) /* 0.253260495 */, 14 },
+ /* 518 */ { MAD_F(0x041007fa) /* 0.253913860 */, 14 },
+ /* 519 */ { MAD_F(0x0412b586) /* 0.254567645 */, 14 },
+ /* 520 */ { MAD_F(0x04156381) /* 0.255221850 */, 14 },
+ /* 521 */ { MAD_F(0x041811ee) /* 0.255876475 */, 14 },
+ /* 522 */ { MAD_F(0x041ac0cb) /* 0.256531518 */, 14 },
+ /* 523 */ { MAD_F(0x041d7018) /* 0.257186980 */, 14 },
+ /* 524 */ { MAD_F(0x04201fd5) /* 0.257842860 */, 14 },
+ /* 525 */ { MAD_F(0x0422d003) /* 0.258499157 */, 14 },
+ /* 526 */ { MAD_F(0x042580a0) /* 0.259155872 */, 14 },
+ /* 527 */ { MAD_F(0x042831ad) /* 0.259813002 */, 14 },
+
+ /* 528 */ { MAD_F(0x042ae32a) /* 0.260470548 */, 14 },
+ /* 529 */ { MAD_F(0x042d9516) /* 0.261128510 */, 14 },
+ /* 530 */ { MAD_F(0x04304772) /* 0.261786886 */, 14 },
+ /* 531 */ { MAD_F(0x0432fa3d) /* 0.262445676 */, 14 },
+ /* 532 */ { MAD_F(0x0435ad76) /* 0.263104880 */, 14 },
+ /* 533 */ { MAD_F(0x0438611f) /* 0.263764497 */, 14 },
+ /* 534 */ { MAD_F(0x043b1536) /* 0.264424527 */, 14 },
+ /* 535 */ { MAD_F(0x043dc9bc) /* 0.265084969 */, 14 },
+ /* 536 */ { MAD_F(0x04407eb1) /* 0.265745823 */, 14 },
+ /* 537 */ { MAD_F(0x04433414) /* 0.266407088 */, 14 },
+ /* 538 */ { MAD_F(0x0445e9e5) /* 0.267068763 */, 14 },
+ /* 539 */ { MAD_F(0x0448a024) /* 0.267730848 */, 14 },
+ /* 540 */ { MAD_F(0x044b56d1) /* 0.268393343 */, 14 },
+ /* 541 */ { MAD_F(0x044e0dec) /* 0.269056248 */, 14 },
+ /* 542 */ { MAD_F(0x0450c575) /* 0.269719560 */, 14 },
+ /* 543 */ { MAD_F(0x04537d6b) /* 0.270383281 */, 14 },
+
+ /* 544 */ { MAD_F(0x045635cf) /* 0.271047409 */, 14 },
+ /* 545 */ { MAD_F(0x0458ee9f) /* 0.271711944 */, 14 },
+ /* 546 */ { MAD_F(0x045ba7dd) /* 0.272376886 */, 14 },
+ /* 547 */ { MAD_F(0x045e6188) /* 0.273042234 */, 14 },
+ /* 548 */ { MAD_F(0x04611ba0) /* 0.273707988 */, 14 },
+ /* 549 */ { MAD_F(0x0463d625) /* 0.274374147 */, 14 },
+ /* 550 */ { MAD_F(0x04669116) /* 0.275040710 */, 14 },
+ /* 551 */ { MAD_F(0x04694c74) /* 0.275707677 */, 14 },
+ /* 552 */ { MAD_F(0x046c083e) /* 0.276375048 */, 14 },
+ /* 553 */ { MAD_F(0x046ec474) /* 0.277042822 */, 14 },
+ /* 554 */ { MAD_F(0x04718116) /* 0.277710999 */, 14 },
+ /* 555 */ { MAD_F(0x04743e25) /* 0.278379578 */, 14 },
+ /* 556 */ { MAD_F(0x0476fb9f) /* 0.279048558 */, 14 },
+ /* 557 */ { MAD_F(0x0479b984) /* 0.279717940 */, 14 },
+ /* 558 */ { MAD_F(0x047c77d6) /* 0.280387722 */, 14 },
+ /* 559 */ { MAD_F(0x047f3693) /* 0.281057905 */, 14 },
+
+ /* 560 */ { MAD_F(0x0481f5bb) /* 0.281728487 */, 14 },
+ /* 561 */ { MAD_F(0x0484b54e) /* 0.282399469 */, 14 },
+ /* 562 */ { MAD_F(0x0487754c) /* 0.283070849 */, 14 },
+ /* 563 */ { MAD_F(0x048a35b6) /* 0.283742628 */, 14 },
+ /* 564 */ { MAD_F(0x048cf68a) /* 0.284414805 */, 14 },
+ /* 565 */ { MAD_F(0x048fb7c8) /* 0.285087379 */, 14 },
+ /* 566 */ { MAD_F(0x04927972) /* 0.285760350 */, 14 },
+ /* 567 */ { MAD_F(0x04953b85) /* 0.286433717 */, 14 },
+ /* 568 */ { MAD_F(0x0497fe03) /* 0.287107481 */, 14 },
+ /* 569 */ { MAD_F(0x049ac0eb) /* 0.287781640 */, 14 },
+ /* 570 */ { MAD_F(0x049d843e) /* 0.288456194 */, 14 },
+ /* 571 */ { MAD_F(0x04a047fa) /* 0.289131142 */, 14 },
+ /* 572 */ { MAD_F(0x04a30c20) /* 0.289806485 */, 14 },
+ /* 573 */ { MAD_F(0x04a5d0af) /* 0.290482221 */, 14 },
+ /* 574 */ { MAD_F(0x04a895a8) /* 0.291158351 */, 14 },
+ /* 575 */ { MAD_F(0x04ab5b0b) /* 0.291834873 */, 14 },
+
+ /* 576 */ { MAD_F(0x04ae20d7) /* 0.292511788 */, 14 },
+ /* 577 */ { MAD_F(0x04b0e70c) /* 0.293189094 */, 14 },
+ /* 578 */ { MAD_F(0x04b3adaa) /* 0.293866792 */, 14 },
+ /* 579 */ { MAD_F(0x04b674b1) /* 0.294544881 */, 14 },
+ /* 580 */ { MAD_F(0x04b93c21) /* 0.295223360 */, 14 },
+ /* 581 */ { MAD_F(0x04bc03fa) /* 0.295902229 */, 14 },
+ /* 582 */ { MAD_F(0x04becc3b) /* 0.296581488 */, 14 },
+ /* 583 */ { MAD_F(0x04c194e4) /* 0.297261136 */, 14 },
+ /* 584 */ { MAD_F(0x04c45df6) /* 0.297941173 */, 14 },
+ /* 585 */ { MAD_F(0x04c72771) /* 0.298621598 */, 14 },
+ /* 586 */ { MAD_F(0x04c9f153) /* 0.299302411 */, 14 },
+ /* 587 */ { MAD_F(0x04ccbb9d) /* 0.299983611 */, 14 },
+ /* 588 */ { MAD_F(0x04cf864f) /* 0.300665198 */, 14 },
+ /* 589 */ { MAD_F(0x04d25169) /* 0.301347172 */, 14 },
+ /* 590 */ { MAD_F(0x04d51ceb) /* 0.302029532 */, 14 },
+ /* 591 */ { MAD_F(0x04d7e8d4) /* 0.302712277 */, 14 },
+
+ /* 592 */ { MAD_F(0x04dab524) /* 0.303395408 */, 14 },
+ /* 593 */ { MAD_F(0x04dd81dc) /* 0.304078923 */, 14 },
+ /* 594 */ { MAD_F(0x04e04efb) /* 0.304762823 */, 14 },
+ /* 595 */ { MAD_F(0x04e31c81) /* 0.305447106 */, 14 },
+ /* 596 */ { MAD_F(0x04e5ea6e) /* 0.306131773 */, 14 },
+ /* 597 */ { MAD_F(0x04e8b8c2) /* 0.306816823 */, 14 },
+ /* 598 */ { MAD_F(0x04eb877c) /* 0.307502256 */, 14 },
+ /* 599 */ { MAD_F(0x04ee569d) /* 0.308188071 */, 14 },
+ /* 600 */ { MAD_F(0x04f12624) /* 0.308874267 */, 14 },
+ /* 601 */ { MAD_F(0x04f3f612) /* 0.309560845 */, 14 },
+ /* 602 */ { MAD_F(0x04f6c666) /* 0.310247804 */, 14 },
+ /* 603 */ { MAD_F(0x04f99721) /* 0.310935143 */, 14 },
+ /* 604 */ { MAD_F(0x04fc6841) /* 0.311622862 */, 14 },
+ /* 605 */ { MAD_F(0x04ff39c7) /* 0.312310961 */, 14 },
+ /* 606 */ { MAD_F(0x05020bb3) /* 0.312999439 */, 14 },
+ /* 607 */ { MAD_F(0x0504de05) /* 0.313688296 */, 14 },
+
+ /* 608 */ { MAD_F(0x0507b0bc) /* 0.314377532 */, 14 },
+ /* 609 */ { MAD_F(0x050a83d8) /* 0.315067145 */, 14 },
+ /* 610 */ { MAD_F(0x050d575b) /* 0.315757136 */, 14 },
+ /* 611 */ { MAD_F(0x05102b42) /* 0.316447504 */, 14 },
+ /* 612 */ { MAD_F(0x0512ff8e) /* 0.317138249 */, 14 },
+ /* 613 */ { MAD_F(0x0515d440) /* 0.317829370 */, 14 },
+ /* 614 */ { MAD_F(0x0518a956) /* 0.318520867 */, 14 },
+ /* 615 */ { MAD_F(0x051b7ed1) /* 0.319212739 */, 14 },
+ /* 616 */ { MAD_F(0x051e54b1) /* 0.319904987 */, 14 },
+ /* 617 */ { MAD_F(0x05212af5) /* 0.320597609 */, 14 },
+ /* 618 */ { MAD_F(0x0524019e) /* 0.321290606 */, 14 },
+ /* 619 */ { MAD_F(0x0526d8ab) /* 0.321983976 */, 14 },
+ /* 620 */ { MAD_F(0x0529b01d) /* 0.322677720 */, 14 },
+ /* 621 */ { MAD_F(0x052c87f2) /* 0.323371837 */, 14 },
+ /* 622 */ { MAD_F(0x052f602c) /* 0.324066327 */, 14 },
+ /* 623 */ { MAD_F(0x053238ca) /* 0.324761189 */, 14 },
+
+ /* 624 */ { MAD_F(0x053511cb) /* 0.325456423 */, 14 },
+ /* 625 */ { MAD_F(0x0537eb30) /* 0.326152028 */, 14 },
+ /* 626 */ { MAD_F(0x053ac4f9) /* 0.326848005 */, 14 },
+ /* 627 */ { MAD_F(0x053d9f25) /* 0.327544352 */, 14 },
+ /* 628 */ { MAD_F(0x054079b5) /* 0.328241070 */, 14 },
+ /* 629 */ { MAD_F(0x054354a8) /* 0.328938157 */, 14 },
+ /* 630 */ { MAD_F(0x05462ffe) /* 0.329635614 */, 14 },
+ /* 631 */ { MAD_F(0x05490bb7) /* 0.330333440 */, 14 },
+ /* 632 */ { MAD_F(0x054be7d4) /* 0.331031635 */, 14 },
+ /* 633 */ { MAD_F(0x054ec453) /* 0.331730198 */, 14 },
+ /* 634 */ { MAD_F(0x0551a134) /* 0.332429129 */, 14 },
+ /* 635 */ { MAD_F(0x05547e79) /* 0.333128427 */, 14 },
+ /* 636 */ { MAD_F(0x05575c20) /* 0.333828093 */, 14 },
+ /* 637 */ { MAD_F(0x055a3a2a) /* 0.334528126 */, 14 },
+ /* 638 */ { MAD_F(0x055d1896) /* 0.335228525 */, 14 },
+ /* 639 */ { MAD_F(0x055ff764) /* 0.335929290 */, 14 },
+
+ /* 640 */ { MAD_F(0x0562d694) /* 0.336630420 */, 14 },
+ /* 641 */ { MAD_F(0x0565b627) /* 0.337331916 */, 14 },
+ /* 642 */ { MAD_F(0x0568961b) /* 0.338033777 */, 14 },
+ /* 643 */ { MAD_F(0x056b7671) /* 0.338736002 */, 14 },
+ /* 644 */ { MAD_F(0x056e5729) /* 0.339438592 */, 14 },
+ /* 645 */ { MAD_F(0x05713843) /* 0.340141545 */, 14 },
+ /* 646 */ { MAD_F(0x057419be) /* 0.340844862 */, 14 },
+ /* 647 */ { MAD_F(0x0576fb9a) /* 0.341548541 */, 14 },
+ /* 648 */ { MAD_F(0x0579ddd8) /* 0.342252584 */, 14 },
+ /* 649 */ { MAD_F(0x057cc077) /* 0.342956988 */, 14 },
+ /* 650 */ { MAD_F(0x057fa378) /* 0.343661754 */, 14 },
+ /* 651 */ { MAD_F(0x058286d9) /* 0.344366882 */, 14 },
+ /* 652 */ { MAD_F(0x05856a9b) /* 0.345072371 */, 14 },
+ /* 653 */ { MAD_F(0x05884ebe) /* 0.345778221 */, 14 },
+ /* 654 */ { MAD_F(0x058b3342) /* 0.346484431 */, 14 },
+ /* 655 */ { MAD_F(0x058e1827) /* 0.347191002 */, 14 },
+
+ /* 656 */ { MAD_F(0x0590fd6c) /* 0.347897931 */, 14 },
+ /* 657 */ { MAD_F(0x0593e311) /* 0.348605221 */, 14 },
+ /* 658 */ { MAD_F(0x0596c917) /* 0.349312869 */, 14 },
+ /* 659 */ { MAD_F(0x0599af7d) /* 0.350020876 */, 14 },
+ /* 660 */ { MAD_F(0x059c9643) /* 0.350729240 */, 14 },
+ /* 661 */ { MAD_F(0x059f7d6a) /* 0.351437963 */, 14 },
+ /* 662 */ { MAD_F(0x05a264f0) /* 0.352147044 */, 14 },
+ /* 663 */ { MAD_F(0x05a54cd6) /* 0.352856481 */, 14 },
+ /* 664 */ { MAD_F(0x05a8351c) /* 0.353566275 */, 14 },
+ /* 665 */ { MAD_F(0x05ab1dc2) /* 0.354276426 */, 14 },
+ /* 666 */ { MAD_F(0x05ae06c7) /* 0.354986932 */, 14 },
+ /* 667 */ { MAD_F(0x05b0f02b) /* 0.355697795 */, 14 },
+ /* 668 */ { MAD_F(0x05b3d9f0) /* 0.356409012 */, 14 },
+ /* 669 */ { MAD_F(0x05b6c413) /* 0.357120585 */, 14 },
+ /* 670 */ { MAD_F(0x05b9ae95) /* 0.357832512 */, 14 },
+ /* 671 */ { MAD_F(0x05bc9977) /* 0.358544794 */, 14 },
+
+ /* 672 */ { MAD_F(0x05bf84b8) /* 0.359257429 */, 14 },
+ /* 673 */ { MAD_F(0x05c27057) /* 0.359970419 */, 14 },
+ /* 674 */ { MAD_F(0x05c55c56) /* 0.360683761 */, 14 },
+ /* 675 */ { MAD_F(0x05c848b3) /* 0.361397456 */, 14 },
+ /* 676 */ { MAD_F(0x05cb356e) /* 0.362111504 */, 14 },
+ /* 677 */ { MAD_F(0x05ce2289) /* 0.362825904 */, 14 },
+ /* 678 */ { MAD_F(0x05d11001) /* 0.363540655 */, 14 },
+ /* 679 */ { MAD_F(0x05d3fdd8) /* 0.364255759 */, 14 },
+ /* 680 */ { MAD_F(0x05d6ec0e) /* 0.364971213 */, 14 },
+ /* 681 */ { MAD_F(0x05d9daa1) /* 0.365687018 */, 14 },
+ /* 682 */ { MAD_F(0x05dcc993) /* 0.366403174 */, 14 },
+ /* 683 */ { MAD_F(0x05dfb8e2) /* 0.367119680 */, 14 },
+ /* 684 */ { MAD_F(0x05e2a890) /* 0.367836535 */, 14 },
+ /* 685 */ { MAD_F(0x05e5989b) /* 0.368553740 */, 14 },
+ /* 686 */ { MAD_F(0x05e88904) /* 0.369271294 */, 14 },
+ /* 687 */ { MAD_F(0x05eb79cb) /* 0.369989197 */, 14 },
+
+ /* 688 */ { MAD_F(0x05ee6aef) /* 0.370707448 */, 14 },
+ /* 689 */ { MAD_F(0x05f15c70) /* 0.371426047 */, 14 },
+ /* 690 */ { MAD_F(0x05f44e4f) /* 0.372144994 */, 14 },
+ /* 691 */ { MAD_F(0x05f7408b) /* 0.372864289 */, 14 },
+ /* 692 */ { MAD_F(0x05fa3324) /* 0.373583930 */, 14 },
+ /* 693 */ { MAD_F(0x05fd261b) /* 0.374303918 */, 14 },
+ /* 694 */ { MAD_F(0x0600196e) /* 0.375024253 */, 14 },
+ /* 695 */ { MAD_F(0x06030d1e) /* 0.375744934 */, 14 },
+ /* 696 */ { MAD_F(0x0606012b) /* 0.376465960 */, 14 },
+ /* 697 */ { MAD_F(0x0608f595) /* 0.377187332 */, 14 },
+ /* 698 */ { MAD_F(0x060bea5c) /* 0.377909049 */, 14 },
+ /* 699 */ { MAD_F(0x060edf7f) /* 0.378631110 */, 14 },
+ /* 700 */ { MAD_F(0x0611d4fe) /* 0.379353516 */, 14 },
+ /* 701 */ { MAD_F(0x0614cada) /* 0.380076266 */, 14 },
+ /* 702 */ { MAD_F(0x0617c112) /* 0.380799360 */, 14 },
+ /* 703 */ { MAD_F(0x061ab7a6) /* 0.381522798 */, 14 },
+
+ /* 704 */ { MAD_F(0x061dae96) /* 0.382246578 */, 14 },
+ /* 705 */ { MAD_F(0x0620a5e3) /* 0.382970701 */, 14 },
+ /* 706 */ { MAD_F(0x06239d8b) /* 0.383695167 */, 14 },
+ /* 707 */ { MAD_F(0x0626958f) /* 0.384419975 */, 14 },
+ /* 708 */ { MAD_F(0x06298def) /* 0.385145124 */, 14 },
+ /* 709 */ { MAD_F(0x062c86aa) /* 0.385870615 */, 14 },
+ /* 710 */ { MAD_F(0x062f7fc1) /* 0.386596448 */, 14 },
+ /* 711 */ { MAD_F(0x06327934) /* 0.387322621 */, 14 },
+ /* 712 */ { MAD_F(0x06357302) /* 0.388049134 */, 14 },
+ /* 713 */ { MAD_F(0x06386d2b) /* 0.388775988 */, 14 },
+ /* 714 */ { MAD_F(0x063b67b0) /* 0.389503182 */, 14 },
+ /* 715 */ { MAD_F(0x063e6290) /* 0.390230715 */, 14 },
+ /* 716 */ { MAD_F(0x06415dcb) /* 0.390958588 */, 14 },
+ /* 717 */ { MAD_F(0x06445960) /* 0.391686799 */, 14 },
+ /* 718 */ { MAD_F(0x06475551) /* 0.392415349 */, 14 },
+ /* 719 */ { MAD_F(0x064a519c) /* 0.393144238 */, 14 },
+
+ /* 720 */ { MAD_F(0x064d4e43) /* 0.393873464 */, 14 },
+ /* 721 */ { MAD_F(0x06504b44) /* 0.394603028 */, 14 },
+ /* 722 */ { MAD_F(0x0653489f) /* 0.395332930 */, 14 },
+ /* 723 */ { MAD_F(0x06564655) /* 0.396063168 */, 14 },
+ /* 724 */ { MAD_F(0x06594465) /* 0.396793743 */, 14 },
+ /* 725 */ { MAD_F(0x065c42d0) /* 0.397524655 */, 14 },
+ /* 726 */ { MAD_F(0x065f4195) /* 0.398255903 */, 14 },
+ /* 727 */ { MAD_F(0x066240b4) /* 0.398987487 */, 14 },
+ /* 728 */ { MAD_F(0x0665402d) /* 0.399719406 */, 14 },
+ /* 729 */ { MAD_F(0x06684000) /* 0.400451660 */, 14 },
+ /* 730 */ { MAD_F(0x066b402d) /* 0.401184249 */, 14 },
+ /* 731 */ { MAD_F(0x066e40b3) /* 0.401917173 */, 14 },
+ /* 732 */ { MAD_F(0x06714194) /* 0.402650431 */, 14 },
+ /* 733 */ { MAD_F(0x067442ce) /* 0.403384024 */, 14 },
+ /* 734 */ { MAD_F(0x06774462) /* 0.404117949 */, 14 },
+ /* 735 */ { MAD_F(0x067a464f) /* 0.404852209 */, 14 },
+
+ /* 736 */ { MAD_F(0x067d4896) /* 0.405586801 */, 14 },
+ /* 737 */ { MAD_F(0x06804b36) /* 0.406321726 */, 14 },
+ /* 738 */ { MAD_F(0x06834e2f) /* 0.407056983 */, 14 },
+ /* 739 */ { MAD_F(0x06865181) /* 0.407792573 */, 14 },
+ /* 740 */ { MAD_F(0x0689552c) /* 0.408528495 */, 14 },
+ /* 741 */ { MAD_F(0x068c5931) /* 0.409264748 */, 14 },
+ /* 742 */ { MAD_F(0x068f5d8e) /* 0.410001332 */, 14 },
+ /* 743 */ { MAD_F(0x06926245) /* 0.410738247 */, 14 },
+ /* 744 */ { MAD_F(0x06956753) /* 0.411475493 */, 14 },
+ /* 745 */ { MAD_F(0x06986cbb) /* 0.412213070 */, 14 },
+ /* 746 */ { MAD_F(0x069b727b) /* 0.412950976 */, 14 },
+ /* 747 */ { MAD_F(0x069e7894) /* 0.413689213 */, 14 },
+ /* 748 */ { MAD_F(0x06a17f05) /* 0.414427779 */, 14 },
+ /* 749 */ { MAD_F(0x06a485cf) /* 0.415166674 */, 14 },
+ /* 750 */ { MAD_F(0x06a78cf1) /* 0.415905897 */, 14 },
+ /* 751 */ { MAD_F(0x06aa946b) /* 0.416645450 */, 14 },
+
+ /* 752 */ { MAD_F(0x06ad9c3d) /* 0.417385331 */, 14 },
+ /* 753 */ { MAD_F(0x06b0a468) /* 0.418125540 */, 14 },
+ /* 754 */ { MAD_F(0x06b3acea) /* 0.418866076 */, 14 },
+ /* 755 */ { MAD_F(0x06b6b5c4) /* 0.419606940 */, 14 },
+ /* 756 */ { MAD_F(0x06b9bef6) /* 0.420348132 */, 14 },
+ /* 757 */ { MAD_F(0x06bcc880) /* 0.421089650 */, 14 },
+ /* 758 */ { MAD_F(0x06bfd261) /* 0.421831494 */, 14 },
+ /* 759 */ { MAD_F(0x06c2dc9a) /* 0.422573665 */, 14 },
+ /* 760 */ { MAD_F(0x06c5e72b) /* 0.423316162 */, 14 },
+ /* 761 */ { MAD_F(0x06c8f213) /* 0.424058985 */, 14 },
+ /* 762 */ { MAD_F(0x06cbfd52) /* 0.424802133 */, 14 },
+ /* 763 */ { MAD_F(0x06cf08e9) /* 0.425545607 */, 14 },
+ /* 764 */ { MAD_F(0x06d214d7) /* 0.426289405 */, 14 },
+ /* 765 */ { MAD_F(0x06d5211c) /* 0.427033528 */, 14 },
+ /* 766 */ { MAD_F(0x06d82db8) /* 0.427777975 */, 14 },
+ /* 767 */ { MAD_F(0x06db3aaa) /* 0.428522746 */, 14 },
+
+ /* 768 */ { MAD_F(0x06de47f4) /* 0.429267841 */, 14 },
+ /* 769 */ { MAD_F(0x06e15595) /* 0.430013259 */, 14 },
+ /* 770 */ { MAD_F(0x06e4638d) /* 0.430759001 */, 14 },
+ /* 771 */ { MAD_F(0x06e771db) /* 0.431505065 */, 14 },
+ /* 772 */ { MAD_F(0x06ea807f) /* 0.432251452 */, 14 },
+ /* 773 */ { MAD_F(0x06ed8f7b) /* 0.432998162 */, 14 },
+ /* 774 */ { MAD_F(0x06f09ecc) /* 0.433745193 */, 14 },
+ /* 775 */ { MAD_F(0x06f3ae75) /* 0.434492546 */, 14 },
+ /* 776 */ { MAD_F(0x06f6be73) /* 0.435240221 */, 14 },
+ /* 777 */ { MAD_F(0x06f9cec8) /* 0.435988217 */, 14 },
+ /* 778 */ { MAD_F(0x06fcdf72) /* 0.436736534 */, 14 },
+ /* 779 */ { MAD_F(0x06fff073) /* 0.437485172 */, 14 },
+ /* 780 */ { MAD_F(0x070301ca) /* 0.438234130 */, 14 },
+ /* 781 */ { MAD_F(0x07061377) /* 0.438983408 */, 14 },
+ /* 782 */ { MAD_F(0x0709257a) /* 0.439733006 */, 14 },
+ /* 783 */ { MAD_F(0x070c37d2) /* 0.440482924 */, 14 },
+
+ /* 784 */ { MAD_F(0x070f4a80) /* 0.441233161 */, 14 },
+ /* 785 */ { MAD_F(0x07125d84) /* 0.441983717 */, 14 },
+ /* 786 */ { MAD_F(0x071570de) /* 0.442734592 */, 14 },
+ /* 787 */ { MAD_F(0x0718848d) /* 0.443485785 */, 14 },
+ /* 788 */ { MAD_F(0x071b9891) /* 0.444237296 */, 14 },
+ /* 789 */ { MAD_F(0x071eaceb) /* 0.444989126 */, 14 },
+ /* 790 */ { MAD_F(0x0721c19a) /* 0.445741273 */, 14 },
+ /* 791 */ { MAD_F(0x0724d69e) /* 0.446493738 */, 14 },
+ /* 792 */ { MAD_F(0x0727ebf7) /* 0.447246519 */, 14 },
+ /* 793 */ { MAD_F(0x072b01a6) /* 0.447999618 */, 14 },
+ /* 794 */ { MAD_F(0x072e17a9) /* 0.448753033 */, 14 },
+ /* 795 */ { MAD_F(0x07312e01) /* 0.449506765 */, 14 },
+ /* 796 */ { MAD_F(0x073444ae) /* 0.450260813 */, 14 },
+ /* 797 */ { MAD_F(0x07375bb0) /* 0.451015176 */, 14 },
+ /* 798 */ { MAD_F(0x073a7307) /* 0.451769856 */, 14 },
+ /* 799 */ { MAD_F(0x073d8ab2) /* 0.452524850 */, 14 },
+
+ /* 800 */ { MAD_F(0x0740a2b2) /* 0.453280160 */, 14 },
+ /* 801 */ { MAD_F(0x0743bb06) /* 0.454035784 */, 14 },
+ /* 802 */ { MAD_F(0x0746d3af) /* 0.454791723 */, 14 },
+ /* 803 */ { MAD_F(0x0749ecac) /* 0.455547976 */, 14 },
+ /* 804 */ { MAD_F(0x074d05fe) /* 0.456304543 */, 14 },
+ /* 805 */ { MAD_F(0x07501fa3) /* 0.457061423 */, 14 },
+ /* 806 */ { MAD_F(0x0753399d) /* 0.457818618 */, 14 },
+ /* 807 */ { MAD_F(0x075653eb) /* 0.458576125 */, 14 },
+ /* 808 */ { MAD_F(0x07596e8d) /* 0.459333946 */, 14 },
+ /* 809 */ { MAD_F(0x075c8983) /* 0.460092079 */, 14 },
+ /* 810 */ { MAD_F(0x075fa4cc) /* 0.460850524 */, 14 },
+ /* 811 */ { MAD_F(0x0762c06a) /* 0.461609282 */, 14 },
+ /* 812 */ { MAD_F(0x0765dc5b) /* 0.462368352 */, 14 },
+ /* 813 */ { MAD_F(0x0768f8a0) /* 0.463127733 */, 14 },
+ /* 814 */ { MAD_F(0x076c1538) /* 0.463887426 */, 14 },
+ /* 815 */ { MAD_F(0x076f3224) /* 0.464647430 */, 14 },
+
+ /* 816 */ { MAD_F(0x07724f64) /* 0.465407744 */, 14 },
+ /* 817 */ { MAD_F(0x07756cf7) /* 0.466168370 */, 14 },
+ /* 818 */ { MAD_F(0x07788add) /* 0.466929306 */, 14 },
+ /* 819 */ { MAD_F(0x077ba916) /* 0.467690552 */, 14 },
+ /* 820 */ { MAD_F(0x077ec7a3) /* 0.468452108 */, 14 },
+ /* 821 */ { MAD_F(0x0781e683) /* 0.469213973 */, 14 },
+ /* 822 */ { MAD_F(0x078505b5) /* 0.469976148 */, 14 },
+ /* 823 */ { MAD_F(0x0788253b) /* 0.470738632 */, 14 },
+ /* 824 */ { MAD_F(0x078b4514) /* 0.471501425 */, 14 },
+ /* 825 */ { MAD_F(0x078e653f) /* 0.472264527 */, 14 },
+ /* 826 */ { MAD_F(0x079185be) /* 0.473027937 */, 14 },
+ /* 827 */ { MAD_F(0x0794a68f) /* 0.473791655 */, 14 },
+ /* 828 */ { MAD_F(0x0797c7b2) /* 0.474555681 */, 14 },
+ /* 829 */ { MAD_F(0x079ae929) /* 0.475320014 */, 14 },
+ /* 830 */ { MAD_F(0x079e0af1) /* 0.476084655 */, 14 },
+ /* 831 */ { MAD_F(0x07a12d0c) /* 0.476849603 */, 14 },
+
+ /* 832 */ { MAD_F(0x07a44f7a) /* 0.477614858 */, 14 },
+ /* 833 */ { MAD_F(0x07a7723a) /* 0.478380420 */, 14 },
+ /* 834 */ { MAD_F(0x07aa954c) /* 0.479146288 */, 14 },
+ /* 835 */ { MAD_F(0x07adb8b0) /* 0.479912463 */, 14 },
+ /* 836 */ { MAD_F(0x07b0dc67) /* 0.480678943 */, 14 },
+ /* 837 */ { MAD_F(0x07b4006f) /* 0.481445729 */, 14 },
+ /* 838 */ { MAD_F(0x07b724ca) /* 0.482212820 */, 14 },
+ /* 839 */ { MAD_F(0x07ba4976) /* 0.482980216 */, 14 },
+ /* 840 */ { MAD_F(0x07bd6e75) /* 0.483747918 */, 14 },
+ /* 841 */ { MAD_F(0x07c093c5) /* 0.484515924 */, 14 },
+ /* 842 */ { MAD_F(0x07c3b967) /* 0.485284235 */, 14 },
+ /* 843 */ { MAD_F(0x07c6df5a) /* 0.486052849 */, 14 },
+ /* 844 */ { MAD_F(0x07ca059f) /* 0.486821768 */, 14 },
+ /* 845 */ { MAD_F(0x07cd2c36) /* 0.487590991 */, 14 },
+ /* 846 */ { MAD_F(0x07d0531e) /* 0.488360517 */, 14 },
+ /* 847 */ { MAD_F(0x07d37a57) /* 0.489130346 */, 14 },
+
+ /* 848 */ { MAD_F(0x07d6a1e2) /* 0.489900479 */, 14 },
+ /* 849 */ { MAD_F(0x07d9c9be) /* 0.490670914 */, 14 },
+ /* 850 */ { MAD_F(0x07dcf1ec) /* 0.491441651 */, 14 },
+ /* 851 */ { MAD_F(0x07e01a6a) /* 0.492212691 */, 14 },
+ /* 852 */ { MAD_F(0x07e3433a) /* 0.492984033 */, 14 },
+ /* 853 */ { MAD_F(0x07e66c5a) /* 0.493755677 */, 14 },
+ /* 854 */ { MAD_F(0x07e995cc) /* 0.494527623 */, 14 },
+ /* 855 */ { MAD_F(0x07ecbf8e) /* 0.495299870 */, 14 },
+ /* 856 */ { MAD_F(0x07efe9a1) /* 0.496072418 */, 14 },
+ /* 857 */ { MAD_F(0x07f31405) /* 0.496845266 */, 14 },
+ /* 858 */ { MAD_F(0x07f63eba) /* 0.497618416 */, 14 },
+ /* 859 */ { MAD_F(0x07f969c0) /* 0.498391866 */, 14 },
+ /* 860 */ { MAD_F(0x07fc9516) /* 0.499165616 */, 14 },
+ /* 861 */ { MAD_F(0x07ffc0bc) /* 0.499939666 */, 14 },
+ /* 862 */ { MAD_F(0x04017659) /* 0.250357008 */, 15 },
+ /* 863 */ { MAD_F(0x04030c7d) /* 0.250744333 */, 15 },
+
+ /* 864 */ { MAD_F(0x0404a2c9) /* 0.251131807 */, 15 },
+ /* 865 */ { MAD_F(0x0406393d) /* 0.251519431 */, 15 },
+ /* 866 */ { MAD_F(0x0407cfd9) /* 0.251907204 */, 15 },
+ /* 867 */ { MAD_F(0x0409669d) /* 0.252295127 */, 15 },
+ /* 868 */ { MAD_F(0x040afd89) /* 0.252683198 */, 15 },
+ /* 869 */ { MAD_F(0x040c949e) /* 0.253071419 */, 15 },
+ /* 870 */ { MAD_F(0x040e2bda) /* 0.253459789 */, 15 },
+ /* 871 */ { MAD_F(0x040fc33e) /* 0.253848307 */, 15 },
+ /* 872 */ { MAD_F(0x04115aca) /* 0.254236974 */, 15 },
+ /* 873 */ { MAD_F(0x0412f27e) /* 0.254625790 */, 15 },
+ /* 874 */ { MAD_F(0x04148a5a) /* 0.255014755 */, 15 },
+ /* 875 */ { MAD_F(0x0416225d) /* 0.255403867 */, 15 },
+ /* 876 */ { MAD_F(0x0417ba89) /* 0.255793128 */, 15 },
+ /* 877 */ { MAD_F(0x041952dc) /* 0.256182537 */, 15 },
+ /* 878 */ { MAD_F(0x041aeb57) /* 0.256572095 */, 15 },
+ /* 879 */ { MAD_F(0x041c83fa) /* 0.256961800 */, 15 },
+
+ /* 880 */ { MAD_F(0x041e1cc4) /* 0.257351652 */, 15 },
+ /* 881 */ { MAD_F(0x041fb5b6) /* 0.257741653 */, 15 },
+ /* 882 */ { MAD_F(0x04214ed0) /* 0.258131801 */, 15 },
+ /* 883 */ { MAD_F(0x0422e811) /* 0.258522097 */, 15 },
+ /* 884 */ { MAD_F(0x04248179) /* 0.258912540 */, 15 },
+ /* 885 */ { MAD_F(0x04261b0a) /* 0.259303130 */, 15 },
+ /* 886 */ { MAD_F(0x0427b4c2) /* 0.259693868 */, 15 },
+ /* 887 */ { MAD_F(0x04294ea1) /* 0.260084752 */, 15 },
+ /* 888 */ { MAD_F(0x042ae8a7) /* 0.260475783 */, 15 },
+ /* 889 */ { MAD_F(0x042c82d6) /* 0.260866961 */, 15 },
+ /* 890 */ { MAD_F(0x042e1d2b) /* 0.261258286 */, 15 },
+ /* 891 */ { MAD_F(0x042fb7a8) /* 0.261649758 */, 15 },
+ /* 892 */ { MAD_F(0x0431524c) /* 0.262041376 */, 15 },
+ /* 893 */ { MAD_F(0x0432ed17) /* 0.262433140 */, 15 },
+ /* 894 */ { MAD_F(0x0434880a) /* 0.262825051 */, 15 },
+ /* 895 */ { MAD_F(0x04362324) /* 0.263217107 */, 15 },
+
+ /* 896 */ { MAD_F(0x0437be65) /* 0.263609310 */, 15 },
+ /* 897 */ { MAD_F(0x043959cd) /* 0.264001659 */, 15 },
+ /* 898 */ { MAD_F(0x043af55d) /* 0.264394153 */, 15 },
+ /* 899 */ { MAD_F(0x043c9113) /* 0.264786794 */, 15 },
+ /* 900 */ { MAD_F(0x043e2cf1) /* 0.265179580 */, 15 },
+ /* 901 */ { MAD_F(0x043fc8f6) /* 0.265572511 */, 15 },
+ /* 902 */ { MAD_F(0x04416522) /* 0.265965588 */, 15 },
+ /* 903 */ { MAD_F(0x04430174) /* 0.266358810 */, 15 },
+ /* 904 */ { MAD_F(0x04449dee) /* 0.266752177 */, 15 },
+ /* 905 */ { MAD_F(0x04463a8f) /* 0.267145689 */, 15 },
+ /* 906 */ { MAD_F(0x0447d756) /* 0.267539347 */, 15 },
+ /* 907 */ { MAD_F(0x04497445) /* 0.267933149 */, 15 },
+ /* 908 */ { MAD_F(0x044b115a) /* 0.268327096 */, 15 },
+ /* 909 */ { MAD_F(0x044cae96) /* 0.268721187 */, 15 },
+ /* 910 */ { MAD_F(0x044e4bf9) /* 0.269115423 */, 15 },
+ /* 911 */ { MAD_F(0x044fe983) /* 0.269509804 */, 15 },
+
+ /* 912 */ { MAD_F(0x04518733) /* 0.269904329 */, 15 },
+ /* 913 */ { MAD_F(0x0453250a) /* 0.270298998 */, 15 },
+ /* 914 */ { MAD_F(0x0454c308) /* 0.270693811 */, 15 },
+ /* 915 */ { MAD_F(0x0456612d) /* 0.271088768 */, 15 },
+ /* 916 */ { MAD_F(0x0457ff78) /* 0.271483869 */, 15 },
+ /* 917 */ { MAD_F(0x04599dea) /* 0.271879114 */, 15 },
+ /* 918 */ { MAD_F(0x045b3c82) /* 0.272274503 */, 15 },
+ /* 919 */ { MAD_F(0x045cdb41) /* 0.272670035 */, 15 },
+ /* 920 */ { MAD_F(0x045e7a26) /* 0.273065710 */, 15 },
+ /* 921 */ { MAD_F(0x04601932) /* 0.273461530 */, 15 },
+ /* 922 */ { MAD_F(0x0461b864) /* 0.273857492 */, 15 },
+ /* 923 */ { MAD_F(0x046357bd) /* 0.274253597 */, 15 },
+ /* 924 */ { MAD_F(0x0464f73c) /* 0.274649846 */, 15 },
+ /* 925 */ { MAD_F(0x046696e2) /* 0.275046238 */, 15 },
+ /* 926 */ { MAD_F(0x046836ae) /* 0.275442772 */, 15 },
+ /* 927 */ { MAD_F(0x0469d6a0) /* 0.275839449 */, 15 },
+
+ /* 928 */ { MAD_F(0x046b76b9) /* 0.276236269 */, 15 },
+ /* 929 */ { MAD_F(0x046d16f7) /* 0.276633232 */, 15 },
+ /* 930 */ { MAD_F(0x046eb75c) /* 0.277030337 */, 15 },
+ /* 931 */ { MAD_F(0x047057e8) /* 0.277427584 */, 15 },
+ /* 932 */ { MAD_F(0x0471f899) /* 0.277824973 */, 15 },
+ /* 933 */ { MAD_F(0x04739971) /* 0.278222505 */, 15 },
+ /* 934 */ { MAD_F(0x04753a6f) /* 0.278620179 */, 15 },
+ /* 935 */ { MAD_F(0x0476db92) /* 0.279017995 */, 15 },
+ /* 936 */ { MAD_F(0x04787cdc) /* 0.279415952 */, 15 },
+ /* 937 */ { MAD_F(0x047a1e4c) /* 0.279814051 */, 15 },
+ /* 938 */ { MAD_F(0x047bbfe2) /* 0.280212292 */, 15 },
+ /* 939 */ { MAD_F(0x047d619e) /* 0.280610675 */, 15 },
+ /* 940 */ { MAD_F(0x047f0380) /* 0.281009199 */, 15 },
+ /* 941 */ { MAD_F(0x0480a588) /* 0.281407864 */, 15 },
+ /* 942 */ { MAD_F(0x048247b6) /* 0.281806670 */, 15 },
+ /* 943 */ { MAD_F(0x0483ea0a) /* 0.282205618 */, 15 },
+
+ /* 944 */ { MAD_F(0x04858c83) /* 0.282604707 */, 15 },
+ /* 945 */ { MAD_F(0x04872f22) /* 0.283003936 */, 15 },
+ /* 946 */ { MAD_F(0x0488d1e8) /* 0.283403307 */, 15 },
+ /* 947 */ { MAD_F(0x048a74d3) /* 0.283802818 */, 15 },
+ /* 948 */ { MAD_F(0x048c17e3) /* 0.284202470 */, 15 },
+ /* 949 */ { MAD_F(0x048dbb1a) /* 0.284602263 */, 15 },
+ /* 950 */ { MAD_F(0x048f5e76) /* 0.285002195 */, 15 },
+ /* 951 */ { MAD_F(0x049101f8) /* 0.285402269 */, 15 },
+ /* 952 */ { MAD_F(0x0492a59f) /* 0.285802482 */, 15 },
+ /* 953 */ { MAD_F(0x0494496c) /* 0.286202836 */, 15 },
+ /* 954 */ { MAD_F(0x0495ed5f) /* 0.286603329 */, 15 },
+ /* 955 */ { MAD_F(0x04979177) /* 0.287003963 */, 15 },
+ /* 956 */ { MAD_F(0x049935b5) /* 0.287404737 */, 15 },
+ /* 957 */ { MAD_F(0x049ada19) /* 0.287805650 */, 15 },
+ /* 958 */ { MAD_F(0x049c7ea1) /* 0.288206703 */, 15 },
+ /* 959 */ { MAD_F(0x049e2350) /* 0.288607895 */, 15 },
+
+ /* 960 */ { MAD_F(0x049fc824) /* 0.289009227 */, 15 },
+ /* 961 */ { MAD_F(0x04a16d1d) /* 0.289410699 */, 15 },
+ /* 962 */ { MAD_F(0x04a3123b) /* 0.289812309 */, 15 },
+ /* 963 */ { MAD_F(0x04a4b77f) /* 0.290214059 */, 15 },
+ /* 964 */ { MAD_F(0x04a65ce8) /* 0.290615948 */, 15 },
+ /* 965 */ { MAD_F(0x04a80277) /* 0.291017976 */, 15 },
+ /* 966 */ { MAD_F(0x04a9a82b) /* 0.291420143 */, 15 },
+ /* 967 */ { MAD_F(0x04ab4e04) /* 0.291822449 */, 15 },
+ /* 968 */ { MAD_F(0x04acf402) /* 0.292224893 */, 15 },
+ /* 969 */ { MAD_F(0x04ae9a26) /* 0.292627476 */, 15 },
+ /* 970 */ { MAD_F(0x04b0406e) /* 0.293030197 */, 15 },
+ /* 971 */ { MAD_F(0x04b1e6dc) /* 0.293433057 */, 15 },
+ /* 972 */ { MAD_F(0x04b38d6f) /* 0.293836055 */, 15 },
+ /* 973 */ { MAD_F(0x04b53427) /* 0.294239192 */, 15 },
+ /* 974 */ { MAD_F(0x04b6db05) /* 0.294642466 */, 15 },
+ /* 975 */ { MAD_F(0x04b88207) /* 0.295045879 */, 15 },
+
+ /* 976 */ { MAD_F(0x04ba292e) /* 0.295449429 */, 15 },
+ /* 977 */ { MAD_F(0x04bbd07a) /* 0.295853118 */, 15 },
+ /* 978 */ { MAD_F(0x04bd77ec) /* 0.296256944 */, 15 },
+ /* 979 */ { MAD_F(0x04bf1f82) /* 0.296660907 */, 15 },
+ /* 980 */ { MAD_F(0x04c0c73d) /* 0.297065009 */, 15 },
+ /* 981 */ { MAD_F(0x04c26f1d) /* 0.297469248 */, 15 },
+ /* 982 */ { MAD_F(0x04c41722) /* 0.297873624 */, 15 },
+ /* 983 */ { MAD_F(0x04c5bf4c) /* 0.298278137 */, 15 },
+ /* 984 */ { MAD_F(0x04c7679a) /* 0.298682788 */, 15 },
+ /* 985 */ { MAD_F(0x04c9100d) /* 0.299087576 */, 15 },
+ /* 986 */ { MAD_F(0x04cab8a6) /* 0.299492500 */, 15 },
+ /* 987 */ { MAD_F(0x04cc6163) /* 0.299897562 */, 15 },
+ /* 988 */ { MAD_F(0x04ce0a44) /* 0.300302761 */, 15 },
+ /* 989 */ { MAD_F(0x04cfb34b) /* 0.300708096 */, 15 },
+ /* 990 */ { MAD_F(0x04d15c76) /* 0.301113568 */, 15 },
+ /* 991 */ { MAD_F(0x04d305c5) /* 0.301519176 */, 15 },
+
+ /* 992 */ { MAD_F(0x04d4af3a) /* 0.301924921 */, 15 },
+ /* 993 */ { MAD_F(0x04d658d2) /* 0.302330802 */, 15 },
+ /* 994 */ { MAD_F(0x04d80290) /* 0.302736820 */, 15 },
+ /* 995 */ { MAD_F(0x04d9ac72) /* 0.303142973 */, 15 },
+ /* 996 */ { MAD_F(0x04db5679) /* 0.303549263 */, 15 },
+ /* 997 */ { MAD_F(0x04dd00a4) /* 0.303955689 */, 15 },
+ /* 998 */ { MAD_F(0x04deaaf3) /* 0.304362251 */, 15 },
+ /* 999 */ { MAD_F(0x04e05567) /* 0.304768948 */, 15 },
+ /* 1000 */ { MAD_F(0x04e20000) /* 0.305175781 */, 15 },
+ /* 1001 */ { MAD_F(0x04e3aabd) /* 0.305582750 */, 15 },
+ /* 1002 */ { MAD_F(0x04e5559e) /* 0.305989854 */, 15 },
+ /* 1003 */ { MAD_F(0x04e700a3) /* 0.306397094 */, 15 },
+ /* 1004 */ { MAD_F(0x04e8abcd) /* 0.306804470 */, 15 },
+ /* 1005 */ { MAD_F(0x04ea571c) /* 0.307211980 */, 15 },
+ /* 1006 */ { MAD_F(0x04ec028e) /* 0.307619626 */, 15 },
+ /* 1007 */ { MAD_F(0x04edae25) /* 0.308027406 */, 15 },
+
+ /* 1008 */ { MAD_F(0x04ef59e0) /* 0.308435322 */, 15 },
+ /* 1009 */ { MAD_F(0x04f105bf) /* 0.308843373 */, 15 },
+ /* 1010 */ { MAD_F(0x04f2b1c3) /* 0.309251558 */, 15 },
+ /* 1011 */ { MAD_F(0x04f45dea) /* 0.309659879 */, 15 },
+ /* 1012 */ { MAD_F(0x04f60a36) /* 0.310068333 */, 15 },
+ /* 1013 */ { MAD_F(0x04f7b6a6) /* 0.310476923 */, 15 },
+ /* 1014 */ { MAD_F(0x04f9633a) /* 0.310885647 */, 15 },
+ /* 1015 */ { MAD_F(0x04fb0ff2) /* 0.311294505 */, 15 },
+ /* 1016 */ { MAD_F(0x04fcbcce) /* 0.311703498 */, 15 },
+ /* 1017 */ { MAD_F(0x04fe69ce) /* 0.312112625 */, 15 },
+ /* 1018 */ { MAD_F(0x050016f3) /* 0.312521885 */, 15 },
+ /* 1019 */ { MAD_F(0x0501c43b) /* 0.312931280 */, 15 },
+ /* 1020 */ { MAD_F(0x050371a7) /* 0.313340809 */, 15 },
+ /* 1021 */ { MAD_F(0x05051f37) /* 0.313750472 */, 15 },
+ /* 1022 */ { MAD_F(0x0506cceb) /* 0.314160269 */, 15 },
+ /* 1023 */ { MAD_F(0x05087ac2) /* 0.314570199 */, 15 },
+
+ /* 1024 */ { MAD_F(0x050a28be) /* 0.314980262 */, 15 },
+ /* 1025 */ { MAD_F(0x050bd6de) /* 0.315390460 */, 15 },
+ /* 1026 */ { MAD_F(0x050d8521) /* 0.315800790 */, 15 },
+ /* 1027 */ { MAD_F(0x050f3388) /* 0.316211255 */, 15 },
+ /* 1028 */ { MAD_F(0x0510e213) /* 0.316621852 */, 15 },
+ /* 1029 */ { MAD_F(0x051290c2) /* 0.317032582 */, 15 },
+ /* 1030 */ { MAD_F(0x05143f94) /* 0.317443446 */, 15 },
+ /* 1031 */ { MAD_F(0x0515ee8a) /* 0.317854442 */, 15 },
+ /* 1032 */ { MAD_F(0x05179da4) /* 0.318265572 */, 15 },
+ /* 1033 */ { MAD_F(0x05194ce1) /* 0.318676834 */, 15 },
+ /* 1034 */ { MAD_F(0x051afc42) /* 0.319088229 */, 15 },
+ /* 1035 */ { MAD_F(0x051cabc7) /* 0.319499756 */, 15 },
+ /* 1036 */ { MAD_F(0x051e5b6f) /* 0.319911417 */, 15 },
+ /* 1037 */ { MAD_F(0x05200b3a) /* 0.320323209 */, 15 },
+ /* 1038 */ { MAD_F(0x0521bb2a) /* 0.320735134 */, 15 },
+ /* 1039 */ { MAD_F(0x05236b3d) /* 0.321147192 */, 15 },
+
+ /* 1040 */ { MAD_F(0x05251b73) /* 0.321559381 */, 15 },
+ /* 1041 */ { MAD_F(0x0526cbcd) /* 0.321971703 */, 15 },
+ /* 1042 */ { MAD_F(0x05287c4a) /* 0.322384156 */, 15 },
+ /* 1043 */ { MAD_F(0x052a2cea) /* 0.322796742 */, 15 },
+ /* 1044 */ { MAD_F(0x052bddae) /* 0.323209460 */, 15 },
+ /* 1045 */ { MAD_F(0x052d8e96) /* 0.323622309 */, 15 },
+ /* 1046 */ { MAD_F(0x052f3fa1) /* 0.324035290 */, 15 },
+ /* 1047 */ { MAD_F(0x0530f0cf) /* 0.324448403 */, 15 },
+ /* 1048 */ { MAD_F(0x0532a220) /* 0.324861647 */, 15 },
+ /* 1049 */ { MAD_F(0x05345395) /* 0.325275023 */, 15 },
+ /* 1050 */ { MAD_F(0x0536052d) /* 0.325688530 */, 15 },
+ /* 1051 */ { MAD_F(0x0537b6e8) /* 0.326102168 */, 15 },
+ /* 1052 */ { MAD_F(0x053968c6) /* 0.326515938 */, 15 },
+ /* 1053 */ { MAD_F(0x053b1ac8) /* 0.326929839 */, 15 },
+ /* 1054 */ { MAD_F(0x053ccced) /* 0.327343870 */, 15 },
+ /* 1055 */ { MAD_F(0x053e7f35) /* 0.327758033 */, 15 },
+
+ /* 1056 */ { MAD_F(0x054031a0) /* 0.328172327 */, 15 },
+ /* 1057 */ { MAD_F(0x0541e42e) /* 0.328586751 */, 15 },
+ /* 1058 */ { MAD_F(0x054396df) /* 0.329001306 */, 15 },
+ /* 1059 */ { MAD_F(0x054549b4) /* 0.329415992 */, 15 },
+ /* 1060 */ { MAD_F(0x0546fcab) /* 0.329830808 */, 15 },
+ /* 1061 */ { MAD_F(0x0548afc6) /* 0.330245755 */, 15 },
+ /* 1062 */ { MAD_F(0x054a6303) /* 0.330660832 */, 15 },
+ /* 1063 */ { MAD_F(0x054c1663) /* 0.331076039 */, 15 },
+ /* 1064 */ { MAD_F(0x054dc9e7) /* 0.331491377 */, 15 },
+ /* 1065 */ { MAD_F(0x054f7d8d) /* 0.331906845 */, 15 },
+ /* 1066 */ { MAD_F(0x05513156) /* 0.332322443 */, 15 },
+ /* 1067 */ { MAD_F(0x0552e542) /* 0.332738170 */, 15 },
+ /* 1068 */ { MAD_F(0x05549951) /* 0.333154028 */, 15 },
+ /* 1069 */ { MAD_F(0x05564d83) /* 0.333570016 */, 15 },
+ /* 1070 */ { MAD_F(0x055801d8) /* 0.333986133 */, 15 },
+ /* 1071 */ { MAD_F(0x0559b64f) /* 0.334402380 */, 15 },
+
+ /* 1072 */ { MAD_F(0x055b6ae9) /* 0.334818756 */, 15 },
+ /* 1073 */ { MAD_F(0x055d1fa6) /* 0.335235262 */, 15 },
+ /* 1074 */ { MAD_F(0x055ed486) /* 0.335651898 */, 15 },
+ /* 1075 */ { MAD_F(0x05608988) /* 0.336068662 */, 15 },
+ /* 1076 */ { MAD_F(0x05623ead) /* 0.336485556 */, 15 },
+ /* 1077 */ { MAD_F(0x0563f3f5) /* 0.336902579 */, 15 },
+ /* 1078 */ { MAD_F(0x0565a960) /* 0.337319732 */, 15 },
+ /* 1079 */ { MAD_F(0x05675eed) /* 0.337737013 */, 15 },
+ /* 1080 */ { MAD_F(0x0569149c) /* 0.338154423 */, 15 },
+ /* 1081 */ { MAD_F(0x056aca6f) /* 0.338571962 */, 15 },
+ /* 1082 */ { MAD_F(0x056c8064) /* 0.338989630 */, 15 },
+ /* 1083 */ { MAD_F(0x056e367b) /* 0.339407426 */, 15 },
+ /* 1084 */ { MAD_F(0x056fecb5) /* 0.339825351 */, 15 },
+ /* 1085 */ { MAD_F(0x0571a311) /* 0.340243405 */, 15 },
+ /* 1086 */ { MAD_F(0x05735990) /* 0.340661587 */, 15 },
+ /* 1087 */ { MAD_F(0x05751032) /* 0.341079898 */, 15 },
+
+ /* 1088 */ { MAD_F(0x0576c6f5) /* 0.341498336 */, 15 },
+ /* 1089 */ { MAD_F(0x05787ddc) /* 0.341916903 */, 15 },
+ /* 1090 */ { MAD_F(0x057a34e4) /* 0.342335598 */, 15 },
+ /* 1091 */ { MAD_F(0x057bec0f) /* 0.342754421 */, 15 },
+ /* 1092 */ { MAD_F(0x057da35d) /* 0.343173373 */, 15 },
+ /* 1093 */ { MAD_F(0x057f5acc) /* 0.343592452 */, 15 },
+ /* 1094 */ { MAD_F(0x0581125e) /* 0.344011659 */, 15 },
+ /* 1095 */ { MAD_F(0x0582ca12) /* 0.344430993 */, 15 },
+ /* 1096 */ { MAD_F(0x058481e9) /* 0.344850455 */, 15 },
+ /* 1097 */ { MAD_F(0x058639e2) /* 0.345270045 */, 15 },
+ /* 1098 */ { MAD_F(0x0587f1fd) /* 0.345689763 */, 15 },
+ /* 1099 */ { MAD_F(0x0589aa3a) /* 0.346109608 */, 15 },
+ /* 1100 */ { MAD_F(0x058b629a) /* 0.346529580 */, 15 },
+ /* 1101 */ { MAD_F(0x058d1b1b) /* 0.346949679 */, 15 },
+ /* 1102 */ { MAD_F(0x058ed3bf) /* 0.347369906 */, 15 },
+ /* 1103 */ { MAD_F(0x05908c85) /* 0.347790260 */, 15 },
+
+ /* 1104 */ { MAD_F(0x0592456d) /* 0.348210741 */, 15 },
+ /* 1105 */ { MAD_F(0x0593fe77) /* 0.348631348 */, 15 },
+ /* 1106 */ { MAD_F(0x0595b7a3) /* 0.349052083 */, 15 },
+ /* 1107 */ { MAD_F(0x059770f1) /* 0.349472945 */, 15 },
+ /* 1108 */ { MAD_F(0x05992a61) /* 0.349893933 */, 15 },
+ /* 1109 */ { MAD_F(0x059ae3f3) /* 0.350315048 */, 15 },
+ /* 1110 */ { MAD_F(0x059c9da8) /* 0.350736290 */, 15 },
+ /* 1111 */ { MAD_F(0x059e577e) /* 0.351157658 */, 15 },
+ /* 1112 */ { MAD_F(0x05a01176) /* 0.351579152 */, 15 },
+ /* 1113 */ { MAD_F(0x05a1cb90) /* 0.352000773 */, 15 },
+ /* 1114 */ { MAD_F(0x05a385cc) /* 0.352422520 */, 15 },
+ /* 1115 */ { MAD_F(0x05a5402a) /* 0.352844394 */, 15 },
+ /* 1116 */ { MAD_F(0x05a6faa9) /* 0.353266393 */, 15 },
+ /* 1117 */ { MAD_F(0x05a8b54b) /* 0.353688519 */, 15 },
+ /* 1118 */ { MAD_F(0x05aa700e) /* 0.354110771 */, 15 },
+ /* 1119 */ { MAD_F(0x05ac2af3) /* 0.354533148 */, 15 },
+
+ /* 1120 */ { MAD_F(0x05ade5fa) /* 0.354955651 */, 15 },
+ /* 1121 */ { MAD_F(0x05afa123) /* 0.355378281 */, 15 },
+ /* 1122 */ { MAD_F(0x05b15c6d) /* 0.355801035 */, 15 },
+ /* 1123 */ { MAD_F(0x05b317d9) /* 0.356223916 */, 15 },
+ /* 1124 */ { MAD_F(0x05b4d367) /* 0.356646922 */, 15 },
+ /* 1125 */ { MAD_F(0x05b68f16) /* 0.357070053 */, 15 },
+ /* 1126 */ { MAD_F(0x05b84ae7) /* 0.357493310 */, 15 },
+ /* 1127 */ { MAD_F(0x05ba06da) /* 0.357916692 */, 15 },
+ /* 1128 */ { MAD_F(0x05bbc2ef) /* 0.358340200 */, 15 },
+ /* 1129 */ { MAD_F(0x05bd7f25) /* 0.358763832 */, 15 },
+ /* 1130 */ { MAD_F(0x05bf3b7c) /* 0.359187590 */, 15 },
+ /* 1131 */ { MAD_F(0x05c0f7f5) /* 0.359611472 */, 15 },
+ /* 1132 */ { MAD_F(0x05c2b490) /* 0.360035480 */, 15 },
+ /* 1133 */ { MAD_F(0x05c4714c) /* 0.360459613 */, 15 },
+ /* 1134 */ { MAD_F(0x05c62e2a) /* 0.360883870 */, 15 },
+ /* 1135 */ { MAD_F(0x05c7eb29) /* 0.361308252 */, 15 },
+
+ /* 1136 */ { MAD_F(0x05c9a84a) /* 0.361732758 */, 15 },
+ /* 1137 */ { MAD_F(0x05cb658c) /* 0.362157390 */, 15 },
+ /* 1138 */ { MAD_F(0x05cd22ef) /* 0.362582145 */, 15 },
+ /* 1139 */ { MAD_F(0x05cee074) /* 0.363007026 */, 15 },
+ /* 1140 */ { MAD_F(0x05d09e1b) /* 0.363432030 */, 15 },
+ /* 1141 */ { MAD_F(0x05d25be2) /* 0.363857159 */, 15 },
+ /* 1142 */ { MAD_F(0x05d419cb) /* 0.364282412 */, 15 },
+ /* 1143 */ { MAD_F(0x05d5d7d5) /* 0.364707789 */, 15 },
+ /* 1144 */ { MAD_F(0x05d79601) /* 0.365133291 */, 15 },
+ /* 1145 */ { MAD_F(0x05d9544e) /* 0.365558916 */, 15 },
+ /* 1146 */ { MAD_F(0x05db12bc) /* 0.365984665 */, 15 },
+ /* 1147 */ { MAD_F(0x05dcd14c) /* 0.366410538 */, 15 },
+ /* 1148 */ { MAD_F(0x05de8ffc) /* 0.366836535 */, 15 },
+ /* 1149 */ { MAD_F(0x05e04ece) /* 0.367262655 */, 15 },
+ /* 1150 */ { MAD_F(0x05e20dc1) /* 0.367688900 */, 15 },
+ /* 1151 */ { MAD_F(0x05e3ccd5) /* 0.368115267 */, 15 },
+
+ /* 1152 */ { MAD_F(0x05e58c0b) /* 0.368541759 */, 15 },
+ /* 1153 */ { MAD_F(0x05e74b61) /* 0.368968373 */, 15 },
+ /* 1154 */ { MAD_F(0x05e90ad9) /* 0.369395111 */, 15 },
+ /* 1155 */ { MAD_F(0x05eaca72) /* 0.369821973 */, 15 },
+ /* 1156 */ { MAD_F(0x05ec8a2b) /* 0.370248957 */, 15 },
+ /* 1157 */ { MAD_F(0x05ee4a06) /* 0.370676065 */, 15 },
+ /* 1158 */ { MAD_F(0x05f00a02) /* 0.371103295 */, 15 },
+ /* 1159 */ { MAD_F(0x05f1ca1f) /* 0.371530649 */, 15 },
+ /* 1160 */ { MAD_F(0x05f38a5d) /* 0.371958126 */, 15 },
+ /* 1161 */ { MAD_F(0x05f54abc) /* 0.372385725 */, 15 },
+ /* 1162 */ { MAD_F(0x05f70b3c) /* 0.372813448 */, 15 },
+ /* 1163 */ { MAD_F(0x05f8cbdc) /* 0.373241292 */, 15 },
+ /* 1164 */ { MAD_F(0x05fa8c9e) /* 0.373669260 */, 15 },
+ /* 1165 */ { MAD_F(0x05fc4d81) /* 0.374097350 */, 15 },
+ /* 1166 */ { MAD_F(0x05fe0e84) /* 0.374525563 */, 15 },
+ /* 1167 */ { MAD_F(0x05ffcfa8) /* 0.374953898 */, 15 },
+
+ /* 1168 */ { MAD_F(0x060190ee) /* 0.375382356 */, 15 },
+ /* 1169 */ { MAD_F(0x06035254) /* 0.375810936 */, 15 },
+ /* 1170 */ { MAD_F(0x060513da) /* 0.376239638 */, 15 },
+ /* 1171 */ { MAD_F(0x0606d582) /* 0.376668462 */, 15 },
+ /* 1172 */ { MAD_F(0x0608974a) /* 0.377097408 */, 15 },
+ /* 1173 */ { MAD_F(0x060a5934) /* 0.377526476 */, 15 },
+ /* 1174 */ { MAD_F(0x060c1b3d) /* 0.377955667 */, 15 },
+ /* 1175 */ { MAD_F(0x060ddd68) /* 0.378384979 */, 15 },
+ /* 1176 */ { MAD_F(0x060f9fb3) /* 0.378814413 */, 15 },
+ /* 1177 */ { MAD_F(0x0611621f) /* 0.379243968 */, 15 },
+ /* 1178 */ { MAD_F(0x061324ac) /* 0.379673646 */, 15 },
+ /* 1179 */ { MAD_F(0x0614e759) /* 0.380103444 */, 15 },
+ /* 1180 */ { MAD_F(0x0616aa27) /* 0.380533365 */, 15 },
+ /* 1181 */ { MAD_F(0x06186d16) /* 0.380963407 */, 15 },
+ /* 1182 */ { MAD_F(0x061a3025) /* 0.381393570 */, 15 },
+ /* 1183 */ { MAD_F(0x061bf354) /* 0.381823855 */, 15 },
+
+ /* 1184 */ { MAD_F(0x061db6a5) /* 0.382254261 */, 15 },
+ /* 1185 */ { MAD_F(0x061f7a15) /* 0.382684788 */, 15 },
+ /* 1186 */ { MAD_F(0x06213da7) /* 0.383115436 */, 15 },
+ /* 1187 */ { MAD_F(0x06230158) /* 0.383546205 */, 15 },
+ /* 1188 */ { MAD_F(0x0624c52a) /* 0.383977096 */, 15 },
+ /* 1189 */ { MAD_F(0x0626891d) /* 0.384408107 */, 15 },
+ /* 1190 */ { MAD_F(0x06284d30) /* 0.384839239 */, 15 },
+ /* 1191 */ { MAD_F(0x062a1164) /* 0.385270492 */, 15 },
+ /* 1192 */ { MAD_F(0x062bd5b8) /* 0.385701865 */, 15 },
+ /* 1193 */ { MAD_F(0x062d9a2c) /* 0.386133359 */, 15 },
+ /* 1194 */ { MAD_F(0x062f5ec1) /* 0.386564974 */, 15 },
+ /* 1195 */ { MAD_F(0x06312376) /* 0.386996709 */, 15 },
+ /* 1196 */ { MAD_F(0x0632e84b) /* 0.387428565 */, 15 },
+ /* 1197 */ { MAD_F(0x0634ad41) /* 0.387860541 */, 15 },
+ /* 1198 */ { MAD_F(0x06367257) /* 0.388292637 */, 15 },
+ /* 1199 */ { MAD_F(0x0638378d) /* 0.388724854 */, 15 },
+
+ /* 1200 */ { MAD_F(0x0639fce4) /* 0.389157191 */, 15 },
+ /* 1201 */ { MAD_F(0x063bc25b) /* 0.389589648 */, 15 },
+ /* 1202 */ { MAD_F(0x063d87f2) /* 0.390022225 */, 15 },
+ /* 1203 */ { MAD_F(0x063f4da9) /* 0.390454922 */, 15 },
+ /* 1204 */ { MAD_F(0x06411380) /* 0.390887739 */, 15 },
+ /* 1205 */ { MAD_F(0x0642d978) /* 0.391320675 */, 15 },
+ /* 1206 */ { MAD_F(0x06449f8f) /* 0.391753732 */, 15 },
+ /* 1207 */ { MAD_F(0x064665c7) /* 0.392186908 */, 15 },
+ /* 1208 */ { MAD_F(0x06482c1f) /* 0.392620204 */, 15 },
+ /* 1209 */ { MAD_F(0x0649f297) /* 0.393053619 */, 15 },
+ /* 1210 */ { MAD_F(0x064bb92f) /* 0.393487154 */, 15 },
+ /* 1211 */ { MAD_F(0x064d7fe8) /* 0.393920808 */, 15 },
+ /* 1212 */ { MAD_F(0x064f46c0) /* 0.394354582 */, 15 },
+ /* 1213 */ { MAD_F(0x06510db8) /* 0.394788475 */, 15 },
+ /* 1214 */ { MAD_F(0x0652d4d0) /* 0.395222488 */, 15 },
+ /* 1215 */ { MAD_F(0x06549c09) /* 0.395656619 */, 15 },
+
+ /* 1216 */ { MAD_F(0x06566361) /* 0.396090870 */, 15 },
+ /* 1217 */ { MAD_F(0x06582ad9) /* 0.396525239 */, 15 },
+ /* 1218 */ { MAD_F(0x0659f271) /* 0.396959728 */, 15 },
+ /* 1219 */ { MAD_F(0x065bba29) /* 0.397394336 */, 15 },
+ /* 1220 */ { MAD_F(0x065d8201) /* 0.397829062 */, 15 },
+ /* 1221 */ { MAD_F(0x065f49f9) /* 0.398263907 */, 15 },
+ /* 1222 */ { MAD_F(0x06611211) /* 0.398698871 */, 15 },
+ /* 1223 */ { MAD_F(0x0662da49) /* 0.399133954 */, 15 },
+ /* 1224 */ { MAD_F(0x0664a2a0) /* 0.399569155 */, 15 },
+ /* 1225 */ { MAD_F(0x06666b17) /* 0.400004475 */, 15 },
+ /* 1226 */ { MAD_F(0x066833ae) /* 0.400439913 */, 15 },
+ /* 1227 */ { MAD_F(0x0669fc65) /* 0.400875470 */, 15 },
+ /* 1228 */ { MAD_F(0x066bc53c) /* 0.401311145 */, 15 },
+ /* 1229 */ { MAD_F(0x066d8e32) /* 0.401746938 */, 15 },
+ /* 1230 */ { MAD_F(0x066f5748) /* 0.402182850 */, 15 },
+ /* 1231 */ { MAD_F(0x0671207e) /* 0.402618879 */, 15 },
+
+ /* 1232 */ { MAD_F(0x0672e9d4) /* 0.403055027 */, 15 },
+ /* 1233 */ { MAD_F(0x0674b349) /* 0.403491293 */, 15 },
+ /* 1234 */ { MAD_F(0x06767cde) /* 0.403927676 */, 15 },
+ /* 1235 */ { MAD_F(0x06784692) /* 0.404364178 */, 15 },
+ /* 1236 */ { MAD_F(0x067a1066) /* 0.404800797 */, 15 },
+ /* 1237 */ { MAD_F(0x067bda5a) /* 0.405237535 */, 15 },
+ /* 1238 */ { MAD_F(0x067da46d) /* 0.405674390 */, 15 },
+ /* 1239 */ { MAD_F(0x067f6ea0) /* 0.406111362 */, 15 },
+ /* 1240 */ { MAD_F(0x068138f3) /* 0.406548452 */, 15 },
+ /* 1241 */ { MAD_F(0x06830365) /* 0.406985660 */, 15 },
+ /* 1242 */ { MAD_F(0x0684cdf6) /* 0.407422985 */, 15 },
+ /* 1243 */ { MAD_F(0x068698a8) /* 0.407860427 */, 15 },
+ /* 1244 */ { MAD_F(0x06886378) /* 0.408297987 */, 15 },
+ /* 1245 */ { MAD_F(0x068a2e68) /* 0.408735664 */, 15 },
+ /* 1246 */ { MAD_F(0x068bf978) /* 0.409173458 */, 15 },
+ /* 1247 */ { MAD_F(0x068dc4a7) /* 0.409611370 */, 15 },
+
+ /* 1248 */ { MAD_F(0x068f8ff5) /* 0.410049398 */, 15 },
+ /* 1249 */ { MAD_F(0x06915b63) /* 0.410487544 */, 15 },
+ /* 1250 */ { MAD_F(0x069326f0) /* 0.410925806 */, 15 },
+ /* 1251 */ { MAD_F(0x0694f29c) /* 0.411364185 */, 15 },
+ /* 1252 */ { MAD_F(0x0696be68) /* 0.411802681 */, 15 },
+ /* 1253 */ { MAD_F(0x06988a54) /* 0.412241294 */, 15 },
+ /* 1254 */ { MAD_F(0x069a565e) /* 0.412680024 */, 15 },
+ /* 1255 */ { MAD_F(0x069c2288) /* 0.413118870 */, 15 },
+ /* 1256 */ { MAD_F(0x069deed1) /* 0.413557833 */, 15 },
+ /* 1257 */ { MAD_F(0x069fbb3a) /* 0.413996912 */, 15 },
+ /* 1258 */ { MAD_F(0x06a187c1) /* 0.414436108 */, 15 },
+ /* 1259 */ { MAD_F(0x06a35468) /* 0.414875420 */, 15 },
+ /* 1260 */ { MAD_F(0x06a5212f) /* 0.415314849 */, 15 },
+ /* 1261 */ { MAD_F(0x06a6ee14) /* 0.415754393 */, 15 },
+ /* 1262 */ { MAD_F(0x06a8bb18) /* 0.416194054 */, 15 },
+ /* 1263 */ { MAD_F(0x06aa883c) /* 0.416633831 */, 15 },
+
+ /* 1264 */ { MAD_F(0x06ac557f) /* 0.417073724 */, 15 },
+ /* 1265 */ { MAD_F(0x06ae22e1) /* 0.417513734 */, 15 },
+ /* 1266 */ { MAD_F(0x06aff062) /* 0.417953859 */, 15 },
+ /* 1267 */ { MAD_F(0x06b1be03) /* 0.418394100 */, 15 },
+ /* 1268 */ { MAD_F(0x06b38bc2) /* 0.418834457 */, 15 },
+ /* 1269 */ { MAD_F(0x06b559a1) /* 0.419274929 */, 15 },
+ /* 1270 */ { MAD_F(0x06b7279e) /* 0.419715518 */, 15 },
+ /* 1271 */ { MAD_F(0x06b8f5bb) /* 0.420156222 */, 15 },
+ /* 1272 */ { MAD_F(0x06bac3f6) /* 0.420597041 */, 15 },
+ /* 1273 */ { MAD_F(0x06bc9251) /* 0.421037977 */, 15 },
+ /* 1274 */ { MAD_F(0x06be60cb) /* 0.421479027 */, 15 },
+ /* 1275 */ { MAD_F(0x06c02f63) /* 0.421920193 */, 15 },
+ /* 1276 */ { MAD_F(0x06c1fe1b) /* 0.422361475 */, 15 },
+ /* 1277 */ { MAD_F(0x06c3ccf1) /* 0.422802871 */, 15 },
+ /* 1278 */ { MAD_F(0x06c59be7) /* 0.423244383 */, 15 },
+ /* 1279 */ { MAD_F(0x06c76afb) /* 0.423686010 */, 15 },
+
+ /* 1280 */ { MAD_F(0x06c93a2e) /* 0.424127753 */, 15 },
+ /* 1281 */ { MAD_F(0x06cb0981) /* 0.424569610 */, 15 },
+ /* 1282 */ { MAD_F(0x06ccd8f2) /* 0.425011582 */, 15 },
+ /* 1283 */ { MAD_F(0x06cea881) /* 0.425453669 */, 15 },
+ /* 1284 */ { MAD_F(0x06d07830) /* 0.425895871 */, 15 },
+ /* 1285 */ { MAD_F(0x06d247fe) /* 0.426338188 */, 15 },
+ /* 1286 */ { MAD_F(0x06d417ea) /* 0.426780620 */, 15 },
+ /* 1287 */ { MAD_F(0x06d5e7f5) /* 0.427223166 */, 15 },
+ /* 1288 */ { MAD_F(0x06d7b81f) /* 0.427665827 */, 15 },
+ /* 1289 */ { MAD_F(0x06d98868) /* 0.428108603 */, 15 },
+ /* 1290 */ { MAD_F(0x06db58cf) /* 0.428551493 */, 15 },
+ /* 1291 */ { MAD_F(0x06dd2955) /* 0.428994497 */, 15 },
+ /* 1292 */ { MAD_F(0x06def9fa) /* 0.429437616 */, 15 },
+ /* 1293 */ { MAD_F(0x06e0cabe) /* 0.429880849 */, 15 },
+ /* 1294 */ { MAD_F(0x06e29ba0) /* 0.430324197 */, 15 },
+ /* 1295 */ { MAD_F(0x06e46ca1) /* 0.430767659 */, 15 },
+
+ /* 1296 */ { MAD_F(0x06e63dc0) /* 0.431211234 */, 15 },
+ /* 1297 */ { MAD_F(0x06e80efe) /* 0.431654924 */, 15 },
+ /* 1298 */ { MAD_F(0x06e9e05b) /* 0.432098728 */, 15 },
+ /* 1299 */ { MAD_F(0x06ebb1d6) /* 0.432542647 */, 15 },
+ /* 1300 */ { MAD_F(0x06ed8370) /* 0.432986678 */, 15 },
+ /* 1301 */ { MAD_F(0x06ef5529) /* 0.433430824 */, 15 },
+ /* 1302 */ { MAD_F(0x06f12700) /* 0.433875084 */, 15 },
+ /* 1303 */ { MAD_F(0x06f2f8f5) /* 0.434319457 */, 15 },
+ /* 1304 */ { MAD_F(0x06f4cb09) /* 0.434763944 */, 15 },
+ /* 1305 */ { MAD_F(0x06f69d3c) /* 0.435208545 */, 15 },
+ /* 1306 */ { MAD_F(0x06f86f8d) /* 0.435653259 */, 15 },
+ /* 1307 */ { MAD_F(0x06fa41fd) /* 0.436098087 */, 15 },
+ /* 1308 */ { MAD_F(0x06fc148b) /* 0.436543029 */, 15 },
+ /* 1309 */ { MAD_F(0x06fde737) /* 0.436988083 */, 15 },
+ /* 1310 */ { MAD_F(0x06ffba02) /* 0.437433251 */, 15 },
+ /* 1311 */ { MAD_F(0x07018ceb) /* 0.437878533 */, 15 },
+
+ /* 1312 */ { MAD_F(0x07035ff3) /* 0.438323927 */, 15 },
+ /* 1313 */ { MAD_F(0x07053319) /* 0.438769435 */, 15 },
+ /* 1314 */ { MAD_F(0x0707065d) /* 0.439215056 */, 15 },
+ /* 1315 */ { MAD_F(0x0708d9c0) /* 0.439660790 */, 15 },
+ /* 1316 */ { MAD_F(0x070aad41) /* 0.440106636 */, 15 },
+ /* 1317 */ { MAD_F(0x070c80e1) /* 0.440552596 */, 15 },
+ /* 1318 */ { MAD_F(0x070e549f) /* 0.440998669 */, 15 },
+ /* 1319 */ { MAD_F(0x0710287b) /* 0.441444855 */, 15 },
+ /* 1320 */ { MAD_F(0x0711fc75) /* 0.441891153 */, 15 },
+ /* 1321 */ { MAD_F(0x0713d08d) /* 0.442337564 */, 15 },
+ /* 1322 */ { MAD_F(0x0715a4c4) /* 0.442784088 */, 15 },
+ /* 1323 */ { MAD_F(0x07177919) /* 0.443230724 */, 15 },
+ /* 1324 */ { MAD_F(0x07194d8c) /* 0.443677473 */, 15 },
+ /* 1325 */ { MAD_F(0x071b221e) /* 0.444124334 */, 15 },
+ /* 1326 */ { MAD_F(0x071cf6ce) /* 0.444571308 */, 15 },
+ /* 1327 */ { MAD_F(0x071ecb9b) /* 0.445018394 */, 15 },
+
+ /* 1328 */ { MAD_F(0x0720a087) /* 0.445465593 */, 15 },
+ /* 1329 */ { MAD_F(0x07227591) /* 0.445912903 */, 15 },
+ /* 1330 */ { MAD_F(0x07244ab9) /* 0.446360326 */, 15 },
+ /* 1331 */ { MAD_F(0x07262000) /* 0.446807861 */, 15 },
+ /* 1332 */ { MAD_F(0x0727f564) /* 0.447255509 */, 15 },
+ /* 1333 */ { MAD_F(0x0729cae7) /* 0.447703268 */, 15 },
+ /* 1334 */ { MAD_F(0x072ba087) /* 0.448151139 */, 15 },
+ /* 1335 */ { MAD_F(0x072d7646) /* 0.448599122 */, 15 },
+ /* 1336 */ { MAD_F(0x072f4c22) /* 0.449047217 */, 15 },
+ /* 1337 */ { MAD_F(0x0731221d) /* 0.449495424 */, 15 },
+ /* 1338 */ { MAD_F(0x0732f835) /* 0.449943742 */, 15 },
+ /* 1339 */ { MAD_F(0x0734ce6c) /* 0.450392173 */, 15 },
+ /* 1340 */ { MAD_F(0x0736a4c1) /* 0.450840715 */, 15 },
+ /* 1341 */ { MAD_F(0x07387b33) /* 0.451289368 */, 15 },
+ /* 1342 */ { MAD_F(0x073a51c4) /* 0.451738133 */, 15 },
+ /* 1343 */ { MAD_F(0x073c2872) /* 0.452187010 */, 15 },
+
+ /* 1344 */ { MAD_F(0x073dff3e) /* 0.452635998 */, 15 },
+ /* 1345 */ { MAD_F(0x073fd628) /* 0.453085097 */, 15 },
+ /* 1346 */ { MAD_F(0x0741ad30) /* 0.453534308 */, 15 },
+ /* 1347 */ { MAD_F(0x07438456) /* 0.453983630 */, 15 },
+ /* 1348 */ { MAD_F(0x07455b9a) /* 0.454433063 */, 15 },
+ /* 1349 */ { MAD_F(0x074732fc) /* 0.454882607 */, 15 },
+ /* 1350 */ { MAD_F(0x07490a7b) /* 0.455332262 */, 15 },
+ /* 1351 */ { MAD_F(0x074ae218) /* 0.455782029 */, 15 },
+ /* 1352 */ { MAD_F(0x074cb9d3) /* 0.456231906 */, 15 },
+ /* 1353 */ { MAD_F(0x074e91ac) /* 0.456681894 */, 15 },
+ /* 1354 */ { MAD_F(0x075069a3) /* 0.457131993 */, 15 },
+ /* 1355 */ { MAD_F(0x075241b7) /* 0.457582203 */, 15 },
+ /* 1356 */ { MAD_F(0x075419e9) /* 0.458032524 */, 15 },
+ /* 1357 */ { MAD_F(0x0755f239) /* 0.458482956 */, 15 },
+ /* 1358 */ { MAD_F(0x0757caa7) /* 0.458933498 */, 15 },
+ /* 1359 */ { MAD_F(0x0759a332) /* 0.459384151 */, 15 },
+
+ /* 1360 */ { MAD_F(0x075b7bdb) /* 0.459834914 */, 15 },
+ /* 1361 */ { MAD_F(0x075d54a1) /* 0.460285788 */, 15 },
+ /* 1362 */ { MAD_F(0x075f2d85) /* 0.460736772 */, 15 },
+ /* 1363 */ { MAD_F(0x07610687) /* 0.461187867 */, 15 },
+ /* 1364 */ { MAD_F(0x0762dfa6) /* 0.461639071 */, 15 },
+ /* 1365 */ { MAD_F(0x0764b8e3) /* 0.462090387 */, 15 },
+ /* 1366 */ { MAD_F(0x0766923e) /* 0.462541812 */, 15 },
+ /* 1367 */ { MAD_F(0x07686bb6) /* 0.462993348 */, 15 },
+ /* 1368 */ { MAD_F(0x076a454c) /* 0.463444993 */, 15 },
+ /* 1369 */ { MAD_F(0x076c1eff) /* 0.463896749 */, 15 },
+ /* 1370 */ { MAD_F(0x076df8d0) /* 0.464348615 */, 15 },
+ /* 1371 */ { MAD_F(0x076fd2be) /* 0.464800591 */, 15 },
+ /* 1372 */ { MAD_F(0x0771acca) /* 0.465252676 */, 15 },
+ /* 1373 */ { MAD_F(0x077386f3) /* 0.465704872 */, 15 },
+ /* 1374 */ { MAD_F(0x0775613a) /* 0.466157177 */, 15 },
+ /* 1375 */ { MAD_F(0x07773b9e) /* 0.466609592 */, 15 },
+
+ /* 1376 */ { MAD_F(0x07791620) /* 0.467062117 */, 15 },
+ /* 1377 */ { MAD_F(0x077af0bf) /* 0.467514751 */, 15 },
+ /* 1378 */ { MAD_F(0x077ccb7c) /* 0.467967495 */, 15 },
+ /* 1379 */ { MAD_F(0x077ea656) /* 0.468420349 */, 15 },
+ /* 1380 */ { MAD_F(0x0780814d) /* 0.468873312 */, 15 },
+ /* 1381 */ { MAD_F(0x07825c62) /* 0.469326384 */, 15 },
+ /* 1382 */ { MAD_F(0x07843794) /* 0.469779566 */, 15 },
+ /* 1383 */ { MAD_F(0x078612e3) /* 0.470232857 */, 15 },
+ /* 1384 */ { MAD_F(0x0787ee50) /* 0.470686258 */, 15 },
+ /* 1385 */ { MAD_F(0x0789c9da) /* 0.471139767 */, 15 },
+ /* 1386 */ { MAD_F(0x078ba581) /* 0.471593386 */, 15 },
+ /* 1387 */ { MAD_F(0x078d8146) /* 0.472047114 */, 15 },
+ /* 1388 */ { MAD_F(0x078f5d28) /* 0.472500951 */, 15 },
+ /* 1389 */ { MAD_F(0x07913927) /* 0.472954896 */, 15 },
+ /* 1390 */ { MAD_F(0x07931543) /* 0.473408951 */, 15 },
+ /* 1391 */ { MAD_F(0x0794f17d) /* 0.473863115 */, 15 },
+
+ /* 1392 */ { MAD_F(0x0796cdd4) /* 0.474317388 */, 15 },
+ /* 1393 */ { MAD_F(0x0798aa48) /* 0.474771769 */, 15 },
+ /* 1394 */ { MAD_F(0x079a86d9) /* 0.475226259 */, 15 },
+ /* 1395 */ { MAD_F(0x079c6388) /* 0.475680858 */, 15 },
+ /* 1396 */ { MAD_F(0x079e4053) /* 0.476135565 */, 15 },
+ /* 1397 */ { MAD_F(0x07a01d3c) /* 0.476590381 */, 15 },
+ /* 1398 */ { MAD_F(0x07a1fa42) /* 0.477045306 */, 15 },
+ /* 1399 */ { MAD_F(0x07a3d765) /* 0.477500339 */, 15 },
+ /* 1400 */ { MAD_F(0x07a5b4a5) /* 0.477955481 */, 15 },
+ /* 1401 */ { MAD_F(0x07a79202) /* 0.478410731 */, 15 },
+ /* 1402 */ { MAD_F(0x07a96f7d) /* 0.478866089 */, 15 },
+ /* 1403 */ { MAD_F(0x07ab4d14) /* 0.479321555 */, 15 },
+ /* 1404 */ { MAD_F(0x07ad2ac8) /* 0.479777130 */, 15 },
+ /* 1405 */ { MAD_F(0x07af089a) /* 0.480232813 */, 15 },
+ /* 1406 */ { MAD_F(0x07b0e688) /* 0.480688604 */, 15 },
+ /* 1407 */ { MAD_F(0x07b2c494) /* 0.481144503 */, 15 },
+
+ /* 1408 */ { MAD_F(0x07b4a2bc) /* 0.481600510 */, 15 },
+ /* 1409 */ { MAD_F(0x07b68102) /* 0.482056625 */, 15 },
+ /* 1410 */ { MAD_F(0x07b85f64) /* 0.482512848 */, 15 },
+ /* 1411 */ { MAD_F(0x07ba3de4) /* 0.482969179 */, 15 },
+ /* 1412 */ { MAD_F(0x07bc1c80) /* 0.483425618 */, 15 },
+ /* 1413 */ { MAD_F(0x07bdfb39) /* 0.483882164 */, 15 },
+ /* 1414 */ { MAD_F(0x07bfda0f) /* 0.484338818 */, 15 },
+ /* 1415 */ { MAD_F(0x07c1b902) /* 0.484795580 */, 15 },
+ /* 1416 */ { MAD_F(0x07c39812) /* 0.485252449 */, 15 },
+ /* 1417 */ { MAD_F(0x07c5773f) /* 0.485709426 */, 15 },
+ /* 1418 */ { MAD_F(0x07c75689) /* 0.486166511 */, 15 },
+ /* 1419 */ { MAD_F(0x07c935ef) /* 0.486623703 */, 15 },
+ /* 1420 */ { MAD_F(0x07cb1573) /* 0.487081002 */, 15 },
+ /* 1421 */ { MAD_F(0x07ccf513) /* 0.487538409 */, 15 },
+ /* 1422 */ { MAD_F(0x07ced4d0) /* 0.487995923 */, 15 },
+ /* 1423 */ { MAD_F(0x07d0b4aa) /* 0.488453544 */, 15 },
+
+ /* 1424 */ { MAD_F(0x07d294a0) /* 0.488911273 */, 15 },
+ /* 1425 */ { MAD_F(0x07d474b3) /* 0.489369108 */, 15 },
+ /* 1426 */ { MAD_F(0x07d654e4) /* 0.489827051 */, 15 },
+ /* 1427 */ { MAD_F(0x07d83530) /* 0.490285101 */, 15 },
+ /* 1428 */ { MAD_F(0x07da159a) /* 0.490743258 */, 15 },
+ /* 1429 */ { MAD_F(0x07dbf620) /* 0.491201522 */, 15 },
+ /* 1430 */ { MAD_F(0x07ddd6c3) /* 0.491659892 */, 15 },
+ /* 1431 */ { MAD_F(0x07dfb783) /* 0.492118370 */, 15 },
+ /* 1432 */ { MAD_F(0x07e1985f) /* 0.492576954 */, 15 },
+ /* 1433 */ { MAD_F(0x07e37958) /* 0.493035645 */, 15 },
+ /* 1434 */ { MAD_F(0x07e55a6e) /* 0.493494443 */, 15 },
+ /* 1435 */ { MAD_F(0x07e73ba0) /* 0.493953348 */, 15 },
+ /* 1436 */ { MAD_F(0x07e91cef) /* 0.494412359 */, 15 },
+ /* 1437 */ { MAD_F(0x07eafe5a) /* 0.494871476 */, 15 },
+ /* 1438 */ { MAD_F(0x07ecdfe2) /* 0.495330701 */, 15 },
+ /* 1439 */ { MAD_F(0x07eec187) /* 0.495790031 */, 15 },
+
+ /* 1440 */ { MAD_F(0x07f0a348) /* 0.496249468 */, 15 },
+ /* 1441 */ { MAD_F(0x07f28526) /* 0.496709012 */, 15 },
+ /* 1442 */ { MAD_F(0x07f46720) /* 0.497168662 */, 15 },
+ /* 1443 */ { MAD_F(0x07f64937) /* 0.497628418 */, 15 },
+ /* 1444 */ { MAD_F(0x07f82b6a) /* 0.498088280 */, 15 },
+ /* 1445 */ { MAD_F(0x07fa0dba) /* 0.498548248 */, 15 },
+ /* 1446 */ { MAD_F(0x07fbf026) /* 0.499008323 */, 15 },
+ /* 1447 */ { MAD_F(0x07fdd2af) /* 0.499468503 */, 15 },
+ /* 1448 */ { MAD_F(0x07ffb554) /* 0.499928790 */, 15 },
+ /* 1449 */ { MAD_F(0x0400cc0b) /* 0.250194591 */, 16 },
+ /* 1450 */ { MAD_F(0x0401bd7a) /* 0.250424840 */, 16 },
+ /* 1451 */ { MAD_F(0x0402aef7) /* 0.250655143 */, 16 },
+ /* 1452 */ { MAD_F(0x0403a083) /* 0.250885498 */, 16 },
+ /* 1453 */ { MAD_F(0x0404921c) /* 0.251115906 */, 16 },
+ /* 1454 */ { MAD_F(0x040583c4) /* 0.251346367 */, 16 },
+ /* 1455 */ { MAD_F(0x0406757a) /* 0.251576880 */, 16 },
+
+ /* 1456 */ { MAD_F(0x0407673f) /* 0.251807447 */, 16 },
+ /* 1457 */ { MAD_F(0x04085911) /* 0.252038066 */, 16 },
+ /* 1458 */ { MAD_F(0x04094af1) /* 0.252268738 */, 16 },
+ /* 1459 */ { MAD_F(0x040a3ce0) /* 0.252499463 */, 16 },
+ /* 1460 */ { MAD_F(0x040b2edd) /* 0.252730240 */, 16 },
+ /* 1461 */ { MAD_F(0x040c20e8) /* 0.252961071 */, 16 },
+ /* 1462 */ { MAD_F(0x040d1301) /* 0.253191953 */, 16 },
+ /* 1463 */ { MAD_F(0x040e0529) /* 0.253422889 */, 16 },
+ /* 1464 */ { MAD_F(0x040ef75e) /* 0.253653877 */, 16 },
+ /* 1465 */ { MAD_F(0x040fe9a1) /* 0.253884918 */, 16 },
+ /* 1466 */ { MAD_F(0x0410dbf3) /* 0.254116011 */, 16 },
+ /* 1467 */ { MAD_F(0x0411ce53) /* 0.254347157 */, 16 },
+ /* 1468 */ { MAD_F(0x0412c0c1) /* 0.254578356 */, 16 },
+ /* 1469 */ { MAD_F(0x0413b33d) /* 0.254809606 */, 16 },
+ /* 1470 */ { MAD_F(0x0414a5c7) /* 0.255040910 */, 16 },
+ /* 1471 */ { MAD_F(0x0415985f) /* 0.255272266 */, 16 },
+
+ /* 1472 */ { MAD_F(0x04168b05) /* 0.255503674 */, 16 },
+ /* 1473 */ { MAD_F(0x04177db9) /* 0.255735135 */, 16 },
+ /* 1474 */ { MAD_F(0x0418707c) /* 0.255966648 */, 16 },
+ /* 1475 */ { MAD_F(0x0419634c) /* 0.256198213 */, 16 },
+ /* 1476 */ { MAD_F(0x041a562a) /* 0.256429831 */, 16 },
+ /* 1477 */ { MAD_F(0x041b4917) /* 0.256661501 */, 16 },
+ /* 1478 */ { MAD_F(0x041c3c11) /* 0.256893223 */, 16 },
+ /* 1479 */ { MAD_F(0x041d2f1a) /* 0.257124998 */, 16 },
+ /* 1480 */ { MAD_F(0x041e2230) /* 0.257356825 */, 16 },
+ /* 1481 */ { MAD_F(0x041f1555) /* 0.257588704 */, 16 },
+ /* 1482 */ { MAD_F(0x04200888) /* 0.257820635 */, 16 },
+ /* 1483 */ { MAD_F(0x0420fbc8) /* 0.258052619 */, 16 },
+ /* 1484 */ { MAD_F(0x0421ef17) /* 0.258284654 */, 16 },
+ /* 1485 */ { MAD_F(0x0422e273) /* 0.258516742 */, 16 },
+ /* 1486 */ { MAD_F(0x0423d5de) /* 0.258748882 */, 16 },
+ /* 1487 */ { MAD_F(0x0424c956) /* 0.258981074 */, 16 },
+
+ /* 1488 */ { MAD_F(0x0425bcdd) /* 0.259213318 */, 16 },
+ /* 1489 */ { MAD_F(0x0426b071) /* 0.259445614 */, 16 },
+ /* 1490 */ { MAD_F(0x0427a414) /* 0.259677962 */, 16 },
+ /* 1491 */ { MAD_F(0x042897c4) /* 0.259910362 */, 16 },
+ /* 1492 */ { MAD_F(0x04298b83) /* 0.260142814 */, 16 },
+ /* 1493 */ { MAD_F(0x042a7f4f) /* 0.260375318 */, 16 },
+ /* 1494 */ { MAD_F(0x042b7329) /* 0.260607874 */, 16 },
+ /* 1495 */ { MAD_F(0x042c6711) /* 0.260840481 */, 16 },
+ /* 1496 */ { MAD_F(0x042d5b07) /* 0.261073141 */, 16 },
+ /* 1497 */ { MAD_F(0x042e4f0b) /* 0.261305852 */, 16 },
+ /* 1498 */ { MAD_F(0x042f431d) /* 0.261538616 */, 16 },
+ /* 1499 */ { MAD_F(0x0430373d) /* 0.261771431 */, 16 },
+ /* 1500 */ { MAD_F(0x04312b6b) /* 0.262004297 */, 16 },
+ /* 1501 */ { MAD_F(0x04321fa6) /* 0.262237216 */, 16 },
+ /* 1502 */ { MAD_F(0x043313f0) /* 0.262470186 */, 16 },
+ /* 1503 */ { MAD_F(0x04340847) /* 0.262703208 */, 16 },
+
+ /* 1504 */ { MAD_F(0x0434fcad) /* 0.262936282 */, 16 },
+ /* 1505 */ { MAD_F(0x0435f120) /* 0.263169407 */, 16 },
+ /* 1506 */ { MAD_F(0x0436e5a1) /* 0.263402584 */, 16 },
+ /* 1507 */ { MAD_F(0x0437da2f) /* 0.263635813 */, 16 },
+ /* 1508 */ { MAD_F(0x0438cecc) /* 0.263869093 */, 16 },
+ /* 1509 */ { MAD_F(0x0439c377) /* 0.264102425 */, 16 },
+ /* 1510 */ { MAD_F(0x043ab82f) /* 0.264335808 */, 16 },
+ /* 1511 */ { MAD_F(0x043bacf5) /* 0.264569243 */, 16 },
+ /* 1512 */ { MAD_F(0x043ca1c9) /* 0.264802730 */, 16 },
+ /* 1513 */ { MAD_F(0x043d96ab) /* 0.265036267 */, 16 },
+ /* 1514 */ { MAD_F(0x043e8b9b) /* 0.265269857 */, 16 },
+ /* 1515 */ { MAD_F(0x043f8098) /* 0.265503498 */, 16 },
+ /* 1516 */ { MAD_F(0x044075a3) /* 0.265737190 */, 16 },
+ /* 1517 */ { MAD_F(0x04416abc) /* 0.265970933 */, 16 },
+ /* 1518 */ { MAD_F(0x04425fe3) /* 0.266204728 */, 16 },
+ /* 1519 */ { MAD_F(0x04435518) /* 0.266438574 */, 16 },
+
+ /* 1520 */ { MAD_F(0x04444a5a) /* 0.266672472 */, 16 },
+ /* 1521 */ { MAD_F(0x04453fab) /* 0.266906421 */, 16 },
+ /* 1522 */ { MAD_F(0x04463508) /* 0.267140421 */, 16 },
+ /* 1523 */ { MAD_F(0x04472a74) /* 0.267374472 */, 16 },
+ /* 1524 */ { MAD_F(0x04481fee) /* 0.267608575 */, 16 },
+ /* 1525 */ { MAD_F(0x04491575) /* 0.267842729 */, 16 },
+ /* 1526 */ { MAD_F(0x044a0b0a) /* 0.268076934 */, 16 },
+ /* 1527 */ { MAD_F(0x044b00ac) /* 0.268311190 */, 16 },
+ /* 1528 */ { MAD_F(0x044bf65d) /* 0.268545497 */, 16 },
+ /* 1529 */ { MAD_F(0x044cec1b) /* 0.268779856 */, 16 },
+ /* 1530 */ { MAD_F(0x044de1e7) /* 0.269014265 */, 16 },
+ /* 1531 */ { MAD_F(0x044ed7c0) /* 0.269248726 */, 16 },
+ /* 1532 */ { MAD_F(0x044fcda8) /* 0.269483238 */, 16 },
+ /* 1533 */ { MAD_F(0x0450c39c) /* 0.269717800 */, 16 },
+ /* 1534 */ { MAD_F(0x0451b99f) /* 0.269952414 */, 16 },
+ /* 1535 */ { MAD_F(0x0452afaf) /* 0.270187079 */, 16 },
+
+ /* 1536 */ { MAD_F(0x0453a5cd) /* 0.270421794 */, 16 },
+ /* 1537 */ { MAD_F(0x04549bf9) /* 0.270656561 */, 16 },
+ /* 1538 */ { MAD_F(0x04559232) /* 0.270891379 */, 16 },
+ /* 1539 */ { MAD_F(0x04568879) /* 0.271126247 */, 16 },
+ /* 1540 */ { MAD_F(0x04577ece) /* 0.271361166 */, 16 },
+ /* 1541 */ { MAD_F(0x04587530) /* 0.271596136 */, 16 },
+ /* 1542 */ { MAD_F(0x04596ba0) /* 0.271831157 */, 16 },
+ /* 1543 */ { MAD_F(0x045a621e) /* 0.272066229 */, 16 },
+ /* 1544 */ { MAD_F(0x045b58a9) /* 0.272301352 */, 16 },
+ /* 1545 */ { MAD_F(0x045c4f42) /* 0.272536525 */, 16 },
+ /* 1546 */ { MAD_F(0x045d45e9) /* 0.272771749 */, 16 },
+ /* 1547 */ { MAD_F(0x045e3c9d) /* 0.273007024 */, 16 },
+ /* 1548 */ { MAD_F(0x045f335e) /* 0.273242350 */, 16 },
+ /* 1549 */ { MAD_F(0x04602a2e) /* 0.273477726 */, 16 },
+ /* 1550 */ { MAD_F(0x0461210b) /* 0.273713153 */, 16 },
+ /* 1551 */ { MAD_F(0x046217f5) /* 0.273948630 */, 16 },
+
+ /* 1552 */ { MAD_F(0x04630eed) /* 0.274184158 */, 16 },
+ /* 1553 */ { MAD_F(0x046405f3) /* 0.274419737 */, 16 },
+ /* 1554 */ { MAD_F(0x0464fd06) /* 0.274655366 */, 16 },
+ /* 1555 */ { MAD_F(0x0465f427) /* 0.274891046 */, 16 },
+ /* 1556 */ { MAD_F(0x0466eb55) /* 0.275126776 */, 16 },
+ /* 1557 */ { MAD_F(0x0467e291) /* 0.275362557 */, 16 },
+ /* 1558 */ { MAD_F(0x0468d9db) /* 0.275598389 */, 16 },
+ /* 1559 */ { MAD_F(0x0469d132) /* 0.275834270 */, 16 },
+ /* 1560 */ { MAD_F(0x046ac896) /* 0.276070203 */, 16 },
+ /* 1561 */ { MAD_F(0x046bc009) /* 0.276306185 */, 16 },
+ /* 1562 */ { MAD_F(0x046cb788) /* 0.276542218 */, 16 },
+ /* 1563 */ { MAD_F(0x046daf15) /* 0.276778302 */, 16 },
+ /* 1564 */ { MAD_F(0x046ea6b0) /* 0.277014435 */, 16 },
+ /* 1565 */ { MAD_F(0x046f9e58) /* 0.277250619 */, 16 },
+ /* 1566 */ { MAD_F(0x0470960e) /* 0.277486854 */, 16 },
+ /* 1567 */ { MAD_F(0x04718dd1) /* 0.277723139 */, 16 },
+
+ /* 1568 */ { MAD_F(0x047285a2) /* 0.277959474 */, 16 },
+ /* 1569 */ { MAD_F(0x04737d80) /* 0.278195859 */, 16 },
+ /* 1570 */ { MAD_F(0x0474756c) /* 0.278432294 */, 16 },
+ /* 1571 */ { MAD_F(0x04756d65) /* 0.278668780 */, 16 },
+ /* 1572 */ { MAD_F(0x0476656b) /* 0.278905316 */, 16 },
+ /* 1573 */ { MAD_F(0x04775d7f) /* 0.279141902 */, 16 },
+ /* 1574 */ { MAD_F(0x047855a1) /* 0.279378538 */, 16 },
+ /* 1575 */ { MAD_F(0x04794dd0) /* 0.279615224 */, 16 },
+ /* 1576 */ { MAD_F(0x047a460c) /* 0.279851960 */, 16 },
+ /* 1577 */ { MAD_F(0x047b3e56) /* 0.280088747 */, 16 },
+ /* 1578 */ { MAD_F(0x047c36ae) /* 0.280325583 */, 16 },
+ /* 1579 */ { MAD_F(0x047d2f12) /* 0.280562470 */, 16 },
+ /* 1580 */ { MAD_F(0x047e2784) /* 0.280799406 */, 16 },
+ /* 1581 */ { MAD_F(0x047f2004) /* 0.281036393 */, 16 },
+ /* 1582 */ { MAD_F(0x04801891) /* 0.281273429 */, 16 },
+ /* 1583 */ { MAD_F(0x0481112b) /* 0.281510516 */, 16 },
+
+ /* 1584 */ { MAD_F(0x048209d3) /* 0.281747652 */, 16 },
+ /* 1585 */ { MAD_F(0x04830288) /* 0.281984838 */, 16 },
+ /* 1586 */ { MAD_F(0x0483fb4b) /* 0.282222075 */, 16 },
+ /* 1587 */ { MAD_F(0x0484f41b) /* 0.282459361 */, 16 },
+ /* 1588 */ { MAD_F(0x0485ecf8) /* 0.282696697 */, 16 },
+ /* 1589 */ { MAD_F(0x0486e5e3) /* 0.282934082 */, 16 },
+ /* 1590 */ { MAD_F(0x0487dedb) /* 0.283171518 */, 16 },
+ /* 1591 */ { MAD_F(0x0488d7e1) /* 0.283409003 */, 16 },
+ /* 1592 */ { MAD_F(0x0489d0f4) /* 0.283646538 */, 16 },
+ /* 1593 */ { MAD_F(0x048aca14) /* 0.283884123 */, 16 },
+ /* 1594 */ { MAD_F(0x048bc341) /* 0.284121757 */, 16 },
+ /* 1595 */ { MAD_F(0x048cbc7c) /* 0.284359441 */, 16 },
+ /* 1596 */ { MAD_F(0x048db5c4) /* 0.284597175 */, 16 },
+ /* 1597 */ { MAD_F(0x048eaf1a) /* 0.284834959 */, 16 },
+ /* 1598 */ { MAD_F(0x048fa87d) /* 0.285072792 */, 16 },
+ /* 1599 */ { MAD_F(0x0490a1ed) /* 0.285310675 */, 16 },
+
+ /* 1600 */ { MAD_F(0x04919b6a) /* 0.285548607 */, 16 },
+ /* 1601 */ { MAD_F(0x049294f5) /* 0.285786589 */, 16 },
+ /* 1602 */ { MAD_F(0x04938e8d) /* 0.286024621 */, 16 },
+ /* 1603 */ { MAD_F(0x04948833) /* 0.286262702 */, 16 },
+ /* 1604 */ { MAD_F(0x049581e5) /* 0.286500832 */, 16 },
+ /* 1605 */ { MAD_F(0x04967ba5) /* 0.286739012 */, 16 },
+ /* 1606 */ { MAD_F(0x04977573) /* 0.286977242 */, 16 },
+ /* 1607 */ { MAD_F(0x04986f4d) /* 0.287215521 */, 16 },
+ /* 1608 */ { MAD_F(0x04996935) /* 0.287453849 */, 16 },
+ /* 1609 */ { MAD_F(0x049a632a) /* 0.287692227 */, 16 },
+ /* 1610 */ { MAD_F(0x049b5d2c) /* 0.287930654 */, 16 },
+ /* 1611 */ { MAD_F(0x049c573c) /* 0.288169131 */, 16 },
+ /* 1612 */ { MAD_F(0x049d5159) /* 0.288407657 */, 16 },
+ /* 1613 */ { MAD_F(0x049e4b83) /* 0.288646232 */, 16 },
+ /* 1614 */ { MAD_F(0x049f45ba) /* 0.288884857 */, 16 },
+ /* 1615 */ { MAD_F(0x04a03ffe) /* 0.289123530 */, 16 },
+
+ /* 1616 */ { MAD_F(0x04a13a50) /* 0.289362253 */, 16 },
+ /* 1617 */ { MAD_F(0x04a234af) /* 0.289601026 */, 16 },
+ /* 1618 */ { MAD_F(0x04a32f1b) /* 0.289839847 */, 16 },
+ /* 1619 */ { MAD_F(0x04a42995) /* 0.290078718 */, 16 },
+ /* 1620 */ { MAD_F(0x04a5241b) /* 0.290317638 */, 16 },
+ /* 1621 */ { MAD_F(0x04a61eaf) /* 0.290556607 */, 16 },
+ /* 1622 */ { MAD_F(0x04a71950) /* 0.290795626 */, 16 },
+ /* 1623 */ { MAD_F(0x04a813fe) /* 0.291034693 */, 16 },
+ /* 1624 */ { MAD_F(0x04a90eba) /* 0.291273810 */, 16 },
+ /* 1625 */ { MAD_F(0x04aa0982) /* 0.291512975 */, 16 },
+ /* 1626 */ { MAD_F(0x04ab0458) /* 0.291752190 */, 16 },
+ /* 1627 */ { MAD_F(0x04abff3b) /* 0.291991453 */, 16 },
+ /* 1628 */ { MAD_F(0x04acfa2b) /* 0.292230766 */, 16 },
+ /* 1629 */ { MAD_F(0x04adf528) /* 0.292470128 */, 16 },
+ /* 1630 */ { MAD_F(0x04aef032) /* 0.292709539 */, 16 },
+ /* 1631 */ { MAD_F(0x04afeb4a) /* 0.292948998 */, 16 },
+
+ /* 1632 */ { MAD_F(0x04b0e66e) /* 0.293188507 */, 16 },
+ /* 1633 */ { MAD_F(0x04b1e1a0) /* 0.293428065 */, 16 },
+ /* 1634 */ { MAD_F(0x04b2dcdf) /* 0.293667671 */, 16 },
+ /* 1635 */ { MAD_F(0x04b3d82b) /* 0.293907326 */, 16 },
+ /* 1636 */ { MAD_F(0x04b4d384) /* 0.294147031 */, 16 },
+ /* 1637 */ { MAD_F(0x04b5ceea) /* 0.294386784 */, 16 },
+ /* 1638 */ { MAD_F(0x04b6ca5e) /* 0.294626585 */, 16 },
+ /* 1639 */ { MAD_F(0x04b7c5de) /* 0.294866436 */, 16 },
+ /* 1640 */ { MAD_F(0x04b8c16c) /* 0.295106336 */, 16 },
+ /* 1641 */ { MAD_F(0x04b9bd06) /* 0.295346284 */, 16 },
+ /* 1642 */ { MAD_F(0x04bab8ae) /* 0.295586281 */, 16 },
+ /* 1643 */ { MAD_F(0x04bbb463) /* 0.295826327 */, 16 },
+ /* 1644 */ { MAD_F(0x04bcb024) /* 0.296066421 */, 16 },
+ /* 1645 */ { MAD_F(0x04bdabf3) /* 0.296306564 */, 16 },
+ /* 1646 */ { MAD_F(0x04bea7cf) /* 0.296546756 */, 16 },
+ /* 1647 */ { MAD_F(0x04bfa3b8) /* 0.296786996 */, 16 },
+
+ /* 1648 */ { MAD_F(0x04c09faf) /* 0.297027285 */, 16 },
+ /* 1649 */ { MAD_F(0x04c19bb2) /* 0.297267623 */, 16 },
+ /* 1650 */ { MAD_F(0x04c297c2) /* 0.297508009 */, 16 },
+ /* 1651 */ { MAD_F(0x04c393df) /* 0.297748444 */, 16 },
+ /* 1652 */ { MAD_F(0x04c49009) /* 0.297988927 */, 16 },
+ /* 1653 */ { MAD_F(0x04c58c41) /* 0.298229459 */, 16 },
+ /* 1654 */ { MAD_F(0x04c68885) /* 0.298470039 */, 16 },
+ /* 1655 */ { MAD_F(0x04c784d6) /* 0.298710668 */, 16 },
+ /* 1656 */ { MAD_F(0x04c88135) /* 0.298951346 */, 16 },
+ /* 1657 */ { MAD_F(0x04c97da0) /* 0.299192071 */, 16 },
+ /* 1658 */ { MAD_F(0x04ca7a18) /* 0.299432846 */, 16 },
+ /* 1659 */ { MAD_F(0x04cb769e) /* 0.299673668 */, 16 },
+ /* 1660 */ { MAD_F(0x04cc7330) /* 0.299914539 */, 16 },
+ /* 1661 */ { MAD_F(0x04cd6fcf) /* 0.300155459 */, 16 },
+ /* 1662 */ { MAD_F(0x04ce6c7b) /* 0.300396426 */, 16 },
+ /* 1663 */ { MAD_F(0x04cf6935) /* 0.300637443 */, 16 },
+
+ /* 1664 */ { MAD_F(0x04d065fb) /* 0.300878507 */, 16 },
+ /* 1665 */ { MAD_F(0x04d162ce) /* 0.301119620 */, 16 },
+ /* 1666 */ { MAD_F(0x04d25fae) /* 0.301360781 */, 16 },
+ /* 1667 */ { MAD_F(0x04d35c9b) /* 0.301601990 */, 16 },
+ /* 1668 */ { MAD_F(0x04d45995) /* 0.301843247 */, 16 },
+ /* 1669 */ { MAD_F(0x04d5569c) /* 0.302084553 */, 16 },
+ /* 1670 */ { MAD_F(0x04d653b0) /* 0.302325907 */, 16 },
+ /* 1671 */ { MAD_F(0x04d750d1) /* 0.302567309 */, 16 },
+ /* 1672 */ { MAD_F(0x04d84dff) /* 0.302808759 */, 16 },
+ /* 1673 */ { MAD_F(0x04d94b3a) /* 0.303050257 */, 16 },
+ /* 1674 */ { MAD_F(0x04da4881) /* 0.303291804 */, 16 },
+ /* 1675 */ { MAD_F(0x04db45d6) /* 0.303533399 */, 16 },
+ /* 1676 */ { MAD_F(0x04dc4337) /* 0.303775041 */, 16 },
+ /* 1677 */ { MAD_F(0x04dd40a6) /* 0.304016732 */, 16 },
+ /* 1678 */ { MAD_F(0x04de3e21) /* 0.304258471 */, 16 },
+ /* 1679 */ { MAD_F(0x04df3ba9) /* 0.304500257 */, 16 },
+
+ /* 1680 */ { MAD_F(0x04e0393e) /* 0.304742092 */, 16 },
+ /* 1681 */ { MAD_F(0x04e136e0) /* 0.304983975 */, 16 },
+ /* 1682 */ { MAD_F(0x04e2348f) /* 0.305225906 */, 16 },
+ /* 1683 */ { MAD_F(0x04e3324b) /* 0.305467885 */, 16 },
+ /* 1684 */ { MAD_F(0x04e43013) /* 0.305709911 */, 16 },
+ /* 1685 */ { MAD_F(0x04e52de9) /* 0.305951986 */, 16 },
+ /* 1686 */ { MAD_F(0x04e62bcb) /* 0.306194108 */, 16 },
+ /* 1687 */ { MAD_F(0x04e729ba) /* 0.306436279 */, 16 },
+ /* 1688 */ { MAD_F(0x04e827b6) /* 0.306678497 */, 16 },
+ /* 1689 */ { MAD_F(0x04e925bf) /* 0.306920763 */, 16 },
+ /* 1690 */ { MAD_F(0x04ea23d4) /* 0.307163077 */, 16 },
+ /* 1691 */ { MAD_F(0x04eb21f7) /* 0.307405438 */, 16 },
+ /* 1692 */ { MAD_F(0x04ec2026) /* 0.307647848 */, 16 },
+ /* 1693 */ { MAD_F(0x04ed1e62) /* 0.307890305 */, 16 },
+ /* 1694 */ { MAD_F(0x04ee1cab) /* 0.308132810 */, 16 },
+ /* 1695 */ { MAD_F(0x04ef1b01) /* 0.308375362 */, 16 },
+
+ /* 1696 */ { MAD_F(0x04f01963) /* 0.308617963 */, 16 },
+ /* 1697 */ { MAD_F(0x04f117d3) /* 0.308860611 */, 16 },
+ /* 1698 */ { MAD_F(0x04f2164f) /* 0.309103306 */, 16 },
+ /* 1699 */ { MAD_F(0x04f314d8) /* 0.309346050 */, 16 },
+ /* 1700 */ { MAD_F(0x04f4136d) /* 0.309588841 */, 16 },
+ /* 1701 */ { MAD_F(0x04f51210) /* 0.309831679 */, 16 },
+ /* 1702 */ { MAD_F(0x04f610bf) /* 0.310074565 */, 16 },
+ /* 1703 */ { MAD_F(0x04f70f7b) /* 0.310317499 */, 16 },
+ /* 1704 */ { MAD_F(0x04f80e44) /* 0.310560480 */, 16 },
+ /* 1705 */ { MAD_F(0x04f90d19) /* 0.310803509 */, 16 },
+ /* 1706 */ { MAD_F(0x04fa0bfc) /* 0.311046586 */, 16 },
+ /* 1707 */ { MAD_F(0x04fb0aeb) /* 0.311289710 */, 16 },
+ /* 1708 */ { MAD_F(0x04fc09e7) /* 0.311532881 */, 16 },
+ /* 1709 */ { MAD_F(0x04fd08ef) /* 0.311776100 */, 16 },
+ /* 1710 */ { MAD_F(0x04fe0805) /* 0.312019366 */, 16 },
+ /* 1711 */ { MAD_F(0x04ff0727) /* 0.312262680 */, 16 },
+
+ /* 1712 */ { MAD_F(0x05000655) /* 0.312506041 */, 16 },
+ /* 1713 */ { MAD_F(0x05010591) /* 0.312749449 */, 16 },
+ /* 1714 */ { MAD_F(0x050204d9) /* 0.312992905 */, 16 },
+ /* 1715 */ { MAD_F(0x0503042e) /* 0.313236408 */, 16 },
+ /* 1716 */ { MAD_F(0x0504038f) /* 0.313479959 */, 16 },
+ /* 1717 */ { MAD_F(0x050502fe) /* 0.313723556 */, 16 },
+ /* 1718 */ { MAD_F(0x05060279) /* 0.313967202 */, 16 },
+ /* 1719 */ { MAD_F(0x05070200) /* 0.314210894 */, 16 },
+ /* 1720 */ { MAD_F(0x05080195) /* 0.314454634 */, 16 },
+ /* 1721 */ { MAD_F(0x05090136) /* 0.314698420 */, 16 },
+ /* 1722 */ { MAD_F(0x050a00e3) /* 0.314942255 */, 16 },
+ /* 1723 */ { MAD_F(0x050b009e) /* 0.315186136 */, 16 },
+ /* 1724 */ { MAD_F(0x050c0065) /* 0.315430064 */, 16 },
+ /* 1725 */ { MAD_F(0x050d0039) /* 0.315674040 */, 16 },
+ /* 1726 */ { MAD_F(0x050e0019) /* 0.315918063 */, 16 },
+ /* 1727 */ { MAD_F(0x050f0006) /* 0.316162133 */, 16 },
+
+ /* 1728 */ { MAD_F(0x05100000) /* 0.316406250 */, 16 },
+ /* 1729 */ { MAD_F(0x05110006) /* 0.316650414 */, 16 },
+ /* 1730 */ { MAD_F(0x05120019) /* 0.316894625 */, 16 },
+ /* 1731 */ { MAD_F(0x05130039) /* 0.317138884 */, 16 },
+ /* 1732 */ { MAD_F(0x05140065) /* 0.317383189 */, 16 },
+ /* 1733 */ { MAD_F(0x0515009e) /* 0.317627541 */, 16 },
+ /* 1734 */ { MAD_F(0x051600e3) /* 0.317871941 */, 16 },
+ /* 1735 */ { MAD_F(0x05170135) /* 0.318116387 */, 16 },
+ /* 1736 */ { MAD_F(0x05180194) /* 0.318360880 */, 16 },
+ /* 1737 */ { MAD_F(0x051901ff) /* 0.318605421 */, 16 },
+ /* 1738 */ { MAD_F(0x051a0277) /* 0.318850008 */, 16 },
+ /* 1739 */ { MAD_F(0x051b02fc) /* 0.319094642 */, 16 },
+ /* 1740 */ { MAD_F(0x051c038d) /* 0.319339323 */, 16 },
+ /* 1741 */ { MAD_F(0x051d042a) /* 0.319584051 */, 16 },
+ /* 1742 */ { MAD_F(0x051e04d4) /* 0.319828826 */, 16 },
+ /* 1743 */ { MAD_F(0x051f058b) /* 0.320073647 */, 16 },
+
+ /* 1744 */ { MAD_F(0x0520064f) /* 0.320318516 */, 16 },
+ /* 1745 */ { MAD_F(0x0521071f) /* 0.320563431 */, 16 },
+ /* 1746 */ { MAD_F(0x052207fb) /* 0.320808393 */, 16 },
+ /* 1747 */ { MAD_F(0x052308e4) /* 0.321053402 */, 16 },
+ /* 1748 */ { MAD_F(0x052409da) /* 0.321298457 */, 16 },
+ /* 1749 */ { MAD_F(0x05250adc) /* 0.321543560 */, 16 },
+ /* 1750 */ { MAD_F(0x05260bea) /* 0.321788709 */, 16 },
+ /* 1751 */ { MAD_F(0x05270d06) /* 0.322033904 */, 16 },
+ /* 1752 */ { MAD_F(0x05280e2d) /* 0.322279147 */, 16 },
+ /* 1753 */ { MAD_F(0x05290f62) /* 0.322524436 */, 16 },
+ /* 1754 */ { MAD_F(0x052a10a3) /* 0.322769771 */, 16 },
+ /* 1755 */ { MAD_F(0x052b11f0) /* 0.323015154 */, 16 },
+ /* 1756 */ { MAD_F(0x052c134a) /* 0.323260583 */, 16 },
+ /* 1757 */ { MAD_F(0x052d14b0) /* 0.323506058 */, 16 },
+ /* 1758 */ { MAD_F(0x052e1623) /* 0.323751580 */, 16 },
+ /* 1759 */ { MAD_F(0x052f17a2) /* 0.323997149 */, 16 },
+
+ /* 1760 */ { MAD_F(0x0530192e) /* 0.324242764 */, 16 },
+ /* 1761 */ { MAD_F(0x05311ac6) /* 0.324488426 */, 16 },
+ /* 1762 */ { MAD_F(0x05321c6b) /* 0.324734134 */, 16 },
+ /* 1763 */ { MAD_F(0x05331e1c) /* 0.324979889 */, 16 },
+ /* 1764 */ { MAD_F(0x05341fda) /* 0.325225690 */, 16 },
+ /* 1765 */ { MAD_F(0x053521a4) /* 0.325471538 */, 16 },
+ /* 1766 */ { MAD_F(0x0536237b) /* 0.325717432 */, 16 },
+ /* 1767 */ { MAD_F(0x0537255e) /* 0.325963372 */, 16 },
+ /* 1768 */ { MAD_F(0x0538274e) /* 0.326209359 */, 16 },
+ /* 1769 */ { MAD_F(0x0539294a) /* 0.326455392 */, 16 },
+ /* 1770 */ { MAD_F(0x053a2b52) /* 0.326701472 */, 16 },
+ /* 1771 */ { MAD_F(0x053b2d67) /* 0.326947598 */, 16 },
+ /* 1772 */ { MAD_F(0x053c2f89) /* 0.327193770 */, 16 },
+ /* 1773 */ { MAD_F(0x053d31b6) /* 0.327439989 */, 16 },
+ /* 1774 */ { MAD_F(0x053e33f1) /* 0.327686254 */, 16 },
+ /* 1775 */ { MAD_F(0x053f3637) /* 0.327932565 */, 16 },
+
+ /* 1776 */ { MAD_F(0x0540388a) /* 0.328178922 */, 16 },
+ /* 1777 */ { MAD_F(0x05413aea) /* 0.328425326 */, 16 },
+ /* 1778 */ { MAD_F(0x05423d56) /* 0.328671776 */, 16 },
+ /* 1779 */ { MAD_F(0x05433fce) /* 0.328918272 */, 16 },
+ /* 1780 */ { MAD_F(0x05444253) /* 0.329164814 */, 16 },
+ /* 1781 */ { MAD_F(0x054544e4) /* 0.329411403 */, 16 },
+ /* 1782 */ { MAD_F(0x05464781) /* 0.329658038 */, 16 },
+ /* 1783 */ { MAD_F(0x05474a2b) /* 0.329904718 */, 16 },
+ /* 1784 */ { MAD_F(0x05484ce2) /* 0.330151445 */, 16 },
+ /* 1785 */ { MAD_F(0x05494fa4) /* 0.330398218 */, 16 },
+ /* 1786 */ { MAD_F(0x054a5273) /* 0.330645037 */, 16 },
+ /* 1787 */ { MAD_F(0x054b554e) /* 0.330891903 */, 16 },
+ /* 1788 */ { MAD_F(0x054c5836) /* 0.331138814 */, 16 },
+ /* 1789 */ { MAD_F(0x054d5b2a) /* 0.331385771 */, 16 },
+ /* 1790 */ { MAD_F(0x054e5e2b) /* 0.331632774 */, 16 },
+ /* 1791 */ { MAD_F(0x054f6138) /* 0.331879824 */, 16 },
+
+ /* 1792 */ { MAD_F(0x05506451) /* 0.332126919 */, 16 },
+ /* 1793 */ { MAD_F(0x05516776) /* 0.332374060 */, 16 },
+ /* 1794 */ { MAD_F(0x05526aa8) /* 0.332621247 */, 16 },
+ /* 1795 */ { MAD_F(0x05536de6) /* 0.332868480 */, 16 },
+ /* 1796 */ { MAD_F(0x05547131) /* 0.333115759 */, 16 },
+ /* 1797 */ { MAD_F(0x05557487) /* 0.333363084 */, 16 },
+ /* 1798 */ { MAD_F(0x055677ea) /* 0.333610455 */, 16 },
+ /* 1799 */ { MAD_F(0x05577b5a) /* 0.333857872 */, 16 },
+ /* 1800 */ { MAD_F(0x05587ed5) /* 0.334105334 */, 16 },
+ /* 1801 */ { MAD_F(0x0559825e) /* 0.334352843 */, 16 },
+ /* 1802 */ { MAD_F(0x055a85f2) /* 0.334600397 */, 16 },
+ /* 1803 */ { MAD_F(0x055b8992) /* 0.334847997 */, 16 },
+ /* 1804 */ { MAD_F(0x055c8d3f) /* 0.335095642 */, 16 },
+ /* 1805 */ { MAD_F(0x055d90f9) /* 0.335343334 */, 16 },
+ /* 1806 */ { MAD_F(0x055e94be) /* 0.335591071 */, 16 },
+ /* 1807 */ { MAD_F(0x055f9890) /* 0.335838854 */, 16 },
+
+ /* 1808 */ { MAD_F(0x05609c6e) /* 0.336086683 */, 16 },
+ /* 1809 */ { MAD_F(0x0561a058) /* 0.336334557 */, 16 },
+ /* 1810 */ { MAD_F(0x0562a44f) /* 0.336582477 */, 16 },
+ /* 1811 */ { MAD_F(0x0563a851) /* 0.336830443 */, 16 },
+ /* 1812 */ { MAD_F(0x0564ac60) /* 0.337078454 */, 16 },
+ /* 1813 */ { MAD_F(0x0565b07c) /* 0.337326511 */, 16 },
+ /* 1814 */ { MAD_F(0x0566b4a3) /* 0.337574614 */, 16 },
+ /* 1815 */ { MAD_F(0x0567b8d7) /* 0.337822762 */, 16 },
+ /* 1816 */ { MAD_F(0x0568bd17) /* 0.338070956 */, 16 },
+ /* 1817 */ { MAD_F(0x0569c163) /* 0.338319195 */, 16 },
+ /* 1818 */ { MAD_F(0x056ac5bc) /* 0.338567480 */, 16 },
+ /* 1819 */ { MAD_F(0x056bca20) /* 0.338815811 */, 16 },
+ /* 1820 */ { MAD_F(0x056cce91) /* 0.339064186 */, 16 },
+ /* 1821 */ { MAD_F(0x056dd30e) /* 0.339312608 */, 16 },
+ /* 1822 */ { MAD_F(0x056ed798) /* 0.339561075 */, 16 },
+ /* 1823 */ { MAD_F(0x056fdc2d) /* 0.339809587 */, 16 },
+
+ /* 1824 */ { MAD_F(0x0570e0cf) /* 0.340058145 */, 16 },
+ /* 1825 */ { MAD_F(0x0571e57d) /* 0.340306748 */, 16 },
+ /* 1826 */ { MAD_F(0x0572ea37) /* 0.340555397 */, 16 },
+ /* 1827 */ { MAD_F(0x0573eefd) /* 0.340804091 */, 16 },
+ /* 1828 */ { MAD_F(0x0574f3d0) /* 0.341052830 */, 16 },
+ /* 1829 */ { MAD_F(0x0575f8ae) /* 0.341301615 */, 16 },
+ /* 1830 */ { MAD_F(0x0576fd99) /* 0.341550445 */, 16 },
+ /* 1831 */ { MAD_F(0x05780290) /* 0.341799321 */, 16 },
+ /* 1832 */ { MAD_F(0x05790793) /* 0.342048241 */, 16 },
+ /* 1833 */ { MAD_F(0x057a0ca3) /* 0.342297207 */, 16 },
+ /* 1834 */ { MAD_F(0x057b11be) /* 0.342546219 */, 16 },
+ /* 1835 */ { MAD_F(0x057c16e6) /* 0.342795275 */, 16 },
+ /* 1836 */ { MAD_F(0x057d1c1a) /* 0.343044377 */, 16 },
+ /* 1837 */ { MAD_F(0x057e2159) /* 0.343293524 */, 16 },
+ /* 1838 */ { MAD_F(0x057f26a6) /* 0.343542717 */, 16 },
+ /* 1839 */ { MAD_F(0x05802bfe) /* 0.343791954 */, 16 },
+
+ /* 1840 */ { MAD_F(0x05813162) /* 0.344041237 */, 16 },
+ /* 1841 */ { MAD_F(0x058236d2) /* 0.344290564 */, 16 },
+ /* 1842 */ { MAD_F(0x05833c4f) /* 0.344539937 */, 16 },
+ /* 1843 */ { MAD_F(0x058441d8) /* 0.344789356 */, 16 },
+ /* 1844 */ { MAD_F(0x0585476c) /* 0.345038819 */, 16 },
+ /* 1845 */ { MAD_F(0x05864d0d) /* 0.345288327 */, 16 },
+ /* 1846 */ { MAD_F(0x058752ba) /* 0.345537880 */, 16 },
+ /* 1847 */ { MAD_F(0x05885873) /* 0.345787479 */, 16 },
+ /* 1848 */ { MAD_F(0x05895e39) /* 0.346037122 */, 16 },
+ /* 1849 */ { MAD_F(0x058a640a) /* 0.346286811 */, 16 },
+ /* 1850 */ { MAD_F(0x058b69e7) /* 0.346536545 */, 16 },
+ /* 1851 */ { MAD_F(0x058c6fd1) /* 0.346786323 */, 16 },
+ /* 1852 */ { MAD_F(0x058d75c6) /* 0.347036147 */, 16 },
+ /* 1853 */ { MAD_F(0x058e7bc8) /* 0.347286015 */, 16 },
+ /* 1854 */ { MAD_F(0x058f81d5) /* 0.347535929 */, 16 },
+ /* 1855 */ { MAD_F(0x059087ef) /* 0.347785887 */, 16 },
+
+ /* 1856 */ { MAD_F(0x05918e15) /* 0.348035890 */, 16 },
+ /* 1857 */ { MAD_F(0x05929447) /* 0.348285939 */, 16 },
+ /* 1858 */ { MAD_F(0x05939a84) /* 0.348536032 */, 16 },
+ /* 1859 */ { MAD_F(0x0594a0ce) /* 0.348786170 */, 16 },
+ /* 1860 */ { MAD_F(0x0595a724) /* 0.349036353 */, 16 },
+ /* 1861 */ { MAD_F(0x0596ad86) /* 0.349286580 */, 16 },
+ /* 1862 */ { MAD_F(0x0597b3f4) /* 0.349536853 */, 16 },
+ /* 1863 */ { MAD_F(0x0598ba6e) /* 0.349787170 */, 16 },
+ /* 1864 */ { MAD_F(0x0599c0f4) /* 0.350037532 */, 16 },
+ /* 1865 */ { MAD_F(0x059ac786) /* 0.350287939 */, 16 },
+ /* 1866 */ { MAD_F(0x059bce25) /* 0.350538391 */, 16 },
+ /* 1867 */ { MAD_F(0x059cd4cf) /* 0.350788887 */, 16 },
+ /* 1868 */ { MAD_F(0x059ddb85) /* 0.351039428 */, 16 },
+ /* 1869 */ { MAD_F(0x059ee247) /* 0.351290014 */, 16 },
+ /* 1870 */ { MAD_F(0x059fe915) /* 0.351540645 */, 16 },
+ /* 1871 */ { MAD_F(0x05a0efef) /* 0.351791320 */, 16 },
+
+ /* 1872 */ { MAD_F(0x05a1f6d5) /* 0.352042040 */, 16 },
+ /* 1873 */ { MAD_F(0x05a2fdc7) /* 0.352292804 */, 16 },
+ /* 1874 */ { MAD_F(0x05a404c5) /* 0.352543613 */, 16 },
+ /* 1875 */ { MAD_F(0x05a50bcf) /* 0.352794467 */, 16 },
+ /* 1876 */ { MAD_F(0x05a612e5) /* 0.353045365 */, 16 },
+ /* 1877 */ { MAD_F(0x05a71a07) /* 0.353296308 */, 16 },
+ /* 1878 */ { MAD_F(0x05a82135) /* 0.353547296 */, 16 },
+ /* 1879 */ { MAD_F(0x05a9286f) /* 0.353798328 */, 16 },
+ /* 1880 */ { MAD_F(0x05aa2fb5) /* 0.354049405 */, 16 },
+ /* 1881 */ { MAD_F(0x05ab3707) /* 0.354300526 */, 16 },
+ /* 1882 */ { MAD_F(0x05ac3e65) /* 0.354551691 */, 16 },
+ /* 1883 */ { MAD_F(0x05ad45ce) /* 0.354802901 */, 16 },
+ /* 1884 */ { MAD_F(0x05ae4d44) /* 0.355054156 */, 16 },
+ /* 1885 */ { MAD_F(0x05af54c6) /* 0.355305455 */, 16 },
+ /* 1886 */ { MAD_F(0x05b05c53) /* 0.355556799 */, 16 },
+ /* 1887 */ { MAD_F(0x05b163ed) /* 0.355808187 */, 16 },
+
+ /* 1888 */ { MAD_F(0x05b26b92) /* 0.356059619 */, 16 },
+ /* 1889 */ { MAD_F(0x05b37343) /* 0.356311096 */, 16 },
+ /* 1890 */ { MAD_F(0x05b47b00) /* 0.356562617 */, 16 },
+ /* 1891 */ { MAD_F(0x05b582c9) /* 0.356814182 */, 16 },
+ /* 1892 */ { MAD_F(0x05b68a9e) /* 0.357065792 */, 16 },
+ /* 1893 */ { MAD_F(0x05b7927f) /* 0.357317446 */, 16 },
+ /* 1894 */ { MAD_F(0x05b89a6c) /* 0.357569145 */, 16 },
+ /* 1895 */ { MAD_F(0x05b9a265) /* 0.357820887 */, 16 },
+ /* 1896 */ { MAD_F(0x05baaa69) /* 0.358072674 */, 16 },
+ /* 1897 */ { MAD_F(0x05bbb27a) /* 0.358324506 */, 16 },
+ /* 1898 */ { MAD_F(0x05bcba96) /* 0.358576381 */, 16 },
+ /* 1899 */ { MAD_F(0x05bdc2be) /* 0.358828301 */, 16 },
+ /* 1900 */ { MAD_F(0x05becaf2) /* 0.359080265 */, 16 },
+ /* 1901 */ { MAD_F(0x05bfd332) /* 0.359332273 */, 16 },
+ /* 1902 */ { MAD_F(0x05c0db7e) /* 0.359584326 */, 16 },
+ /* 1903 */ { MAD_F(0x05c1e3d6) /* 0.359836423 */, 16 },
+
+ /* 1904 */ { MAD_F(0x05c2ec39) /* 0.360088563 */, 16 },
+ /* 1905 */ { MAD_F(0x05c3f4a9) /* 0.360340748 */, 16 },
+ /* 1906 */ { MAD_F(0x05c4fd24) /* 0.360592977 */, 16 },
+ /* 1907 */ { MAD_F(0x05c605ab) /* 0.360845251 */, 16 },
+ /* 1908 */ { MAD_F(0x05c70e3e) /* 0.361097568 */, 16 },
+ /* 1909 */ { MAD_F(0x05c816dd) /* 0.361349929 */, 16 },
+ /* 1910 */ { MAD_F(0x05c91f87) /* 0.361602335 */, 16 },
+ /* 1911 */ { MAD_F(0x05ca283e) /* 0.361854784 */, 16 },
+ /* 1912 */ { MAD_F(0x05cb3100) /* 0.362107278 */, 16 },
+ /* 1913 */ { MAD_F(0x05cc39ce) /* 0.362359815 */, 16 },
+ /* 1914 */ { MAD_F(0x05cd42a8) /* 0.362612397 */, 16 },
+ /* 1915 */ { MAD_F(0x05ce4b8d) /* 0.362865022 */, 16 },
+ /* 1916 */ { MAD_F(0x05cf547f) /* 0.363117692 */, 16 },
+ /* 1917 */ { MAD_F(0x05d05d7c) /* 0.363370405 */, 16 },
+ /* 1918 */ { MAD_F(0x05d16685) /* 0.363623163 */, 16 },
+ /* 1919 */ { MAD_F(0x05d26f9a) /* 0.363875964 */, 16 },
+
+ /* 1920 */ { MAD_F(0x05d378bb) /* 0.364128809 */, 16 },
+ /* 1921 */ { MAD_F(0x05d481e7) /* 0.364381698 */, 16 },
+ /* 1922 */ { MAD_F(0x05d58b1f) /* 0.364634632 */, 16 },
+ /* 1923 */ { MAD_F(0x05d69463) /* 0.364887608 */, 16 },
+ /* 1924 */ { MAD_F(0x05d79db3) /* 0.365140629 */, 16 },
+ /* 1925 */ { MAD_F(0x05d8a70f) /* 0.365393694 */, 16 },
+ /* 1926 */ { MAD_F(0x05d9b076) /* 0.365646802 */, 16 },
+ /* 1927 */ { MAD_F(0x05dab9e9) /* 0.365899955 */, 16 },
+ /* 1928 */ { MAD_F(0x05dbc368) /* 0.366153151 */, 16 },
+ /* 1929 */ { MAD_F(0x05dcccf2) /* 0.366406390 */, 16 },
+ /* 1930 */ { MAD_F(0x05ddd689) /* 0.366659674 */, 16 },
+ /* 1931 */ { MAD_F(0x05dee02b) /* 0.366913001 */, 16 },
+ /* 1932 */ { MAD_F(0x05dfe9d8) /* 0.367166372 */, 16 },
+ /* 1933 */ { MAD_F(0x05e0f392) /* 0.367419787 */, 16 },
+ /* 1934 */ { MAD_F(0x05e1fd57) /* 0.367673246 */, 16 },
+ /* 1935 */ { MAD_F(0x05e30728) /* 0.367926748 */, 16 },
+
+ /* 1936 */ { MAD_F(0x05e41105) /* 0.368180294 */, 16 },
+ /* 1937 */ { MAD_F(0x05e51aed) /* 0.368433883 */, 16 },
+ /* 1938 */ { MAD_F(0x05e624e1) /* 0.368687517 */, 16 },
+ /* 1939 */ { MAD_F(0x05e72ee1) /* 0.368941193 */, 16 },
+ /* 1940 */ { MAD_F(0x05e838ed) /* 0.369194914 */, 16 },
+ /* 1941 */ { MAD_F(0x05e94304) /* 0.369448678 */, 16 },
+ /* 1942 */ { MAD_F(0x05ea4d27) /* 0.369702485 */, 16 },
+ /* 1943 */ { MAD_F(0x05eb5756) /* 0.369956336 */, 16 },
+ /* 1944 */ { MAD_F(0x05ec6190) /* 0.370210231 */, 16 },
+ /* 1945 */ { MAD_F(0x05ed6bd6) /* 0.370464169 */, 16 },
+ /* 1946 */ { MAD_F(0x05ee7628) /* 0.370718151 */, 16 },
+ /* 1947 */ { MAD_F(0x05ef8085) /* 0.370972177 */, 16 },
+ /* 1948 */ { MAD_F(0x05f08aee) /* 0.371226245 */, 16 },
+ /* 1949 */ { MAD_F(0x05f19563) /* 0.371480358 */, 16 },
+ /* 1950 */ { MAD_F(0x05f29fe3) /* 0.371734513 */, 16 },
+ /* 1951 */ { MAD_F(0x05f3aa6f) /* 0.371988712 */, 16 },
+
+ /* 1952 */ { MAD_F(0x05f4b507) /* 0.372242955 */, 16 },
+ /* 1953 */ { MAD_F(0x05f5bfab) /* 0.372497241 */, 16 },
+ /* 1954 */ { MAD_F(0x05f6ca5a) /* 0.372751570 */, 16 },
+ /* 1955 */ { MAD_F(0x05f7d514) /* 0.373005943 */, 16 },
+ /* 1956 */ { MAD_F(0x05f8dfdb) /* 0.373260359 */, 16 },
+ /* 1957 */ { MAD_F(0x05f9eaad) /* 0.373514819 */, 16 },
+ /* 1958 */ { MAD_F(0x05faf58a) /* 0.373769322 */, 16 },
+ /* 1959 */ { MAD_F(0x05fc0073) /* 0.374023868 */, 16 },
+ /* 1960 */ { MAD_F(0x05fd0b68) /* 0.374278458 */, 16 },
+ /* 1961 */ { MAD_F(0x05fe1669) /* 0.374533091 */, 16 },
+ /* 1962 */ { MAD_F(0x05ff2175) /* 0.374787767 */, 16 },
+ /* 1963 */ { MAD_F(0x06002c8d) /* 0.375042486 */, 16 },
+ /* 1964 */ { MAD_F(0x060137b0) /* 0.375297249 */, 16 },
+ /* 1965 */ { MAD_F(0x060242df) /* 0.375552055 */, 16 },
+ /* 1966 */ { MAD_F(0x06034e19) /* 0.375806904 */, 16 },
+ /* 1967 */ { MAD_F(0x0604595f) /* 0.376061796 */, 16 },
+
+ /* 1968 */ { MAD_F(0x060564b1) /* 0.376316732 */, 16 },
+ /* 1969 */ { MAD_F(0x0606700f) /* 0.376571710 */, 16 },
+ /* 1970 */ { MAD_F(0x06077b77) /* 0.376826732 */, 16 },
+ /* 1971 */ { MAD_F(0x060886ec) /* 0.377081797 */, 16 },
+ /* 1972 */ { MAD_F(0x0609926c) /* 0.377336905 */, 16 },
+ /* 1973 */ { MAD_F(0x060a9df8) /* 0.377592057 */, 16 },
+ /* 1974 */ { MAD_F(0x060ba98f) /* 0.377847251 */, 16 },
+ /* 1975 */ { MAD_F(0x060cb532) /* 0.378102489 */, 16 },
+ /* 1976 */ { MAD_F(0x060dc0e0) /* 0.378357769 */, 16 },
+ /* 1977 */ { MAD_F(0x060ecc9a) /* 0.378613093 */, 16 },
+ /* 1978 */ { MAD_F(0x060fd860) /* 0.378868460 */, 16 },
+ /* 1979 */ { MAD_F(0x0610e431) /* 0.379123870 */, 16 },
+ /* 1980 */ { MAD_F(0x0611f00d) /* 0.379379322 */, 16 },
+ /* 1981 */ { MAD_F(0x0612fbf5) /* 0.379634818 */, 16 },
+ /* 1982 */ { MAD_F(0x061407e9) /* 0.379890357 */, 16 },
+ /* 1983 */ { MAD_F(0x061513e8) /* 0.380145939 */, 16 },
+
+ /* 1984 */ { MAD_F(0x06161ff3) /* 0.380401563 */, 16 },
+ /* 1985 */ { MAD_F(0x06172c09) /* 0.380657231 */, 16 },
+ /* 1986 */ { MAD_F(0x0618382b) /* 0.380912942 */, 16 },
+ /* 1987 */ { MAD_F(0x06194458) /* 0.381168695 */, 16 },
+ /* 1988 */ { MAD_F(0x061a5091) /* 0.381424492 */, 16 },
+ /* 1989 */ { MAD_F(0x061b5cd5) /* 0.381680331 */, 16 },
+ /* 1990 */ { MAD_F(0x061c6925) /* 0.381936213 */, 16 },
+ /* 1991 */ { MAD_F(0x061d7581) /* 0.382192138 */, 16 },
+ /* 1992 */ { MAD_F(0x061e81e8) /* 0.382448106 */, 16 },
+ /* 1993 */ { MAD_F(0x061f8e5a) /* 0.382704117 */, 16 },
+ /* 1994 */ { MAD_F(0x06209ad8) /* 0.382960171 */, 16 },
+ /* 1995 */ { MAD_F(0x0621a761) /* 0.383216267 */, 16 },
+ /* 1996 */ { MAD_F(0x0622b3f6) /* 0.383472406 */, 16 },
+ /* 1997 */ { MAD_F(0x0623c096) /* 0.383728588 */, 16 },
+ /* 1998 */ { MAD_F(0x0624cd42) /* 0.383984813 */, 16 },
+ /* 1999 */ { MAD_F(0x0625d9f9) /* 0.384241080 */, 16 },
+
+ /* 2000 */ { MAD_F(0x0626e6bc) /* 0.384497391 */, 16 },
+ /* 2001 */ { MAD_F(0x0627f38a) /* 0.384753744 */, 16 },
+ /* 2002 */ { MAD_F(0x06290064) /* 0.385010139 */, 16 },
+ /* 2003 */ { MAD_F(0x062a0d49) /* 0.385266578 */, 16 },
+ /* 2004 */ { MAD_F(0x062b1a3a) /* 0.385523059 */, 16 },
+ /* 2005 */ { MAD_F(0x062c2736) /* 0.385779582 */, 16 },
+ /* 2006 */ { MAD_F(0x062d343d) /* 0.386036149 */, 16 },
+ /* 2007 */ { MAD_F(0x062e4150) /* 0.386292758 */, 16 },
+ /* 2008 */ { MAD_F(0x062f4e6f) /* 0.386549409 */, 16 },
+ /* 2009 */ { MAD_F(0x06305b99) /* 0.386806104 */, 16 },
+ /* 2010 */ { MAD_F(0x063168ce) /* 0.387062840 */, 16 },
+ /* 2011 */ { MAD_F(0x0632760f) /* 0.387319620 */, 16 },
+ /* 2012 */ { MAD_F(0x0633835b) /* 0.387576442 */, 16 },
+ /* 2013 */ { MAD_F(0x063490b2) /* 0.387833306 */, 16 },
+ /* 2014 */ { MAD_F(0x06359e15) /* 0.388090213 */, 16 },
+ /* 2015 */ { MAD_F(0x0636ab83) /* 0.388347163 */, 16 },
+
+ /* 2016 */ { MAD_F(0x0637b8fd) /* 0.388604155 */, 16 },
+ /* 2017 */ { MAD_F(0x0638c682) /* 0.388861190 */, 16 },
+ /* 2018 */ { MAD_F(0x0639d413) /* 0.389118267 */, 16 },
+ /* 2019 */ { MAD_F(0x063ae1af) /* 0.389375386 */, 16 },
+ /* 2020 */ { MAD_F(0x063bef56) /* 0.389632548 */, 16 },
+ /* 2021 */ { MAD_F(0x063cfd09) /* 0.389889752 */, 16 },
+ /* 2022 */ { MAD_F(0x063e0ac7) /* 0.390146999 */, 16 },
+ /* 2023 */ { MAD_F(0x063f1891) /* 0.390404289 */, 16 },
+ /* 2024 */ { MAD_F(0x06402666) /* 0.390661620 */, 16 },
+ /* 2025 */ { MAD_F(0x06413446) /* 0.390918994 */, 16 },
+ /* 2026 */ { MAD_F(0x06424232) /* 0.391176411 */, 16 },
+ /* 2027 */ { MAD_F(0x06435029) /* 0.391433869 */, 16 },
+ /* 2028 */ { MAD_F(0x06445e2b) /* 0.391691371 */, 16 },
+ /* 2029 */ { MAD_F(0x06456c39) /* 0.391948914 */, 16 },
+ /* 2030 */ { MAD_F(0x06467a52) /* 0.392206500 */, 16 },
+ /* 2031 */ { MAD_F(0x06478877) /* 0.392464128 */, 16 },
+
+ /* 2032 */ { MAD_F(0x064896a7) /* 0.392721798 */, 16 },
+ /* 2033 */ { MAD_F(0x0649a4e2) /* 0.392979511 */, 16 },
+ /* 2034 */ { MAD_F(0x064ab328) /* 0.393237266 */, 16 },
+ /* 2035 */ { MAD_F(0x064bc17a) /* 0.393495063 */, 16 },
+ /* 2036 */ { MAD_F(0x064ccfd8) /* 0.393752902 */, 16 },
+ /* 2037 */ { MAD_F(0x064dde40) /* 0.394010784 */, 16 },
+ /* 2038 */ { MAD_F(0x064eecb4) /* 0.394268707 */, 16 },
+ /* 2039 */ { MAD_F(0x064ffb33) /* 0.394526673 */, 16 },
+ /* 2040 */ { MAD_F(0x065109be) /* 0.394784681 */, 16 },
+ /* 2041 */ { MAD_F(0x06521854) /* 0.395042732 */, 16 },
+ /* 2042 */ { MAD_F(0x065326f5) /* 0.395300824 */, 16 },
+ /* 2043 */ { MAD_F(0x065435a1) /* 0.395558959 */, 16 },
+ /* 2044 */ { MAD_F(0x06554459) /* 0.395817135 */, 16 },
+ /* 2045 */ { MAD_F(0x0656531c) /* 0.396075354 */, 16 },
+ /* 2046 */ { MAD_F(0x065761ea) /* 0.396333615 */, 16 },
+ /* 2047 */ { MAD_F(0x065870c4) /* 0.396591918 */, 16 },
+
+ /* 2048 */ { MAD_F(0x06597fa9) /* 0.396850263 */, 16 },
+ /* 2049 */ { MAD_F(0x065a8e99) /* 0.397108650 */, 16 },
+ /* 2050 */ { MAD_F(0x065b9d95) /* 0.397367079 */, 16 },
+ /* 2051 */ { MAD_F(0x065cac9c) /* 0.397625550 */, 16 },
+ /* 2052 */ { MAD_F(0x065dbbae) /* 0.397884063 */, 16 },
+ /* 2053 */ { MAD_F(0x065ecacb) /* 0.398142619 */, 16 },
+ /* 2054 */ { MAD_F(0x065fd9f4) /* 0.398401216 */, 16 },
+ /* 2055 */ { MAD_F(0x0660e928) /* 0.398659855 */, 16 },
+ /* 2056 */ { MAD_F(0x0661f867) /* 0.398918536 */, 16 },
+ /* 2057 */ { MAD_F(0x066307b1) /* 0.399177259 */, 16 },
+ /* 2058 */ { MAD_F(0x06641707) /* 0.399436024 */, 16 },
+ /* 2059 */ { MAD_F(0x06652668) /* 0.399694831 */, 16 },
+ /* 2060 */ { MAD_F(0x066635d4) /* 0.399953679 */, 16 },
+ /* 2061 */ { MAD_F(0x0667454c) /* 0.400212570 */, 16 },
+ /* 2062 */ { MAD_F(0x066854ce) /* 0.400471503 */, 16 },
+ /* 2063 */ { MAD_F(0x0669645c) /* 0.400730477 */, 16 },
+
+ /* 2064 */ { MAD_F(0x066a73f5) /* 0.400989493 */, 16 },
+ /* 2065 */ { MAD_F(0x066b839a) /* 0.401248551 */, 16 },
+ /* 2066 */ { MAD_F(0x066c9349) /* 0.401507651 */, 16 },
+ /* 2067 */ { MAD_F(0x066da304) /* 0.401766793 */, 16 },
+ /* 2068 */ { MAD_F(0x066eb2ca) /* 0.402025976 */, 16 },
+ /* 2069 */ { MAD_F(0x066fc29b) /* 0.402285202 */, 16 },
+ /* 2070 */ { MAD_F(0x0670d278) /* 0.402544469 */, 16 },
+ /* 2071 */ { MAD_F(0x0671e25f) /* 0.402803777 */, 16 },
+ /* 2072 */ { MAD_F(0x0672f252) /* 0.403063128 */, 16 },
+ /* 2073 */ { MAD_F(0x06740250) /* 0.403322520 */, 16 },
+ /* 2074 */ { MAD_F(0x0675125a) /* 0.403581954 */, 16 },
+ /* 2075 */ { MAD_F(0x0676226e) /* 0.403841430 */, 16 },
+ /* 2076 */ { MAD_F(0x0677328e) /* 0.404100947 */, 16 },
+ /* 2077 */ { MAD_F(0x067842b9) /* 0.404360506 */, 16 },
+ /* 2078 */ { MAD_F(0x067952ef) /* 0.404620107 */, 16 },
+ /* 2079 */ { MAD_F(0x067a6330) /* 0.404879749 */, 16 },
+
+ /* 2080 */ { MAD_F(0x067b737c) /* 0.405139433 */, 16 },
+ /* 2081 */ { MAD_F(0x067c83d4) /* 0.405399159 */, 16 },
+ /* 2082 */ { MAD_F(0x067d9436) /* 0.405658926 */, 16 },
+ /* 2083 */ { MAD_F(0x067ea4a4) /* 0.405918735 */, 16 },
+ /* 2084 */ { MAD_F(0x067fb51d) /* 0.406178585 */, 16 },
+ /* 2085 */ { MAD_F(0x0680c5a2) /* 0.406438477 */, 16 },
+ /* 2086 */ { MAD_F(0x0681d631) /* 0.406698410 */, 16 },
+ /* 2087 */ { MAD_F(0x0682e6cb) /* 0.406958385 */, 16 },
+ /* 2088 */ { MAD_F(0x0683f771) /* 0.407218402 */, 16 },
+ /* 2089 */ { MAD_F(0x06850822) /* 0.407478460 */, 16 },
+ /* 2090 */ { MAD_F(0x068618de) /* 0.407738559 */, 16 },
+ /* 2091 */ { MAD_F(0x068729a5) /* 0.407998700 */, 16 },
+ /* 2092 */ { MAD_F(0x06883a77) /* 0.408258883 */, 16 },
+ /* 2093 */ { MAD_F(0x06894b55) /* 0.408519107 */, 16 },
+ /* 2094 */ { MAD_F(0x068a5c3d) /* 0.408779372 */, 16 },
+ /* 2095 */ { MAD_F(0x068b6d31) /* 0.409039679 */, 16 },
+
+ /* 2096 */ { MAD_F(0x068c7e2f) /* 0.409300027 */, 16 },
+ /* 2097 */ { MAD_F(0x068d8f39) /* 0.409560417 */, 16 },
+ /* 2098 */ { MAD_F(0x068ea04e) /* 0.409820848 */, 16 },
+ /* 2099 */ { MAD_F(0x068fb16e) /* 0.410081321 */, 16 },
+ /* 2100 */ { MAD_F(0x0690c299) /* 0.410341834 */, 16 },
+ /* 2101 */ { MAD_F(0x0691d3cf) /* 0.410602390 */, 16 },
+ /* 2102 */ { MAD_F(0x0692e511) /* 0.410862986 */, 16 },
+ /* 2103 */ { MAD_F(0x0693f65d) /* 0.411123624 */, 16 },
+ /* 2104 */ { MAD_F(0x069507b5) /* 0.411384303 */, 16 },
+ /* 2105 */ { MAD_F(0x06961917) /* 0.411645024 */, 16 },
+ /* 2106 */ { MAD_F(0x06972a85) /* 0.411905785 */, 16 },
+ /* 2107 */ { MAD_F(0x06983bfe) /* 0.412166588 */, 16 },
+ /* 2108 */ { MAD_F(0x06994d82) /* 0.412427433 */, 16 },
+ /* 2109 */ { MAD_F(0x069a5f11) /* 0.412688318 */, 16 },
+ /* 2110 */ { MAD_F(0x069b70ab) /* 0.412949245 */, 16 },
+ /* 2111 */ { MAD_F(0x069c8250) /* 0.413210213 */, 16 },
+
+ /* 2112 */ { MAD_F(0x069d9400) /* 0.413471222 */, 16 },
+ /* 2113 */ { MAD_F(0x069ea5bb) /* 0.413732273 */, 16 },
+ /* 2114 */ { MAD_F(0x069fb781) /* 0.413993364 */, 16 },
+ /* 2115 */ { MAD_F(0x06a0c953) /* 0.414254497 */, 16 },
+ /* 2116 */ { MAD_F(0x06a1db2f) /* 0.414515671 */, 16 },
+ /* 2117 */ { MAD_F(0x06a2ed16) /* 0.414776886 */, 16 },
+ /* 2118 */ { MAD_F(0x06a3ff09) /* 0.415038142 */, 16 },
+ /* 2119 */ { MAD_F(0x06a51106) /* 0.415299440 */, 16 },
+ /* 2120 */ { MAD_F(0x06a6230f) /* 0.415560778 */, 16 },
+ /* 2121 */ { MAD_F(0x06a73522) /* 0.415822157 */, 16 },
+ /* 2122 */ { MAD_F(0x06a84741) /* 0.416083578 */, 16 },
+ /* 2123 */ { MAD_F(0x06a9596a) /* 0.416345040 */, 16 },
+ /* 2124 */ { MAD_F(0x06aa6b9f) /* 0.416606542 */, 16 },
+ /* 2125 */ { MAD_F(0x06ab7ddf) /* 0.416868086 */, 16 },
+ /* 2126 */ { MAD_F(0x06ac9029) /* 0.417129671 */, 16 },
+ /* 2127 */ { MAD_F(0x06ada27f) /* 0.417391297 */, 16 },
+
+ /* 2128 */ { MAD_F(0x06aeb4e0) /* 0.417652964 */, 16 },
+ /* 2129 */ { MAD_F(0x06afc74b) /* 0.417914672 */, 16 },
+ /* 2130 */ { MAD_F(0x06b0d9c2) /* 0.418176420 */, 16 },
+ /* 2131 */ { MAD_F(0x06b1ec43) /* 0.418438210 */, 16 },
+ /* 2132 */ { MAD_F(0x06b2fed0) /* 0.418700041 */, 16 },
+ /* 2133 */ { MAD_F(0x06b41168) /* 0.418961912 */, 16 },
+ /* 2134 */ { MAD_F(0x06b5240a) /* 0.419223825 */, 16 },
+ /* 2135 */ { MAD_F(0x06b636b8) /* 0.419485778 */, 16 },
+ /* 2136 */ { MAD_F(0x06b74971) /* 0.419747773 */, 16 },
+ /* 2137 */ { MAD_F(0x06b85c34) /* 0.420009808 */, 16 },
+ /* 2138 */ { MAD_F(0x06b96f03) /* 0.420271884 */, 16 },
+ /* 2139 */ { MAD_F(0x06ba81dc) /* 0.420534001 */, 16 },
+ /* 2140 */ { MAD_F(0x06bb94c1) /* 0.420796159 */, 16 },
+ /* 2141 */ { MAD_F(0x06bca7b0) /* 0.421058358 */, 16 },
+ /* 2142 */ { MAD_F(0x06bdbaaa) /* 0.421320597 */, 16 },
+ /* 2143 */ { MAD_F(0x06becdb0) /* 0.421582878 */, 16 },
+
+ /* 2144 */ { MAD_F(0x06bfe0c0) /* 0.421845199 */, 16 },
+ /* 2145 */ { MAD_F(0x06c0f3db) /* 0.422107561 */, 16 },
+ /* 2146 */ { MAD_F(0x06c20702) /* 0.422369964 */, 16 },
+ /* 2147 */ { MAD_F(0x06c31a33) /* 0.422632407 */, 16 },
+ /* 2148 */ { MAD_F(0x06c42d6f) /* 0.422894891 */, 16 },
+ /* 2149 */ { MAD_F(0x06c540b6) /* 0.423157416 */, 16 },
+ /* 2150 */ { MAD_F(0x06c65408) /* 0.423419982 */, 16 },
+ /* 2151 */ { MAD_F(0x06c76765) /* 0.423682588 */, 16 },
+ /* 2152 */ { MAD_F(0x06c87acc) /* 0.423945235 */, 16 },
+ /* 2153 */ { MAD_F(0x06c98e3f) /* 0.424207923 */, 16 },
+ /* 2154 */ { MAD_F(0x06caa1bd) /* 0.424470652 */, 16 },
+ /* 2155 */ { MAD_F(0x06cbb545) /* 0.424733421 */, 16 },
+ /* 2156 */ { MAD_F(0x06ccc8d9) /* 0.424996230 */, 16 },
+ /* 2157 */ { MAD_F(0x06cddc77) /* 0.425259081 */, 16 },
+ /* 2158 */ { MAD_F(0x06cef020) /* 0.425521972 */, 16 },
+ /* 2159 */ { MAD_F(0x06d003d4) /* 0.425784903 */, 16 },
+
+ /* 2160 */ { MAD_F(0x06d11794) /* 0.426047876 */, 16 },
+ /* 2161 */ { MAD_F(0x06d22b5e) /* 0.426310889 */, 16 },
+ /* 2162 */ { MAD_F(0x06d33f32) /* 0.426573942 */, 16 },
+ /* 2163 */ { MAD_F(0x06d45312) /* 0.426837036 */, 16 },
+ /* 2164 */ { MAD_F(0x06d566fd) /* 0.427100170 */, 16 },
+ /* 2165 */ { MAD_F(0x06d67af2) /* 0.427363345 */, 16 },
+ /* 2166 */ { MAD_F(0x06d78ef3) /* 0.427626561 */, 16 },
+ /* 2167 */ { MAD_F(0x06d8a2fe) /* 0.427889817 */, 16 },
+ /* 2168 */ { MAD_F(0x06d9b714) /* 0.428153114 */, 16 },
+ /* 2169 */ { MAD_F(0x06dacb35) /* 0.428416451 */, 16 },
+ /* 2170 */ { MAD_F(0x06dbdf61) /* 0.428679828 */, 16 },
+ /* 2171 */ { MAD_F(0x06dcf398) /* 0.428943246 */, 16 },
+ /* 2172 */ { MAD_F(0x06de07d9) /* 0.429206704 */, 16 },
+ /* 2173 */ { MAD_F(0x06df1c26) /* 0.429470203 */, 16 },
+ /* 2174 */ { MAD_F(0x06e0307d) /* 0.429733743 */, 16 },
+ /* 2175 */ { MAD_F(0x06e144df) /* 0.429997322 */, 16 },
+
+ /* 2176 */ { MAD_F(0x06e2594c) /* 0.430260942 */, 16 },
+ /* 2177 */ { MAD_F(0x06e36dc4) /* 0.430524603 */, 16 },
+ /* 2178 */ { MAD_F(0x06e48246) /* 0.430788304 */, 16 },
+ /* 2179 */ { MAD_F(0x06e596d4) /* 0.431052045 */, 16 },
+ /* 2180 */ { MAD_F(0x06e6ab6c) /* 0.431315826 */, 16 },
+ /* 2181 */ { MAD_F(0x06e7c00f) /* 0.431579648 */, 16 },
+ /* 2182 */ { MAD_F(0x06e8d4bd) /* 0.431843511 */, 16 },
+ /* 2183 */ { MAD_F(0x06e9e976) /* 0.432107413 */, 16 },
+ /* 2184 */ { MAD_F(0x06eafe3a) /* 0.432371356 */, 16 },
+ /* 2185 */ { MAD_F(0x06ec1308) /* 0.432635339 */, 16 },
+ /* 2186 */ { MAD_F(0x06ed27e2) /* 0.432899362 */, 16 },
+ /* 2187 */ { MAD_F(0x06ee3cc6) /* 0.433163426 */, 16 },
+ /* 2188 */ { MAD_F(0x06ef51b4) /* 0.433427530 */, 16 },
+ /* 2189 */ { MAD_F(0x06f066ae) /* 0.433691674 */, 16 },
+ /* 2190 */ { MAD_F(0x06f17bb3) /* 0.433955859 */, 16 },
+ /* 2191 */ { MAD_F(0x06f290c2) /* 0.434220083 */, 16 },
+
+ /* 2192 */ { MAD_F(0x06f3a5dc) /* 0.434484348 */, 16 },
+ /* 2193 */ { MAD_F(0x06f4bb01) /* 0.434748653 */, 16 },
+ /* 2194 */ { MAD_F(0x06f5d030) /* 0.435012998 */, 16 },
+ /* 2195 */ { MAD_F(0x06f6e56b) /* 0.435277383 */, 16 },
+ /* 2196 */ { MAD_F(0x06f7fab0) /* 0.435541809 */, 16 },
+ /* 2197 */ { MAD_F(0x06f91000) /* 0.435806274 */, 16 },
+ /* 2198 */ { MAD_F(0x06fa255a) /* 0.436070780 */, 16 },
+ /* 2199 */ { MAD_F(0x06fb3ac0) /* 0.436335326 */, 16 },
+ /* 2200 */ { MAD_F(0x06fc5030) /* 0.436599912 */, 16 },
+ /* 2201 */ { MAD_F(0x06fd65ab) /* 0.436864538 */, 16 },
+ /* 2202 */ { MAD_F(0x06fe7b31) /* 0.437129204 */, 16 },
+ /* 2203 */ { MAD_F(0x06ff90c2) /* 0.437393910 */, 16 },
+ /* 2204 */ { MAD_F(0x0700a65d) /* 0.437658657 */, 16 },
+ /* 2205 */ { MAD_F(0x0701bc03) /* 0.437923443 */, 16 },
+ /* 2206 */ { MAD_F(0x0702d1b4) /* 0.438188269 */, 16 },
+ /* 2207 */ { MAD_F(0x0703e76f) /* 0.438453136 */, 16 },
+
+ /* 2208 */ { MAD_F(0x0704fd35) /* 0.438718042 */, 16 },
+ /* 2209 */ { MAD_F(0x07061306) /* 0.438982988 */, 16 },
+ /* 2210 */ { MAD_F(0x070728e2) /* 0.439247975 */, 16 },
+ /* 2211 */ { MAD_F(0x07083ec9) /* 0.439513001 */, 16 },
+ /* 2212 */ { MAD_F(0x070954ba) /* 0.439778067 */, 16 },
+ /* 2213 */ { MAD_F(0x070a6ab6) /* 0.440043173 */, 16 },
+ /* 2214 */ { MAD_F(0x070b80bc) /* 0.440308320 */, 16 },
+ /* 2215 */ { MAD_F(0x070c96ce) /* 0.440573506 */, 16 },
+ /* 2216 */ { MAD_F(0x070dacea) /* 0.440838732 */, 16 },
+ /* 2217 */ { MAD_F(0x070ec310) /* 0.441103997 */, 16 },
+ /* 2218 */ { MAD_F(0x070fd942) /* 0.441369303 */, 16 },
+ /* 2219 */ { MAD_F(0x0710ef7e) /* 0.441634649 */, 16 },
+ /* 2220 */ { MAD_F(0x071205c5) /* 0.441900034 */, 16 },
+ /* 2221 */ { MAD_F(0x07131c17) /* 0.442165460 */, 16 },
+ /* 2222 */ { MAD_F(0x07143273) /* 0.442430925 */, 16 },
+ /* 2223 */ { MAD_F(0x071548da) /* 0.442696430 */, 16 },
+
+ /* 2224 */ { MAD_F(0x07165f4b) /* 0.442961975 */, 16 },
+ /* 2225 */ { MAD_F(0x071775c8) /* 0.443227559 */, 16 },
+ /* 2226 */ { MAD_F(0x07188c4f) /* 0.443493184 */, 16 },
+ /* 2227 */ { MAD_F(0x0719a2e0) /* 0.443758848 */, 16 },
+ /* 2228 */ { MAD_F(0x071ab97d) /* 0.444024552 */, 16 },
+ /* 2229 */ { MAD_F(0x071bd024) /* 0.444290296 */, 16 },
+ /* 2230 */ { MAD_F(0x071ce6d6) /* 0.444556079 */, 16 },
+ /* 2231 */ { MAD_F(0x071dfd92) /* 0.444821902 */, 16 },
+ /* 2232 */ { MAD_F(0x071f1459) /* 0.445087765 */, 16 },
+ /* 2233 */ { MAD_F(0x07202b2b) /* 0.445353668 */, 16 },
+ /* 2234 */ { MAD_F(0x07214207) /* 0.445619610 */, 16 },
+ /* 2235 */ { MAD_F(0x072258ee) /* 0.445885592 */, 16 },
+ /* 2236 */ { MAD_F(0x07236fe0) /* 0.446151614 */, 16 },
+ /* 2237 */ { MAD_F(0x072486dc) /* 0.446417675 */, 16 },
+ /* 2238 */ { MAD_F(0x07259de3) /* 0.446683776 */, 16 },
+ /* 2239 */ { MAD_F(0x0726b4f4) /* 0.446949917 */, 16 },
+
+ /* 2240 */ { MAD_F(0x0727cc11) /* 0.447216097 */, 16 },
+ /* 2241 */ { MAD_F(0x0728e338) /* 0.447482317 */, 16 },
+ /* 2242 */ { MAD_F(0x0729fa69) /* 0.447748576 */, 16 },
+ /* 2243 */ { MAD_F(0x072b11a5) /* 0.448014875 */, 16 },
+ /* 2244 */ { MAD_F(0x072c28ec) /* 0.448281214 */, 16 },
+ /* 2245 */ { MAD_F(0x072d403d) /* 0.448547592 */, 16 },
+ /* 2246 */ { MAD_F(0x072e5799) /* 0.448814010 */, 16 },
+ /* 2247 */ { MAD_F(0x072f6f00) /* 0.449080467 */, 16 },
+ /* 2248 */ { MAD_F(0x07308671) /* 0.449346964 */, 16 },
+ /* 2249 */ { MAD_F(0x07319ded) /* 0.449613501 */, 16 },
+ /* 2250 */ { MAD_F(0x0732b573) /* 0.449880076 */, 16 },
+ /* 2251 */ { MAD_F(0x0733cd04) /* 0.450146692 */, 16 },
+ /* 2252 */ { MAD_F(0x0734e4a0) /* 0.450413347 */, 16 },
+ /* 2253 */ { MAD_F(0x0735fc46) /* 0.450680041 */, 16 },
+ /* 2254 */ { MAD_F(0x073713f7) /* 0.450946775 */, 16 },
+ /* 2255 */ { MAD_F(0x07382bb2) /* 0.451213548 */, 16 },
+
+ /* 2256 */ { MAD_F(0x07394378) /* 0.451480360 */, 16 },
+ /* 2257 */ { MAD_F(0x073a5b49) /* 0.451747213 */, 16 },
+ /* 2258 */ { MAD_F(0x073b7324) /* 0.452014104 */, 16 },
+ /* 2259 */ { MAD_F(0x073c8b0a) /* 0.452281035 */, 16 },
+ /* 2260 */ { MAD_F(0x073da2fa) /* 0.452548005 */, 16 },
+ /* 2261 */ { MAD_F(0x073ebaf5) /* 0.452815015 */, 16 },
+ /* 2262 */ { MAD_F(0x073fd2fa) /* 0.453082064 */, 16 },
+ /* 2263 */ { MAD_F(0x0740eb0a) /* 0.453349152 */, 16 },
+ /* 2264 */ { MAD_F(0x07420325) /* 0.453616280 */, 16 },
+ /* 2265 */ { MAD_F(0x07431b4a) /* 0.453883447 */, 16 },
+ /* 2266 */ { MAD_F(0x0744337a) /* 0.454150653 */, 16 },
+ /* 2267 */ { MAD_F(0x07454bb4) /* 0.454417899 */, 16 },
+ /* 2268 */ { MAD_F(0x074663f8) /* 0.454685184 */, 16 },
+ /* 2269 */ { MAD_F(0x07477c48) /* 0.454952508 */, 16 },
+ /* 2270 */ { MAD_F(0x074894a2) /* 0.455219872 */, 16 },
+ /* 2271 */ { MAD_F(0x0749ad06) /* 0.455487275 */, 16 },
+
+ /* 2272 */ { MAD_F(0x074ac575) /* 0.455754717 */, 16 },
+ /* 2273 */ { MAD_F(0x074bddee) /* 0.456022198 */, 16 },
+ /* 2274 */ { MAD_F(0x074cf672) /* 0.456289719 */, 16 },
+ /* 2275 */ { MAD_F(0x074e0f01) /* 0.456557278 */, 16 },
+ /* 2276 */ { MAD_F(0x074f279a) /* 0.456824877 */, 16 },
+ /* 2277 */ { MAD_F(0x0750403e) /* 0.457092516 */, 16 },
+ /* 2278 */ { MAD_F(0x075158ec) /* 0.457360193 */, 16 },
+ /* 2279 */ { MAD_F(0x075271a4) /* 0.457627909 */, 16 },
+ /* 2280 */ { MAD_F(0x07538a67) /* 0.457895665 */, 16 },
+ /* 2281 */ { MAD_F(0x0754a335) /* 0.458163460 */, 16 },
+ /* 2282 */ { MAD_F(0x0755bc0d) /* 0.458431294 */, 16 },
+ /* 2283 */ { MAD_F(0x0756d4f0) /* 0.458699167 */, 16 },
+ /* 2284 */ { MAD_F(0x0757eddd) /* 0.458967079 */, 16 },
+ /* 2285 */ { MAD_F(0x075906d5) /* 0.459235030 */, 16 },
+ /* 2286 */ { MAD_F(0x075a1fd7) /* 0.459503021 */, 16 },
+ /* 2287 */ { MAD_F(0x075b38e3) /* 0.459771050 */, 16 },
+
+ /* 2288 */ { MAD_F(0x075c51fa) /* 0.460039119 */, 16 },
+ /* 2289 */ { MAD_F(0x075d6b1c) /* 0.460307226 */, 16 },
+ /* 2290 */ { MAD_F(0x075e8448) /* 0.460575373 */, 16 },
+ /* 2291 */ { MAD_F(0x075f9d7f) /* 0.460843559 */, 16 },
+ /* 2292 */ { MAD_F(0x0760b6c0) /* 0.461111783 */, 16 },
+ /* 2293 */ { MAD_F(0x0761d00b) /* 0.461380047 */, 16 },
+ /* 2294 */ { MAD_F(0x0762e961) /* 0.461648350 */, 16 },
+ /* 2295 */ { MAD_F(0x076402c1) /* 0.461916691 */, 16 },
+ /* 2296 */ { MAD_F(0x07651c2c) /* 0.462185072 */, 16 },
+ /* 2297 */ { MAD_F(0x076635a2) /* 0.462453492 */, 16 },
+ /* 2298 */ { MAD_F(0x07674f22) /* 0.462721950 */, 16 },
+ /* 2299 */ { MAD_F(0x076868ac) /* 0.462990448 */, 16 },
+ /* 2300 */ { MAD_F(0x07698240) /* 0.463258984 */, 16 },
+ /* 2301 */ { MAD_F(0x076a9be0) /* 0.463527560 */, 16 },
+ /* 2302 */ { MAD_F(0x076bb589) /* 0.463796174 */, 16 },
+ /* 2303 */ { MAD_F(0x076ccf3d) /* 0.464064827 */, 16 },
+
+ /* 2304 */ { MAD_F(0x076de8fc) /* 0.464333519 */, 16 },
+ /* 2305 */ { MAD_F(0x076f02c5) /* 0.464602250 */, 16 },
+ /* 2306 */ { MAD_F(0x07701c98) /* 0.464871020 */, 16 },
+ /* 2307 */ { MAD_F(0x07713676) /* 0.465139829 */, 16 },
+ /* 2308 */ { MAD_F(0x0772505e) /* 0.465408676 */, 16 },
+ /* 2309 */ { MAD_F(0x07736a51) /* 0.465677563 */, 16 },
+ /* 2310 */ { MAD_F(0x0774844e) /* 0.465946488 */, 16 },
+ /* 2311 */ { MAD_F(0x07759e55) /* 0.466215452 */, 16 },
+ /* 2312 */ { MAD_F(0x0776b867) /* 0.466484455 */, 16 },
+ /* 2313 */ { MAD_F(0x0777d283) /* 0.466753496 */, 16 },
+ /* 2314 */ { MAD_F(0x0778ecaa) /* 0.467022577 */, 16 },
+ /* 2315 */ { MAD_F(0x077a06db) /* 0.467291696 */, 16 },
+ /* 2316 */ { MAD_F(0x077b2117) /* 0.467560854 */, 16 },
+ /* 2317 */ { MAD_F(0x077c3b5d) /* 0.467830050 */, 16 },
+ /* 2318 */ { MAD_F(0x077d55ad) /* 0.468099285 */, 16 },
+ /* 2319 */ { MAD_F(0x077e7008) /* 0.468368560 */, 16 },
+
+ /* 2320 */ { MAD_F(0x077f8a6d) /* 0.468637872 */, 16 },
+ /* 2321 */ { MAD_F(0x0780a4dc) /* 0.468907224 */, 16 },
+ /* 2322 */ { MAD_F(0x0781bf56) /* 0.469176614 */, 16 },
+ /* 2323 */ { MAD_F(0x0782d9da) /* 0.469446043 */, 16 },
+ /* 2324 */ { MAD_F(0x0783f469) /* 0.469715510 */, 16 },
+ /* 2325 */ { MAD_F(0x07850f02) /* 0.469985016 */, 16 },
+ /* 2326 */ { MAD_F(0x078629a5) /* 0.470254561 */, 16 },
+ /* 2327 */ { MAD_F(0x07874453) /* 0.470524145 */, 16 },
+ /* 2328 */ { MAD_F(0x07885f0b) /* 0.470793767 */, 16 },
+ /* 2329 */ { MAD_F(0x078979ce) /* 0.471063427 */, 16 },
+ /* 2330 */ { MAD_F(0x078a949a) /* 0.471333126 */, 16 },
+ /* 2331 */ { MAD_F(0x078baf72) /* 0.471602864 */, 16 },
+ /* 2332 */ { MAD_F(0x078cca53) /* 0.471872641 */, 16 },
+ /* 2333 */ { MAD_F(0x078de53f) /* 0.472142456 */, 16 },
+ /* 2334 */ { MAD_F(0x078f0035) /* 0.472412309 */, 16 },
+ /* 2335 */ { MAD_F(0x07901b36) /* 0.472682201 */, 16 },
+
+ /* 2336 */ { MAD_F(0x07913641) /* 0.472952132 */, 16 },
+ /* 2337 */ { MAD_F(0x07925156) /* 0.473222101 */, 16 },
+ /* 2338 */ { MAD_F(0x07936c76) /* 0.473492108 */, 16 },
+ /* 2339 */ { MAD_F(0x079487a0) /* 0.473762155 */, 16 },
+ /* 2340 */ { MAD_F(0x0795a2d4) /* 0.474032239 */, 16 },
+ /* 2341 */ { MAD_F(0x0796be13) /* 0.474302362 */, 16 },
+ /* 2342 */ { MAD_F(0x0797d95c) /* 0.474572524 */, 16 },
+ /* 2343 */ { MAD_F(0x0798f4af) /* 0.474842724 */, 16 },
+ /* 2344 */ { MAD_F(0x079a100c) /* 0.475112962 */, 16 },
+ /* 2345 */ { MAD_F(0x079b2b74) /* 0.475383239 */, 16 },
+ /* 2346 */ { MAD_F(0x079c46e7) /* 0.475653554 */, 16 },
+ /* 2347 */ { MAD_F(0x079d6263) /* 0.475923908 */, 16 },
+ /* 2348 */ { MAD_F(0x079e7dea) /* 0.476194300 */, 16 },
+ /* 2349 */ { MAD_F(0x079f997b) /* 0.476464731 */, 16 },
+ /* 2350 */ { MAD_F(0x07a0b516) /* 0.476735200 */, 16 },
+ /* 2351 */ { MAD_F(0x07a1d0bc) /* 0.477005707 */, 16 },
+
+ /* 2352 */ { MAD_F(0x07a2ec6c) /* 0.477276252 */, 16 },
+ /* 2353 */ { MAD_F(0x07a40827) /* 0.477546836 */, 16 },
+ /* 2354 */ { MAD_F(0x07a523eb) /* 0.477817459 */, 16 },
+ /* 2355 */ { MAD_F(0x07a63fba) /* 0.478088119 */, 16 },
+ /* 2356 */ { MAD_F(0x07a75b93) /* 0.478358818 */, 16 },
+ /* 2357 */ { MAD_F(0x07a87777) /* 0.478629555 */, 16 },
+ /* 2358 */ { MAD_F(0x07a99364) /* 0.478900331 */, 16 },
+ /* 2359 */ { MAD_F(0x07aaaf5c) /* 0.479171145 */, 16 },
+ /* 2360 */ { MAD_F(0x07abcb5f) /* 0.479441997 */, 16 },
+ /* 2361 */ { MAD_F(0x07ace76b) /* 0.479712887 */, 16 },
+ /* 2362 */ { MAD_F(0x07ae0382) /* 0.479983816 */, 16 },
+ /* 2363 */ { MAD_F(0x07af1fa3) /* 0.480254782 */, 16 },
+ /* 2364 */ { MAD_F(0x07b03bcf) /* 0.480525787 */, 16 },
+ /* 2365 */ { MAD_F(0x07b15804) /* 0.480796831 */, 16 },
+ /* 2366 */ { MAD_F(0x07b27444) /* 0.481067912 */, 16 },
+ /* 2367 */ { MAD_F(0x07b3908e) /* 0.481339032 */, 16 },
+
+ /* 2368 */ { MAD_F(0x07b4ace3) /* 0.481610189 */, 16 },
+ /* 2369 */ { MAD_F(0x07b5c941) /* 0.481881385 */, 16 },
+ /* 2370 */ { MAD_F(0x07b6e5aa) /* 0.482152620 */, 16 },
+ /* 2371 */ { MAD_F(0x07b8021d) /* 0.482423892 */, 16 },
+ /* 2372 */ { MAD_F(0x07b91e9b) /* 0.482695202 */, 16 },
+ /* 2373 */ { MAD_F(0x07ba3b22) /* 0.482966551 */, 16 },
+ /* 2374 */ { MAD_F(0x07bb57b4) /* 0.483237938 */, 16 },
+ /* 2375 */ { MAD_F(0x07bc7450) /* 0.483509362 */, 16 },
+ /* 2376 */ { MAD_F(0x07bd90f6) /* 0.483780825 */, 16 },
+ /* 2377 */ { MAD_F(0x07beada7) /* 0.484052326 */, 16 },
+ /* 2378 */ { MAD_F(0x07bfca61) /* 0.484323865 */, 16 },
+ /* 2379 */ { MAD_F(0x07c0e726) /* 0.484595443 */, 16 },
+ /* 2380 */ { MAD_F(0x07c203f5) /* 0.484867058 */, 16 },
+ /* 2381 */ { MAD_F(0x07c320cf) /* 0.485138711 */, 16 },
+ /* 2382 */ { MAD_F(0x07c43db2) /* 0.485410402 */, 16 },
+ /* 2383 */ { MAD_F(0x07c55aa0) /* 0.485682131 */, 16 },
+
+ /* 2384 */ { MAD_F(0x07c67798) /* 0.485953899 */, 16 },
+ /* 2385 */ { MAD_F(0x07c7949a) /* 0.486225704 */, 16 },
+ /* 2386 */ { MAD_F(0x07c8b1a7) /* 0.486497547 */, 16 },
+ /* 2387 */ { MAD_F(0x07c9cebd) /* 0.486769429 */, 16 },
+ /* 2388 */ { MAD_F(0x07caebde) /* 0.487041348 */, 16 },
+ /* 2389 */ { MAD_F(0x07cc0909) /* 0.487313305 */, 16 },
+ /* 2390 */ { MAD_F(0x07cd263e) /* 0.487585300 */, 16 },
+ /* 2391 */ { MAD_F(0x07ce437d) /* 0.487857333 */, 16 },
+ /* 2392 */ { MAD_F(0x07cf60c7) /* 0.488129404 */, 16 },
+ /* 2393 */ { MAD_F(0x07d07e1b) /* 0.488401513 */, 16 },
+ /* 2394 */ { MAD_F(0x07d19b79) /* 0.488673660 */, 16 },
+ /* 2395 */ { MAD_F(0x07d2b8e1) /* 0.488945845 */, 16 },
+ /* 2396 */ { MAD_F(0x07d3d653) /* 0.489218067 */, 16 },
+ /* 2397 */ { MAD_F(0x07d4f3cf) /* 0.489490328 */, 16 },
+ /* 2398 */ { MAD_F(0x07d61156) /* 0.489762626 */, 16 },
+ /* 2399 */ { MAD_F(0x07d72ee6) /* 0.490034962 */, 16 },
+
+ /* 2400 */ { MAD_F(0x07d84c81) /* 0.490307336 */, 16 },
+ /* 2401 */ { MAD_F(0x07d96a26) /* 0.490579748 */, 16 },
+ /* 2402 */ { MAD_F(0x07da87d5) /* 0.490852198 */, 16 },
+ /* 2403 */ { MAD_F(0x07dba58f) /* 0.491124686 */, 16 },
+ /* 2404 */ { MAD_F(0x07dcc352) /* 0.491397211 */, 16 },
+ /* 2405 */ { MAD_F(0x07dde120) /* 0.491669774 */, 16 },
+ /* 2406 */ { MAD_F(0x07defef7) /* 0.491942375 */, 16 },
+ /* 2407 */ { MAD_F(0x07e01cd9) /* 0.492215014 */, 16 },
+ /* 2408 */ { MAD_F(0x07e13ac5) /* 0.492487690 */, 16 },
+ /* 2409 */ { MAD_F(0x07e258bc) /* 0.492760404 */, 16 },
+ /* 2410 */ { MAD_F(0x07e376bc) /* 0.493033156 */, 16 },
+ /* 2411 */ { MAD_F(0x07e494c6) /* 0.493305946 */, 16 },
+ /* 2412 */ { MAD_F(0x07e5b2db) /* 0.493578773 */, 16 },
+ /* 2413 */ { MAD_F(0x07e6d0f9) /* 0.493851638 */, 16 },
+ /* 2414 */ { MAD_F(0x07e7ef22) /* 0.494124541 */, 16 },
+ /* 2415 */ { MAD_F(0x07e90d55) /* 0.494397481 */, 16 },
+
+ /* 2416 */ { MAD_F(0x07ea2b92) /* 0.494670459 */, 16 },
+ /* 2417 */ { MAD_F(0x07eb49d9) /* 0.494943475 */, 16 },
+ /* 2418 */ { MAD_F(0x07ec682a) /* 0.495216529 */, 16 },
+ /* 2419 */ { MAD_F(0x07ed8686) /* 0.495489620 */, 16 },
+ /* 2420 */ { MAD_F(0x07eea4eb) /* 0.495762748 */, 16 },
+ /* 2421 */ { MAD_F(0x07efc35b) /* 0.496035915 */, 16 },
+ /* 2422 */ { MAD_F(0x07f0e1d4) /* 0.496309119 */, 16 },
+ /* 2423 */ { MAD_F(0x07f20058) /* 0.496582360 */, 16 },
+ /* 2424 */ { MAD_F(0x07f31ee6) /* 0.496855639 */, 16 },
+ /* 2425 */ { MAD_F(0x07f43d7e) /* 0.497128956 */, 16 },
+ /* 2426 */ { MAD_F(0x07f55c20) /* 0.497402310 */, 16 },
+ /* 2427 */ { MAD_F(0x07f67acc) /* 0.497675702 */, 16 },
+ /* 2428 */ { MAD_F(0x07f79982) /* 0.497949132 */, 16 },
+ /* 2429 */ { MAD_F(0x07f8b842) /* 0.498222598 */, 16 },
+ /* 2430 */ { MAD_F(0x07f9d70c) /* 0.498496103 */, 16 },
+ /* 2431 */ { MAD_F(0x07faf5e1) /* 0.498769645 */, 16 },
+
+ /* 2432 */ { MAD_F(0x07fc14bf) /* 0.499043224 */, 16 },
+ /* 2433 */ { MAD_F(0x07fd33a8) /* 0.499316841 */, 16 },
+ /* 2434 */ { MAD_F(0x07fe529a) /* 0.499590496 */, 16 },
+ /* 2435 */ { MAD_F(0x07ff7197) /* 0.499864188 */, 16 },
+ /* 2436 */ { MAD_F(0x0400484f) /* 0.250068959 */, 17 },
+ /* 2437 */ { MAD_F(0x0400d7d7) /* 0.250205842 */, 17 },
+ /* 2438 */ { MAD_F(0x04016764) /* 0.250342744 */, 17 },
+ /* 2439 */ { MAD_F(0x0401f6f7) /* 0.250479665 */, 17 },
+ /* 2440 */ { MAD_F(0x0402868e) /* 0.250616605 */, 17 },
+ /* 2441 */ { MAD_F(0x0403162b) /* 0.250753563 */, 17 },
+ /* 2442 */ { MAD_F(0x0403a5cc) /* 0.250890540 */, 17 },
+ /* 2443 */ { MAD_F(0x04043573) /* 0.251027536 */, 17 },
+ /* 2444 */ { MAD_F(0x0404c51e) /* 0.251164550 */, 17 },
+ /* 2445 */ { MAD_F(0x040554cf) /* 0.251301583 */, 17 },
+ /* 2446 */ { MAD_F(0x0405e484) /* 0.251438635 */, 17 },
+ /* 2447 */ { MAD_F(0x0406743f) /* 0.251575706 */, 17 },
+
+ /* 2448 */ { MAD_F(0x040703ff) /* 0.251712795 */, 17 },
+ /* 2449 */ { MAD_F(0x040793c3) /* 0.251849903 */, 17 },
+ /* 2450 */ { MAD_F(0x0408238d) /* 0.251987029 */, 17 },
+ /* 2451 */ { MAD_F(0x0408b35b) /* 0.252124174 */, 17 },
+ /* 2452 */ { MAD_F(0x0409432f) /* 0.252261338 */, 17 },
+ /* 2453 */ { MAD_F(0x0409d308) /* 0.252398520 */, 17 },
+ /* 2454 */ { MAD_F(0x040a62e5) /* 0.252535721 */, 17 },
+ /* 2455 */ { MAD_F(0x040af2c8) /* 0.252672941 */, 17 },
+ /* 2456 */ { MAD_F(0x040b82b0) /* 0.252810180 */, 17 },
+ /* 2457 */ { MAD_F(0x040c129c) /* 0.252947436 */, 17 },
+ /* 2458 */ { MAD_F(0x040ca28e) /* 0.253084712 */, 17 },
+ /* 2459 */ { MAD_F(0x040d3284) /* 0.253222006 */, 17 },
+ /* 2460 */ { MAD_F(0x040dc280) /* 0.253359319 */, 17 },
+ /* 2461 */ { MAD_F(0x040e5281) /* 0.253496651 */, 17 },
+ /* 2462 */ { MAD_F(0x040ee286) /* 0.253634001 */, 17 },
+ /* 2463 */ { MAD_F(0x040f7291) /* 0.253771369 */, 17 },
+
+ /* 2464 */ { MAD_F(0x041002a1) /* 0.253908756 */, 17 },
+ /* 2465 */ { MAD_F(0x041092b5) /* 0.254046162 */, 17 },
+ /* 2466 */ { MAD_F(0x041122cf) /* 0.254183587 */, 17 },
+ /* 2467 */ { MAD_F(0x0411b2ed) /* 0.254321030 */, 17 },
+ /* 2468 */ { MAD_F(0x04124311) /* 0.254458491 */, 17 },
+ /* 2469 */ { MAD_F(0x0412d339) /* 0.254595971 */, 17 },
+ /* 2470 */ { MAD_F(0x04136367) /* 0.254733470 */, 17 },
+ /* 2471 */ { MAD_F(0x0413f399) /* 0.254870987 */, 17 },
+ /* 2472 */ { MAD_F(0x041483d1) /* 0.255008523 */, 17 },
+ /* 2473 */ { MAD_F(0x0415140d) /* 0.255146077 */, 17 },
+ /* 2474 */ { MAD_F(0x0415a44f) /* 0.255283650 */, 17 },
+ /* 2475 */ { MAD_F(0x04163495) /* 0.255421241 */, 17 },
+ /* 2476 */ { MAD_F(0x0416c4e1) /* 0.255558851 */, 17 },
+ /* 2477 */ { MAD_F(0x04175531) /* 0.255696480 */, 17 },
+ /* 2478 */ { MAD_F(0x0417e586) /* 0.255834127 */, 17 },
+ /* 2479 */ { MAD_F(0x041875e1) /* 0.255971792 */, 17 },
+
+ /* 2480 */ { MAD_F(0x04190640) /* 0.256109476 */, 17 },
+ /* 2481 */ { MAD_F(0x041996a4) /* 0.256247179 */, 17 },
+ /* 2482 */ { MAD_F(0x041a270d) /* 0.256384900 */, 17 },
+ /* 2483 */ { MAD_F(0x041ab77b) /* 0.256522639 */, 17 },
+ /* 2484 */ { MAD_F(0x041b47ef) /* 0.256660397 */, 17 },
+ /* 2485 */ { MAD_F(0x041bd867) /* 0.256798174 */, 17 },
+ /* 2486 */ { MAD_F(0x041c68e4) /* 0.256935969 */, 17 },
+ /* 2487 */ { MAD_F(0x041cf966) /* 0.257073782 */, 17 },
+ /* 2488 */ { MAD_F(0x041d89ed) /* 0.257211614 */, 17 },
+ /* 2489 */ { MAD_F(0x041e1a79) /* 0.257349465 */, 17 },
+ /* 2490 */ { MAD_F(0x041eab0a) /* 0.257487334 */, 17 },
+ /* 2491 */ { MAD_F(0x041f3b9f) /* 0.257625221 */, 17 },
+ /* 2492 */ { MAD_F(0x041fcc3a) /* 0.257763127 */, 17 },
+ /* 2493 */ { MAD_F(0x04205cda) /* 0.257901051 */, 17 },
+ /* 2494 */ { MAD_F(0x0420ed7f) /* 0.258038994 */, 17 },
+ /* 2495 */ { MAD_F(0x04217e28) /* 0.258176955 */, 17 },
+
+ /* 2496 */ { MAD_F(0x04220ed7) /* 0.258314934 */, 17 },
+ /* 2497 */ { MAD_F(0x04229f8a) /* 0.258452932 */, 17 },
+ /* 2498 */ { MAD_F(0x04233043) /* 0.258590948 */, 17 },
+ /* 2499 */ { MAD_F(0x0423c100) /* 0.258728983 */, 17 },
+ /* 2500 */ { MAD_F(0x042451c3) /* 0.258867036 */, 17 },
+ /* 2501 */ { MAD_F(0x0424e28a) /* 0.259005108 */, 17 },
+ /* 2502 */ { MAD_F(0x04257356) /* 0.259143198 */, 17 },
+ /* 2503 */ { MAD_F(0x04260428) /* 0.259281307 */, 17 },
+ /* 2504 */ { MAD_F(0x042694fe) /* 0.259419433 */, 17 },
+ /* 2505 */ { MAD_F(0x042725d9) /* 0.259557579 */, 17 },
+ /* 2506 */ { MAD_F(0x0427b6b9) /* 0.259695742 */, 17 },
+ /* 2507 */ { MAD_F(0x0428479e) /* 0.259833924 */, 17 },
+ /* 2508 */ { MAD_F(0x0428d888) /* 0.259972124 */, 17 },
+ /* 2509 */ { MAD_F(0x04296976) /* 0.260110343 */, 17 },
+ /* 2510 */ { MAD_F(0x0429fa6a) /* 0.260248580 */, 17 },
+ /* 2511 */ { MAD_F(0x042a8b63) /* 0.260386836 */, 17 },
+
+ /* 2512 */ { MAD_F(0x042b1c60) /* 0.260525110 */, 17 },
+ /* 2513 */ { MAD_F(0x042bad63) /* 0.260663402 */, 17 },
+ /* 2514 */ { MAD_F(0x042c3e6a) /* 0.260801712 */, 17 },
+ /* 2515 */ { MAD_F(0x042ccf77) /* 0.260940041 */, 17 },
+ /* 2516 */ { MAD_F(0x042d6088) /* 0.261078388 */, 17 },
+ /* 2517 */ { MAD_F(0x042df19e) /* 0.261216754 */, 17 },
+ /* 2518 */ { MAD_F(0x042e82b9) /* 0.261355137 */, 17 },
+ /* 2519 */ { MAD_F(0x042f13d9) /* 0.261493540 */, 17 },
+ /* 2520 */ { MAD_F(0x042fa4fe) /* 0.261631960 */, 17 },
+ /* 2521 */ { MAD_F(0x04303628) /* 0.261770399 */, 17 },
+ /* 2522 */ { MAD_F(0x0430c757) /* 0.261908856 */, 17 },
+ /* 2523 */ { MAD_F(0x0431588b) /* 0.262047331 */, 17 },
+ /* 2524 */ { MAD_F(0x0431e9c3) /* 0.262185825 */, 17 },
+ /* 2525 */ { MAD_F(0x04327b01) /* 0.262324337 */, 17 },
+ /* 2526 */ { MAD_F(0x04330c43) /* 0.262462867 */, 17 },
+ /* 2527 */ { MAD_F(0x04339d8a) /* 0.262601416 */, 17 },
+
+ /* 2528 */ { MAD_F(0x04342ed7) /* 0.262739982 */, 17 },
+ /* 2529 */ { MAD_F(0x0434c028) /* 0.262878568 */, 17 },
+ /* 2530 */ { MAD_F(0x0435517e) /* 0.263017171 */, 17 },
+ /* 2531 */ { MAD_F(0x0435e2d9) /* 0.263155792 */, 17 },
+ /* 2532 */ { MAD_F(0x04367439) /* 0.263294432 */, 17 },
+ /* 2533 */ { MAD_F(0x0437059e) /* 0.263433090 */, 17 },
+ /* 2534 */ { MAD_F(0x04379707) /* 0.263571767 */, 17 },
+ /* 2535 */ { MAD_F(0x04382876) /* 0.263710461 */, 17 },
+ /* 2536 */ { MAD_F(0x0438b9e9) /* 0.263849174 */, 17 },
+ /* 2537 */ { MAD_F(0x04394b61) /* 0.263987905 */, 17 },
+ /* 2538 */ { MAD_F(0x0439dcdf) /* 0.264126655 */, 17 },
+ /* 2539 */ { MAD_F(0x043a6e61) /* 0.264265422 */, 17 },
+ /* 2540 */ { MAD_F(0x043affe8) /* 0.264404208 */, 17 },
+ /* 2541 */ { MAD_F(0x043b9174) /* 0.264543012 */, 17 },
+ /* 2542 */ { MAD_F(0x043c2305) /* 0.264681834 */, 17 },
+ /* 2543 */ { MAD_F(0x043cb49a) /* 0.264820674 */, 17 },
+
+ /* 2544 */ { MAD_F(0x043d4635) /* 0.264959533 */, 17 },
+ /* 2545 */ { MAD_F(0x043dd7d4) /* 0.265098410 */, 17 },
+ /* 2546 */ { MAD_F(0x043e6979) /* 0.265237305 */, 17 },
+ /* 2547 */ { MAD_F(0x043efb22) /* 0.265376218 */, 17 },
+ /* 2548 */ { MAD_F(0x043f8cd0) /* 0.265515149 */, 17 },
+ /* 2549 */ { MAD_F(0x04401e83) /* 0.265654099 */, 17 },
+ /* 2550 */ { MAD_F(0x0440b03b) /* 0.265793066 */, 17 },
+ /* 2551 */ { MAD_F(0x044141f7) /* 0.265932052 */, 17 },
+ /* 2552 */ { MAD_F(0x0441d3b9) /* 0.266071056 */, 17 },
+ /* 2553 */ { MAD_F(0x04426580) /* 0.266210078 */, 17 },
+ /* 2554 */ { MAD_F(0x0442f74b) /* 0.266349119 */, 17 },
+ /* 2555 */ { MAD_F(0x0443891b) /* 0.266488177 */, 17 },
+ /* 2556 */ { MAD_F(0x04441af0) /* 0.266627254 */, 17 },
+ /* 2557 */ { MAD_F(0x0444acca) /* 0.266766349 */, 17 },
+ /* 2558 */ { MAD_F(0x04453ea9) /* 0.266905462 */, 17 },
+ /* 2559 */ { MAD_F(0x0445d08d) /* 0.267044593 */, 17 },
+
+ /* 2560 */ { MAD_F(0x04466275) /* 0.267183742 */, 17 },
+ /* 2561 */ { MAD_F(0x0446f463) /* 0.267322909 */, 17 },
+ /* 2562 */ { MAD_F(0x04478655) /* 0.267462094 */, 17 },
+ /* 2563 */ { MAD_F(0x0448184c) /* 0.267601298 */, 17 },
+ /* 2564 */ { MAD_F(0x0448aa48) /* 0.267740519 */, 17 },
+ /* 2565 */ { MAD_F(0x04493c49) /* 0.267879759 */, 17 },
+ /* 2566 */ { MAD_F(0x0449ce4f) /* 0.268019017 */, 17 },
+ /* 2567 */ { MAD_F(0x044a6059) /* 0.268158293 */, 17 },
+ /* 2568 */ { MAD_F(0x044af269) /* 0.268297587 */, 17 },
+ /* 2569 */ { MAD_F(0x044b847d) /* 0.268436899 */, 17 },
+ /* 2570 */ { MAD_F(0x044c1696) /* 0.268576229 */, 17 },
+ /* 2571 */ { MAD_F(0x044ca8b4) /* 0.268715577 */, 17 },
+ /* 2572 */ { MAD_F(0x044d3ad7) /* 0.268854943 */, 17 },
+ /* 2573 */ { MAD_F(0x044dccff) /* 0.268994328 */, 17 },
+ /* 2574 */ { MAD_F(0x044e5f2b) /* 0.269133730 */, 17 },
+ /* 2575 */ { MAD_F(0x044ef15d) /* 0.269273150 */, 17 },
+
+ /* 2576 */ { MAD_F(0x044f8393) /* 0.269412589 */, 17 },
+ /* 2577 */ { MAD_F(0x045015ce) /* 0.269552045 */, 17 },
+ /* 2578 */ { MAD_F(0x0450a80e) /* 0.269691520 */, 17 },
+ /* 2579 */ { MAD_F(0x04513a53) /* 0.269831013 */, 17 },
+ /* 2580 */ { MAD_F(0x0451cc9c) /* 0.269970523 */, 17 },
+ /* 2581 */ { MAD_F(0x04525eeb) /* 0.270110052 */, 17 },
+ /* 2582 */ { MAD_F(0x0452f13e) /* 0.270249599 */, 17 },
+ /* 2583 */ { MAD_F(0x04538396) /* 0.270389163 */, 17 },
+ /* 2584 */ { MAD_F(0x045415f3) /* 0.270528746 */, 17 },
+ /* 2585 */ { MAD_F(0x0454a855) /* 0.270668347 */, 17 },
+ /* 2586 */ { MAD_F(0x04553abb) /* 0.270807965 */, 17 },
+ /* 2587 */ { MAD_F(0x0455cd27) /* 0.270947602 */, 17 },
+ /* 2588 */ { MAD_F(0x04565f97) /* 0.271087257 */, 17 },
+ /* 2589 */ { MAD_F(0x0456f20c) /* 0.271226930 */, 17 },
+ /* 2590 */ { MAD_F(0x04578486) /* 0.271366620 */, 17 },
+ /* 2591 */ { MAD_F(0x04581705) /* 0.271506329 */, 17 },
+
+ /* 2592 */ { MAD_F(0x0458a989) /* 0.271646056 */, 17 },
+ /* 2593 */ { MAD_F(0x04593c11) /* 0.271785800 */, 17 },
+ /* 2594 */ { MAD_F(0x0459ce9e) /* 0.271925563 */, 17 },
+ /* 2595 */ { MAD_F(0x045a6130) /* 0.272065343 */, 17 },
+ /* 2596 */ { MAD_F(0x045af3c7) /* 0.272205142 */, 17 },
+ /* 2597 */ { MAD_F(0x045b8663) /* 0.272344958 */, 17 },
+ /* 2598 */ { MAD_F(0x045c1903) /* 0.272484793 */, 17 },
+ /* 2599 */ { MAD_F(0x045caba9) /* 0.272624645 */, 17 },
+ /* 2600 */ { MAD_F(0x045d3e53) /* 0.272764515 */, 17 },
+ /* 2601 */ { MAD_F(0x045dd102) /* 0.272904403 */, 17 },
+ /* 2602 */ { MAD_F(0x045e63b6) /* 0.273044310 */, 17 },
+ /* 2603 */ { MAD_F(0x045ef66e) /* 0.273184234 */, 17 },
+ /* 2604 */ { MAD_F(0x045f892b) /* 0.273324176 */, 17 },
+ /* 2605 */ { MAD_F(0x04601bee) /* 0.273464136 */, 17 },
+ /* 2606 */ { MAD_F(0x0460aeb5) /* 0.273604113 */, 17 },
+ /* 2607 */ { MAD_F(0x04614180) /* 0.273744109 */, 17 },
+
+ /* 2608 */ { MAD_F(0x0461d451) /* 0.273884123 */, 17 },
+ /* 2609 */ { MAD_F(0x04626727) /* 0.274024154 */, 17 },
+ /* 2610 */ { MAD_F(0x0462fa01) /* 0.274164204 */, 17 },
+ /* 2611 */ { MAD_F(0x04638ce0) /* 0.274304271 */, 17 },
+ /* 2612 */ { MAD_F(0x04641fc4) /* 0.274444356 */, 17 },
+ /* 2613 */ { MAD_F(0x0464b2ac) /* 0.274584459 */, 17 },
+ /* 2614 */ { MAD_F(0x0465459a) /* 0.274724580 */, 17 },
+ /* 2615 */ { MAD_F(0x0465d88c) /* 0.274864719 */, 17 },
+ /* 2616 */ { MAD_F(0x04666b83) /* 0.275004875 */, 17 },
+ /* 2617 */ { MAD_F(0x0466fe7f) /* 0.275145050 */, 17 },
+ /* 2618 */ { MAD_F(0x0467917f) /* 0.275285242 */, 17 },
+ /* 2619 */ { MAD_F(0x04682485) /* 0.275425452 */, 17 },
+ /* 2620 */ { MAD_F(0x0468b78f) /* 0.275565681 */, 17 },
+ /* 2621 */ { MAD_F(0x04694a9e) /* 0.275705926 */, 17 },
+ /* 2622 */ { MAD_F(0x0469ddb2) /* 0.275846190 */, 17 },
+ /* 2623 */ { MAD_F(0x046a70ca) /* 0.275986472 */, 17 },
+
+ /* 2624 */ { MAD_F(0x046b03e7) /* 0.276126771 */, 17 },
+ /* 2625 */ { MAD_F(0x046b970a) /* 0.276267088 */, 17 },
+ /* 2626 */ { MAD_F(0x046c2a31) /* 0.276407423 */, 17 },
+ /* 2627 */ { MAD_F(0x046cbd5c) /* 0.276547776 */, 17 },
+ /* 2628 */ { MAD_F(0x046d508d) /* 0.276688147 */, 17 },
+ /* 2629 */ { MAD_F(0x046de3c2) /* 0.276828535 */, 17 },
+ /* 2630 */ { MAD_F(0x046e76fc) /* 0.276968942 */, 17 },
+ /* 2631 */ { MAD_F(0x046f0a3b) /* 0.277109366 */, 17 },
+ /* 2632 */ { MAD_F(0x046f9d7e) /* 0.277249808 */, 17 },
+ /* 2633 */ { MAD_F(0x047030c7) /* 0.277390267 */, 17 },
+ /* 2634 */ { MAD_F(0x0470c414) /* 0.277530745 */, 17 },
+ /* 2635 */ { MAD_F(0x04715766) /* 0.277671240 */, 17 },
+ /* 2636 */ { MAD_F(0x0471eabc) /* 0.277811753 */, 17 },
+ /* 2637 */ { MAD_F(0x04727e18) /* 0.277952284 */, 17 },
+ /* 2638 */ { MAD_F(0x04731178) /* 0.278092832 */, 17 },
+ /* 2639 */ { MAD_F(0x0473a4dd) /* 0.278233399 */, 17 },
+
+ /* 2640 */ { MAD_F(0x04743847) /* 0.278373983 */, 17 },
+ /* 2641 */ { MAD_F(0x0474cbb5) /* 0.278514584 */, 17 },
+ /* 2642 */ { MAD_F(0x04755f29) /* 0.278655204 */, 17 },
+ /* 2643 */ { MAD_F(0x0475f2a1) /* 0.278795841 */, 17 },
+ /* 2644 */ { MAD_F(0x0476861d) /* 0.278936496 */, 17 },
+ /* 2645 */ { MAD_F(0x0477199f) /* 0.279077169 */, 17 },
+ /* 2646 */ { MAD_F(0x0477ad25) /* 0.279217860 */, 17 },
+ /* 2647 */ { MAD_F(0x047840b0) /* 0.279358568 */, 17 },
+ /* 2648 */ { MAD_F(0x0478d440) /* 0.279499294 */, 17 },
+ /* 2649 */ { MAD_F(0x047967d5) /* 0.279640037 */, 17 },
+ /* 2650 */ { MAD_F(0x0479fb6e) /* 0.279780799 */, 17 },
+ /* 2651 */ { MAD_F(0x047a8f0c) /* 0.279921578 */, 17 },
+ /* 2652 */ { MAD_F(0x047b22af) /* 0.280062375 */, 17 },
+ /* 2653 */ { MAD_F(0x047bb657) /* 0.280203189 */, 17 },
+ /* 2654 */ { MAD_F(0x047c4a03) /* 0.280344021 */, 17 },
+ /* 2655 */ { MAD_F(0x047cddb4) /* 0.280484871 */, 17 },
+
+ /* 2656 */ { MAD_F(0x047d716a) /* 0.280625739 */, 17 },
+ /* 2657 */ { MAD_F(0x047e0524) /* 0.280766624 */, 17 },
+ /* 2658 */ { MAD_F(0x047e98e4) /* 0.280907527 */, 17 },
+ /* 2659 */ { MAD_F(0x047f2ca8) /* 0.281048447 */, 17 },
+ /* 2660 */ { MAD_F(0x047fc071) /* 0.281189385 */, 17 },
+ /* 2661 */ { MAD_F(0x0480543e) /* 0.281330341 */, 17 },
+ /* 2662 */ { MAD_F(0x0480e811) /* 0.281471315 */, 17 },
+ /* 2663 */ { MAD_F(0x04817be8) /* 0.281612306 */, 17 },
+ /* 2664 */ { MAD_F(0x04820fc3) /* 0.281753315 */, 17 },
+ /* 2665 */ { MAD_F(0x0482a3a4) /* 0.281894341 */, 17 },
+ /* 2666 */ { MAD_F(0x04833789) /* 0.282035386 */, 17 },
+ /* 2667 */ { MAD_F(0x0483cb73) /* 0.282176447 */, 17 },
+ /* 2668 */ { MAD_F(0x04845f62) /* 0.282317527 */, 17 },
+ /* 2669 */ { MAD_F(0x0484f355) /* 0.282458624 */, 17 },
+ /* 2670 */ { MAD_F(0x0485874d) /* 0.282599738 */, 17 },
+ /* 2671 */ { MAD_F(0x04861b4a) /* 0.282740871 */, 17 },
+
+ /* 2672 */ { MAD_F(0x0486af4c) /* 0.282882021 */, 17 },
+ /* 2673 */ { MAD_F(0x04874352) /* 0.283023188 */, 17 },
+ /* 2674 */ { MAD_F(0x0487d75d) /* 0.283164373 */, 17 },
+ /* 2675 */ { MAD_F(0x04886b6d) /* 0.283305576 */, 17 },
+ /* 2676 */ { MAD_F(0x0488ff82) /* 0.283446796 */, 17 },
+ /* 2677 */ { MAD_F(0x0489939b) /* 0.283588034 */, 17 },
+ /* 2678 */ { MAD_F(0x048a27b9) /* 0.283729290 */, 17 },
+ /* 2679 */ { MAD_F(0x048abbdc) /* 0.283870563 */, 17 },
+ /* 2680 */ { MAD_F(0x048b5003) /* 0.284011853 */, 17 },
+ /* 2681 */ { MAD_F(0x048be42f) /* 0.284153161 */, 17 },
+ /* 2682 */ { MAD_F(0x048c7860) /* 0.284294487 */, 17 },
+ /* 2683 */ { MAD_F(0x048d0c96) /* 0.284435831 */, 17 },
+ /* 2684 */ { MAD_F(0x048da0d0) /* 0.284577192 */, 17 },
+ /* 2685 */ { MAD_F(0x048e350f) /* 0.284718570 */, 17 },
+ /* 2686 */ { MAD_F(0x048ec953) /* 0.284859966 */, 17 },
+ /* 2687 */ { MAD_F(0x048f5d9b) /* 0.285001380 */, 17 },
+
+ /* 2688 */ { MAD_F(0x048ff1e8) /* 0.285142811 */, 17 },
+ /* 2689 */ { MAD_F(0x0490863a) /* 0.285284259 */, 17 },
+ /* 2690 */ { MAD_F(0x04911a91) /* 0.285425726 */, 17 },
+ /* 2691 */ { MAD_F(0x0491aeec) /* 0.285567209 */, 17 },
+ /* 2692 */ { MAD_F(0x0492434c) /* 0.285708711 */, 17 },
+ /* 2693 */ { MAD_F(0x0492d7b0) /* 0.285850229 */, 17 },
+ /* 2694 */ { MAD_F(0x04936c1a) /* 0.285991766 */, 17 },
+ /* 2695 */ { MAD_F(0x04940088) /* 0.286133319 */, 17 },
+ /* 2696 */ { MAD_F(0x049494fb) /* 0.286274891 */, 17 },
+ /* 2697 */ { MAD_F(0x04952972) /* 0.286416480 */, 17 },
+ /* 2698 */ { MAD_F(0x0495bdee) /* 0.286558086 */, 17 },
+ /* 2699 */ { MAD_F(0x0496526f) /* 0.286699710 */, 17 },
+ /* 2700 */ { MAD_F(0x0496e6f5) /* 0.286841351 */, 17 },
+ /* 2701 */ { MAD_F(0x04977b7f) /* 0.286983010 */, 17 },
+ /* 2702 */ { MAD_F(0x0498100e) /* 0.287124686 */, 17 },
+ /* 2703 */ { MAD_F(0x0498a4a1) /* 0.287266380 */, 17 },
+
+ /* 2704 */ { MAD_F(0x0499393a) /* 0.287408091 */, 17 },
+ /* 2705 */ { MAD_F(0x0499cdd7) /* 0.287549820 */, 17 },
+ /* 2706 */ { MAD_F(0x049a6278) /* 0.287691566 */, 17 },
+ /* 2707 */ { MAD_F(0x049af71f) /* 0.287833330 */, 17 },
+ /* 2708 */ { MAD_F(0x049b8bca) /* 0.287975111 */, 17 },
+ /* 2709 */ { MAD_F(0x049c207a) /* 0.288116909 */, 17 },
+ /* 2710 */ { MAD_F(0x049cb52e) /* 0.288258725 */, 17 },
+ /* 2711 */ { MAD_F(0x049d49e7) /* 0.288400559 */, 17 },
+ /* 2712 */ { MAD_F(0x049ddea5) /* 0.288542409 */, 17 },
+ /* 2713 */ { MAD_F(0x049e7367) /* 0.288684278 */, 17 },
+ /* 2714 */ { MAD_F(0x049f082f) /* 0.288826163 */, 17 },
+ /* 2715 */ { MAD_F(0x049f9cfa) /* 0.288968067 */, 17 },
+ /* 2716 */ { MAD_F(0x04a031cb) /* 0.289109987 */, 17 },
+ /* 2717 */ { MAD_F(0x04a0c6a0) /* 0.289251925 */, 17 },
+ /* 2718 */ { MAD_F(0x04a15b7a) /* 0.289393881 */, 17 },
+ /* 2719 */ { MAD_F(0x04a1f059) /* 0.289535854 */, 17 },
+
+ /* 2720 */ { MAD_F(0x04a2853c) /* 0.289677844 */, 17 },
+ /* 2721 */ { MAD_F(0x04a31a24) /* 0.289819851 */, 17 },
+ /* 2722 */ { MAD_F(0x04a3af10) /* 0.289961876 */, 17 },
+ /* 2723 */ { MAD_F(0x04a44401) /* 0.290103919 */, 17 },
+ /* 2724 */ { MAD_F(0x04a4d8f7) /* 0.290245979 */, 17 },
+ /* 2725 */ { MAD_F(0x04a56df2) /* 0.290388056 */, 17 },
+ /* 2726 */ { MAD_F(0x04a602f1) /* 0.290530150 */, 17 },
+ /* 2727 */ { MAD_F(0x04a697f5) /* 0.290672262 */, 17 },
+ /* 2728 */ { MAD_F(0x04a72cfe) /* 0.290814392 */, 17 },
+ /* 2729 */ { MAD_F(0x04a7c20b) /* 0.290956538 */, 17 },
+ /* 2730 */ { MAD_F(0x04a8571d) /* 0.291098703 */, 17 },
+ /* 2731 */ { MAD_F(0x04a8ec33) /* 0.291240884 */, 17 },
+ /* 2732 */ { MAD_F(0x04a9814e) /* 0.291383083 */, 17 },
+ /* 2733 */ { MAD_F(0x04aa166e) /* 0.291525299 */, 17 },
+ /* 2734 */ { MAD_F(0x04aaab93) /* 0.291667532 */, 17 },
+ /* 2735 */ { MAD_F(0x04ab40bc) /* 0.291809783 */, 17 },
+
+ /* 2736 */ { MAD_F(0x04abd5ea) /* 0.291952051 */, 17 },
+ /* 2737 */ { MAD_F(0x04ac6b1c) /* 0.292094337 */, 17 },
+ /* 2738 */ { MAD_F(0x04ad0053) /* 0.292236640 */, 17 },
+ /* 2739 */ { MAD_F(0x04ad958f) /* 0.292378960 */, 17 },
+ /* 2740 */ { MAD_F(0x04ae2ad0) /* 0.292521297 */, 17 },
+ /* 2741 */ { MAD_F(0x04aec015) /* 0.292663652 */, 17 },
+ /* 2742 */ { MAD_F(0x04af555e) /* 0.292806024 */, 17 },
+ /* 2743 */ { MAD_F(0x04afeaad) /* 0.292948414 */, 17 },
+ /* 2744 */ { MAD_F(0x04b08000) /* 0.293090820 */, 17 },
+ /* 2745 */ { MAD_F(0x04b11557) /* 0.293233244 */, 17 },
+ /* 2746 */ { MAD_F(0x04b1aab4) /* 0.293375686 */, 17 },
+ /* 2747 */ { MAD_F(0x04b24015) /* 0.293518144 */, 17 },
+ /* 2748 */ { MAD_F(0x04b2d57a) /* 0.293660620 */, 17 },
+ /* 2749 */ { MAD_F(0x04b36ae4) /* 0.293803113 */, 17 },
+ /* 2750 */ { MAD_F(0x04b40053) /* 0.293945624 */, 17 },
+ /* 2751 */ { MAD_F(0x04b495c7) /* 0.294088151 */, 17 },
+
+ /* 2752 */ { MAD_F(0x04b52b3f) /* 0.294230696 */, 17 },
+ /* 2753 */ { MAD_F(0x04b5c0bc) /* 0.294373259 */, 17 },
+ /* 2754 */ { MAD_F(0x04b6563d) /* 0.294515838 */, 17 },
+ /* 2755 */ { MAD_F(0x04b6ebc3) /* 0.294658435 */, 17 },
+ /* 2756 */ { MAD_F(0x04b7814e) /* 0.294801049 */, 17 },
+ /* 2757 */ { MAD_F(0x04b816dd) /* 0.294943680 */, 17 },
+ /* 2758 */ { MAD_F(0x04b8ac71) /* 0.295086329 */, 17 },
+ /* 2759 */ { MAD_F(0x04b9420a) /* 0.295228995 */, 17 },
+ /* 2760 */ { MAD_F(0x04b9d7a7) /* 0.295371678 */, 17 },
+ /* 2761 */ { MAD_F(0x04ba6d49) /* 0.295514378 */, 17 },
+ /* 2762 */ { MAD_F(0x04bb02ef) /* 0.295657095 */, 17 },
+ /* 2763 */ { MAD_F(0x04bb989a) /* 0.295799830 */, 17 },
+ /* 2764 */ { MAD_F(0x04bc2e4a) /* 0.295942582 */, 17 },
+ /* 2765 */ { MAD_F(0x04bcc3fe) /* 0.296085351 */, 17 },
+ /* 2766 */ { MAD_F(0x04bd59b7) /* 0.296228138 */, 17 },
+ /* 2767 */ { MAD_F(0x04bdef74) /* 0.296370941 */, 17 },
+
+ /* 2768 */ { MAD_F(0x04be8537) /* 0.296513762 */, 17 },
+ /* 2769 */ { MAD_F(0x04bf1afd) /* 0.296656600 */, 17 },
+ /* 2770 */ { MAD_F(0x04bfb0c9) /* 0.296799455 */, 17 },
+ /* 2771 */ { MAD_F(0x04c04699) /* 0.296942327 */, 17 },
+ /* 2772 */ { MAD_F(0x04c0dc6d) /* 0.297085217 */, 17 },
+ /* 2773 */ { MAD_F(0x04c17247) /* 0.297228124 */, 17 },
+ /* 2774 */ { MAD_F(0x04c20824) /* 0.297371048 */, 17 },
+ /* 2775 */ { MAD_F(0x04c29e07) /* 0.297513989 */, 17 },
+ /* 2776 */ { MAD_F(0x04c333ee) /* 0.297656947 */, 17 },
+ /* 2777 */ { MAD_F(0x04c3c9da) /* 0.297799922 */, 17 },
+ /* 2778 */ { MAD_F(0x04c45fca) /* 0.297942915 */, 17 },
+ /* 2779 */ { MAD_F(0x04c4f5bf) /* 0.298085925 */, 17 },
+ /* 2780 */ { MAD_F(0x04c58bb8) /* 0.298228951 */, 17 },
+ /* 2781 */ { MAD_F(0x04c621b6) /* 0.298371996 */, 17 },
+ /* 2782 */ { MAD_F(0x04c6b7b9) /* 0.298515057 */, 17 },
+ /* 2783 */ { MAD_F(0x04c74dc0) /* 0.298658135 */, 17 },
+
+ /* 2784 */ { MAD_F(0x04c7e3cc) /* 0.298801231 */, 17 },
+ /* 2785 */ { MAD_F(0x04c879dd) /* 0.298944343 */, 17 },
+ /* 2786 */ { MAD_F(0x04c90ff2) /* 0.299087473 */, 17 },
+ /* 2787 */ { MAD_F(0x04c9a60c) /* 0.299230620 */, 17 },
+ /* 2788 */ { MAD_F(0x04ca3c2a) /* 0.299373784 */, 17 },
+ /* 2789 */ { MAD_F(0x04cad24d) /* 0.299516965 */, 17 },
+ /* 2790 */ { MAD_F(0x04cb6874) /* 0.299660163 */, 17 },
+ /* 2791 */ { MAD_F(0x04cbfea0) /* 0.299803378 */, 17 },
+ /* 2792 */ { MAD_F(0x04cc94d1) /* 0.299946611 */, 17 },
+ /* 2793 */ { MAD_F(0x04cd2b06) /* 0.300089860 */, 17 },
+ /* 2794 */ { MAD_F(0x04cdc140) /* 0.300233127 */, 17 },
+ /* 2795 */ { MAD_F(0x04ce577f) /* 0.300376411 */, 17 },
+ /* 2796 */ { MAD_F(0x04ceedc2) /* 0.300519711 */, 17 },
+ /* 2797 */ { MAD_F(0x04cf8409) /* 0.300663029 */, 17 },
+ /* 2798 */ { MAD_F(0x04d01a55) /* 0.300806364 */, 17 },
+ /* 2799 */ { MAD_F(0x04d0b0a6) /* 0.300949716 */, 17 },
+
+ /* 2800 */ { MAD_F(0x04d146fb) /* 0.301093085 */, 17 },
+ /* 2801 */ { MAD_F(0x04d1dd55) /* 0.301236472 */, 17 },
+ /* 2802 */ { MAD_F(0x04d273b4) /* 0.301379875 */, 17 },
+ /* 2803 */ { MAD_F(0x04d30a17) /* 0.301523295 */, 17 },
+ /* 2804 */ { MAD_F(0x04d3a07f) /* 0.301666733 */, 17 },
+ /* 2805 */ { MAD_F(0x04d436eb) /* 0.301810187 */, 17 },
+ /* 2806 */ { MAD_F(0x04d4cd5c) /* 0.301953659 */, 17 },
+ /* 2807 */ { MAD_F(0x04d563d1) /* 0.302097147 */, 17 },
+ /* 2808 */ { MAD_F(0x04d5fa4b) /* 0.302240653 */, 17 },
+ /* 2809 */ { MAD_F(0x04d690ca) /* 0.302384175 */, 17 },
+ /* 2810 */ { MAD_F(0x04d7274d) /* 0.302527715 */, 17 },
+ /* 2811 */ { MAD_F(0x04d7bdd5) /* 0.302671271 */, 17 },
+ /* 2812 */ { MAD_F(0x04d85461) /* 0.302814845 */, 17 },
+ /* 2813 */ { MAD_F(0x04d8eaf2) /* 0.302958436 */, 17 },
+ /* 2814 */ { MAD_F(0x04d98187) /* 0.303102044 */, 17 },
+ /* 2815 */ { MAD_F(0x04da1821) /* 0.303245668 */, 17 },
+
+ /* 2816 */ { MAD_F(0x04daaec0) /* 0.303389310 */, 17 },
+ /* 2817 */ { MAD_F(0x04db4563) /* 0.303532969 */, 17 },
+ /* 2818 */ { MAD_F(0x04dbdc0a) /* 0.303676645 */, 17 },
+ /* 2819 */ { MAD_F(0x04dc72b7) /* 0.303820337 */, 17 },
+ /* 2820 */ { MAD_F(0x04dd0967) /* 0.303964047 */, 17 },
+ /* 2821 */ { MAD_F(0x04dda01d) /* 0.304107774 */, 17 },
+ /* 2822 */ { MAD_F(0x04de36d7) /* 0.304251517 */, 17 },
+ /* 2823 */ { MAD_F(0x04decd95) /* 0.304395278 */, 17 },
+ /* 2824 */ { MAD_F(0x04df6458) /* 0.304539056 */, 17 },
+ /* 2825 */ { MAD_F(0x04dffb20) /* 0.304682850 */, 17 },
+ /* 2826 */ { MAD_F(0x04e091ec) /* 0.304826662 */, 17 },
+ /* 2827 */ { MAD_F(0x04e128bc) /* 0.304970491 */, 17 },
+ /* 2828 */ { MAD_F(0x04e1bf92) /* 0.305114336 */, 17 },
+ /* 2829 */ { MAD_F(0x04e2566b) /* 0.305258199 */, 17 },
+ /* 2830 */ { MAD_F(0x04e2ed4a) /* 0.305402078 */, 17 },
+ /* 2831 */ { MAD_F(0x04e3842d) /* 0.305545974 */, 17 },
+
+ /* 2832 */ { MAD_F(0x04e41b14) /* 0.305689888 */, 17 },
+ /* 2833 */ { MAD_F(0x04e4b200) /* 0.305833818 */, 17 },
+ /* 2834 */ { MAD_F(0x04e548f1) /* 0.305977765 */, 17 },
+ /* 2835 */ { MAD_F(0x04e5dfe6) /* 0.306121729 */, 17 },
+ /* 2836 */ { MAD_F(0x04e676df) /* 0.306265710 */, 17 },
+ /* 2837 */ { MAD_F(0x04e70dde) /* 0.306409708 */, 17 },
+ /* 2838 */ { MAD_F(0x04e7a4e0) /* 0.306553723 */, 17 },
+ /* 2839 */ { MAD_F(0x04e83be7) /* 0.306697755 */, 17 },
+ /* 2840 */ { MAD_F(0x04e8d2f3) /* 0.306841804 */, 17 },
+ /* 2841 */ { MAD_F(0x04e96a04) /* 0.306985869 */, 17 },
+ /* 2842 */ { MAD_F(0x04ea0118) /* 0.307129952 */, 17 },
+ /* 2843 */ { MAD_F(0x04ea9832) /* 0.307274051 */, 17 },
+ /* 2844 */ { MAD_F(0x04eb2f50) /* 0.307418168 */, 17 },
+ /* 2845 */ { MAD_F(0x04ebc672) /* 0.307562301 */, 17 },
+ /* 2846 */ { MAD_F(0x04ec5d99) /* 0.307706451 */, 17 },
+ /* 2847 */ { MAD_F(0x04ecf4c5) /* 0.307850618 */, 17 },
+
+ /* 2848 */ { MAD_F(0x04ed8bf5) /* 0.307994802 */, 17 },
+ /* 2849 */ { MAD_F(0x04ee2329) /* 0.308139003 */, 17 },
+ /* 2850 */ { MAD_F(0x04eeba63) /* 0.308283220 */, 17 },
+ /* 2851 */ { MAD_F(0x04ef51a0) /* 0.308427455 */, 17 },
+ /* 2852 */ { MAD_F(0x04efe8e2) /* 0.308571706 */, 17 },
+ /* 2853 */ { MAD_F(0x04f08029) /* 0.308715974 */, 17 },
+ /* 2854 */ { MAD_F(0x04f11774) /* 0.308860260 */, 17 },
+ /* 2855 */ { MAD_F(0x04f1aec4) /* 0.309004561 */, 17 },
+ /* 2856 */ { MAD_F(0x04f24618) /* 0.309148880 */, 17 },
+ /* 2857 */ { MAD_F(0x04f2dd71) /* 0.309293216 */, 17 },
+ /* 2858 */ { MAD_F(0x04f374cf) /* 0.309437568 */, 17 },
+ /* 2859 */ { MAD_F(0x04f40c30) /* 0.309581938 */, 17 },
+ /* 2860 */ { MAD_F(0x04f4a397) /* 0.309726324 */, 17 },
+ /* 2861 */ { MAD_F(0x04f53b02) /* 0.309870727 */, 17 },
+ /* 2862 */ { MAD_F(0x04f5d271) /* 0.310015147 */, 17 },
+ /* 2863 */ { MAD_F(0x04f669e5) /* 0.310159583 */, 17 },
+
+ /* 2864 */ { MAD_F(0x04f7015d) /* 0.310304037 */, 17 },
+ /* 2865 */ { MAD_F(0x04f798da) /* 0.310448507 */, 17 },
+ /* 2866 */ { MAD_F(0x04f8305c) /* 0.310592994 */, 17 },
+ /* 2867 */ { MAD_F(0x04f8c7e2) /* 0.310737498 */, 17 },
+ /* 2868 */ { MAD_F(0x04f95f6c) /* 0.310882018 */, 17 },
+ /* 2869 */ { MAD_F(0x04f9f6fb) /* 0.311026556 */, 17 },
+ /* 2870 */ { MAD_F(0x04fa8e8f) /* 0.311171110 */, 17 },
+ /* 2871 */ { MAD_F(0x04fb2627) /* 0.311315681 */, 17 },
+ /* 2872 */ { MAD_F(0x04fbbdc3) /* 0.311460269 */, 17 },
+ /* 2873 */ { MAD_F(0x04fc5564) /* 0.311604874 */, 17 },
+ /* 2874 */ { MAD_F(0x04fced0a) /* 0.311749495 */, 17 },
+ /* 2875 */ { MAD_F(0x04fd84b4) /* 0.311894133 */, 17 },
+ /* 2876 */ { MAD_F(0x04fe1c62) /* 0.312038788 */, 17 },
+ /* 2877 */ { MAD_F(0x04feb415) /* 0.312183460 */, 17 },
+ /* 2878 */ { MAD_F(0x04ff4bcd) /* 0.312328148 */, 17 },
+ /* 2879 */ { MAD_F(0x04ffe389) /* 0.312472854 */, 17 },
+
+ /* 2880 */ { MAD_F(0x05007b49) /* 0.312617576 */, 17 },
+ /* 2881 */ { MAD_F(0x0501130e) /* 0.312762314 */, 17 },
+ /* 2882 */ { MAD_F(0x0501aad8) /* 0.312907070 */, 17 },
+ /* 2883 */ { MAD_F(0x050242a6) /* 0.313051842 */, 17 },
+ /* 2884 */ { MAD_F(0x0502da78) /* 0.313196631 */, 17 },
+ /* 2885 */ { MAD_F(0x0503724f) /* 0.313341437 */, 17 },
+ /* 2886 */ { MAD_F(0x05040a2b) /* 0.313486259 */, 17 },
+ /* 2887 */ { MAD_F(0x0504a20b) /* 0.313631098 */, 17 },
+ /* 2888 */ { MAD_F(0x050539ef) /* 0.313775954 */, 17 },
+ /* 2889 */ { MAD_F(0x0505d1d8) /* 0.313920827 */, 17 },
+ /* 2890 */ { MAD_F(0x050669c5) /* 0.314065716 */, 17 },
+ /* 2891 */ { MAD_F(0x050701b7) /* 0.314210622 */, 17 },
+ /* 2892 */ { MAD_F(0x050799ae) /* 0.314355545 */, 17 },
+ /* 2893 */ { MAD_F(0x050831a9) /* 0.314500484 */, 17 },
+ /* 2894 */ { MAD_F(0x0508c9a8) /* 0.314645440 */, 17 },
+ /* 2895 */ { MAD_F(0x050961ac) /* 0.314790413 */, 17 },
+
+ /* 2896 */ { MAD_F(0x0509f9b4) /* 0.314935403 */, 17 },
+ /* 2897 */ { MAD_F(0x050a91c1) /* 0.315080409 */, 17 },
+ /* 2898 */ { MAD_F(0x050b29d2) /* 0.315225432 */, 17 },
+ /* 2899 */ { MAD_F(0x050bc1e8) /* 0.315370472 */, 17 },
+ /* 2900 */ { MAD_F(0x050c5a02) /* 0.315515528 */, 17 },
+ /* 2901 */ { MAD_F(0x050cf221) /* 0.315660601 */, 17 },
+ /* 2902 */ { MAD_F(0x050d8a44) /* 0.315805690 */, 17 },
+ /* 2903 */ { MAD_F(0x050e226c) /* 0.315950797 */, 17 },
+ /* 2904 */ { MAD_F(0x050eba98) /* 0.316095920 */, 17 },
+ /* 2905 */ { MAD_F(0x050f52c9) /* 0.316241059 */, 17 },
+ /* 2906 */ { MAD_F(0x050feafe) /* 0.316386216 */, 17 },
+ /* 2907 */ { MAD_F(0x05108337) /* 0.316531388 */, 17 },
+ /* 2908 */ { MAD_F(0x05111b75) /* 0.316676578 */, 17 },
+ /* 2909 */ { MAD_F(0x0511b3b8) /* 0.316821784 */, 17 },
+ /* 2910 */ { MAD_F(0x05124bff) /* 0.316967007 */, 17 },
+ /* 2911 */ { MAD_F(0x0512e44a) /* 0.317112247 */, 17 },
+
+ /* 2912 */ { MAD_F(0x05137c9a) /* 0.317257503 */, 17 },
+ /* 2913 */ { MAD_F(0x051414ee) /* 0.317402775 */, 17 },
+ /* 2914 */ { MAD_F(0x0514ad47) /* 0.317548065 */, 17 },
+ /* 2915 */ { MAD_F(0x051545a5) /* 0.317693371 */, 17 },
+ /* 2916 */ { MAD_F(0x0515de06) /* 0.317838693 */, 17 },
+ /* 2917 */ { MAD_F(0x0516766d) /* 0.317984033 */, 17 },
+ /* 2918 */ { MAD_F(0x05170ed7) /* 0.318129388 */, 17 },
+ /* 2919 */ { MAD_F(0x0517a746) /* 0.318274761 */, 17 },
+ /* 2920 */ { MAD_F(0x05183fba) /* 0.318420150 */, 17 },
+ /* 2921 */ { MAD_F(0x0518d832) /* 0.318565555 */, 17 },
+ /* 2922 */ { MAD_F(0x051970ae) /* 0.318710978 */, 17 },
+ /* 2923 */ { MAD_F(0x051a092f) /* 0.318856416 */, 17 },
+ /* 2924 */ { MAD_F(0x051aa1b5) /* 0.319001872 */, 17 },
+ /* 2925 */ { MAD_F(0x051b3a3f) /* 0.319147344 */, 17 },
+ /* 2926 */ { MAD_F(0x051bd2cd) /* 0.319292832 */, 17 },
+ /* 2927 */ { MAD_F(0x051c6b60) /* 0.319438338 */, 17 },
+
+ /* 2928 */ { MAD_F(0x051d03f7) /* 0.319583859 */, 17 },
+ /* 2929 */ { MAD_F(0x051d9c92) /* 0.319729398 */, 17 },
+ /* 2930 */ { MAD_F(0x051e3532) /* 0.319874952 */, 17 },
+ /* 2931 */ { MAD_F(0x051ecdd7) /* 0.320020524 */, 17 },
+ /* 2932 */ { MAD_F(0x051f6680) /* 0.320166112 */, 17 },
+ /* 2933 */ { MAD_F(0x051fff2d) /* 0.320311716 */, 17 },
+ /* 2934 */ { MAD_F(0x052097df) /* 0.320457337 */, 17 },
+ /* 2935 */ { MAD_F(0x05213095) /* 0.320602975 */, 17 },
+ /* 2936 */ { MAD_F(0x0521c950) /* 0.320748629 */, 17 },
+ /* 2937 */ { MAD_F(0x0522620f) /* 0.320894300 */, 17 },
+ /* 2938 */ { MAD_F(0x0522fad3) /* 0.321039987 */, 17 },
+ /* 2939 */ { MAD_F(0x0523939b) /* 0.321185691 */, 17 },
+ /* 2940 */ { MAD_F(0x05242c68) /* 0.321331411 */, 17 },
+ /* 2941 */ { MAD_F(0x0524c538) /* 0.321477148 */, 17 },
+ /* 2942 */ { MAD_F(0x05255e0e) /* 0.321622901 */, 17 },
+ /* 2943 */ { MAD_F(0x0525f6e8) /* 0.321768671 */, 17 },
+
+ /* 2944 */ { MAD_F(0x05268fc6) /* 0.321914457 */, 17 },
+ /* 2945 */ { MAD_F(0x052728a9) /* 0.322060260 */, 17 },
+ /* 2946 */ { MAD_F(0x0527c190) /* 0.322206079 */, 17 },
+ /* 2947 */ { MAD_F(0x05285a7b) /* 0.322351915 */, 17 },
+ /* 2948 */ { MAD_F(0x0528f36b) /* 0.322497768 */, 17 },
+ /* 2949 */ { MAD_F(0x05298c5f) /* 0.322643636 */, 17 },
+ /* 2950 */ { MAD_F(0x052a2558) /* 0.322789522 */, 17 },
+ /* 2951 */ { MAD_F(0x052abe55) /* 0.322935424 */, 17 },
+ /* 2952 */ { MAD_F(0x052b5757) /* 0.323081342 */, 17 },
+ /* 2953 */ { MAD_F(0x052bf05d) /* 0.323227277 */, 17 },
+ /* 2954 */ { MAD_F(0x052c8968) /* 0.323373228 */, 17 },
+ /* 2955 */ { MAD_F(0x052d2277) /* 0.323519196 */, 17 },
+ /* 2956 */ { MAD_F(0x052dbb8a) /* 0.323665180 */, 17 },
+ /* 2957 */ { MAD_F(0x052e54a2) /* 0.323811180 */, 17 },
+ /* 2958 */ { MAD_F(0x052eedbe) /* 0.323957197 */, 17 },
+ /* 2959 */ { MAD_F(0x052f86de) /* 0.324103231 */, 17 },
+
+ /* 2960 */ { MAD_F(0x05302003) /* 0.324249281 */, 17 },
+ /* 2961 */ { MAD_F(0x0530b92d) /* 0.324395347 */, 17 },
+ /* 2962 */ { MAD_F(0x0531525b) /* 0.324541430 */, 17 },
+ /* 2963 */ { MAD_F(0x0531eb8d) /* 0.324687530 */, 17 },
+ /* 2964 */ { MAD_F(0x053284c4) /* 0.324833646 */, 17 },
+ /* 2965 */ { MAD_F(0x05331dff) /* 0.324979778 */, 17 },
+ /* 2966 */ { MAD_F(0x0533b73e) /* 0.325125926 */, 17 },
+ /* 2967 */ { MAD_F(0x05345082) /* 0.325272091 */, 17 },
+ /* 2968 */ { MAD_F(0x0534e9ca) /* 0.325418273 */, 17 },
+ /* 2969 */ { MAD_F(0x05358317) /* 0.325564471 */, 17 },
+ /* 2970 */ { MAD_F(0x05361c68) /* 0.325710685 */, 17 },
+ /* 2971 */ { MAD_F(0x0536b5be) /* 0.325856916 */, 17 },
+ /* 2972 */ { MAD_F(0x05374f17) /* 0.326003163 */, 17 },
+ /* 2973 */ { MAD_F(0x0537e876) /* 0.326149427 */, 17 },
+ /* 2974 */ { MAD_F(0x053881d9) /* 0.326295707 */, 17 },
+ /* 2975 */ { MAD_F(0x05391b40) /* 0.326442003 */, 17 },
+
+ /* 2976 */ { MAD_F(0x0539b4ab) /* 0.326588316 */, 17 },
+ /* 2977 */ { MAD_F(0x053a4e1b) /* 0.326734645 */, 17 },
+ /* 2978 */ { MAD_F(0x053ae78f) /* 0.326880990 */, 17 },
+ /* 2979 */ { MAD_F(0x053b8108) /* 0.327027352 */, 17 },
+ /* 2980 */ { MAD_F(0x053c1a85) /* 0.327173730 */, 17 },
+ /* 2981 */ { MAD_F(0x053cb407) /* 0.327320125 */, 17 },
+ /* 2982 */ { MAD_F(0x053d4d8d) /* 0.327466536 */, 17 },
+ /* 2983 */ { MAD_F(0x053de717) /* 0.327612963 */, 17 },
+ /* 2984 */ { MAD_F(0x053e80a6) /* 0.327759407 */, 17 },
+ /* 2985 */ { MAD_F(0x053f1a39) /* 0.327905867 */, 17 },
+ /* 2986 */ { MAD_F(0x053fb3d0) /* 0.328052344 */, 17 },
+ /* 2987 */ { MAD_F(0x05404d6c) /* 0.328198837 */, 17 },
+ /* 2988 */ { MAD_F(0x0540e70c) /* 0.328345346 */, 17 },
+ /* 2989 */ { MAD_F(0x054180b1) /* 0.328491871 */, 17 },
+ /* 2990 */ { MAD_F(0x05421a5a) /* 0.328638413 */, 17 },
+ /* 2991 */ { MAD_F(0x0542b407) /* 0.328784971 */, 17 },
+
+ /* 2992 */ { MAD_F(0x05434db9) /* 0.328931546 */, 17 },
+ /* 2993 */ { MAD_F(0x0543e76f) /* 0.329078137 */, 17 },
+ /* 2994 */ { MAD_F(0x0544812a) /* 0.329224744 */, 17 },
+ /* 2995 */ { MAD_F(0x05451ae9) /* 0.329371367 */, 17 },
+ /* 2996 */ { MAD_F(0x0545b4ac) /* 0.329518007 */, 17 },
+ /* 2997 */ { MAD_F(0x05464e74) /* 0.329664663 */, 17 },
+ /* 2998 */ { MAD_F(0x0546e840) /* 0.329811336 */, 17 },
+ /* 2999 */ { MAD_F(0x05478211) /* 0.329958024 */, 17 },
+ /* 3000 */ { MAD_F(0x05481be5) /* 0.330104730 */, 17 },
+ /* 3001 */ { MAD_F(0x0548b5bf) /* 0.330251451 */, 17 },
+ /* 3002 */ { MAD_F(0x05494f9c) /* 0.330398189 */, 17 },
+ /* 3003 */ { MAD_F(0x0549e97e) /* 0.330544943 */, 17 },
+ /* 3004 */ { MAD_F(0x054a8364) /* 0.330691713 */, 17 },
+ /* 3005 */ { MAD_F(0x054b1d4f) /* 0.330838499 */, 17 },
+ /* 3006 */ { MAD_F(0x054bb73e) /* 0.330985302 */, 17 },
+ /* 3007 */ { MAD_F(0x054c5132) /* 0.331132121 */, 17 },
+
+ /* 3008 */ { MAD_F(0x054ceb2a) /* 0.331278957 */, 17 },
+ /* 3009 */ { MAD_F(0x054d8526) /* 0.331425808 */, 17 },
+ /* 3010 */ { MAD_F(0x054e1f26) /* 0.331572676 */, 17 },
+ /* 3011 */ { MAD_F(0x054eb92b) /* 0.331719560 */, 17 },
+ /* 3012 */ { MAD_F(0x054f5334) /* 0.331866461 */, 17 },
+ /* 3013 */ { MAD_F(0x054fed42) /* 0.332013377 */, 17 },
+ /* 3014 */ { MAD_F(0x05508754) /* 0.332160310 */, 17 },
+ /* 3015 */ { MAD_F(0x0551216b) /* 0.332307260 */, 17 },
+ /* 3016 */ { MAD_F(0x0551bb85) /* 0.332454225 */, 17 },
+ /* 3017 */ { MAD_F(0x055255a4) /* 0.332601207 */, 17 },
+ /* 3018 */ { MAD_F(0x0552efc8) /* 0.332748205 */, 17 },
+ /* 3019 */ { MAD_F(0x055389f0) /* 0.332895219 */, 17 },
+ /* 3020 */ { MAD_F(0x0554241c) /* 0.333042249 */, 17 },
+ /* 3021 */ { MAD_F(0x0554be4c) /* 0.333189296 */, 17 },
+ /* 3022 */ { MAD_F(0x05555881) /* 0.333336359 */, 17 },
+ /* 3023 */ { MAD_F(0x0555f2ba) /* 0.333483438 */, 17 },
+
+ /* 3024 */ { MAD_F(0x05568cf8) /* 0.333630533 */, 17 },
+ /* 3025 */ { MAD_F(0x0557273a) /* 0.333777645 */, 17 },
+ /* 3026 */ { MAD_F(0x0557c180) /* 0.333924772 */, 17 },
+ /* 3027 */ { MAD_F(0x05585bcb) /* 0.334071916 */, 17 },
+ /* 3028 */ { MAD_F(0x0558f61a) /* 0.334219076 */, 17 },
+ /* 3029 */ { MAD_F(0x0559906d) /* 0.334366253 */, 17 },
+ /* 3030 */ { MAD_F(0x055a2ac5) /* 0.334513445 */, 17 },
+ /* 3031 */ { MAD_F(0x055ac521) /* 0.334660654 */, 17 },
+ /* 3032 */ { MAD_F(0x055b5f81) /* 0.334807879 */, 17 },
+ /* 3033 */ { MAD_F(0x055bf9e6) /* 0.334955120 */, 17 },
+ /* 3034 */ { MAD_F(0x055c944f) /* 0.335102377 */, 17 },
+ /* 3035 */ { MAD_F(0x055d2ebd) /* 0.335249651 */, 17 },
+ /* 3036 */ { MAD_F(0x055dc92e) /* 0.335396941 */, 17 },
+ /* 3037 */ { MAD_F(0x055e63a5) /* 0.335544246 */, 17 },
+ /* 3038 */ { MAD_F(0x055efe1f) /* 0.335691568 */, 17 },
+ /* 3039 */ { MAD_F(0x055f989e) /* 0.335838906 */, 17 },
+
+ /* 3040 */ { MAD_F(0x05603321) /* 0.335986261 */, 17 },
+ /* 3041 */ { MAD_F(0x0560cda8) /* 0.336133631 */, 17 },
+ /* 3042 */ { MAD_F(0x05616834) /* 0.336281018 */, 17 },
+ /* 3043 */ { MAD_F(0x056202c4) /* 0.336428421 */, 17 },
+ /* 3044 */ { MAD_F(0x05629d59) /* 0.336575840 */, 17 },
+ /* 3045 */ { MAD_F(0x056337f2) /* 0.336723275 */, 17 },
+ /* 3046 */ { MAD_F(0x0563d28f) /* 0.336870726 */, 17 },
+ /* 3047 */ { MAD_F(0x05646d30) /* 0.337018193 */, 17 },
+ /* 3048 */ { MAD_F(0x056507d6) /* 0.337165677 */, 17 },
+ /* 3049 */ { MAD_F(0x0565a280) /* 0.337313176 */, 17 },
+ /* 3050 */ { MAD_F(0x05663d2f) /* 0.337460692 */, 17 },
+ /* 3051 */ { MAD_F(0x0566d7e1) /* 0.337608224 */, 17 },
+ /* 3052 */ { MAD_F(0x05677298) /* 0.337755772 */, 17 },
+ /* 3053 */ { MAD_F(0x05680d54) /* 0.337903336 */, 17 },
+ /* 3054 */ { MAD_F(0x0568a814) /* 0.338050916 */, 17 },
+ /* 3055 */ { MAD_F(0x056942d8) /* 0.338198513 */, 17 },
+
+ /* 3056 */ { MAD_F(0x0569dda0) /* 0.338346125 */, 17 },
+ /* 3057 */ { MAD_F(0x056a786d) /* 0.338493753 */, 17 },
+ /* 3058 */ { MAD_F(0x056b133e) /* 0.338641398 */, 17 },
+ /* 3059 */ { MAD_F(0x056bae13) /* 0.338789059 */, 17 },
+ /* 3060 */ { MAD_F(0x056c48ed) /* 0.338936736 */, 17 },
+ /* 3061 */ { MAD_F(0x056ce3cb) /* 0.339084429 */, 17 },
+ /* 3062 */ { MAD_F(0x056d7ead) /* 0.339232138 */, 17 },
+ /* 3063 */ { MAD_F(0x056e1994) /* 0.339379863 */, 17 },
+ /* 3064 */ { MAD_F(0x056eb47f) /* 0.339527604 */, 17 },
+ /* 3065 */ { MAD_F(0x056f4f6e) /* 0.339675361 */, 17 },
+ /* 3066 */ { MAD_F(0x056fea62) /* 0.339823134 */, 17 },
+ /* 3067 */ { MAD_F(0x0570855a) /* 0.339970924 */, 17 },
+ /* 3068 */ { MAD_F(0x05712056) /* 0.340118729 */, 17 },
+ /* 3069 */ { MAD_F(0x0571bb56) /* 0.340266550 */, 17 },
+ /* 3070 */ { MAD_F(0x0572565b) /* 0.340414388 */, 17 },
+ /* 3071 */ { MAD_F(0x0572f164) /* 0.340562242 */, 17 },
+
+ /* 3072 */ { MAD_F(0x05738c72) /* 0.340710111 */, 17 },
+ /* 3073 */ { MAD_F(0x05742784) /* 0.340857997 */, 17 },
+ /* 3074 */ { MAD_F(0x0574c29a) /* 0.341005899 */, 17 },
+ /* 3075 */ { MAD_F(0x05755db4) /* 0.341153816 */, 17 },
+ /* 3076 */ { MAD_F(0x0575f8d3) /* 0.341301750 */, 17 },
+ /* 3077 */ { MAD_F(0x057693f6) /* 0.341449700 */, 17 },
+ /* 3078 */ { MAD_F(0x05772f1d) /* 0.341597666 */, 17 },
+ /* 3079 */ { MAD_F(0x0577ca49) /* 0.341745648 */, 17 },
+ /* 3080 */ { MAD_F(0x05786578) /* 0.341893646 */, 17 },
+ /* 3081 */ { MAD_F(0x057900ad) /* 0.342041659 */, 17 },
+ /* 3082 */ { MAD_F(0x05799be5) /* 0.342189689 */, 17 },
+ /* 3083 */ { MAD_F(0x057a3722) /* 0.342337735 */, 17 },
+ /* 3084 */ { MAD_F(0x057ad263) /* 0.342485797 */, 17 },
+ /* 3085 */ { MAD_F(0x057b6da8) /* 0.342633875 */, 17 },
+ /* 3086 */ { MAD_F(0x057c08f2) /* 0.342781969 */, 17 },
+ /* 3087 */ { MAD_F(0x057ca440) /* 0.342930079 */, 17 },
+
+ /* 3088 */ { MAD_F(0x057d3f92) /* 0.343078205 */, 17 },
+ /* 3089 */ { MAD_F(0x057ddae9) /* 0.343226347 */, 17 },
+ /* 3090 */ { MAD_F(0x057e7644) /* 0.343374505 */, 17 },
+ /* 3091 */ { MAD_F(0x057f11a3) /* 0.343522679 */, 17 },
+ /* 3092 */ { MAD_F(0x057fad06) /* 0.343670869 */, 17 },
+ /* 3093 */ { MAD_F(0x0580486e) /* 0.343819075 */, 17 },
+ /* 3094 */ { MAD_F(0x0580e3da) /* 0.343967296 */, 17 },
+ /* 3095 */ { MAD_F(0x05817f4a) /* 0.344115534 */, 17 },
+ /* 3096 */ { MAD_F(0x05821abf) /* 0.344263788 */, 17 },
+ /* 3097 */ { MAD_F(0x0582b638) /* 0.344412058 */, 17 },
+ /* 3098 */ { MAD_F(0x058351b5) /* 0.344560343 */, 17 },
+ /* 3099 */ { MAD_F(0x0583ed36) /* 0.344708645 */, 17 },
+ /* 3100 */ { MAD_F(0x058488bc) /* 0.344856963 */, 17 },
+ /* 3101 */ { MAD_F(0x05852446) /* 0.345005296 */, 17 },
+ /* 3102 */ { MAD_F(0x0585bfd4) /* 0.345153646 */, 17 },
+ /* 3103 */ { MAD_F(0x05865b67) /* 0.345302011 */, 17 },
+
+ /* 3104 */ { MAD_F(0x0586f6fd) /* 0.345450393 */, 17 },
+ /* 3105 */ { MAD_F(0x05879298) /* 0.345598790 */, 17 },
+ /* 3106 */ { MAD_F(0x05882e38) /* 0.345747203 */, 17 },
+ /* 3107 */ { MAD_F(0x0588c9dc) /* 0.345895632 */, 17 },
+ /* 3108 */ { MAD_F(0x05896583) /* 0.346044077 */, 17 },
+ /* 3109 */ { MAD_F(0x058a0130) /* 0.346192538 */, 17 },
+ /* 3110 */ { MAD_F(0x058a9ce0) /* 0.346341015 */, 17 },
+ /* 3111 */ { MAD_F(0x058b3895) /* 0.346489508 */, 17 },
+ /* 3112 */ { MAD_F(0x058bd44e) /* 0.346638017 */, 17 },
+ /* 3113 */ { MAD_F(0x058c700b) /* 0.346786542 */, 17 },
+ /* 3114 */ { MAD_F(0x058d0bcd) /* 0.346935082 */, 17 },
+ /* 3115 */ { MAD_F(0x058da793) /* 0.347083639 */, 17 },
+ /* 3116 */ { MAD_F(0x058e435d) /* 0.347232211 */, 17 },
+ /* 3117 */ { MAD_F(0x058edf2b) /* 0.347380799 */, 17 },
+ /* 3118 */ { MAD_F(0x058f7afe) /* 0.347529403 */, 17 },
+ /* 3119 */ { MAD_F(0x059016d5) /* 0.347678023 */, 17 },
+
+ /* 3120 */ { MAD_F(0x0590b2b0) /* 0.347826659 */, 17 },
+ /* 3121 */ { MAD_F(0x05914e8f) /* 0.347975311 */, 17 },
+ /* 3122 */ { MAD_F(0x0591ea73) /* 0.348123979 */, 17 },
+ /* 3123 */ { MAD_F(0x0592865b) /* 0.348272662 */, 17 },
+ /* 3124 */ { MAD_F(0x05932247) /* 0.348421362 */, 17 },
+ /* 3125 */ { MAD_F(0x0593be37) /* 0.348570077 */, 17 },
+ /* 3126 */ { MAD_F(0x05945a2c) /* 0.348718808 */, 17 },
+ /* 3127 */ { MAD_F(0x0594f625) /* 0.348867555 */, 17 },
+ /* 3128 */ { MAD_F(0x05959222) /* 0.349016318 */, 17 },
+ /* 3129 */ { MAD_F(0x05962e24) /* 0.349165097 */, 17 },
+ /* 3130 */ { MAD_F(0x0596ca2a) /* 0.349313892 */, 17 },
+ /* 3131 */ { MAD_F(0x05976634) /* 0.349462702 */, 17 },
+ /* 3132 */ { MAD_F(0x05980242) /* 0.349611528 */, 17 },
+ /* 3133 */ { MAD_F(0x05989e54) /* 0.349760370 */, 17 },
+ /* 3134 */ { MAD_F(0x05993a6b) /* 0.349909228 */, 17 },
+ /* 3135 */ { MAD_F(0x0599d686) /* 0.350058102 */, 17 },
+
+ /* 3136 */ { MAD_F(0x059a72a5) /* 0.350206992 */, 17 },
+ /* 3137 */ { MAD_F(0x059b0ec9) /* 0.350355897 */, 17 },
+ /* 3138 */ { MAD_F(0x059baaf1) /* 0.350504818 */, 17 },
+ /* 3139 */ { MAD_F(0x059c471d) /* 0.350653756 */, 17 },
+ /* 3140 */ { MAD_F(0x059ce34d) /* 0.350802708 */, 17 },
+ /* 3141 */ { MAD_F(0x059d7f81) /* 0.350951677 */, 17 },
+ /* 3142 */ { MAD_F(0x059e1bba) /* 0.351100662 */, 17 },
+ /* 3143 */ { MAD_F(0x059eb7f7) /* 0.351249662 */, 17 },
+ /* 3144 */ { MAD_F(0x059f5438) /* 0.351398678 */, 17 },
+ /* 3145 */ { MAD_F(0x059ff07e) /* 0.351547710 */, 17 },
+ /* 3146 */ { MAD_F(0x05a08cc7) /* 0.351696758 */, 17 },
+ /* 3147 */ { MAD_F(0x05a12915) /* 0.351845821 */, 17 },
+ /* 3148 */ { MAD_F(0x05a1c567) /* 0.351994901 */, 17 },
+ /* 3149 */ { MAD_F(0x05a261be) /* 0.352143996 */, 17 },
+ /* 3150 */ { MAD_F(0x05a2fe18) /* 0.352293107 */, 17 },
+ /* 3151 */ { MAD_F(0x05a39a77) /* 0.352442233 */, 17 },
+
+ /* 3152 */ { MAD_F(0x05a436da) /* 0.352591376 */, 17 },
+ /* 3153 */ { MAD_F(0x05a4d342) /* 0.352740534 */, 17 },
+ /* 3154 */ { MAD_F(0x05a56fad) /* 0.352889708 */, 17 },
+ /* 3155 */ { MAD_F(0x05a60c1d) /* 0.353038898 */, 17 },
+ /* 3156 */ { MAD_F(0x05a6a891) /* 0.353188103 */, 17 },
+ /* 3157 */ { MAD_F(0x05a7450a) /* 0.353337325 */, 17 },
+ /* 3158 */ { MAD_F(0x05a7e186) /* 0.353486562 */, 17 },
+ /* 3159 */ { MAD_F(0x05a87e07) /* 0.353635814 */, 17 },
+ /* 3160 */ { MAD_F(0x05a91a8c) /* 0.353785083 */, 17 },
+ /* 3161 */ { MAD_F(0x05a9b715) /* 0.353934367 */, 17 },
+ /* 3162 */ { MAD_F(0x05aa53a2) /* 0.354083667 */, 17 },
+ /* 3163 */ { MAD_F(0x05aaf034) /* 0.354232983 */, 17 },
+ /* 3164 */ { MAD_F(0x05ab8cca) /* 0.354382314 */, 17 },
+ /* 3165 */ { MAD_F(0x05ac2964) /* 0.354531662 */, 17 },
+ /* 3166 */ { MAD_F(0x05acc602) /* 0.354681025 */, 17 },
+ /* 3167 */ { MAD_F(0x05ad62a5) /* 0.354830403 */, 17 },
+
+ /* 3168 */ { MAD_F(0x05adff4c) /* 0.354979798 */, 17 },
+ /* 3169 */ { MAD_F(0x05ae9bf7) /* 0.355129208 */, 17 },
+ /* 3170 */ { MAD_F(0x05af38a6) /* 0.355278634 */, 17 },
+ /* 3171 */ { MAD_F(0x05afd559) /* 0.355428075 */, 17 },
+ /* 3172 */ { MAD_F(0x05b07211) /* 0.355577533 */, 17 },
+ /* 3173 */ { MAD_F(0x05b10ecd) /* 0.355727006 */, 17 },
+ /* 3174 */ { MAD_F(0x05b1ab8d) /* 0.355876494 */, 17 },
+ /* 3175 */ { MAD_F(0x05b24851) /* 0.356025999 */, 17 },
+ /* 3176 */ { MAD_F(0x05b2e51a) /* 0.356175519 */, 17 },
+ /* 3177 */ { MAD_F(0x05b381e6) /* 0.356325054 */, 17 },
+ /* 3178 */ { MAD_F(0x05b41eb7) /* 0.356474606 */, 17 },
+ /* 3179 */ { MAD_F(0x05b4bb8c) /* 0.356624173 */, 17 },
+ /* 3180 */ { MAD_F(0x05b55866) /* 0.356773756 */, 17 },
+ /* 3181 */ { MAD_F(0x05b5f543) /* 0.356923354 */, 17 },
+ /* 3182 */ { MAD_F(0x05b69225) /* 0.357072969 */, 17 },
+ /* 3183 */ { MAD_F(0x05b72f0b) /* 0.357222598 */, 17 },
+
+ /* 3184 */ { MAD_F(0x05b7cbf5) /* 0.357372244 */, 17 },
+ /* 3185 */ { MAD_F(0x05b868e3) /* 0.357521905 */, 17 },
+ /* 3186 */ { MAD_F(0x05b905d6) /* 0.357671582 */, 17 },
+ /* 3187 */ { MAD_F(0x05b9a2cd) /* 0.357821275 */, 17 },
+ /* 3188 */ { MAD_F(0x05ba3fc8) /* 0.357970983 */, 17 },
+ /* 3189 */ { MAD_F(0x05badcc7) /* 0.358120707 */, 17 },
+ /* 3190 */ { MAD_F(0x05bb79ca) /* 0.358270446 */, 17 },
+ /* 3191 */ { MAD_F(0x05bc16d2) /* 0.358420201 */, 17 },
+ /* 3192 */ { MAD_F(0x05bcb3de) /* 0.358569972 */, 17 },
+ /* 3193 */ { MAD_F(0x05bd50ee) /* 0.358719758 */, 17 },
+ /* 3194 */ { MAD_F(0x05bdee02) /* 0.358869560 */, 17 },
+ /* 3195 */ { MAD_F(0x05be8b1a) /* 0.359019378 */, 17 },
+ /* 3196 */ { MAD_F(0x05bf2837) /* 0.359169211 */, 17 },
+ /* 3197 */ { MAD_F(0x05bfc558) /* 0.359319060 */, 17 },
+ /* 3198 */ { MAD_F(0x05c0627d) /* 0.359468925 */, 17 },
+ /* 3199 */ { MAD_F(0x05c0ffa6) /* 0.359618805 */, 17 },
+
+ /* 3200 */ { MAD_F(0x05c19cd3) /* 0.359768701 */, 17 },
+ /* 3201 */ { MAD_F(0x05c23a05) /* 0.359918612 */, 17 },
+ /* 3202 */ { MAD_F(0x05c2d73a) /* 0.360068540 */, 17 },
+ /* 3203 */ { MAD_F(0x05c37474) /* 0.360218482 */, 17 },
+ /* 3204 */ { MAD_F(0x05c411b2) /* 0.360368440 */, 17 },
+ /* 3205 */ { MAD_F(0x05c4aef5) /* 0.360518414 */, 17 },
+ /* 3206 */ { MAD_F(0x05c54c3b) /* 0.360668404 */, 17 },
+ /* 3207 */ { MAD_F(0x05c5e986) /* 0.360818409 */, 17 },
+ /* 3208 */ { MAD_F(0x05c686d5) /* 0.360968429 */, 17 },
+ /* 3209 */ { MAD_F(0x05c72428) /* 0.361118466 */, 17 },
+ /* 3210 */ { MAD_F(0x05c7c17f) /* 0.361268517 */, 17 },
+ /* 3211 */ { MAD_F(0x05c85eda) /* 0.361418585 */, 17 },
+ /* 3212 */ { MAD_F(0x05c8fc3a) /* 0.361568668 */, 17 },
+ /* 3213 */ { MAD_F(0x05c9999e) /* 0.361718766 */, 17 },
+ /* 3214 */ { MAD_F(0x05ca3706) /* 0.361868881 */, 17 },
+ /* 3215 */ { MAD_F(0x05cad472) /* 0.362019010 */, 17 },
+
+ /* 3216 */ { MAD_F(0x05cb71e2) /* 0.362169156 */, 17 },
+ /* 3217 */ { MAD_F(0x05cc0f57) /* 0.362319316 */, 17 },
+ /* 3218 */ { MAD_F(0x05ccaccf) /* 0.362469493 */, 17 },
+ /* 3219 */ { MAD_F(0x05cd4a4c) /* 0.362619685 */, 17 },
+ /* 3220 */ { MAD_F(0x05cde7cd) /* 0.362769892 */, 17 },
+ /* 3221 */ { MAD_F(0x05ce8552) /* 0.362920115 */, 17 },
+ /* 3222 */ { MAD_F(0x05cf22dc) /* 0.363070354 */, 17 },
+ /* 3223 */ { MAD_F(0x05cfc069) /* 0.363220608 */, 17 },
+ /* 3224 */ { MAD_F(0x05d05dfb) /* 0.363370878 */, 17 },
+ /* 3225 */ { MAD_F(0x05d0fb91) /* 0.363521163 */, 17 },
+ /* 3226 */ { MAD_F(0x05d1992b) /* 0.363671464 */, 17 },
+ /* 3227 */ { MAD_F(0x05d236c9) /* 0.363821780 */, 17 },
+ /* 3228 */ { MAD_F(0x05d2d46c) /* 0.363972112 */, 17 },
+ /* 3229 */ { MAD_F(0x05d37212) /* 0.364122459 */, 17 },
+ /* 3230 */ { MAD_F(0x05d40fbd) /* 0.364272822 */, 17 },
+ /* 3231 */ { MAD_F(0x05d4ad6c) /* 0.364423200 */, 17 },
+
+ /* 3232 */ { MAD_F(0x05d54b1f) /* 0.364573594 */, 17 },
+ /* 3233 */ { MAD_F(0x05d5e8d6) /* 0.364724004 */, 17 },
+ /* 3234 */ { MAD_F(0x05d68691) /* 0.364874429 */, 17 },
+ /* 3235 */ { MAD_F(0x05d72451) /* 0.365024869 */, 17 },
+ /* 3236 */ { MAD_F(0x05d7c215) /* 0.365175325 */, 17 },
+ /* 3237 */ { MAD_F(0x05d85fdc) /* 0.365325796 */, 17 },
+ /* 3238 */ { MAD_F(0x05d8fda8) /* 0.365476283 */, 17 },
+ /* 3239 */ { MAD_F(0x05d99b79) /* 0.365626786 */, 17 },
+ /* 3240 */ { MAD_F(0x05da394d) /* 0.365777304 */, 17 },
+ /* 3241 */ { MAD_F(0x05dad726) /* 0.365927837 */, 17 },
+ /* 3242 */ { MAD_F(0x05db7502) /* 0.366078386 */, 17 },
+ /* 3243 */ { MAD_F(0x05dc12e3) /* 0.366228950 */, 17 },
+ /* 3244 */ { MAD_F(0x05dcb0c8) /* 0.366379530 */, 17 },
+ /* 3245 */ { MAD_F(0x05dd4eb1) /* 0.366530125 */, 17 },
+ /* 3246 */ { MAD_F(0x05ddec9e) /* 0.366680736 */, 17 },
+ /* 3247 */ { MAD_F(0x05de8a90) /* 0.366831362 */, 17 },
+
+ /* 3248 */ { MAD_F(0x05df2885) /* 0.366982004 */, 17 },
+ /* 3249 */ { MAD_F(0x05dfc67f) /* 0.367132661 */, 17 },
+ /* 3250 */ { MAD_F(0x05e0647d) /* 0.367283334 */, 17 },
+ /* 3251 */ { MAD_F(0x05e1027f) /* 0.367434022 */, 17 },
+ /* 3252 */ { MAD_F(0x05e1a085) /* 0.367584725 */, 17 },
+ /* 3253 */ { MAD_F(0x05e23e8f) /* 0.367735444 */, 17 },
+ /* 3254 */ { MAD_F(0x05e2dc9e) /* 0.367886179 */, 17 },
+ /* 3255 */ { MAD_F(0x05e37ab0) /* 0.368036929 */, 17 },
+ /* 3256 */ { MAD_F(0x05e418c7) /* 0.368187694 */, 17 },
+ /* 3257 */ { MAD_F(0x05e4b6e2) /* 0.368338475 */, 17 },
+ /* 3258 */ { MAD_F(0x05e55501) /* 0.368489271 */, 17 },
+ /* 3259 */ { MAD_F(0x05e5f324) /* 0.368640082 */, 17 },
+ /* 3260 */ { MAD_F(0x05e6914c) /* 0.368790909 */, 17 },
+ /* 3261 */ { MAD_F(0x05e72f77) /* 0.368941752 */, 17 },
+ /* 3262 */ { MAD_F(0x05e7cda7) /* 0.369092610 */, 17 },
+ /* 3263 */ { MAD_F(0x05e86bda) /* 0.369243483 */, 17 },
+
+ /* 3264 */ { MAD_F(0x05e90a12) /* 0.369394372 */, 17 },
+ /* 3265 */ { MAD_F(0x05e9a84e) /* 0.369545276 */, 17 },
+ /* 3266 */ { MAD_F(0x05ea468e) /* 0.369696195 */, 17 },
+ /* 3267 */ { MAD_F(0x05eae4d3) /* 0.369847130 */, 17 },
+ /* 3268 */ { MAD_F(0x05eb831b) /* 0.369998080 */, 17 },
+ /* 3269 */ { MAD_F(0x05ec2168) /* 0.370149046 */, 17 },
+ /* 3270 */ { MAD_F(0x05ecbfb8) /* 0.370300027 */, 17 },
+ /* 3271 */ { MAD_F(0x05ed5e0d) /* 0.370451024 */, 17 },
+ /* 3272 */ { MAD_F(0x05edfc66) /* 0.370602036 */, 17 },
+ /* 3273 */ { MAD_F(0x05ee9ac3) /* 0.370753063 */, 17 },
+ /* 3274 */ { MAD_F(0x05ef3924) /* 0.370904105 */, 17 },
+ /* 3275 */ { MAD_F(0x05efd78a) /* 0.371055163 */, 17 },
+ /* 3276 */ { MAD_F(0x05f075f3) /* 0.371206237 */, 17 },
+ /* 3277 */ { MAD_F(0x05f11461) /* 0.371357326 */, 17 },
+ /* 3278 */ { MAD_F(0x05f1b2d3) /* 0.371508430 */, 17 },
+ /* 3279 */ { MAD_F(0x05f25148) /* 0.371659549 */, 17 },
+
+ /* 3280 */ { MAD_F(0x05f2efc2) /* 0.371810684 */, 17 },
+ /* 3281 */ { MAD_F(0x05f38e40) /* 0.371961834 */, 17 },
+ /* 3282 */ { MAD_F(0x05f42cc3) /* 0.372113000 */, 17 },
+ /* 3283 */ { MAD_F(0x05f4cb49) /* 0.372264181 */, 17 },
+ /* 3284 */ { MAD_F(0x05f569d3) /* 0.372415377 */, 17 },
+ /* 3285 */ { MAD_F(0x05f60862) /* 0.372566589 */, 17 },
+ /* 3286 */ { MAD_F(0x05f6a6f5) /* 0.372717816 */, 17 },
+ /* 3287 */ { MAD_F(0x05f7458b) /* 0.372869058 */, 17 },
+ /* 3288 */ { MAD_F(0x05f7e426) /* 0.373020316 */, 17 },
+ /* 3289 */ { MAD_F(0x05f882c5) /* 0.373171589 */, 17 },
+ /* 3290 */ { MAD_F(0x05f92169) /* 0.373322877 */, 17 },
+ /* 3291 */ { MAD_F(0x05f9c010) /* 0.373474181 */, 17 },
+ /* 3292 */ { MAD_F(0x05fa5ebb) /* 0.373625500 */, 17 },
+ /* 3293 */ { MAD_F(0x05fafd6b) /* 0.373776834 */, 17 },
+ /* 3294 */ { MAD_F(0x05fb9c1e) /* 0.373928184 */, 17 },
+ /* 3295 */ { MAD_F(0x05fc3ad6) /* 0.374079549 */, 17 },
+
+ /* 3296 */ { MAD_F(0x05fcd992) /* 0.374230929 */, 17 },
+ /* 3297 */ { MAD_F(0x05fd7852) /* 0.374382325 */, 17 },
+ /* 3298 */ { MAD_F(0x05fe1716) /* 0.374533735 */, 17 },
+ /* 3299 */ { MAD_F(0x05feb5de) /* 0.374685162 */, 17 },
+ /* 3300 */ { MAD_F(0x05ff54aa) /* 0.374836603 */, 17 },
+ /* 3301 */ { MAD_F(0x05fff37b) /* 0.374988060 */, 17 },
+ /* 3302 */ { MAD_F(0x0600924f) /* 0.375139532 */, 17 },
+ /* 3303 */ { MAD_F(0x06013128) /* 0.375291019 */, 17 },
+ /* 3304 */ { MAD_F(0x0601d004) /* 0.375442522 */, 17 },
+ /* 3305 */ { MAD_F(0x06026ee5) /* 0.375594040 */, 17 },
+ /* 3306 */ { MAD_F(0x06030dca) /* 0.375745573 */, 17 },
+ /* 3307 */ { MAD_F(0x0603acb3) /* 0.375897122 */, 17 },
+ /* 3308 */ { MAD_F(0x06044ba0) /* 0.376048685 */, 17 },
+ /* 3309 */ { MAD_F(0x0604ea91) /* 0.376200265 */, 17 },
+ /* 3310 */ { MAD_F(0x06058987) /* 0.376351859 */, 17 },
+ /* 3311 */ { MAD_F(0x06062880) /* 0.376503468 */, 17 },
+
+ /* 3312 */ { MAD_F(0x0606c77d) /* 0.376655093 */, 17 },
+ /* 3313 */ { MAD_F(0x0607667f) /* 0.376806733 */, 17 },
+ /* 3314 */ { MAD_F(0x06080585) /* 0.376958389 */, 17 },
+ /* 3315 */ { MAD_F(0x0608a48f) /* 0.377110059 */, 17 },
+ /* 3316 */ { MAD_F(0x0609439c) /* 0.377261745 */, 17 },
+ /* 3317 */ { MAD_F(0x0609e2ae) /* 0.377413446 */, 17 },
+ /* 3318 */ { MAD_F(0x060a81c4) /* 0.377565163 */, 17 },
+ /* 3319 */ { MAD_F(0x060b20df) /* 0.377716894 */, 17 },
+ /* 3320 */ { MAD_F(0x060bbffd) /* 0.377868641 */, 17 },
+ /* 3321 */ { MAD_F(0x060c5f1f) /* 0.378020403 */, 17 },
+ /* 3322 */ { MAD_F(0x060cfe46) /* 0.378172181 */, 17 },
+ /* 3323 */ { MAD_F(0x060d9d70) /* 0.378323973 */, 17 },
+ /* 3324 */ { MAD_F(0x060e3c9f) /* 0.378475781 */, 17 },
+ /* 3325 */ { MAD_F(0x060edbd1) /* 0.378627604 */, 17 },
+ /* 3326 */ { MAD_F(0x060f7b08) /* 0.378779442 */, 17 },
+ /* 3327 */ { MAD_F(0x06101a43) /* 0.378931296 */, 17 },
+
+ /* 3328 */ { MAD_F(0x0610b982) /* 0.379083164 */, 17 },
+ /* 3329 */ { MAD_F(0x061158c5) /* 0.379235048 */, 17 },
+ /* 3330 */ { MAD_F(0x0611f80c) /* 0.379386947 */, 17 },
+ /* 3331 */ { MAD_F(0x06129757) /* 0.379538862 */, 17 },
+ /* 3332 */ { MAD_F(0x061336a6) /* 0.379690791 */, 17 },
+ /* 3333 */ { MAD_F(0x0613d5fa) /* 0.379842736 */, 17 },
+ /* 3334 */ { MAD_F(0x06147551) /* 0.379994696 */, 17 },
+ /* 3335 */ { MAD_F(0x061514ad) /* 0.380146671 */, 17 },
+ /* 3336 */ { MAD_F(0x0615b40c) /* 0.380298661 */, 17 },
+ /* 3337 */ { MAD_F(0x06165370) /* 0.380450666 */, 17 },
+ /* 3338 */ { MAD_F(0x0616f2d8) /* 0.380602687 */, 17 },
+ /* 3339 */ { MAD_F(0x06179243) /* 0.380754723 */, 17 },
+ /* 3340 */ { MAD_F(0x061831b3) /* 0.380906774 */, 17 },
+ /* 3341 */ { MAD_F(0x0618d127) /* 0.381058840 */, 17 },
+ /* 3342 */ { MAD_F(0x0619709f) /* 0.381210921 */, 17 },
+ /* 3343 */ { MAD_F(0x061a101b) /* 0.381363018 */, 17 },
+
+ /* 3344 */ { MAD_F(0x061aaf9c) /* 0.381515130 */, 17 },
+ /* 3345 */ { MAD_F(0x061b4f20) /* 0.381667257 */, 17 },
+ /* 3346 */ { MAD_F(0x061beea8) /* 0.381819399 */, 17 },
+ /* 3347 */ { MAD_F(0x061c8e34) /* 0.381971556 */, 17 },
+ /* 3348 */ { MAD_F(0x061d2dc5) /* 0.382123728 */, 17 },
+ /* 3349 */ { MAD_F(0x061dcd59) /* 0.382275916 */, 17 },
+ /* 3350 */ { MAD_F(0x061e6cf2) /* 0.382428118 */, 17 },
+ /* 3351 */ { MAD_F(0x061f0c8f) /* 0.382580336 */, 17 },
+ /* 3352 */ { MAD_F(0x061fac2f) /* 0.382732569 */, 17 },
+ /* 3353 */ { MAD_F(0x06204bd4) /* 0.382884817 */, 17 },
+ /* 3354 */ { MAD_F(0x0620eb7d) /* 0.383037080 */, 17 },
+ /* 3355 */ { MAD_F(0x06218b2a) /* 0.383189358 */, 17 },
+ /* 3356 */ { MAD_F(0x06222adb) /* 0.383341652 */, 17 },
+ /* 3357 */ { MAD_F(0x0622ca90) /* 0.383493960 */, 17 },
+ /* 3358 */ { MAD_F(0x06236a49) /* 0.383646284 */, 17 },
+ /* 3359 */ { MAD_F(0x06240a06) /* 0.383798623 */, 17 },
+
+ /* 3360 */ { MAD_F(0x0624a9c7) /* 0.383950977 */, 17 },
+ /* 3361 */ { MAD_F(0x0625498d) /* 0.384103346 */, 17 },
+ /* 3362 */ { MAD_F(0x0625e956) /* 0.384255730 */, 17 },
+ /* 3363 */ { MAD_F(0x06268923) /* 0.384408129 */, 17 },
+ /* 3364 */ { MAD_F(0x062728f5) /* 0.384560544 */, 17 },
+ /* 3365 */ { MAD_F(0x0627c8ca) /* 0.384712973 */, 17 },
+ /* 3366 */ { MAD_F(0x062868a4) /* 0.384865418 */, 17 },
+ /* 3367 */ { MAD_F(0x06290881) /* 0.385017878 */, 17 },
+ /* 3368 */ { MAD_F(0x0629a863) /* 0.385170352 */, 17 },
+ /* 3369 */ { MAD_F(0x062a4849) /* 0.385322842 */, 17 },
+ /* 3370 */ { MAD_F(0x062ae832) /* 0.385475347 */, 17 },
+ /* 3371 */ { MAD_F(0x062b8820) /* 0.385627867 */, 17 },
+ /* 3372 */ { MAD_F(0x062c2812) /* 0.385780402 */, 17 },
+ /* 3373 */ { MAD_F(0x062cc808) /* 0.385932953 */, 17 },
+ /* 3374 */ { MAD_F(0x062d6802) /* 0.386085518 */, 17 },
+ /* 3375 */ { MAD_F(0x062e0800) /* 0.386238098 */, 17 },
+
+ /* 3376 */ { MAD_F(0x062ea802) /* 0.386390694 */, 17 },
+ /* 3377 */ { MAD_F(0x062f4808) /* 0.386543304 */, 17 },
+ /* 3378 */ { MAD_F(0x062fe812) /* 0.386695930 */, 17 },
+ /* 3379 */ { MAD_F(0x06308820) /* 0.386848570 */, 17 },
+ /* 3380 */ { MAD_F(0x06312832) /* 0.387001226 */, 17 },
+ /* 3381 */ { MAD_F(0x0631c849) /* 0.387153897 */, 17 },
+ /* 3382 */ { MAD_F(0x06326863) /* 0.387306582 */, 17 },
+ /* 3383 */ { MAD_F(0x06330881) /* 0.387459283 */, 17 },
+ /* 3384 */ { MAD_F(0x0633a8a3) /* 0.387611999 */, 17 },
+ /* 3385 */ { MAD_F(0x063448ca) /* 0.387764730 */, 17 },
+ /* 3386 */ { MAD_F(0x0634e8f4) /* 0.387917476 */, 17 },
+ /* 3387 */ { MAD_F(0x06358923) /* 0.388070237 */, 17 },
+ /* 3388 */ { MAD_F(0x06362955) /* 0.388223013 */, 17 },
+ /* 3389 */ { MAD_F(0x0636c98c) /* 0.388375804 */, 17 },
+ /* 3390 */ { MAD_F(0x063769c6) /* 0.388528610 */, 17 },
+ /* 3391 */ { MAD_F(0x06380a05) /* 0.388681431 */, 17 },
+
+ /* 3392 */ { MAD_F(0x0638aa48) /* 0.388834268 */, 17 },
+ /* 3393 */ { MAD_F(0x06394a8e) /* 0.388987119 */, 17 },
+ /* 3394 */ { MAD_F(0x0639ead9) /* 0.389139985 */, 17 },
+ /* 3395 */ { MAD_F(0x063a8b28) /* 0.389292866 */, 17 },
+ /* 3396 */ { MAD_F(0x063b2b7b) /* 0.389445762 */, 17 },
+ /* 3397 */ { MAD_F(0x063bcbd1) /* 0.389598674 */, 17 },
+ /* 3398 */ { MAD_F(0x063c6c2c) /* 0.389751600 */, 17 },
+ /* 3399 */ { MAD_F(0x063d0c8b) /* 0.389904541 */, 17 },
+ /* 3400 */ { MAD_F(0x063dacee) /* 0.390057497 */, 17 },
+ /* 3401 */ { MAD_F(0x063e4d55) /* 0.390210468 */, 17 },
+ /* 3402 */ { MAD_F(0x063eedc0) /* 0.390363455 */, 17 },
+ /* 3403 */ { MAD_F(0x063f8e2f) /* 0.390516456 */, 17 },
+ /* 3404 */ { MAD_F(0x06402ea2) /* 0.390669472 */, 17 },
+ /* 3405 */ { MAD_F(0x0640cf19) /* 0.390822503 */, 17 },
+ /* 3406 */ { MAD_F(0x06416f94) /* 0.390975549 */, 17 },
+ /* 3407 */ { MAD_F(0x06421013) /* 0.391128611 */, 17 },
+
+ /* 3408 */ { MAD_F(0x0642b096) /* 0.391281687 */, 17 },
+ /* 3409 */ { MAD_F(0x0643511d) /* 0.391434778 */, 17 },
+ /* 3410 */ { MAD_F(0x0643f1a8) /* 0.391587884 */, 17 },
+ /* 3411 */ { MAD_F(0x06449237) /* 0.391741005 */, 17 },
+ /* 3412 */ { MAD_F(0x064532ca) /* 0.391894141 */, 17 },
+ /* 3413 */ { MAD_F(0x0645d361) /* 0.392047292 */, 17 },
+ /* 3414 */ { MAD_F(0x064673fc) /* 0.392200458 */, 17 },
+ /* 3415 */ { MAD_F(0x0647149c) /* 0.392353638 */, 17 },
+ /* 3416 */ { MAD_F(0x0647b53f) /* 0.392506834 */, 17 },
+ /* 3417 */ { MAD_F(0x064855e6) /* 0.392660045 */, 17 },
+ /* 3418 */ { MAD_F(0x0648f691) /* 0.392813271 */, 17 },
+ /* 3419 */ { MAD_F(0x06499740) /* 0.392966511 */, 17 },
+ /* 3420 */ { MAD_F(0x064a37f4) /* 0.393119767 */, 17 },
+ /* 3421 */ { MAD_F(0x064ad8ab) /* 0.393273038 */, 17 },
+ /* 3422 */ { MAD_F(0x064b7966) /* 0.393426323 */, 17 },
+ /* 3423 */ { MAD_F(0x064c1a25) /* 0.393579623 */, 17 },
+
+ /* 3424 */ { MAD_F(0x064cbae9) /* 0.393732939 */, 17 },
+ /* 3425 */ { MAD_F(0x064d5bb0) /* 0.393886269 */, 17 },
+ /* 3426 */ { MAD_F(0x064dfc7b) /* 0.394039614 */, 17 },
+ /* 3427 */ { MAD_F(0x064e9d4b) /* 0.394192974 */, 17 },
+ /* 3428 */ { MAD_F(0x064f3e1e) /* 0.394346349 */, 17 },
+ /* 3429 */ { MAD_F(0x064fdef5) /* 0.394499739 */, 17 },
+ /* 3430 */ { MAD_F(0x06507fd0) /* 0.394653144 */, 17 },
+ /* 3431 */ { MAD_F(0x065120b0) /* 0.394806564 */, 17 },
+ /* 3432 */ { MAD_F(0x0651c193) /* 0.394959999 */, 17 },
+ /* 3433 */ { MAD_F(0x0652627a) /* 0.395113448 */, 17 },
+ /* 3434 */ { MAD_F(0x06530366) /* 0.395266913 */, 17 },
+ /* 3435 */ { MAD_F(0x0653a455) /* 0.395420392 */, 17 },
+ /* 3436 */ { MAD_F(0x06544548) /* 0.395573886 */, 17 },
+ /* 3437 */ { MAD_F(0x0654e640) /* 0.395727395 */, 17 },
+ /* 3438 */ { MAD_F(0x0655873b) /* 0.395880919 */, 17 },
+ /* 3439 */ { MAD_F(0x0656283a) /* 0.396034458 */, 17 },
+
+ /* 3440 */ { MAD_F(0x0656c93d) /* 0.396188012 */, 17 },
+ /* 3441 */ { MAD_F(0x06576a45) /* 0.396341581 */, 17 },
+ /* 3442 */ { MAD_F(0x06580b50) /* 0.396495164 */, 17 },
+ /* 3443 */ { MAD_F(0x0658ac5f) /* 0.396648763 */, 17 },
+ /* 3444 */ { MAD_F(0x06594d73) /* 0.396802376 */, 17 },
+ /* 3445 */ { MAD_F(0x0659ee8a) /* 0.396956004 */, 17 },
+ /* 3446 */ { MAD_F(0x065a8fa5) /* 0.397109647 */, 17 },
+ /* 3447 */ { MAD_F(0x065b30c4) /* 0.397263305 */, 17 },
+ /* 3448 */ { MAD_F(0x065bd1e7) /* 0.397416978 */, 17 },
+ /* 3449 */ { MAD_F(0x065c730f) /* 0.397570666 */, 17 },
+ /* 3450 */ { MAD_F(0x065d143a) /* 0.397724368 */, 17 },
+ /* 3451 */ { MAD_F(0x065db569) /* 0.397878085 */, 17 },
+ /* 3452 */ { MAD_F(0x065e569c) /* 0.398031818 */, 17 },
+ /* 3453 */ { MAD_F(0x065ef7d3) /* 0.398185565 */, 17 },
+ /* 3454 */ { MAD_F(0x065f990e) /* 0.398339326 */, 17 },
+ /* 3455 */ { MAD_F(0x06603a4e) /* 0.398493103 */, 17 },
+
+ /* 3456 */ { MAD_F(0x0660db91) /* 0.398646895 */, 17 },
+ /* 3457 */ { MAD_F(0x06617cd8) /* 0.398800701 */, 17 },
+ /* 3458 */ { MAD_F(0x06621e23) /* 0.398954522 */, 17 },
+ /* 3459 */ { MAD_F(0x0662bf72) /* 0.399108358 */, 17 },
+ /* 3460 */ { MAD_F(0x066360c5) /* 0.399262209 */, 17 },
+ /* 3461 */ { MAD_F(0x0664021c) /* 0.399416075 */, 17 },
+ /* 3462 */ { MAD_F(0x0664a377) /* 0.399569955 */, 17 },
+ /* 3463 */ { MAD_F(0x066544d6) /* 0.399723851 */, 17 },
+ /* 3464 */ { MAD_F(0x0665e639) /* 0.399877761 */, 17 },
+ /* 3465 */ { MAD_F(0x066687a0) /* 0.400031686 */, 17 },
+ /* 3466 */ { MAD_F(0x0667290b) /* 0.400185625 */, 17 },
+ /* 3467 */ { MAD_F(0x0667ca79) /* 0.400339580 */, 17 },
+ /* 3468 */ { MAD_F(0x06686bec) /* 0.400493549 */, 17 },
+ /* 3469 */ { MAD_F(0x06690d63) /* 0.400647534 */, 17 },
+ /* 3470 */ { MAD_F(0x0669aede) /* 0.400801533 */, 17 },
+ /* 3471 */ { MAD_F(0x066a505d) /* 0.400955546 */, 17 },
+
+ /* 3472 */ { MAD_F(0x066af1df) /* 0.401109575 */, 17 },
+ /* 3473 */ { MAD_F(0x066b9366) /* 0.401263618 */, 17 },
+ /* 3474 */ { MAD_F(0x066c34f1) /* 0.401417676 */, 17 },
+ /* 3475 */ { MAD_F(0x066cd67f) /* 0.401571749 */, 17 },
+ /* 3476 */ { MAD_F(0x066d7812) /* 0.401725837 */, 17 },
+ /* 3477 */ { MAD_F(0x066e19a9) /* 0.401879939 */, 17 },
+ /* 3478 */ { MAD_F(0x066ebb43) /* 0.402034056 */, 17 },
+ /* 3479 */ { MAD_F(0x066f5ce2) /* 0.402188188 */, 17 },
+ /* 3480 */ { MAD_F(0x066ffe84) /* 0.402342335 */, 17 },
+ /* 3481 */ { MAD_F(0x0670a02a) /* 0.402496497 */, 17 },
+ /* 3482 */ { MAD_F(0x067141d5) /* 0.402650673 */, 17 },
+ /* 3483 */ { MAD_F(0x0671e383) /* 0.402804864 */, 17 },
+ /* 3484 */ { MAD_F(0x06728535) /* 0.402959070 */, 17 },
+ /* 3485 */ { MAD_F(0x067326ec) /* 0.403113291 */, 17 },
+ /* 3486 */ { MAD_F(0x0673c8a6) /* 0.403267526 */, 17 },
+ /* 3487 */ { MAD_F(0x06746a64) /* 0.403421776 */, 17 },
+
+ /* 3488 */ { MAD_F(0x06750c26) /* 0.403576041 */, 17 },
+ /* 3489 */ { MAD_F(0x0675adec) /* 0.403730320 */, 17 },
+ /* 3490 */ { MAD_F(0x06764fb6) /* 0.403884615 */, 17 },
+ /* 3491 */ { MAD_F(0x0676f184) /* 0.404038924 */, 17 },
+ /* 3492 */ { MAD_F(0x06779356) /* 0.404193247 */, 17 },
+ /* 3493 */ { MAD_F(0x0678352c) /* 0.404347586 */, 17 },
+ /* 3494 */ { MAD_F(0x0678d706) /* 0.404501939 */, 17 },
+ /* 3495 */ { MAD_F(0x067978e4) /* 0.404656307 */, 17 },
+ /* 3496 */ { MAD_F(0x067a1ac6) /* 0.404810690 */, 17 },
+ /* 3497 */ { MAD_F(0x067abcac) /* 0.404965087 */, 17 },
+ /* 3498 */ { MAD_F(0x067b5e95) /* 0.405119499 */, 17 },
+ /* 3499 */ { MAD_F(0x067c0083) /* 0.405273926 */, 17 },
+ /* 3500 */ { MAD_F(0x067ca275) /* 0.405428368 */, 17 },
+ /* 3501 */ { MAD_F(0x067d446a) /* 0.405582824 */, 17 },
+ /* 3502 */ { MAD_F(0x067de664) /* 0.405737295 */, 17 },
+ /* 3503 */ { MAD_F(0x067e8861) /* 0.405891781 */, 17 },
+
+ /* 3504 */ { MAD_F(0x067f2a62) /* 0.406046281 */, 17 },
+ /* 3505 */ { MAD_F(0x067fcc68) /* 0.406200796 */, 17 },
+ /* 3506 */ { MAD_F(0x06806e71) /* 0.406355326 */, 17 },
+ /* 3507 */ { MAD_F(0x0681107e) /* 0.406509870 */, 17 },
+ /* 3508 */ { MAD_F(0x0681b28f) /* 0.406664429 */, 17 },
+ /* 3509 */ { MAD_F(0x068254a4) /* 0.406819003 */, 17 },
+ /* 3510 */ { MAD_F(0x0682f6bd) /* 0.406973592 */, 17 },
+ /* 3511 */ { MAD_F(0x068398da) /* 0.407128195 */, 17 },
+ /* 3512 */ { MAD_F(0x06843afb) /* 0.407282813 */, 17 },
+ /* 3513 */ { MAD_F(0x0684dd20) /* 0.407437445 */, 17 },
+ /* 3514 */ { MAD_F(0x06857f49) /* 0.407592093 */, 17 },
+ /* 3515 */ { MAD_F(0x06862176) /* 0.407746754 */, 17 },
+ /* 3516 */ { MAD_F(0x0686c3a6) /* 0.407901431 */, 17 },
+ /* 3517 */ { MAD_F(0x068765db) /* 0.408056122 */, 17 },
+ /* 3518 */ { MAD_F(0x06880814) /* 0.408210828 */, 17 },
+ /* 3519 */ { MAD_F(0x0688aa50) /* 0.408365549 */, 17 },
+
+ /* 3520 */ { MAD_F(0x06894c90) /* 0.408520284 */, 17 },
+ /* 3521 */ { MAD_F(0x0689eed5) /* 0.408675034 */, 17 },
+ /* 3522 */ { MAD_F(0x068a911d) /* 0.408829798 */, 17 },
+ /* 3523 */ { MAD_F(0x068b3369) /* 0.408984577 */, 17 },
+ /* 3524 */ { MAD_F(0x068bd5b9) /* 0.409139371 */, 17 },
+ /* 3525 */ { MAD_F(0x068c780e) /* 0.409294180 */, 17 },
+ /* 3526 */ { MAD_F(0x068d1a66) /* 0.409449003 */, 17 },
+ /* 3527 */ { MAD_F(0x068dbcc1) /* 0.409603840 */, 17 },
+ /* 3528 */ { MAD_F(0x068e5f21) /* 0.409758693 */, 17 },
+ /* 3529 */ { MAD_F(0x068f0185) /* 0.409913560 */, 17 },
+ /* 3530 */ { MAD_F(0x068fa3ed) /* 0.410068441 */, 17 },
+ /* 3531 */ { MAD_F(0x06904658) /* 0.410223338 */, 17 },
+ /* 3532 */ { MAD_F(0x0690e8c8) /* 0.410378249 */, 17 },
+ /* 3533 */ { MAD_F(0x06918b3c) /* 0.410533174 */, 17 },
+ /* 3534 */ { MAD_F(0x06922db3) /* 0.410688114 */, 17 },
+ /* 3535 */ { MAD_F(0x0692d02e) /* 0.410843069 */, 17 },
+
+ /* 3536 */ { MAD_F(0x069372ae) /* 0.410998038 */, 17 },
+ /* 3537 */ { MAD_F(0x06941531) /* 0.411153022 */, 17 },
+ /* 3538 */ { MAD_F(0x0694b7b8) /* 0.411308021 */, 17 },
+ /* 3539 */ { MAD_F(0x06955a43) /* 0.411463034 */, 17 },
+ /* 3540 */ { MAD_F(0x0695fcd2) /* 0.411618062 */, 17 },
+ /* 3541 */ { MAD_F(0x06969f65) /* 0.411773104 */, 17 },
+ /* 3542 */ { MAD_F(0x069741fb) /* 0.411928161 */, 17 },
+ /* 3543 */ { MAD_F(0x0697e496) /* 0.412083232 */, 17 },
+ /* 3544 */ { MAD_F(0x06988735) /* 0.412238319 */, 17 },
+ /* 3545 */ { MAD_F(0x069929d7) /* 0.412393419 */, 17 },
+ /* 3546 */ { MAD_F(0x0699cc7e) /* 0.412548535 */, 17 },
+ /* 3547 */ { MAD_F(0x069a6f28) /* 0.412703664 */, 17 },
+ /* 3548 */ { MAD_F(0x069b11d6) /* 0.412858809 */, 17 },
+ /* 3549 */ { MAD_F(0x069bb489) /* 0.413013968 */, 17 },
+ /* 3550 */ { MAD_F(0x069c573f) /* 0.413169142 */, 17 },
+ /* 3551 */ { MAD_F(0x069cf9f9) /* 0.413324330 */, 17 },
+
+ /* 3552 */ { MAD_F(0x069d9cb7) /* 0.413479532 */, 17 },
+ /* 3553 */ { MAD_F(0x069e3f78) /* 0.413634750 */, 17 },
+ /* 3554 */ { MAD_F(0x069ee23e) /* 0.413789982 */, 17 },
+ /* 3555 */ { MAD_F(0x069f8508) /* 0.413945228 */, 17 },
+ /* 3556 */ { MAD_F(0x06a027d5) /* 0.414100489 */, 17 },
+ /* 3557 */ { MAD_F(0x06a0caa7) /* 0.414255765 */, 17 },
+ /* 3558 */ { MAD_F(0x06a16d7c) /* 0.414411055 */, 17 },
+ /* 3559 */ { MAD_F(0x06a21055) /* 0.414566359 */, 17 },
+ /* 3560 */ { MAD_F(0x06a2b333) /* 0.414721679 */, 17 },
+ /* 3561 */ { MAD_F(0x06a35614) /* 0.414877012 */, 17 },
+ /* 3562 */ { MAD_F(0x06a3f8f9) /* 0.415032361 */, 17 },
+ /* 3563 */ { MAD_F(0x06a49be2) /* 0.415187723 */, 17 },
+ /* 3564 */ { MAD_F(0x06a53ece) /* 0.415343101 */, 17 },
+ /* 3565 */ { MAD_F(0x06a5e1bf) /* 0.415498493 */, 17 },
+ /* 3566 */ { MAD_F(0x06a684b4) /* 0.415653899 */, 17 },
+ /* 3567 */ { MAD_F(0x06a727ac) /* 0.415809320 */, 17 },
+
+ /* 3568 */ { MAD_F(0x06a7caa9) /* 0.415964756 */, 17 },
+ /* 3569 */ { MAD_F(0x06a86da9) /* 0.416120206 */, 17 },
+ /* 3570 */ { MAD_F(0x06a910ad) /* 0.416275670 */, 17 },
+ /* 3571 */ { MAD_F(0x06a9b3b5) /* 0.416431149 */, 17 },
+ /* 3572 */ { MAD_F(0x06aa56c1) /* 0.416586643 */, 17 },
+ /* 3573 */ { MAD_F(0x06aaf9d1) /* 0.416742151 */, 17 },
+ /* 3574 */ { MAD_F(0x06ab9ce5) /* 0.416897673 */, 17 },
+ /* 3575 */ { MAD_F(0x06ac3ffc) /* 0.417053210 */, 17 },
+ /* 3576 */ { MAD_F(0x06ace318) /* 0.417208762 */, 17 },
+ /* 3577 */ { MAD_F(0x06ad8637) /* 0.417364328 */, 17 },
+ /* 3578 */ { MAD_F(0x06ae295b) /* 0.417519909 */, 17 },
+ /* 3579 */ { MAD_F(0x06aecc82) /* 0.417675504 */, 17 },
+ /* 3580 */ { MAD_F(0x06af6fad) /* 0.417831113 */, 17 },
+ /* 3581 */ { MAD_F(0x06b012dc) /* 0.417986737 */, 17 },
+ /* 3582 */ { MAD_F(0x06b0b60f) /* 0.418142376 */, 17 },
+ /* 3583 */ { MAD_F(0x06b15946) /* 0.418298029 */, 17 },
+
+ /* 3584 */ { MAD_F(0x06b1fc81) /* 0.418453696 */, 17 },
+ /* 3585 */ { MAD_F(0x06b29fbf) /* 0.418609378 */, 17 },
+ /* 3586 */ { MAD_F(0x06b34302) /* 0.418765075 */, 17 },
+ /* 3587 */ { MAD_F(0x06b3e648) /* 0.418920786 */, 17 },
+ /* 3588 */ { MAD_F(0x06b48992) /* 0.419076511 */, 17 },
+ /* 3589 */ { MAD_F(0x06b52ce0) /* 0.419232251 */, 17 },
+ /* 3590 */ { MAD_F(0x06b5d032) /* 0.419388005 */, 17 },
+ /* 3591 */ { MAD_F(0x06b67388) /* 0.419543774 */, 17 },
+ /* 3592 */ { MAD_F(0x06b716e2) /* 0.419699557 */, 17 },
+ /* 3593 */ { MAD_F(0x06b7ba3f) /* 0.419855355 */, 17 },
+ /* 3594 */ { MAD_F(0x06b85da1) /* 0.420011167 */, 17 },
+ /* 3595 */ { MAD_F(0x06b90106) /* 0.420166994 */, 17 },
+ /* 3596 */ { MAD_F(0x06b9a470) /* 0.420322835 */, 17 },
+ /* 3597 */ { MAD_F(0x06ba47dd) /* 0.420478690 */, 17 },
+ /* 3598 */ { MAD_F(0x06baeb4e) /* 0.420634560 */, 17 },
+ /* 3599 */ { MAD_F(0x06bb8ec3) /* 0.420790445 */, 17 },
+
+ /* 3600 */ { MAD_F(0x06bc323b) /* 0.420946343 */, 17 },
+ /* 3601 */ { MAD_F(0x06bcd5b8) /* 0.421102257 */, 17 },
+ /* 3602 */ { MAD_F(0x06bd7939) /* 0.421258184 */, 17 },
+ /* 3603 */ { MAD_F(0x06be1cbd) /* 0.421414127 */, 17 },
+ /* 3604 */ { MAD_F(0x06bec045) /* 0.421570083 */, 17 },
+ /* 3605 */ { MAD_F(0x06bf63d1) /* 0.421726054 */, 17 },
+ /* 3606 */ { MAD_F(0x06c00761) /* 0.421882040 */, 17 },
+ /* 3607 */ { MAD_F(0x06c0aaf5) /* 0.422038039 */, 17 },
+ /* 3608 */ { MAD_F(0x06c14e8d) /* 0.422194054 */, 17 },
+ /* 3609 */ { MAD_F(0x06c1f229) /* 0.422350082 */, 17 },
+ /* 3610 */ { MAD_F(0x06c295c8) /* 0.422506125 */, 17 },
+ /* 3611 */ { MAD_F(0x06c3396c) /* 0.422662183 */, 17 },
+ /* 3612 */ { MAD_F(0x06c3dd13) /* 0.422818255 */, 17 },
+ /* 3613 */ { MAD_F(0x06c480be) /* 0.422974341 */, 17 },
+ /* 3614 */ { MAD_F(0x06c5246d) /* 0.423130442 */, 17 },
+ /* 3615 */ { MAD_F(0x06c5c820) /* 0.423286557 */, 17 },
+
+ /* 3616 */ { MAD_F(0x06c66bd6) /* 0.423442686 */, 17 },
+ /* 3617 */ { MAD_F(0x06c70f91) /* 0.423598830 */, 17 },
+ /* 3618 */ { MAD_F(0x06c7b34f) /* 0.423754988 */, 17 },
+ /* 3619 */ { MAD_F(0x06c85712) /* 0.423911161 */, 17 },
+ /* 3620 */ { MAD_F(0x06c8fad8) /* 0.424067348 */, 17 },
+ /* 3621 */ { MAD_F(0x06c99ea2) /* 0.424223550 */, 17 },
+ /* 3622 */ { MAD_F(0x06ca4270) /* 0.424379765 */, 17 },
+ /* 3623 */ { MAD_F(0x06cae641) /* 0.424535996 */, 17 },
+ /* 3624 */ { MAD_F(0x06cb8a17) /* 0.424692240 */, 17 },
+ /* 3625 */ { MAD_F(0x06cc2df0) /* 0.424848499 */, 17 },
+ /* 3626 */ { MAD_F(0x06ccd1ce) /* 0.425004772 */, 17 },
+ /* 3627 */ { MAD_F(0x06cd75af) /* 0.425161060 */, 17 },
+ /* 3628 */ { MAD_F(0x06ce1994) /* 0.425317362 */, 17 },
+ /* 3629 */ { MAD_F(0x06cebd7d) /* 0.425473678 */, 17 },
+ /* 3630 */ { MAD_F(0x06cf6169) /* 0.425630009 */, 17 },
+ /* 3631 */ { MAD_F(0x06d0055a) /* 0.425786354 */, 17 },
+
+ /* 3632 */ { MAD_F(0x06d0a94e) /* 0.425942714 */, 17 },
+ /* 3633 */ { MAD_F(0x06d14d47) /* 0.426099088 */, 17 },
+ /* 3634 */ { MAD_F(0x06d1f143) /* 0.426255476 */, 17 },
+ /* 3635 */ { MAD_F(0x06d29543) /* 0.426411878 */, 17 },
+ /* 3636 */ { MAD_F(0x06d33947) /* 0.426568295 */, 17 },
+ /* 3637 */ { MAD_F(0x06d3dd4e) /* 0.426724726 */, 17 },
+ /* 3638 */ { MAD_F(0x06d4815a) /* 0.426881172 */, 17 },
+ /* 3639 */ { MAD_F(0x06d52569) /* 0.427037632 */, 17 },
+ /* 3640 */ { MAD_F(0x06d5c97c) /* 0.427194106 */, 17 },
+ /* 3641 */ { MAD_F(0x06d66d93) /* 0.427350594 */, 17 },
+ /* 3642 */ { MAD_F(0x06d711ae) /* 0.427507097 */, 17 },
+ /* 3643 */ { MAD_F(0x06d7b5cd) /* 0.427663614 */, 17 },
+ /* 3644 */ { MAD_F(0x06d859f0) /* 0.427820146 */, 17 },
+ /* 3645 */ { MAD_F(0x06d8fe16) /* 0.427976692 */, 17 },
+ /* 3646 */ { MAD_F(0x06d9a240) /* 0.428133252 */, 17 },
+ /* 3647 */ { MAD_F(0x06da466f) /* 0.428289826 */, 17 },
+
+ /* 3648 */ { MAD_F(0x06daeaa1) /* 0.428446415 */, 17 },
+ /* 3649 */ { MAD_F(0x06db8ed6) /* 0.428603018 */, 17 },
+ /* 3650 */ { MAD_F(0x06dc3310) /* 0.428759635 */, 17 },
+ /* 3651 */ { MAD_F(0x06dcd74d) /* 0.428916267 */, 17 },
+ /* 3652 */ { MAD_F(0x06dd7b8f) /* 0.429072913 */, 17 },
+ /* 3653 */ { MAD_F(0x06de1fd4) /* 0.429229573 */, 17 },
+ /* 3654 */ { MAD_F(0x06dec41d) /* 0.429386248 */, 17 },
+ /* 3655 */ { MAD_F(0x06df686a) /* 0.429542937 */, 17 },
+ /* 3656 */ { MAD_F(0x06e00cbb) /* 0.429699640 */, 17 },
+ /* 3657 */ { MAD_F(0x06e0b10f) /* 0.429856357 */, 17 },
+ /* 3658 */ { MAD_F(0x06e15567) /* 0.430013089 */, 17 },
+ /* 3659 */ { MAD_F(0x06e1f9c4) /* 0.430169835 */, 17 },
+ /* 3660 */ { MAD_F(0x06e29e24) /* 0.430326595 */, 17 },
+ /* 3661 */ { MAD_F(0x06e34287) /* 0.430483370 */, 17 },
+ /* 3662 */ { MAD_F(0x06e3e6ef) /* 0.430640159 */, 17 },
+ /* 3663 */ { MAD_F(0x06e48b5b) /* 0.430796962 */, 17 },
+
+ /* 3664 */ { MAD_F(0x06e52fca) /* 0.430953779 */, 17 },
+ /* 3665 */ { MAD_F(0x06e5d43d) /* 0.431110611 */, 17 },
+ /* 3666 */ { MAD_F(0x06e678b4) /* 0.431267457 */, 17 },
+ /* 3667 */ { MAD_F(0x06e71d2f) /* 0.431424317 */, 17 },
+ /* 3668 */ { MAD_F(0x06e7c1ae) /* 0.431581192 */, 17 },
+ /* 3669 */ { MAD_F(0x06e86630) /* 0.431738080 */, 17 },
+ /* 3670 */ { MAD_F(0x06e90ab7) /* 0.431894983 */, 17 },
+ /* 3671 */ { MAD_F(0x06e9af41) /* 0.432051900 */, 17 },
+ /* 3672 */ { MAD_F(0x06ea53cf) /* 0.432208832 */, 17 },
+ /* 3673 */ { MAD_F(0x06eaf860) /* 0.432365778 */, 17 },
+ /* 3674 */ { MAD_F(0x06eb9cf6) /* 0.432522737 */, 17 },
+ /* 3675 */ { MAD_F(0x06ec418f) /* 0.432679712 */, 17 },
+ /* 3676 */ { MAD_F(0x06ece62d) /* 0.432836700 */, 17 },
+ /* 3677 */ { MAD_F(0x06ed8ace) /* 0.432993703 */, 17 },
+ /* 3678 */ { MAD_F(0x06ee2f73) /* 0.433150720 */, 17 },
+ /* 3679 */ { MAD_F(0x06eed41b) /* 0.433307751 */, 17 },
+
+ /* 3680 */ { MAD_F(0x06ef78c8) /* 0.433464796 */, 17 },
+ /* 3681 */ { MAD_F(0x06f01d78) /* 0.433621856 */, 17 },
+ /* 3682 */ { MAD_F(0x06f0c22c) /* 0.433778929 */, 17 },
+ /* 3683 */ { MAD_F(0x06f166e4) /* 0.433936017 */, 17 },
+ /* 3684 */ { MAD_F(0x06f20ba0) /* 0.434093120 */, 17 },
+ /* 3685 */ { MAD_F(0x06f2b060) /* 0.434250236 */, 17 },
+ /* 3686 */ { MAD_F(0x06f35523) /* 0.434407367 */, 17 },
+ /* 3687 */ { MAD_F(0x06f3f9eb) /* 0.434564512 */, 17 },
+ /* 3688 */ { MAD_F(0x06f49eb6) /* 0.434721671 */, 17 },
+ /* 3689 */ { MAD_F(0x06f54385) /* 0.434878844 */, 17 },
+ /* 3690 */ { MAD_F(0x06f5e857) /* 0.435036032 */, 17 },
+ /* 3691 */ { MAD_F(0x06f68d2e) /* 0.435193233 */, 17 },
+ /* 3692 */ { MAD_F(0x06f73208) /* 0.435350449 */, 17 },
+ /* 3693 */ { MAD_F(0x06f7d6e6) /* 0.435507679 */, 17 },
+ /* 3694 */ { MAD_F(0x06f87bc8) /* 0.435664924 */, 17 },
+ /* 3695 */ { MAD_F(0x06f920ae) /* 0.435822182 */, 17 },
+
+ /* 3696 */ { MAD_F(0x06f9c597) /* 0.435979455 */, 17 },
+ /* 3697 */ { MAD_F(0x06fa6a85) /* 0.436136741 */, 17 },
+ /* 3698 */ { MAD_F(0x06fb0f76) /* 0.436294042 */, 17 },
+ /* 3699 */ { MAD_F(0x06fbb46b) /* 0.436451358 */, 17 },
+ /* 3700 */ { MAD_F(0x06fc5964) /* 0.436608687 */, 17 },
+ /* 3701 */ { MAD_F(0x06fcfe60) /* 0.436766031 */, 17 },
+ /* 3702 */ { MAD_F(0x06fda361) /* 0.436923388 */, 17 },
+ /* 3703 */ { MAD_F(0x06fe4865) /* 0.437080760 */, 17 },
+ /* 3704 */ { MAD_F(0x06feed6d) /* 0.437238146 */, 17 },
+ /* 3705 */ { MAD_F(0x06ff9279) /* 0.437395547 */, 17 },
+ /* 3706 */ { MAD_F(0x07003788) /* 0.437552961 */, 17 },
+ /* 3707 */ { MAD_F(0x0700dc9c) /* 0.437710389 */, 17 },
+ /* 3708 */ { MAD_F(0x070181b3) /* 0.437867832 */, 17 },
+ /* 3709 */ { MAD_F(0x070226ce) /* 0.438025289 */, 17 },
+ /* 3710 */ { MAD_F(0x0702cbed) /* 0.438182760 */, 17 },
+ /* 3711 */ { MAD_F(0x0703710f) /* 0.438340245 */, 17 },
+
+ /* 3712 */ { MAD_F(0x07041636) /* 0.438497744 */, 17 },
+ /* 3713 */ { MAD_F(0x0704bb60) /* 0.438655258 */, 17 },
+ /* 3714 */ { MAD_F(0x0705608e) /* 0.438812785 */, 17 },
+ /* 3715 */ { MAD_F(0x070605c0) /* 0.438970327 */, 17 },
+ /* 3716 */ { MAD_F(0x0706aaf5) /* 0.439127883 */, 17 },
+ /* 3717 */ { MAD_F(0x0707502f) /* 0.439285453 */, 17 },
+ /* 3718 */ { MAD_F(0x0707f56c) /* 0.439443037 */, 17 },
+ /* 3719 */ { MAD_F(0x07089aad) /* 0.439600635 */, 17 },
+ /* 3720 */ { MAD_F(0x07093ff2) /* 0.439758248 */, 17 },
+ /* 3721 */ { MAD_F(0x0709e53a) /* 0.439915874 */, 17 },
+ /* 3722 */ { MAD_F(0x070a8a86) /* 0.440073515 */, 17 },
+ /* 3723 */ { MAD_F(0x070b2fd7) /* 0.440231170 */, 17 },
+ /* 3724 */ { MAD_F(0x070bd52a) /* 0.440388839 */, 17 },
+ /* 3725 */ { MAD_F(0x070c7a82) /* 0.440546522 */, 17 },
+ /* 3726 */ { MAD_F(0x070d1fde) /* 0.440704219 */, 17 },
+ /* 3727 */ { MAD_F(0x070dc53d) /* 0.440861930 */, 17 },
+
+ /* 3728 */ { MAD_F(0x070e6aa0) /* 0.441019655 */, 17 },
+ /* 3729 */ { MAD_F(0x070f1007) /* 0.441177395 */, 17 },
+ /* 3730 */ { MAD_F(0x070fb571) /* 0.441335148 */, 17 },
+ /* 3731 */ { MAD_F(0x07105ae0) /* 0.441492916 */, 17 },
+ /* 3732 */ { MAD_F(0x07110052) /* 0.441650697 */, 17 },
+ /* 3733 */ { MAD_F(0x0711a5c8) /* 0.441808493 */, 17 },
+ /* 3734 */ { MAD_F(0x07124b42) /* 0.441966303 */, 17 },
+ /* 3735 */ { MAD_F(0x0712f0bf) /* 0.442124127 */, 17 },
+ /* 3736 */ { MAD_F(0x07139641) /* 0.442281965 */, 17 },
+ /* 3737 */ { MAD_F(0x07143bc6) /* 0.442439817 */, 17 },
+ /* 3738 */ { MAD_F(0x0714e14f) /* 0.442597683 */, 17 },
+ /* 3739 */ { MAD_F(0x071586db) /* 0.442755564 */, 17 },
+ /* 3740 */ { MAD_F(0x07162c6c) /* 0.442913458 */, 17 },
+ /* 3741 */ { MAD_F(0x0716d200) /* 0.443071366 */, 17 },
+ /* 3742 */ { MAD_F(0x07177798) /* 0.443229289 */, 17 },
+ /* 3743 */ { MAD_F(0x07181d34) /* 0.443387226 */, 17 },
+
+ /* 3744 */ { MAD_F(0x0718c2d3) /* 0.443545176 */, 17 },
+ /* 3745 */ { MAD_F(0x07196877) /* 0.443703141 */, 17 },
+ /* 3746 */ { MAD_F(0x071a0e1e) /* 0.443861120 */, 17 },
+ /* 3747 */ { MAD_F(0x071ab3c9) /* 0.444019113 */, 17 },
+ /* 3748 */ { MAD_F(0x071b5977) /* 0.444177119 */, 17 },
+ /* 3749 */ { MAD_F(0x071bff2a) /* 0.444335140 */, 17 },
+ /* 3750 */ { MAD_F(0x071ca4e0) /* 0.444493175 */, 17 },
+ /* 3751 */ { MAD_F(0x071d4a9a) /* 0.444651224 */, 17 },
+ /* 3752 */ { MAD_F(0x071df058) /* 0.444809288 */, 17 },
+ /* 3753 */ { MAD_F(0x071e9619) /* 0.444967365 */, 17 },
+ /* 3754 */ { MAD_F(0x071f3bde) /* 0.445125456 */, 17 },
+ /* 3755 */ { MAD_F(0x071fe1a8) /* 0.445283561 */, 17 },
+ /* 3756 */ { MAD_F(0x07208774) /* 0.445441680 */, 17 },
+ /* 3757 */ { MAD_F(0x07212d45) /* 0.445599814 */, 17 },
+ /* 3758 */ { MAD_F(0x0721d319) /* 0.445757961 */, 17 },
+ /* 3759 */ { MAD_F(0x072278f1) /* 0.445916122 */, 17 },
+
+ /* 3760 */ { MAD_F(0x07231ecd) /* 0.446074298 */, 17 },
+ /* 3761 */ { MAD_F(0x0723c4ad) /* 0.446232487 */, 17 },
+ /* 3762 */ { MAD_F(0x07246a90) /* 0.446390690 */, 17 },
+ /* 3763 */ { MAD_F(0x07251077) /* 0.446548908 */, 17 },
+ /* 3764 */ { MAD_F(0x0725b662) /* 0.446707139 */, 17 },
+ /* 3765 */ { MAD_F(0x07265c51) /* 0.446865385 */, 17 },
+ /* 3766 */ { MAD_F(0x07270244) /* 0.447023644 */, 17 },
+ /* 3767 */ { MAD_F(0x0727a83a) /* 0.447181918 */, 17 },
+ /* 3768 */ { MAD_F(0x07284e34) /* 0.447340205 */, 17 },
+ /* 3769 */ { MAD_F(0x0728f431) /* 0.447498507 */, 17 },
+ /* 3770 */ { MAD_F(0x07299a33) /* 0.447656822 */, 17 },
+ /* 3771 */ { MAD_F(0x072a4038) /* 0.447815152 */, 17 },
+ /* 3772 */ { MAD_F(0x072ae641) /* 0.447973495 */, 17 },
+ /* 3773 */ { MAD_F(0x072b8c4e) /* 0.448131853 */, 17 },
+ /* 3774 */ { MAD_F(0x072c325e) /* 0.448290224 */, 17 },
+ /* 3775 */ { MAD_F(0x072cd873) /* 0.448448609 */, 17 },
+
+ /* 3776 */ { MAD_F(0x072d7e8b) /* 0.448607009 */, 17 },
+ /* 3777 */ { MAD_F(0x072e24a7) /* 0.448765422 */, 17 },
+ /* 3778 */ { MAD_F(0x072ecac6) /* 0.448923850 */, 17 },
+ /* 3779 */ { MAD_F(0x072f70e9) /* 0.449082291 */, 17 },
+ /* 3780 */ { MAD_F(0x07301710) /* 0.449240746 */, 17 },
+ /* 3781 */ { MAD_F(0x0730bd3b) /* 0.449399216 */, 17 },
+ /* 3782 */ { MAD_F(0x0731636a) /* 0.449557699 */, 17 },
+ /* 3783 */ { MAD_F(0x0732099c) /* 0.449716196 */, 17 },
+ /* 3784 */ { MAD_F(0x0732afd2) /* 0.449874708 */, 17 },
+ /* 3785 */ { MAD_F(0x0733560c) /* 0.450033233 */, 17 },
+ /* 3786 */ { MAD_F(0x0733fc49) /* 0.450191772 */, 17 },
+ /* 3787 */ { MAD_F(0x0734a28b) /* 0.450350325 */, 17 },
+ /* 3788 */ { MAD_F(0x073548d0) /* 0.450508892 */, 17 },
+ /* 3789 */ { MAD_F(0x0735ef18) /* 0.450667473 */, 17 },
+ /* 3790 */ { MAD_F(0x07369565) /* 0.450826068 */, 17 },
+ /* 3791 */ { MAD_F(0x07373bb5) /* 0.450984677 */, 17 },
+
+ /* 3792 */ { MAD_F(0x0737e209) /* 0.451143300 */, 17 },
+ /* 3793 */ { MAD_F(0x07388861) /* 0.451301937 */, 17 },
+ /* 3794 */ { MAD_F(0x07392ebc) /* 0.451460588 */, 17 },
+ /* 3795 */ { MAD_F(0x0739d51c) /* 0.451619252 */, 17 },
+ /* 3796 */ { MAD_F(0x073a7b7f) /* 0.451777931 */, 17 },
+ /* 3797 */ { MAD_F(0x073b21e5) /* 0.451936623 */, 17 },
+ /* 3798 */ { MAD_F(0x073bc850) /* 0.452095330 */, 17 },
+ /* 3799 */ { MAD_F(0x073c6ebe) /* 0.452254050 */, 17 },
+ /* 3800 */ { MAD_F(0x073d1530) /* 0.452412785 */, 17 },
+ /* 3801 */ { MAD_F(0x073dbba6) /* 0.452571533 */, 17 },
+ /* 3802 */ { MAD_F(0x073e621f) /* 0.452730295 */, 17 },
+ /* 3803 */ { MAD_F(0x073f089c) /* 0.452889071 */, 17 },
+ /* 3804 */ { MAD_F(0x073faf1d) /* 0.453047861 */, 17 },
+ /* 3805 */ { MAD_F(0x074055a2) /* 0.453206665 */, 17 },
+ /* 3806 */ { MAD_F(0x0740fc2a) /* 0.453365483 */, 17 },
+ /* 3807 */ { MAD_F(0x0741a2b6) /* 0.453524315 */, 17 },
+
+ /* 3808 */ { MAD_F(0x07424946) /* 0.453683161 */, 17 },
+ /* 3809 */ { MAD_F(0x0742efd9) /* 0.453842020 */, 17 },
+ /* 3810 */ { MAD_F(0x07439671) /* 0.454000894 */, 17 },
+ /* 3811 */ { MAD_F(0x07443d0c) /* 0.454159781 */, 17 },
+ /* 3812 */ { MAD_F(0x0744e3aa) /* 0.454318683 */, 17 },
+ /* 3813 */ { MAD_F(0x07458a4d) /* 0.454477598 */, 17 },
+ /* 3814 */ { MAD_F(0x074630f3) /* 0.454636527 */, 17 },
+ /* 3815 */ { MAD_F(0x0746d79d) /* 0.454795470 */, 17 },
+ /* 3816 */ { MAD_F(0x07477e4b) /* 0.454954427 */, 17 },
+ /* 3817 */ { MAD_F(0x074824fc) /* 0.455113397 */, 17 },
+ /* 3818 */ { MAD_F(0x0748cbb1) /* 0.455272382 */, 17 },
+ /* 3819 */ { MAD_F(0x0749726a) /* 0.455431381 */, 17 },
+ /* 3820 */ { MAD_F(0x074a1927) /* 0.455590393 */, 17 },
+ /* 3821 */ { MAD_F(0x074abfe7) /* 0.455749419 */, 17 },
+ /* 3822 */ { MAD_F(0x074b66ab) /* 0.455908459 */, 17 },
+ /* 3823 */ { MAD_F(0x074c0d73) /* 0.456067513 */, 17 },
+
+ /* 3824 */ { MAD_F(0x074cb43e) /* 0.456226581 */, 17 },
+ /* 3825 */ { MAD_F(0x074d5b0d) /* 0.456385663 */, 17 },
+ /* 3826 */ { MAD_F(0x074e01e0) /* 0.456544759 */, 17 },
+ /* 3827 */ { MAD_F(0x074ea8b7) /* 0.456703868 */, 17 },
+ /* 3828 */ { MAD_F(0x074f4f91) /* 0.456862992 */, 17 },
+ /* 3829 */ { MAD_F(0x074ff66f) /* 0.457022129 */, 17 },
+ /* 3830 */ { MAD_F(0x07509d51) /* 0.457181280 */, 17 },
+ /* 3831 */ { MAD_F(0x07514437) /* 0.457340445 */, 17 },
+ /* 3832 */ { MAD_F(0x0751eb20) /* 0.457499623 */, 17 },
+ /* 3833 */ { MAD_F(0x0752920d) /* 0.457658816 */, 17 },
+ /* 3834 */ { MAD_F(0x075338fd) /* 0.457818022 */, 17 },
+ /* 3835 */ { MAD_F(0x0753dff2) /* 0.457977243 */, 17 },
+ /* 3836 */ { MAD_F(0x075486ea) /* 0.458136477 */, 17 },
+ /* 3837 */ { MAD_F(0x07552de6) /* 0.458295725 */, 17 },
+ /* 3838 */ { MAD_F(0x0755d4e5) /* 0.458454987 */, 17 },
+ /* 3839 */ { MAD_F(0x07567be8) /* 0.458614262 */, 17 },
+
+ /* 3840 */ { MAD_F(0x075722ef) /* 0.458773552 */, 17 },
+ /* 3841 */ { MAD_F(0x0757c9fa) /* 0.458932855 */, 17 },
+ /* 3842 */ { MAD_F(0x07587108) /* 0.459092172 */, 17 },
+ /* 3843 */ { MAD_F(0x0759181a) /* 0.459251503 */, 17 },
+ /* 3844 */ { MAD_F(0x0759bf30) /* 0.459410848 */, 17 },
+ /* 3845 */ { MAD_F(0x075a664a) /* 0.459570206 */, 17 },
+ /* 3846 */ { MAD_F(0x075b0d67) /* 0.459729579 */, 17 },
+ /* 3847 */ { MAD_F(0x075bb488) /* 0.459888965 */, 17 },
+ /* 3848 */ { MAD_F(0x075c5bac) /* 0.460048365 */, 17 },
+ /* 3849 */ { MAD_F(0x075d02d5) /* 0.460207779 */, 17 },
+ /* 3850 */ { MAD_F(0x075daa01) /* 0.460367206 */, 17 },
+ /* 3851 */ { MAD_F(0x075e5130) /* 0.460526648 */, 17 },
+ /* 3852 */ { MAD_F(0x075ef864) /* 0.460686103 */, 17 },
+ /* 3853 */ { MAD_F(0x075f9f9b) /* 0.460845572 */, 17 },
+ /* 3854 */ { MAD_F(0x076046d6) /* 0.461005055 */, 17 },
+ /* 3855 */ { MAD_F(0x0760ee14) /* 0.461164552 */, 17 },
+
+ /* 3856 */ { MAD_F(0x07619557) /* 0.461324062 */, 17 },
+ /* 3857 */ { MAD_F(0x07623c9d) /* 0.461483586 */, 17 },
+ /* 3858 */ { MAD_F(0x0762e3e6) /* 0.461643124 */, 17 },
+ /* 3859 */ { MAD_F(0x07638b34) /* 0.461802676 */, 17 },
+ /* 3860 */ { MAD_F(0x07643285) /* 0.461962242 */, 17 },
+ /* 3861 */ { MAD_F(0x0764d9d9) /* 0.462121821 */, 17 },
+ /* 3862 */ { MAD_F(0x07658132) /* 0.462281414 */, 17 },
+ /* 3863 */ { MAD_F(0x0766288e) /* 0.462441021 */, 17 },
+ /* 3864 */ { MAD_F(0x0766cfee) /* 0.462600642 */, 17 },
+ /* 3865 */ { MAD_F(0x07677751) /* 0.462760276 */, 17 },
+ /* 3866 */ { MAD_F(0x07681eb9) /* 0.462919924 */, 17 },
+ /* 3867 */ { MAD_F(0x0768c624) /* 0.463079586 */, 17 },
+ /* 3868 */ { MAD_F(0x07696d92) /* 0.463239262 */, 17 },
+ /* 3869 */ { MAD_F(0x076a1505) /* 0.463398951 */, 17 },
+ /* 3870 */ { MAD_F(0x076abc7b) /* 0.463558655 */, 17 },
+ /* 3871 */ { MAD_F(0x076b63f4) /* 0.463718372 */, 17 },
+
+ /* 3872 */ { MAD_F(0x076c0b72) /* 0.463878102 */, 17 },
+ /* 3873 */ { MAD_F(0x076cb2f3) /* 0.464037847 */, 17 },
+ /* 3874 */ { MAD_F(0x076d5a78) /* 0.464197605 */, 17 },
+ /* 3875 */ { MAD_F(0x076e0200) /* 0.464357377 */, 17 },
+ /* 3876 */ { MAD_F(0x076ea98c) /* 0.464517163 */, 17 },
+ /* 3877 */ { MAD_F(0x076f511c) /* 0.464676962 */, 17 },
+ /* 3878 */ { MAD_F(0x076ff8b0) /* 0.464836776 */, 17 },
+ /* 3879 */ { MAD_F(0x0770a047) /* 0.464996603 */, 17 },
+ /* 3880 */ { MAD_F(0x077147e2) /* 0.465156443 */, 17 },
+ /* 3881 */ { MAD_F(0x0771ef80) /* 0.465316298 */, 17 },
+ /* 3882 */ { MAD_F(0x07729723) /* 0.465476166 */, 17 },
+ /* 3883 */ { MAD_F(0x07733ec9) /* 0.465636048 */, 17 },
+ /* 3884 */ { MAD_F(0x0773e672) /* 0.465795943 */, 17 },
+ /* 3885 */ { MAD_F(0x07748e20) /* 0.465955853 */, 17 },
+ /* 3886 */ { MAD_F(0x077535d1) /* 0.466115776 */, 17 },
+ /* 3887 */ { MAD_F(0x0775dd85) /* 0.466275713 */, 17 },
+
+ /* 3888 */ { MAD_F(0x0776853e) /* 0.466435663 */, 17 },
+ /* 3889 */ { MAD_F(0x07772cfa) /* 0.466595627 */, 17 },
+ /* 3890 */ { MAD_F(0x0777d4ba) /* 0.466755605 */, 17 },
+ /* 3891 */ { MAD_F(0x07787c7d) /* 0.466915597 */, 17 },
+ /* 3892 */ { MAD_F(0x07792444) /* 0.467075602 */, 17 },
+ /* 3893 */ { MAD_F(0x0779cc0f) /* 0.467235621 */, 17 },
+ /* 3894 */ { MAD_F(0x077a73dd) /* 0.467395654 */, 17 },
+ /* 3895 */ { MAD_F(0x077b1baf) /* 0.467555701 */, 17 },
+ /* 3896 */ { MAD_F(0x077bc385) /* 0.467715761 */, 17 },
+ /* 3897 */ { MAD_F(0x077c6b5f) /* 0.467875835 */, 17 },
+ /* 3898 */ { MAD_F(0x077d133c) /* 0.468035922 */, 17 },
+ /* 3899 */ { MAD_F(0x077dbb1d) /* 0.468196023 */, 17 },
+ /* 3900 */ { MAD_F(0x077e6301) /* 0.468356138 */, 17 },
+ /* 3901 */ { MAD_F(0x077f0ae9) /* 0.468516267 */, 17 },
+ /* 3902 */ { MAD_F(0x077fb2d5) /* 0.468676409 */, 17 },
+ /* 3903 */ { MAD_F(0x07805ac5) /* 0.468836565 */, 17 },
+
+ /* 3904 */ { MAD_F(0x078102b8) /* 0.468996735 */, 17 },
+ /* 3905 */ { MAD_F(0x0781aaaf) /* 0.469156918 */, 17 },
+ /* 3906 */ { MAD_F(0x078252aa) /* 0.469317115 */, 17 },
+ /* 3907 */ { MAD_F(0x0782faa8) /* 0.469477326 */, 17 },
+ /* 3908 */ { MAD_F(0x0783a2aa) /* 0.469637550 */, 17 },
+ /* 3909 */ { MAD_F(0x07844aaf) /* 0.469797788 */, 17 },
+ /* 3910 */ { MAD_F(0x0784f2b8) /* 0.469958040 */, 17 },
+ /* 3911 */ { MAD_F(0x07859ac5) /* 0.470118305 */, 17 },
+ /* 3912 */ { MAD_F(0x078642d6) /* 0.470278584 */, 17 },
+ /* 3913 */ { MAD_F(0x0786eaea) /* 0.470438877 */, 17 },
+ /* 3914 */ { MAD_F(0x07879302) /* 0.470599183 */, 17 },
+ /* 3915 */ { MAD_F(0x07883b1e) /* 0.470759503 */, 17 },
+ /* 3916 */ { MAD_F(0x0788e33d) /* 0.470919836 */, 17 },
+ /* 3917 */ { MAD_F(0x07898b60) /* 0.471080184 */, 17 },
+ /* 3918 */ { MAD_F(0x078a3386) /* 0.471240545 */, 17 },
+ /* 3919 */ { MAD_F(0x078adbb0) /* 0.471400919 */, 17 },
+
+ /* 3920 */ { MAD_F(0x078b83de) /* 0.471561307 */, 17 },
+ /* 3921 */ { MAD_F(0x078c2c10) /* 0.471721709 */, 17 },
+ /* 3922 */ { MAD_F(0x078cd445) /* 0.471882125 */, 17 },
+ /* 3923 */ { MAD_F(0x078d7c7e) /* 0.472042554 */, 17 },
+ /* 3924 */ { MAD_F(0x078e24ba) /* 0.472202996 */, 17 },
+ /* 3925 */ { MAD_F(0x078eccfb) /* 0.472363453 */, 17 },
+ /* 3926 */ { MAD_F(0x078f753e) /* 0.472523923 */, 17 },
+ /* 3927 */ { MAD_F(0x07901d86) /* 0.472684406 */, 17 },
+ /* 3928 */ { MAD_F(0x0790c5d1) /* 0.472844904 */, 17 },
+ /* 3929 */ { MAD_F(0x07916e20) /* 0.473005414 */, 17 },
+ /* 3930 */ { MAD_F(0x07921672) /* 0.473165939 */, 17 },
+ /* 3931 */ { MAD_F(0x0792bec8) /* 0.473326477 */, 17 },
+ /* 3932 */ { MAD_F(0x07936722) /* 0.473487029 */, 17 },
+ /* 3933 */ { MAD_F(0x07940f80) /* 0.473647594 */, 17 },
+ /* 3934 */ { MAD_F(0x0794b7e1) /* 0.473808173 */, 17 },
+ /* 3935 */ { MAD_F(0x07956045) /* 0.473968765 */, 17 },
+
+ /* 3936 */ { MAD_F(0x079608ae) /* 0.474129372 */, 17 },
+ /* 3937 */ { MAD_F(0x0796b11a) /* 0.474289991 */, 17 },
+ /* 3938 */ { MAD_F(0x0797598a) /* 0.474450625 */, 17 },
+ /* 3939 */ { MAD_F(0x079801fd) /* 0.474611272 */, 17 },
+ /* 3940 */ { MAD_F(0x0798aa74) /* 0.474771932 */, 17 },
+ /* 3941 */ { MAD_F(0x079952ee) /* 0.474932606 */, 17 },
+ /* 3942 */ { MAD_F(0x0799fb6d) /* 0.475093294 */, 17 },
+ /* 3943 */ { MAD_F(0x079aa3ef) /* 0.475253995 */, 17 },
+ /* 3944 */ { MAD_F(0x079b4c74) /* 0.475414710 */, 17 },
+ /* 3945 */ { MAD_F(0x079bf4fd) /* 0.475575439 */, 17 },
+ /* 3946 */ { MAD_F(0x079c9d8a) /* 0.475736181 */, 17 },
+ /* 3947 */ { MAD_F(0x079d461b) /* 0.475896936 */, 17 },
+ /* 3948 */ { MAD_F(0x079deeaf) /* 0.476057705 */, 17 },
+ /* 3949 */ { MAD_F(0x079e9747) /* 0.476218488 */, 17 },
+ /* 3950 */ { MAD_F(0x079f3fe2) /* 0.476379285 */, 17 },
+ /* 3951 */ { MAD_F(0x079fe881) /* 0.476540095 */, 17 },
+
+ /* 3952 */ { MAD_F(0x07a09124) /* 0.476700918 */, 17 },
+ /* 3953 */ { MAD_F(0x07a139ca) /* 0.476861755 */, 17 },
+ /* 3954 */ { MAD_F(0x07a1e274) /* 0.477022606 */, 17 },
+ /* 3955 */ { MAD_F(0x07a28b22) /* 0.477183470 */, 17 },
+ /* 3956 */ { MAD_F(0x07a333d3) /* 0.477344348 */, 17 },
+ /* 3957 */ { MAD_F(0x07a3dc88) /* 0.477505239 */, 17 },
+ /* 3958 */ { MAD_F(0x07a48541) /* 0.477666144 */, 17 },
+ /* 3959 */ { MAD_F(0x07a52dfd) /* 0.477827062 */, 17 },
+ /* 3960 */ { MAD_F(0x07a5d6bd) /* 0.477987994 */, 17 },
+ /* 3961 */ { MAD_F(0x07a67f80) /* 0.478148940 */, 17 },
+ /* 3962 */ { MAD_F(0x07a72847) /* 0.478309899 */, 17 },
+ /* 3963 */ { MAD_F(0x07a7d112) /* 0.478470871 */, 17 },
+ /* 3964 */ { MAD_F(0x07a879e1) /* 0.478631857 */, 17 },
+ /* 3965 */ { MAD_F(0x07a922b3) /* 0.478792857 */, 17 },
+ /* 3966 */ { MAD_F(0x07a9cb88) /* 0.478953870 */, 17 },
+ /* 3967 */ { MAD_F(0x07aa7462) /* 0.479114897 */, 17 },
+
+ /* 3968 */ { MAD_F(0x07ab1d3e) /* 0.479275937 */, 17 },
+ /* 3969 */ { MAD_F(0x07abc61f) /* 0.479436991 */, 17 },
+ /* 3970 */ { MAD_F(0x07ac6f03) /* 0.479598058 */, 17 },
+ /* 3971 */ { MAD_F(0x07ad17eb) /* 0.479759139 */, 17 },
+ /* 3972 */ { MAD_F(0x07adc0d6) /* 0.479920233 */, 17 },
+ /* 3973 */ { MAD_F(0x07ae69c6) /* 0.480081341 */, 17 },
+ /* 3974 */ { MAD_F(0x07af12b8) /* 0.480242463 */, 17 },
+ /* 3975 */ { MAD_F(0x07afbbaf) /* 0.480403598 */, 17 },
+ /* 3976 */ { MAD_F(0x07b064a8) /* 0.480564746 */, 17 },
+ /* 3977 */ { MAD_F(0x07b10da6) /* 0.480725908 */, 17 },
+ /* 3978 */ { MAD_F(0x07b1b6a7) /* 0.480887083 */, 17 },
+ /* 3979 */ { MAD_F(0x07b25fac) /* 0.481048272 */, 17 },
+ /* 3980 */ { MAD_F(0x07b308b5) /* 0.481209475 */, 17 },
+ /* 3981 */ { MAD_F(0x07b3b1c1) /* 0.481370691 */, 17 },
+ /* 3982 */ { MAD_F(0x07b45ad0) /* 0.481531920 */, 17 },
+ /* 3983 */ { MAD_F(0x07b503e4) /* 0.481693163 */, 17 },
+
+ /* 3984 */ { MAD_F(0x07b5acfb) /* 0.481854420 */, 17 },
+ /* 3985 */ { MAD_F(0x07b65615) /* 0.482015690 */, 17 },
+ /* 3986 */ { MAD_F(0x07b6ff33) /* 0.482176973 */, 17 },
+ /* 3987 */ { MAD_F(0x07b7a855) /* 0.482338270 */, 17 },
+ /* 3988 */ { MAD_F(0x07b8517b) /* 0.482499580 */, 17 },
+ /* 3989 */ { MAD_F(0x07b8faa4) /* 0.482660904 */, 17 },
+ /* 3990 */ { MAD_F(0x07b9a3d0) /* 0.482822242 */, 17 },
+ /* 3991 */ { MAD_F(0x07ba4d01) /* 0.482983592 */, 17 },
+ /* 3992 */ { MAD_F(0x07baf635) /* 0.483144957 */, 17 },
+ /* 3993 */ { MAD_F(0x07bb9f6c) /* 0.483306335 */, 17 },
+ /* 3994 */ { MAD_F(0x07bc48a7) /* 0.483467726 */, 17 },
+ /* 3995 */ { MAD_F(0x07bcf1e6) /* 0.483629131 */, 17 },
+ /* 3996 */ { MAD_F(0x07bd9b28) /* 0.483790549 */, 17 },
+ /* 3997 */ { MAD_F(0x07be446e) /* 0.483951980 */, 17 },
+ /* 3998 */ { MAD_F(0x07beedb8) /* 0.484113426 */, 17 },
+ /* 3999 */ { MAD_F(0x07bf9705) /* 0.484274884 */, 17 },
+
+ /* 4000 */ { MAD_F(0x07c04056) /* 0.484436356 */, 17 },
+ /* 4001 */ { MAD_F(0x07c0e9aa) /* 0.484597842 */, 17 },
+ /* 4002 */ { MAD_F(0x07c19302) /* 0.484759341 */, 17 },
+ /* 4003 */ { MAD_F(0x07c23c5e) /* 0.484920853 */, 17 },
+ /* 4004 */ { MAD_F(0x07c2e5bd) /* 0.485082379 */, 17 },
+ /* 4005 */ { MAD_F(0x07c38f20) /* 0.485243918 */, 17 },
+ /* 4006 */ { MAD_F(0x07c43887) /* 0.485405471 */, 17 },
+ /* 4007 */ { MAD_F(0x07c4e1f1) /* 0.485567037 */, 17 },
+ /* 4008 */ { MAD_F(0x07c58b5f) /* 0.485728617 */, 17 },
+ /* 4009 */ { MAD_F(0x07c634d0) /* 0.485890210 */, 17 },
+ /* 4010 */ { MAD_F(0x07c6de45) /* 0.486051817 */, 17 },
+ /* 4011 */ { MAD_F(0x07c787bd) /* 0.486213436 */, 17 },
+ /* 4012 */ { MAD_F(0x07c83139) /* 0.486375070 */, 17 },
+ /* 4013 */ { MAD_F(0x07c8dab9) /* 0.486536717 */, 17 },
+ /* 4014 */ { MAD_F(0x07c9843c) /* 0.486698377 */, 17 },
+ /* 4015 */ { MAD_F(0x07ca2dc3) /* 0.486860051 */, 17 },
+
+ /* 4016 */ { MAD_F(0x07cad74e) /* 0.487021738 */, 17 },
+ /* 4017 */ { MAD_F(0x07cb80dc) /* 0.487183438 */, 17 },
+ /* 4018 */ { MAD_F(0x07cc2a6e) /* 0.487345152 */, 17 },
+ /* 4019 */ { MAD_F(0x07ccd403) /* 0.487506879 */, 17 },
+ /* 4020 */ { MAD_F(0x07cd7d9c) /* 0.487668620 */, 17 },
+ /* 4021 */ { MAD_F(0x07ce2739) /* 0.487830374 */, 17 },
+ /* 4022 */ { MAD_F(0x07ced0d9) /* 0.487992142 */, 17 },
+ /* 4023 */ { MAD_F(0x07cf7a7d) /* 0.488153923 */, 17 },
+ /* 4024 */ { MAD_F(0x07d02424) /* 0.488315717 */, 17 },
+ /* 4025 */ { MAD_F(0x07d0cdcf) /* 0.488477525 */, 17 },
+ /* 4026 */ { MAD_F(0x07d1777e) /* 0.488639346 */, 17 },
+ /* 4027 */ { MAD_F(0x07d22130) /* 0.488801181 */, 17 },
+ /* 4028 */ { MAD_F(0x07d2cae5) /* 0.488963029 */, 17 },
+ /* 4029 */ { MAD_F(0x07d3749f) /* 0.489124890 */, 17 },
+ /* 4030 */ { MAD_F(0x07d41e5c) /* 0.489286765 */, 17 },
+ /* 4031 */ { MAD_F(0x07d4c81c) /* 0.489448653 */, 17 },
+
+ /* 4032 */ { MAD_F(0x07d571e0) /* 0.489610555 */, 17 },
+ /* 4033 */ { MAD_F(0x07d61ba8) /* 0.489772470 */, 17 },
+ /* 4034 */ { MAD_F(0x07d6c573) /* 0.489934398 */, 17 },
+ /* 4035 */ { MAD_F(0x07d76f42) /* 0.490096340 */, 17 },
+ /* 4036 */ { MAD_F(0x07d81915) /* 0.490258295 */, 17 },
+ /* 4037 */ { MAD_F(0x07d8c2eb) /* 0.490420263 */, 17 },
+ /* 4038 */ { MAD_F(0x07d96cc4) /* 0.490582245 */, 17 },
+ /* 4039 */ { MAD_F(0x07da16a2) /* 0.490744240 */, 17 },
+ /* 4040 */ { MAD_F(0x07dac083) /* 0.490906249 */, 17 },
+ /* 4041 */ { MAD_F(0x07db6a67) /* 0.491068271 */, 17 },
+ /* 4042 */ { MAD_F(0x07dc144f) /* 0.491230306 */, 17 },
+ /* 4043 */ { MAD_F(0x07dcbe3b) /* 0.491392355 */, 17 },
+ /* 4044 */ { MAD_F(0x07dd682a) /* 0.491554417 */, 17 },
+ /* 4045 */ { MAD_F(0x07de121d) /* 0.491716492 */, 17 },
+ /* 4046 */ { MAD_F(0x07debc13) /* 0.491878581 */, 17 },
+ /* 4047 */ { MAD_F(0x07df660d) /* 0.492040683 */, 17 },
+
+ /* 4048 */ { MAD_F(0x07e0100a) /* 0.492202799 */, 17 },
+ /* 4049 */ { MAD_F(0x07e0ba0c) /* 0.492364928 */, 17 },
+ /* 4050 */ { MAD_F(0x07e16410) /* 0.492527070 */, 17 },
+ /* 4051 */ { MAD_F(0x07e20e19) /* 0.492689225 */, 17 },
+ /* 4052 */ { MAD_F(0x07e2b824) /* 0.492851394 */, 17 },
+ /* 4053 */ { MAD_F(0x07e36234) /* 0.493013576 */, 17 },
+ /* 4054 */ { MAD_F(0x07e40c47) /* 0.493175772 */, 17 },
+ /* 4055 */ { MAD_F(0x07e4b65e) /* 0.493337981 */, 17 },
+ /* 4056 */ { MAD_F(0x07e56078) /* 0.493500203 */, 17 },
+ /* 4057 */ { MAD_F(0x07e60a95) /* 0.493662438 */, 17 },
+ /* 4058 */ { MAD_F(0x07e6b4b7) /* 0.493824687 */, 17 },
+ /* 4059 */ { MAD_F(0x07e75edc) /* 0.493986949 */, 17 },
+ /* 4060 */ { MAD_F(0x07e80904) /* 0.494149225 */, 17 },
+ /* 4061 */ { MAD_F(0x07e8b330) /* 0.494311514 */, 17 },
+ /* 4062 */ { MAD_F(0x07e95d60) /* 0.494473816 */, 17 },
+ /* 4063 */ { MAD_F(0x07ea0793) /* 0.494636131 */, 17 },
+
+ /* 4064 */ { MAD_F(0x07eab1ca) /* 0.494798460 */, 17 },
+ /* 4065 */ { MAD_F(0x07eb5c04) /* 0.494960802 */, 17 },
+ /* 4066 */ { MAD_F(0x07ec0642) /* 0.495123158 */, 17 },
+ /* 4067 */ { MAD_F(0x07ecb084) /* 0.495285526 */, 17 },
+ /* 4068 */ { MAD_F(0x07ed5ac9) /* 0.495447908 */, 17 },
+ /* 4069 */ { MAD_F(0x07ee0512) /* 0.495610304 */, 17 },
+ /* 4070 */ { MAD_F(0x07eeaf5e) /* 0.495772712 */, 17 },
+ /* 4071 */ { MAD_F(0x07ef59ae) /* 0.495935134 */, 17 },
+ /* 4072 */ { MAD_F(0x07f00401) /* 0.496097570 */, 17 },
+ /* 4073 */ { MAD_F(0x07f0ae58) /* 0.496260018 */, 17 },
+ /* 4074 */ { MAD_F(0x07f158b3) /* 0.496422480 */, 17 },
+ /* 4075 */ { MAD_F(0x07f20311) /* 0.496584955 */, 17 },
+ /* 4076 */ { MAD_F(0x07f2ad72) /* 0.496747444 */, 17 },
+ /* 4077 */ { MAD_F(0x07f357d8) /* 0.496909945 */, 17 },
+ /* 4078 */ { MAD_F(0x07f40240) /* 0.497072460 */, 17 },
+ /* 4079 */ { MAD_F(0x07f4acad) /* 0.497234989 */, 17 },
+
+ /* 4080 */ { MAD_F(0x07f5571d) /* 0.497397530 */, 17 },
+ /* 4081 */ { MAD_F(0x07f60190) /* 0.497560085 */, 17 },
+ /* 4082 */ { MAD_F(0x07f6ac07) /* 0.497722653 */, 17 },
+ /* 4083 */ { MAD_F(0x07f75682) /* 0.497885235 */, 17 },
+ /* 4084 */ { MAD_F(0x07f80100) /* 0.498047829 */, 17 },
+ /* 4085 */ { MAD_F(0x07f8ab82) /* 0.498210437 */, 17 },
+ /* 4086 */ { MAD_F(0x07f95607) /* 0.498373058 */, 17 },
+ /* 4087 */ { MAD_F(0x07fa0090) /* 0.498535693 */, 17 },
+ /* 4088 */ { MAD_F(0x07faab1c) /* 0.498698341 */, 17 },
+ /* 4089 */ { MAD_F(0x07fb55ac) /* 0.498861002 */, 17 },
+ /* 4090 */ { MAD_F(0x07fc0040) /* 0.499023676 */, 17 },
+ /* 4091 */ { MAD_F(0x07fcaad7) /* 0.499186364 */, 17 },
+ /* 4092 */ { MAD_F(0x07fd5572) /* 0.499349064 */, 17 },
+ /* 4093 */ { MAD_F(0x07fe0010) /* 0.499511778 */, 17 },
+ /* 4094 */ { MAD_F(0x07feaab2) /* 0.499674506 */, 17 },
+ /* 4095 */ { MAD_F(0x07ff5557) /* 0.499837246 */, 17 },
+
+ /* 4096 */ { MAD_F(0x04000000) /* 0.250000000 */, 18 },
+ /* 4097 */ { MAD_F(0x04005556) /* 0.250081384 */, 18 },
+ /* 4098 */ { MAD_F(0x0400aaae) /* 0.250162774 */, 18 },
+ /* 4099 */ { MAD_F(0x04010008) /* 0.250244170 */, 18 },
+ /* 4100 */ { MAD_F(0x04015563) /* 0.250325574 */, 18 },
+ /* 4101 */ { MAD_F(0x0401aac1) /* 0.250406984 */, 18 },
+ /* 4102 */ { MAD_F(0x04020020) /* 0.250488400 */, 18 },
+ /* 4103 */ { MAD_F(0x04025581) /* 0.250569824 */, 18 },
+ /* 4104 */ { MAD_F(0x0402aae3) /* 0.250651254 */, 18 },
+ /* 4105 */ { MAD_F(0x04030048) /* 0.250732690 */, 18 },
+ /* 4106 */ { MAD_F(0x040355ae) /* 0.250814133 */, 18 },
+ /* 4107 */ { MAD_F(0x0403ab16) /* 0.250895583 */, 18 },
+ /* 4108 */ { MAD_F(0x04040080) /* 0.250977039 */, 18 },
+ /* 4109 */ { MAD_F(0x040455eb) /* 0.251058502 */, 18 },
+ /* 4110 */ { MAD_F(0x0404ab59) /* 0.251139971 */, 18 },
+ /* 4111 */ { MAD_F(0x040500c8) /* 0.251221448 */, 18 },
+
+ /* 4112 */ { MAD_F(0x04055638) /* 0.251302930 */, 18 },
+ /* 4113 */ { MAD_F(0x0405abab) /* 0.251384420 */, 18 },
+ /* 4114 */ { MAD_F(0x0406011f) /* 0.251465916 */, 18 },
+ /* 4115 */ { MAD_F(0x04065696) /* 0.251547418 */, 18 },
+ /* 4116 */ { MAD_F(0x0406ac0e) /* 0.251628927 */, 18 },
+ /* 4117 */ { MAD_F(0x04070187) /* 0.251710443 */, 18 },
+ /* 4118 */ { MAD_F(0x04075703) /* 0.251791965 */, 18 },
+ /* 4119 */ { MAD_F(0x0407ac80) /* 0.251873494 */, 18 },
+ /* 4120 */ { MAD_F(0x040801ff) /* 0.251955030 */, 18 },
+ /* 4121 */ { MAD_F(0x04085780) /* 0.252036572 */, 18 },
+ /* 4122 */ { MAD_F(0x0408ad02) /* 0.252118121 */, 18 },
+ /* 4123 */ { MAD_F(0x04090287) /* 0.252199676 */, 18 },
+ /* 4124 */ { MAD_F(0x0409580d) /* 0.252281238 */, 18 },
+ /* 4125 */ { MAD_F(0x0409ad95) /* 0.252362807 */, 18 },
+ /* 4126 */ { MAD_F(0x040a031e) /* 0.252444382 */, 18 },
+ /* 4127 */ { MAD_F(0x040a58aa) /* 0.252525963 */, 18 },
+
+ /* 4128 */ { MAD_F(0x040aae37) /* 0.252607552 */, 18 },
+ /* 4129 */ { MAD_F(0x040b03c6) /* 0.252689147 */, 18 },
+ /* 4130 */ { MAD_F(0x040b5957) /* 0.252770748 */, 18 },
+ /* 4131 */ { MAD_F(0x040baee9) /* 0.252852356 */, 18 },
+ /* 4132 */ { MAD_F(0x040c047e) /* 0.252933971 */, 18 },
+ /* 4133 */ { MAD_F(0x040c5a14) /* 0.253015592 */, 18 },
+ /* 4134 */ { MAD_F(0x040cafab) /* 0.253097220 */, 18 },
+ /* 4135 */ { MAD_F(0x040d0545) /* 0.253178854 */, 18 },
+ /* 4136 */ { MAD_F(0x040d5ae0) /* 0.253260495 */, 18 },
+ /* 4137 */ { MAD_F(0x040db07d) /* 0.253342143 */, 18 },
+ /* 4138 */ { MAD_F(0x040e061c) /* 0.253423797 */, 18 },
+ /* 4139 */ { MAD_F(0x040e5bbd) /* 0.253505457 */, 18 },
+ /* 4140 */ { MAD_F(0x040eb15f) /* 0.253587125 */, 18 },
+ /* 4141 */ { MAD_F(0x040f0703) /* 0.253668799 */, 18 },
+ /* 4142 */ { MAD_F(0x040f5ca9) /* 0.253750479 */, 18 },
+ /* 4143 */ { MAD_F(0x040fb251) /* 0.253832166 */, 18 },
+
+ /* 4144 */ { MAD_F(0x041007fa) /* 0.253913860 */, 18 },
+ /* 4145 */ { MAD_F(0x04105da6) /* 0.253995560 */, 18 },
+ /* 4146 */ { MAD_F(0x0410b353) /* 0.254077266 */, 18 },
+ /* 4147 */ { MAD_F(0x04110901) /* 0.254158980 */, 18 },
+ /* 4148 */ { MAD_F(0x04115eb2) /* 0.254240700 */, 18 },
+ /* 4149 */ { MAD_F(0x0411b464) /* 0.254322426 */, 18 },
+ /* 4150 */ { MAD_F(0x04120a18) /* 0.254404159 */, 18 },
+ /* 4151 */ { MAD_F(0x04125fce) /* 0.254485899 */, 18 },
+ /* 4152 */ { MAD_F(0x0412b586) /* 0.254567645 */, 18 },
+ /* 4153 */ { MAD_F(0x04130b3f) /* 0.254649397 */, 18 },
+ /* 4154 */ { MAD_F(0x041360fa) /* 0.254731157 */, 18 },
+ /* 4155 */ { MAD_F(0x0413b6b7) /* 0.254812922 */, 18 },
+ /* 4156 */ { MAD_F(0x04140c75) /* 0.254894695 */, 18 },
+ /* 4157 */ { MAD_F(0x04146236) /* 0.254976474 */, 18 },
+ /* 4158 */ { MAD_F(0x0414b7f8) /* 0.255058259 */, 18 },
+ /* 4159 */ { MAD_F(0x04150dbc) /* 0.255140051 */, 18 },
+
+ /* 4160 */ { MAD_F(0x04156381) /* 0.255221850 */, 18 },
+ /* 4161 */ { MAD_F(0x0415b949) /* 0.255303655 */, 18 },
+ /* 4162 */ { MAD_F(0x04160f12) /* 0.255385467 */, 18 },
+ /* 4163 */ { MAD_F(0x041664dd) /* 0.255467285 */, 18 },
+ /* 4164 */ { MAD_F(0x0416baaa) /* 0.255549110 */, 18 },
+ /* 4165 */ { MAD_F(0x04171078) /* 0.255630941 */, 18 },
+ /* 4166 */ { MAD_F(0x04176648) /* 0.255712779 */, 18 },
+ /* 4167 */ { MAD_F(0x0417bc1a) /* 0.255794624 */, 18 },
+ /* 4168 */ { MAD_F(0x041811ee) /* 0.255876475 */, 18 },
+ /* 4169 */ { MAD_F(0x041867c3) /* 0.255958332 */, 18 },
+ /* 4170 */ { MAD_F(0x0418bd9b) /* 0.256040196 */, 18 },
+ /* 4171 */ { MAD_F(0x04191374) /* 0.256122067 */, 18 },
+ /* 4172 */ { MAD_F(0x0419694e) /* 0.256203944 */, 18 },
+ /* 4173 */ { MAD_F(0x0419bf2b) /* 0.256285828 */, 18 },
+ /* 4174 */ { MAD_F(0x041a1509) /* 0.256367718 */, 18 },
+ /* 4175 */ { MAD_F(0x041a6ae9) /* 0.256449615 */, 18 },
+
+ /* 4176 */ { MAD_F(0x041ac0cb) /* 0.256531518 */, 18 },
+ /* 4177 */ { MAD_F(0x041b16ae) /* 0.256613428 */, 18 },
+ /* 4178 */ { MAD_F(0x041b6c94) /* 0.256695344 */, 18 },
+ /* 4179 */ { MAD_F(0x041bc27b) /* 0.256777267 */, 18 },
+ /* 4180 */ { MAD_F(0x041c1863) /* 0.256859197 */, 18 },
+ /* 4181 */ { MAD_F(0x041c6e4e) /* 0.256941133 */, 18 },
+ /* 4182 */ { MAD_F(0x041cc43a) /* 0.257023076 */, 18 },
+ /* 4183 */ { MAD_F(0x041d1a28) /* 0.257105025 */, 18 },
+ /* 4184 */ { MAD_F(0x041d7018) /* 0.257186980 */, 18 },
+ /* 4185 */ { MAD_F(0x041dc60a) /* 0.257268942 */, 18 },
+ /* 4186 */ { MAD_F(0x041e1bfd) /* 0.257350911 */, 18 },
+ /* 4187 */ { MAD_F(0x041e71f2) /* 0.257432886 */, 18 },
+ /* 4188 */ { MAD_F(0x041ec7e9) /* 0.257514868 */, 18 },
+ /* 4189 */ { MAD_F(0x041f1de1) /* 0.257596856 */, 18 },
+ /* 4190 */ { MAD_F(0x041f73dc) /* 0.257678851 */, 18 },
+ /* 4191 */ { MAD_F(0x041fc9d8) /* 0.257760852 */, 18 },
+
+ /* 4192 */ { MAD_F(0x04201fd5) /* 0.257842860 */, 18 },
+ /* 4193 */ { MAD_F(0x042075d5) /* 0.257924875 */, 18 },
+ /* 4194 */ { MAD_F(0x0420cbd6) /* 0.258006895 */, 18 },
+ /* 4195 */ { MAD_F(0x042121d9) /* 0.258088923 */, 18 },
+ /* 4196 */ { MAD_F(0x042177de) /* 0.258170957 */, 18 },
+ /* 4197 */ { MAD_F(0x0421cde5) /* 0.258252997 */, 18 },
+ /* 4198 */ { MAD_F(0x042223ed) /* 0.258335044 */, 18 },
+ /* 4199 */ { MAD_F(0x042279f7) /* 0.258417097 */, 18 },
+ /* 4200 */ { MAD_F(0x0422d003) /* 0.258499157 */, 18 },
+ /* 4201 */ { MAD_F(0x04232611) /* 0.258581224 */, 18 },
+ /* 4202 */ { MAD_F(0x04237c20) /* 0.258663297 */, 18 },
+ /* 4203 */ { MAD_F(0x0423d231) /* 0.258745376 */, 18 },
+ /* 4204 */ { MAD_F(0x04242844) /* 0.258827462 */, 18 },
+ /* 4205 */ { MAD_F(0x04247e58) /* 0.258909555 */, 18 },
+ /* 4206 */ { MAD_F(0x0424d46e) /* 0.258991654 */, 18 },
+ /* 4207 */ { MAD_F(0x04252a87) /* 0.259073760 */, 18 },
+
+ /* 4208 */ { MAD_F(0x042580a0) /* 0.259155872 */, 18 },
+ /* 4209 */ { MAD_F(0x0425d6bc) /* 0.259237990 */, 18 },
+ /* 4210 */ { MAD_F(0x04262cd9) /* 0.259320115 */, 18 },
+ /* 4211 */ { MAD_F(0x042682f8) /* 0.259402247 */, 18 },
+ /* 4212 */ { MAD_F(0x0426d919) /* 0.259484385 */, 18 },
+ /* 4213 */ { MAD_F(0x04272f3b) /* 0.259566529 */, 18 },
+ /* 4214 */ { MAD_F(0x04278560) /* 0.259648680 */, 18 },
+ /* 4215 */ { MAD_F(0x0427db86) /* 0.259730838 */, 18 },
+ /* 4216 */ { MAD_F(0x042831ad) /* 0.259813002 */, 18 },
+ /* 4217 */ { MAD_F(0x042887d7) /* 0.259895173 */, 18 },
+ /* 4218 */ { MAD_F(0x0428de02) /* 0.259977350 */, 18 },
+ /* 4219 */ { MAD_F(0x0429342f) /* 0.260059533 */, 18 },
+ /* 4220 */ { MAD_F(0x04298a5e) /* 0.260141723 */, 18 },
+ /* 4221 */ { MAD_F(0x0429e08e) /* 0.260223920 */, 18 },
+ /* 4222 */ { MAD_F(0x042a36c0) /* 0.260306123 */, 18 },
+ /* 4223 */ { MAD_F(0x042a8cf4) /* 0.260388332 */, 18 },
+
+ /* 4224 */ { MAD_F(0x042ae32a) /* 0.260470548 */, 18 },
+ /* 4225 */ { MAD_F(0x042b3962) /* 0.260552771 */, 18 },
+ /* 4226 */ { MAD_F(0x042b8f9b) /* 0.260635000 */, 18 },
+ /* 4227 */ { MAD_F(0x042be5d6) /* 0.260717235 */, 18 },
+ /* 4228 */ { MAD_F(0x042c3c12) /* 0.260799477 */, 18 },
+ /* 4229 */ { MAD_F(0x042c9251) /* 0.260881725 */, 18 },
+ /* 4230 */ { MAD_F(0x042ce891) /* 0.260963980 */, 18 },
+ /* 4231 */ { MAD_F(0x042d3ed3) /* 0.261046242 */, 18 },
+ /* 4232 */ { MAD_F(0x042d9516) /* 0.261128510 */, 18 },
+ /* 4233 */ { MAD_F(0x042deb5c) /* 0.261210784 */, 18 },
+ /* 4234 */ { MAD_F(0x042e41a3) /* 0.261293065 */, 18 },
+ /* 4235 */ { MAD_F(0x042e97ec) /* 0.261375352 */, 18 },
+ /* 4236 */ { MAD_F(0x042eee36) /* 0.261457646 */, 18 },
+ /* 4237 */ { MAD_F(0x042f4482) /* 0.261539946 */, 18 },
+ /* 4238 */ { MAD_F(0x042f9ad1) /* 0.261622253 */, 18 },
+ /* 4239 */ { MAD_F(0x042ff120) /* 0.261704566 */, 18 },
+
+ /* 4240 */ { MAD_F(0x04304772) /* 0.261786886 */, 18 },
+ /* 4241 */ { MAD_F(0x04309dc5) /* 0.261869212 */, 18 },
+ /* 4242 */ { MAD_F(0x0430f41a) /* 0.261951545 */, 18 },
+ /* 4243 */ { MAD_F(0x04314a71) /* 0.262033884 */, 18 },
+ /* 4244 */ { MAD_F(0x0431a0c9) /* 0.262116229 */, 18 },
+ /* 4245 */ { MAD_F(0x0431f723) /* 0.262198581 */, 18 },
+ /* 4246 */ { MAD_F(0x04324d7f) /* 0.262280940 */, 18 },
+ /* 4247 */ { MAD_F(0x0432a3dd) /* 0.262363305 */, 18 },
+ /* 4248 */ { MAD_F(0x0432fa3d) /* 0.262445676 */, 18 },
+ /* 4249 */ { MAD_F(0x0433509e) /* 0.262528054 */, 18 },
+ /* 4250 */ { MAD_F(0x0433a701) /* 0.262610438 */, 18 },
+ /* 4251 */ { MAD_F(0x0433fd65) /* 0.262692829 */, 18 },
+ /* 4252 */ { MAD_F(0x043453cc) /* 0.262775227 */, 18 },
+ /* 4253 */ { MAD_F(0x0434aa34) /* 0.262857630 */, 18 },
+ /* 4254 */ { MAD_F(0x0435009d) /* 0.262940040 */, 18 },
+ /* 4255 */ { MAD_F(0x04355709) /* 0.263022457 */, 18 },
+
+ /* 4256 */ { MAD_F(0x0435ad76) /* 0.263104880 */, 18 },
+ /* 4257 */ { MAD_F(0x043603e5) /* 0.263187310 */, 18 },
+ /* 4258 */ { MAD_F(0x04365a56) /* 0.263269746 */, 18 },
+ /* 4259 */ { MAD_F(0x0436b0c9) /* 0.263352188 */, 18 },
+ /* 4260 */ { MAD_F(0x0437073d) /* 0.263434637 */, 18 },
+ /* 4261 */ { MAD_F(0x04375db3) /* 0.263517093 */, 18 },
+ /* 4262 */ { MAD_F(0x0437b42a) /* 0.263599554 */, 18 },
+ /* 4263 */ { MAD_F(0x04380aa4) /* 0.263682023 */, 18 },
+ /* 4264 */ { MAD_F(0x0438611f) /* 0.263764497 */, 18 },
+ /* 4265 */ { MAD_F(0x0438b79c) /* 0.263846979 */, 18 },
+ /* 4266 */ { MAD_F(0x04390e1a) /* 0.263929466 */, 18 },
+ /* 4267 */ { MAD_F(0x0439649b) /* 0.264011960 */, 18 },
+ /* 4268 */ { MAD_F(0x0439bb1d) /* 0.264094461 */, 18 },
+ /* 4269 */ { MAD_F(0x043a11a1) /* 0.264176968 */, 18 },
+ /* 4270 */ { MAD_F(0x043a6826) /* 0.264259481 */, 18 },
+ /* 4271 */ { MAD_F(0x043abead) /* 0.264342001 */, 18 },
+
+ /* 4272 */ { MAD_F(0x043b1536) /* 0.264424527 */, 18 },
+ /* 4273 */ { MAD_F(0x043b6bc1) /* 0.264507060 */, 18 },
+ /* 4274 */ { MAD_F(0x043bc24d) /* 0.264589599 */, 18 },
+ /* 4275 */ { MAD_F(0x043c18dc) /* 0.264672145 */, 18 },
+ /* 4276 */ { MAD_F(0x043c6f6c) /* 0.264754697 */, 18 },
+ /* 4277 */ { MAD_F(0x043cc5fd) /* 0.264837255 */, 18 },
+ /* 4278 */ { MAD_F(0x043d1c91) /* 0.264919820 */, 18 },
+ /* 4279 */ { MAD_F(0x043d7326) /* 0.265002392 */, 18 },
+ /* 4280 */ { MAD_F(0x043dc9bc) /* 0.265084969 */, 18 },
+ /* 4281 */ { MAD_F(0x043e2055) /* 0.265167554 */, 18 },
+ /* 4282 */ { MAD_F(0x043e76ef) /* 0.265250144 */, 18 },
+ /* 4283 */ { MAD_F(0x043ecd8b) /* 0.265332741 */, 18 },
+ /* 4284 */ { MAD_F(0x043f2429) /* 0.265415345 */, 18 },
+ /* 4285 */ { MAD_F(0x043f7ac8) /* 0.265497955 */, 18 },
+ /* 4286 */ { MAD_F(0x043fd169) /* 0.265580571 */, 18 },
+ /* 4287 */ { MAD_F(0x0440280c) /* 0.265663194 */, 18 },
+
+ /* 4288 */ { MAD_F(0x04407eb1) /* 0.265745823 */, 18 },
+ /* 4289 */ { MAD_F(0x0440d557) /* 0.265828459 */, 18 },
+ /* 4290 */ { MAD_F(0x04412bff) /* 0.265911101 */, 18 },
+ /* 4291 */ { MAD_F(0x044182a9) /* 0.265993749 */, 18 },
+ /* 4292 */ { MAD_F(0x0441d955) /* 0.266076404 */, 18 },
+ /* 4293 */ { MAD_F(0x04423002) /* 0.266159065 */, 18 },
+ /* 4294 */ { MAD_F(0x044286b1) /* 0.266241733 */, 18 },
+ /* 4295 */ { MAD_F(0x0442dd61) /* 0.266324407 */, 18 },
+ /* 4296 */ { MAD_F(0x04433414) /* 0.266407088 */, 18 },
+ /* 4297 */ { MAD_F(0x04438ac8) /* 0.266489775 */, 18 },
+ /* 4298 */ { MAD_F(0x0443e17e) /* 0.266572468 */, 18 },
+ /* 4299 */ { MAD_F(0x04443835) /* 0.266655168 */, 18 },
+ /* 4300 */ { MAD_F(0x04448eef) /* 0.266737874 */, 18 },
+ /* 4301 */ { MAD_F(0x0444e5aa) /* 0.266820587 */, 18 },
+ /* 4302 */ { MAD_F(0x04453c66) /* 0.266903306 */, 18 },
+ /* 4303 */ { MAD_F(0x04459325) /* 0.266986031 */, 18 },
+
+ /* 4304 */ { MAD_F(0x0445e9e5) /* 0.267068763 */, 18 },
+ /* 4305 */ { MAD_F(0x044640a7) /* 0.267151501 */, 18 },
+ /* 4306 */ { MAD_F(0x0446976a) /* 0.267234246 */, 18 },
+ /* 4307 */ { MAD_F(0x0446ee30) /* 0.267316997 */, 18 },
+ /* 4308 */ { MAD_F(0x044744f7) /* 0.267399755 */, 18 },
+ /* 4309 */ { MAD_F(0x04479bc0) /* 0.267482518 */, 18 },
+ /* 4310 */ { MAD_F(0x0447f28a) /* 0.267565289 */, 18 },
+ /* 4311 */ { MAD_F(0x04484956) /* 0.267648065 */, 18 },
+ /* 4312 */ { MAD_F(0x0448a024) /* 0.267730848 */, 18 },
+ /* 4313 */ { MAD_F(0x0448f6f4) /* 0.267813638 */, 18 },
+ /* 4314 */ { MAD_F(0x04494dc5) /* 0.267896434 */, 18 },
+ /* 4315 */ { MAD_F(0x0449a498) /* 0.267979236 */, 18 },
+ /* 4316 */ { MAD_F(0x0449fb6d) /* 0.268062045 */, 18 },
+ /* 4317 */ { MAD_F(0x044a5243) /* 0.268144860 */, 18 },
+ /* 4318 */ { MAD_F(0x044aa91c) /* 0.268227681 */, 18 },
+ /* 4319 */ { MAD_F(0x044afff6) /* 0.268310509 */, 18 },
+
+ /* 4320 */ { MAD_F(0x044b56d1) /* 0.268393343 */, 18 },
+ /* 4321 */ { MAD_F(0x044badaf) /* 0.268476184 */, 18 },
+ /* 4322 */ { MAD_F(0x044c048e) /* 0.268559031 */, 18 },
+ /* 4323 */ { MAD_F(0x044c5b6f) /* 0.268641885 */, 18 },
+ /* 4324 */ { MAD_F(0x044cb251) /* 0.268724744 */, 18 },
+ /* 4325 */ { MAD_F(0x044d0935) /* 0.268807611 */, 18 },
+ /* 4326 */ { MAD_F(0x044d601b) /* 0.268890483 */, 18 },
+ /* 4327 */ { MAD_F(0x044db703) /* 0.268973362 */, 18 },
+ /* 4328 */ { MAD_F(0x044e0dec) /* 0.269056248 */, 18 },
+ /* 4329 */ { MAD_F(0x044e64d7) /* 0.269139139 */, 18 },
+ /* 4330 */ { MAD_F(0x044ebbc4) /* 0.269222037 */, 18 },
+ /* 4331 */ { MAD_F(0x044f12b3) /* 0.269304942 */, 18 },
+ /* 4332 */ { MAD_F(0x044f69a3) /* 0.269387853 */, 18 },
+ /* 4333 */ { MAD_F(0x044fc095) /* 0.269470770 */, 18 },
+ /* 4334 */ { MAD_F(0x04501788) /* 0.269553694 */, 18 },
+ /* 4335 */ { MAD_F(0x04506e7e) /* 0.269636624 */, 18 },
+
+ /* 4336 */ { MAD_F(0x0450c575) /* 0.269719560 */, 18 },
+ /* 4337 */ { MAD_F(0x04511c6e) /* 0.269802503 */, 18 },
+ /* 4338 */ { MAD_F(0x04517368) /* 0.269885452 */, 18 },
+ /* 4339 */ { MAD_F(0x0451ca64) /* 0.269968408 */, 18 },
+ /* 4340 */ { MAD_F(0x04522162) /* 0.270051370 */, 18 },
+ /* 4341 */ { MAD_F(0x04527862) /* 0.270134338 */, 18 },
+ /* 4342 */ { MAD_F(0x0452cf63) /* 0.270217312 */, 18 },
+ /* 4343 */ { MAD_F(0x04532666) /* 0.270300293 */, 18 },
+ /* 4344 */ { MAD_F(0x04537d6b) /* 0.270383281 */, 18 },
+ /* 4345 */ { MAD_F(0x0453d472) /* 0.270466275 */, 18 },
+ /* 4346 */ { MAD_F(0x04542b7a) /* 0.270549275 */, 18 },
+ /* 4347 */ { MAD_F(0x04548284) /* 0.270632281 */, 18 },
+ /* 4348 */ { MAD_F(0x0454d98f) /* 0.270715294 */, 18 },
+ /* 4349 */ { MAD_F(0x0455309c) /* 0.270798313 */, 18 },
+ /* 4350 */ { MAD_F(0x045587ab) /* 0.270881339 */, 18 },
+ /* 4351 */ { MAD_F(0x0455debc) /* 0.270964371 */, 18 },
+
+ /* 4352 */ { MAD_F(0x045635cf) /* 0.271047409 */, 18 },
+ /* 4353 */ { MAD_F(0x04568ce3) /* 0.271130454 */, 18 },
+ /* 4354 */ { MAD_F(0x0456e3f9) /* 0.271213505 */, 18 },
+ /* 4355 */ { MAD_F(0x04573b10) /* 0.271296562 */, 18 },
+ /* 4356 */ { MAD_F(0x04579229) /* 0.271379626 */, 18 },
+ /* 4357 */ { MAD_F(0x0457e944) /* 0.271462696 */, 18 },
+ /* 4358 */ { MAD_F(0x04584061) /* 0.271545772 */, 18 },
+ /* 4359 */ { MAD_F(0x0458977f) /* 0.271628855 */, 18 },
+ /* 4360 */ { MAD_F(0x0458ee9f) /* 0.271711944 */, 18 },
+ /* 4361 */ { MAD_F(0x045945c1) /* 0.271795040 */, 18 },
+ /* 4362 */ { MAD_F(0x04599ce5) /* 0.271878142 */, 18 },
+ /* 4363 */ { MAD_F(0x0459f40a) /* 0.271961250 */, 18 },
+ /* 4364 */ { MAD_F(0x045a4b31) /* 0.272044365 */, 18 },
+ /* 4365 */ { MAD_F(0x045aa259) /* 0.272127486 */, 18 },
+ /* 4366 */ { MAD_F(0x045af984) /* 0.272210613 */, 18 },
+ /* 4367 */ { MAD_F(0x045b50b0) /* 0.272293746 */, 18 },
+
+ /* 4368 */ { MAD_F(0x045ba7dd) /* 0.272376886 */, 18 },
+ /* 4369 */ { MAD_F(0x045bff0d) /* 0.272460033 */, 18 },
+ /* 4370 */ { MAD_F(0x045c563e) /* 0.272543185 */, 18 },
+ /* 4371 */ { MAD_F(0x045cad71) /* 0.272626344 */, 18 },
+ /* 4372 */ { MAD_F(0x045d04a5) /* 0.272709510 */, 18 },
+ /* 4373 */ { MAD_F(0x045d5bdc) /* 0.272792681 */, 18 },
+ /* 4374 */ { MAD_F(0x045db313) /* 0.272875859 */, 18 },
+ /* 4375 */ { MAD_F(0x045e0a4d) /* 0.272959044 */, 18 },
+ /* 4376 */ { MAD_F(0x045e6188) /* 0.273042234 */, 18 },
+ /* 4377 */ { MAD_F(0x045eb8c5) /* 0.273125431 */, 18 },
+ /* 4378 */ { MAD_F(0x045f1004) /* 0.273208635 */, 18 },
+ /* 4379 */ { MAD_F(0x045f6745) /* 0.273291844 */, 18 },
+ /* 4380 */ { MAD_F(0x045fbe87) /* 0.273375060 */, 18 },
+ /* 4381 */ { MAD_F(0x046015cb) /* 0.273458283 */, 18 },
+ /* 4382 */ { MAD_F(0x04606d10) /* 0.273541511 */, 18 },
+ /* 4383 */ { MAD_F(0x0460c457) /* 0.273624747 */, 18 },
+
+ /* 4384 */ { MAD_F(0x04611ba0) /* 0.273707988 */, 18 },
+ /* 4385 */ { MAD_F(0x046172eb) /* 0.273791236 */, 18 },
+ /* 4386 */ { MAD_F(0x0461ca37) /* 0.273874490 */, 18 },
+ /* 4387 */ { MAD_F(0x04622185) /* 0.273957750 */, 18 },
+ /* 4388 */ { MAD_F(0x046278d5) /* 0.274041017 */, 18 },
+ /* 4389 */ { MAD_F(0x0462d026) /* 0.274124290 */, 18 },
+ /* 4390 */ { MAD_F(0x0463277a) /* 0.274207569 */, 18 },
+ /* 4391 */ { MAD_F(0x04637ece) /* 0.274290855 */, 18 },
+ /* 4392 */ { MAD_F(0x0463d625) /* 0.274374147 */, 18 },
+ /* 4393 */ { MAD_F(0x04642d7d) /* 0.274457445 */, 18 },
+ /* 4394 */ { MAD_F(0x046484d7) /* 0.274540749 */, 18 },
+ /* 4395 */ { MAD_F(0x0464dc33) /* 0.274624060 */, 18 },
+ /* 4396 */ { MAD_F(0x04653390) /* 0.274707378 */, 18 },
+ /* 4397 */ { MAD_F(0x04658aef) /* 0.274790701 */, 18 },
+ /* 4398 */ { MAD_F(0x0465e250) /* 0.274874031 */, 18 },
+ /* 4399 */ { MAD_F(0x046639b2) /* 0.274957367 */, 18 },
+
+ /* 4400 */ { MAD_F(0x04669116) /* 0.275040710 */, 18 },
+ /* 4401 */ { MAD_F(0x0466e87c) /* 0.275124059 */, 18 },
+ /* 4402 */ { MAD_F(0x04673fe3) /* 0.275207414 */, 18 },
+ /* 4403 */ { MAD_F(0x0467974d) /* 0.275290775 */, 18 },
+ /* 4404 */ { MAD_F(0x0467eeb7) /* 0.275374143 */, 18 },
+ /* 4405 */ { MAD_F(0x04684624) /* 0.275457517 */, 18 },
+ /* 4406 */ { MAD_F(0x04689d92) /* 0.275540897 */, 18 },
+ /* 4407 */ { MAD_F(0x0468f502) /* 0.275624284 */, 18 },
+ /* 4408 */ { MAD_F(0x04694c74) /* 0.275707677 */, 18 },
+ /* 4409 */ { MAD_F(0x0469a3e7) /* 0.275791076 */, 18 },
+ /* 4410 */ { MAD_F(0x0469fb5c) /* 0.275874482 */, 18 },
+ /* 4411 */ { MAD_F(0x046a52d3) /* 0.275957894 */, 18 },
+ /* 4412 */ { MAD_F(0x046aaa4b) /* 0.276041312 */, 18 },
+ /* 4413 */ { MAD_F(0x046b01c5) /* 0.276124737 */, 18 },
+ /* 4414 */ { MAD_F(0x046b5941) /* 0.276208167 */, 18 },
+ /* 4415 */ { MAD_F(0x046bb0bf) /* 0.276291605 */, 18 },
+
+ /* 4416 */ { MAD_F(0x046c083e) /* 0.276375048 */, 18 },
+ /* 4417 */ { MAD_F(0x046c5fbf) /* 0.276458498 */, 18 },
+ /* 4418 */ { MAD_F(0x046cb741) /* 0.276541954 */, 18 },
+ /* 4419 */ { MAD_F(0x046d0ec5) /* 0.276625416 */, 18 },
+ /* 4420 */ { MAD_F(0x046d664b) /* 0.276708885 */, 18 },
+ /* 4421 */ { MAD_F(0x046dbdd3) /* 0.276792360 */, 18 },
+ /* 4422 */ { MAD_F(0x046e155c) /* 0.276875841 */, 18 },
+ /* 4423 */ { MAD_F(0x046e6ce7) /* 0.276959328 */, 18 },
+ /* 4424 */ { MAD_F(0x046ec474) /* 0.277042822 */, 18 },
+ /* 4425 */ { MAD_F(0x046f1c02) /* 0.277126322 */, 18 },
+ /* 4426 */ { MAD_F(0x046f7392) /* 0.277209829 */, 18 },
+ /* 4427 */ { MAD_F(0x046fcb24) /* 0.277293341 */, 18 },
+ /* 4428 */ { MAD_F(0x047022b8) /* 0.277376860 */, 18 },
+ /* 4429 */ { MAD_F(0x04707a4d) /* 0.277460385 */, 18 },
+ /* 4430 */ { MAD_F(0x0470d1e4) /* 0.277543917 */, 18 },
+ /* 4431 */ { MAD_F(0x0471297c) /* 0.277627455 */, 18 },
+
+ /* 4432 */ { MAD_F(0x04718116) /* 0.277710999 */, 18 },
+ /* 4433 */ { MAD_F(0x0471d8b2) /* 0.277794549 */, 18 },
+ /* 4434 */ { MAD_F(0x04723050) /* 0.277878106 */, 18 },
+ /* 4435 */ { MAD_F(0x047287ef) /* 0.277961669 */, 18 },
+ /* 4436 */ { MAD_F(0x0472df90) /* 0.278045238 */, 18 },
+ /* 4437 */ { MAD_F(0x04733733) /* 0.278128813 */, 18 },
+ /* 4438 */ { MAD_F(0x04738ed7) /* 0.278212395 */, 18 },
+ /* 4439 */ { MAD_F(0x0473e67d) /* 0.278295983 */, 18 },
+ /* 4440 */ { MAD_F(0x04743e25) /* 0.278379578 */, 18 },
+ /* 4441 */ { MAD_F(0x047495ce) /* 0.278463178 */, 18 },
+ /* 4442 */ { MAD_F(0x0474ed79) /* 0.278546785 */, 18 },
+ /* 4443 */ { MAD_F(0x04754526) /* 0.278630398 */, 18 },
+ /* 4444 */ { MAD_F(0x04759cd4) /* 0.278714018 */, 18 },
+ /* 4445 */ { MAD_F(0x0475f484) /* 0.278797643 */, 18 },
+ /* 4446 */ { MAD_F(0x04764c36) /* 0.278881275 */, 18 },
+ /* 4447 */ { MAD_F(0x0476a3ea) /* 0.278964914 */, 18 },
+
+ /* 4448 */ { MAD_F(0x0476fb9f) /* 0.279048558 */, 18 },
+ /* 4449 */ { MAD_F(0x04775356) /* 0.279132209 */, 18 },
+ /* 4450 */ { MAD_F(0x0477ab0e) /* 0.279215866 */, 18 },
+ /* 4451 */ { MAD_F(0x047802c8) /* 0.279299529 */, 18 },
+ /* 4452 */ { MAD_F(0x04785a84) /* 0.279383199 */, 18 },
+ /* 4453 */ { MAD_F(0x0478b242) /* 0.279466875 */, 18 },
+ /* 4454 */ { MAD_F(0x04790a01) /* 0.279550557 */, 18 },
+ /* 4455 */ { MAD_F(0x047961c2) /* 0.279634245 */, 18 },
+ /* 4456 */ { MAD_F(0x0479b984) /* 0.279717940 */, 18 },
+ /* 4457 */ { MAD_F(0x047a1149) /* 0.279801641 */, 18 },
+ /* 4458 */ { MAD_F(0x047a690f) /* 0.279885348 */, 18 },
+ /* 4459 */ { MAD_F(0x047ac0d6) /* 0.279969061 */, 18 },
+ /* 4460 */ { MAD_F(0x047b18a0) /* 0.280052781 */, 18 },
+ /* 4461 */ { MAD_F(0x047b706b) /* 0.280136507 */, 18 },
+ /* 4462 */ { MAD_F(0x047bc837) /* 0.280220239 */, 18 },
+ /* 4463 */ { MAD_F(0x047c2006) /* 0.280303978 */, 18 },
+
+ /* 4464 */ { MAD_F(0x047c77d6) /* 0.280387722 */, 18 },
+ /* 4465 */ { MAD_F(0x047ccfa8) /* 0.280471473 */, 18 },
+ /* 4466 */ { MAD_F(0x047d277b) /* 0.280555230 */, 18 },
+ /* 4467 */ { MAD_F(0x047d7f50) /* 0.280638994 */, 18 },
+ /* 4468 */ { MAD_F(0x047dd727) /* 0.280722764 */, 18 },
+ /* 4469 */ { MAD_F(0x047e2eff) /* 0.280806540 */, 18 },
+ /* 4470 */ { MAD_F(0x047e86d9) /* 0.280890322 */, 18 },
+ /* 4471 */ { MAD_F(0x047edeb5) /* 0.280974110 */, 18 },
+ /* 4472 */ { MAD_F(0x047f3693) /* 0.281057905 */, 18 },
+ /* 4473 */ { MAD_F(0x047f8e72) /* 0.281141706 */, 18 },
+ /* 4474 */ { MAD_F(0x047fe653) /* 0.281225513 */, 18 },
+ /* 4475 */ { MAD_F(0x04803e35) /* 0.281309326 */, 18 },
+ /* 4476 */ { MAD_F(0x04809619) /* 0.281393146 */, 18 },
+ /* 4477 */ { MAD_F(0x0480edff) /* 0.281476972 */, 18 },
+ /* 4478 */ { MAD_F(0x048145e7) /* 0.281560804 */, 18 },
+ /* 4479 */ { MAD_F(0x04819dd0) /* 0.281644643 */, 18 },
+
+ /* 4480 */ { MAD_F(0x0481f5bb) /* 0.281728487 */, 18 },
+ /* 4481 */ { MAD_F(0x04824da7) /* 0.281812338 */, 18 },
+ /* 4482 */ { MAD_F(0x0482a595) /* 0.281896195 */, 18 },
+ /* 4483 */ { MAD_F(0x0482fd85) /* 0.281980059 */, 18 },
+ /* 4484 */ { MAD_F(0x04835577) /* 0.282063928 */, 18 },
+ /* 4485 */ { MAD_F(0x0483ad6a) /* 0.282147804 */, 18 },
+ /* 4486 */ { MAD_F(0x0484055f) /* 0.282231686 */, 18 },
+ /* 4487 */ { MAD_F(0x04845d56) /* 0.282315574 */, 18 },
+ /* 4488 */ { MAD_F(0x0484b54e) /* 0.282399469 */, 18 },
+ /* 4489 */ { MAD_F(0x04850d48) /* 0.282483370 */, 18 },
+ /* 4490 */ { MAD_F(0x04856544) /* 0.282567277 */, 18 },
+ /* 4491 */ { MAD_F(0x0485bd41) /* 0.282651190 */, 18 },
+ /* 4492 */ { MAD_F(0x04861540) /* 0.282735109 */, 18 },
+ /* 4493 */ { MAD_F(0x04866d40) /* 0.282819035 */, 18 },
+ /* 4494 */ { MAD_F(0x0486c543) /* 0.282902967 */, 18 },
+ /* 4495 */ { MAD_F(0x04871d47) /* 0.282986905 */, 18 },
+
+ /* 4496 */ { MAD_F(0x0487754c) /* 0.283070849 */, 18 },
+ /* 4497 */ { MAD_F(0x0487cd54) /* 0.283154800 */, 18 },
+ /* 4498 */ { MAD_F(0x0488255d) /* 0.283238757 */, 18 },
+ /* 4499 */ { MAD_F(0x04887d67) /* 0.283322720 */, 18 },
+ /* 4500 */ { MAD_F(0x0488d574) /* 0.283406689 */, 18 },
+ /* 4501 */ { MAD_F(0x04892d82) /* 0.283490665 */, 18 },
+ /* 4502 */ { MAD_F(0x04898591) /* 0.283574646 */, 18 },
+ /* 4503 */ { MAD_F(0x0489dda3) /* 0.283658634 */, 18 },
+ /* 4504 */ { MAD_F(0x048a35b6) /* 0.283742628 */, 18 },
+ /* 4505 */ { MAD_F(0x048a8dca) /* 0.283826629 */, 18 },
+ /* 4506 */ { MAD_F(0x048ae5e1) /* 0.283910635 */, 18 },
+ /* 4507 */ { MAD_F(0x048b3df9) /* 0.283994648 */, 18 },
+ /* 4508 */ { MAD_F(0x048b9612) /* 0.284078667 */, 18 },
+ /* 4509 */ { MAD_F(0x048bee2e) /* 0.284162692 */, 18 },
+ /* 4510 */ { MAD_F(0x048c464b) /* 0.284246723 */, 18 },
+ /* 4511 */ { MAD_F(0x048c9e69) /* 0.284330761 */, 18 },
+
+ /* 4512 */ { MAD_F(0x048cf68a) /* 0.284414805 */, 18 },
+ /* 4513 */ { MAD_F(0x048d4eac) /* 0.284498855 */, 18 },
+ /* 4514 */ { MAD_F(0x048da6cf) /* 0.284582911 */, 18 },
+ /* 4515 */ { MAD_F(0x048dfef5) /* 0.284666974 */, 18 },
+ /* 4516 */ { MAD_F(0x048e571c) /* 0.284751042 */, 18 },
+ /* 4517 */ { MAD_F(0x048eaf44) /* 0.284835117 */, 18 },
+ /* 4518 */ { MAD_F(0x048f076f) /* 0.284919198 */, 18 },
+ /* 4519 */ { MAD_F(0x048f5f9b) /* 0.285003285 */, 18 },
+ /* 4520 */ { MAD_F(0x048fb7c8) /* 0.285087379 */, 18 },
+ /* 4521 */ { MAD_F(0x04900ff8) /* 0.285171479 */, 18 },
+ /* 4522 */ { MAD_F(0x04906829) /* 0.285255584 */, 18 },
+ /* 4523 */ { MAD_F(0x0490c05b) /* 0.285339697 */, 18 },
+ /* 4524 */ { MAD_F(0x04911890) /* 0.285423815 */, 18 },
+ /* 4525 */ { MAD_F(0x049170c6) /* 0.285507939 */, 18 },
+ /* 4526 */ { MAD_F(0x0491c8fd) /* 0.285592070 */, 18 },
+ /* 4527 */ { MAD_F(0x04922137) /* 0.285676207 */, 18 },
+
+ /* 4528 */ { MAD_F(0x04927972) /* 0.285760350 */, 18 },
+ /* 4529 */ { MAD_F(0x0492d1ae) /* 0.285844499 */, 18 },
+ /* 4530 */ { MAD_F(0x049329ed) /* 0.285928655 */, 18 },
+ /* 4531 */ { MAD_F(0x0493822c) /* 0.286012816 */, 18 },
+ /* 4532 */ { MAD_F(0x0493da6e) /* 0.286096984 */, 18 },
+ /* 4533 */ { MAD_F(0x049432b1) /* 0.286181158 */, 18 },
+ /* 4534 */ { MAD_F(0x04948af6) /* 0.286265338 */, 18 },
+ /* 4535 */ { MAD_F(0x0494e33d) /* 0.286349525 */, 18 },
+ /* 4536 */ { MAD_F(0x04953b85) /* 0.286433717 */, 18 },
+ /* 4537 */ { MAD_F(0x049593cf) /* 0.286517916 */, 18 },
+ /* 4538 */ { MAD_F(0x0495ec1b) /* 0.286602121 */, 18 },
+ /* 4539 */ { MAD_F(0x04964468) /* 0.286686332 */, 18 },
+ /* 4540 */ { MAD_F(0x04969cb7) /* 0.286770550 */, 18 },
+ /* 4541 */ { MAD_F(0x0496f508) /* 0.286854773 */, 18 },
+ /* 4542 */ { MAD_F(0x04974d5a) /* 0.286939003 */, 18 },
+ /* 4543 */ { MAD_F(0x0497a5ae) /* 0.287023239 */, 18 },
+
+ /* 4544 */ { MAD_F(0x0497fe03) /* 0.287107481 */, 18 },
+ /* 4545 */ { MAD_F(0x0498565a) /* 0.287191729 */, 18 },
+ /* 4546 */ { MAD_F(0x0498aeb3) /* 0.287275983 */, 18 },
+ /* 4547 */ { MAD_F(0x0499070e) /* 0.287360244 */, 18 },
+ /* 4548 */ { MAD_F(0x04995f6a) /* 0.287444511 */, 18 },
+ /* 4549 */ { MAD_F(0x0499b7c8) /* 0.287528784 */, 18 },
+ /* 4550 */ { MAD_F(0x049a1027) /* 0.287613063 */, 18 },
+ /* 4551 */ { MAD_F(0x049a6889) /* 0.287697348 */, 18 },
+ /* 4552 */ { MAD_F(0x049ac0eb) /* 0.287781640 */, 18 },
+ /* 4553 */ { MAD_F(0x049b1950) /* 0.287865937 */, 18 },
+ /* 4554 */ { MAD_F(0x049b71b6) /* 0.287950241 */, 18 },
+ /* 4555 */ { MAD_F(0x049bca1e) /* 0.288034551 */, 18 },
+ /* 4556 */ { MAD_F(0x049c2287) /* 0.288118867 */, 18 },
+ /* 4557 */ { MAD_F(0x049c7af2) /* 0.288203190 */, 18 },
+ /* 4558 */ { MAD_F(0x049cd35f) /* 0.288287518 */, 18 },
+ /* 4559 */ { MAD_F(0x049d2bce) /* 0.288371853 */, 18 },
+
+ /* 4560 */ { MAD_F(0x049d843e) /* 0.288456194 */, 18 },
+ /* 4561 */ { MAD_F(0x049ddcaf) /* 0.288540541 */, 18 },
+ /* 4562 */ { MAD_F(0x049e3523) /* 0.288624894 */, 18 },
+ /* 4563 */ { MAD_F(0x049e8d98) /* 0.288709253 */, 18 },
+ /* 4564 */ { MAD_F(0x049ee60e) /* 0.288793619 */, 18 },
+ /* 4565 */ { MAD_F(0x049f3e87) /* 0.288877990 */, 18 },
+ /* 4566 */ { MAD_F(0x049f9701) /* 0.288962368 */, 18 },
+ /* 4567 */ { MAD_F(0x049fef7c) /* 0.289046752 */, 18 },
+ /* 4568 */ { MAD_F(0x04a047fa) /* 0.289131142 */, 18 },
+ /* 4569 */ { MAD_F(0x04a0a079) /* 0.289215538 */, 18 },
+ /* 4570 */ { MAD_F(0x04a0f8f9) /* 0.289299941 */, 18 },
+ /* 4571 */ { MAD_F(0x04a1517c) /* 0.289384349 */, 18 },
+ /* 4572 */ { MAD_F(0x04a1a9ff) /* 0.289468764 */, 18 },
+ /* 4573 */ { MAD_F(0x04a20285) /* 0.289553185 */, 18 },
+ /* 4574 */ { MAD_F(0x04a25b0c) /* 0.289637612 */, 18 },
+ /* 4575 */ { MAD_F(0x04a2b395) /* 0.289722045 */, 18 },
+
+ /* 4576 */ { MAD_F(0x04a30c20) /* 0.289806485 */, 18 },
+ /* 4577 */ { MAD_F(0x04a364ac) /* 0.289890930 */, 18 },
+ /* 4578 */ { MAD_F(0x04a3bd3a) /* 0.289975382 */, 18 },
+ /* 4579 */ { MAD_F(0x04a415c9) /* 0.290059840 */, 18 },
+ /* 4580 */ { MAD_F(0x04a46e5a) /* 0.290144304 */, 18 },
+ /* 4581 */ { MAD_F(0x04a4c6ed) /* 0.290228774 */, 18 },
+ /* 4582 */ { MAD_F(0x04a51f81) /* 0.290313250 */, 18 },
+ /* 4583 */ { MAD_F(0x04a57818) /* 0.290397733 */, 18 },
+ /* 4584 */ { MAD_F(0x04a5d0af) /* 0.290482221 */, 18 },
+ /* 4585 */ { MAD_F(0x04a62949) /* 0.290566716 */, 18 },
+ /* 4586 */ { MAD_F(0x04a681e4) /* 0.290651217 */, 18 },
+ /* 4587 */ { MAD_F(0x04a6da80) /* 0.290735724 */, 18 },
+ /* 4588 */ { MAD_F(0x04a7331f) /* 0.290820237 */, 18 },
+ /* 4589 */ { MAD_F(0x04a78bbf) /* 0.290904756 */, 18 },
+ /* 4590 */ { MAD_F(0x04a7e460) /* 0.290989281 */, 18 },
+ /* 4591 */ { MAD_F(0x04a83d03) /* 0.291073813 */, 18 },
+
+ /* 4592 */ { MAD_F(0x04a895a8) /* 0.291158351 */, 18 },
+ /* 4593 */ { MAD_F(0x04a8ee4f) /* 0.291242894 */, 18 },
+ /* 4594 */ { MAD_F(0x04a946f7) /* 0.291327444 */, 18 },
+ /* 4595 */ { MAD_F(0x04a99fa1) /* 0.291412001 */, 18 },
+ /* 4596 */ { MAD_F(0x04a9f84c) /* 0.291496563 */, 18 },
+ /* 4597 */ { MAD_F(0x04aa50fa) /* 0.291581131 */, 18 },
+ /* 4598 */ { MAD_F(0x04aaa9a8) /* 0.291665706 */, 18 },
+ /* 4599 */ { MAD_F(0x04ab0259) /* 0.291750286 */, 18 },
+ /* 4600 */ { MAD_F(0x04ab5b0b) /* 0.291834873 */, 18 },
+ /* 4601 */ { MAD_F(0x04abb3bf) /* 0.291919466 */, 18 },
+ /* 4602 */ { MAD_F(0x04ac0c74) /* 0.292004065 */, 18 },
+ /* 4603 */ { MAD_F(0x04ac652b) /* 0.292088670 */, 18 },
+ /* 4604 */ { MAD_F(0x04acbde4) /* 0.292173281 */, 18 },
+ /* 4605 */ { MAD_F(0x04ad169e) /* 0.292257899 */, 18 },
+ /* 4606 */ { MAD_F(0x04ad6f5a) /* 0.292342522 */, 18 },
+ /* 4607 */ { MAD_F(0x04adc818) /* 0.292427152 */, 18 },
+
+ /* 4608 */ { MAD_F(0x04ae20d7) /* 0.292511788 */, 18 },
+ /* 4609 */ { MAD_F(0x04ae7998) /* 0.292596430 */, 18 },
+ /* 4610 */ { MAD_F(0x04aed25a) /* 0.292681078 */, 18 },
+ /* 4611 */ { MAD_F(0x04af2b1e) /* 0.292765732 */, 18 },
+ /* 4612 */ { MAD_F(0x04af83e4) /* 0.292850392 */, 18 },
+ /* 4613 */ { MAD_F(0x04afdcac) /* 0.292935058 */, 18 },
+ /* 4614 */ { MAD_F(0x04b03575) /* 0.293019731 */, 18 },
+ /* 4615 */ { MAD_F(0x04b08e40) /* 0.293104409 */, 18 },
+ /* 4616 */ { MAD_F(0x04b0e70c) /* 0.293189094 */, 18 },
+ /* 4617 */ { MAD_F(0x04b13fda) /* 0.293273785 */, 18 },
+ /* 4618 */ { MAD_F(0x04b198aa) /* 0.293358482 */, 18 },
+ /* 4619 */ { MAD_F(0x04b1f17b) /* 0.293443185 */, 18 },
+ /* 4620 */ { MAD_F(0x04b24a4e) /* 0.293527894 */, 18 },
+ /* 4621 */ { MAD_F(0x04b2a322) /* 0.293612609 */, 18 },
+ /* 4622 */ { MAD_F(0x04b2fbf9) /* 0.293697331 */, 18 },
+ /* 4623 */ { MAD_F(0x04b354d1) /* 0.293782058 */, 18 },
+
+ /* 4624 */ { MAD_F(0x04b3adaa) /* 0.293866792 */, 18 },
+ /* 4625 */ { MAD_F(0x04b40685) /* 0.293951532 */, 18 },
+ /* 4626 */ { MAD_F(0x04b45f62) /* 0.294036278 */, 18 },
+ /* 4627 */ { MAD_F(0x04b4b840) /* 0.294121029 */, 18 },
+ /* 4628 */ { MAD_F(0x04b51120) /* 0.294205788 */, 18 },
+ /* 4629 */ { MAD_F(0x04b56a02) /* 0.294290552 */, 18 },
+ /* 4630 */ { MAD_F(0x04b5c2e6) /* 0.294375322 */, 18 },
+ /* 4631 */ { MAD_F(0x04b61bcb) /* 0.294460098 */, 18 },
+ /* 4632 */ { MAD_F(0x04b674b1) /* 0.294544881 */, 18 },
+ /* 4633 */ { MAD_F(0x04b6cd99) /* 0.294629669 */, 18 },
+ /* 4634 */ { MAD_F(0x04b72683) /* 0.294714464 */, 18 },
+ /* 4635 */ { MAD_F(0x04b77f6f) /* 0.294799265 */, 18 },
+ /* 4636 */ { MAD_F(0x04b7d85c) /* 0.294884072 */, 18 },
+ /* 4637 */ { MAD_F(0x04b8314b) /* 0.294968885 */, 18 },
+ /* 4638 */ { MAD_F(0x04b88a3b) /* 0.295053704 */, 18 },
+ /* 4639 */ { MAD_F(0x04b8e32d) /* 0.295138529 */, 18 },
+
+ /* 4640 */ { MAD_F(0x04b93c21) /* 0.295223360 */, 18 },
+ /* 4641 */ { MAD_F(0x04b99516) /* 0.295308197 */, 18 },
+ /* 4642 */ { MAD_F(0x04b9ee0d) /* 0.295393041 */, 18 },
+ /* 4643 */ { MAD_F(0x04ba4706) /* 0.295477890 */, 18 },
+ /* 4644 */ { MAD_F(0x04baa000) /* 0.295562746 */, 18 },
+ /* 4645 */ { MAD_F(0x04baf8fc) /* 0.295647608 */, 18 },
+ /* 4646 */ { MAD_F(0x04bb51fa) /* 0.295732476 */, 18 },
+ /* 4647 */ { MAD_F(0x04bbaaf9) /* 0.295817349 */, 18 },
+ /* 4648 */ { MAD_F(0x04bc03fa) /* 0.295902229 */, 18 },
+ /* 4649 */ { MAD_F(0x04bc5cfc) /* 0.295987115 */, 18 },
+ /* 4650 */ { MAD_F(0x04bcb600) /* 0.296072008 */, 18 },
+ /* 4651 */ { MAD_F(0x04bd0f06) /* 0.296156906 */, 18 },
+ /* 4652 */ { MAD_F(0x04bd680d) /* 0.296241810 */, 18 },
+ /* 4653 */ { MAD_F(0x04bdc116) /* 0.296326721 */, 18 },
+ /* 4654 */ { MAD_F(0x04be1a21) /* 0.296411637 */, 18 },
+ /* 4655 */ { MAD_F(0x04be732d) /* 0.296496560 */, 18 },
+
+ /* 4656 */ { MAD_F(0x04becc3b) /* 0.296581488 */, 18 },
+ /* 4657 */ { MAD_F(0x04bf254a) /* 0.296666423 */, 18 },
+ /* 4658 */ { MAD_F(0x04bf7e5b) /* 0.296751364 */, 18 },
+ /* 4659 */ { MAD_F(0x04bfd76e) /* 0.296836311 */, 18 },
+ /* 4660 */ { MAD_F(0x04c03083) /* 0.296921264 */, 18 },
+ /* 4661 */ { MAD_F(0x04c08999) /* 0.297006223 */, 18 },
+ /* 4662 */ { MAD_F(0x04c0e2b0) /* 0.297091188 */, 18 },
+ /* 4663 */ { MAD_F(0x04c13bca) /* 0.297176159 */, 18 },
+ /* 4664 */ { MAD_F(0x04c194e4) /* 0.297261136 */, 18 },
+ /* 4665 */ { MAD_F(0x04c1ee01) /* 0.297346120 */, 18 },
+ /* 4666 */ { MAD_F(0x04c2471f) /* 0.297431109 */, 18 },
+ /* 4667 */ { MAD_F(0x04c2a03f) /* 0.297516105 */, 18 },
+ /* 4668 */ { MAD_F(0x04c2f960) /* 0.297601106 */, 18 },
+ /* 4669 */ { MAD_F(0x04c35283) /* 0.297686114 */, 18 },
+ /* 4670 */ { MAD_F(0x04c3aba8) /* 0.297771128 */, 18 },
+ /* 4671 */ { MAD_F(0x04c404ce) /* 0.297856147 */, 18 },
+
+ /* 4672 */ { MAD_F(0x04c45df6) /* 0.297941173 */, 18 },
+ /* 4673 */ { MAD_F(0x04c4b720) /* 0.298026205 */, 18 },
+ /* 4674 */ { MAD_F(0x04c5104b) /* 0.298111243 */, 18 },
+ /* 4675 */ { MAD_F(0x04c56978) /* 0.298196287 */, 18 },
+ /* 4676 */ { MAD_F(0x04c5c2a7) /* 0.298281337 */, 18 },
+ /* 4677 */ { MAD_F(0x04c61bd7) /* 0.298366393 */, 18 },
+ /* 4678 */ { MAD_F(0x04c67508) /* 0.298451456 */, 18 },
+ /* 4679 */ { MAD_F(0x04c6ce3c) /* 0.298536524 */, 18 },
+ /* 4680 */ { MAD_F(0x04c72771) /* 0.298621598 */, 18 },
+ /* 4681 */ { MAD_F(0x04c780a7) /* 0.298706679 */, 18 },
+ /* 4682 */ { MAD_F(0x04c7d9df) /* 0.298791765 */, 18 },
+ /* 4683 */ { MAD_F(0x04c83319) /* 0.298876858 */, 18 },
+ /* 4684 */ { MAD_F(0x04c88c55) /* 0.298961956 */, 18 },
+ /* 4685 */ { MAD_F(0x04c8e592) /* 0.299047061 */, 18 },
+ /* 4686 */ { MAD_F(0x04c93ed1) /* 0.299132172 */, 18 },
+ /* 4687 */ { MAD_F(0x04c99811) /* 0.299217288 */, 18 },
+
+ /* 4688 */ { MAD_F(0x04c9f153) /* 0.299302411 */, 18 },
+ /* 4689 */ { MAD_F(0x04ca4a97) /* 0.299387540 */, 18 },
+ /* 4690 */ { MAD_F(0x04caa3dc) /* 0.299472675 */, 18 },
+ /* 4691 */ { MAD_F(0x04cafd23) /* 0.299557816 */, 18 },
+ /* 4692 */ { MAD_F(0x04cb566b) /* 0.299642963 */, 18 },
+ /* 4693 */ { MAD_F(0x04cbafb5) /* 0.299728116 */, 18 },
+ /* 4694 */ { MAD_F(0x04cc0901) /* 0.299813275 */, 18 },
+ /* 4695 */ { MAD_F(0x04cc624e) /* 0.299898440 */, 18 },
+ /* 4696 */ { MAD_F(0x04ccbb9d) /* 0.299983611 */, 18 },
+ /* 4697 */ { MAD_F(0x04cd14ee) /* 0.300068789 */, 18 },
+ /* 4698 */ { MAD_F(0x04cd6e40) /* 0.300153972 */, 18 },
+ /* 4699 */ { MAD_F(0x04cdc794) /* 0.300239161 */, 18 },
+ /* 4700 */ { MAD_F(0x04ce20e9) /* 0.300324357 */, 18 },
+ /* 4701 */ { MAD_F(0x04ce7a40) /* 0.300409558 */, 18 },
+ /* 4702 */ { MAD_F(0x04ced399) /* 0.300494765 */, 18 },
+ /* 4703 */ { MAD_F(0x04cf2cf3) /* 0.300579979 */, 18 },
+
+ /* 4704 */ { MAD_F(0x04cf864f) /* 0.300665198 */, 18 },
+ /* 4705 */ { MAD_F(0x04cfdfad) /* 0.300750424 */, 18 },
+ /* 4706 */ { MAD_F(0x04d0390c) /* 0.300835656 */, 18 },
+ /* 4707 */ { MAD_F(0x04d0926d) /* 0.300920893 */, 18 },
+ /* 4708 */ { MAD_F(0x04d0ebcf) /* 0.301006137 */, 18 },
+ /* 4709 */ { MAD_F(0x04d14533) /* 0.301091387 */, 18 },
+ /* 4710 */ { MAD_F(0x04d19e99) /* 0.301176643 */, 18 },
+ /* 4711 */ { MAD_F(0x04d1f800) /* 0.301261904 */, 18 },
+ /* 4712 */ { MAD_F(0x04d25169) /* 0.301347172 */, 18 },
+ /* 4713 */ { MAD_F(0x04d2aad4) /* 0.301432446 */, 18 },
+ /* 4714 */ { MAD_F(0x04d30440) /* 0.301517726 */, 18 },
+ /* 4715 */ { MAD_F(0x04d35dae) /* 0.301603012 */, 18 },
+ /* 4716 */ { MAD_F(0x04d3b71d) /* 0.301688304 */, 18 },
+ /* 4717 */ { MAD_F(0x04d4108e) /* 0.301773602 */, 18 },
+ /* 4718 */ { MAD_F(0x04d46a01) /* 0.301858906 */, 18 },
+ /* 4719 */ { MAD_F(0x04d4c375) /* 0.301944216 */, 18 },
+
+ /* 4720 */ { MAD_F(0x04d51ceb) /* 0.302029532 */, 18 },
+ /* 4721 */ { MAD_F(0x04d57662) /* 0.302114854 */, 18 },
+ /* 4722 */ { MAD_F(0x04d5cfdb) /* 0.302200182 */, 18 },
+ /* 4723 */ { MAD_F(0x04d62956) /* 0.302285516 */, 18 },
+ /* 4724 */ { MAD_F(0x04d682d2) /* 0.302370856 */, 18 },
+ /* 4725 */ { MAD_F(0x04d6dc50) /* 0.302456203 */, 18 },
+ /* 4726 */ { MAD_F(0x04d735d0) /* 0.302541555 */, 18 },
+ /* 4727 */ { MAD_F(0x04d78f51) /* 0.302626913 */, 18 },
+ /* 4728 */ { MAD_F(0x04d7e8d4) /* 0.302712277 */, 18 },
+ /* 4729 */ { MAD_F(0x04d84258) /* 0.302797648 */, 18 },
+ /* 4730 */ { MAD_F(0x04d89bde) /* 0.302883024 */, 18 },
+ /* 4731 */ { MAD_F(0x04d8f566) /* 0.302968406 */, 18 },
+ /* 4732 */ { MAD_F(0x04d94eef) /* 0.303053794 */, 18 },
+ /* 4733 */ { MAD_F(0x04d9a87a) /* 0.303139189 */, 18 },
+ /* 4734 */ { MAD_F(0x04da0207) /* 0.303224589 */, 18 },
+ /* 4735 */ { MAD_F(0x04da5b95) /* 0.303309995 */, 18 },
+
+ /* 4736 */ { MAD_F(0x04dab524) /* 0.303395408 */, 18 },
+ /* 4737 */ { MAD_F(0x04db0eb6) /* 0.303480826 */, 18 },
+ /* 4738 */ { MAD_F(0x04db6849) /* 0.303566251 */, 18 },
+ /* 4739 */ { MAD_F(0x04dbc1dd) /* 0.303651681 */, 18 },
+ /* 4740 */ { MAD_F(0x04dc1b73) /* 0.303737117 */, 18 },
+ /* 4741 */ { MAD_F(0x04dc750b) /* 0.303822560 */, 18 },
+ /* 4742 */ { MAD_F(0x04dccea5) /* 0.303908008 */, 18 },
+ /* 4743 */ { MAD_F(0x04dd2840) /* 0.303993463 */, 18 },
+ /* 4744 */ { MAD_F(0x04dd81dc) /* 0.304078923 */, 18 },
+ /* 4745 */ { MAD_F(0x04dddb7a) /* 0.304164390 */, 18 },
+ /* 4746 */ { MAD_F(0x04de351a) /* 0.304249862 */, 18 },
+ /* 4747 */ { MAD_F(0x04de8ebc) /* 0.304335340 */, 18 },
+ /* 4748 */ { MAD_F(0x04dee85f) /* 0.304420825 */, 18 },
+ /* 4749 */ { MAD_F(0x04df4203) /* 0.304506315 */, 18 },
+ /* 4750 */ { MAD_F(0x04df9baa) /* 0.304591812 */, 18 },
+ /* 4751 */ { MAD_F(0x04dff552) /* 0.304677314 */, 18 },
+
+ /* 4752 */ { MAD_F(0x04e04efb) /* 0.304762823 */, 18 },
+ /* 4753 */ { MAD_F(0x04e0a8a6) /* 0.304848337 */, 18 },
+ /* 4754 */ { MAD_F(0x04e10253) /* 0.304933858 */, 18 },
+ /* 4755 */ { MAD_F(0x04e15c01) /* 0.305019384 */, 18 },
+ /* 4756 */ { MAD_F(0x04e1b5b1) /* 0.305104917 */, 18 },
+ /* 4757 */ { MAD_F(0x04e20f63) /* 0.305190455 */, 18 },
+ /* 4758 */ { MAD_F(0x04e26916) /* 0.305275999 */, 18 },
+ /* 4759 */ { MAD_F(0x04e2c2cb) /* 0.305361550 */, 18 },
+ /* 4760 */ { MAD_F(0x04e31c81) /* 0.305447106 */, 18 },
+ /* 4761 */ { MAD_F(0x04e37639) /* 0.305532669 */, 18 },
+ /* 4762 */ { MAD_F(0x04e3cff3) /* 0.305618237 */, 18 },
+ /* 4763 */ { MAD_F(0x04e429ae) /* 0.305703811 */, 18 },
+ /* 4764 */ { MAD_F(0x04e4836b) /* 0.305789392 */, 18 },
+ /* 4765 */ { MAD_F(0x04e4dd29) /* 0.305874978 */, 18 },
+ /* 4766 */ { MAD_F(0x04e536e9) /* 0.305960571 */, 18 },
+ /* 4767 */ { MAD_F(0x04e590ab) /* 0.306046169 */, 18 },
+
+ /* 4768 */ { MAD_F(0x04e5ea6e) /* 0.306131773 */, 18 },
+ /* 4769 */ { MAD_F(0x04e64433) /* 0.306217383 */, 18 },
+ /* 4770 */ { MAD_F(0x04e69df9) /* 0.306303000 */, 18 },
+ /* 4771 */ { MAD_F(0x04e6f7c1) /* 0.306388622 */, 18 },
+ /* 4772 */ { MAD_F(0x04e7518b) /* 0.306474250 */, 18 },
+ /* 4773 */ { MAD_F(0x04e7ab56) /* 0.306559885 */, 18 },
+ /* 4774 */ { MAD_F(0x04e80523) /* 0.306645525 */, 18 },
+ /* 4775 */ { MAD_F(0x04e85ef2) /* 0.306731171 */, 18 },
+ /* 4776 */ { MAD_F(0x04e8b8c2) /* 0.306816823 */, 18 },
+ /* 4777 */ { MAD_F(0x04e91293) /* 0.306902481 */, 18 },
+ /* 4778 */ { MAD_F(0x04e96c67) /* 0.306988145 */, 18 },
+ /* 4779 */ { MAD_F(0x04e9c63b) /* 0.307073816 */, 18 },
+ /* 4780 */ { MAD_F(0x04ea2012) /* 0.307159492 */, 18 },
+ /* 4781 */ { MAD_F(0x04ea79ea) /* 0.307245174 */, 18 },
+ /* 4782 */ { MAD_F(0x04ead3c4) /* 0.307330862 */, 18 },
+ /* 4783 */ { MAD_F(0x04eb2d9f) /* 0.307416556 */, 18 },
+
+ /* 4784 */ { MAD_F(0x04eb877c) /* 0.307502256 */, 18 },
+ /* 4785 */ { MAD_F(0x04ebe15b) /* 0.307587962 */, 18 },
+ /* 4786 */ { MAD_F(0x04ec3b3b) /* 0.307673674 */, 18 },
+ /* 4787 */ { MAD_F(0x04ec951c) /* 0.307759392 */, 18 },
+ /* 4788 */ { MAD_F(0x04ecef00) /* 0.307845115 */, 18 },
+ /* 4789 */ { MAD_F(0x04ed48e5) /* 0.307930845 */, 18 },
+ /* 4790 */ { MAD_F(0x04eda2cb) /* 0.308016581 */, 18 },
+ /* 4791 */ { MAD_F(0x04edfcb3) /* 0.308102323 */, 18 },
+ /* 4792 */ { MAD_F(0x04ee569d) /* 0.308188071 */, 18 },
+ /* 4793 */ { MAD_F(0x04eeb088) /* 0.308273824 */, 18 },
+ /* 4794 */ { MAD_F(0x04ef0a75) /* 0.308359584 */, 18 },
+ /* 4795 */ { MAD_F(0x04ef6464) /* 0.308445350 */, 18 },
+ /* 4796 */ { MAD_F(0x04efbe54) /* 0.308531121 */, 18 },
+ /* 4797 */ { MAD_F(0x04f01846) /* 0.308616899 */, 18 },
+ /* 4798 */ { MAD_F(0x04f07239) /* 0.308702682 */, 18 },
+ /* 4799 */ { MAD_F(0x04f0cc2e) /* 0.308788472 */, 18 },
+
+ /* 4800 */ { MAD_F(0x04f12624) /* 0.308874267 */, 18 },
+ /* 4801 */ { MAD_F(0x04f1801d) /* 0.308960068 */, 18 },
+ /* 4802 */ { MAD_F(0x04f1da16) /* 0.309045876 */, 18 },
+ /* 4803 */ { MAD_F(0x04f23412) /* 0.309131689 */, 18 },
+ /* 4804 */ { MAD_F(0x04f28e0f) /* 0.309217508 */, 18 },
+ /* 4805 */ { MAD_F(0x04f2e80d) /* 0.309303334 */, 18 },
+ /* 4806 */ { MAD_F(0x04f3420d) /* 0.309389165 */, 18 },
+ /* 4807 */ { MAD_F(0x04f39c0f) /* 0.309475002 */, 18 },
+ /* 4808 */ { MAD_F(0x04f3f612) /* 0.309560845 */, 18 },
+ /* 4809 */ { MAD_F(0x04f45017) /* 0.309646694 */, 18 },
+ /* 4810 */ { MAD_F(0x04f4aa1e) /* 0.309732549 */, 18 },
+ /* 4811 */ { MAD_F(0x04f50426) /* 0.309818410 */, 18 },
+ /* 4812 */ { MAD_F(0x04f55e30) /* 0.309904277 */, 18 },
+ /* 4813 */ { MAD_F(0x04f5b83b) /* 0.309990150 */, 18 },
+ /* 4814 */ { MAD_F(0x04f61248) /* 0.310076028 */, 18 },
+ /* 4815 */ { MAD_F(0x04f66c56) /* 0.310161913 */, 18 },
+
+ /* 4816 */ { MAD_F(0x04f6c666) /* 0.310247804 */, 18 },
+ /* 4817 */ { MAD_F(0x04f72078) /* 0.310333700 */, 18 },
+ /* 4818 */ { MAD_F(0x04f77a8b) /* 0.310419603 */, 18 },
+ /* 4819 */ { MAD_F(0x04f7d4a0) /* 0.310505511 */, 18 },
+ /* 4820 */ { MAD_F(0x04f82eb7) /* 0.310591426 */, 18 },
+ /* 4821 */ { MAD_F(0x04f888cf) /* 0.310677346 */, 18 },
+ /* 4822 */ { MAD_F(0x04f8e2e9) /* 0.310763272 */, 18 },
+ /* 4823 */ { MAD_F(0x04f93d04) /* 0.310849205 */, 18 },
+ /* 4824 */ { MAD_F(0x04f99721) /* 0.310935143 */, 18 },
+ /* 4825 */ { MAD_F(0x04f9f13f) /* 0.311021087 */, 18 },
+ /* 4826 */ { MAD_F(0x04fa4b5f) /* 0.311107037 */, 18 },
+ /* 4827 */ { MAD_F(0x04faa581) /* 0.311192993 */, 18 },
+ /* 4828 */ { MAD_F(0x04faffa4) /* 0.311278955 */, 18 },
+ /* 4829 */ { MAD_F(0x04fb59c9) /* 0.311364923 */, 18 },
+ /* 4830 */ { MAD_F(0x04fbb3ef) /* 0.311450897 */, 18 },
+ /* 4831 */ { MAD_F(0x04fc0e17) /* 0.311536877 */, 18 },
+
+ /* 4832 */ { MAD_F(0x04fc6841) /* 0.311622862 */, 18 },
+ /* 4833 */ { MAD_F(0x04fcc26c) /* 0.311708854 */, 18 },
+ /* 4834 */ { MAD_F(0x04fd1c99) /* 0.311794851 */, 18 },
+ /* 4835 */ { MAD_F(0x04fd76c7) /* 0.311880855 */, 18 },
+ /* 4836 */ { MAD_F(0x04fdd0f7) /* 0.311966864 */, 18 },
+ /* 4837 */ { MAD_F(0x04fe2b29) /* 0.312052880 */, 18 },
+ /* 4838 */ { MAD_F(0x04fe855c) /* 0.312138901 */, 18 },
+ /* 4839 */ { MAD_F(0x04fedf91) /* 0.312224928 */, 18 },
+ /* 4840 */ { MAD_F(0x04ff39c7) /* 0.312310961 */, 18 },
+ /* 4841 */ { MAD_F(0x04ff93ff) /* 0.312397000 */, 18 },
+ /* 4842 */ { MAD_F(0x04ffee38) /* 0.312483045 */, 18 },
+ /* 4843 */ { MAD_F(0x05004874) /* 0.312569096 */, 18 },
+ /* 4844 */ { MAD_F(0x0500a2b0) /* 0.312655153 */, 18 },
+ /* 4845 */ { MAD_F(0x0500fcef) /* 0.312741216 */, 18 },
+ /* 4846 */ { MAD_F(0x0501572e) /* 0.312827284 */, 18 },
+ /* 4847 */ { MAD_F(0x0501b170) /* 0.312913359 */, 18 },
+
+ /* 4848 */ { MAD_F(0x05020bb3) /* 0.312999439 */, 18 },
+ /* 4849 */ { MAD_F(0x050265f8) /* 0.313085526 */, 18 },
+ /* 4850 */ { MAD_F(0x0502c03e) /* 0.313171618 */, 18 },
+ /* 4851 */ { MAD_F(0x05031a86) /* 0.313257716 */, 18 },
+ /* 4852 */ { MAD_F(0x050374cf) /* 0.313343820 */, 18 },
+ /* 4853 */ { MAD_F(0x0503cf1a) /* 0.313429931 */, 18 },
+ /* 4854 */ { MAD_F(0x05042967) /* 0.313516047 */, 18 },
+ /* 4855 */ { MAD_F(0x050483b5) /* 0.313602168 */, 18 },
+ /* 4856 */ { MAD_F(0x0504de05) /* 0.313688296 */, 18 },
+ /* 4857 */ { MAD_F(0x05053856) /* 0.313774430 */, 18 },
+ /* 4858 */ { MAD_F(0x050592a9) /* 0.313860570 */, 18 },
+ /* 4859 */ { MAD_F(0x0505ecfd) /* 0.313946715 */, 18 },
+ /* 4860 */ { MAD_F(0x05064754) /* 0.314032867 */, 18 },
+ /* 4861 */ { MAD_F(0x0506a1ab) /* 0.314119024 */, 18 },
+ /* 4862 */ { MAD_F(0x0506fc04) /* 0.314205187 */, 18 },
+ /* 4863 */ { MAD_F(0x0507565f) /* 0.314291357 */, 18 },
+
+ /* 4864 */ { MAD_F(0x0507b0bc) /* 0.314377532 */, 18 },
+ /* 4865 */ { MAD_F(0x05080b1a) /* 0.314463713 */, 18 },
+ /* 4866 */ { MAD_F(0x05086579) /* 0.314549900 */, 18 },
+ /* 4867 */ { MAD_F(0x0508bfdb) /* 0.314636092 */, 18 },
+ /* 4868 */ { MAD_F(0x05091a3d) /* 0.314722291 */, 18 },
+ /* 4869 */ { MAD_F(0x050974a2) /* 0.314808496 */, 18 },
+ /* 4870 */ { MAD_F(0x0509cf08) /* 0.314894706 */, 18 },
+ /* 4871 */ { MAD_F(0x050a296f) /* 0.314980923 */, 18 },
+ /* 4872 */ { MAD_F(0x050a83d8) /* 0.315067145 */, 18 },
+ /* 4873 */ { MAD_F(0x050ade43) /* 0.315153373 */, 18 },
+ /* 4874 */ { MAD_F(0x050b38af) /* 0.315239607 */, 18 },
+ /* 4875 */ { MAD_F(0x050b931d) /* 0.315325847 */, 18 },
+ /* 4876 */ { MAD_F(0x050bed8d) /* 0.315412093 */, 18 },
+ /* 4877 */ { MAD_F(0x050c47fe) /* 0.315498345 */, 18 },
+ /* 4878 */ { MAD_F(0x050ca271) /* 0.315584603 */, 18 },
+ /* 4879 */ { MAD_F(0x050cfce5) /* 0.315670866 */, 18 },
+
+ /* 4880 */ { MAD_F(0x050d575b) /* 0.315757136 */, 18 },
+ /* 4881 */ { MAD_F(0x050db1d2) /* 0.315843411 */, 18 },
+ /* 4882 */ { MAD_F(0x050e0c4b) /* 0.315929693 */, 18 },
+ /* 4883 */ { MAD_F(0x050e66c5) /* 0.316015980 */, 18 },
+ /* 4884 */ { MAD_F(0x050ec141) /* 0.316102273 */, 18 },
+ /* 4885 */ { MAD_F(0x050f1bbf) /* 0.316188572 */, 18 },
+ /* 4886 */ { MAD_F(0x050f763e) /* 0.316274877 */, 18 },
+ /* 4887 */ { MAD_F(0x050fd0bf) /* 0.316361187 */, 18 },
+ /* 4888 */ { MAD_F(0x05102b42) /* 0.316447504 */, 18 },
+ /* 4889 */ { MAD_F(0x051085c6) /* 0.316533826 */, 18 },
+ /* 4890 */ { MAD_F(0x0510e04b) /* 0.316620155 */, 18 },
+ /* 4891 */ { MAD_F(0x05113ad3) /* 0.316706489 */, 18 },
+ /* 4892 */ { MAD_F(0x0511955b) /* 0.316792829 */, 18 },
+ /* 4893 */ { MAD_F(0x0511efe6) /* 0.316879175 */, 18 },
+ /* 4894 */ { MAD_F(0x05124a72) /* 0.316965527 */, 18 },
+ /* 4895 */ { MAD_F(0x0512a4ff) /* 0.317051885 */, 18 },
+
+ /* 4896 */ { MAD_F(0x0512ff8e) /* 0.317138249 */, 18 },
+ /* 4897 */ { MAD_F(0x05135a1f) /* 0.317224618 */, 18 },
+ /* 4898 */ { MAD_F(0x0513b4b1) /* 0.317310994 */, 18 },
+ /* 4899 */ { MAD_F(0x05140f45) /* 0.317397375 */, 18 },
+ /* 4900 */ { MAD_F(0x051469da) /* 0.317483762 */, 18 },
+ /* 4901 */ { MAD_F(0x0514c471) /* 0.317570155 */, 18 },
+ /* 4902 */ { MAD_F(0x05151f0a) /* 0.317656554 */, 18 },
+ /* 4903 */ { MAD_F(0x051579a4) /* 0.317742959 */, 18 },
+ /* 4904 */ { MAD_F(0x0515d440) /* 0.317829370 */, 18 },
+ /* 4905 */ { MAD_F(0x05162edd) /* 0.317915786 */, 18 },
+ /* 4906 */ { MAD_F(0x0516897c) /* 0.318002209 */, 18 },
+ /* 4907 */ { MAD_F(0x0516e41c) /* 0.318088637 */, 18 },
+ /* 4908 */ { MAD_F(0x05173ebe) /* 0.318175071 */, 18 },
+ /* 4909 */ { MAD_F(0x05179962) /* 0.318261511 */, 18 },
+ /* 4910 */ { MAD_F(0x0517f407) /* 0.318347957 */, 18 },
+ /* 4911 */ { MAD_F(0x05184eae) /* 0.318434409 */, 18 },
+
+ /* 4912 */ { MAD_F(0x0518a956) /* 0.318520867 */, 18 },
+ /* 4913 */ { MAD_F(0x05190400) /* 0.318607330 */, 18 },
+ /* 4914 */ { MAD_F(0x05195eab) /* 0.318693800 */, 18 },
+ /* 4915 */ { MAD_F(0x0519b958) /* 0.318780275 */, 18 },
+ /* 4916 */ { MAD_F(0x051a1407) /* 0.318866756 */, 18 },
+ /* 4917 */ { MAD_F(0x051a6eb7) /* 0.318953243 */, 18 },
+ /* 4918 */ { MAD_F(0x051ac969) /* 0.319039736 */, 18 },
+ /* 4919 */ { MAD_F(0x051b241c) /* 0.319126235 */, 18 },
+ /* 4920 */ { MAD_F(0x051b7ed1) /* 0.319212739 */, 18 },
+ /* 4921 */ { MAD_F(0x051bd987) /* 0.319299250 */, 18 },
+ /* 4922 */ { MAD_F(0x051c3440) /* 0.319385766 */, 18 },
+ /* 4923 */ { MAD_F(0x051c8ef9) /* 0.319472288 */, 18 },
+ /* 4924 */ { MAD_F(0x051ce9b4) /* 0.319558816 */, 18 },
+ /* 4925 */ { MAD_F(0x051d4471) /* 0.319645350 */, 18 },
+ /* 4926 */ { MAD_F(0x051d9f2f) /* 0.319731890 */, 18 },
+ /* 4927 */ { MAD_F(0x051df9ef) /* 0.319818435 */, 18 },
+
+ /* 4928 */ { MAD_F(0x051e54b1) /* 0.319904987 */, 18 },
+ /* 4929 */ { MAD_F(0x051eaf74) /* 0.319991544 */, 18 },
+ /* 4930 */ { MAD_F(0x051f0a38) /* 0.320078107 */, 18 },
+ /* 4931 */ { MAD_F(0x051f64ff) /* 0.320164676 */, 18 },
+ /* 4932 */ { MAD_F(0x051fbfc6) /* 0.320251251 */, 18 },
+ /* 4933 */ { MAD_F(0x05201a90) /* 0.320337832 */, 18 },
+ /* 4934 */ { MAD_F(0x0520755b) /* 0.320424419 */, 18 },
+ /* 4935 */ { MAD_F(0x0520d027) /* 0.320511011 */, 18 },
+ /* 4936 */ { MAD_F(0x05212af5) /* 0.320597609 */, 18 },
+ /* 4937 */ { MAD_F(0x052185c5) /* 0.320684213 */, 18 },
+ /* 4938 */ { MAD_F(0x0521e096) /* 0.320770823 */, 18 },
+ /* 4939 */ { MAD_F(0x05223b69) /* 0.320857439 */, 18 },
+ /* 4940 */ { MAD_F(0x0522963d) /* 0.320944061 */, 18 },
+ /* 4941 */ { MAD_F(0x0522f113) /* 0.321030688 */, 18 },
+ /* 4942 */ { MAD_F(0x05234bea) /* 0.321117322 */, 18 },
+ /* 4943 */ { MAD_F(0x0523a6c3) /* 0.321203961 */, 18 },
+
+ /* 4944 */ { MAD_F(0x0524019e) /* 0.321290606 */, 18 },
+ /* 4945 */ { MAD_F(0x05245c7a) /* 0.321377257 */, 18 },
+ /* 4946 */ { MAD_F(0x0524b758) /* 0.321463913 */, 18 },
+ /* 4947 */ { MAD_F(0x05251237) /* 0.321550576 */, 18 },
+ /* 4948 */ { MAD_F(0x05256d18) /* 0.321637244 */, 18 },
+ /* 4949 */ { MAD_F(0x0525c7fb) /* 0.321723919 */, 18 },
+ /* 4950 */ { MAD_F(0x052622df) /* 0.321810599 */, 18 },
+ /* 4951 */ { MAD_F(0x05267dc4) /* 0.321897285 */, 18 },
+ /* 4952 */ { MAD_F(0x0526d8ab) /* 0.321983976 */, 18 },
+ /* 4953 */ { MAD_F(0x05273394) /* 0.322070674 */, 18 },
+ /* 4954 */ { MAD_F(0x05278e7e) /* 0.322157377 */, 18 },
+ /* 4955 */ { MAD_F(0x0527e96a) /* 0.322244087 */, 18 },
+ /* 4956 */ { MAD_F(0x05284457) /* 0.322330802 */, 18 },
+ /* 4957 */ { MAD_F(0x05289f46) /* 0.322417523 */, 18 },
+ /* 4958 */ { MAD_F(0x0528fa37) /* 0.322504249 */, 18 },
+ /* 4959 */ { MAD_F(0x05295529) /* 0.322590982 */, 18 },
+
+ /* 4960 */ { MAD_F(0x0529b01d) /* 0.322677720 */, 18 },
+ /* 4961 */ { MAD_F(0x052a0b12) /* 0.322764465 */, 18 },
+ /* 4962 */ { MAD_F(0x052a6609) /* 0.322851215 */, 18 },
+ /* 4963 */ { MAD_F(0x052ac101) /* 0.322937971 */, 18 },
+ /* 4964 */ { MAD_F(0x052b1bfb) /* 0.323024732 */, 18 },
+ /* 4965 */ { MAD_F(0x052b76f7) /* 0.323111500 */, 18 },
+ /* 4966 */ { MAD_F(0x052bd1f4) /* 0.323198273 */, 18 },
+ /* 4967 */ { MAD_F(0x052c2cf2) /* 0.323285052 */, 18 },
+ /* 4968 */ { MAD_F(0x052c87f2) /* 0.323371837 */, 18 },
+ /* 4969 */ { MAD_F(0x052ce2f4) /* 0.323458628 */, 18 },
+ /* 4970 */ { MAD_F(0x052d3df7) /* 0.323545425 */, 18 },
+ /* 4971 */ { MAD_F(0x052d98fc) /* 0.323632227 */, 18 },
+ /* 4972 */ { MAD_F(0x052df403) /* 0.323719036 */, 18 },
+ /* 4973 */ { MAD_F(0x052e4f0b) /* 0.323805850 */, 18 },
+ /* 4974 */ { MAD_F(0x052eaa14) /* 0.323892670 */, 18 },
+ /* 4975 */ { MAD_F(0x052f051f) /* 0.323979496 */, 18 },
+
+ /* 4976 */ { MAD_F(0x052f602c) /* 0.324066327 */, 18 },
+ /* 4977 */ { MAD_F(0x052fbb3a) /* 0.324153165 */, 18 },
+ /* 4978 */ { MAD_F(0x0530164a) /* 0.324240008 */, 18 },
+ /* 4979 */ { MAD_F(0x0530715b) /* 0.324326857 */, 18 },
+ /* 4980 */ { MAD_F(0x0530cc6e) /* 0.324413712 */, 18 },
+ /* 4981 */ { MAD_F(0x05312783) /* 0.324500572 */, 18 },
+ /* 4982 */ { MAD_F(0x05318299) /* 0.324587439 */, 18 },
+ /* 4983 */ { MAD_F(0x0531ddb0) /* 0.324674311 */, 18 },
+ /* 4984 */ { MAD_F(0x053238ca) /* 0.324761189 */, 18 },
+ /* 4985 */ { MAD_F(0x053293e4) /* 0.324848073 */, 18 },
+ /* 4986 */ { MAD_F(0x0532ef01) /* 0.324934963 */, 18 },
+ /* 4987 */ { MAD_F(0x05334a1e) /* 0.325021858 */, 18 },
+ /* 4988 */ { MAD_F(0x0533a53e) /* 0.325108760 */, 18 },
+ /* 4989 */ { MAD_F(0x0534005f) /* 0.325195667 */, 18 },
+ /* 4990 */ { MAD_F(0x05345b81) /* 0.325282580 */, 18 },
+ /* 4991 */ { MAD_F(0x0534b6a5) /* 0.325369498 */, 18 },
+
+ /* 4992 */ { MAD_F(0x053511cb) /* 0.325456423 */, 18 },
+ /* 4993 */ { MAD_F(0x05356cf2) /* 0.325543353 */, 18 },
+ /* 4994 */ { MAD_F(0x0535c81b) /* 0.325630290 */, 18 },
+ /* 4995 */ { MAD_F(0x05362345) /* 0.325717232 */, 18 },
+ /* 4996 */ { MAD_F(0x05367e71) /* 0.325804179 */, 18 },
+ /* 4997 */ { MAD_F(0x0536d99f) /* 0.325891133 */, 18 },
+ /* 4998 */ { MAD_F(0x053734ce) /* 0.325978092 */, 18 },
+ /* 4999 */ { MAD_F(0x05378ffe) /* 0.326065057 */, 18 },
+ /* 5000 */ { MAD_F(0x0537eb30) /* 0.326152028 */, 18 },
+ /* 5001 */ { MAD_F(0x05384664) /* 0.326239005 */, 18 },
+ /* 5002 */ { MAD_F(0x0538a199) /* 0.326325988 */, 18 },
+ /* 5003 */ { MAD_F(0x0538fcd0) /* 0.326412976 */, 18 },
+ /* 5004 */ { MAD_F(0x05395808) /* 0.326499970 */, 18 },
+ /* 5005 */ { MAD_F(0x0539b342) /* 0.326586970 */, 18 },
+ /* 5006 */ { MAD_F(0x053a0e7d) /* 0.326673976 */, 18 },
+ /* 5007 */ { MAD_F(0x053a69ba) /* 0.326760988 */, 18 },
+
+ /* 5008 */ { MAD_F(0x053ac4f9) /* 0.326848005 */, 18 },
+ /* 5009 */ { MAD_F(0x053b2039) /* 0.326935028 */, 18 },
+ /* 5010 */ { MAD_F(0x053b7b7b) /* 0.327022057 */, 18 },
+ /* 5011 */ { MAD_F(0x053bd6be) /* 0.327109092 */, 18 },
+ /* 5012 */ { MAD_F(0x053c3203) /* 0.327196132 */, 18 },
+ /* 5013 */ { MAD_F(0x053c8d49) /* 0.327283178 */, 18 },
+ /* 5014 */ { MAD_F(0x053ce891) /* 0.327370231 */, 18 },
+ /* 5015 */ { MAD_F(0x053d43da) /* 0.327457288 */, 18 },
+ /* 5016 */ { MAD_F(0x053d9f25) /* 0.327544352 */, 18 },
+ /* 5017 */ { MAD_F(0x053dfa72) /* 0.327631421 */, 18 },
+ /* 5018 */ { MAD_F(0x053e55c0) /* 0.327718497 */, 18 },
+ /* 5019 */ { MAD_F(0x053eb10f) /* 0.327805578 */, 18 },
+ /* 5020 */ { MAD_F(0x053f0c61) /* 0.327892665 */, 18 },
+ /* 5021 */ { MAD_F(0x053f67b3) /* 0.327979757 */, 18 },
+ /* 5022 */ { MAD_F(0x053fc308) /* 0.328066855 */, 18 },
+ /* 5023 */ { MAD_F(0x05401e5e) /* 0.328153960 */, 18 },
+
+ /* 5024 */ { MAD_F(0x054079b5) /* 0.328241070 */, 18 },
+ /* 5025 */ { MAD_F(0x0540d50e) /* 0.328328185 */, 18 },
+ /* 5026 */ { MAD_F(0x05413068) /* 0.328415307 */, 18 },
+ /* 5027 */ { MAD_F(0x05418bc4) /* 0.328502434 */, 18 },
+ /* 5028 */ { MAD_F(0x0541e722) /* 0.328589567 */, 18 },
+ /* 5029 */ { MAD_F(0x05424281) /* 0.328676706 */, 18 },
+ /* 5030 */ { MAD_F(0x05429de2) /* 0.328763850 */, 18 },
+ /* 5031 */ { MAD_F(0x0542f944) /* 0.328851001 */, 18 },
+ /* 5032 */ { MAD_F(0x054354a8) /* 0.328938157 */, 18 },
+ /* 5033 */ { MAD_F(0x0543b00d) /* 0.329025319 */, 18 },
+ /* 5034 */ { MAD_F(0x05440b74) /* 0.329112486 */, 18 },
+ /* 5035 */ { MAD_F(0x054466dd) /* 0.329199660 */, 18 },
+ /* 5036 */ { MAD_F(0x0544c247) /* 0.329286839 */, 18 },
+ /* 5037 */ { MAD_F(0x05451db2) /* 0.329374024 */, 18 },
+ /* 5038 */ { MAD_F(0x0545791f) /* 0.329461215 */, 18 },
+ /* 5039 */ { MAD_F(0x0545d48e) /* 0.329548411 */, 18 },
+
+ /* 5040 */ { MAD_F(0x05462ffe) /* 0.329635614 */, 18 },
+ /* 5041 */ { MAD_F(0x05468b70) /* 0.329722822 */, 18 },
+ /* 5042 */ { MAD_F(0x0546e6e3) /* 0.329810036 */, 18 },
+ /* 5043 */ { MAD_F(0x05474258) /* 0.329897255 */, 18 },
+ /* 5044 */ { MAD_F(0x05479dce) /* 0.329984481 */, 18 },
+ /* 5045 */ { MAD_F(0x0547f946) /* 0.330071712 */, 18 },
+ /* 5046 */ { MAD_F(0x054854c0) /* 0.330158949 */, 18 },
+ /* 5047 */ { MAD_F(0x0548b03b) /* 0.330246191 */, 18 },
+ /* 5048 */ { MAD_F(0x05490bb7) /* 0.330333440 */, 18 },
+ /* 5049 */ { MAD_F(0x05496735) /* 0.330420694 */, 18 },
+ /* 5050 */ { MAD_F(0x0549c2b5) /* 0.330507954 */, 18 },
+ /* 5051 */ { MAD_F(0x054a1e36) /* 0.330595220 */, 18 },
+ /* 5052 */ { MAD_F(0x054a79b9) /* 0.330682491 */, 18 },
+ /* 5053 */ { MAD_F(0x054ad53d) /* 0.330769768 */, 18 },
+ /* 5054 */ { MAD_F(0x054b30c3) /* 0.330857051 */, 18 },
+ /* 5055 */ { MAD_F(0x054b8c4b) /* 0.330944340 */, 18 },
+
+ /* 5056 */ { MAD_F(0x054be7d4) /* 0.331031635 */, 18 },
+ /* 5057 */ { MAD_F(0x054c435e) /* 0.331118935 */, 18 },
+ /* 5058 */ { MAD_F(0x054c9eea) /* 0.331206241 */, 18 },
+ /* 5059 */ { MAD_F(0x054cfa78) /* 0.331293553 */, 18 },
+ /* 5060 */ { MAD_F(0x054d5607) /* 0.331380870 */, 18 },
+ /* 5061 */ { MAD_F(0x054db197) /* 0.331468193 */, 18 },
+ /* 5062 */ { MAD_F(0x054e0d2a) /* 0.331555522 */, 18 },
+ /* 5063 */ { MAD_F(0x054e68bd) /* 0.331642857 */, 18 },
+ /* 5064 */ { MAD_F(0x054ec453) /* 0.331730198 */, 18 },
+ /* 5065 */ { MAD_F(0x054f1fe9) /* 0.331817544 */, 18 },
+ /* 5066 */ { MAD_F(0x054f7b82) /* 0.331904896 */, 18 },
+ /* 5067 */ { MAD_F(0x054fd71c) /* 0.331992254 */, 18 },
+ /* 5068 */ { MAD_F(0x055032b7) /* 0.332079617 */, 18 },
+ /* 5069 */ { MAD_F(0x05508e54) /* 0.332166986 */, 18 },
+ /* 5070 */ { MAD_F(0x0550e9f3) /* 0.332254361 */, 18 },
+ /* 5071 */ { MAD_F(0x05514593) /* 0.332341742 */, 18 },
+
+ /* 5072 */ { MAD_F(0x0551a134) /* 0.332429129 */, 18 },
+ /* 5073 */ { MAD_F(0x0551fcd8) /* 0.332516521 */, 18 },
+ /* 5074 */ { MAD_F(0x0552587c) /* 0.332603919 */, 18 },
+ /* 5075 */ { MAD_F(0x0552b423) /* 0.332691323 */, 18 },
+ /* 5076 */ { MAD_F(0x05530fca) /* 0.332778732 */, 18 },
+ /* 5077 */ { MAD_F(0x05536b74) /* 0.332866147 */, 18 },
+ /* 5078 */ { MAD_F(0x0553c71f) /* 0.332953568 */, 18 },
+ /* 5079 */ { MAD_F(0x055422cb) /* 0.333040995 */, 18 },
+ /* 5080 */ { MAD_F(0x05547e79) /* 0.333128427 */, 18 },
+ /* 5081 */ { MAD_F(0x0554da29) /* 0.333215865 */, 18 },
+ /* 5082 */ { MAD_F(0x055535da) /* 0.333303309 */, 18 },
+ /* 5083 */ { MAD_F(0x0555918c) /* 0.333390759 */, 18 },
+ /* 5084 */ { MAD_F(0x0555ed40) /* 0.333478214 */, 18 },
+ /* 5085 */ { MAD_F(0x055648f6) /* 0.333565675 */, 18 },
+ /* 5086 */ { MAD_F(0x0556a4ad) /* 0.333653142 */, 18 },
+ /* 5087 */ { MAD_F(0x05570066) /* 0.333740615 */, 18 },
+
+ /* 5088 */ { MAD_F(0x05575c20) /* 0.333828093 */, 18 },
+ /* 5089 */ { MAD_F(0x0557b7dc) /* 0.333915577 */, 18 },
+ /* 5090 */ { MAD_F(0x05581399) /* 0.334003067 */, 18 },
+ /* 5091 */ { MAD_F(0x05586f58) /* 0.334090562 */, 18 },
+ /* 5092 */ { MAD_F(0x0558cb19) /* 0.334178063 */, 18 },
+ /* 5093 */ { MAD_F(0x055926db) /* 0.334265570 */, 18 },
+ /* 5094 */ { MAD_F(0x0559829e) /* 0.334353083 */, 18 },
+ /* 5095 */ { MAD_F(0x0559de63) /* 0.334440601 */, 18 },
+ /* 5096 */ { MAD_F(0x055a3a2a) /* 0.334528126 */, 18 },
+ /* 5097 */ { MAD_F(0x055a95f2) /* 0.334615655 */, 18 },
+ /* 5098 */ { MAD_F(0x055af1bb) /* 0.334703191 */, 18 },
+ /* 5099 */ { MAD_F(0x055b4d87) /* 0.334790732 */, 18 },
+ /* 5100 */ { MAD_F(0x055ba953) /* 0.334878279 */, 18 },
+ /* 5101 */ { MAD_F(0x055c0522) /* 0.334965832 */, 18 },
+ /* 5102 */ { MAD_F(0x055c60f1) /* 0.335053391 */, 18 },
+ /* 5103 */ { MAD_F(0x055cbcc3) /* 0.335140955 */, 18 },
+
+ /* 5104 */ { MAD_F(0x055d1896) /* 0.335228525 */, 18 },
+ /* 5105 */ { MAD_F(0x055d746a) /* 0.335316100 */, 18 },
+ /* 5106 */ { MAD_F(0x055dd040) /* 0.335403682 */, 18 },
+ /* 5107 */ { MAD_F(0x055e2c17) /* 0.335491269 */, 18 },
+ /* 5108 */ { MAD_F(0x055e87f0) /* 0.335578861 */, 18 },
+ /* 5109 */ { MAD_F(0x055ee3cb) /* 0.335666460 */, 18 },
+ /* 5110 */ { MAD_F(0x055f3fa7) /* 0.335754064 */, 18 },
+ /* 5111 */ { MAD_F(0x055f9b85) /* 0.335841674 */, 18 },
+ /* 5112 */ { MAD_F(0x055ff764) /* 0.335929290 */, 18 },
+ /* 5113 */ { MAD_F(0x05605344) /* 0.336016911 */, 18 },
+ /* 5114 */ { MAD_F(0x0560af27) /* 0.336104538 */, 18 },
+ /* 5115 */ { MAD_F(0x05610b0a) /* 0.336192171 */, 18 },
+ /* 5116 */ { MAD_F(0x056166f0) /* 0.336279809 */, 18 },
+ /* 5117 */ { MAD_F(0x0561c2d7) /* 0.336367453 */, 18 },
+ /* 5118 */ { MAD_F(0x05621ebf) /* 0.336455103 */, 18 },
+ /* 5119 */ { MAD_F(0x05627aa9) /* 0.336542759 */, 18 },
+
+ /* 5120 */ { MAD_F(0x0562d694) /* 0.336630420 */, 18 },
+ /* 5121 */ { MAD_F(0x05633281) /* 0.336718087 */, 18 },
+ /* 5122 */ { MAD_F(0x05638e70) /* 0.336805760 */, 18 },
+ /* 5123 */ { MAD_F(0x0563ea60) /* 0.336893439 */, 18 },
+ /* 5124 */ { MAD_F(0x05644651) /* 0.336981123 */, 18 },
+ /* 5125 */ { MAD_F(0x0564a244) /* 0.337068813 */, 18 },
+ /* 5126 */ { MAD_F(0x0564fe39) /* 0.337156508 */, 18 },
+ /* 5127 */ { MAD_F(0x05655a2f) /* 0.337244209 */, 18 },
+ /* 5128 */ { MAD_F(0x0565b627) /* 0.337331916 */, 18 },
+ /* 5129 */ { MAD_F(0x05661220) /* 0.337419629 */, 18 },
+ /* 5130 */ { MAD_F(0x05666e1a) /* 0.337507347 */, 18 },
+ /* 5131 */ { MAD_F(0x0566ca17) /* 0.337595071 */, 18 },
+ /* 5132 */ { MAD_F(0x05672614) /* 0.337682801 */, 18 },
+ /* 5133 */ { MAD_F(0x05678214) /* 0.337770537 */, 18 },
+ /* 5134 */ { MAD_F(0x0567de15) /* 0.337858278 */, 18 },
+ /* 5135 */ { MAD_F(0x05683a17) /* 0.337946025 */, 18 },
+
+ /* 5136 */ { MAD_F(0x0568961b) /* 0.338033777 */, 18 },
+ /* 5137 */ { MAD_F(0x0568f220) /* 0.338121535 */, 18 },
+ /* 5138 */ { MAD_F(0x05694e27) /* 0.338209299 */, 18 },
+ /* 5139 */ { MAD_F(0x0569aa30) /* 0.338297069 */, 18 },
+ /* 5140 */ { MAD_F(0x056a063a) /* 0.338384844 */, 18 },
+ /* 5141 */ { MAD_F(0x056a6245) /* 0.338472625 */, 18 },
+ /* 5142 */ { MAD_F(0x056abe52) /* 0.338560412 */, 18 },
+ /* 5143 */ { MAD_F(0x056b1a61) /* 0.338648204 */, 18 },
+ /* 5144 */ { MAD_F(0x056b7671) /* 0.338736002 */, 18 },
+ /* 5145 */ { MAD_F(0x056bd283) /* 0.338823806 */, 18 },
+ /* 5146 */ { MAD_F(0x056c2e96) /* 0.338911616 */, 18 },
+ /* 5147 */ { MAD_F(0x056c8aab) /* 0.338999431 */, 18 },
+ /* 5148 */ { MAD_F(0x056ce6c1) /* 0.339087252 */, 18 },
+ /* 5149 */ { MAD_F(0x056d42d9) /* 0.339175078 */, 18 },
+ /* 5150 */ { MAD_F(0x056d9ef2) /* 0.339262910 */, 18 },
+ /* 5151 */ { MAD_F(0x056dfb0d) /* 0.339350748 */, 18 },
+
+ /* 5152 */ { MAD_F(0x056e5729) /* 0.339438592 */, 18 },
+ /* 5153 */ { MAD_F(0x056eb347) /* 0.339526441 */, 18 },
+ /* 5154 */ { MAD_F(0x056f0f66) /* 0.339614296 */, 18 },
+ /* 5155 */ { MAD_F(0x056f6b87) /* 0.339702157 */, 18 },
+ /* 5156 */ { MAD_F(0x056fc7aa) /* 0.339790023 */, 18 },
+ /* 5157 */ { MAD_F(0x057023cd) /* 0.339877895 */, 18 },
+ /* 5158 */ { MAD_F(0x05707ff3) /* 0.339965773 */, 18 },
+ /* 5159 */ { MAD_F(0x0570dc1a) /* 0.340053656 */, 18 },
+ /* 5160 */ { MAD_F(0x05713843) /* 0.340141545 */, 18 },
+ /* 5161 */ { MAD_F(0x0571946d) /* 0.340229440 */, 18 },
+ /* 5162 */ { MAD_F(0x0571f098) /* 0.340317340 */, 18 },
+ /* 5163 */ { MAD_F(0x05724cc5) /* 0.340405246 */, 18 },
+ /* 5164 */ { MAD_F(0x0572a8f4) /* 0.340493158 */, 18 },
+ /* 5165 */ { MAD_F(0x05730524) /* 0.340581075 */, 18 },
+ /* 5166 */ { MAD_F(0x05736156) /* 0.340668999 */, 18 },
+ /* 5167 */ { MAD_F(0x0573bd89) /* 0.340756927 */, 18 },
+
+ /* 5168 */ { MAD_F(0x057419be) /* 0.340844862 */, 18 },
+ /* 5169 */ { MAD_F(0x057475f4) /* 0.340932802 */, 18 },
+ /* 5170 */ { MAD_F(0x0574d22c) /* 0.341020748 */, 18 },
+ /* 5171 */ { MAD_F(0x05752e65) /* 0.341108699 */, 18 },
+ /* 5172 */ { MAD_F(0x05758aa0) /* 0.341196656 */, 18 },
+ /* 5173 */ { MAD_F(0x0575e6dc) /* 0.341284619 */, 18 },
+ /* 5174 */ { MAD_F(0x0576431a) /* 0.341372587 */, 18 },
+ /* 5175 */ { MAD_F(0x05769f59) /* 0.341460562 */, 18 },
+ /* 5176 */ { MAD_F(0x0576fb9a) /* 0.341548541 */, 18 },
+ /* 5177 */ { MAD_F(0x057757dd) /* 0.341636527 */, 18 },
+ /* 5178 */ { MAD_F(0x0577b421) /* 0.341724518 */, 18 },
+ /* 5179 */ { MAD_F(0x05781066) /* 0.341812515 */, 18 },
+ /* 5180 */ { MAD_F(0x05786cad) /* 0.341900517 */, 18 },
+ /* 5181 */ { MAD_F(0x0578c8f5) /* 0.341988525 */, 18 },
+ /* 5182 */ { MAD_F(0x0579253f) /* 0.342076539 */, 18 },
+ /* 5183 */ { MAD_F(0x0579818b) /* 0.342164558 */, 18 },
+
+ /* 5184 */ { MAD_F(0x0579ddd8) /* 0.342252584 */, 18 },
+ /* 5185 */ { MAD_F(0x057a3a27) /* 0.342340614 */, 18 },
+ /* 5186 */ { MAD_F(0x057a9677) /* 0.342428651 */, 18 },
+ /* 5187 */ { MAD_F(0x057af2c8) /* 0.342516693 */, 18 },
+ /* 5188 */ { MAD_F(0x057b4f1c) /* 0.342604741 */, 18 },
+ /* 5189 */ { MAD_F(0x057bab70) /* 0.342692794 */, 18 },
+ /* 5190 */ { MAD_F(0x057c07c6) /* 0.342780853 */, 18 },
+ /* 5191 */ { MAD_F(0x057c641e) /* 0.342868918 */, 18 },
+ /* 5192 */ { MAD_F(0x057cc077) /* 0.342956988 */, 18 },
+ /* 5193 */ { MAD_F(0x057d1cd2) /* 0.343045064 */, 18 },
+ /* 5194 */ { MAD_F(0x057d792e) /* 0.343133146 */, 18 },
+ /* 5195 */ { MAD_F(0x057dd58c) /* 0.343221233 */, 18 },
+ /* 5196 */ { MAD_F(0x057e31eb) /* 0.343309326 */, 18 },
+ /* 5197 */ { MAD_F(0x057e8e4c) /* 0.343397425 */, 18 },
+ /* 5198 */ { MAD_F(0x057eeaae) /* 0.343485529 */, 18 },
+ /* 5199 */ { MAD_F(0x057f4712) /* 0.343573639 */, 18 },
+
+ /* 5200 */ { MAD_F(0x057fa378) /* 0.343661754 */, 18 },
+ /* 5201 */ { MAD_F(0x057fffde) /* 0.343749876 */, 18 },
+ /* 5202 */ { MAD_F(0x05805c47) /* 0.343838003 */, 18 },
+ /* 5203 */ { MAD_F(0x0580b8b1) /* 0.343926135 */, 18 },
+ /* 5204 */ { MAD_F(0x0581151c) /* 0.344014273 */, 18 },
+ /* 5205 */ { MAD_F(0x05817189) /* 0.344102417 */, 18 },
+ /* 5206 */ { MAD_F(0x0581cdf7) /* 0.344190566 */, 18 },
+ /* 5207 */ { MAD_F(0x05822a67) /* 0.344278722 */, 18 },
+ /* 5208 */ { MAD_F(0x058286d9) /* 0.344366882 */, 18 },
+ /* 5209 */ { MAD_F(0x0582e34c) /* 0.344455049 */, 18 },
+ /* 5210 */ { MAD_F(0x05833fc0) /* 0.344543221 */, 18 },
+ /* 5211 */ { MAD_F(0x05839c36) /* 0.344631398 */, 18 },
+ /* 5212 */ { MAD_F(0x0583f8ae) /* 0.344719582 */, 18 },
+ /* 5213 */ { MAD_F(0x05845527) /* 0.344807771 */, 18 },
+ /* 5214 */ { MAD_F(0x0584b1a1) /* 0.344895965 */, 18 },
+ /* 5215 */ { MAD_F(0x05850e1e) /* 0.344984165 */, 18 },
+
+ /* 5216 */ { MAD_F(0x05856a9b) /* 0.345072371 */, 18 },
+ /* 5217 */ { MAD_F(0x0585c71a) /* 0.345160583 */, 18 },
+ /* 5218 */ { MAD_F(0x0586239b) /* 0.345248800 */, 18 },
+ /* 5219 */ { MAD_F(0x0586801d) /* 0.345337023 */, 18 },
+ /* 5220 */ { MAD_F(0x0586dca1) /* 0.345425251 */, 18 },
+ /* 5221 */ { MAD_F(0x05873926) /* 0.345513485 */, 18 },
+ /* 5222 */ { MAD_F(0x058795ac) /* 0.345601725 */, 18 },
+ /* 5223 */ { MAD_F(0x0587f235) /* 0.345689970 */, 18 },
+ /* 5224 */ { MAD_F(0x05884ebe) /* 0.345778221 */, 18 },
+ /* 5225 */ { MAD_F(0x0588ab49) /* 0.345866478 */, 18 },
+ /* 5226 */ { MAD_F(0x058907d6) /* 0.345954740 */, 18 },
+ /* 5227 */ { MAD_F(0x05896464) /* 0.346043008 */, 18 },
+ /* 5228 */ { MAD_F(0x0589c0f4) /* 0.346131281 */, 18 },
+ /* 5229 */ { MAD_F(0x058a1d85) /* 0.346219560 */, 18 },
+ /* 5230 */ { MAD_F(0x058a7a18) /* 0.346307845 */, 18 },
+ /* 5231 */ { MAD_F(0x058ad6ac) /* 0.346396135 */, 18 },
+
+ /* 5232 */ { MAD_F(0x058b3342) /* 0.346484431 */, 18 },
+ /* 5233 */ { MAD_F(0x058b8fd9) /* 0.346572733 */, 18 },
+ /* 5234 */ { MAD_F(0x058bec72) /* 0.346661040 */, 18 },
+ /* 5235 */ { MAD_F(0x058c490c) /* 0.346749353 */, 18 },
+ /* 5236 */ { MAD_F(0x058ca5a8) /* 0.346837671 */, 18 },
+ /* 5237 */ { MAD_F(0x058d0246) /* 0.346925996 */, 18 },
+ /* 5238 */ { MAD_F(0x058d5ee4) /* 0.347014325 */, 18 },
+ /* 5239 */ { MAD_F(0x058dbb85) /* 0.347102661 */, 18 },
+ /* 5240 */ { MAD_F(0x058e1827) /* 0.347191002 */, 18 },
+ /* 5241 */ { MAD_F(0x058e74ca) /* 0.347279348 */, 18 },
+ /* 5242 */ { MAD_F(0x058ed16f) /* 0.347367700 */, 18 },
+ /* 5243 */ { MAD_F(0x058f2e15) /* 0.347456058 */, 18 },
+ /* 5244 */ { MAD_F(0x058f8abd) /* 0.347544422 */, 18 },
+ /* 5245 */ { MAD_F(0x058fe766) /* 0.347632791 */, 18 },
+ /* 5246 */ { MAD_F(0x05904411) /* 0.347721165 */, 18 },
+ /* 5247 */ { MAD_F(0x0590a0be) /* 0.347809546 */, 18 },
+
+ /* 5248 */ { MAD_F(0x0590fd6c) /* 0.347897931 */, 18 },
+ /* 5249 */ { MAD_F(0x05915a1b) /* 0.347986323 */, 18 },
+ /* 5250 */ { MAD_F(0x0591b6cc) /* 0.348074720 */, 18 },
+ /* 5251 */ { MAD_F(0x0592137e) /* 0.348163123 */, 18 },
+ /* 5252 */ { MAD_F(0x05927032) /* 0.348251531 */, 18 },
+ /* 5253 */ { MAD_F(0x0592cce8) /* 0.348339945 */, 18 },
+ /* 5254 */ { MAD_F(0x0593299f) /* 0.348428365 */, 18 },
+ /* 5255 */ { MAD_F(0x05938657) /* 0.348516790 */, 18 },
+ /* 5256 */ { MAD_F(0x0593e311) /* 0.348605221 */, 18 },
+ /* 5257 */ { MAD_F(0x05943fcd) /* 0.348693657 */, 18 },
+ /* 5258 */ { MAD_F(0x05949c8a) /* 0.348782099 */, 18 },
+ /* 5259 */ { MAD_F(0x0594f948) /* 0.348870547 */, 18 },
+ /* 5260 */ { MAD_F(0x05955608) /* 0.348959000 */, 18 },
+ /* 5261 */ { MAD_F(0x0595b2ca) /* 0.349047459 */, 18 },
+ /* 5262 */ { MAD_F(0x05960f8c) /* 0.349135923 */, 18 },
+ /* 5263 */ { MAD_F(0x05966c51) /* 0.349224393 */, 18 },
+
+ /* 5264 */ { MAD_F(0x0596c917) /* 0.349312869 */, 18 },
+ /* 5265 */ { MAD_F(0x059725de) /* 0.349401350 */, 18 },
+ /* 5266 */ { MAD_F(0x059782a7) /* 0.349489837 */, 18 },
+ /* 5267 */ { MAD_F(0x0597df72) /* 0.349578329 */, 18 },
+ /* 5268 */ { MAD_F(0x05983c3e) /* 0.349666827 */, 18 },
+ /* 5269 */ { MAD_F(0x0598990c) /* 0.349755331 */, 18 },
+ /* 5270 */ { MAD_F(0x0598f5db) /* 0.349843840 */, 18 },
+ /* 5271 */ { MAD_F(0x059952ab) /* 0.349932355 */, 18 },
+ /* 5272 */ { MAD_F(0x0599af7d) /* 0.350020876 */, 18 },
+ /* 5273 */ { MAD_F(0x059a0c51) /* 0.350109402 */, 18 },
+ /* 5274 */ { MAD_F(0x059a6926) /* 0.350197933 */, 18 },
+ /* 5275 */ { MAD_F(0x059ac5fc) /* 0.350286470 */, 18 },
+ /* 5276 */ { MAD_F(0x059b22d4) /* 0.350375013 */, 18 },
+ /* 5277 */ { MAD_F(0x059b7fae) /* 0.350463562 */, 18 },
+ /* 5278 */ { MAD_F(0x059bdc89) /* 0.350552116 */, 18 },
+ /* 5279 */ { MAD_F(0x059c3965) /* 0.350640675 */, 18 },
+
+ /* 5280 */ { MAD_F(0x059c9643) /* 0.350729240 */, 18 },
+ /* 5281 */ { MAD_F(0x059cf323) /* 0.350817811 */, 18 },
+ /* 5282 */ { MAD_F(0x059d5004) /* 0.350906388 */, 18 },
+ /* 5283 */ { MAD_F(0x059dace6) /* 0.350994970 */, 18 },
+ /* 5284 */ { MAD_F(0x059e09cb) /* 0.351083557 */, 18 },
+ /* 5285 */ { MAD_F(0x059e66b0) /* 0.351172150 */, 18 },
+ /* 5286 */ { MAD_F(0x059ec397) /* 0.351260749 */, 18 },
+ /* 5287 */ { MAD_F(0x059f2080) /* 0.351349353 */, 18 },
+ /* 5288 */ { MAD_F(0x059f7d6a) /* 0.351437963 */, 18 },
+ /* 5289 */ { MAD_F(0x059fda55) /* 0.351526579 */, 18 },
+ /* 5290 */ { MAD_F(0x05a03742) /* 0.351615200 */, 18 },
+ /* 5291 */ { MAD_F(0x05a09431) /* 0.351703827 */, 18 },
+ /* 5292 */ { MAD_F(0x05a0f121) /* 0.351792459 */, 18 },
+ /* 5293 */ { MAD_F(0x05a14e12) /* 0.351881097 */, 18 },
+ /* 5294 */ { MAD_F(0x05a1ab05) /* 0.351969740 */, 18 },
+ /* 5295 */ { MAD_F(0x05a207fa) /* 0.352058389 */, 18 },
+
+ /* 5296 */ { MAD_F(0x05a264f0) /* 0.352147044 */, 18 },
+ /* 5297 */ { MAD_F(0x05a2c1e7) /* 0.352235704 */, 18 },
+ /* 5298 */ { MAD_F(0x05a31ee1) /* 0.352324369 */, 18 },
+ /* 5299 */ { MAD_F(0x05a37bdb) /* 0.352413041 */, 18 },
+ /* 5300 */ { MAD_F(0x05a3d8d7) /* 0.352501718 */, 18 },
+ /* 5301 */ { MAD_F(0x05a435d5) /* 0.352590400 */, 18 },
+ /* 5302 */ { MAD_F(0x05a492d4) /* 0.352679088 */, 18 },
+ /* 5303 */ { MAD_F(0x05a4efd4) /* 0.352767782 */, 18 },
+ /* 5304 */ { MAD_F(0x05a54cd6) /* 0.352856481 */, 18 },
+ /* 5305 */ { MAD_F(0x05a5a9da) /* 0.352945186 */, 18 },
+ /* 5306 */ { MAD_F(0x05a606df) /* 0.353033896 */, 18 },
+ /* 5307 */ { MAD_F(0x05a663e5) /* 0.353122612 */, 18 },
+ /* 5308 */ { MAD_F(0x05a6c0ed) /* 0.353211333 */, 18 },
+ /* 5309 */ { MAD_F(0x05a71df7) /* 0.353300061 */, 18 },
+ /* 5310 */ { MAD_F(0x05a77b02) /* 0.353388793 */, 18 },
+ /* 5311 */ { MAD_F(0x05a7d80e) /* 0.353477531 */, 18 },
+
+ /* 5312 */ { MAD_F(0x05a8351c) /* 0.353566275 */, 18 },
+ /* 5313 */ { MAD_F(0x05a8922c) /* 0.353655024 */, 18 },
+ /* 5314 */ { MAD_F(0x05a8ef3c) /* 0.353743779 */, 18 },
+ /* 5315 */ { MAD_F(0x05a94c4f) /* 0.353832540 */, 18 },
+ /* 5316 */ { MAD_F(0x05a9a963) /* 0.353921306 */, 18 },
+ /* 5317 */ { MAD_F(0x05aa0678) /* 0.354010077 */, 18 },
+ /* 5318 */ { MAD_F(0x05aa638f) /* 0.354098855 */, 18 },
+ /* 5319 */ { MAD_F(0x05aac0a8) /* 0.354187637 */, 18 },
+ /* 5320 */ { MAD_F(0x05ab1dc2) /* 0.354276426 */, 18 },
+ /* 5321 */ { MAD_F(0x05ab7add) /* 0.354365220 */, 18 },
+ /* 5322 */ { MAD_F(0x05abd7fa) /* 0.354454019 */, 18 },
+ /* 5323 */ { MAD_F(0x05ac3518) /* 0.354542824 */, 18 },
+ /* 5324 */ { MAD_F(0x05ac9238) /* 0.354631635 */, 18 },
+ /* 5325 */ { MAD_F(0x05acef5a) /* 0.354720451 */, 18 },
+ /* 5326 */ { MAD_F(0x05ad4c7d) /* 0.354809272 */, 18 },
+ /* 5327 */ { MAD_F(0x05ada9a1) /* 0.354898100 */, 18 },
+
+ /* 5328 */ { MAD_F(0x05ae06c7) /* 0.354986932 */, 18 },
+ /* 5329 */ { MAD_F(0x05ae63ee) /* 0.355075771 */, 18 },
+ /* 5330 */ { MAD_F(0x05aec117) /* 0.355164615 */, 18 },
+ /* 5331 */ { MAD_F(0x05af1e41) /* 0.355253464 */, 18 },
+ /* 5332 */ { MAD_F(0x05af7b6d) /* 0.355342319 */, 18 },
+ /* 5333 */ { MAD_F(0x05afd89b) /* 0.355431180 */, 18 },
+ /* 5334 */ { MAD_F(0x05b035c9) /* 0.355520046 */, 18 },
+ /* 5335 */ { MAD_F(0x05b092fa) /* 0.355608917 */, 18 },
+ /* 5336 */ { MAD_F(0x05b0f02b) /* 0.355697795 */, 18 },
+ /* 5337 */ { MAD_F(0x05b14d5f) /* 0.355786677 */, 18 },
+ /* 5338 */ { MAD_F(0x05b1aa94) /* 0.355875566 */, 18 },
+ /* 5339 */ { MAD_F(0x05b207ca) /* 0.355964460 */, 18 },
+ /* 5340 */ { MAD_F(0x05b26502) /* 0.356053359 */, 18 },
+ /* 5341 */ { MAD_F(0x05b2c23b) /* 0.356142264 */, 18 },
+ /* 5342 */ { MAD_F(0x05b31f76) /* 0.356231175 */, 18 },
+ /* 5343 */ { MAD_F(0x05b37cb2) /* 0.356320091 */, 18 },
+
+ /* 5344 */ { MAD_F(0x05b3d9f0) /* 0.356409012 */, 18 },
+ /* 5345 */ { MAD_F(0x05b4372f) /* 0.356497940 */, 18 },
+ /* 5346 */ { MAD_F(0x05b4946f) /* 0.356586872 */, 18 },
+ /* 5347 */ { MAD_F(0x05b4f1b2) /* 0.356675811 */, 18 },
+ /* 5348 */ { MAD_F(0x05b54ef5) /* 0.356764754 */, 18 },
+ /* 5349 */ { MAD_F(0x05b5ac3a) /* 0.356853704 */, 18 },
+ /* 5350 */ { MAD_F(0x05b60981) /* 0.356942659 */, 18 },
+ /* 5351 */ { MAD_F(0x05b666c9) /* 0.357031619 */, 18 },
+ /* 5352 */ { MAD_F(0x05b6c413) /* 0.357120585 */, 18 },
+ /* 5353 */ { MAD_F(0x05b7215e) /* 0.357209557 */, 18 },
+ /* 5354 */ { MAD_F(0x05b77eab) /* 0.357298534 */, 18 },
+ /* 5355 */ { MAD_F(0x05b7dbf9) /* 0.357387516 */, 18 },
+ /* 5356 */ { MAD_F(0x05b83948) /* 0.357476504 */, 18 },
+ /* 5357 */ { MAD_F(0x05b89699) /* 0.357565498 */, 18 },
+ /* 5358 */ { MAD_F(0x05b8f3ec) /* 0.357654497 */, 18 },
+ /* 5359 */ { MAD_F(0x05b95140) /* 0.357743502 */, 18 },
+
+ /* 5360 */ { MAD_F(0x05b9ae95) /* 0.357832512 */, 18 },
+ /* 5361 */ { MAD_F(0x05ba0bec) /* 0.357921528 */, 18 },
+ /* 5362 */ { MAD_F(0x05ba6945) /* 0.358010550 */, 18 },
+ /* 5363 */ { MAD_F(0x05bac69f) /* 0.358099576 */, 18 },
+ /* 5364 */ { MAD_F(0x05bb23fa) /* 0.358188609 */, 18 },
+ /* 5365 */ { MAD_F(0x05bb8157) /* 0.358277647 */, 18 },
+ /* 5366 */ { MAD_F(0x05bbdeb6) /* 0.358366690 */, 18 },
+ /* 5367 */ { MAD_F(0x05bc3c16) /* 0.358455739 */, 18 },
+ /* 5368 */ { MAD_F(0x05bc9977) /* 0.358544794 */, 18 },
+ /* 5369 */ { MAD_F(0x05bcf6da) /* 0.358633854 */, 18 },
+ /* 5370 */ { MAD_F(0x05bd543e) /* 0.358722920 */, 18 },
+ /* 5371 */ { MAD_F(0x05bdb1a4) /* 0.358811991 */, 18 },
+ /* 5372 */ { MAD_F(0x05be0f0b) /* 0.358901067 */, 18 },
+ /* 5373 */ { MAD_F(0x05be6c74) /* 0.358990150 */, 18 },
+ /* 5374 */ { MAD_F(0x05bec9df) /* 0.359079237 */, 18 },
+ /* 5375 */ { MAD_F(0x05bf274a) /* 0.359168331 */, 18 },
+
+ /* 5376 */ { MAD_F(0x05bf84b8) /* 0.359257429 */, 18 },
+ /* 5377 */ { MAD_F(0x05bfe226) /* 0.359346534 */, 18 },
+ /* 5378 */ { MAD_F(0x05c03f97) /* 0.359435644 */, 18 },
+ /* 5379 */ { MAD_F(0x05c09d08) /* 0.359524759 */, 18 },
+ /* 5380 */ { MAD_F(0x05c0fa7c) /* 0.359613880 */, 18 },
+ /* 5381 */ { MAD_F(0x05c157f0) /* 0.359703006 */, 18 },
+ /* 5382 */ { MAD_F(0x05c1b566) /* 0.359792138 */, 18 },
+ /* 5383 */ { MAD_F(0x05c212de) /* 0.359881276 */, 18 },
+ /* 5384 */ { MAD_F(0x05c27057) /* 0.359970419 */, 18 },
+ /* 5385 */ { MAD_F(0x05c2cdd2) /* 0.360059567 */, 18 },
+ /* 5386 */ { MAD_F(0x05c32b4e) /* 0.360148721 */, 18 },
+ /* 5387 */ { MAD_F(0x05c388cb) /* 0.360237881 */, 18 },
+ /* 5388 */ { MAD_F(0x05c3e64b) /* 0.360327046 */, 18 },
+ /* 5389 */ { MAD_F(0x05c443cb) /* 0.360416216 */, 18 },
+ /* 5390 */ { MAD_F(0x05c4a14d) /* 0.360505392 */, 18 },
+ /* 5391 */ { MAD_F(0x05c4fed1) /* 0.360594574 */, 18 },
+
+ /* 5392 */ { MAD_F(0x05c55c56) /* 0.360683761 */, 18 },
+ /* 5393 */ { MAD_F(0x05c5b9dc) /* 0.360772953 */, 18 },
+ /* 5394 */ { MAD_F(0x05c61764) /* 0.360862152 */, 18 },
+ /* 5395 */ { MAD_F(0x05c674ed) /* 0.360951355 */, 18 },
+ /* 5396 */ { MAD_F(0x05c6d278) /* 0.361040564 */, 18 },
+ /* 5397 */ { MAD_F(0x05c73005) /* 0.361129779 */, 18 },
+ /* 5398 */ { MAD_F(0x05c78d93) /* 0.361218999 */, 18 },
+ /* 5399 */ { MAD_F(0x05c7eb22) /* 0.361308225 */, 18 },
+ /* 5400 */ { MAD_F(0x05c848b3) /* 0.361397456 */, 18 },
+ /* 5401 */ { MAD_F(0x05c8a645) /* 0.361486693 */, 18 },
+ /* 5402 */ { MAD_F(0x05c903d9) /* 0.361575935 */, 18 },
+ /* 5403 */ { MAD_F(0x05c9616e) /* 0.361665183 */, 18 },
+ /* 5404 */ { MAD_F(0x05c9bf05) /* 0.361754436 */, 18 },
+ /* 5405 */ { MAD_F(0x05ca1c9d) /* 0.361843695 */, 18 },
+ /* 5406 */ { MAD_F(0x05ca7a37) /* 0.361932959 */, 18 },
+ /* 5407 */ { MAD_F(0x05cad7d2) /* 0.362022229 */, 18 },
+
+ /* 5408 */ { MAD_F(0x05cb356e) /* 0.362111504 */, 18 },
+ /* 5409 */ { MAD_F(0x05cb930d) /* 0.362200785 */, 18 },
+ /* 5410 */ { MAD_F(0x05cbf0ac) /* 0.362290071 */, 18 },
+ /* 5411 */ { MAD_F(0x05cc4e4d) /* 0.362379362 */, 18 },
+ /* 5412 */ { MAD_F(0x05ccabf0) /* 0.362468660 */, 18 },
+ /* 5413 */ { MAD_F(0x05cd0994) /* 0.362557962 */, 18 },
+ /* 5414 */ { MAD_F(0x05cd6739) /* 0.362647271 */, 18 },
+ /* 5415 */ { MAD_F(0x05cdc4e0) /* 0.362736584 */, 18 },
+ /* 5416 */ { MAD_F(0x05ce2289) /* 0.362825904 */, 18 },
+ /* 5417 */ { MAD_F(0x05ce8033) /* 0.362915228 */, 18 },
+ /* 5418 */ { MAD_F(0x05ceddde) /* 0.363004559 */, 18 },
+ /* 5419 */ { MAD_F(0x05cf3b8b) /* 0.363093894 */, 18 },
+ /* 5420 */ { MAD_F(0x05cf9939) /* 0.363183236 */, 18 },
+ /* 5421 */ { MAD_F(0x05cff6e9) /* 0.363272582 */, 18 },
+ /* 5422 */ { MAD_F(0x05d0549a) /* 0.363361935 */, 18 },
+ /* 5423 */ { MAD_F(0x05d0b24d) /* 0.363451292 */, 18 },
+
+ /* 5424 */ { MAD_F(0x05d11001) /* 0.363540655 */, 18 },
+ /* 5425 */ { MAD_F(0x05d16db7) /* 0.363630024 */, 18 },
+ /* 5426 */ { MAD_F(0x05d1cb6e) /* 0.363719398 */, 18 },
+ /* 5427 */ { MAD_F(0x05d22927) /* 0.363808778 */, 18 },
+ /* 5428 */ { MAD_F(0x05d286e1) /* 0.363898163 */, 18 },
+ /* 5429 */ { MAD_F(0x05d2e49d) /* 0.363987554 */, 18 },
+ /* 5430 */ { MAD_F(0x05d3425a) /* 0.364076950 */, 18 },
+ /* 5431 */ { MAD_F(0x05d3a018) /* 0.364166352 */, 18 },
+ /* 5432 */ { MAD_F(0x05d3fdd8) /* 0.364255759 */, 18 },
+ /* 5433 */ { MAD_F(0x05d45b9a) /* 0.364345171 */, 18 },
+ /* 5434 */ { MAD_F(0x05d4b95d) /* 0.364434589 */, 18 },
+ /* 5435 */ { MAD_F(0x05d51721) /* 0.364524013 */, 18 },
+ /* 5436 */ { MAD_F(0x05d574e7) /* 0.364613442 */, 18 },
+ /* 5437 */ { MAD_F(0x05d5d2af) /* 0.364702877 */, 18 },
+ /* 5438 */ { MAD_F(0x05d63078) /* 0.364792317 */, 18 },
+ /* 5439 */ { MAD_F(0x05d68e42) /* 0.364881762 */, 18 },
+
+ /* 5440 */ { MAD_F(0x05d6ec0e) /* 0.364971213 */, 18 },
+ /* 5441 */ { MAD_F(0x05d749db) /* 0.365060669 */, 18 },
+ /* 5442 */ { MAD_F(0x05d7a7aa) /* 0.365150131 */, 18 },
+ /* 5443 */ { MAD_F(0x05d8057a) /* 0.365239599 */, 18 },
+ /* 5444 */ { MAD_F(0x05d8634c) /* 0.365329072 */, 18 },
+ /* 5445 */ { MAD_F(0x05d8c11f) /* 0.365418550 */, 18 },
+ /* 5446 */ { MAD_F(0x05d91ef4) /* 0.365508034 */, 18 },
+ /* 5447 */ { MAD_F(0x05d97cca) /* 0.365597523 */, 18 },
+ /* 5448 */ { MAD_F(0x05d9daa1) /* 0.365687018 */, 18 },
+ /* 5449 */ { MAD_F(0x05da387a) /* 0.365776518 */, 18 },
+ /* 5450 */ { MAD_F(0x05da9655) /* 0.365866024 */, 18 },
+ /* 5451 */ { MAD_F(0x05daf431) /* 0.365955536 */, 18 },
+ /* 5452 */ { MAD_F(0x05db520e) /* 0.366045052 */, 18 },
+ /* 5453 */ { MAD_F(0x05dbafed) /* 0.366134574 */, 18 },
+ /* 5454 */ { MAD_F(0x05dc0dce) /* 0.366224102 */, 18 },
+ /* 5455 */ { MAD_F(0x05dc6baf) /* 0.366313635 */, 18 },
+
+ /* 5456 */ { MAD_F(0x05dcc993) /* 0.366403174 */, 18 },
+ /* 5457 */ { MAD_F(0x05dd2778) /* 0.366492718 */, 18 },
+ /* 5458 */ { MAD_F(0x05dd855e) /* 0.366582267 */, 18 },
+ /* 5459 */ { MAD_F(0x05dde346) /* 0.366671822 */, 18 },
+ /* 5460 */ { MAD_F(0x05de412f) /* 0.366761383 */, 18 },
+ /* 5461 */ { MAD_F(0x05de9f1a) /* 0.366850949 */, 18 },
+ /* 5462 */ { MAD_F(0x05defd06) /* 0.366940520 */, 18 },
+ /* 5463 */ { MAD_F(0x05df5af3) /* 0.367030097 */, 18 },
+ /* 5464 */ { MAD_F(0x05dfb8e2) /* 0.367119680 */, 18 },
+ /* 5465 */ { MAD_F(0x05e016d3) /* 0.367209267 */, 18 },
+ /* 5466 */ { MAD_F(0x05e074c5) /* 0.367298861 */, 18 },
+ /* 5467 */ { MAD_F(0x05e0d2b8) /* 0.367388459 */, 18 },
+ /* 5468 */ { MAD_F(0x05e130ad) /* 0.367478064 */, 18 },
+ /* 5469 */ { MAD_F(0x05e18ea4) /* 0.367567673 */, 18 },
+ /* 5470 */ { MAD_F(0x05e1ec9c) /* 0.367657288 */, 18 },
+ /* 5471 */ { MAD_F(0x05e24a95) /* 0.367746909 */, 18 },
+
+ /* 5472 */ { MAD_F(0x05e2a890) /* 0.367836535 */, 18 },
+ /* 5473 */ { MAD_F(0x05e3068c) /* 0.367926167 */, 18 },
+ /* 5474 */ { MAD_F(0x05e3648a) /* 0.368015804 */, 18 },
+ /* 5475 */ { MAD_F(0x05e3c289) /* 0.368105446 */, 18 },
+ /* 5476 */ { MAD_F(0x05e4208a) /* 0.368195094 */, 18 },
+ /* 5477 */ { MAD_F(0x05e47e8c) /* 0.368284747 */, 18 },
+ /* 5478 */ { MAD_F(0x05e4dc8f) /* 0.368374406 */, 18 },
+ /* 5479 */ { MAD_F(0x05e53a94) /* 0.368464070 */, 18 },
+ /* 5480 */ { MAD_F(0x05e5989b) /* 0.368553740 */, 18 },
+ /* 5481 */ { MAD_F(0x05e5f6a3) /* 0.368643415 */, 18 },
+ /* 5482 */ { MAD_F(0x05e654ac) /* 0.368733096 */, 18 },
+ /* 5483 */ { MAD_F(0x05e6b2b7) /* 0.368822782 */, 18 },
+ /* 5484 */ { MAD_F(0x05e710c4) /* 0.368912473 */, 18 },
+ /* 5485 */ { MAD_F(0x05e76ed2) /* 0.369002170 */, 18 },
+ /* 5486 */ { MAD_F(0x05e7cce1) /* 0.369091873 */, 18 },
+ /* 5487 */ { MAD_F(0x05e82af2) /* 0.369181581 */, 18 },
+
+ /* 5488 */ { MAD_F(0x05e88904) /* 0.369271294 */, 18 },
+ /* 5489 */ { MAD_F(0x05e8e718) /* 0.369361013 */, 18 },
+ /* 5490 */ { MAD_F(0x05e9452d) /* 0.369450737 */, 18 },
+ /* 5491 */ { MAD_F(0x05e9a343) /* 0.369540467 */, 18 },
+ /* 5492 */ { MAD_F(0x05ea015c) /* 0.369630202 */, 18 },
+ /* 5493 */ { MAD_F(0x05ea5f75) /* 0.369719942 */, 18 },
+ /* 5494 */ { MAD_F(0x05eabd90) /* 0.369809688 */, 18 },
+ /* 5495 */ { MAD_F(0x05eb1bad) /* 0.369899440 */, 18 },
+ /* 5496 */ { MAD_F(0x05eb79cb) /* 0.369989197 */, 18 },
+ /* 5497 */ { MAD_F(0x05ebd7ea) /* 0.370078959 */, 18 },
+ /* 5498 */ { MAD_F(0x05ec360b) /* 0.370168727 */, 18 },
+ /* 5499 */ { MAD_F(0x05ec942d) /* 0.370258500 */, 18 },
+ /* 5500 */ { MAD_F(0x05ecf251) /* 0.370348279 */, 18 },
+ /* 5501 */ { MAD_F(0x05ed5076) /* 0.370438063 */, 18 },
+ /* 5502 */ { MAD_F(0x05edae9d) /* 0.370527853 */, 18 },
+ /* 5503 */ { MAD_F(0x05ee0cc5) /* 0.370617648 */, 18 },
+
+ /* 5504 */ { MAD_F(0x05ee6aef) /* 0.370707448 */, 18 },
+ /* 5505 */ { MAD_F(0x05eec91a) /* 0.370797254 */, 18 },
+ /* 5506 */ { MAD_F(0x05ef2746) /* 0.370887065 */, 18 },
+ /* 5507 */ { MAD_F(0x05ef8574) /* 0.370976882 */, 18 },
+ /* 5508 */ { MAD_F(0x05efe3a4) /* 0.371066704 */, 18 },
+ /* 5509 */ { MAD_F(0x05f041d5) /* 0.371156532 */, 18 },
+ /* 5510 */ { MAD_F(0x05f0a007) /* 0.371246365 */, 18 },
+ /* 5511 */ { MAD_F(0x05f0fe3b) /* 0.371336203 */, 18 },
+ /* 5512 */ { MAD_F(0x05f15c70) /* 0.371426047 */, 18 },
+ /* 5513 */ { MAD_F(0x05f1baa7) /* 0.371515897 */, 18 },
+ /* 5514 */ { MAD_F(0x05f218df) /* 0.371605751 */, 18 },
+ /* 5515 */ { MAD_F(0x05f27719) /* 0.371695612 */, 18 },
+ /* 5516 */ { MAD_F(0x05f2d554) /* 0.371785477 */, 18 },
+ /* 5517 */ { MAD_F(0x05f33390) /* 0.371875348 */, 18 },
+ /* 5518 */ { MAD_F(0x05f391cf) /* 0.371965225 */, 18 },
+ /* 5519 */ { MAD_F(0x05f3f00e) /* 0.372055107 */, 18 },
+
+ /* 5520 */ { MAD_F(0x05f44e4f) /* 0.372144994 */, 18 },
+ /* 5521 */ { MAD_F(0x05f4ac91) /* 0.372234887 */, 18 },
+ /* 5522 */ { MAD_F(0x05f50ad5) /* 0.372324785 */, 18 },
+ /* 5523 */ { MAD_F(0x05f5691b) /* 0.372414689 */, 18 },
+ /* 5524 */ { MAD_F(0x05f5c761) /* 0.372504598 */, 18 },
+ /* 5525 */ { MAD_F(0x05f625aa) /* 0.372594513 */, 18 },
+ /* 5526 */ { MAD_F(0x05f683f3) /* 0.372684433 */, 18 },
+ /* 5527 */ { MAD_F(0x05f6e23f) /* 0.372774358 */, 18 },
+ /* 5528 */ { MAD_F(0x05f7408b) /* 0.372864289 */, 18 },
+ /* 5529 */ { MAD_F(0x05f79ed9) /* 0.372954225 */, 18 },
+ /* 5530 */ { MAD_F(0x05f7fd29) /* 0.373044167 */, 18 },
+ /* 5531 */ { MAD_F(0x05f85b7a) /* 0.373134114 */, 18 },
+ /* 5532 */ { MAD_F(0x05f8b9cc) /* 0.373224066 */, 18 },
+ /* 5533 */ { MAD_F(0x05f91820) /* 0.373314024 */, 18 },
+ /* 5534 */ { MAD_F(0x05f97675) /* 0.373403987 */, 18 },
+ /* 5535 */ { MAD_F(0x05f9d4cc) /* 0.373493956 */, 18 },
+
+ /* 5536 */ { MAD_F(0x05fa3324) /* 0.373583930 */, 18 },
+ /* 5537 */ { MAD_F(0x05fa917e) /* 0.373673910 */, 18 },
+ /* 5538 */ { MAD_F(0x05faefd9) /* 0.373763895 */, 18 },
+ /* 5539 */ { MAD_F(0x05fb4e36) /* 0.373853885 */, 18 },
+ /* 5540 */ { MAD_F(0x05fbac94) /* 0.373943881 */, 18 },
+ /* 5541 */ { MAD_F(0x05fc0af3) /* 0.374033882 */, 18 },
+ /* 5542 */ { MAD_F(0x05fc6954) /* 0.374123889 */, 18 },
+ /* 5543 */ { MAD_F(0x05fcc7b7) /* 0.374213901 */, 18 },
+ /* 5544 */ { MAD_F(0x05fd261b) /* 0.374303918 */, 18 },
+ /* 5545 */ { MAD_F(0x05fd8480) /* 0.374393941 */, 18 },
+ /* 5546 */ { MAD_F(0x05fde2e7) /* 0.374483970 */, 18 },
+ /* 5547 */ { MAD_F(0x05fe414f) /* 0.374574003 */, 18 },
+ /* 5548 */ { MAD_F(0x05fe9fb9) /* 0.374664042 */, 18 },
+ /* 5549 */ { MAD_F(0x05fefe24) /* 0.374754087 */, 18 },
+ /* 5550 */ { MAD_F(0x05ff5c91) /* 0.374844137 */, 18 },
+ /* 5551 */ { MAD_F(0x05ffbaff) /* 0.374934192 */, 18 },
+
+ /* 5552 */ { MAD_F(0x0600196e) /* 0.375024253 */, 18 },
+ /* 5553 */ { MAD_F(0x060077df) /* 0.375114319 */, 18 },
+ /* 5554 */ { MAD_F(0x0600d651) /* 0.375204391 */, 18 },
+ /* 5555 */ { MAD_F(0x060134c5) /* 0.375294468 */, 18 },
+ /* 5556 */ { MAD_F(0x0601933b) /* 0.375384550 */, 18 },
+ /* 5557 */ { MAD_F(0x0601f1b1) /* 0.375474638 */, 18 },
+ /* 5558 */ { MAD_F(0x0602502a) /* 0.375564731 */, 18 },
+ /* 5559 */ { MAD_F(0x0602aea3) /* 0.375654830 */, 18 },
+ /* 5560 */ { MAD_F(0x06030d1e) /* 0.375744934 */, 18 },
+ /* 5561 */ { MAD_F(0x06036b9b) /* 0.375835043 */, 18 },
+ /* 5562 */ { MAD_F(0x0603ca19) /* 0.375925158 */, 18 },
+ /* 5563 */ { MAD_F(0x06042898) /* 0.376015278 */, 18 },
+ /* 5564 */ { MAD_F(0x06048719) /* 0.376105404 */, 18 },
+ /* 5565 */ { MAD_F(0x0604e59c) /* 0.376195535 */, 18 },
+ /* 5566 */ { MAD_F(0x0605441f) /* 0.376285671 */, 18 },
+ /* 5567 */ { MAD_F(0x0605a2a5) /* 0.376375813 */, 18 },
+
+ /* 5568 */ { MAD_F(0x0606012b) /* 0.376465960 */, 18 },
+ /* 5569 */ { MAD_F(0x06065fb4) /* 0.376556113 */, 18 },
+ /* 5570 */ { MAD_F(0x0606be3d) /* 0.376646271 */, 18 },
+ /* 5571 */ { MAD_F(0x06071cc8) /* 0.376736434 */, 18 },
+ /* 5572 */ { MAD_F(0x06077b55) /* 0.376826603 */, 18 },
+ /* 5573 */ { MAD_F(0x0607d9e3) /* 0.376916777 */, 18 },
+ /* 5574 */ { MAD_F(0x06083872) /* 0.377006957 */, 18 },
+ /* 5575 */ { MAD_F(0x06089703) /* 0.377097141 */, 18 },
+ /* 5576 */ { MAD_F(0x0608f595) /* 0.377187332 */, 18 },
+ /* 5577 */ { MAD_F(0x06095429) /* 0.377277528 */, 18 },
+ /* 5578 */ { MAD_F(0x0609b2be) /* 0.377367729 */, 18 },
+ /* 5579 */ { MAD_F(0x060a1155) /* 0.377457935 */, 18 },
+ /* 5580 */ { MAD_F(0x060a6fed) /* 0.377548147 */, 18 },
+ /* 5581 */ { MAD_F(0x060ace86) /* 0.377638364 */, 18 },
+ /* 5582 */ { MAD_F(0x060b2d21) /* 0.377728587 */, 18 },
+ /* 5583 */ { MAD_F(0x060b8bbe) /* 0.377818815 */, 18 },
+
+ /* 5584 */ { MAD_F(0x060bea5c) /* 0.377909049 */, 18 },
+ /* 5585 */ { MAD_F(0x060c48fb) /* 0.377999288 */, 18 },
+ /* 5586 */ { MAD_F(0x060ca79c) /* 0.378089532 */, 18 },
+ /* 5587 */ { MAD_F(0x060d063e) /* 0.378179781 */, 18 },
+ /* 5588 */ { MAD_F(0x060d64e1) /* 0.378270036 */, 18 },
+ /* 5589 */ { MAD_F(0x060dc387) /* 0.378360297 */, 18 },
+ /* 5590 */ { MAD_F(0x060e222d) /* 0.378450563 */, 18 },
+ /* 5591 */ { MAD_F(0x060e80d5) /* 0.378540834 */, 18 },
+ /* 5592 */ { MAD_F(0x060edf7f) /* 0.378631110 */, 18 },
+ /* 5593 */ { MAD_F(0x060f3e29) /* 0.378721392 */, 18 },
+ /* 5594 */ { MAD_F(0x060f9cd6) /* 0.378811680 */, 18 },
+ /* 5595 */ { MAD_F(0x060ffb83) /* 0.378901972 */, 18 },
+ /* 5596 */ { MAD_F(0x06105a33) /* 0.378992270 */, 18 },
+ /* 5597 */ { MAD_F(0x0610b8e3) /* 0.379082574 */, 18 },
+ /* 5598 */ { MAD_F(0x06111795) /* 0.379172883 */, 18 },
+ /* 5599 */ { MAD_F(0x06117649) /* 0.379263197 */, 18 },
+
+ /* 5600 */ { MAD_F(0x0611d4fe) /* 0.379353516 */, 18 },
+ /* 5601 */ { MAD_F(0x061233b4) /* 0.379443841 */, 18 },
+ /* 5602 */ { MAD_F(0x0612926c) /* 0.379534172 */, 18 },
+ /* 5603 */ { MAD_F(0x0612f125) /* 0.379624507 */, 18 },
+ /* 5604 */ { MAD_F(0x06134fe0) /* 0.379714848 */, 18 },
+ /* 5605 */ { MAD_F(0x0613ae9c) /* 0.379805195 */, 18 },
+ /* 5606 */ { MAD_F(0x06140d5a) /* 0.379895547 */, 18 },
+ /* 5607 */ { MAD_F(0x06146c19) /* 0.379985904 */, 18 },
+ /* 5608 */ { MAD_F(0x0614cada) /* 0.380076266 */, 18 },
+ /* 5609 */ { MAD_F(0x0615299c) /* 0.380166634 */, 18 },
+ /* 5610 */ { MAD_F(0x0615885f) /* 0.380257008 */, 18 },
+ /* 5611 */ { MAD_F(0x0615e724) /* 0.380347386 */, 18 },
+ /* 5612 */ { MAD_F(0x061645ea) /* 0.380437770 */, 18 },
+ /* 5613 */ { MAD_F(0x0616a4b2) /* 0.380528160 */, 18 },
+ /* 5614 */ { MAD_F(0x0617037b) /* 0.380618555 */, 18 },
+ /* 5615 */ { MAD_F(0x06176246) /* 0.380708955 */, 18 },
+
+ /* 5616 */ { MAD_F(0x0617c112) /* 0.380799360 */, 18 },
+ /* 5617 */ { MAD_F(0x06181fdf) /* 0.380889771 */, 18 },
+ /* 5618 */ { MAD_F(0x06187eae) /* 0.380980187 */, 18 },
+ /* 5619 */ { MAD_F(0x0618dd7e) /* 0.381070609 */, 18 },
+ /* 5620 */ { MAD_F(0x06193c50) /* 0.381161036 */, 18 },
+ /* 5621 */ { MAD_F(0x06199b24) /* 0.381251468 */, 18 },
+ /* 5622 */ { MAD_F(0x0619f9f8) /* 0.381341906 */, 18 },
+ /* 5623 */ { MAD_F(0x061a58ce) /* 0.381432349 */, 18 },
+ /* 5624 */ { MAD_F(0x061ab7a6) /* 0.381522798 */, 18 },
+ /* 5625 */ { MAD_F(0x061b167f) /* 0.381613251 */, 18 },
+ /* 5626 */ { MAD_F(0x061b7559) /* 0.381703711 */, 18 },
+ /* 5627 */ { MAD_F(0x061bd435) /* 0.381794175 */, 18 },
+ /* 5628 */ { MAD_F(0x061c3313) /* 0.381884645 */, 18 },
+ /* 5629 */ { MAD_F(0x061c91f1) /* 0.381975120 */, 18 },
+ /* 5630 */ { MAD_F(0x061cf0d2) /* 0.382065601 */, 18 },
+ /* 5631 */ { MAD_F(0x061d4fb3) /* 0.382156087 */, 18 },
+
+ /* 5632 */ { MAD_F(0x061dae96) /* 0.382246578 */, 18 },
+ /* 5633 */ { MAD_F(0x061e0d7b) /* 0.382337075 */, 18 },
+ /* 5634 */ { MAD_F(0x061e6c61) /* 0.382427577 */, 18 },
+ /* 5635 */ { MAD_F(0x061ecb48) /* 0.382518084 */, 18 },
+ /* 5636 */ { MAD_F(0x061f2a31) /* 0.382608597 */, 18 },
+ /* 5637 */ { MAD_F(0x061f891b) /* 0.382699115 */, 18 },
+ /* 5638 */ { MAD_F(0x061fe807) /* 0.382789638 */, 18 },
+ /* 5639 */ { MAD_F(0x062046f4) /* 0.382880167 */, 18 },
+ /* 5640 */ { MAD_F(0x0620a5e3) /* 0.382970701 */, 18 },
+ /* 5641 */ { MAD_F(0x062104d3) /* 0.383061241 */, 18 },
+ /* 5642 */ { MAD_F(0x062163c4) /* 0.383151786 */, 18 },
+ /* 5643 */ { MAD_F(0x0621c2b7) /* 0.383242336 */, 18 },
+ /* 5644 */ { MAD_F(0x062221ab) /* 0.383332891 */, 18 },
+ /* 5645 */ { MAD_F(0x062280a1) /* 0.383423452 */, 18 },
+ /* 5646 */ { MAD_F(0x0622df98) /* 0.383514018 */, 18 },
+ /* 5647 */ { MAD_F(0x06233e91) /* 0.383604590 */, 18 },
+
+ /* 5648 */ { MAD_F(0x06239d8b) /* 0.383695167 */, 18 },
+ /* 5649 */ { MAD_F(0x0623fc86) /* 0.383785749 */, 18 },
+ /* 5650 */ { MAD_F(0x06245b83) /* 0.383876337 */, 18 },
+ /* 5651 */ { MAD_F(0x0624ba82) /* 0.383966930 */, 18 },
+ /* 5652 */ { MAD_F(0x06251981) /* 0.384057528 */, 18 },
+ /* 5653 */ { MAD_F(0x06257883) /* 0.384148132 */, 18 },
+ /* 5654 */ { MAD_F(0x0625d785) /* 0.384238741 */, 18 },
+ /* 5655 */ { MAD_F(0x06263689) /* 0.384329355 */, 18 },
+ /* 5656 */ { MAD_F(0x0626958f) /* 0.384419975 */, 18 },
+ /* 5657 */ { MAD_F(0x0626f496) /* 0.384510600 */, 18 },
+ /* 5658 */ { MAD_F(0x0627539e) /* 0.384601230 */, 18 },
+ /* 5659 */ { MAD_F(0x0627b2a8) /* 0.384691866 */, 18 },
+ /* 5660 */ { MAD_F(0x062811b3) /* 0.384782507 */, 18 },
+ /* 5661 */ { MAD_F(0x062870c0) /* 0.384873153 */, 18 },
+ /* 5662 */ { MAD_F(0x0628cfce) /* 0.384963805 */, 18 },
+ /* 5663 */ { MAD_F(0x06292ede) /* 0.385054462 */, 18 },
+
+ /* 5664 */ { MAD_F(0x06298def) /* 0.385145124 */, 18 },
+ /* 5665 */ { MAD_F(0x0629ed01) /* 0.385235792 */, 18 },
+ /* 5666 */ { MAD_F(0x062a4c15) /* 0.385326465 */, 18 },
+ /* 5667 */ { MAD_F(0x062aab2a) /* 0.385417143 */, 18 },
+ /* 5668 */ { MAD_F(0x062b0a41) /* 0.385507827 */, 18 },
+ /* 5669 */ { MAD_F(0x062b6959) /* 0.385598516 */, 18 },
+ /* 5670 */ { MAD_F(0x062bc873) /* 0.385689211 */, 18 },
+ /* 5671 */ { MAD_F(0x062c278e) /* 0.385779910 */, 18 },
+ /* 5672 */ { MAD_F(0x062c86aa) /* 0.385870615 */, 18 },
+ /* 5673 */ { MAD_F(0x062ce5c8) /* 0.385961326 */, 18 },
+ /* 5674 */ { MAD_F(0x062d44e8) /* 0.386052041 */, 18 },
+ /* 5675 */ { MAD_F(0x062da408) /* 0.386142762 */, 18 },
+ /* 5676 */ { MAD_F(0x062e032a) /* 0.386233489 */, 18 },
+ /* 5677 */ { MAD_F(0x062e624e) /* 0.386324221 */, 18 },
+ /* 5678 */ { MAD_F(0x062ec173) /* 0.386414958 */, 18 },
+ /* 5679 */ { MAD_F(0x062f209a) /* 0.386505700 */, 18 },
+
+ /* 5680 */ { MAD_F(0x062f7fc1) /* 0.386596448 */, 18 },
+ /* 5681 */ { MAD_F(0x062fdeeb) /* 0.386687201 */, 18 },
+ /* 5682 */ { MAD_F(0x06303e16) /* 0.386777959 */, 18 },
+ /* 5683 */ { MAD_F(0x06309d42) /* 0.386868723 */, 18 },
+ /* 5684 */ { MAD_F(0x0630fc6f) /* 0.386959492 */, 18 },
+ /* 5685 */ { MAD_F(0x06315b9e) /* 0.387050266 */, 18 },
+ /* 5686 */ { MAD_F(0x0631bacf) /* 0.387141045 */, 18 },
+ /* 5687 */ { MAD_F(0x06321a01) /* 0.387231830 */, 18 },
+ /* 5688 */ { MAD_F(0x06327934) /* 0.387322621 */, 18 },
+ /* 5689 */ { MAD_F(0x0632d869) /* 0.387413416 */, 18 },
+ /* 5690 */ { MAD_F(0x0633379f) /* 0.387504217 */, 18 },
+ /* 5691 */ { MAD_F(0x063396d7) /* 0.387595023 */, 18 },
+ /* 5692 */ { MAD_F(0x0633f610) /* 0.387685835 */, 18 },
+ /* 5693 */ { MAD_F(0x0634554a) /* 0.387776652 */, 18 },
+ /* 5694 */ { MAD_F(0x0634b486) /* 0.387867474 */, 18 },
+ /* 5695 */ { MAD_F(0x063513c3) /* 0.387958301 */, 18 },
+
+ /* 5696 */ { MAD_F(0x06357302) /* 0.388049134 */, 18 },
+ /* 5697 */ { MAD_F(0x0635d242) /* 0.388139972 */, 18 },
+ /* 5698 */ { MAD_F(0x06363184) /* 0.388230816 */, 18 },
+ /* 5699 */ { MAD_F(0x063690c7) /* 0.388321665 */, 18 },
+ /* 5700 */ { MAD_F(0x0636f00b) /* 0.388412519 */, 18 },
+ /* 5701 */ { MAD_F(0x06374f51) /* 0.388503378 */, 18 },
+ /* 5702 */ { MAD_F(0x0637ae99) /* 0.388594243 */, 18 },
+ /* 5703 */ { MAD_F(0x06380de1) /* 0.388685113 */, 18 },
+ /* 5704 */ { MAD_F(0x06386d2b) /* 0.388775988 */, 18 },
+ /* 5705 */ { MAD_F(0x0638cc77) /* 0.388866869 */, 18 },
+ /* 5706 */ { MAD_F(0x06392bc4) /* 0.388957755 */, 18 },
+ /* 5707 */ { MAD_F(0x06398b12) /* 0.389048646 */, 18 },
+ /* 5708 */ { MAD_F(0x0639ea62) /* 0.389139542 */, 18 },
+ /* 5709 */ { MAD_F(0x063a49b4) /* 0.389230444 */, 18 },
+ /* 5710 */ { MAD_F(0x063aa906) /* 0.389321352 */, 18 },
+ /* 5711 */ { MAD_F(0x063b085a) /* 0.389412264 */, 18 },
+
+ /* 5712 */ { MAD_F(0x063b67b0) /* 0.389503182 */, 18 },
+ /* 5713 */ { MAD_F(0x063bc707) /* 0.389594105 */, 18 },
+ /* 5714 */ { MAD_F(0x063c265f) /* 0.389685033 */, 18 },
+ /* 5715 */ { MAD_F(0x063c85b9) /* 0.389775967 */, 18 },
+ /* 5716 */ { MAD_F(0x063ce514) /* 0.389866906 */, 18 },
+ /* 5717 */ { MAD_F(0x063d4471) /* 0.389957850 */, 18 },
+ /* 5718 */ { MAD_F(0x063da3cf) /* 0.390048800 */, 18 },
+ /* 5719 */ { MAD_F(0x063e032f) /* 0.390139755 */, 18 },
+ /* 5720 */ { MAD_F(0x063e6290) /* 0.390230715 */, 18 },
+ /* 5721 */ { MAD_F(0x063ec1f2) /* 0.390321681 */, 18 },
+ /* 5722 */ { MAD_F(0x063f2156) /* 0.390412651 */, 18 },
+ /* 5723 */ { MAD_F(0x063f80bb) /* 0.390503628 */, 18 },
+ /* 5724 */ { MAD_F(0x063fe022) /* 0.390594609 */, 18 },
+ /* 5725 */ { MAD_F(0x06403f8a) /* 0.390685596 */, 18 },
+ /* 5726 */ { MAD_F(0x06409ef3) /* 0.390776588 */, 18 },
+ /* 5727 */ { MAD_F(0x0640fe5e) /* 0.390867585 */, 18 },
+
+ /* 5728 */ { MAD_F(0x06415dcb) /* 0.390958588 */, 18 },
+ /* 5729 */ { MAD_F(0x0641bd38) /* 0.391049596 */, 18 },
+ /* 5730 */ { MAD_F(0x06421ca7) /* 0.391140609 */, 18 },
+ /* 5731 */ { MAD_F(0x06427c18) /* 0.391231627 */, 18 },
+ /* 5732 */ { MAD_F(0x0642db8a) /* 0.391322651 */, 18 },
+ /* 5733 */ { MAD_F(0x06433afd) /* 0.391413680 */, 18 },
+ /* 5734 */ { MAD_F(0x06439a72) /* 0.391504714 */, 18 },
+ /* 5735 */ { MAD_F(0x0643f9e9) /* 0.391595754 */, 18 },
+ /* 5736 */ { MAD_F(0x06445960) /* 0.391686799 */, 18 },
+ /* 5737 */ { MAD_F(0x0644b8d9) /* 0.391777849 */, 18 },
+ /* 5738 */ { MAD_F(0x06451854) /* 0.391868905 */, 18 },
+ /* 5739 */ { MAD_F(0x064577d0) /* 0.391959966 */, 18 },
+ /* 5740 */ { MAD_F(0x0645d74d) /* 0.392051032 */, 18 },
+ /* 5741 */ { MAD_F(0x064636cc) /* 0.392142103 */, 18 },
+ /* 5742 */ { MAD_F(0x0646964c) /* 0.392233180 */, 18 },
+ /* 5743 */ { MAD_F(0x0646f5ce) /* 0.392324262 */, 18 },
+
+ /* 5744 */ { MAD_F(0x06475551) /* 0.392415349 */, 18 },
+ /* 5745 */ { MAD_F(0x0647b4d5) /* 0.392506442 */, 18 },
+ /* 5746 */ { MAD_F(0x0648145b) /* 0.392597540 */, 18 },
+ /* 5747 */ { MAD_F(0x064873e3) /* 0.392688643 */, 18 },
+ /* 5748 */ { MAD_F(0x0648d36b) /* 0.392779751 */, 18 },
+ /* 5749 */ { MAD_F(0x064932f6) /* 0.392870865 */, 18 },
+ /* 5750 */ { MAD_F(0x06499281) /* 0.392961984 */, 18 },
+ /* 5751 */ { MAD_F(0x0649f20e) /* 0.393053108 */, 18 },
+ /* 5752 */ { MAD_F(0x064a519c) /* 0.393144238 */, 18 },
+ /* 5753 */ { MAD_F(0x064ab12c) /* 0.393235372 */, 18 },
+ /* 5754 */ { MAD_F(0x064b10be) /* 0.393326513 */, 18 },
+ /* 5755 */ { MAD_F(0x064b7050) /* 0.393417658 */, 18 },
+ /* 5756 */ { MAD_F(0x064bcfe4) /* 0.393508809 */, 18 },
+ /* 5757 */ { MAD_F(0x064c2f7a) /* 0.393599965 */, 18 },
+ /* 5758 */ { MAD_F(0x064c8f11) /* 0.393691126 */, 18 },
+ /* 5759 */ { MAD_F(0x064ceea9) /* 0.393782292 */, 18 },
+
+ /* 5760 */ { MAD_F(0x064d4e43) /* 0.393873464 */, 18 },
+ /* 5761 */ { MAD_F(0x064dadde) /* 0.393964641 */, 18 },
+ /* 5762 */ { MAD_F(0x064e0d7a) /* 0.394055823 */, 18 },
+ /* 5763 */ { MAD_F(0x064e6d18) /* 0.394147011 */, 18 },
+ /* 5764 */ { MAD_F(0x064eccb8) /* 0.394238204 */, 18 },
+ /* 5765 */ { MAD_F(0x064f2c59) /* 0.394329402 */, 18 },
+ /* 5766 */ { MAD_F(0x064f8bfb) /* 0.394420605 */, 18 },
+ /* 5767 */ { MAD_F(0x064feb9e) /* 0.394511814 */, 18 },
+ /* 5768 */ { MAD_F(0x06504b44) /* 0.394603028 */, 18 },
+ /* 5769 */ { MAD_F(0x0650aaea) /* 0.394694247 */, 18 },
+ /* 5770 */ { MAD_F(0x06510a92) /* 0.394785472 */, 18 },
+ /* 5771 */ { MAD_F(0x06516a3b) /* 0.394876702 */, 18 },
+ /* 5772 */ { MAD_F(0x0651c9e6) /* 0.394967937 */, 18 },
+ /* 5773 */ { MAD_F(0x06522992) /* 0.395059177 */, 18 },
+ /* 5774 */ { MAD_F(0x06528940) /* 0.395150423 */, 18 },
+ /* 5775 */ { MAD_F(0x0652e8ef) /* 0.395241673 */, 18 },
+
+ /* 5776 */ { MAD_F(0x0653489f) /* 0.395332930 */, 18 },
+ /* 5777 */ { MAD_F(0x0653a851) /* 0.395424191 */, 18 },
+ /* 5778 */ { MAD_F(0x06540804) /* 0.395515458 */, 18 },
+ /* 5779 */ { MAD_F(0x065467b9) /* 0.395606730 */, 18 },
+ /* 5780 */ { MAD_F(0x0654c76f) /* 0.395698007 */, 18 },
+ /* 5781 */ { MAD_F(0x06552726) /* 0.395789289 */, 18 },
+ /* 5782 */ { MAD_F(0x065586df) /* 0.395880577 */, 18 },
+ /* 5783 */ { MAD_F(0x0655e699) /* 0.395971870 */, 18 },
+ /* 5784 */ { MAD_F(0x06564655) /* 0.396063168 */, 18 },
+ /* 5785 */ { MAD_F(0x0656a612) /* 0.396154472 */, 18 },
+ /* 5786 */ { MAD_F(0x065705d0) /* 0.396245780 */, 18 },
+ /* 5787 */ { MAD_F(0x06576590) /* 0.396337094 */, 18 },
+ /* 5788 */ { MAD_F(0x0657c552) /* 0.396428414 */, 18 },
+ /* 5789 */ { MAD_F(0x06582514) /* 0.396519738 */, 18 },
+ /* 5790 */ { MAD_F(0x065884d9) /* 0.396611068 */, 18 },
+ /* 5791 */ { MAD_F(0x0658e49e) /* 0.396702403 */, 18 },
+
+ /* 5792 */ { MAD_F(0x06594465) /* 0.396793743 */, 18 },
+ /* 5793 */ { MAD_F(0x0659a42e) /* 0.396885089 */, 18 },
+ /* 5794 */ { MAD_F(0x065a03f7) /* 0.396976440 */, 18 },
+ /* 5795 */ { MAD_F(0x065a63c3) /* 0.397067796 */, 18 },
+ /* 5796 */ { MAD_F(0x065ac38f) /* 0.397159157 */, 18 },
+ /* 5797 */ { MAD_F(0x065b235d) /* 0.397250524 */, 18 },
+ /* 5798 */ { MAD_F(0x065b832d) /* 0.397341896 */, 18 },
+ /* 5799 */ { MAD_F(0x065be2fe) /* 0.397433273 */, 18 },
+ /* 5800 */ { MAD_F(0x065c42d0) /* 0.397524655 */, 18 },
+ /* 5801 */ { MAD_F(0x065ca2a3) /* 0.397616043 */, 18 },
+ /* 5802 */ { MAD_F(0x065d0279) /* 0.397707436 */, 18 },
+ /* 5803 */ { MAD_F(0x065d624f) /* 0.397798834 */, 18 },
+ /* 5804 */ { MAD_F(0x065dc227) /* 0.397890237 */, 18 },
+ /* 5805 */ { MAD_F(0x065e2200) /* 0.397981646 */, 18 },
+ /* 5806 */ { MAD_F(0x065e81db) /* 0.398073059 */, 18 },
+ /* 5807 */ { MAD_F(0x065ee1b7) /* 0.398164479 */, 18 },
+
+ /* 5808 */ { MAD_F(0x065f4195) /* 0.398255903 */, 18 },
+ /* 5809 */ { MAD_F(0x065fa174) /* 0.398347333 */, 18 },
+ /* 5810 */ { MAD_F(0x06600154) /* 0.398438767 */, 18 },
+ /* 5811 */ { MAD_F(0x06606136) /* 0.398530207 */, 18 },
+ /* 5812 */ { MAD_F(0x0660c119) /* 0.398621653 */, 18 },
+ /* 5813 */ { MAD_F(0x066120fd) /* 0.398713103 */, 18 },
+ /* 5814 */ { MAD_F(0x066180e3) /* 0.398804559 */, 18 },
+ /* 5815 */ { MAD_F(0x0661e0cb) /* 0.398896020 */, 18 },
+ /* 5816 */ { MAD_F(0x066240b4) /* 0.398987487 */, 18 },
+ /* 5817 */ { MAD_F(0x0662a09e) /* 0.399078958 */, 18 },
+ /* 5818 */ { MAD_F(0x06630089) /* 0.399170435 */, 18 },
+ /* 5819 */ { MAD_F(0x06636077) /* 0.399261917 */, 18 },
+ /* 5820 */ { MAD_F(0x0663c065) /* 0.399353404 */, 18 },
+ /* 5821 */ { MAD_F(0x06642055) /* 0.399444897 */, 18 },
+ /* 5822 */ { MAD_F(0x06648046) /* 0.399536395 */, 18 },
+ /* 5823 */ { MAD_F(0x0664e039) /* 0.399627898 */, 18 },
+
+ /* 5824 */ { MAD_F(0x0665402d) /* 0.399719406 */, 18 },
+ /* 5825 */ { MAD_F(0x0665a022) /* 0.399810919 */, 18 },
+ /* 5826 */ { MAD_F(0x06660019) /* 0.399902438 */, 18 },
+ /* 5827 */ { MAD_F(0x06666011) /* 0.399993962 */, 18 },
+ /* 5828 */ { MAD_F(0x0666c00b) /* 0.400085491 */, 18 },
+ /* 5829 */ { MAD_F(0x06672006) /* 0.400177026 */, 18 },
+ /* 5830 */ { MAD_F(0x06678003) /* 0.400268565 */, 18 },
+ /* 5831 */ { MAD_F(0x0667e000) /* 0.400360110 */, 18 },
+ /* 5832 */ { MAD_F(0x06684000) /* 0.400451660 */, 18 },
+ /* 5833 */ { MAD_F(0x0668a000) /* 0.400543216 */, 18 },
+ /* 5834 */ { MAD_F(0x06690003) /* 0.400634776 */, 18 },
+ /* 5835 */ { MAD_F(0x06696006) /* 0.400726342 */, 18 },
+ /* 5836 */ { MAD_F(0x0669c00b) /* 0.400817913 */, 18 },
+ /* 5837 */ { MAD_F(0x066a2011) /* 0.400909489 */, 18 },
+ /* 5838 */ { MAD_F(0x066a8019) /* 0.401001071 */, 18 },
+ /* 5839 */ { MAD_F(0x066ae022) /* 0.401092657 */, 18 },
+
+ /* 5840 */ { MAD_F(0x066b402d) /* 0.401184249 */, 18 },
+ /* 5841 */ { MAD_F(0x066ba039) /* 0.401275847 */, 18 },
+ /* 5842 */ { MAD_F(0x066c0046) /* 0.401367449 */, 18 },
+ /* 5843 */ { MAD_F(0x066c6055) /* 0.401459057 */, 18 },
+ /* 5844 */ { MAD_F(0x066cc065) /* 0.401550670 */, 18 },
+ /* 5845 */ { MAD_F(0x066d2076) /* 0.401642288 */, 18 },
+ /* 5846 */ { MAD_F(0x066d8089) /* 0.401733911 */, 18 },
+ /* 5847 */ { MAD_F(0x066de09e) /* 0.401825540 */, 18 },
+ /* 5848 */ { MAD_F(0x066e40b3) /* 0.401917173 */, 18 },
+ /* 5849 */ { MAD_F(0x066ea0cb) /* 0.402008812 */, 18 },
+ /* 5850 */ { MAD_F(0x066f00e3) /* 0.402100457 */, 18 },
+ /* 5851 */ { MAD_F(0x066f60fd) /* 0.402192106 */, 18 },
+ /* 5852 */ { MAD_F(0x066fc118) /* 0.402283761 */, 18 },
+ /* 5853 */ { MAD_F(0x06702135) /* 0.402375420 */, 18 },
+ /* 5854 */ { MAD_F(0x06708153) /* 0.402467086 */, 18 },
+ /* 5855 */ { MAD_F(0x0670e173) /* 0.402558756 */, 18 },
+
+ /* 5856 */ { MAD_F(0x06714194) /* 0.402650431 */, 18 },
+ /* 5857 */ { MAD_F(0x0671a1b6) /* 0.402742112 */, 18 },
+ /* 5858 */ { MAD_F(0x067201da) /* 0.402833798 */, 18 },
+ /* 5859 */ { MAD_F(0x067261ff) /* 0.402925489 */, 18 },
+ /* 5860 */ { MAD_F(0x0672c226) /* 0.403017186 */, 18 },
+ /* 5861 */ { MAD_F(0x0673224e) /* 0.403108887 */, 18 },
+ /* 5862 */ { MAD_F(0x06738277) /* 0.403200594 */, 18 },
+ /* 5863 */ { MAD_F(0x0673e2a2) /* 0.403292306 */, 18 },
+ /* 5864 */ { MAD_F(0x067442ce) /* 0.403384024 */, 18 },
+ /* 5865 */ { MAD_F(0x0674a2fc) /* 0.403475746 */, 18 },
+ /* 5866 */ { MAD_F(0x0675032b) /* 0.403567474 */, 18 },
+ /* 5867 */ { MAD_F(0x0675635b) /* 0.403659207 */, 18 },
+ /* 5868 */ { MAD_F(0x0675c38d) /* 0.403750945 */, 18 },
+ /* 5869 */ { MAD_F(0x067623c0) /* 0.403842688 */, 18 },
+ /* 5870 */ { MAD_F(0x067683f4) /* 0.403934437 */, 18 },
+ /* 5871 */ { MAD_F(0x0676e42a) /* 0.404026190 */, 18 },
+
+ /* 5872 */ { MAD_F(0x06774462) /* 0.404117949 */, 18 },
+ /* 5873 */ { MAD_F(0x0677a49b) /* 0.404209714 */, 18 },
+ /* 5874 */ { MAD_F(0x067804d5) /* 0.404301483 */, 18 },
+ /* 5875 */ { MAD_F(0x06786510) /* 0.404393258 */, 18 },
+ /* 5876 */ { MAD_F(0x0678c54d) /* 0.404485037 */, 18 },
+ /* 5877 */ { MAD_F(0x0679258c) /* 0.404576822 */, 18 },
+ /* 5878 */ { MAD_F(0x067985cb) /* 0.404668613 */, 18 },
+ /* 5879 */ { MAD_F(0x0679e60c) /* 0.404760408 */, 18 },
+ /* 5880 */ { MAD_F(0x067a464f) /* 0.404852209 */, 18 },
+ /* 5881 */ { MAD_F(0x067aa693) /* 0.404944014 */, 18 },
+ /* 5882 */ { MAD_F(0x067b06d8) /* 0.405035825 */, 18 },
+ /* 5883 */ { MAD_F(0x067b671f) /* 0.405127642 */, 18 },
+ /* 5884 */ { MAD_F(0x067bc767) /* 0.405219463 */, 18 },
+ /* 5885 */ { MAD_F(0x067c27b1) /* 0.405311290 */, 18 },
+ /* 5886 */ { MAD_F(0x067c87fc) /* 0.405403122 */, 18 },
+ /* 5887 */ { MAD_F(0x067ce848) /* 0.405494959 */, 18 },
+
+ /* 5888 */ { MAD_F(0x067d4896) /* 0.405586801 */, 18 },
+ /* 5889 */ { MAD_F(0x067da8e5) /* 0.405678648 */, 18 },
+ /* 5890 */ { MAD_F(0x067e0935) /* 0.405770501 */, 18 },
+ /* 5891 */ { MAD_F(0x067e6987) /* 0.405862359 */, 18 },
+ /* 5892 */ { MAD_F(0x067ec9da) /* 0.405954222 */, 18 },
+ /* 5893 */ { MAD_F(0x067f2a2f) /* 0.406046090 */, 18 },
+ /* 5894 */ { MAD_F(0x067f8a85) /* 0.406137963 */, 18 },
+ /* 5895 */ { MAD_F(0x067feadd) /* 0.406229842 */, 18 },
+ /* 5896 */ { MAD_F(0x06804b36) /* 0.406321726 */, 18 },
+ /* 5897 */ { MAD_F(0x0680ab90) /* 0.406413615 */, 18 },
+ /* 5898 */ { MAD_F(0x06810beb) /* 0.406505509 */, 18 },
+ /* 5899 */ { MAD_F(0x06816c49) /* 0.406597408 */, 18 },
+ /* 5900 */ { MAD_F(0x0681cca7) /* 0.406689313 */, 18 },
+ /* 5901 */ { MAD_F(0x06822d07) /* 0.406781223 */, 18 },
+ /* 5902 */ { MAD_F(0x06828d68) /* 0.406873138 */, 18 },
+ /* 5903 */ { MAD_F(0x0682edcb) /* 0.406965058 */, 18 },
+
+ /* 5904 */ { MAD_F(0x06834e2f) /* 0.407056983 */, 18 },
+ /* 5905 */ { MAD_F(0x0683ae94) /* 0.407148914 */, 18 },
+ /* 5906 */ { MAD_F(0x06840efb) /* 0.407240850 */, 18 },
+ /* 5907 */ { MAD_F(0x06846f63) /* 0.407332791 */, 18 },
+ /* 5908 */ { MAD_F(0x0684cfcd) /* 0.407424737 */, 18 },
+ /* 5909 */ { MAD_F(0x06853038) /* 0.407516688 */, 18 },
+ /* 5910 */ { MAD_F(0x068590a4) /* 0.407608645 */, 18 },
+ /* 5911 */ { MAD_F(0x0685f112) /* 0.407700606 */, 18 },
+ /* 5912 */ { MAD_F(0x06865181) /* 0.407792573 */, 18 },
+ /* 5913 */ { MAD_F(0x0686b1f2) /* 0.407884545 */, 18 },
+ /* 5914 */ { MAD_F(0x06871264) /* 0.407976522 */, 18 },
+ /* 5915 */ { MAD_F(0x068772d7) /* 0.408068505 */, 18 },
+ /* 5916 */ { MAD_F(0x0687d34c) /* 0.408160492 */, 18 },
+ /* 5917 */ { MAD_F(0x068833c2) /* 0.408252485 */, 18 },
+ /* 5918 */ { MAD_F(0x06889439) /* 0.408344483 */, 18 },
+ /* 5919 */ { MAD_F(0x0688f4b2) /* 0.408436486 */, 18 },
+
+ /* 5920 */ { MAD_F(0x0689552c) /* 0.408528495 */, 18 },
+ /* 5921 */ { MAD_F(0x0689b5a8) /* 0.408620508 */, 18 },
+ /* 5922 */ { MAD_F(0x068a1625) /* 0.408712527 */, 18 },
+ /* 5923 */ { MAD_F(0x068a76a4) /* 0.408804551 */, 18 },
+ /* 5924 */ { MAD_F(0x068ad724) /* 0.408896580 */, 18 },
+ /* 5925 */ { MAD_F(0x068b37a5) /* 0.408988614 */, 18 },
+ /* 5926 */ { MAD_F(0x068b9827) /* 0.409080653 */, 18 },
+ /* 5927 */ { MAD_F(0x068bf8ac) /* 0.409172698 */, 18 },
+ /* 5928 */ { MAD_F(0x068c5931) /* 0.409264748 */, 18 },
+ /* 5929 */ { MAD_F(0x068cb9b8) /* 0.409356803 */, 18 },
+ /* 5930 */ { MAD_F(0x068d1a40) /* 0.409448863 */, 18 },
+ /* 5931 */ { MAD_F(0x068d7aca) /* 0.409540928 */, 18 },
+ /* 5932 */ { MAD_F(0x068ddb54) /* 0.409632999 */, 18 },
+ /* 5933 */ { MAD_F(0x068e3be1) /* 0.409725074 */, 18 },
+ /* 5934 */ { MAD_F(0x068e9c6f) /* 0.409817155 */, 18 },
+ /* 5935 */ { MAD_F(0x068efcfe) /* 0.409909241 */, 18 },
+
+ /* 5936 */ { MAD_F(0x068f5d8e) /* 0.410001332 */, 18 },
+ /* 5937 */ { MAD_F(0x068fbe20) /* 0.410093428 */, 18 },
+ /* 5938 */ { MAD_F(0x06901eb4) /* 0.410185530 */, 18 },
+ /* 5939 */ { MAD_F(0x06907f48) /* 0.410277637 */, 18 },
+ /* 5940 */ { MAD_F(0x0690dfde) /* 0.410369748 */, 18 },
+ /* 5941 */ { MAD_F(0x06914076) /* 0.410461865 */, 18 },
+ /* 5942 */ { MAD_F(0x0691a10f) /* 0.410553988 */, 18 },
+ /* 5943 */ { MAD_F(0x069201a9) /* 0.410646115 */, 18 },
+ /* 5944 */ { MAD_F(0x06926245) /* 0.410738247 */, 18 },
+ /* 5945 */ { MAD_F(0x0692c2e2) /* 0.410830385 */, 18 },
+ /* 5946 */ { MAD_F(0x06932380) /* 0.410922528 */, 18 },
+ /* 5947 */ { MAD_F(0x06938420) /* 0.411014676 */, 18 },
+ /* 5948 */ { MAD_F(0x0693e4c1) /* 0.411106829 */, 18 },
+ /* 5949 */ { MAD_F(0x06944563) /* 0.411198987 */, 18 },
+ /* 5950 */ { MAD_F(0x0694a607) /* 0.411291151 */, 18 },
+ /* 5951 */ { MAD_F(0x069506ad) /* 0.411383320 */, 18 },
+
+ /* 5952 */ { MAD_F(0x06956753) /* 0.411475493 */, 18 },
+ /* 5953 */ { MAD_F(0x0695c7fc) /* 0.411567672 */, 18 },
+ /* 5954 */ { MAD_F(0x069628a5) /* 0.411659857 */, 18 },
+ /* 5955 */ { MAD_F(0x06968950) /* 0.411752046 */, 18 },
+ /* 5956 */ { MAD_F(0x0696e9fc) /* 0.411844240 */, 18 },
+ /* 5957 */ { MAD_F(0x06974aaa) /* 0.411936440 */, 18 },
+ /* 5958 */ { MAD_F(0x0697ab59) /* 0.412028645 */, 18 },
+ /* 5959 */ { MAD_F(0x06980c09) /* 0.412120855 */, 18 },
+ /* 5960 */ { MAD_F(0x06986cbb) /* 0.412213070 */, 18 },
+ /* 5961 */ { MAD_F(0x0698cd6e) /* 0.412305290 */, 18 },
+ /* 5962 */ { MAD_F(0x06992e23) /* 0.412397516 */, 18 },
+ /* 5963 */ { MAD_F(0x06998ed9) /* 0.412489746 */, 18 },
+ /* 5964 */ { MAD_F(0x0699ef90) /* 0.412581982 */, 18 },
+ /* 5965 */ { MAD_F(0x069a5049) /* 0.412674223 */, 18 },
+ /* 5966 */ { MAD_F(0x069ab103) /* 0.412766469 */, 18 },
+ /* 5967 */ { MAD_F(0x069b11bf) /* 0.412858720 */, 18 },
+
+ /* 5968 */ { MAD_F(0x069b727b) /* 0.412950976 */, 18 },
+ /* 5969 */ { MAD_F(0x069bd33a) /* 0.413043238 */, 18 },
+ /* 5970 */ { MAD_F(0x069c33f9) /* 0.413135505 */, 18 },
+ /* 5971 */ { MAD_F(0x069c94ba) /* 0.413227776 */, 18 },
+ /* 5972 */ { MAD_F(0x069cf57d) /* 0.413320053 */, 18 },
+ /* 5973 */ { MAD_F(0x069d5641) /* 0.413412335 */, 18 },
+ /* 5974 */ { MAD_F(0x069db706) /* 0.413504623 */, 18 },
+ /* 5975 */ { MAD_F(0x069e17cc) /* 0.413596915 */, 18 },
+ /* 5976 */ { MAD_F(0x069e7894) /* 0.413689213 */, 18 },
+ /* 5977 */ { MAD_F(0x069ed95e) /* 0.413781515 */, 18 },
+ /* 5978 */ { MAD_F(0x069f3a28) /* 0.413873823 */, 18 },
+ /* 5979 */ { MAD_F(0x069f9af4) /* 0.413966136 */, 18 },
+ /* 5980 */ { MAD_F(0x069ffbc2) /* 0.414058454 */, 18 },
+ /* 5981 */ { MAD_F(0x06a05c91) /* 0.414150778 */, 18 },
+ /* 5982 */ { MAD_F(0x06a0bd61) /* 0.414243106 */, 18 },
+ /* 5983 */ { MAD_F(0x06a11e32) /* 0.414335440 */, 18 },
+
+ /* 5984 */ { MAD_F(0x06a17f05) /* 0.414427779 */, 18 },
+ /* 5985 */ { MAD_F(0x06a1dfda) /* 0.414520122 */, 18 },
+ /* 5986 */ { MAD_F(0x06a240b0) /* 0.414612471 */, 18 },
+ /* 5987 */ { MAD_F(0x06a2a187) /* 0.414704826 */, 18 },
+ /* 5988 */ { MAD_F(0x06a3025f) /* 0.414797185 */, 18 },
+ /* 5989 */ { MAD_F(0x06a36339) /* 0.414889549 */, 18 },
+ /* 5990 */ { MAD_F(0x06a3c414) /* 0.414981919 */, 18 },
+ /* 5991 */ { MAD_F(0x06a424f1) /* 0.415074294 */, 18 },
+ /* 5992 */ { MAD_F(0x06a485cf) /* 0.415166674 */, 18 },
+ /* 5993 */ { MAD_F(0x06a4e6ae) /* 0.415259059 */, 18 },
+ /* 5994 */ { MAD_F(0x06a5478f) /* 0.415351449 */, 18 },
+ /* 5995 */ { MAD_F(0x06a5a871) /* 0.415443844 */, 18 },
+ /* 5996 */ { MAD_F(0x06a60955) /* 0.415536244 */, 18 },
+ /* 5997 */ { MAD_F(0x06a66a3a) /* 0.415628650 */, 18 },
+ /* 5998 */ { MAD_F(0x06a6cb20) /* 0.415721061 */, 18 },
+ /* 5999 */ { MAD_F(0x06a72c08) /* 0.415813476 */, 18 },
+
+ /* 6000 */ { MAD_F(0x06a78cf1) /* 0.415905897 */, 18 },
+ /* 6001 */ { MAD_F(0x06a7eddb) /* 0.415998324 */, 18 },
+ /* 6002 */ { MAD_F(0x06a84ec7) /* 0.416090755 */, 18 },
+ /* 6003 */ { MAD_F(0x06a8afb4) /* 0.416183191 */, 18 },
+ /* 6004 */ { MAD_F(0x06a910a3) /* 0.416275633 */, 18 },
+ /* 6005 */ { MAD_F(0x06a97193) /* 0.416368079 */, 18 },
+ /* 6006 */ { MAD_F(0x06a9d284) /* 0.416460531 */, 18 },
+ /* 6007 */ { MAD_F(0x06aa3377) /* 0.416552988 */, 18 },
+ /* 6008 */ { MAD_F(0x06aa946b) /* 0.416645450 */, 18 },
+ /* 6009 */ { MAD_F(0x06aaf561) /* 0.416737917 */, 18 },
+ /* 6010 */ { MAD_F(0x06ab5657) /* 0.416830389 */, 18 },
+ /* 6011 */ { MAD_F(0x06abb750) /* 0.416922867 */, 18 },
+ /* 6012 */ { MAD_F(0x06ac1849) /* 0.417015349 */, 18 },
+ /* 6013 */ { MAD_F(0x06ac7944) /* 0.417107837 */, 18 },
+ /* 6014 */ { MAD_F(0x06acda41) /* 0.417200330 */, 18 },
+ /* 6015 */ { MAD_F(0x06ad3b3e) /* 0.417292828 */, 18 },
+
+ /* 6016 */ { MAD_F(0x06ad9c3d) /* 0.417385331 */, 18 },
+ /* 6017 */ { MAD_F(0x06adfd3e) /* 0.417477839 */, 18 },
+ /* 6018 */ { MAD_F(0x06ae5e40) /* 0.417570352 */, 18 },
+ /* 6019 */ { MAD_F(0x06aebf43) /* 0.417662871 */, 18 },
+ /* 6020 */ { MAD_F(0x06af2047) /* 0.417755394 */, 18 },
+ /* 6021 */ { MAD_F(0x06af814d) /* 0.417847923 */, 18 },
+ /* 6022 */ { MAD_F(0x06afe255) /* 0.417940457 */, 18 },
+ /* 6023 */ { MAD_F(0x06b0435e) /* 0.418032996 */, 18 },
+ /* 6024 */ { MAD_F(0x06b0a468) /* 0.418125540 */, 18 },
+ /* 6025 */ { MAD_F(0x06b10573) /* 0.418218089 */, 18 },
+ /* 6026 */ { MAD_F(0x06b16680) /* 0.418310643 */, 18 },
+ /* 6027 */ { MAD_F(0x06b1c78e) /* 0.418403203 */, 18 },
+ /* 6028 */ { MAD_F(0x06b2289e) /* 0.418495767 */, 18 },
+ /* 6029 */ { MAD_F(0x06b289af) /* 0.418588337 */, 18 },
+ /* 6030 */ { MAD_F(0x06b2eac1) /* 0.418680911 */, 18 },
+ /* 6031 */ { MAD_F(0x06b34bd5) /* 0.418773491 */, 18 },
+
+ /* 6032 */ { MAD_F(0x06b3acea) /* 0.418866076 */, 18 },
+ /* 6033 */ { MAD_F(0x06b40e00) /* 0.418958666 */, 18 },
+ /* 6034 */ { MAD_F(0x06b46f18) /* 0.419051262 */, 18 },
+ /* 6035 */ { MAD_F(0x06b4d031) /* 0.419143862 */, 18 },
+ /* 6036 */ { MAD_F(0x06b5314c) /* 0.419236467 */, 18 },
+ /* 6037 */ { MAD_F(0x06b59268) /* 0.419329078 */, 18 },
+ /* 6038 */ { MAD_F(0x06b5f385) /* 0.419421694 */, 18 },
+ /* 6039 */ { MAD_F(0x06b654a4) /* 0.419514314 */, 18 },
+ /* 6040 */ { MAD_F(0x06b6b5c4) /* 0.419606940 */, 18 },
+ /* 6041 */ { MAD_F(0x06b716e6) /* 0.419699571 */, 18 },
+ /* 6042 */ { MAD_F(0x06b77808) /* 0.419792208 */, 18 },
+ /* 6043 */ { MAD_F(0x06b7d92d) /* 0.419884849 */, 18 },
+ /* 6044 */ { MAD_F(0x06b83a52) /* 0.419977495 */, 18 },
+ /* 6045 */ { MAD_F(0x06b89b79) /* 0.420070147 */, 18 },
+ /* 6046 */ { MAD_F(0x06b8fca1) /* 0.420162803 */, 18 },
+ /* 6047 */ { MAD_F(0x06b95dcb) /* 0.420255465 */, 18 },
+
+ /* 6048 */ { MAD_F(0x06b9bef6) /* 0.420348132 */, 18 },
+ /* 6049 */ { MAD_F(0x06ba2023) /* 0.420440803 */, 18 },
+ /* 6050 */ { MAD_F(0x06ba8150) /* 0.420533481 */, 18 },
+ /* 6051 */ { MAD_F(0x06bae280) /* 0.420626163 */, 18 },
+ /* 6052 */ { MAD_F(0x06bb43b0) /* 0.420718850 */, 18 },
+ /* 6053 */ { MAD_F(0x06bba4e2) /* 0.420811542 */, 18 },
+ /* 6054 */ { MAD_F(0x06bc0615) /* 0.420904240 */, 18 },
+ /* 6055 */ { MAD_F(0x06bc674a) /* 0.420996942 */, 18 },
+ /* 6056 */ { MAD_F(0x06bcc880) /* 0.421089650 */, 18 },
+ /* 6057 */ { MAD_F(0x06bd29b7) /* 0.421182362 */, 18 },
+ /* 6058 */ { MAD_F(0x06bd8af0) /* 0.421275080 */, 18 },
+ /* 6059 */ { MAD_F(0x06bdec2a) /* 0.421367803 */, 18 },
+ /* 6060 */ { MAD_F(0x06be4d66) /* 0.421460531 */, 18 },
+ /* 6061 */ { MAD_F(0x06beaea3) /* 0.421553264 */, 18 },
+ /* 6062 */ { MAD_F(0x06bf0fe1) /* 0.421646003 */, 18 },
+ /* 6063 */ { MAD_F(0x06bf7120) /* 0.421738746 */, 18 },
+
+ /* 6064 */ { MAD_F(0x06bfd261) /* 0.421831494 */, 18 },
+ /* 6065 */ { MAD_F(0x06c033a4) /* 0.421924248 */, 18 },
+ /* 6066 */ { MAD_F(0x06c094e7) /* 0.422017007 */, 18 },
+ /* 6067 */ { MAD_F(0x06c0f62c) /* 0.422109770 */, 18 },
+ /* 6068 */ { MAD_F(0x06c15773) /* 0.422202539 */, 18 },
+ /* 6069 */ { MAD_F(0x06c1b8bb) /* 0.422295313 */, 18 },
+ /* 6070 */ { MAD_F(0x06c21a04) /* 0.422388092 */, 18 },
+ /* 6071 */ { MAD_F(0x06c27b4e) /* 0.422480876 */, 18 },
+ /* 6072 */ { MAD_F(0x06c2dc9a) /* 0.422573665 */, 18 },
+ /* 6073 */ { MAD_F(0x06c33de8) /* 0.422666460 */, 18 },
+ /* 6074 */ { MAD_F(0x06c39f36) /* 0.422759259 */, 18 },
+ /* 6075 */ { MAD_F(0x06c40086) /* 0.422852064 */, 18 },
+ /* 6076 */ { MAD_F(0x06c461d8) /* 0.422944873 */, 18 },
+ /* 6077 */ { MAD_F(0x06c4c32a) /* 0.423037688 */, 18 },
+ /* 6078 */ { MAD_F(0x06c5247f) /* 0.423130508 */, 18 },
+ /* 6079 */ { MAD_F(0x06c585d4) /* 0.423223333 */, 18 },
+
+ /* 6080 */ { MAD_F(0x06c5e72b) /* 0.423316162 */, 18 },
+ /* 6081 */ { MAD_F(0x06c64883) /* 0.423408997 */, 18 },
+ /* 6082 */ { MAD_F(0x06c6a9dd) /* 0.423501838 */, 18 },
+ /* 6083 */ { MAD_F(0x06c70b38) /* 0.423594683 */, 18 },
+ /* 6084 */ { MAD_F(0x06c76c94) /* 0.423687533 */, 18 },
+ /* 6085 */ { MAD_F(0x06c7cdf2) /* 0.423780389 */, 18 },
+ /* 6086 */ { MAD_F(0x06c82f51) /* 0.423873249 */, 18 },
+ /* 6087 */ { MAD_F(0x06c890b1) /* 0.423966115 */, 18 },
+ /* 6088 */ { MAD_F(0x06c8f213) /* 0.424058985 */, 18 },
+ /* 6089 */ { MAD_F(0x06c95376) /* 0.424151861 */, 18 },
+ /* 6090 */ { MAD_F(0x06c9b4da) /* 0.424244742 */, 18 },
+ /* 6091 */ { MAD_F(0x06ca1640) /* 0.424337628 */, 18 },
+ /* 6092 */ { MAD_F(0x06ca77a8) /* 0.424430519 */, 18 },
+ /* 6093 */ { MAD_F(0x06cad910) /* 0.424523415 */, 18 },
+ /* 6094 */ { MAD_F(0x06cb3a7a) /* 0.424616316 */, 18 },
+ /* 6095 */ { MAD_F(0x06cb9be5) /* 0.424709222 */, 18 },
+
+ /* 6096 */ { MAD_F(0x06cbfd52) /* 0.424802133 */, 18 },
+ /* 6097 */ { MAD_F(0x06cc5ec0) /* 0.424895050 */, 18 },
+ /* 6098 */ { MAD_F(0x06ccc030) /* 0.424987971 */, 18 },
+ /* 6099 */ { MAD_F(0x06cd21a0) /* 0.425080898 */, 18 },
+ /* 6100 */ { MAD_F(0x06cd8313) /* 0.425173829 */, 18 },
+ /* 6101 */ { MAD_F(0x06cde486) /* 0.425266766 */, 18 },
+ /* 6102 */ { MAD_F(0x06ce45fb) /* 0.425359708 */, 18 },
+ /* 6103 */ { MAD_F(0x06cea771) /* 0.425452655 */, 18 },
+ /* 6104 */ { MAD_F(0x06cf08e9) /* 0.425545607 */, 18 },
+ /* 6105 */ { MAD_F(0x06cf6a62) /* 0.425638564 */, 18 },
+ /* 6106 */ { MAD_F(0x06cfcbdc) /* 0.425731526 */, 18 },
+ /* 6107 */ { MAD_F(0x06d02d58) /* 0.425824493 */, 18 },
+ /* 6108 */ { MAD_F(0x06d08ed5) /* 0.425917465 */, 18 },
+ /* 6109 */ { MAD_F(0x06d0f053) /* 0.426010443 */, 18 },
+ /* 6110 */ { MAD_F(0x06d151d3) /* 0.426103425 */, 18 },
+ /* 6111 */ { MAD_F(0x06d1b354) /* 0.426196412 */, 18 },
+
+ /* 6112 */ { MAD_F(0x06d214d7) /* 0.426289405 */, 18 },
+ /* 6113 */ { MAD_F(0x06d2765a) /* 0.426382403 */, 18 },
+ /* 6114 */ { MAD_F(0x06d2d7e0) /* 0.426475405 */, 18 },
+ /* 6115 */ { MAD_F(0x06d33966) /* 0.426568413 */, 18 },
+ /* 6116 */ { MAD_F(0x06d39aee) /* 0.426661426 */, 18 },
+ /* 6117 */ { MAD_F(0x06d3fc77) /* 0.426754444 */, 18 },
+ /* 6118 */ { MAD_F(0x06d45e02) /* 0.426847467 */, 18 },
+ /* 6119 */ { MAD_F(0x06d4bf8e) /* 0.426940495 */, 18 },
+ /* 6120 */ { MAD_F(0x06d5211c) /* 0.427033528 */, 18 },
+ /* 6121 */ { MAD_F(0x06d582aa) /* 0.427126566 */, 18 },
+ /* 6122 */ { MAD_F(0x06d5e43a) /* 0.427219609 */, 18 },
+ /* 6123 */ { MAD_F(0x06d645cc) /* 0.427312657 */, 18 },
+ /* 6124 */ { MAD_F(0x06d6a75f) /* 0.427405711 */, 18 },
+ /* 6125 */ { MAD_F(0x06d708f3) /* 0.427498769 */, 18 },
+ /* 6126 */ { MAD_F(0x06d76a88) /* 0.427591833 */, 18 },
+ /* 6127 */ { MAD_F(0x06d7cc1f) /* 0.427684901 */, 18 },
+
+ /* 6128 */ { MAD_F(0x06d82db8) /* 0.427777975 */, 18 },
+ /* 6129 */ { MAD_F(0x06d88f51) /* 0.427871054 */, 18 },
+ /* 6130 */ { MAD_F(0x06d8f0ec) /* 0.427964137 */, 18 },
+ /* 6131 */ { MAD_F(0x06d95288) /* 0.428057226 */, 18 },
+ /* 6132 */ { MAD_F(0x06d9b426) /* 0.428150320 */, 18 },
+ /* 6133 */ { MAD_F(0x06da15c5) /* 0.428243419 */, 18 },
+ /* 6134 */ { MAD_F(0x06da7766) /* 0.428336523 */, 18 },
+ /* 6135 */ { MAD_F(0x06dad907) /* 0.428429632 */, 18 },
+ /* 6136 */ { MAD_F(0x06db3aaa) /* 0.428522746 */, 18 },
+ /* 6137 */ { MAD_F(0x06db9c4f) /* 0.428615865 */, 18 },
+ /* 6138 */ { MAD_F(0x06dbfdf5) /* 0.428708989 */, 18 },
+ /* 6139 */ { MAD_F(0x06dc5f9c) /* 0.428802119 */, 18 },
+ /* 6140 */ { MAD_F(0x06dcc145) /* 0.428895253 */, 18 },
+ /* 6141 */ { MAD_F(0x06dd22ee) /* 0.428988392 */, 18 },
+ /* 6142 */ { MAD_F(0x06dd849a) /* 0.429081537 */, 18 },
+ /* 6143 */ { MAD_F(0x06dde646) /* 0.429174686 */, 18 },
+
+ /* 6144 */ { MAD_F(0x06de47f4) /* 0.429267841 */, 18 },
+ /* 6145 */ { MAD_F(0x06dea9a4) /* 0.429361001 */, 18 },
+ /* 6146 */ { MAD_F(0x06df0b54) /* 0.429454165 */, 18 },
+ /* 6147 */ { MAD_F(0x06df6d06) /* 0.429547335 */, 18 },
+ /* 6148 */ { MAD_F(0x06dfceba) /* 0.429640510 */, 18 },
+ /* 6149 */ { MAD_F(0x06e0306f) /* 0.429733690 */, 18 },
+ /* 6150 */ { MAD_F(0x06e09225) /* 0.429826874 */, 18 },
+ /* 6151 */ { MAD_F(0x06e0f3dc) /* 0.429920064 */, 18 },
+ /* 6152 */ { MAD_F(0x06e15595) /* 0.430013259 */, 18 },
+ /* 6153 */ { MAD_F(0x06e1b74f) /* 0.430106459 */, 18 },
+ /* 6154 */ { MAD_F(0x06e2190b) /* 0.430199664 */, 18 },
+ /* 6155 */ { MAD_F(0x06e27ac8) /* 0.430292875 */, 18 },
+ /* 6156 */ { MAD_F(0x06e2dc86) /* 0.430386090 */, 18 },
+ /* 6157 */ { MAD_F(0x06e33e46) /* 0.430479310 */, 18 },
+ /* 6158 */ { MAD_F(0x06e3a007) /* 0.430572535 */, 18 },
+ /* 6159 */ { MAD_F(0x06e401c9) /* 0.430665765 */, 18 },
+
+ /* 6160 */ { MAD_F(0x06e4638d) /* 0.430759001 */, 18 },
+ /* 6161 */ { MAD_F(0x06e4c552) /* 0.430852241 */, 18 },
+ /* 6162 */ { MAD_F(0x06e52718) /* 0.430945487 */, 18 },
+ /* 6163 */ { MAD_F(0x06e588e0) /* 0.431038737 */, 18 },
+ /* 6164 */ { MAD_F(0x06e5eaa9) /* 0.431131993 */, 18 },
+ /* 6165 */ { MAD_F(0x06e64c73) /* 0.431225253 */, 18 },
+ /* 6166 */ { MAD_F(0x06e6ae3f) /* 0.431318519 */, 18 },
+ /* 6167 */ { MAD_F(0x06e7100c) /* 0.431411790 */, 18 },
+ /* 6168 */ { MAD_F(0x06e771db) /* 0.431505065 */, 18 },
+ /* 6169 */ { MAD_F(0x06e7d3ab) /* 0.431598346 */, 18 },
+ /* 6170 */ { MAD_F(0x06e8357c) /* 0.431691632 */, 18 },
+ /* 6171 */ { MAD_F(0x06e8974e) /* 0.431784923 */, 18 },
+ /* 6172 */ { MAD_F(0x06e8f922) /* 0.431878218 */, 18 },
+ /* 6173 */ { MAD_F(0x06e95af8) /* 0.431971519 */, 18 },
+ /* 6174 */ { MAD_F(0x06e9bcce) /* 0.432064825 */, 18 },
+ /* 6175 */ { MAD_F(0x06ea1ea6) /* 0.432158136 */, 18 },
+
+ /* 6176 */ { MAD_F(0x06ea807f) /* 0.432251452 */, 18 },
+ /* 6177 */ { MAD_F(0x06eae25a) /* 0.432344773 */, 18 },
+ /* 6178 */ { MAD_F(0x06eb4436) /* 0.432438099 */, 18 },
+ /* 6179 */ { MAD_F(0x06eba614) /* 0.432531431 */, 18 },
+ /* 6180 */ { MAD_F(0x06ec07f2) /* 0.432624767 */, 18 },
+ /* 6181 */ { MAD_F(0x06ec69d2) /* 0.432718108 */, 18 },
+ /* 6182 */ { MAD_F(0x06eccbb4) /* 0.432811454 */, 18 },
+ /* 6183 */ { MAD_F(0x06ed2d97) /* 0.432904805 */, 18 },
+ /* 6184 */ { MAD_F(0x06ed8f7b) /* 0.432998162 */, 18 },
+ /* 6185 */ { MAD_F(0x06edf160) /* 0.433091523 */, 18 },
+ /* 6186 */ { MAD_F(0x06ee5347) /* 0.433184889 */, 18 },
+ /* 6187 */ { MAD_F(0x06eeb52f) /* 0.433278261 */, 18 },
+ /* 6188 */ { MAD_F(0x06ef1719) /* 0.433371637 */, 18 },
+ /* 6189 */ { MAD_F(0x06ef7904) /* 0.433465019 */, 18 },
+ /* 6190 */ { MAD_F(0x06efdaf0) /* 0.433558405 */, 18 },
+ /* 6191 */ { MAD_F(0x06f03cde) /* 0.433651797 */, 18 },
+
+ /* 6192 */ { MAD_F(0x06f09ecc) /* 0.433745193 */, 18 },
+ /* 6193 */ { MAD_F(0x06f100bd) /* 0.433838595 */, 18 },
+ /* 6194 */ { MAD_F(0x06f162ae) /* 0.433932001 */, 18 },
+ /* 6195 */ { MAD_F(0x06f1c4a1) /* 0.434025413 */, 18 },
+ /* 6196 */ { MAD_F(0x06f22696) /* 0.434118830 */, 18 },
+ /* 6197 */ { MAD_F(0x06f2888b) /* 0.434212251 */, 18 },
+ /* 6198 */ { MAD_F(0x06f2ea82) /* 0.434305678 */, 18 },
+ /* 6199 */ { MAD_F(0x06f34c7b) /* 0.434399110 */, 18 },
+ /* 6200 */ { MAD_F(0x06f3ae75) /* 0.434492546 */, 18 },
+ /* 6201 */ { MAD_F(0x06f41070) /* 0.434585988 */, 18 },
+ /* 6202 */ { MAD_F(0x06f4726c) /* 0.434679435 */, 18 },
+ /* 6203 */ { MAD_F(0x06f4d46a) /* 0.434772887 */, 18 },
+ /* 6204 */ { MAD_F(0x06f53669) /* 0.434866344 */, 18 },
+ /* 6205 */ { MAD_F(0x06f59869) /* 0.434959806 */, 18 },
+ /* 6206 */ { MAD_F(0x06f5fa6b) /* 0.435053272 */, 18 },
+ /* 6207 */ { MAD_F(0x06f65c6e) /* 0.435146744 */, 18 },
+
+ /* 6208 */ { MAD_F(0x06f6be73) /* 0.435240221 */, 18 },
+ /* 6209 */ { MAD_F(0x06f72079) /* 0.435333703 */, 18 },
+ /* 6210 */ { MAD_F(0x06f78280) /* 0.435427190 */, 18 },
+ /* 6211 */ { MAD_F(0x06f7e489) /* 0.435520682 */, 18 },
+ /* 6212 */ { MAD_F(0x06f84693) /* 0.435614179 */, 18 },
+ /* 6213 */ { MAD_F(0x06f8a89e) /* 0.435707681 */, 18 },
+ /* 6214 */ { MAD_F(0x06f90aaa) /* 0.435801188 */, 18 },
+ /* 6215 */ { MAD_F(0x06f96cb8) /* 0.435894700 */, 18 },
+ /* 6216 */ { MAD_F(0x06f9cec8) /* 0.435988217 */, 18 },
+ /* 6217 */ { MAD_F(0x06fa30d8) /* 0.436081739 */, 18 },
+ /* 6218 */ { MAD_F(0x06fa92ea) /* 0.436175266 */, 18 },
+ /* 6219 */ { MAD_F(0x06faf4fe) /* 0.436268799 */, 18 },
+ /* 6220 */ { MAD_F(0x06fb5712) /* 0.436362336 */, 18 },
+ /* 6221 */ { MAD_F(0x06fbb928) /* 0.436455878 */, 18 },
+ /* 6222 */ { MAD_F(0x06fc1b40) /* 0.436549425 */, 18 },
+ /* 6223 */ { MAD_F(0x06fc7d58) /* 0.436642977 */, 18 },
+
+ /* 6224 */ { MAD_F(0x06fcdf72) /* 0.436736534 */, 18 },
+ /* 6225 */ { MAD_F(0x06fd418e) /* 0.436830096 */, 18 },
+ /* 6226 */ { MAD_F(0x06fda3ab) /* 0.436923664 */, 18 },
+ /* 6227 */ { MAD_F(0x06fe05c9) /* 0.437017236 */, 18 },
+ /* 6228 */ { MAD_F(0x06fe67e8) /* 0.437110813 */, 18 },
+ /* 6229 */ { MAD_F(0x06feca09) /* 0.437204395 */, 18 },
+ /* 6230 */ { MAD_F(0x06ff2c2b) /* 0.437297982 */, 18 },
+ /* 6231 */ { MAD_F(0x06ff8e4f) /* 0.437391575 */, 18 },
+ /* 6232 */ { MAD_F(0x06fff073) /* 0.437485172 */, 18 },
+ /* 6233 */ { MAD_F(0x0700529a) /* 0.437578774 */, 18 },
+ /* 6234 */ { MAD_F(0x0700b4c1) /* 0.437672381 */, 18 },
+ /* 6235 */ { MAD_F(0x070116ea) /* 0.437765994 */, 18 },
+ /* 6236 */ { MAD_F(0x07017914) /* 0.437859611 */, 18 },
+ /* 6237 */ { MAD_F(0x0701db40) /* 0.437953233 */, 18 },
+ /* 6238 */ { MAD_F(0x07023d6c) /* 0.438046860 */, 18 },
+ /* 6239 */ { MAD_F(0x07029f9b) /* 0.438140493 */, 18 },
+
+ /* 6240 */ { MAD_F(0x070301ca) /* 0.438234130 */, 18 },
+ /* 6241 */ { MAD_F(0x070363fb) /* 0.438327772 */, 18 },
+ /* 6242 */ { MAD_F(0x0703c62d) /* 0.438421419 */, 18 },
+ /* 6243 */ { MAD_F(0x07042861) /* 0.438515072 */, 18 },
+ /* 6244 */ { MAD_F(0x07048a96) /* 0.438608729 */, 18 },
+ /* 6245 */ { MAD_F(0x0704eccc) /* 0.438702391 */, 18 },
+ /* 6246 */ { MAD_F(0x07054f04) /* 0.438796059 */, 18 },
+ /* 6247 */ { MAD_F(0x0705b13d) /* 0.438889731 */, 18 },
+ /* 6248 */ { MAD_F(0x07061377) /* 0.438983408 */, 18 },
+ /* 6249 */ { MAD_F(0x070675b3) /* 0.439077090 */, 18 },
+ /* 6250 */ { MAD_F(0x0706d7f0) /* 0.439170778 */, 18 },
+ /* 6251 */ { MAD_F(0x07073a2e) /* 0.439264470 */, 18 },
+ /* 6252 */ { MAD_F(0x07079c6e) /* 0.439358167 */, 18 },
+ /* 6253 */ { MAD_F(0x0707feaf) /* 0.439451869 */, 18 },
+ /* 6254 */ { MAD_F(0x070860f1) /* 0.439545577 */, 18 },
+ /* 6255 */ { MAD_F(0x0708c335) /* 0.439639289 */, 18 },
+
+ /* 6256 */ { MAD_F(0x0709257a) /* 0.439733006 */, 18 },
+ /* 6257 */ { MAD_F(0x070987c0) /* 0.439826728 */, 18 },
+ /* 6258 */ { MAD_F(0x0709ea08) /* 0.439920456 */, 18 },
+ /* 6259 */ { MAD_F(0x070a4c51) /* 0.440014188 */, 18 },
+ /* 6260 */ { MAD_F(0x070aae9b) /* 0.440107925 */, 18 },
+ /* 6261 */ { MAD_F(0x070b10e7) /* 0.440201667 */, 18 },
+ /* 6262 */ { MAD_F(0x070b7334) /* 0.440295414 */, 18 },
+ /* 6263 */ { MAD_F(0x070bd583) /* 0.440389167 */, 18 },
+ /* 6264 */ { MAD_F(0x070c37d2) /* 0.440482924 */, 18 },
+ /* 6265 */ { MAD_F(0x070c9a23) /* 0.440576686 */, 18 },
+ /* 6266 */ { MAD_F(0x070cfc76) /* 0.440670453 */, 18 },
+ /* 6267 */ { MAD_F(0x070d5eca) /* 0.440764225 */, 18 },
+ /* 6268 */ { MAD_F(0x070dc11f) /* 0.440858002 */, 18 },
+ /* 6269 */ { MAD_F(0x070e2375) /* 0.440951784 */, 18 },
+ /* 6270 */ { MAD_F(0x070e85cd) /* 0.441045572 */, 18 },
+ /* 6271 */ { MAD_F(0x070ee826) /* 0.441139364 */, 18 },
+
+ /* 6272 */ { MAD_F(0x070f4a80) /* 0.441233161 */, 18 },
+ /* 6273 */ { MAD_F(0x070facdc) /* 0.441326963 */, 18 },
+ /* 6274 */ { MAD_F(0x07100f39) /* 0.441420770 */, 18 },
+ /* 6275 */ { MAD_F(0x07107198) /* 0.441514582 */, 18 },
+ /* 6276 */ { MAD_F(0x0710d3f8) /* 0.441608399 */, 18 },
+ /* 6277 */ { MAD_F(0x07113659) /* 0.441702221 */, 18 },
+ /* 6278 */ { MAD_F(0x071198bb) /* 0.441796048 */, 18 },
+ /* 6279 */ { MAD_F(0x0711fb1f) /* 0.441889880 */, 18 },
+ /* 6280 */ { MAD_F(0x07125d84) /* 0.441983717 */, 18 },
+ /* 6281 */ { MAD_F(0x0712bfeb) /* 0.442077559 */, 18 },
+ /* 6282 */ { MAD_F(0x07132253) /* 0.442171406 */, 18 },
+ /* 6283 */ { MAD_F(0x071384bc) /* 0.442265257 */, 18 },
+ /* 6284 */ { MAD_F(0x0713e726) /* 0.442359114 */, 18 },
+ /* 6285 */ { MAD_F(0x07144992) /* 0.442452976 */, 18 },
+ /* 6286 */ { MAD_F(0x0714abff) /* 0.442546843 */, 18 },
+ /* 6287 */ { MAD_F(0x07150e6e) /* 0.442640715 */, 18 },
+
+ /* 6288 */ { MAD_F(0x071570de) /* 0.442734592 */, 18 },
+ /* 6289 */ { MAD_F(0x0715d34f) /* 0.442828473 */, 18 },
+ /* 6290 */ { MAD_F(0x071635c1) /* 0.442922360 */, 18 },
+ /* 6291 */ { MAD_F(0x07169835) /* 0.443016252 */, 18 },
+ /* 6292 */ { MAD_F(0x0716faaa) /* 0.443110148 */, 18 },
+ /* 6293 */ { MAD_F(0x07175d21) /* 0.443204050 */, 18 },
+ /* 6294 */ { MAD_F(0x0717bf99) /* 0.443297957 */, 18 },
+ /* 6295 */ { MAD_F(0x07182212) /* 0.443391868 */, 18 },
+ /* 6296 */ { MAD_F(0x0718848d) /* 0.443485785 */, 18 },
+ /* 6297 */ { MAD_F(0x0718e709) /* 0.443579706 */, 18 },
+ /* 6298 */ { MAD_F(0x07194986) /* 0.443673633 */, 18 },
+ /* 6299 */ { MAD_F(0x0719ac04) /* 0.443767564 */, 18 },
+ /* 6300 */ { MAD_F(0x071a0e84) /* 0.443861501 */, 18 },
+ /* 6301 */ { MAD_F(0x071a7105) /* 0.443955442 */, 18 },
+ /* 6302 */ { MAD_F(0x071ad388) /* 0.444049389 */, 18 },
+ /* 6303 */ { MAD_F(0x071b360c) /* 0.444143340 */, 18 },
+
+ /* 6304 */ { MAD_F(0x071b9891) /* 0.444237296 */, 18 },
+ /* 6305 */ { MAD_F(0x071bfb18) /* 0.444331258 */, 18 },
+ /* 6306 */ { MAD_F(0x071c5d9f) /* 0.444425224 */, 18 },
+ /* 6307 */ { MAD_F(0x071cc029) /* 0.444519195 */, 18 },
+ /* 6308 */ { MAD_F(0x071d22b3) /* 0.444613171 */, 18 },
+ /* 6309 */ { MAD_F(0x071d853f) /* 0.444707153 */, 18 },
+ /* 6310 */ { MAD_F(0x071de7cc) /* 0.444801139 */, 18 },
+ /* 6311 */ { MAD_F(0x071e4a5b) /* 0.444895130 */, 18 },
+ /* 6312 */ { MAD_F(0x071eaceb) /* 0.444989126 */, 18 },
+ /* 6313 */ { MAD_F(0x071f0f7c) /* 0.445083127 */, 18 },
+ /* 6314 */ { MAD_F(0x071f720e) /* 0.445177133 */, 18 },
+ /* 6315 */ { MAD_F(0x071fd4a2) /* 0.445271144 */, 18 },
+ /* 6316 */ { MAD_F(0x07203737) /* 0.445365160 */, 18 },
+ /* 6317 */ { MAD_F(0x072099ce) /* 0.445459181 */, 18 },
+ /* 6318 */ { MAD_F(0x0720fc66) /* 0.445553206 */, 18 },
+ /* 6319 */ { MAD_F(0x07215eff) /* 0.445647237 */, 18 },
+
+ /* 6320 */ { MAD_F(0x0721c19a) /* 0.445741273 */, 18 },
+ /* 6321 */ { MAD_F(0x07222436) /* 0.445835314 */, 18 },
+ /* 6322 */ { MAD_F(0x072286d3) /* 0.445929359 */, 18 },
+ /* 6323 */ { MAD_F(0x0722e971) /* 0.446023410 */, 18 },
+ /* 6324 */ { MAD_F(0x07234c11) /* 0.446117466 */, 18 },
+ /* 6325 */ { MAD_F(0x0723aeb2) /* 0.446211526 */, 18 },
+ /* 6326 */ { MAD_F(0x07241155) /* 0.446305592 */, 18 },
+ /* 6327 */ { MAD_F(0x072473f9) /* 0.446399662 */, 18 },
+ /* 6328 */ { MAD_F(0x0724d69e) /* 0.446493738 */, 18 },
+ /* 6329 */ { MAD_F(0x07253944) /* 0.446587818 */, 18 },
+ /* 6330 */ { MAD_F(0x07259bec) /* 0.446681903 */, 18 },
+ /* 6331 */ { MAD_F(0x0725fe95) /* 0.446775994 */, 18 },
+ /* 6332 */ { MAD_F(0x07266140) /* 0.446870089 */, 18 },
+ /* 6333 */ { MAD_F(0x0726c3ec) /* 0.446964189 */, 18 },
+ /* 6334 */ { MAD_F(0x07272699) /* 0.447058294 */, 18 },
+ /* 6335 */ { MAD_F(0x07278947) /* 0.447152404 */, 18 },
+
+ /* 6336 */ { MAD_F(0x0727ebf7) /* 0.447246519 */, 18 },
+ /* 6337 */ { MAD_F(0x07284ea8) /* 0.447340639 */, 18 },
+ /* 6338 */ { MAD_F(0x0728b15b) /* 0.447434764 */, 18 },
+ /* 6339 */ { MAD_F(0x0729140f) /* 0.447528894 */, 18 },
+ /* 6340 */ { MAD_F(0x072976c4) /* 0.447623029 */, 18 },
+ /* 6341 */ { MAD_F(0x0729d97a) /* 0.447717169 */, 18 },
+ /* 6342 */ { MAD_F(0x072a3c32) /* 0.447811314 */, 18 },
+ /* 6343 */ { MAD_F(0x072a9eeb) /* 0.447905463 */, 18 },
+ /* 6344 */ { MAD_F(0x072b01a6) /* 0.447999618 */, 18 },
+ /* 6345 */ { MAD_F(0x072b6461) /* 0.448093778 */, 18 },
+ /* 6346 */ { MAD_F(0x072bc71e) /* 0.448187942 */, 18 },
+ /* 6347 */ { MAD_F(0x072c29dd) /* 0.448282112 */, 18 },
+ /* 6348 */ { MAD_F(0x072c8c9d) /* 0.448376286 */, 18 },
+ /* 6349 */ { MAD_F(0x072cef5e) /* 0.448470466 */, 18 },
+ /* 6350 */ { MAD_F(0x072d5220) /* 0.448564650 */, 18 },
+ /* 6351 */ { MAD_F(0x072db4e4) /* 0.448658839 */, 18 },
+
+ /* 6352 */ { MAD_F(0x072e17a9) /* 0.448753033 */, 18 },
+ /* 6353 */ { MAD_F(0x072e7a6f) /* 0.448847233 */, 18 },
+ /* 6354 */ { MAD_F(0x072edd37) /* 0.448941437 */, 18 },
+ /* 6355 */ { MAD_F(0x072f4000) /* 0.449035646 */, 18 },
+ /* 6356 */ { MAD_F(0x072fa2ca) /* 0.449129860 */, 18 },
+ /* 6357 */ { MAD_F(0x07300596) /* 0.449224079 */, 18 },
+ /* 6358 */ { MAD_F(0x07306863) /* 0.449318303 */, 18 },
+ /* 6359 */ { MAD_F(0x0730cb32) /* 0.449412531 */, 18 },
+ /* 6360 */ { MAD_F(0x07312e01) /* 0.449506765 */, 18 },
+ /* 6361 */ { MAD_F(0x073190d2) /* 0.449601004 */, 18 },
+ /* 6362 */ { MAD_F(0x0731f3a5) /* 0.449695247 */, 18 },
+ /* 6363 */ { MAD_F(0x07325678) /* 0.449789496 */, 18 },
+ /* 6364 */ { MAD_F(0x0732b94d) /* 0.449883749 */, 18 },
+ /* 6365 */ { MAD_F(0x07331c23) /* 0.449978008 */, 18 },
+ /* 6366 */ { MAD_F(0x07337efb) /* 0.450072271 */, 18 },
+ /* 6367 */ { MAD_F(0x0733e1d4) /* 0.450166540 */, 18 },
+
+ /* 6368 */ { MAD_F(0x073444ae) /* 0.450260813 */, 18 },
+ /* 6369 */ { MAD_F(0x0734a78a) /* 0.450355091 */, 18 },
+ /* 6370 */ { MAD_F(0x07350a67) /* 0.450449374 */, 18 },
+ /* 6371 */ { MAD_F(0x07356d45) /* 0.450543662 */, 18 },
+ /* 6372 */ { MAD_F(0x0735d025) /* 0.450637955 */, 18 },
+ /* 6373 */ { MAD_F(0x07363306) /* 0.450732253 */, 18 },
+ /* 6374 */ { MAD_F(0x073695e8) /* 0.450826556 */, 18 },
+ /* 6375 */ { MAD_F(0x0736f8cb) /* 0.450920864 */, 18 },
+ /* 6376 */ { MAD_F(0x07375bb0) /* 0.451015176 */, 18 },
+ /* 6377 */ { MAD_F(0x0737be96) /* 0.451109494 */, 18 },
+ /* 6378 */ { MAD_F(0x0738217e) /* 0.451203817 */, 18 },
+ /* 6379 */ { MAD_F(0x07388467) /* 0.451298144 */, 18 },
+ /* 6380 */ { MAD_F(0x0738e751) /* 0.451392477 */, 18 },
+ /* 6381 */ { MAD_F(0x07394a3d) /* 0.451486814 */, 18 },
+ /* 6382 */ { MAD_F(0x0739ad29) /* 0.451581156 */, 18 },
+ /* 6383 */ { MAD_F(0x073a1017) /* 0.451675503 */, 18 },
+
+ /* 6384 */ { MAD_F(0x073a7307) /* 0.451769856 */, 18 },
+ /* 6385 */ { MAD_F(0x073ad5f8) /* 0.451864213 */, 18 },
+ /* 6386 */ { MAD_F(0x073b38ea) /* 0.451958575 */, 18 },
+ /* 6387 */ { MAD_F(0x073b9bdd) /* 0.452052942 */, 18 },
+ /* 6388 */ { MAD_F(0x073bfed2) /* 0.452147313 */, 18 },
+ /* 6389 */ { MAD_F(0x073c61c8) /* 0.452241690 */, 18 },
+ /* 6390 */ { MAD_F(0x073cc4bf) /* 0.452336072 */, 18 },
+ /* 6391 */ { MAD_F(0x073d27b8) /* 0.452430458 */, 18 },
+ /* 6392 */ { MAD_F(0x073d8ab2) /* 0.452524850 */, 18 },
+ /* 6393 */ { MAD_F(0x073dedae) /* 0.452619246 */, 18 },
+ /* 6394 */ { MAD_F(0x073e50aa) /* 0.452713648 */, 18 },
+ /* 6395 */ { MAD_F(0x073eb3a8) /* 0.452808054 */, 18 },
+ /* 6396 */ { MAD_F(0x073f16a8) /* 0.452902465 */, 18 },
+ /* 6397 */ { MAD_F(0x073f79a8) /* 0.452996882 */, 18 },
+ /* 6398 */ { MAD_F(0x073fdcaa) /* 0.453091303 */, 18 },
+ /* 6399 */ { MAD_F(0x07403fad) /* 0.453185729 */, 18 },
+
+ /* 6400 */ { MAD_F(0x0740a2b2) /* 0.453280160 */, 18 },
+ /* 6401 */ { MAD_F(0x074105b8) /* 0.453374595 */, 18 },
+ /* 6402 */ { MAD_F(0x074168bf) /* 0.453469036 */, 18 },
+ /* 6403 */ { MAD_F(0x0741cbc8) /* 0.453563482 */, 18 },
+ /* 6404 */ { MAD_F(0x07422ed2) /* 0.453657932 */, 18 },
+ /* 6405 */ { MAD_F(0x074291dd) /* 0.453752388 */, 18 },
+ /* 6406 */ { MAD_F(0x0742f4e9) /* 0.453846848 */, 18 },
+ /* 6407 */ { MAD_F(0x074357f7) /* 0.453941314 */, 18 },
+ /* 6408 */ { MAD_F(0x0743bb06) /* 0.454035784 */, 18 },
+ /* 6409 */ { MAD_F(0x07441e17) /* 0.454130259 */, 18 },
+ /* 6410 */ { MAD_F(0x07448129) /* 0.454224739 */, 18 },
+ /* 6411 */ { MAD_F(0x0744e43c) /* 0.454319224 */, 18 },
+ /* 6412 */ { MAD_F(0x07454750) /* 0.454413714 */, 18 },
+ /* 6413 */ { MAD_F(0x0745aa66) /* 0.454508209 */, 18 },
+ /* 6414 */ { MAD_F(0x07460d7d) /* 0.454602708 */, 18 },
+ /* 6415 */ { MAD_F(0x07467095) /* 0.454697213 */, 18 },
+
+ /* 6416 */ { MAD_F(0x0746d3af) /* 0.454791723 */, 18 },
+ /* 6417 */ { MAD_F(0x074736ca) /* 0.454886237 */, 18 },
+ /* 6418 */ { MAD_F(0x074799e7) /* 0.454980756 */, 18 },
+ /* 6419 */ { MAD_F(0x0747fd04) /* 0.455075281 */, 18 },
+ /* 6420 */ { MAD_F(0x07486023) /* 0.455169810 */, 18 },
+ /* 6421 */ { MAD_F(0x0748c344) /* 0.455264344 */, 18 },
+ /* 6422 */ { MAD_F(0x07492665) /* 0.455358883 */, 18 },
+ /* 6423 */ { MAD_F(0x07498988) /* 0.455453427 */, 18 },
+ /* 6424 */ { MAD_F(0x0749ecac) /* 0.455547976 */, 18 },
+ /* 6425 */ { MAD_F(0x074a4fd2) /* 0.455642529 */, 18 },
+ /* 6426 */ { MAD_F(0x074ab2f9) /* 0.455737088 */, 18 },
+ /* 6427 */ { MAD_F(0x074b1621) /* 0.455831652 */, 18 },
+ /* 6428 */ { MAD_F(0x074b794b) /* 0.455926220 */, 18 },
+ /* 6429 */ { MAD_F(0x074bdc75) /* 0.456020793 */, 18 },
+ /* 6430 */ { MAD_F(0x074c3fa1) /* 0.456115372 */, 18 },
+ /* 6431 */ { MAD_F(0x074ca2cf) /* 0.456209955 */, 18 },
+
+ /* 6432 */ { MAD_F(0x074d05fe) /* 0.456304543 */, 18 },
+ /* 6433 */ { MAD_F(0x074d692e) /* 0.456399136 */, 18 },
+ /* 6434 */ { MAD_F(0x074dcc5f) /* 0.456493733 */, 18 },
+ /* 6435 */ { MAD_F(0x074e2f92) /* 0.456588336 */, 18 },
+ /* 6436 */ { MAD_F(0x074e92c6) /* 0.456682944 */, 18 },
+ /* 6437 */ { MAD_F(0x074ef5fb) /* 0.456777556 */, 18 },
+ /* 6438 */ { MAD_F(0x074f5932) /* 0.456872174 */, 18 },
+ /* 6439 */ { MAD_F(0x074fbc6a) /* 0.456966796 */, 18 },
+ /* 6440 */ { MAD_F(0x07501fa3) /* 0.457061423 */, 18 },
+ /* 6441 */ { MAD_F(0x075082de) /* 0.457156056 */, 18 },
+ /* 6442 */ { MAD_F(0x0750e61a) /* 0.457250693 */, 18 },
+ /* 6443 */ { MAD_F(0x07514957) /* 0.457345335 */, 18 },
+ /* 6444 */ { MAD_F(0x0751ac96) /* 0.457439981 */, 18 },
+ /* 6445 */ { MAD_F(0x07520fd6) /* 0.457534633 */, 18 },
+ /* 6446 */ { MAD_F(0x07527317) /* 0.457629290 */, 18 },
+ /* 6447 */ { MAD_F(0x0752d659) /* 0.457723951 */, 18 },
+
+ /* 6448 */ { MAD_F(0x0753399d) /* 0.457818618 */, 18 },
+ /* 6449 */ { MAD_F(0x07539ce2) /* 0.457913289 */, 18 },
+ /* 6450 */ { MAD_F(0x07540029) /* 0.458007965 */, 18 },
+ /* 6451 */ { MAD_F(0x07546371) /* 0.458102646 */, 18 },
+ /* 6452 */ { MAD_F(0x0754c6ba) /* 0.458197332 */, 18 },
+ /* 6453 */ { MAD_F(0x07552a04) /* 0.458292023 */, 18 },
+ /* 6454 */ { MAD_F(0x07558d50) /* 0.458386719 */, 18 },
+ /* 6455 */ { MAD_F(0x0755f09d) /* 0.458481420 */, 18 },
+ /* 6456 */ { MAD_F(0x075653eb) /* 0.458576125 */, 18 },
+ /* 6457 */ { MAD_F(0x0756b73b) /* 0.458670836 */, 18 },
+ /* 6458 */ { MAD_F(0x07571a8c) /* 0.458765551 */, 18 },
+ /* 6459 */ { MAD_F(0x07577dde) /* 0.458860271 */, 18 },
+ /* 6460 */ { MAD_F(0x0757e131) /* 0.458954996 */, 18 },
+ /* 6461 */ { MAD_F(0x07584486) /* 0.459049726 */, 18 },
+ /* 6462 */ { MAD_F(0x0758a7dd) /* 0.459144461 */, 18 },
+ /* 6463 */ { MAD_F(0x07590b34) /* 0.459239201 */, 18 },
+
+ /* 6464 */ { MAD_F(0x07596e8d) /* 0.459333946 */, 18 },
+ /* 6465 */ { MAD_F(0x0759d1e7) /* 0.459428695 */, 18 },
+ /* 6466 */ { MAD_F(0x075a3542) /* 0.459523450 */, 18 },
+ /* 6467 */ { MAD_F(0x075a989f) /* 0.459618209 */, 18 },
+ /* 6468 */ { MAD_F(0x075afbfd) /* 0.459712973 */, 18 },
+ /* 6469 */ { MAD_F(0x075b5f5d) /* 0.459807742 */, 18 },
+ /* 6470 */ { MAD_F(0x075bc2bd) /* 0.459902516 */, 18 },
+ /* 6471 */ { MAD_F(0x075c261f) /* 0.459997295 */, 18 },
+ /* 6472 */ { MAD_F(0x075c8983) /* 0.460092079 */, 18 },
+ /* 6473 */ { MAD_F(0x075cece7) /* 0.460186867 */, 18 },
+ /* 6474 */ { MAD_F(0x075d504d) /* 0.460281661 */, 18 },
+ /* 6475 */ { MAD_F(0x075db3b5) /* 0.460376459 */, 18 },
+ /* 6476 */ { MAD_F(0x075e171d) /* 0.460471262 */, 18 },
+ /* 6477 */ { MAD_F(0x075e7a87) /* 0.460566071 */, 18 },
+ /* 6478 */ { MAD_F(0x075eddf2) /* 0.460660884 */, 18 },
+ /* 6479 */ { MAD_F(0x075f415f) /* 0.460755701 */, 18 },
+
+ /* 6480 */ { MAD_F(0x075fa4cc) /* 0.460850524 */, 18 },
+ /* 6481 */ { MAD_F(0x0760083b) /* 0.460945352 */, 18 },
+ /* 6482 */ { MAD_F(0x07606bac) /* 0.461040184 */, 18 },
+ /* 6483 */ { MAD_F(0x0760cf1e) /* 0.461135022 */, 18 },
+ /* 6484 */ { MAD_F(0x07613291) /* 0.461229864 */, 18 },
+ /* 6485 */ { MAD_F(0x07619605) /* 0.461324711 */, 18 },
+ /* 6486 */ { MAD_F(0x0761f97b) /* 0.461419563 */, 18 },
+ /* 6487 */ { MAD_F(0x07625cf2) /* 0.461514420 */, 18 },
+ /* 6488 */ { MAD_F(0x0762c06a) /* 0.461609282 */, 18 },
+ /* 6489 */ { MAD_F(0x076323e3) /* 0.461704149 */, 18 },
+ /* 6490 */ { MAD_F(0x0763875e) /* 0.461799020 */, 18 },
+ /* 6491 */ { MAD_F(0x0763eadb) /* 0.461893897 */, 18 },
+ /* 6492 */ { MAD_F(0x07644e58) /* 0.461988778 */, 18 },
+ /* 6493 */ { MAD_F(0x0764b1d7) /* 0.462083664 */, 18 },
+ /* 6494 */ { MAD_F(0x07651557) /* 0.462178555 */, 18 },
+ /* 6495 */ { MAD_F(0x076578d8) /* 0.462273451 */, 18 },
+
+ /* 6496 */ { MAD_F(0x0765dc5b) /* 0.462368352 */, 18 },
+ /* 6497 */ { MAD_F(0x07663fdf) /* 0.462463257 */, 18 },
+ /* 6498 */ { MAD_F(0x0766a364) /* 0.462558168 */, 18 },
+ /* 6499 */ { MAD_F(0x076706eb) /* 0.462653083 */, 18 },
+ /* 6500 */ { MAD_F(0x07676a73) /* 0.462748003 */, 18 },
+ /* 6501 */ { MAD_F(0x0767cdfc) /* 0.462842928 */, 18 },
+ /* 6502 */ { MAD_F(0x07683187) /* 0.462937858 */, 18 },
+ /* 6503 */ { MAD_F(0x07689513) /* 0.463032793 */, 18 },
+ /* 6504 */ { MAD_F(0x0768f8a0) /* 0.463127733 */, 18 },
+ /* 6505 */ { MAD_F(0x07695c2e) /* 0.463222678 */, 18 },
+ /* 6506 */ { MAD_F(0x0769bfbe) /* 0.463317627 */, 18 },
+ /* 6507 */ { MAD_F(0x076a234f) /* 0.463412581 */, 18 },
+ /* 6508 */ { MAD_F(0x076a86e2) /* 0.463507540 */, 18 },
+ /* 6509 */ { MAD_F(0x076aea75) /* 0.463602504 */, 18 },
+ /* 6510 */ { MAD_F(0x076b4e0a) /* 0.463697473 */, 18 },
+ /* 6511 */ { MAD_F(0x076bb1a1) /* 0.463792447 */, 18 },
+
+ /* 6512 */ { MAD_F(0x076c1538) /* 0.463887426 */, 18 },
+ /* 6513 */ { MAD_F(0x076c78d1) /* 0.463982409 */, 18 },
+ /* 6514 */ { MAD_F(0x076cdc6c) /* 0.464077398 */, 18 },
+ /* 6515 */ { MAD_F(0x076d4007) /* 0.464172391 */, 18 },
+ /* 6516 */ { MAD_F(0x076da3a4) /* 0.464267389 */, 18 },
+ /* 6517 */ { MAD_F(0x076e0742) /* 0.464362392 */, 18 },
+ /* 6518 */ { MAD_F(0x076e6ae2) /* 0.464457399 */, 18 },
+ /* 6519 */ { MAD_F(0x076ece82) /* 0.464552412 */, 18 },
+ /* 6520 */ { MAD_F(0x076f3224) /* 0.464647430 */, 18 },
+ /* 6521 */ { MAD_F(0x076f95c8) /* 0.464742452 */, 18 },
+ /* 6522 */ { MAD_F(0x076ff96c) /* 0.464837479 */, 18 },
+ /* 6523 */ { MAD_F(0x07705d12) /* 0.464932511 */, 18 },
+ /* 6524 */ { MAD_F(0x0770c0ba) /* 0.465027548 */, 18 },
+ /* 6525 */ { MAD_F(0x07712462) /* 0.465122590 */, 18 },
+ /* 6526 */ { MAD_F(0x0771880c) /* 0.465217637 */, 18 },
+ /* 6527 */ { MAD_F(0x0771ebb7) /* 0.465312688 */, 18 },
+
+ /* 6528 */ { MAD_F(0x07724f64) /* 0.465407744 */, 18 },
+ /* 6529 */ { MAD_F(0x0772b312) /* 0.465502806 */, 18 },
+ /* 6530 */ { MAD_F(0x077316c1) /* 0.465597872 */, 18 },
+ /* 6531 */ { MAD_F(0x07737a71) /* 0.465692943 */, 18 },
+ /* 6532 */ { MAD_F(0x0773de23) /* 0.465788018 */, 18 },
+ /* 6533 */ { MAD_F(0x077441d6) /* 0.465883099 */, 18 },
+ /* 6534 */ { MAD_F(0x0774a58a) /* 0.465978184 */, 18 },
+ /* 6535 */ { MAD_F(0x07750940) /* 0.466073275 */, 18 },
+ /* 6536 */ { MAD_F(0x07756cf7) /* 0.466168370 */, 18 },
+ /* 6537 */ { MAD_F(0x0775d0af) /* 0.466263470 */, 18 },
+ /* 6538 */ { MAD_F(0x07763468) /* 0.466358575 */, 18 },
+ /* 6539 */ { MAD_F(0x07769823) /* 0.466453684 */, 18 },
+ /* 6540 */ { MAD_F(0x0776fbdf) /* 0.466548799 */, 18 },
+ /* 6541 */ { MAD_F(0x07775f9d) /* 0.466643918 */, 18 },
+ /* 6542 */ { MAD_F(0x0777c35c) /* 0.466739043 */, 18 },
+ /* 6543 */ { MAD_F(0x0778271c) /* 0.466834172 */, 18 },
+
+ /* 6544 */ { MAD_F(0x07788add) /* 0.466929306 */, 18 },
+ /* 6545 */ { MAD_F(0x0778ee9f) /* 0.467024445 */, 18 },
+ /* 6546 */ { MAD_F(0x07795263) /* 0.467119588 */, 18 },
+ /* 6547 */ { MAD_F(0x0779b629) /* 0.467214737 */, 18 },
+ /* 6548 */ { MAD_F(0x077a19ef) /* 0.467309890 */, 18 },
+ /* 6549 */ { MAD_F(0x077a7db7) /* 0.467405048 */, 18 },
+ /* 6550 */ { MAD_F(0x077ae180) /* 0.467500211 */, 18 },
+ /* 6551 */ { MAD_F(0x077b454b) /* 0.467595379 */, 18 },
+ /* 6552 */ { MAD_F(0x077ba916) /* 0.467690552 */, 18 },
+ /* 6553 */ { MAD_F(0x077c0ce3) /* 0.467785729 */, 18 },
+ /* 6554 */ { MAD_F(0x077c70b2) /* 0.467880912 */, 18 },
+ /* 6555 */ { MAD_F(0x077cd481) /* 0.467976099 */, 18 },
+ /* 6556 */ { MAD_F(0x077d3852) /* 0.468071291 */, 18 },
+ /* 6557 */ { MAD_F(0x077d9c24) /* 0.468166488 */, 18 },
+ /* 6558 */ { MAD_F(0x077dfff8) /* 0.468261690 */, 18 },
+ /* 6559 */ { MAD_F(0x077e63cd) /* 0.468356896 */, 18 },
+
+ /* 6560 */ { MAD_F(0x077ec7a3) /* 0.468452108 */, 18 },
+ /* 6561 */ { MAD_F(0x077f2b7a) /* 0.468547324 */, 18 },
+ /* 6562 */ { MAD_F(0x077f8f53) /* 0.468642545 */, 18 },
+ /* 6563 */ { MAD_F(0x077ff32d) /* 0.468737771 */, 18 },
+ /* 6564 */ { MAD_F(0x07805708) /* 0.468833002 */, 18 },
+ /* 6565 */ { MAD_F(0x0780bae5) /* 0.468928237 */, 18 },
+ /* 6566 */ { MAD_F(0x07811ec3) /* 0.469023478 */, 18 },
+ /* 6567 */ { MAD_F(0x078182a2) /* 0.469118723 */, 18 },
+ /* 6568 */ { MAD_F(0x0781e683) /* 0.469213973 */, 18 },
+ /* 6569 */ { MAD_F(0x07824a64) /* 0.469309228 */, 18 },
+ /* 6570 */ { MAD_F(0x0782ae47) /* 0.469404488 */, 18 },
+ /* 6571 */ { MAD_F(0x0783122c) /* 0.469499752 */, 18 },
+ /* 6572 */ { MAD_F(0x07837612) /* 0.469595022 */, 18 },
+ /* 6573 */ { MAD_F(0x0783d9f9) /* 0.469690296 */, 18 },
+ /* 6574 */ { MAD_F(0x07843de1) /* 0.469785575 */, 18 },
+ /* 6575 */ { MAD_F(0x0784a1ca) /* 0.469880859 */, 18 },
+
+ /* 6576 */ { MAD_F(0x078505b5) /* 0.469976148 */, 18 },
+ /* 6577 */ { MAD_F(0x078569a2) /* 0.470071442 */, 18 },
+ /* 6578 */ { MAD_F(0x0785cd8f) /* 0.470166740 */, 18 },
+ /* 6579 */ { MAD_F(0x0786317e) /* 0.470262043 */, 18 },
+ /* 6580 */ { MAD_F(0x0786956e) /* 0.470357351 */, 18 },
+ /* 6581 */ { MAD_F(0x0786f95f) /* 0.470452664 */, 18 },
+ /* 6582 */ { MAD_F(0x07875d52) /* 0.470547982 */, 18 },
+ /* 6583 */ { MAD_F(0x0787c146) /* 0.470643305 */, 18 },
+ /* 6584 */ { MAD_F(0x0788253b) /* 0.470738632 */, 18 },
+ /* 6585 */ { MAD_F(0x07888932) /* 0.470833964 */, 18 },
+ /* 6586 */ { MAD_F(0x0788ed2a) /* 0.470929301 */, 18 },
+ /* 6587 */ { MAD_F(0x07895123) /* 0.471024643 */, 18 },
+ /* 6588 */ { MAD_F(0x0789b51d) /* 0.471119990 */, 18 },
+ /* 6589 */ { MAD_F(0x078a1919) /* 0.471215341 */, 18 },
+ /* 6590 */ { MAD_F(0x078a7d16) /* 0.471310698 */, 18 },
+ /* 6591 */ { MAD_F(0x078ae114) /* 0.471406059 */, 18 },
+
+ /* 6592 */ { MAD_F(0x078b4514) /* 0.471501425 */, 18 },
+ /* 6593 */ { MAD_F(0x078ba915) /* 0.471596796 */, 18 },
+ /* 6594 */ { MAD_F(0x078c0d17) /* 0.471692171 */, 18 },
+ /* 6595 */ { MAD_F(0x078c711a) /* 0.471787552 */, 18 },
+ /* 6596 */ { MAD_F(0x078cd51f) /* 0.471882937 */, 18 },
+ /* 6597 */ { MAD_F(0x078d3925) /* 0.471978327 */, 18 },
+ /* 6598 */ { MAD_F(0x078d9d2d) /* 0.472073722 */, 18 },
+ /* 6599 */ { MAD_F(0x078e0135) /* 0.472169122 */, 18 },
+ /* 6600 */ { MAD_F(0x078e653f) /* 0.472264527 */, 18 },
+ /* 6601 */ { MAD_F(0x078ec94b) /* 0.472359936 */, 18 },
+ /* 6602 */ { MAD_F(0x078f2d57) /* 0.472455350 */, 18 },
+ /* 6603 */ { MAD_F(0x078f9165) /* 0.472550769 */, 18 },
+ /* 6604 */ { MAD_F(0x078ff574) /* 0.472646193 */, 18 },
+ /* 6605 */ { MAD_F(0x07905985) /* 0.472741622 */, 18 },
+ /* 6606 */ { MAD_F(0x0790bd96) /* 0.472837055 */, 18 },
+ /* 6607 */ { MAD_F(0x079121a9) /* 0.472932493 */, 18 },
+
+ /* 6608 */ { MAD_F(0x079185be) /* 0.473027937 */, 18 },
+ /* 6609 */ { MAD_F(0x0791e9d3) /* 0.473123384 */, 18 },
+ /* 6610 */ { MAD_F(0x07924dea) /* 0.473218837 */, 18 },
+ /* 6611 */ { MAD_F(0x0792b202) /* 0.473314295 */, 18 },
+ /* 6612 */ { MAD_F(0x0793161c) /* 0.473409757 */, 18 },
+ /* 6613 */ { MAD_F(0x07937a37) /* 0.473505224 */, 18 },
+ /* 6614 */ { MAD_F(0x0793de53) /* 0.473600696 */, 18 },
+ /* 6615 */ { MAD_F(0x07944270) /* 0.473696173 */, 18 },
+ /* 6616 */ { MAD_F(0x0794a68f) /* 0.473791655 */, 18 },
+ /* 6617 */ { MAD_F(0x07950aaf) /* 0.473887141 */, 18 },
+ /* 6618 */ { MAD_F(0x07956ed0) /* 0.473982632 */, 18 },
+ /* 6619 */ { MAD_F(0x0795d2f2) /* 0.474078128 */, 18 },
+ /* 6620 */ { MAD_F(0x07963716) /* 0.474173629 */, 18 },
+ /* 6621 */ { MAD_F(0x07969b3b) /* 0.474269135 */, 18 },
+ /* 6622 */ { MAD_F(0x0796ff62) /* 0.474364645 */, 18 },
+ /* 6623 */ { MAD_F(0x07976389) /* 0.474460161 */, 18 },
+
+ /* 6624 */ { MAD_F(0x0797c7b2) /* 0.474555681 */, 18 },
+ /* 6625 */ { MAD_F(0x07982bdd) /* 0.474651205 */, 18 },
+ /* 6626 */ { MAD_F(0x07989008) /* 0.474746735 */, 18 },
+ /* 6627 */ { MAD_F(0x0798f435) /* 0.474842270 */, 18 },
+ /* 6628 */ { MAD_F(0x07995863) /* 0.474937809 */, 18 },
+ /* 6629 */ { MAD_F(0x0799bc92) /* 0.475033353 */, 18 },
+ /* 6630 */ { MAD_F(0x079a20c3) /* 0.475128902 */, 18 },
+ /* 6631 */ { MAD_F(0x079a84f5) /* 0.475224456 */, 18 },
+ /* 6632 */ { MAD_F(0x079ae929) /* 0.475320014 */, 18 },
+ /* 6633 */ { MAD_F(0x079b4d5d) /* 0.475415578 */, 18 },
+ /* 6634 */ { MAD_F(0x079bb193) /* 0.475511146 */, 18 },
+ /* 6635 */ { MAD_F(0x079c15ca) /* 0.475606719 */, 18 },
+ /* 6636 */ { MAD_F(0x079c7a03) /* 0.475702296 */, 18 },
+ /* 6637 */ { MAD_F(0x079cde3c) /* 0.475797879 */, 18 },
+ /* 6638 */ { MAD_F(0x079d4277) /* 0.475893466 */, 18 },
+ /* 6639 */ { MAD_F(0x079da6b4) /* 0.475989058 */, 18 },
+
+ /* 6640 */ { MAD_F(0x079e0af1) /* 0.476084655 */, 18 },
+ /* 6641 */ { MAD_F(0x079e6f30) /* 0.476180257 */, 18 },
+ /* 6642 */ { MAD_F(0x079ed370) /* 0.476275863 */, 18 },
+ /* 6643 */ { MAD_F(0x079f37b2) /* 0.476371475 */, 18 },
+ /* 6644 */ { MAD_F(0x079f9bf5) /* 0.476467091 */, 18 },
+ /* 6645 */ { MAD_F(0x07a00039) /* 0.476562712 */, 18 },
+ /* 6646 */ { MAD_F(0x07a0647e) /* 0.476658338 */, 18 },
+ /* 6647 */ { MAD_F(0x07a0c8c5) /* 0.476753968 */, 18 },
+ /* 6648 */ { MAD_F(0x07a12d0c) /* 0.476849603 */, 18 },
+ /* 6649 */ { MAD_F(0x07a19156) /* 0.476945243 */, 18 },
+ /* 6650 */ { MAD_F(0x07a1f5a0) /* 0.477040888 */, 18 },
+ /* 6651 */ { MAD_F(0x07a259ec) /* 0.477136538 */, 18 },
+ /* 6652 */ { MAD_F(0x07a2be39) /* 0.477232193 */, 18 },
+ /* 6653 */ { MAD_F(0x07a32287) /* 0.477327852 */, 18 },
+ /* 6654 */ { MAD_F(0x07a386d7) /* 0.477423516 */, 18 },
+ /* 6655 */ { MAD_F(0x07a3eb28) /* 0.477519185 */, 18 },
+
+ /* 6656 */ { MAD_F(0x07a44f7a) /* 0.477614858 */, 18 },
+ /* 6657 */ { MAD_F(0x07a4b3ce) /* 0.477710537 */, 18 },
+ /* 6658 */ { MAD_F(0x07a51822) /* 0.477806220 */, 18 },
+ /* 6659 */ { MAD_F(0x07a57c78) /* 0.477901908 */, 18 },
+ /* 6660 */ { MAD_F(0x07a5e0d0) /* 0.477997601 */, 18 },
+ /* 6661 */ { MAD_F(0x07a64528) /* 0.478093299 */, 18 },
+ /* 6662 */ { MAD_F(0x07a6a982) /* 0.478189001 */, 18 },
+ /* 6663 */ { MAD_F(0x07a70ddd) /* 0.478284708 */, 18 },
+ /* 6664 */ { MAD_F(0x07a7723a) /* 0.478380420 */, 18 },
+ /* 6665 */ { MAD_F(0x07a7d698) /* 0.478476137 */, 18 },
+ /* 6666 */ { MAD_F(0x07a83af7) /* 0.478571858 */, 18 },
+ /* 6667 */ { MAD_F(0x07a89f57) /* 0.478667585 */, 18 },
+ /* 6668 */ { MAD_F(0x07a903b9) /* 0.478763316 */, 18 },
+ /* 6669 */ { MAD_F(0x07a9681c) /* 0.478859052 */, 18 },
+ /* 6670 */ { MAD_F(0x07a9cc80) /* 0.478954793 */, 18 },
+ /* 6671 */ { MAD_F(0x07aa30e5) /* 0.479050538 */, 18 },
+
+ /* 6672 */ { MAD_F(0x07aa954c) /* 0.479146288 */, 18 },
+ /* 6673 */ { MAD_F(0x07aaf9b4) /* 0.479242043 */, 18 },
+ /* 6674 */ { MAD_F(0x07ab5e1e) /* 0.479337803 */, 18 },
+ /* 6675 */ { MAD_F(0x07abc288) /* 0.479433568 */, 18 },
+ /* 6676 */ { MAD_F(0x07ac26f4) /* 0.479529337 */, 18 },
+ /* 6677 */ { MAD_F(0x07ac8b61) /* 0.479625111 */, 18 },
+ /* 6678 */ { MAD_F(0x07acefd0) /* 0.479720890 */, 18 },
+ /* 6679 */ { MAD_F(0x07ad543f) /* 0.479816674 */, 18 },
+ /* 6680 */ { MAD_F(0x07adb8b0) /* 0.479912463 */, 18 },
+ /* 6681 */ { MAD_F(0x07ae1d23) /* 0.480008256 */, 18 },
+ /* 6682 */ { MAD_F(0x07ae8196) /* 0.480104054 */, 18 },
+ /* 6683 */ { MAD_F(0x07aee60b) /* 0.480199857 */, 18 },
+ /* 6684 */ { MAD_F(0x07af4a81) /* 0.480295664 */, 18 },
+ /* 6685 */ { MAD_F(0x07afaef9) /* 0.480391477 */, 18 },
+ /* 6686 */ { MAD_F(0x07b01372) /* 0.480487294 */, 18 },
+ /* 6687 */ { MAD_F(0x07b077ec) /* 0.480583116 */, 18 },
+
+ /* 6688 */ { MAD_F(0x07b0dc67) /* 0.480678943 */, 18 },
+ /* 6689 */ { MAD_F(0x07b140e4) /* 0.480774774 */, 18 },
+ /* 6690 */ { MAD_F(0x07b1a561) /* 0.480870611 */, 18 },
+ /* 6691 */ { MAD_F(0x07b209e1) /* 0.480966452 */, 18 },
+ /* 6692 */ { MAD_F(0x07b26e61) /* 0.481062298 */, 18 },
+ /* 6693 */ { MAD_F(0x07b2d2e3) /* 0.481158148 */, 18 },
+ /* 6694 */ { MAD_F(0x07b33766) /* 0.481254004 */, 18 },
+ /* 6695 */ { MAD_F(0x07b39bea) /* 0.481349864 */, 18 },
+ /* 6696 */ { MAD_F(0x07b4006f) /* 0.481445729 */, 18 },
+ /* 6697 */ { MAD_F(0x07b464f6) /* 0.481541598 */, 18 },
+ /* 6698 */ { MAD_F(0x07b4c97e) /* 0.481637473 */, 18 },
+ /* 6699 */ { MAD_F(0x07b52e08) /* 0.481733352 */, 18 },
+ /* 6700 */ { MAD_F(0x07b59292) /* 0.481829236 */, 18 },
+ /* 6701 */ { MAD_F(0x07b5f71e) /* 0.481925125 */, 18 },
+ /* 6702 */ { MAD_F(0x07b65bac) /* 0.482021019 */, 18 },
+ /* 6703 */ { MAD_F(0x07b6c03a) /* 0.482116917 */, 18 },
+
+ /* 6704 */ { MAD_F(0x07b724ca) /* 0.482212820 */, 18 },
+ /* 6705 */ { MAD_F(0x07b7895b) /* 0.482308728 */, 18 },
+ /* 6706 */ { MAD_F(0x07b7eded) /* 0.482404640 */, 18 },
+ /* 6707 */ { MAD_F(0x07b85281) /* 0.482500558 */, 18 },
+ /* 6708 */ { MAD_F(0x07b8b716) /* 0.482596480 */, 18 },
+ /* 6709 */ { MAD_F(0x07b91bac) /* 0.482692407 */, 18 },
+ /* 6710 */ { MAD_F(0x07b98044) /* 0.482788339 */, 18 },
+ /* 6711 */ { MAD_F(0x07b9e4dc) /* 0.482884275 */, 18 },
+ /* 6712 */ { MAD_F(0x07ba4976) /* 0.482980216 */, 18 },
+ /* 6713 */ { MAD_F(0x07baae12) /* 0.483076162 */, 18 },
+ /* 6714 */ { MAD_F(0x07bb12ae) /* 0.483172113 */, 18 },
+ /* 6715 */ { MAD_F(0x07bb774c) /* 0.483268069 */, 18 },
+ /* 6716 */ { MAD_F(0x07bbdbeb) /* 0.483364029 */, 18 },
+ /* 6717 */ { MAD_F(0x07bc408c) /* 0.483459994 */, 18 },
+ /* 6718 */ { MAD_F(0x07bca52d) /* 0.483555964 */, 18 },
+ /* 6719 */ { MAD_F(0x07bd09d0) /* 0.483651939 */, 18 },
+
+ /* 6720 */ { MAD_F(0x07bd6e75) /* 0.483747918 */, 18 },
+ /* 6721 */ { MAD_F(0x07bdd31a) /* 0.483843902 */, 18 },
+ /* 6722 */ { MAD_F(0x07be37c1) /* 0.483939891 */, 18 },
+ /* 6723 */ { MAD_F(0x07be9c69) /* 0.484035885 */, 18 },
+ /* 6724 */ { MAD_F(0x07bf0113) /* 0.484131883 */, 18 },
+ /* 6725 */ { MAD_F(0x07bf65bd) /* 0.484227886 */, 18 },
+ /* 6726 */ { MAD_F(0x07bfca69) /* 0.484323894 */, 18 },
+ /* 6727 */ { MAD_F(0x07c02f16) /* 0.484419907 */, 18 },
+ /* 6728 */ { MAD_F(0x07c093c5) /* 0.484515924 */, 18 },
+ /* 6729 */ { MAD_F(0x07c0f875) /* 0.484611946 */, 18 },
+ /* 6730 */ { MAD_F(0x07c15d26) /* 0.484707973 */, 18 },
+ /* 6731 */ { MAD_F(0x07c1c1d8) /* 0.484804005 */, 18 },
+ /* 6732 */ { MAD_F(0x07c2268b) /* 0.484900041 */, 18 },
+ /* 6733 */ { MAD_F(0x07c28b40) /* 0.484996083 */, 18 },
+ /* 6734 */ { MAD_F(0x07c2eff6) /* 0.485092128 */, 18 },
+ /* 6735 */ { MAD_F(0x07c354ae) /* 0.485188179 */, 18 },
+
+ /* 6736 */ { MAD_F(0x07c3b967) /* 0.485284235 */, 18 },
+ /* 6737 */ { MAD_F(0x07c41e21) /* 0.485380295 */, 18 },
+ /* 6738 */ { MAD_F(0x07c482dc) /* 0.485476360 */, 18 },
+ /* 6739 */ { MAD_F(0x07c4e798) /* 0.485572430 */, 18 },
+ /* 6740 */ { MAD_F(0x07c54c56) /* 0.485668504 */, 18 },
+ /* 6741 */ { MAD_F(0x07c5b115) /* 0.485764583 */, 18 },
+ /* 6742 */ { MAD_F(0x07c615d6) /* 0.485860667 */, 18 },
+ /* 6743 */ { MAD_F(0x07c67a97) /* 0.485956756 */, 18 },
+ /* 6744 */ { MAD_F(0x07c6df5a) /* 0.486052849 */, 18 },
+ /* 6745 */ { MAD_F(0x07c7441e) /* 0.486148948 */, 18 },
+ /* 6746 */ { MAD_F(0x07c7a8e4) /* 0.486245051 */, 18 },
+ /* 6747 */ { MAD_F(0x07c80daa) /* 0.486341158 */, 18 },
+ /* 6748 */ { MAD_F(0x07c87272) /* 0.486437271 */, 18 },
+ /* 6749 */ { MAD_F(0x07c8d73c) /* 0.486533388 */, 18 },
+ /* 6750 */ { MAD_F(0x07c93c06) /* 0.486629510 */, 18 },
+ /* 6751 */ { MAD_F(0x07c9a0d2) /* 0.486725637 */, 18 },
+
+ /* 6752 */ { MAD_F(0x07ca059f) /* 0.486821768 */, 18 },
+ /* 6753 */ { MAD_F(0x07ca6a6d) /* 0.486917905 */, 18 },
+ /* 6754 */ { MAD_F(0x07cacf3d) /* 0.487014045 */, 18 },
+ /* 6755 */ { MAD_F(0x07cb340e) /* 0.487110191 */, 18 },
+ /* 6756 */ { MAD_F(0x07cb98e0) /* 0.487206342 */, 18 },
+ /* 6757 */ { MAD_F(0x07cbfdb4) /* 0.487302497 */, 18 },
+ /* 6758 */ { MAD_F(0x07cc6288) /* 0.487398657 */, 18 },
+ /* 6759 */ { MAD_F(0x07ccc75e) /* 0.487494821 */, 18 },
+ /* 6760 */ { MAD_F(0x07cd2c36) /* 0.487590991 */, 18 },
+ /* 6761 */ { MAD_F(0x07cd910e) /* 0.487687165 */, 18 },
+ /* 6762 */ { MAD_F(0x07cdf5e8) /* 0.487783344 */, 18 },
+ /* 6763 */ { MAD_F(0x07ce5ac3) /* 0.487879528 */, 18 },
+ /* 6764 */ { MAD_F(0x07cebfa0) /* 0.487975716 */, 18 },
+ /* 6765 */ { MAD_F(0x07cf247d) /* 0.488071909 */, 18 },
+ /* 6766 */ { MAD_F(0x07cf895c) /* 0.488168107 */, 18 },
+ /* 6767 */ { MAD_F(0x07cfee3c) /* 0.488264310 */, 18 },
+
+ /* 6768 */ { MAD_F(0x07d0531e) /* 0.488360517 */, 18 },
+ /* 6769 */ { MAD_F(0x07d0b801) /* 0.488456729 */, 18 },
+ /* 6770 */ { MAD_F(0x07d11ce5) /* 0.488552946 */, 18 },
+ /* 6771 */ { MAD_F(0x07d181ca) /* 0.488649167 */, 18 },
+ /* 6772 */ { MAD_F(0x07d1e6b0) /* 0.488745394 */, 18 },
+ /* 6773 */ { MAD_F(0x07d24b98) /* 0.488841625 */, 18 },
+ /* 6774 */ { MAD_F(0x07d2b081) /* 0.488937860 */, 18 },
+ /* 6775 */ { MAD_F(0x07d3156c) /* 0.489034101 */, 18 },
+ /* 6776 */ { MAD_F(0x07d37a57) /* 0.489130346 */, 18 },
+ /* 6777 */ { MAD_F(0x07d3df44) /* 0.489226596 */, 18 },
+ /* 6778 */ { MAD_F(0x07d44432) /* 0.489322851 */, 18 },
+ /* 6779 */ { MAD_F(0x07d4a922) /* 0.489419110 */, 18 },
+ /* 6780 */ { MAD_F(0x07d50e13) /* 0.489515375 */, 18 },
+ /* 6781 */ { MAD_F(0x07d57305) /* 0.489611643 */, 18 },
+ /* 6782 */ { MAD_F(0x07d5d7f8) /* 0.489707917 */, 18 },
+ /* 6783 */ { MAD_F(0x07d63cec) /* 0.489804195 */, 18 },
+
+ /* 6784 */ { MAD_F(0x07d6a1e2) /* 0.489900479 */, 18 },
+ /* 6785 */ { MAD_F(0x07d706d9) /* 0.489996766 */, 18 },
+ /* 6786 */ { MAD_F(0x07d76bd2) /* 0.490093059 */, 18 },
+ /* 6787 */ { MAD_F(0x07d7d0cb) /* 0.490189356 */, 18 },
+ /* 6788 */ { MAD_F(0x07d835c6) /* 0.490285658 */, 18 },
+ /* 6789 */ { MAD_F(0x07d89ac2) /* 0.490381965 */, 18 },
+ /* 6790 */ { MAD_F(0x07d8ffc0) /* 0.490478277 */, 18 },
+ /* 6791 */ { MAD_F(0x07d964be) /* 0.490574593 */, 18 },
+ /* 6792 */ { MAD_F(0x07d9c9be) /* 0.490670914 */, 18 },
+ /* 6793 */ { MAD_F(0x07da2ebf) /* 0.490767239 */, 18 },
+ /* 6794 */ { MAD_F(0x07da93c2) /* 0.490863570 */, 18 },
+ /* 6795 */ { MAD_F(0x07daf8c6) /* 0.490959905 */, 18 },
+ /* 6796 */ { MAD_F(0x07db5dcb) /* 0.491056245 */, 18 },
+ /* 6797 */ { MAD_F(0x07dbc2d1) /* 0.491152589 */, 18 },
+ /* 6798 */ { MAD_F(0x07dc27d9) /* 0.491248939 */, 18 },
+ /* 6799 */ { MAD_F(0x07dc8ce1) /* 0.491345293 */, 18 },
+
+ /* 6800 */ { MAD_F(0x07dcf1ec) /* 0.491441651 */, 18 },
+ /* 6801 */ { MAD_F(0x07dd56f7) /* 0.491538015 */, 18 },
+ /* 6802 */ { MAD_F(0x07ddbc04) /* 0.491634383 */, 18 },
+ /* 6803 */ { MAD_F(0x07de2111) /* 0.491730756 */, 18 },
+ /* 6804 */ { MAD_F(0x07de8621) /* 0.491827134 */, 18 },
+ /* 6805 */ { MAD_F(0x07deeb31) /* 0.491923516 */, 18 },
+ /* 6806 */ { MAD_F(0x07df5043) /* 0.492019903 */, 18 },
+ /* 6807 */ { MAD_F(0x07dfb556) /* 0.492116295 */, 18 },
+ /* 6808 */ { MAD_F(0x07e01a6a) /* 0.492212691 */, 18 },
+ /* 6809 */ { MAD_F(0x07e07f80) /* 0.492309093 */, 18 },
+ /* 6810 */ { MAD_F(0x07e0e496) /* 0.492405499 */, 18 },
+ /* 6811 */ { MAD_F(0x07e149ae) /* 0.492501909 */, 18 },
+ /* 6812 */ { MAD_F(0x07e1aec8) /* 0.492598325 */, 18 },
+ /* 6813 */ { MAD_F(0x07e213e2) /* 0.492694745 */, 18 },
+ /* 6814 */ { MAD_F(0x07e278fe) /* 0.492791170 */, 18 },
+ /* 6815 */ { MAD_F(0x07e2de1b) /* 0.492887599 */, 18 },
+
+ /* 6816 */ { MAD_F(0x07e3433a) /* 0.492984033 */, 18 },
+ /* 6817 */ { MAD_F(0x07e3a859) /* 0.493080472 */, 18 },
+ /* 6818 */ { MAD_F(0x07e40d7a) /* 0.493176916 */, 18 },
+ /* 6819 */ { MAD_F(0x07e4729c) /* 0.493273365 */, 18 },
+ /* 6820 */ { MAD_F(0x07e4d7c0) /* 0.493369818 */, 18 },
+ /* 6821 */ { MAD_F(0x07e53ce4) /* 0.493466275 */, 18 },
+ /* 6822 */ { MAD_F(0x07e5a20a) /* 0.493562738 */, 18 },
+ /* 6823 */ { MAD_F(0x07e60732) /* 0.493659205 */, 18 },
+ /* 6824 */ { MAD_F(0x07e66c5a) /* 0.493755677 */, 18 },
+ /* 6825 */ { MAD_F(0x07e6d184) /* 0.493852154 */, 18 },
+ /* 6826 */ { MAD_F(0x07e736af) /* 0.493948635 */, 18 },
+ /* 6827 */ { MAD_F(0x07e79bdb) /* 0.494045122 */, 18 },
+ /* 6828 */ { MAD_F(0x07e80109) /* 0.494141612 */, 18 },
+ /* 6829 */ { MAD_F(0x07e86638) /* 0.494238108 */, 18 },
+ /* 6830 */ { MAD_F(0x07e8cb68) /* 0.494334608 */, 18 },
+ /* 6831 */ { MAD_F(0x07e93099) /* 0.494431113 */, 18 },
+
+ /* 6832 */ { MAD_F(0x07e995cc) /* 0.494527623 */, 18 },
+ /* 6833 */ { MAD_F(0x07e9fb00) /* 0.494624137 */, 18 },
+ /* 6834 */ { MAD_F(0x07ea6035) /* 0.494720656 */, 18 },
+ /* 6835 */ { MAD_F(0x07eac56b) /* 0.494817180 */, 18 },
+ /* 6836 */ { MAD_F(0x07eb2aa3) /* 0.494913709 */, 18 },
+ /* 6837 */ { MAD_F(0x07eb8fdc) /* 0.495010242 */, 18 },
+ /* 6838 */ { MAD_F(0x07ebf516) /* 0.495106780 */, 18 },
+ /* 6839 */ { MAD_F(0x07ec5a51) /* 0.495203322 */, 18 },
+ /* 6840 */ { MAD_F(0x07ecbf8e) /* 0.495299870 */, 18 },
+ /* 6841 */ { MAD_F(0x07ed24cc) /* 0.495396422 */, 18 },
+ /* 6842 */ { MAD_F(0x07ed8a0b) /* 0.495492978 */, 18 },
+ /* 6843 */ { MAD_F(0x07edef4c) /* 0.495589540 */, 18 },
+ /* 6844 */ { MAD_F(0x07ee548e) /* 0.495686106 */, 18 },
+ /* 6845 */ { MAD_F(0x07eeb9d1) /* 0.495782677 */, 18 },
+ /* 6846 */ { MAD_F(0x07ef1f15) /* 0.495879252 */, 18 },
+ /* 6847 */ { MAD_F(0x07ef845b) /* 0.495975833 */, 18 },
+
+ /* 6848 */ { MAD_F(0x07efe9a1) /* 0.496072418 */, 18 },
+ /* 6849 */ { MAD_F(0x07f04ee9) /* 0.496169007 */, 18 },
+ /* 6850 */ { MAD_F(0x07f0b433) /* 0.496265602 */, 18 },
+ /* 6851 */ { MAD_F(0x07f1197d) /* 0.496362201 */, 18 },
+ /* 6852 */ { MAD_F(0x07f17ec9) /* 0.496458804 */, 18 },
+ /* 6853 */ { MAD_F(0x07f1e416) /* 0.496555413 */, 18 },
+ /* 6854 */ { MAD_F(0x07f24965) /* 0.496652026 */, 18 },
+ /* 6855 */ { MAD_F(0x07f2aeb5) /* 0.496748644 */, 18 },
+ /* 6856 */ { MAD_F(0x07f31405) /* 0.496845266 */, 18 },
+ /* 6857 */ { MAD_F(0x07f37958) /* 0.496941894 */, 18 },
+ /* 6858 */ { MAD_F(0x07f3deab) /* 0.497038526 */, 18 },
+ /* 6859 */ { MAD_F(0x07f44400) /* 0.497135162 */, 18 },
+ /* 6860 */ { MAD_F(0x07f4a956) /* 0.497231804 */, 18 },
+ /* 6861 */ { MAD_F(0x07f50ead) /* 0.497328450 */, 18 },
+ /* 6862 */ { MAD_F(0x07f57405) /* 0.497425100 */, 18 },
+ /* 6863 */ { MAD_F(0x07f5d95f) /* 0.497521756 */, 18 },
+
+ /* 6864 */ { MAD_F(0x07f63eba) /* 0.497618416 */, 18 },
+ /* 6865 */ { MAD_F(0x07f6a416) /* 0.497715081 */, 18 },
+ /* 6866 */ { MAD_F(0x07f70974) /* 0.497811750 */, 18 },
+ /* 6867 */ { MAD_F(0x07f76ed3) /* 0.497908425 */, 18 },
+ /* 6868 */ { MAD_F(0x07f7d433) /* 0.498005103 */, 18 },
+ /* 6869 */ { MAD_F(0x07f83994) /* 0.498101787 */, 18 },
+ /* 6870 */ { MAD_F(0x07f89ef7) /* 0.498198475 */, 18 },
+ /* 6871 */ { MAD_F(0x07f9045a) /* 0.498295168 */, 18 },
+ /* 6872 */ { MAD_F(0x07f969c0) /* 0.498391866 */, 18 },
+ /* 6873 */ { MAD_F(0x07f9cf26) /* 0.498488568 */, 18 },
+ /* 6874 */ { MAD_F(0x07fa348e) /* 0.498585275 */, 18 },
+ /* 6875 */ { MAD_F(0x07fa99f6) /* 0.498681987 */, 18 },
+ /* 6876 */ { MAD_F(0x07faff60) /* 0.498778704 */, 18 },
+ /* 6877 */ { MAD_F(0x07fb64cc) /* 0.498875425 */, 18 },
+ /* 6878 */ { MAD_F(0x07fbca38) /* 0.498972150 */, 18 },
+ /* 6879 */ { MAD_F(0x07fc2fa6) /* 0.499068881 */, 18 },
+
+ /* 6880 */ { MAD_F(0x07fc9516) /* 0.499165616 */, 18 },
+ /* 6881 */ { MAD_F(0x07fcfa86) /* 0.499262356 */, 18 },
+ /* 6882 */ { MAD_F(0x07fd5ff8) /* 0.499359101 */, 18 },
+ /* 6883 */ { MAD_F(0x07fdc56b) /* 0.499455850 */, 18 },
+ /* 6884 */ { MAD_F(0x07fe2adf) /* 0.499552604 */, 18 },
+ /* 6885 */ { MAD_F(0x07fe9054) /* 0.499649362 */, 18 },
+ /* 6886 */ { MAD_F(0x07fef5cb) /* 0.499746126 */, 18 },
+ /* 6887 */ { MAD_F(0x07ff5b43) /* 0.499842894 */, 18 },
+ /* 6888 */ { MAD_F(0x07ffc0bc) /* 0.499939666 */, 18 },
+ /* 6889 */ { MAD_F(0x0400131b) /* 0.250018222 */, 19 },
+ /* 6890 */ { MAD_F(0x040045d9) /* 0.250066613 */, 19 },
+ /* 6891 */ { MAD_F(0x04007897) /* 0.250115006 */, 19 },
+ /* 6892 */ { MAD_F(0x0400ab57) /* 0.250163402 */, 19 },
+ /* 6893 */ { MAD_F(0x0400de16) /* 0.250211800 */, 19 },
+ /* 6894 */ { MAD_F(0x040110d7) /* 0.250260200 */, 19 },
+ /* 6895 */ { MAD_F(0x04014398) /* 0.250308603 */, 19 },
+
+ /* 6896 */ { MAD_F(0x04017659) /* 0.250357008 */, 19 },
+ /* 6897 */ { MAD_F(0x0401a91c) /* 0.250405415 */, 19 },
+ /* 6898 */ { MAD_F(0x0401dbdf) /* 0.250453825 */, 19 },
+ /* 6899 */ { MAD_F(0x04020ea2) /* 0.250502237 */, 19 },
+ /* 6900 */ { MAD_F(0x04024166) /* 0.250550652 */, 19 },
+ /* 6901 */ { MAD_F(0x0402742b) /* 0.250599068 */, 19 },
+ /* 6902 */ { MAD_F(0x0402a6f0) /* 0.250647488 */, 19 },
+ /* 6903 */ { MAD_F(0x0402d9b6) /* 0.250695909 */, 19 },
+ /* 6904 */ { MAD_F(0x04030c7d) /* 0.250744333 */, 19 },
+ /* 6905 */ { MAD_F(0x04033f44) /* 0.250792759 */, 19 },
+ /* 6906 */ { MAD_F(0x0403720c) /* 0.250841187 */, 19 },
+ /* 6907 */ { MAD_F(0x0403a4d5) /* 0.250889618 */, 19 },
+ /* 6908 */ { MAD_F(0x0403d79e) /* 0.250938051 */, 19 },
+ /* 6909 */ { MAD_F(0x04040a68) /* 0.250986487 */, 19 },
+ /* 6910 */ { MAD_F(0x04043d32) /* 0.251034924 */, 19 },
+ /* 6911 */ { MAD_F(0x04046ffd) /* 0.251083365 */, 19 },
+
+ /* 6912 */ { MAD_F(0x0404a2c9) /* 0.251131807 */, 19 },
+ /* 6913 */ { MAD_F(0x0404d595) /* 0.251180252 */, 19 },
+ /* 6914 */ { MAD_F(0x04050862) /* 0.251228699 */, 19 },
+ /* 6915 */ { MAD_F(0x04053b30) /* 0.251277148 */, 19 },
+ /* 6916 */ { MAD_F(0x04056dfe) /* 0.251325600 */, 19 },
+ /* 6917 */ { MAD_F(0x0405a0cd) /* 0.251374054 */, 19 },
+ /* 6918 */ { MAD_F(0x0405d39c) /* 0.251422511 */, 19 },
+ /* 6919 */ { MAD_F(0x0406066c) /* 0.251470970 */, 19 },
+ /* 6920 */ { MAD_F(0x0406393d) /* 0.251519431 */, 19 },
+ /* 6921 */ { MAD_F(0x04066c0e) /* 0.251567894 */, 19 },
+ /* 6922 */ { MAD_F(0x04069ee0) /* 0.251616360 */, 19 },
+ /* 6923 */ { MAD_F(0x0406d1b3) /* 0.251664828 */, 19 },
+ /* 6924 */ { MAD_F(0x04070486) /* 0.251713299 */, 19 },
+ /* 6925 */ { MAD_F(0x0407375a) /* 0.251761772 */, 19 },
+ /* 6926 */ { MAD_F(0x04076a2e) /* 0.251810247 */, 19 },
+ /* 6927 */ { MAD_F(0x04079d03) /* 0.251858724 */, 19 },
+
+ /* 6928 */ { MAD_F(0x0407cfd9) /* 0.251907204 */, 19 },
+ /* 6929 */ { MAD_F(0x040802af) /* 0.251955686 */, 19 },
+ /* 6930 */ { MAD_F(0x04083586) /* 0.252004171 */, 19 },
+ /* 6931 */ { MAD_F(0x0408685e) /* 0.252052658 */, 19 },
+ /* 6932 */ { MAD_F(0x04089b36) /* 0.252101147 */, 19 },
+ /* 6933 */ { MAD_F(0x0408ce0f) /* 0.252149638 */, 19 },
+ /* 6934 */ { MAD_F(0x040900e8) /* 0.252198132 */, 19 },
+ /* 6935 */ { MAD_F(0x040933c2) /* 0.252246628 */, 19 },
+ /* 6936 */ { MAD_F(0x0409669d) /* 0.252295127 */, 19 },
+ /* 6937 */ { MAD_F(0x04099978) /* 0.252343627 */, 19 },
+ /* 6938 */ { MAD_F(0x0409cc54) /* 0.252392131 */, 19 },
+ /* 6939 */ { MAD_F(0x0409ff31) /* 0.252440636 */, 19 },
+ /* 6940 */ { MAD_F(0x040a320e) /* 0.252489144 */, 19 },
+ /* 6941 */ { MAD_F(0x040a64ec) /* 0.252537654 */, 19 },
+ /* 6942 */ { MAD_F(0x040a97cb) /* 0.252586166 */, 19 },
+ /* 6943 */ { MAD_F(0x040acaaa) /* 0.252634681 */, 19 },
+
+ /* 6944 */ { MAD_F(0x040afd89) /* 0.252683198 */, 19 },
+ /* 6945 */ { MAD_F(0x040b306a) /* 0.252731718 */, 19 },
+ /* 6946 */ { MAD_F(0x040b634b) /* 0.252780240 */, 19 },
+ /* 6947 */ { MAD_F(0x040b962c) /* 0.252828764 */, 19 },
+ /* 6948 */ { MAD_F(0x040bc90e) /* 0.252877290 */, 19 },
+ /* 6949 */ { MAD_F(0x040bfbf1) /* 0.252925819 */, 19 },
+ /* 6950 */ { MAD_F(0x040c2ed5) /* 0.252974350 */, 19 },
+ /* 6951 */ { MAD_F(0x040c61b9) /* 0.253022883 */, 19 },
+ /* 6952 */ { MAD_F(0x040c949e) /* 0.253071419 */, 19 },
+ /* 6953 */ { MAD_F(0x040cc783) /* 0.253119957 */, 19 },
+ /* 6954 */ { MAD_F(0x040cfa69) /* 0.253168498 */, 19 },
+ /* 6955 */ { MAD_F(0x040d2d4f) /* 0.253217040 */, 19 },
+ /* 6956 */ { MAD_F(0x040d6037) /* 0.253265585 */, 19 },
+ /* 6957 */ { MAD_F(0x040d931e) /* 0.253314133 */, 19 },
+ /* 6958 */ { MAD_F(0x040dc607) /* 0.253362682 */, 19 },
+ /* 6959 */ { MAD_F(0x040df8f0) /* 0.253411234 */, 19 },
+
+ /* 6960 */ { MAD_F(0x040e2bda) /* 0.253459789 */, 19 },
+ /* 6961 */ { MAD_F(0x040e5ec4) /* 0.253508345 */, 19 },
+ /* 6962 */ { MAD_F(0x040e91af) /* 0.253556904 */, 19 },
+ /* 6963 */ { MAD_F(0x040ec49b) /* 0.253605466 */, 19 },
+ /* 6964 */ { MAD_F(0x040ef787) /* 0.253654029 */, 19 },
+ /* 6965 */ { MAD_F(0x040f2a74) /* 0.253702595 */, 19 },
+ /* 6966 */ { MAD_F(0x040f5d61) /* 0.253751164 */, 19 },
+ /* 6967 */ { MAD_F(0x040f904f) /* 0.253799734 */, 19 },
+ /* 6968 */ { MAD_F(0x040fc33e) /* 0.253848307 */, 19 },
+ /* 6969 */ { MAD_F(0x040ff62d) /* 0.253896883 */, 19 },
+ /* 6970 */ { MAD_F(0x0410291d) /* 0.253945460 */, 19 },
+ /* 6971 */ { MAD_F(0x04105c0e) /* 0.253994040 */, 19 },
+ /* 6972 */ { MAD_F(0x04108eff) /* 0.254042622 */, 19 },
+ /* 6973 */ { MAD_F(0x0410c1f1) /* 0.254091207 */, 19 },
+ /* 6974 */ { MAD_F(0x0410f4e3) /* 0.254139794 */, 19 },
+ /* 6975 */ { MAD_F(0x041127d6) /* 0.254188383 */, 19 },
+
+ /* 6976 */ { MAD_F(0x04115aca) /* 0.254236974 */, 19 },
+ /* 6977 */ { MAD_F(0x04118dbe) /* 0.254285568 */, 19 },
+ /* 6978 */ { MAD_F(0x0411c0b3) /* 0.254334165 */, 19 },
+ /* 6979 */ { MAD_F(0x0411f3a9) /* 0.254382763 */, 19 },
+ /* 6980 */ { MAD_F(0x0412269f) /* 0.254431364 */, 19 },
+ /* 6981 */ { MAD_F(0x04125996) /* 0.254479967 */, 19 },
+ /* 6982 */ { MAD_F(0x04128c8d) /* 0.254528572 */, 19 },
+ /* 6983 */ { MAD_F(0x0412bf85) /* 0.254577180 */, 19 },
+ /* 6984 */ { MAD_F(0x0412f27e) /* 0.254625790 */, 19 },
+ /* 6985 */ { MAD_F(0x04132577) /* 0.254674403 */, 19 },
+ /* 6986 */ { MAD_F(0x04135871) /* 0.254723017 */, 19 },
+ /* 6987 */ { MAD_F(0x04138b6c) /* 0.254771635 */, 19 },
+ /* 6988 */ { MAD_F(0x0413be67) /* 0.254820254 */, 19 },
+ /* 6989 */ { MAD_F(0x0413f163) /* 0.254868876 */, 19 },
+ /* 6990 */ { MAD_F(0x0414245f) /* 0.254917500 */, 19 },
+ /* 6991 */ { MAD_F(0x0414575c) /* 0.254966126 */, 19 },
+
+ /* 6992 */ { MAD_F(0x04148a5a) /* 0.255014755 */, 19 },
+ /* 6993 */ { MAD_F(0x0414bd58) /* 0.255063386 */, 19 },
+ /* 6994 */ { MAD_F(0x0414f057) /* 0.255112019 */, 19 },
+ /* 6995 */ { MAD_F(0x04152356) /* 0.255160655 */, 19 },
+ /* 6996 */ { MAD_F(0x04155657) /* 0.255209292 */, 19 },
+ /* 6997 */ { MAD_F(0x04158957) /* 0.255257933 */, 19 },
+ /* 6998 */ { MAD_F(0x0415bc59) /* 0.255306575 */, 19 },
+ /* 6999 */ { MAD_F(0x0415ef5b) /* 0.255355220 */, 19 },
+ /* 7000 */ { MAD_F(0x0416225d) /* 0.255403867 */, 19 },
+ /* 7001 */ { MAD_F(0x04165561) /* 0.255452517 */, 19 },
+ /* 7002 */ { MAD_F(0x04168864) /* 0.255501169 */, 19 },
+ /* 7003 */ { MAD_F(0x0416bb69) /* 0.255549823 */, 19 },
+ /* 7004 */ { MAD_F(0x0416ee6e) /* 0.255598479 */, 19 },
+ /* 7005 */ { MAD_F(0x04172174) /* 0.255647138 */, 19 },
+ /* 7006 */ { MAD_F(0x0417547a) /* 0.255695799 */, 19 },
+ /* 7007 */ { MAD_F(0x04178781) /* 0.255744463 */, 19 },
+
+ /* 7008 */ { MAD_F(0x0417ba89) /* 0.255793128 */, 19 },
+ /* 7009 */ { MAD_F(0x0417ed91) /* 0.255841796 */, 19 },
+ /* 7010 */ { MAD_F(0x0418209a) /* 0.255890467 */, 19 },
+ /* 7011 */ { MAD_F(0x041853a3) /* 0.255939139 */, 19 },
+ /* 7012 */ { MAD_F(0x041886ad) /* 0.255987814 */, 19 },
+ /* 7013 */ { MAD_F(0x0418b9b8) /* 0.256036492 */, 19 },
+ /* 7014 */ { MAD_F(0x0418ecc3) /* 0.256085171 */, 19 },
+ /* 7015 */ { MAD_F(0x04191fcf) /* 0.256133853 */, 19 },
+ /* 7016 */ { MAD_F(0x041952dc) /* 0.256182537 */, 19 },
+ /* 7017 */ { MAD_F(0x041985e9) /* 0.256231224 */, 19 },
+ /* 7018 */ { MAD_F(0x0419b8f7) /* 0.256279913 */, 19 },
+ /* 7019 */ { MAD_F(0x0419ec05) /* 0.256328604 */, 19 },
+ /* 7020 */ { MAD_F(0x041a1f15) /* 0.256377297 */, 19 },
+ /* 7021 */ { MAD_F(0x041a5224) /* 0.256425993 */, 19 },
+ /* 7022 */ { MAD_F(0x041a8534) /* 0.256474691 */, 19 },
+ /* 7023 */ { MAD_F(0x041ab845) /* 0.256523392 */, 19 },
+
+ /* 7024 */ { MAD_F(0x041aeb57) /* 0.256572095 */, 19 },
+ /* 7025 */ { MAD_F(0x041b1e69) /* 0.256620800 */, 19 },
+ /* 7026 */ { MAD_F(0x041b517c) /* 0.256669507 */, 19 },
+ /* 7027 */ { MAD_F(0x041b848f) /* 0.256718217 */, 19 },
+ /* 7028 */ { MAD_F(0x041bb7a3) /* 0.256766929 */, 19 },
+ /* 7029 */ { MAD_F(0x041beab8) /* 0.256815643 */, 19 },
+ /* 7030 */ { MAD_F(0x041c1dcd) /* 0.256864359 */, 19 },
+ /* 7031 */ { MAD_F(0x041c50e3) /* 0.256913078 */, 19 },
+ /* 7032 */ { MAD_F(0x041c83fa) /* 0.256961800 */, 19 },
+ /* 7033 */ { MAD_F(0x041cb711) /* 0.257010523 */, 19 },
+ /* 7034 */ { MAD_F(0x041cea28) /* 0.257059249 */, 19 },
+ /* 7035 */ { MAD_F(0x041d1d41) /* 0.257107977 */, 19 },
+ /* 7036 */ { MAD_F(0x041d505a) /* 0.257156708 */, 19 },
+ /* 7037 */ { MAD_F(0x041d8373) /* 0.257205440 */, 19 },
+ /* 7038 */ { MAD_F(0x041db68e) /* 0.257254175 */, 19 },
+ /* 7039 */ { MAD_F(0x041de9a8) /* 0.257302913 */, 19 },
+
+ /* 7040 */ { MAD_F(0x041e1cc4) /* 0.257351652 */, 19 },
+ /* 7041 */ { MAD_F(0x041e4fe0) /* 0.257400394 */, 19 },
+ /* 7042 */ { MAD_F(0x041e82fd) /* 0.257449139 */, 19 },
+ /* 7043 */ { MAD_F(0x041eb61a) /* 0.257497885 */, 19 },
+ /* 7044 */ { MAD_F(0x041ee938) /* 0.257546634 */, 19 },
+ /* 7045 */ { MAD_F(0x041f1c57) /* 0.257595386 */, 19 },
+ /* 7046 */ { MAD_F(0x041f4f76) /* 0.257644139 */, 19 },
+ /* 7047 */ { MAD_F(0x041f8296) /* 0.257692895 */, 19 },
+ /* 7048 */ { MAD_F(0x041fb5b6) /* 0.257741653 */, 19 },
+ /* 7049 */ { MAD_F(0x041fe8d7) /* 0.257790414 */, 19 },
+ /* 7050 */ { MAD_F(0x04201bf9) /* 0.257839176 */, 19 },
+ /* 7051 */ { MAD_F(0x04204f1b) /* 0.257887941 */, 19 },
+ /* 7052 */ { MAD_F(0x0420823e) /* 0.257936709 */, 19 },
+ /* 7053 */ { MAD_F(0x0420b561) /* 0.257985478 */, 19 },
+ /* 7054 */ { MAD_F(0x0420e885) /* 0.258034250 */, 19 },
+ /* 7055 */ { MAD_F(0x04211baa) /* 0.258083025 */, 19 },
+
+ /* 7056 */ { MAD_F(0x04214ed0) /* 0.258131801 */, 19 },
+ /* 7057 */ { MAD_F(0x042181f6) /* 0.258180580 */, 19 },
+ /* 7058 */ { MAD_F(0x0421b51c) /* 0.258229361 */, 19 },
+ /* 7059 */ { MAD_F(0x0421e843) /* 0.258278145 */, 19 },
+ /* 7060 */ { MAD_F(0x04221b6b) /* 0.258326931 */, 19 },
+ /* 7061 */ { MAD_F(0x04224e94) /* 0.258375719 */, 19 },
+ /* 7062 */ { MAD_F(0x042281bd) /* 0.258424509 */, 19 },
+ /* 7063 */ { MAD_F(0x0422b4e6) /* 0.258473302 */, 19 },
+ /* 7064 */ { MAD_F(0x0422e811) /* 0.258522097 */, 19 },
+ /* 7065 */ { MAD_F(0x04231b3c) /* 0.258570894 */, 19 },
+ /* 7066 */ { MAD_F(0x04234e67) /* 0.258619694 */, 19 },
+ /* 7067 */ { MAD_F(0x04238193) /* 0.258668496 */, 19 },
+ /* 7068 */ { MAD_F(0x0423b4c0) /* 0.258717300 */, 19 },
+ /* 7069 */ { MAD_F(0x0423e7ee) /* 0.258766106 */, 19 },
+ /* 7070 */ { MAD_F(0x04241b1c) /* 0.258814915 */, 19 },
+ /* 7071 */ { MAD_F(0x04244e4a) /* 0.258863726 */, 19 },
+
+ /* 7072 */ { MAD_F(0x04248179) /* 0.258912540 */, 19 },
+ /* 7073 */ { MAD_F(0x0424b4a9) /* 0.258961356 */, 19 },
+ /* 7074 */ { MAD_F(0x0424e7da) /* 0.259010174 */, 19 },
+ /* 7075 */ { MAD_F(0x04251b0b) /* 0.259058994 */, 19 },
+ /* 7076 */ { MAD_F(0x04254e3d) /* 0.259107817 */, 19 },
+ /* 7077 */ { MAD_F(0x0425816f) /* 0.259156642 */, 19 },
+ /* 7078 */ { MAD_F(0x0425b4a2) /* 0.259205469 */, 19 },
+ /* 7079 */ { MAD_F(0x0425e7d6) /* 0.259254298 */, 19 },
+ /* 7080 */ { MAD_F(0x04261b0a) /* 0.259303130 */, 19 },
+ /* 7081 */ { MAD_F(0x04264e3f) /* 0.259351964 */, 19 },
+ /* 7082 */ { MAD_F(0x04268174) /* 0.259400801 */, 19 },
+ /* 7083 */ { MAD_F(0x0426b4aa) /* 0.259449639 */, 19 },
+ /* 7084 */ { MAD_F(0x0426e7e1) /* 0.259498480 */, 19 },
+ /* 7085 */ { MAD_F(0x04271b18) /* 0.259547324 */, 19 },
+ /* 7086 */ { MAD_F(0x04274e50) /* 0.259596169 */, 19 },
+ /* 7087 */ { MAD_F(0x04278188) /* 0.259645017 */, 19 },
+
+ /* 7088 */ { MAD_F(0x0427b4c2) /* 0.259693868 */, 19 },
+ /* 7089 */ { MAD_F(0x0427e7fb) /* 0.259742720 */, 19 },
+ /* 7090 */ { MAD_F(0x04281b36) /* 0.259791575 */, 19 },
+ /* 7091 */ { MAD_F(0x04284e71) /* 0.259840432 */, 19 },
+ /* 7092 */ { MAD_F(0x042881ac) /* 0.259889291 */, 19 },
+ /* 7093 */ { MAD_F(0x0428b4e8) /* 0.259938153 */, 19 },
+ /* 7094 */ { MAD_F(0x0428e825) /* 0.259987017 */, 19 },
+ /* 7095 */ { MAD_F(0x04291b63) /* 0.260035883 */, 19 },
+ /* 7096 */ { MAD_F(0x04294ea1) /* 0.260084752 */, 19 },
+ /* 7097 */ { MAD_F(0x042981df) /* 0.260133623 */, 19 },
+ /* 7098 */ { MAD_F(0x0429b51f) /* 0.260182496 */, 19 },
+ /* 7099 */ { MAD_F(0x0429e85f) /* 0.260231372 */, 19 },
+ /* 7100 */ { MAD_F(0x042a1b9f) /* 0.260280249 */, 19 },
+ /* 7101 */ { MAD_F(0x042a4ee0) /* 0.260329129 */, 19 },
+ /* 7102 */ { MAD_F(0x042a8222) /* 0.260378012 */, 19 },
+ /* 7103 */ { MAD_F(0x042ab564) /* 0.260426896 */, 19 },
+
+ /* 7104 */ { MAD_F(0x042ae8a7) /* 0.260475783 */, 19 },
+ /* 7105 */ { MAD_F(0x042b1beb) /* 0.260524673 */, 19 },
+ /* 7106 */ { MAD_F(0x042b4f2f) /* 0.260573564 */, 19 },
+ /* 7107 */ { MAD_F(0x042b8274) /* 0.260622458 */, 19 },
+ /* 7108 */ { MAD_F(0x042bb5ba) /* 0.260671354 */, 19 },
+ /* 7109 */ { MAD_F(0x042be900) /* 0.260720252 */, 19 },
+ /* 7110 */ { MAD_F(0x042c1c46) /* 0.260769153 */, 19 },
+ /* 7111 */ { MAD_F(0x042c4f8e) /* 0.260818056 */, 19 },
+ /* 7112 */ { MAD_F(0x042c82d6) /* 0.260866961 */, 19 },
+ /* 7113 */ { MAD_F(0x042cb61e) /* 0.260915869 */, 19 },
+ /* 7114 */ { MAD_F(0x042ce967) /* 0.260964779 */, 19 },
+ /* 7115 */ { MAD_F(0x042d1cb1) /* 0.261013691 */, 19 },
+ /* 7116 */ { MAD_F(0x042d4ffb) /* 0.261062606 */, 19 },
+ /* 7117 */ { MAD_F(0x042d8346) /* 0.261111522 */, 19 },
+ /* 7118 */ { MAD_F(0x042db692) /* 0.261160441 */, 19 },
+ /* 7119 */ { MAD_F(0x042de9de) /* 0.261209363 */, 19 },
+
+ /* 7120 */ { MAD_F(0x042e1d2b) /* 0.261258286 */, 19 },
+ /* 7121 */ { MAD_F(0x042e5078) /* 0.261307212 */, 19 },
+ /* 7122 */ { MAD_F(0x042e83c6) /* 0.261356140 */, 19 },
+ /* 7123 */ { MAD_F(0x042eb715) /* 0.261405071 */, 19 },
+ /* 7124 */ { MAD_F(0x042eea64) /* 0.261454004 */, 19 },
+ /* 7125 */ { MAD_F(0x042f1db4) /* 0.261502939 */, 19 },
+ /* 7126 */ { MAD_F(0x042f5105) /* 0.261551876 */, 19 },
+ /* 7127 */ { MAD_F(0x042f8456) /* 0.261600816 */, 19 },
+ /* 7128 */ { MAD_F(0x042fb7a8) /* 0.261649758 */, 19 },
+ /* 7129 */ { MAD_F(0x042feafa) /* 0.261698702 */, 19 },
+ /* 7130 */ { MAD_F(0x04301e4d) /* 0.261747649 */, 19 },
+ /* 7131 */ { MAD_F(0x043051a1) /* 0.261796597 */, 19 },
+ /* 7132 */ { MAD_F(0x043084f5) /* 0.261845548 */, 19 },
+ /* 7133 */ { MAD_F(0x0430b84a) /* 0.261894502 */, 19 },
+ /* 7134 */ { MAD_F(0x0430eb9f) /* 0.261943458 */, 19 },
+ /* 7135 */ { MAD_F(0x04311ef5) /* 0.261992416 */, 19 },
+
+ /* 7136 */ { MAD_F(0x0431524c) /* 0.262041376 */, 19 },
+ /* 7137 */ { MAD_F(0x043185a3) /* 0.262090338 */, 19 },
+ /* 7138 */ { MAD_F(0x0431b8fb) /* 0.262139303 */, 19 },
+ /* 7139 */ { MAD_F(0x0431ec54) /* 0.262188270 */, 19 },
+ /* 7140 */ { MAD_F(0x04321fad) /* 0.262237240 */, 19 },
+ /* 7141 */ { MAD_F(0x04325306) /* 0.262286211 */, 19 },
+ /* 7142 */ { MAD_F(0x04328661) /* 0.262335185 */, 19 },
+ /* 7143 */ { MAD_F(0x0432b9bc) /* 0.262384162 */, 19 },
+ /* 7144 */ { MAD_F(0x0432ed17) /* 0.262433140 */, 19 },
+ /* 7145 */ { MAD_F(0x04332074) /* 0.262482121 */, 19 },
+ /* 7146 */ { MAD_F(0x043353d0) /* 0.262531104 */, 19 },
+ /* 7147 */ { MAD_F(0x0433872e) /* 0.262580089 */, 19 },
+ /* 7148 */ { MAD_F(0x0433ba8c) /* 0.262629077 */, 19 },
+ /* 7149 */ { MAD_F(0x0433edea) /* 0.262678067 */, 19 },
+ /* 7150 */ { MAD_F(0x0434214a) /* 0.262727059 */, 19 },
+ /* 7151 */ { MAD_F(0x043454aa) /* 0.262776054 */, 19 },
+
+ /* 7152 */ { MAD_F(0x0434880a) /* 0.262825051 */, 19 },
+ /* 7153 */ { MAD_F(0x0434bb6b) /* 0.262874050 */, 19 },
+ /* 7154 */ { MAD_F(0x0434eecd) /* 0.262923051 */, 19 },
+ /* 7155 */ { MAD_F(0x0435222f) /* 0.262972055 */, 19 },
+ /* 7156 */ { MAD_F(0x04355592) /* 0.263021061 */, 19 },
+ /* 7157 */ { MAD_F(0x043588f6) /* 0.263070069 */, 19 },
+ /* 7158 */ { MAD_F(0x0435bc5a) /* 0.263119079 */, 19 },
+ /* 7159 */ { MAD_F(0x0435efbf) /* 0.263168092 */, 19 },
+ /* 7160 */ { MAD_F(0x04362324) /* 0.263217107 */, 19 },
+ /* 7161 */ { MAD_F(0x0436568a) /* 0.263266125 */, 19 },
+ /* 7162 */ { MAD_F(0x043689f1) /* 0.263315144 */, 19 },
+ /* 7163 */ { MAD_F(0x0436bd58) /* 0.263364166 */, 19 },
+ /* 7164 */ { MAD_F(0x0436f0c0) /* 0.263413191 */, 19 },
+ /* 7165 */ { MAD_F(0x04372428) /* 0.263462217 */, 19 },
+ /* 7166 */ { MAD_F(0x04375791) /* 0.263511246 */, 19 },
+ /* 7167 */ { MAD_F(0x04378afb) /* 0.263560277 */, 19 },
+
+ /* 7168 */ { MAD_F(0x0437be65) /* 0.263609310 */, 19 },
+ /* 7169 */ { MAD_F(0x0437f1d0) /* 0.263658346 */, 19 },
+ /* 7170 */ { MAD_F(0x0438253c) /* 0.263707384 */, 19 },
+ /* 7171 */ { MAD_F(0x043858a8) /* 0.263756424 */, 19 },
+ /* 7172 */ { MAD_F(0x04388c14) /* 0.263805466 */, 19 },
+ /* 7173 */ { MAD_F(0x0438bf82) /* 0.263854511 */, 19 },
+ /* 7174 */ { MAD_F(0x0438f2f0) /* 0.263903558 */, 19 },
+ /* 7175 */ { MAD_F(0x0439265e) /* 0.263952607 */, 19 },
+ /* 7176 */ { MAD_F(0x043959cd) /* 0.264001659 */, 19 },
+ /* 7177 */ { MAD_F(0x04398d3d) /* 0.264050713 */, 19 },
+ /* 7178 */ { MAD_F(0x0439c0ae) /* 0.264099769 */, 19 },
+ /* 7179 */ { MAD_F(0x0439f41f) /* 0.264148827 */, 19 },
+ /* 7180 */ { MAD_F(0x043a2790) /* 0.264197888 */, 19 },
+ /* 7181 */ { MAD_F(0x043a5b02) /* 0.264246951 */, 19 },
+ /* 7182 */ { MAD_F(0x043a8e75) /* 0.264296016 */, 19 },
+ /* 7183 */ { MAD_F(0x043ac1e9) /* 0.264345084 */, 19 },
+
+ /* 7184 */ { MAD_F(0x043af55d) /* 0.264394153 */, 19 },
+ /* 7185 */ { MAD_F(0x043b28d2) /* 0.264443225 */, 19 },
+ /* 7186 */ { MAD_F(0x043b5c47) /* 0.264492300 */, 19 },
+ /* 7187 */ { MAD_F(0x043b8fbd) /* 0.264541376 */, 19 },
+ /* 7188 */ { MAD_F(0x043bc333) /* 0.264590455 */, 19 },
+ /* 7189 */ { MAD_F(0x043bf6aa) /* 0.264639536 */, 19 },
+ /* 7190 */ { MAD_F(0x043c2a22) /* 0.264688620 */, 19 },
+ /* 7191 */ { MAD_F(0x043c5d9a) /* 0.264737706 */, 19 },
+ /* 7192 */ { MAD_F(0x043c9113) /* 0.264786794 */, 19 },
+ /* 7193 */ { MAD_F(0x043cc48d) /* 0.264835884 */, 19 },
+ /* 7194 */ { MAD_F(0x043cf807) /* 0.264884976 */, 19 },
+ /* 7195 */ { MAD_F(0x043d2b82) /* 0.264934071 */, 19 },
+ /* 7196 */ { MAD_F(0x043d5efd) /* 0.264983168 */, 19 },
+ /* 7197 */ { MAD_F(0x043d9279) /* 0.265032268 */, 19 },
+ /* 7198 */ { MAD_F(0x043dc5f6) /* 0.265081369 */, 19 },
+ /* 7199 */ { MAD_F(0x043df973) /* 0.265130473 */, 19 },
+
+ /* 7200 */ { MAD_F(0x043e2cf1) /* 0.265179580 */, 19 },
+ /* 7201 */ { MAD_F(0x043e6070) /* 0.265228688 */, 19 },
+ /* 7202 */ { MAD_F(0x043e93ef) /* 0.265277799 */, 19 },
+ /* 7203 */ { MAD_F(0x043ec76e) /* 0.265326912 */, 19 },
+ /* 7204 */ { MAD_F(0x043efaef) /* 0.265376027 */, 19 },
+ /* 7205 */ { MAD_F(0x043f2e6f) /* 0.265425145 */, 19 },
+ /* 7206 */ { MAD_F(0x043f61f1) /* 0.265474264 */, 19 },
+ /* 7207 */ { MAD_F(0x043f9573) /* 0.265523387 */, 19 },
+ /* 7208 */ { MAD_F(0x043fc8f6) /* 0.265572511 */, 19 },
+ /* 7209 */ { MAD_F(0x043ffc79) /* 0.265621638 */, 19 },
+ /* 7210 */ { MAD_F(0x04402ffd) /* 0.265670766 */, 19 },
+ /* 7211 */ { MAD_F(0x04406382) /* 0.265719898 */, 19 },
+ /* 7212 */ { MAD_F(0x04409707) /* 0.265769031 */, 19 },
+ /* 7213 */ { MAD_F(0x0440ca8d) /* 0.265818167 */, 19 },
+ /* 7214 */ { MAD_F(0x0440fe13) /* 0.265867305 */, 19 },
+ /* 7215 */ { MAD_F(0x0441319a) /* 0.265916445 */, 19 },
+
+ /* 7216 */ { MAD_F(0x04416522) /* 0.265965588 */, 19 },
+ /* 7217 */ { MAD_F(0x044198aa) /* 0.266014732 */, 19 },
+ /* 7218 */ { MAD_F(0x0441cc33) /* 0.266063880 */, 19 },
+ /* 7219 */ { MAD_F(0x0441ffbc) /* 0.266113029 */, 19 },
+ /* 7220 */ { MAD_F(0x04423346) /* 0.266162181 */, 19 },
+ /* 7221 */ { MAD_F(0x044266d1) /* 0.266211334 */, 19 },
+ /* 7222 */ { MAD_F(0x04429a5c) /* 0.266260491 */, 19 },
+ /* 7223 */ { MAD_F(0x0442cde8) /* 0.266309649 */, 19 },
+ /* 7224 */ { MAD_F(0x04430174) /* 0.266358810 */, 19 },
+ /* 7225 */ { MAD_F(0x04433501) /* 0.266407973 */, 19 },
+ /* 7226 */ { MAD_F(0x0443688f) /* 0.266457138 */, 19 },
+ /* 7227 */ { MAD_F(0x04439c1d) /* 0.266506305 */, 19 },
+ /* 7228 */ { MAD_F(0x0443cfac) /* 0.266555475 */, 19 },
+ /* 7229 */ { MAD_F(0x0444033c) /* 0.266604647 */, 19 },
+ /* 7230 */ { MAD_F(0x044436cc) /* 0.266653822 */, 19 },
+ /* 7231 */ { MAD_F(0x04446a5d) /* 0.266702998 */, 19 },
+
+ /* 7232 */ { MAD_F(0x04449dee) /* 0.266752177 */, 19 },
+ /* 7233 */ { MAD_F(0x0444d180) /* 0.266801358 */, 19 },
+ /* 7234 */ { MAD_F(0x04450513) /* 0.266850541 */, 19 },
+ /* 7235 */ { MAD_F(0x044538a6) /* 0.266899727 */, 19 },
+ /* 7236 */ { MAD_F(0x04456c39) /* 0.266948915 */, 19 },
+ /* 7237 */ { MAD_F(0x04459fce) /* 0.266998105 */, 19 },
+ /* 7238 */ { MAD_F(0x0445d363) /* 0.267047298 */, 19 },
+ /* 7239 */ { MAD_F(0x044606f8) /* 0.267096492 */, 19 },
+ /* 7240 */ { MAD_F(0x04463a8f) /* 0.267145689 */, 19 },
+ /* 7241 */ { MAD_F(0x04466e25) /* 0.267194888 */, 19 },
+ /* 7242 */ { MAD_F(0x0446a1bd) /* 0.267244090 */, 19 },
+ /* 7243 */ { MAD_F(0x0446d555) /* 0.267293294 */, 19 },
+ /* 7244 */ { MAD_F(0x044708ee) /* 0.267342500 */, 19 },
+ /* 7245 */ { MAD_F(0x04473c87) /* 0.267391708 */, 19 },
+ /* 7246 */ { MAD_F(0x04477021) /* 0.267440919 */, 19 },
+ /* 7247 */ { MAD_F(0x0447a3bb) /* 0.267490131 */, 19 },
+
+ /* 7248 */ { MAD_F(0x0447d756) /* 0.267539347 */, 19 },
+ /* 7249 */ { MAD_F(0x04480af2) /* 0.267588564 */, 19 },
+ /* 7250 */ { MAD_F(0x04483e8e) /* 0.267637783 */, 19 },
+ /* 7251 */ { MAD_F(0x0448722b) /* 0.267687005 */, 19 },
+ /* 7252 */ { MAD_F(0x0448a5c9) /* 0.267736229 */, 19 },
+ /* 7253 */ { MAD_F(0x0448d967) /* 0.267785456 */, 19 },
+ /* 7254 */ { MAD_F(0x04490d05) /* 0.267834685 */, 19 },
+ /* 7255 */ { MAD_F(0x044940a5) /* 0.267883915 */, 19 },
+ /* 7256 */ { MAD_F(0x04497445) /* 0.267933149 */, 19 },
+ /* 7257 */ { MAD_F(0x0449a7e5) /* 0.267982384 */, 19 },
+ /* 7258 */ { MAD_F(0x0449db86) /* 0.268031622 */, 19 },
+ /* 7259 */ { MAD_F(0x044a0f28) /* 0.268080862 */, 19 },
+ /* 7260 */ { MAD_F(0x044a42ca) /* 0.268130104 */, 19 },
+ /* 7261 */ { MAD_F(0x044a766d) /* 0.268179349 */, 19 },
+ /* 7262 */ { MAD_F(0x044aaa11) /* 0.268228595 */, 19 },
+ /* 7263 */ { MAD_F(0x044addb5) /* 0.268277844 */, 19 },
+
+ /* 7264 */ { MAD_F(0x044b115a) /* 0.268327096 */, 19 },
+ /* 7265 */ { MAD_F(0x044b44ff) /* 0.268376349 */, 19 },
+ /* 7266 */ { MAD_F(0x044b78a5) /* 0.268425605 */, 19 },
+ /* 7267 */ { MAD_F(0x044bac4c) /* 0.268474863 */, 19 },
+ /* 7268 */ { MAD_F(0x044bdff3) /* 0.268524123 */, 19 },
+ /* 7269 */ { MAD_F(0x044c139b) /* 0.268573386 */, 19 },
+ /* 7270 */ { MAD_F(0x044c4743) /* 0.268622651 */, 19 },
+ /* 7271 */ { MAD_F(0x044c7aec) /* 0.268671918 */, 19 },
+ /* 7272 */ { MAD_F(0x044cae96) /* 0.268721187 */, 19 },
+ /* 7273 */ { MAD_F(0x044ce240) /* 0.268770459 */, 19 },
+ /* 7274 */ { MAD_F(0x044d15eb) /* 0.268819733 */, 19 },
+ /* 7275 */ { MAD_F(0x044d4997) /* 0.268869009 */, 19 },
+ /* 7276 */ { MAD_F(0x044d7d43) /* 0.268918287 */, 19 },
+ /* 7277 */ { MAD_F(0x044db0ef) /* 0.268967568 */, 19 },
+ /* 7278 */ { MAD_F(0x044de49d) /* 0.269016851 */, 19 },
+ /* 7279 */ { MAD_F(0x044e184b) /* 0.269066136 */, 19 },
+
+ /* 7280 */ { MAD_F(0x044e4bf9) /* 0.269115423 */, 19 },
+ /* 7281 */ { MAD_F(0x044e7fa8) /* 0.269164713 */, 19 },
+ /* 7282 */ { MAD_F(0x044eb358) /* 0.269214005 */, 19 },
+ /* 7283 */ { MAD_F(0x044ee708) /* 0.269263299 */, 19 },
+ /* 7284 */ { MAD_F(0x044f1ab9) /* 0.269312595 */, 19 },
+ /* 7285 */ { MAD_F(0x044f4e6b) /* 0.269361894 */, 19 },
+ /* 7286 */ { MAD_F(0x044f821d) /* 0.269411195 */, 19 },
+ /* 7287 */ { MAD_F(0x044fb5cf) /* 0.269460498 */, 19 },
+ /* 7288 */ { MAD_F(0x044fe983) /* 0.269509804 */, 19 },
+ /* 7289 */ { MAD_F(0x04501d37) /* 0.269559111 */, 19 },
+ /* 7290 */ { MAD_F(0x045050eb) /* 0.269608421 */, 19 },
+ /* 7291 */ { MAD_F(0x045084a0) /* 0.269657734 */, 19 },
+ /* 7292 */ { MAD_F(0x0450b856) /* 0.269707048 */, 19 },
+ /* 7293 */ { MAD_F(0x0450ec0d) /* 0.269756365 */, 19 },
+ /* 7294 */ { MAD_F(0x04511fc4) /* 0.269805684 */, 19 },
+ /* 7295 */ { MAD_F(0x0451537b) /* 0.269855005 */, 19 },
+
+ /* 7296 */ { MAD_F(0x04518733) /* 0.269904329 */, 19 },
+ /* 7297 */ { MAD_F(0x0451baec) /* 0.269953654 */, 19 },
+ /* 7298 */ { MAD_F(0x0451eea5) /* 0.270002982 */, 19 },
+ /* 7299 */ { MAD_F(0x0452225f) /* 0.270052313 */, 19 },
+ /* 7300 */ { MAD_F(0x0452561a) /* 0.270101645 */, 19 },
+ /* 7301 */ { MAD_F(0x045289d5) /* 0.270150980 */, 19 },
+ /* 7302 */ { MAD_F(0x0452bd91) /* 0.270200317 */, 19 },
+ /* 7303 */ { MAD_F(0x0452f14d) /* 0.270249656 */, 19 },
+ /* 7304 */ { MAD_F(0x0453250a) /* 0.270298998 */, 19 },
+ /* 7305 */ { MAD_F(0x045358c8) /* 0.270348341 */, 19 },
+ /* 7306 */ { MAD_F(0x04538c86) /* 0.270397687 */, 19 },
+ /* 7307 */ { MAD_F(0x0453c045) /* 0.270447036 */, 19 },
+ /* 7308 */ { MAD_F(0x0453f405) /* 0.270496386 */, 19 },
+ /* 7309 */ { MAD_F(0x045427c5) /* 0.270545739 */, 19 },
+ /* 7310 */ { MAD_F(0x04545b85) /* 0.270595094 */, 19 },
+ /* 7311 */ { MAD_F(0x04548f46) /* 0.270644451 */, 19 },
+
+ /* 7312 */ { MAD_F(0x0454c308) /* 0.270693811 */, 19 },
+ /* 7313 */ { MAD_F(0x0454f6cb) /* 0.270743173 */, 19 },
+ /* 7314 */ { MAD_F(0x04552a8e) /* 0.270792537 */, 19 },
+ /* 7315 */ { MAD_F(0x04555e51) /* 0.270841903 */, 19 },
+ /* 7316 */ { MAD_F(0x04559216) /* 0.270891271 */, 19 },
+ /* 7317 */ { MAD_F(0x0455c5db) /* 0.270940642 */, 19 },
+ /* 7318 */ { MAD_F(0x0455f9a0) /* 0.270990015 */, 19 },
+ /* 7319 */ { MAD_F(0x04562d66) /* 0.271039390 */, 19 },
+ /* 7320 */ { MAD_F(0x0456612d) /* 0.271088768 */, 19 },
+ /* 7321 */ { MAD_F(0x045694f4) /* 0.271138148 */, 19 },
+ /* 7322 */ { MAD_F(0x0456c8bc) /* 0.271187530 */, 19 },
+ /* 7323 */ { MAD_F(0x0456fc84) /* 0.271236914 */, 19 },
+ /* 7324 */ { MAD_F(0x0457304e) /* 0.271286301 */, 19 },
+ /* 7325 */ { MAD_F(0x04576417) /* 0.271335689 */, 19 },
+ /* 7326 */ { MAD_F(0x045797e2) /* 0.271385080 */, 19 },
+ /* 7327 */ { MAD_F(0x0457cbac) /* 0.271434474 */, 19 },
+
+ /* 7328 */ { MAD_F(0x0457ff78) /* 0.271483869 */, 19 },
+ /* 7329 */ { MAD_F(0x04583344) /* 0.271533267 */, 19 },
+ /* 7330 */ { MAD_F(0x04586711) /* 0.271582667 */, 19 },
+ /* 7331 */ { MAD_F(0x04589ade) /* 0.271632069 */, 19 },
+ /* 7332 */ { MAD_F(0x0458ceac) /* 0.271681474 */, 19 },
+ /* 7333 */ { MAD_F(0x0459027b) /* 0.271730880 */, 19 },
+ /* 7334 */ { MAD_F(0x0459364a) /* 0.271780289 */, 19 },
+ /* 7335 */ { MAD_F(0x04596a19) /* 0.271829701 */, 19 },
+ /* 7336 */ { MAD_F(0x04599dea) /* 0.271879114 */, 19 },
+ /* 7337 */ { MAD_F(0x0459d1bb) /* 0.271928530 */, 19 },
+ /* 7338 */ { MAD_F(0x045a058c) /* 0.271977948 */, 19 },
+ /* 7339 */ { MAD_F(0x045a395e) /* 0.272027368 */, 19 },
+ /* 7340 */ { MAD_F(0x045a6d31) /* 0.272076790 */, 19 },
+ /* 7341 */ { MAD_F(0x045aa104) /* 0.272126215 */, 19 },
+ /* 7342 */ { MAD_F(0x045ad4d8) /* 0.272175642 */, 19 },
+ /* 7343 */ { MAD_F(0x045b08ad) /* 0.272225071 */, 19 },
+
+ /* 7344 */ { MAD_F(0x045b3c82) /* 0.272274503 */, 19 },
+ /* 7345 */ { MAD_F(0x045b7058) /* 0.272323936 */, 19 },
+ /* 7346 */ { MAD_F(0x045ba42e) /* 0.272373372 */, 19 },
+ /* 7347 */ { MAD_F(0x045bd805) /* 0.272422810 */, 19 },
+ /* 7348 */ { MAD_F(0x045c0bdd) /* 0.272472251 */, 19 },
+ /* 7349 */ { MAD_F(0x045c3fb5) /* 0.272521693 */, 19 },
+ /* 7350 */ { MAD_F(0x045c738e) /* 0.272571138 */, 19 },
+ /* 7351 */ { MAD_F(0x045ca767) /* 0.272620585 */, 19 },
+ /* 7352 */ { MAD_F(0x045cdb41) /* 0.272670035 */, 19 },
+ /* 7353 */ { MAD_F(0x045d0f1b) /* 0.272719486 */, 19 },
+ /* 7354 */ { MAD_F(0x045d42f7) /* 0.272768940 */, 19 },
+ /* 7355 */ { MAD_F(0x045d76d2) /* 0.272818396 */, 19 },
+ /* 7356 */ { MAD_F(0x045daaaf) /* 0.272867855 */, 19 },
+ /* 7357 */ { MAD_F(0x045dde8c) /* 0.272917315 */, 19 },
+ /* 7358 */ { MAD_F(0x045e1269) /* 0.272966778 */, 19 },
+ /* 7359 */ { MAD_F(0x045e4647) /* 0.273016243 */, 19 },
+
+ /* 7360 */ { MAD_F(0x045e7a26) /* 0.273065710 */, 19 },
+ /* 7361 */ { MAD_F(0x045eae06) /* 0.273115180 */, 19 },
+ /* 7362 */ { MAD_F(0x045ee1e6) /* 0.273164652 */, 19 },
+ /* 7363 */ { MAD_F(0x045f15c6) /* 0.273214126 */, 19 },
+ /* 7364 */ { MAD_F(0x045f49a7) /* 0.273263602 */, 19 },
+ /* 7365 */ { MAD_F(0x045f7d89) /* 0.273313081 */, 19 },
+ /* 7366 */ { MAD_F(0x045fb16c) /* 0.273362561 */, 19 },
+ /* 7367 */ { MAD_F(0x045fe54f) /* 0.273412044 */, 19 },
+ /* 7368 */ { MAD_F(0x04601932) /* 0.273461530 */, 19 },
+ /* 7369 */ { MAD_F(0x04604d16) /* 0.273511017 */, 19 },
+ /* 7370 */ { MAD_F(0x046080fb) /* 0.273560507 */, 19 },
+ /* 7371 */ { MAD_F(0x0460b4e1) /* 0.273609999 */, 19 },
+ /* 7372 */ { MAD_F(0x0460e8c7) /* 0.273659493 */, 19 },
+ /* 7373 */ { MAD_F(0x04611cad) /* 0.273708989 */, 19 },
+ /* 7374 */ { MAD_F(0x04615094) /* 0.273758488 */, 19 },
+ /* 7375 */ { MAD_F(0x0461847c) /* 0.273807989 */, 19 },
+
+ /* 7376 */ { MAD_F(0x0461b864) /* 0.273857492 */, 19 },
+ /* 7377 */ { MAD_F(0x0461ec4d) /* 0.273906997 */, 19 },
+ /* 7378 */ { MAD_F(0x04622037) /* 0.273956505 */, 19 },
+ /* 7379 */ { MAD_F(0x04625421) /* 0.274006015 */, 19 },
+ /* 7380 */ { MAD_F(0x0462880c) /* 0.274055527 */, 19 },
+ /* 7381 */ { MAD_F(0x0462bbf7) /* 0.274105041 */, 19 },
+ /* 7382 */ { MAD_F(0x0462efe3) /* 0.274154558 */, 19 },
+ /* 7383 */ { MAD_F(0x046323d0) /* 0.274204076 */, 19 },
+ /* 7384 */ { MAD_F(0x046357bd) /* 0.274253597 */, 19 },
+ /* 7385 */ { MAD_F(0x04638bab) /* 0.274303121 */, 19 },
+ /* 7386 */ { MAD_F(0x0463bf99) /* 0.274352646 */, 19 },
+ /* 7387 */ { MAD_F(0x0463f388) /* 0.274402174 */, 19 },
+ /* 7388 */ { MAD_F(0x04642778) /* 0.274451704 */, 19 },
+ /* 7389 */ { MAD_F(0x04645b68) /* 0.274501236 */, 19 },
+ /* 7390 */ { MAD_F(0x04648f59) /* 0.274550771 */, 19 },
+ /* 7391 */ { MAD_F(0x0464c34a) /* 0.274600307 */, 19 },
+
+ /* 7392 */ { MAD_F(0x0464f73c) /* 0.274649846 */, 19 },
+ /* 7393 */ { MAD_F(0x04652b2f) /* 0.274699387 */, 19 },
+ /* 7394 */ { MAD_F(0x04655f22) /* 0.274748931 */, 19 },
+ /* 7395 */ { MAD_F(0x04659316) /* 0.274798476 */, 19 },
+ /* 7396 */ { MAD_F(0x0465c70a) /* 0.274848024 */, 19 },
+ /* 7397 */ { MAD_F(0x0465faff) /* 0.274897574 */, 19 },
+ /* 7398 */ { MAD_F(0x04662ef5) /* 0.274947126 */, 19 },
+ /* 7399 */ { MAD_F(0x046662eb) /* 0.274996681 */, 19 },
+ /* 7400 */ { MAD_F(0x046696e2) /* 0.275046238 */, 19 },
+ /* 7401 */ { MAD_F(0x0466cad9) /* 0.275095797 */, 19 },
+ /* 7402 */ { MAD_F(0x0466fed1) /* 0.275145358 */, 19 },
+ /* 7403 */ { MAD_F(0x046732ca) /* 0.275194921 */, 19 },
+ /* 7404 */ { MAD_F(0x046766c3) /* 0.275244487 */, 19 },
+ /* 7405 */ { MAD_F(0x04679abd) /* 0.275294055 */, 19 },
+ /* 7406 */ { MAD_F(0x0467ceb7) /* 0.275343625 */, 19 },
+ /* 7407 */ { MAD_F(0x046802b2) /* 0.275393198 */, 19 },
+
+ /* 7408 */ { MAD_F(0x046836ae) /* 0.275442772 */, 19 },
+ /* 7409 */ { MAD_F(0x04686aaa) /* 0.275492349 */, 19 },
+ /* 7410 */ { MAD_F(0x04689ea7) /* 0.275541928 */, 19 },
+ /* 7411 */ { MAD_F(0x0468d2a4) /* 0.275591509 */, 19 },
+ /* 7412 */ { MAD_F(0x046906a2) /* 0.275641093 */, 19 },
+ /* 7413 */ { MAD_F(0x04693aa1) /* 0.275690679 */, 19 },
+ /* 7414 */ { MAD_F(0x04696ea0) /* 0.275740267 */, 19 },
+ /* 7415 */ { MAD_F(0x0469a2a0) /* 0.275789857 */, 19 },
+ /* 7416 */ { MAD_F(0x0469d6a0) /* 0.275839449 */, 19 },
+ /* 7417 */ { MAD_F(0x046a0aa1) /* 0.275889044 */, 19 },
+ /* 7418 */ { MAD_F(0x046a3ea3) /* 0.275938641 */, 19 },
+ /* 7419 */ { MAD_F(0x046a72a5) /* 0.275988240 */, 19 },
+ /* 7420 */ { MAD_F(0x046aa6a8) /* 0.276037842 */, 19 },
+ /* 7421 */ { MAD_F(0x046adaab) /* 0.276087445 */, 19 },
+ /* 7422 */ { MAD_F(0x046b0eaf) /* 0.276137051 */, 19 },
+ /* 7423 */ { MAD_F(0x046b42b3) /* 0.276186659 */, 19 },
+
+ /* 7424 */ { MAD_F(0x046b76b9) /* 0.276236269 */, 19 },
+ /* 7425 */ { MAD_F(0x046baabe) /* 0.276285882 */, 19 },
+ /* 7426 */ { MAD_F(0x046bdec5) /* 0.276335497 */, 19 },
+ /* 7427 */ { MAD_F(0x046c12cc) /* 0.276385113 */, 19 },
+ /* 7428 */ { MAD_F(0x046c46d3) /* 0.276434733 */, 19 },
+ /* 7429 */ { MAD_F(0x046c7adb) /* 0.276484354 */, 19 },
+ /* 7430 */ { MAD_F(0x046caee4) /* 0.276533978 */, 19 },
+ /* 7431 */ { MAD_F(0x046ce2ee) /* 0.276583604 */, 19 },
+ /* 7432 */ { MAD_F(0x046d16f7) /* 0.276633232 */, 19 },
+ /* 7433 */ { MAD_F(0x046d4b02) /* 0.276682862 */, 19 },
+ /* 7434 */ { MAD_F(0x046d7f0d) /* 0.276732495 */, 19 },
+ /* 7435 */ { MAD_F(0x046db319) /* 0.276782129 */, 19 },
+ /* 7436 */ { MAD_F(0x046de725) /* 0.276831766 */, 19 },
+ /* 7437 */ { MAD_F(0x046e1b32) /* 0.276881406 */, 19 },
+ /* 7438 */ { MAD_F(0x046e4f40) /* 0.276931047 */, 19 },
+ /* 7439 */ { MAD_F(0x046e834e) /* 0.276980691 */, 19 },
+
+ /* 7440 */ { MAD_F(0x046eb75c) /* 0.277030337 */, 19 },
+ /* 7441 */ { MAD_F(0x046eeb6c) /* 0.277079985 */, 19 },
+ /* 7442 */ { MAD_F(0x046f1f7c) /* 0.277129635 */, 19 },
+ /* 7443 */ { MAD_F(0x046f538c) /* 0.277179288 */, 19 },
+ /* 7444 */ { MAD_F(0x046f879d) /* 0.277228942 */, 19 },
+ /* 7445 */ { MAD_F(0x046fbbaf) /* 0.277278600 */, 19 },
+ /* 7446 */ { MAD_F(0x046fefc1) /* 0.277328259 */, 19 },
+ /* 7447 */ { MAD_F(0x047023d4) /* 0.277377920 */, 19 },
+ /* 7448 */ { MAD_F(0x047057e8) /* 0.277427584 */, 19 },
+ /* 7449 */ { MAD_F(0x04708bfc) /* 0.277477250 */, 19 },
+ /* 7450 */ { MAD_F(0x0470c011) /* 0.277526918 */, 19 },
+ /* 7451 */ { MAD_F(0x0470f426) /* 0.277576588 */, 19 },
+ /* 7452 */ { MAD_F(0x0471283c) /* 0.277626261 */, 19 },
+ /* 7453 */ { MAD_F(0x04715c52) /* 0.277675936 */, 19 },
+ /* 7454 */ { MAD_F(0x04719069) /* 0.277725613 */, 19 },
+ /* 7455 */ { MAD_F(0x0471c481) /* 0.277775292 */, 19 },
+
+ /* 7456 */ { MAD_F(0x0471f899) /* 0.277824973 */, 19 },
+ /* 7457 */ { MAD_F(0x04722cb2) /* 0.277874657 */, 19 },
+ /* 7458 */ { MAD_F(0x047260cc) /* 0.277924343 */, 19 },
+ /* 7459 */ { MAD_F(0x047294e6) /* 0.277974031 */, 19 },
+ /* 7460 */ { MAD_F(0x0472c900) /* 0.278023722 */, 19 },
+ /* 7461 */ { MAD_F(0x0472fd1b) /* 0.278073414 */, 19 },
+ /* 7462 */ { MAD_F(0x04733137) /* 0.278123109 */, 19 },
+ /* 7463 */ { MAD_F(0x04736554) /* 0.278172806 */, 19 },
+ /* 7464 */ { MAD_F(0x04739971) /* 0.278222505 */, 19 },
+ /* 7465 */ { MAD_F(0x0473cd8e) /* 0.278272207 */, 19 },
+ /* 7466 */ { MAD_F(0x047401ad) /* 0.278321910 */, 19 },
+ /* 7467 */ { MAD_F(0x047435cb) /* 0.278371616 */, 19 },
+ /* 7468 */ { MAD_F(0x047469eb) /* 0.278421324 */, 19 },
+ /* 7469 */ { MAD_F(0x04749e0b) /* 0.278471035 */, 19 },
+ /* 7470 */ { MAD_F(0x0474d22c) /* 0.278520747 */, 19 },
+ /* 7471 */ { MAD_F(0x0475064d) /* 0.278570462 */, 19 },
+
+ /* 7472 */ { MAD_F(0x04753a6f) /* 0.278620179 */, 19 },
+ /* 7473 */ { MAD_F(0x04756e91) /* 0.278669898 */, 19 },
+ /* 7474 */ { MAD_F(0x0475a2b4) /* 0.278719619 */, 19 },
+ /* 7475 */ { MAD_F(0x0475d6d7) /* 0.278769343 */, 19 },
+ /* 7476 */ { MAD_F(0x04760afc) /* 0.278819069 */, 19 },
+ /* 7477 */ { MAD_F(0x04763f20) /* 0.278868797 */, 19 },
+ /* 7478 */ { MAD_F(0x04767346) /* 0.278918527 */, 19 },
+ /* 7479 */ { MAD_F(0x0476a76c) /* 0.278968260 */, 19 },
+ /* 7480 */ { MAD_F(0x0476db92) /* 0.279017995 */, 19 },
+ /* 7481 */ { MAD_F(0x04770fba) /* 0.279067731 */, 19 },
+ /* 7482 */ { MAD_F(0x047743e1) /* 0.279117471 */, 19 },
+ /* 7483 */ { MAD_F(0x0477780a) /* 0.279167212 */, 19 },
+ /* 7484 */ { MAD_F(0x0477ac33) /* 0.279216956 */, 19 },
+ /* 7485 */ { MAD_F(0x0477e05c) /* 0.279266701 */, 19 },
+ /* 7486 */ { MAD_F(0x04781486) /* 0.279316449 */, 19 },
+ /* 7487 */ { MAD_F(0x047848b1) /* 0.279366200 */, 19 },
+
+ /* 7488 */ { MAD_F(0x04787cdc) /* 0.279415952 */, 19 },
+ /* 7489 */ { MAD_F(0x0478b108) /* 0.279465707 */, 19 },
+ /* 7490 */ { MAD_F(0x0478e535) /* 0.279515464 */, 19 },
+ /* 7491 */ { MAD_F(0x04791962) /* 0.279565223 */, 19 },
+ /* 7492 */ { MAD_F(0x04794d8f) /* 0.279614984 */, 19 },
+ /* 7493 */ { MAD_F(0x047981be) /* 0.279664748 */, 19 },
+ /* 7494 */ { MAD_F(0x0479b5ed) /* 0.279714513 */, 19 },
+ /* 7495 */ { MAD_F(0x0479ea1c) /* 0.279764281 */, 19 },
+ /* 7496 */ { MAD_F(0x047a1e4c) /* 0.279814051 */, 19 },
+ /* 7497 */ { MAD_F(0x047a527d) /* 0.279863824 */, 19 },
+ /* 7498 */ { MAD_F(0x047a86ae) /* 0.279913598 */, 19 },
+ /* 7499 */ { MAD_F(0x047abae0) /* 0.279963375 */, 19 },
+ /* 7500 */ { MAD_F(0x047aef12) /* 0.280013154 */, 19 },
+ /* 7501 */ { MAD_F(0x047b2346) /* 0.280062935 */, 19 },
+ /* 7502 */ { MAD_F(0x047b5779) /* 0.280112719 */, 19 },
+ /* 7503 */ { MAD_F(0x047b8bad) /* 0.280162504 */, 19 },
+
+ /* 7504 */ { MAD_F(0x047bbfe2) /* 0.280212292 */, 19 },
+ /* 7505 */ { MAD_F(0x047bf418) /* 0.280262082 */, 19 },
+ /* 7506 */ { MAD_F(0x047c284e) /* 0.280311875 */, 19 },
+ /* 7507 */ { MAD_F(0x047c5c84) /* 0.280361669 */, 19 },
+ /* 7508 */ { MAD_F(0x047c90bb) /* 0.280411466 */, 19 },
+ /* 7509 */ { MAD_F(0x047cc4f3) /* 0.280461265 */, 19 },
+ /* 7510 */ { MAD_F(0x047cf92c) /* 0.280511066 */, 19 },
+ /* 7511 */ { MAD_F(0x047d2d65) /* 0.280560869 */, 19 },
+ /* 7512 */ { MAD_F(0x047d619e) /* 0.280610675 */, 19 },
+ /* 7513 */ { MAD_F(0x047d95d8) /* 0.280660483 */, 19 },
+ /* 7514 */ { MAD_F(0x047dca13) /* 0.280710292 */, 19 },
+ /* 7515 */ { MAD_F(0x047dfe4e) /* 0.280760105 */, 19 },
+ /* 7516 */ { MAD_F(0x047e328a) /* 0.280809919 */, 19 },
+ /* 7517 */ { MAD_F(0x047e66c7) /* 0.280859736 */, 19 },
+ /* 7518 */ { MAD_F(0x047e9b04) /* 0.280909554 */, 19 },
+ /* 7519 */ { MAD_F(0x047ecf42) /* 0.280959375 */, 19 },
+
+ /* 7520 */ { MAD_F(0x047f0380) /* 0.281009199 */, 19 },
+ /* 7521 */ { MAD_F(0x047f37bf) /* 0.281059024 */, 19 },
+ /* 7522 */ { MAD_F(0x047f6bff) /* 0.281108852 */, 19 },
+ /* 7523 */ { MAD_F(0x047fa03f) /* 0.281158682 */, 19 },
+ /* 7524 */ { MAD_F(0x047fd47f) /* 0.281208514 */, 19 },
+ /* 7525 */ { MAD_F(0x048008c1) /* 0.281258348 */, 19 },
+ /* 7526 */ { MAD_F(0x04803d02) /* 0.281308184 */, 19 },
+ /* 7527 */ { MAD_F(0x04807145) /* 0.281358023 */, 19 },
+ /* 7528 */ { MAD_F(0x0480a588) /* 0.281407864 */, 19 },
+ /* 7529 */ { MAD_F(0x0480d9cc) /* 0.281457707 */, 19 },
+ /* 7530 */ { MAD_F(0x04810e10) /* 0.281507552 */, 19 },
+ /* 7531 */ { MAD_F(0x04814255) /* 0.281557400 */, 19 },
+ /* 7532 */ { MAD_F(0x0481769a) /* 0.281607250 */, 19 },
+ /* 7533 */ { MAD_F(0x0481aae0) /* 0.281657101 */, 19 },
+ /* 7534 */ { MAD_F(0x0481df27) /* 0.281706956 */, 19 },
+ /* 7535 */ { MAD_F(0x0482136e) /* 0.281756812 */, 19 },
+
+ /* 7536 */ { MAD_F(0x048247b6) /* 0.281806670 */, 19 },
+ /* 7537 */ { MAD_F(0x04827bfe) /* 0.281856531 */, 19 },
+ /* 7538 */ { MAD_F(0x0482b047) /* 0.281906394 */, 19 },
+ /* 7539 */ { MAD_F(0x0482e491) /* 0.281956259 */, 19 },
+ /* 7540 */ { MAD_F(0x048318db) /* 0.282006127 */, 19 },
+ /* 7541 */ { MAD_F(0x04834d26) /* 0.282055996 */, 19 },
+ /* 7542 */ { MAD_F(0x04838171) /* 0.282105868 */, 19 },
+ /* 7543 */ { MAD_F(0x0483b5bd) /* 0.282155742 */, 19 },
+ /* 7544 */ { MAD_F(0x0483ea0a) /* 0.282205618 */, 19 },
+ /* 7545 */ { MAD_F(0x04841e57) /* 0.282255496 */, 19 },
+ /* 7546 */ { MAD_F(0x048452a4) /* 0.282305377 */, 19 },
+ /* 7547 */ { MAD_F(0x048486f3) /* 0.282355260 */, 19 },
+ /* 7548 */ { MAD_F(0x0484bb42) /* 0.282405145 */, 19 },
+ /* 7549 */ { MAD_F(0x0484ef91) /* 0.282455032 */, 19 },
+ /* 7550 */ { MAD_F(0x048523e1) /* 0.282504921 */, 19 },
+ /* 7551 */ { MAD_F(0x04855832) /* 0.282554813 */, 19 },
+
+ /* 7552 */ { MAD_F(0x04858c83) /* 0.282604707 */, 19 },
+ /* 7553 */ { MAD_F(0x0485c0d5) /* 0.282654603 */, 19 },
+ /* 7554 */ { MAD_F(0x0485f527) /* 0.282704501 */, 19 },
+ /* 7555 */ { MAD_F(0x0486297a) /* 0.282754401 */, 19 },
+ /* 7556 */ { MAD_F(0x04865dce) /* 0.282804304 */, 19 },
+ /* 7557 */ { MAD_F(0x04869222) /* 0.282854209 */, 19 },
+ /* 7558 */ { MAD_F(0x0486c677) /* 0.282904116 */, 19 },
+ /* 7559 */ { MAD_F(0x0486facc) /* 0.282954025 */, 19 },
+ /* 7560 */ { MAD_F(0x04872f22) /* 0.283003936 */, 19 },
+ /* 7561 */ { MAD_F(0x04876379) /* 0.283053850 */, 19 },
+ /* 7562 */ { MAD_F(0x048797d0) /* 0.283103766 */, 19 },
+ /* 7563 */ { MAD_F(0x0487cc28) /* 0.283153684 */, 19 },
+ /* 7564 */ { MAD_F(0x04880080) /* 0.283203604 */, 19 },
+ /* 7565 */ { MAD_F(0x048834d9) /* 0.283253527 */, 19 },
+ /* 7566 */ { MAD_F(0x04886933) /* 0.283303451 */, 19 },
+ /* 7567 */ { MAD_F(0x04889d8d) /* 0.283353378 */, 19 },
+
+ /* 7568 */ { MAD_F(0x0488d1e8) /* 0.283403307 */, 19 },
+ /* 7569 */ { MAD_F(0x04890643) /* 0.283453238 */, 19 },
+ /* 7570 */ { MAD_F(0x04893a9f) /* 0.283503172 */, 19 },
+ /* 7571 */ { MAD_F(0x04896efb) /* 0.283553107 */, 19 },
+ /* 7572 */ { MAD_F(0x0489a358) /* 0.283603045 */, 19 },
+ /* 7573 */ { MAD_F(0x0489d7b6) /* 0.283652985 */, 19 },
+ /* 7574 */ { MAD_F(0x048a0c14) /* 0.283702927 */, 19 },
+ /* 7575 */ { MAD_F(0x048a4073) /* 0.283752872 */, 19 },
+ /* 7576 */ { MAD_F(0x048a74d3) /* 0.283802818 */, 19 },
+ /* 7577 */ { MAD_F(0x048aa933) /* 0.283852767 */, 19 },
+ /* 7578 */ { MAD_F(0x048add93) /* 0.283902718 */, 19 },
+ /* 7579 */ { MAD_F(0x048b11f5) /* 0.283952671 */, 19 },
+ /* 7580 */ { MAD_F(0x048b4656) /* 0.284002627 */, 19 },
+ /* 7581 */ { MAD_F(0x048b7ab9) /* 0.284052584 */, 19 },
+ /* 7582 */ { MAD_F(0x048baf1c) /* 0.284102544 */, 19 },
+ /* 7583 */ { MAD_F(0x048be37f) /* 0.284152506 */, 19 },
+
+ /* 7584 */ { MAD_F(0x048c17e3) /* 0.284202470 */, 19 },
+ /* 7585 */ { MAD_F(0x048c4c48) /* 0.284252436 */, 19 },
+ /* 7586 */ { MAD_F(0x048c80ad) /* 0.284302405 */, 19 },
+ /* 7587 */ { MAD_F(0x048cb513) /* 0.284352376 */, 19 },
+ /* 7588 */ { MAD_F(0x048ce97a) /* 0.284402349 */, 19 },
+ /* 7589 */ { MAD_F(0x048d1de1) /* 0.284452324 */, 19 },
+ /* 7590 */ { MAD_F(0x048d5249) /* 0.284502301 */, 19 },
+ /* 7591 */ { MAD_F(0x048d86b1) /* 0.284552281 */, 19 },
+ /* 7592 */ { MAD_F(0x048dbb1a) /* 0.284602263 */, 19 },
+ /* 7593 */ { MAD_F(0x048def83) /* 0.284652246 */, 19 },
+ /* 7594 */ { MAD_F(0x048e23ed) /* 0.284702233 */, 19 },
+ /* 7595 */ { MAD_F(0x048e5858) /* 0.284752221 */, 19 },
+ /* 7596 */ { MAD_F(0x048e8cc3) /* 0.284802211 */, 19 },
+ /* 7597 */ { MAD_F(0x048ec12f) /* 0.284852204 */, 19 },
+ /* 7598 */ { MAD_F(0x048ef59b) /* 0.284902199 */, 19 },
+ /* 7599 */ { MAD_F(0x048f2a08) /* 0.284952196 */, 19 },
+
+ /* 7600 */ { MAD_F(0x048f5e76) /* 0.285002195 */, 19 },
+ /* 7601 */ { MAD_F(0x048f92e4) /* 0.285052197 */, 19 },
+ /* 7602 */ { MAD_F(0x048fc753) /* 0.285102201 */, 19 },
+ /* 7603 */ { MAD_F(0x048ffbc2) /* 0.285152206 */, 19 },
+ /* 7604 */ { MAD_F(0x04903032) /* 0.285202214 */, 19 },
+ /* 7605 */ { MAD_F(0x049064a3) /* 0.285252225 */, 19 },
+ /* 7606 */ { MAD_F(0x04909914) /* 0.285302237 */, 19 },
+ /* 7607 */ { MAD_F(0x0490cd86) /* 0.285352252 */, 19 },
+ /* 7608 */ { MAD_F(0x049101f8) /* 0.285402269 */, 19 },
+ /* 7609 */ { MAD_F(0x0491366b) /* 0.285452288 */, 19 },
+ /* 7610 */ { MAD_F(0x04916ade) /* 0.285502309 */, 19 },
+ /* 7611 */ { MAD_F(0x04919f52) /* 0.285552332 */, 19 },
+ /* 7612 */ { MAD_F(0x0491d3c7) /* 0.285602358 */, 19 },
+ /* 7613 */ { MAD_F(0x0492083c) /* 0.285652386 */, 19 },
+ /* 7614 */ { MAD_F(0x04923cb2) /* 0.285702416 */, 19 },
+ /* 7615 */ { MAD_F(0x04927128) /* 0.285752448 */, 19 },
+
+ /* 7616 */ { MAD_F(0x0492a59f) /* 0.285802482 */, 19 },
+ /* 7617 */ { MAD_F(0x0492da17) /* 0.285852519 */, 19 },
+ /* 7618 */ { MAD_F(0x04930e8f) /* 0.285902557 */, 19 },
+ /* 7619 */ { MAD_F(0x04934308) /* 0.285952598 */, 19 },
+ /* 7620 */ { MAD_F(0x04937781) /* 0.286002641 */, 19 },
+ /* 7621 */ { MAD_F(0x0493abfb) /* 0.286052687 */, 19 },
+ /* 7622 */ { MAD_F(0x0493e076) /* 0.286102734 */, 19 },
+ /* 7623 */ { MAD_F(0x049414f1) /* 0.286152784 */, 19 },
+ /* 7624 */ { MAD_F(0x0494496c) /* 0.286202836 */, 19 },
+ /* 7625 */ { MAD_F(0x04947de9) /* 0.286252890 */, 19 },
+ /* 7626 */ { MAD_F(0x0494b266) /* 0.286302946 */, 19 },
+ /* 7627 */ { MAD_F(0x0494e6e3) /* 0.286353005 */, 19 },
+ /* 7628 */ { MAD_F(0x04951b61) /* 0.286403065 */, 19 },
+ /* 7629 */ { MAD_F(0x04954fe0) /* 0.286453128 */, 19 },
+ /* 7630 */ { MAD_F(0x0495845f) /* 0.286503193 */, 19 },
+ /* 7631 */ { MAD_F(0x0495b8df) /* 0.286553260 */, 19 },
+
+ /* 7632 */ { MAD_F(0x0495ed5f) /* 0.286603329 */, 19 },
+ /* 7633 */ { MAD_F(0x049621e0) /* 0.286653401 */, 19 },
+ /* 7634 */ { MAD_F(0x04965662) /* 0.286703475 */, 19 },
+ /* 7635 */ { MAD_F(0x04968ae4) /* 0.286753551 */, 19 },
+ /* 7636 */ { MAD_F(0x0496bf67) /* 0.286803629 */, 19 },
+ /* 7637 */ { MAD_F(0x0496f3ea) /* 0.286853709 */, 19 },
+ /* 7638 */ { MAD_F(0x0497286e) /* 0.286903792 */, 19 },
+ /* 7639 */ { MAD_F(0x04975cf2) /* 0.286953876 */, 19 },
+ /* 7640 */ { MAD_F(0x04979177) /* 0.287003963 */, 19 },
+ /* 7641 */ { MAD_F(0x0497c5fd) /* 0.287054052 */, 19 },
+ /* 7642 */ { MAD_F(0x0497fa83) /* 0.287104143 */, 19 },
+ /* 7643 */ { MAD_F(0x04982f0a) /* 0.287154237 */, 19 },
+ /* 7644 */ { MAD_F(0x04986392) /* 0.287204332 */, 19 },
+ /* 7645 */ { MAD_F(0x0498981a) /* 0.287254430 */, 19 },
+ /* 7646 */ { MAD_F(0x0498cca2) /* 0.287304530 */, 19 },
+ /* 7647 */ { MAD_F(0x0499012c) /* 0.287354632 */, 19 },
+
+ /* 7648 */ { MAD_F(0x049935b5) /* 0.287404737 */, 19 },
+ /* 7649 */ { MAD_F(0x04996a40) /* 0.287454843 */, 19 },
+ /* 7650 */ { MAD_F(0x04999ecb) /* 0.287504952 */, 19 },
+ /* 7651 */ { MAD_F(0x0499d356) /* 0.287555063 */, 19 },
+ /* 7652 */ { MAD_F(0x049a07e2) /* 0.287605176 */, 19 },
+ /* 7653 */ { MAD_F(0x049a3c6f) /* 0.287655291 */, 19 },
+ /* 7654 */ { MAD_F(0x049a70fc) /* 0.287705409 */, 19 },
+ /* 7655 */ { MAD_F(0x049aa58a) /* 0.287755528 */, 19 },
+ /* 7656 */ { MAD_F(0x049ada19) /* 0.287805650 */, 19 },
+ /* 7657 */ { MAD_F(0x049b0ea8) /* 0.287855774 */, 19 },
+ /* 7658 */ { MAD_F(0x049b4337) /* 0.287905900 */, 19 },
+ /* 7659 */ { MAD_F(0x049b77c8) /* 0.287956028 */, 19 },
+ /* 7660 */ { MAD_F(0x049bac58) /* 0.288006159 */, 19 },
+ /* 7661 */ { MAD_F(0x049be0ea) /* 0.288056292 */, 19 },
+ /* 7662 */ { MAD_F(0x049c157c) /* 0.288106427 */, 19 },
+ /* 7663 */ { MAD_F(0x049c4a0e) /* 0.288156564 */, 19 },
+
+ /* 7664 */ { MAD_F(0x049c7ea1) /* 0.288206703 */, 19 },
+ /* 7665 */ { MAD_F(0x049cb335) /* 0.288256844 */, 19 },
+ /* 7666 */ { MAD_F(0x049ce7ca) /* 0.288306988 */, 19 },
+ /* 7667 */ { MAD_F(0x049d1c5e) /* 0.288357134 */, 19 },
+ /* 7668 */ { MAD_F(0x049d50f4) /* 0.288407282 */, 19 },
+ /* 7669 */ { MAD_F(0x049d858a) /* 0.288457432 */, 19 },
+ /* 7670 */ { MAD_F(0x049dba21) /* 0.288507584 */, 19 },
+ /* 7671 */ { MAD_F(0x049deeb8) /* 0.288557739 */, 19 },
+ /* 7672 */ { MAD_F(0x049e2350) /* 0.288607895 */, 19 },
+ /* 7673 */ { MAD_F(0x049e57e8) /* 0.288658054 */, 19 },
+ /* 7674 */ { MAD_F(0x049e8c81) /* 0.288708215 */, 19 },
+ /* 7675 */ { MAD_F(0x049ec11b) /* 0.288758379 */, 19 },
+ /* 7676 */ { MAD_F(0x049ef5b5) /* 0.288808544 */, 19 },
+ /* 7677 */ { MAD_F(0x049f2a50) /* 0.288858712 */, 19 },
+ /* 7678 */ { MAD_F(0x049f5eeb) /* 0.288908881 */, 19 },
+ /* 7679 */ { MAD_F(0x049f9387) /* 0.288959053 */, 19 },
+
+ /* 7680 */ { MAD_F(0x049fc824) /* 0.289009227 */, 19 },
+ /* 7681 */ { MAD_F(0x049ffcc1) /* 0.289059404 */, 19 },
+ /* 7682 */ { MAD_F(0x04a0315e) /* 0.289109582 */, 19 },
+ /* 7683 */ { MAD_F(0x04a065fd) /* 0.289159763 */, 19 },
+ /* 7684 */ { MAD_F(0x04a09a9b) /* 0.289209946 */, 19 },
+ /* 7685 */ { MAD_F(0x04a0cf3b) /* 0.289260131 */, 19 },
+ /* 7686 */ { MAD_F(0x04a103db) /* 0.289310318 */, 19 },
+ /* 7687 */ { MAD_F(0x04a1387b) /* 0.289360507 */, 19 },
+ /* 7688 */ { MAD_F(0x04a16d1d) /* 0.289410699 */, 19 },
+ /* 7689 */ { MAD_F(0x04a1a1be) /* 0.289460893 */, 19 },
+ /* 7690 */ { MAD_F(0x04a1d661) /* 0.289511088 */, 19 },
+ /* 7691 */ { MAD_F(0x04a20b04) /* 0.289561287 */, 19 },
+ /* 7692 */ { MAD_F(0x04a23fa7) /* 0.289611487 */, 19 },
+ /* 7693 */ { MAD_F(0x04a2744b) /* 0.289661689 */, 19 },
+ /* 7694 */ { MAD_F(0x04a2a8f0) /* 0.289711894 */, 19 },
+ /* 7695 */ { MAD_F(0x04a2dd95) /* 0.289762101 */, 19 },
+
+ /* 7696 */ { MAD_F(0x04a3123b) /* 0.289812309 */, 19 },
+ /* 7697 */ { MAD_F(0x04a346e2) /* 0.289862521 */, 19 },
+ /* 7698 */ { MAD_F(0x04a37b89) /* 0.289912734 */, 19 },
+ /* 7699 */ { MAD_F(0x04a3b030) /* 0.289962949 */, 19 },
+ /* 7700 */ { MAD_F(0x04a3e4d8) /* 0.290013167 */, 19 },
+ /* 7701 */ { MAD_F(0x04a41981) /* 0.290063387 */, 19 },
+ /* 7702 */ { MAD_F(0x04a44e2b) /* 0.290113609 */, 19 },
+ /* 7703 */ { MAD_F(0x04a482d5) /* 0.290163833 */, 19 },
+ /* 7704 */ { MAD_F(0x04a4b77f) /* 0.290214059 */, 19 },
+ /* 7705 */ { MAD_F(0x04a4ec2a) /* 0.290264288 */, 19 },
+ /* 7706 */ { MAD_F(0x04a520d6) /* 0.290314519 */, 19 },
+ /* 7707 */ { MAD_F(0x04a55582) /* 0.290364751 */, 19 },
+ /* 7708 */ { MAD_F(0x04a58a2f) /* 0.290414986 */, 19 },
+ /* 7709 */ { MAD_F(0x04a5bedd) /* 0.290465224 */, 19 },
+ /* 7710 */ { MAD_F(0x04a5f38b) /* 0.290515463 */, 19 },
+ /* 7711 */ { MAD_F(0x04a62839) /* 0.290565705 */, 19 },
+
+ /* 7712 */ { MAD_F(0x04a65ce8) /* 0.290615948 */, 19 },
+ /* 7713 */ { MAD_F(0x04a69198) /* 0.290666194 */, 19 },
+ /* 7714 */ { MAD_F(0x04a6c648) /* 0.290716442 */, 19 },
+ /* 7715 */ { MAD_F(0x04a6faf9) /* 0.290766692 */, 19 },
+ /* 7716 */ { MAD_F(0x04a72fab) /* 0.290816945 */, 19 },
+ /* 7717 */ { MAD_F(0x04a7645d) /* 0.290867199 */, 19 },
+ /* 7718 */ { MAD_F(0x04a79910) /* 0.290917456 */, 19 },
+ /* 7719 */ { MAD_F(0x04a7cdc3) /* 0.290967715 */, 19 },
+ /* 7720 */ { MAD_F(0x04a80277) /* 0.291017976 */, 19 },
+ /* 7721 */ { MAD_F(0x04a8372b) /* 0.291068239 */, 19 },
+ /* 7722 */ { MAD_F(0x04a86be0) /* 0.291118505 */, 19 },
+ /* 7723 */ { MAD_F(0x04a8a096) /* 0.291168772 */, 19 },
+ /* 7724 */ { MAD_F(0x04a8d54c) /* 0.291219042 */, 19 },
+ /* 7725 */ { MAD_F(0x04a90a03) /* 0.291269314 */, 19 },
+ /* 7726 */ { MAD_F(0x04a93eba) /* 0.291319588 */, 19 },
+ /* 7727 */ { MAD_F(0x04a97372) /* 0.291369865 */, 19 },
+
+ /* 7728 */ { MAD_F(0x04a9a82b) /* 0.291420143 */, 19 },
+ /* 7729 */ { MAD_F(0x04a9dce4) /* 0.291470424 */, 19 },
+ /* 7730 */ { MAD_F(0x04aa119d) /* 0.291520706 */, 19 },
+ /* 7731 */ { MAD_F(0x04aa4658) /* 0.291570991 */, 19 },
+ /* 7732 */ { MAD_F(0x04aa7b13) /* 0.291621278 */, 19 },
+ /* 7733 */ { MAD_F(0x04aaafce) /* 0.291671568 */, 19 },
+ /* 7734 */ { MAD_F(0x04aae48a) /* 0.291721859 */, 19 },
+ /* 7735 */ { MAD_F(0x04ab1947) /* 0.291772153 */, 19 },
+ /* 7736 */ { MAD_F(0x04ab4e04) /* 0.291822449 */, 19 },
+ /* 7737 */ { MAD_F(0x04ab82c2) /* 0.291872747 */, 19 },
+ /* 7738 */ { MAD_F(0x04abb780) /* 0.291923047 */, 19 },
+ /* 7739 */ { MAD_F(0x04abec3f) /* 0.291973349 */, 19 },
+ /* 7740 */ { MAD_F(0x04ac20fe) /* 0.292023653 */, 19 },
+ /* 7741 */ { MAD_F(0x04ac55be) /* 0.292073960 */, 19 },
+ /* 7742 */ { MAD_F(0x04ac8a7f) /* 0.292124269 */, 19 },
+ /* 7743 */ { MAD_F(0x04acbf40) /* 0.292174580 */, 19 },
+
+ /* 7744 */ { MAD_F(0x04acf402) /* 0.292224893 */, 19 },
+ /* 7745 */ { MAD_F(0x04ad28c5) /* 0.292275208 */, 19 },
+ /* 7746 */ { MAD_F(0x04ad5d88) /* 0.292325526 */, 19 },
+ /* 7747 */ { MAD_F(0x04ad924b) /* 0.292375845 */, 19 },
+ /* 7748 */ { MAD_F(0x04adc70f) /* 0.292426167 */, 19 },
+ /* 7749 */ { MAD_F(0x04adfbd4) /* 0.292476491 */, 19 },
+ /* 7750 */ { MAD_F(0x04ae3099) /* 0.292526817 */, 19 },
+ /* 7751 */ { MAD_F(0x04ae655f) /* 0.292577145 */, 19 },
+ /* 7752 */ { MAD_F(0x04ae9a26) /* 0.292627476 */, 19 },
+ /* 7753 */ { MAD_F(0x04aeceed) /* 0.292677808 */, 19 },
+ /* 7754 */ { MAD_F(0x04af03b4) /* 0.292728143 */, 19 },
+ /* 7755 */ { MAD_F(0x04af387d) /* 0.292778480 */, 19 },
+ /* 7756 */ { MAD_F(0x04af6d45) /* 0.292828819 */, 19 },
+ /* 7757 */ { MAD_F(0x04afa20f) /* 0.292879160 */, 19 },
+ /* 7758 */ { MAD_F(0x04afd6d9) /* 0.292929504 */, 19 },
+ /* 7759 */ { MAD_F(0x04b00ba3) /* 0.292979849 */, 19 },
+
+ /* 7760 */ { MAD_F(0x04b0406e) /* 0.293030197 */, 19 },
+ /* 7761 */ { MAD_F(0x04b0753a) /* 0.293080547 */, 19 },
+ /* 7762 */ { MAD_F(0x04b0aa06) /* 0.293130899 */, 19 },
+ /* 7763 */ { MAD_F(0x04b0ded3) /* 0.293181253 */, 19 },
+ /* 7764 */ { MAD_F(0x04b113a1) /* 0.293231610 */, 19 },
+ /* 7765 */ { MAD_F(0x04b1486f) /* 0.293281968 */, 19 },
+ /* 7766 */ { MAD_F(0x04b17d3d) /* 0.293332329 */, 19 },
+ /* 7767 */ { MAD_F(0x04b1b20c) /* 0.293382692 */, 19 },
+ /* 7768 */ { MAD_F(0x04b1e6dc) /* 0.293433057 */, 19 },
+ /* 7769 */ { MAD_F(0x04b21bad) /* 0.293483424 */, 19 },
+ /* 7770 */ { MAD_F(0x04b2507d) /* 0.293533794 */, 19 },
+ /* 7771 */ { MAD_F(0x04b2854f) /* 0.293584165 */, 19 },
+ /* 7772 */ { MAD_F(0x04b2ba21) /* 0.293634539 */, 19 },
+ /* 7773 */ { MAD_F(0x04b2eef4) /* 0.293684915 */, 19 },
+ /* 7774 */ { MAD_F(0x04b323c7) /* 0.293735293 */, 19 },
+ /* 7775 */ { MAD_F(0x04b3589b) /* 0.293785673 */, 19 },
+
+ /* 7776 */ { MAD_F(0x04b38d6f) /* 0.293836055 */, 19 },
+ /* 7777 */ { MAD_F(0x04b3c244) /* 0.293886440 */, 19 },
+ /* 7778 */ { MAD_F(0x04b3f71a) /* 0.293936826 */, 19 },
+ /* 7779 */ { MAD_F(0x04b42bf0) /* 0.293987215 */, 19 },
+ /* 7780 */ { MAD_F(0x04b460c7) /* 0.294037606 */, 19 },
+ /* 7781 */ { MAD_F(0x04b4959e) /* 0.294087999 */, 19 },
+ /* 7782 */ { MAD_F(0x04b4ca76) /* 0.294138395 */, 19 },
+ /* 7783 */ { MAD_F(0x04b4ff4e) /* 0.294188792 */, 19 },
+ /* 7784 */ { MAD_F(0x04b53427) /* 0.294239192 */, 19 },
+ /* 7785 */ { MAD_F(0x04b56901) /* 0.294289593 */, 19 },
+ /* 7786 */ { MAD_F(0x04b59ddb) /* 0.294339997 */, 19 },
+ /* 7787 */ { MAD_F(0x04b5d2b6) /* 0.294390403 */, 19 },
+ /* 7788 */ { MAD_F(0x04b60791) /* 0.294440812 */, 19 },
+ /* 7789 */ { MAD_F(0x04b63c6d) /* 0.294491222 */, 19 },
+ /* 7790 */ { MAD_F(0x04b6714a) /* 0.294541635 */, 19 },
+ /* 7791 */ { MAD_F(0x04b6a627) /* 0.294592049 */, 19 },
+
+ /* 7792 */ { MAD_F(0x04b6db05) /* 0.294642466 */, 19 },
+ /* 7793 */ { MAD_F(0x04b70fe3) /* 0.294692885 */, 19 },
+ /* 7794 */ { MAD_F(0x04b744c2) /* 0.294743306 */, 19 },
+ /* 7795 */ { MAD_F(0x04b779a1) /* 0.294793730 */, 19 },
+ /* 7796 */ { MAD_F(0x04b7ae81) /* 0.294844155 */, 19 },
+ /* 7797 */ { MAD_F(0x04b7e362) /* 0.294894583 */, 19 },
+ /* 7798 */ { MAD_F(0x04b81843) /* 0.294945013 */, 19 },
+ /* 7799 */ { MAD_F(0x04b84d24) /* 0.294995445 */, 19 },
+ /* 7800 */ { MAD_F(0x04b88207) /* 0.295045879 */, 19 },
+ /* 7801 */ { MAD_F(0x04b8b6ea) /* 0.295096315 */, 19 },
+ /* 7802 */ { MAD_F(0x04b8ebcd) /* 0.295146753 */, 19 },
+ /* 7803 */ { MAD_F(0x04b920b1) /* 0.295197194 */, 19 },
+ /* 7804 */ { MAD_F(0x04b95596) /* 0.295247637 */, 19 },
+ /* 7805 */ { MAD_F(0x04b98a7b) /* 0.295298082 */, 19 },
+ /* 7806 */ { MAD_F(0x04b9bf61) /* 0.295348529 */, 19 },
+ /* 7807 */ { MAD_F(0x04b9f447) /* 0.295398978 */, 19 },
+
+ /* 7808 */ { MAD_F(0x04ba292e) /* 0.295449429 */, 19 },
+ /* 7809 */ { MAD_F(0x04ba5e16) /* 0.295499883 */, 19 },
+ /* 7810 */ { MAD_F(0x04ba92fe) /* 0.295550338 */, 19 },
+ /* 7811 */ { MAD_F(0x04bac7e6) /* 0.295600796 */, 19 },
+ /* 7812 */ { MAD_F(0x04bafcd0) /* 0.295651256 */, 19 },
+ /* 7813 */ { MAD_F(0x04bb31b9) /* 0.295701718 */, 19 },
+ /* 7814 */ { MAD_F(0x04bb66a4) /* 0.295752183 */, 19 },
+ /* 7815 */ { MAD_F(0x04bb9b8f) /* 0.295802649 */, 19 },
+ /* 7816 */ { MAD_F(0x04bbd07a) /* 0.295853118 */, 19 },
+ /* 7817 */ { MAD_F(0x04bc0566) /* 0.295903588 */, 19 },
+ /* 7818 */ { MAD_F(0x04bc3a53) /* 0.295954061 */, 19 },
+ /* 7819 */ { MAD_F(0x04bc6f40) /* 0.296004536 */, 19 },
+ /* 7820 */ { MAD_F(0x04bca42e) /* 0.296055013 */, 19 },
+ /* 7821 */ { MAD_F(0x04bcd91d) /* 0.296105493 */, 19 },
+ /* 7822 */ { MAD_F(0x04bd0e0c) /* 0.296155974 */, 19 },
+ /* 7823 */ { MAD_F(0x04bd42fb) /* 0.296206458 */, 19 },
+
+ /* 7824 */ { MAD_F(0x04bd77ec) /* 0.296256944 */, 19 },
+ /* 7825 */ { MAD_F(0x04bdacdc) /* 0.296307432 */, 19 },
+ /* 7826 */ { MAD_F(0x04bde1ce) /* 0.296357922 */, 19 },
+ /* 7827 */ { MAD_F(0x04be16c0) /* 0.296408414 */, 19 },
+ /* 7828 */ { MAD_F(0x04be4bb2) /* 0.296458908 */, 19 },
+ /* 7829 */ { MAD_F(0x04be80a5) /* 0.296509405 */, 19 },
+ /* 7830 */ { MAD_F(0x04beb599) /* 0.296559904 */, 19 },
+ /* 7831 */ { MAD_F(0x04beea8d) /* 0.296610404 */, 19 },
+ /* 7832 */ { MAD_F(0x04bf1f82) /* 0.296660907 */, 19 },
+ /* 7833 */ { MAD_F(0x04bf5477) /* 0.296711413 */, 19 },
+ /* 7834 */ { MAD_F(0x04bf896d) /* 0.296761920 */, 19 },
+ /* 7835 */ { MAD_F(0x04bfbe64) /* 0.296812429 */, 19 },
+ /* 7836 */ { MAD_F(0x04bff35b) /* 0.296862941 */, 19 },
+ /* 7837 */ { MAD_F(0x04c02852) /* 0.296913455 */, 19 },
+ /* 7838 */ { MAD_F(0x04c05d4b) /* 0.296963971 */, 19 },
+ /* 7839 */ { MAD_F(0x04c09243) /* 0.297014489 */, 19 },
+
+ /* 7840 */ { MAD_F(0x04c0c73d) /* 0.297065009 */, 19 },
+ /* 7841 */ { MAD_F(0x04c0fc37) /* 0.297115531 */, 19 },
+ /* 7842 */ { MAD_F(0x04c13131) /* 0.297166056 */, 19 },
+ /* 7843 */ { MAD_F(0x04c1662d) /* 0.297216582 */, 19 },
+ /* 7844 */ { MAD_F(0x04c19b28) /* 0.297267111 */, 19 },
+ /* 7845 */ { MAD_F(0x04c1d025) /* 0.297317642 */, 19 },
+ /* 7846 */ { MAD_F(0x04c20521) /* 0.297368175 */, 19 },
+ /* 7847 */ { MAD_F(0x04c23a1f) /* 0.297418710 */, 19 },
+ /* 7848 */ { MAD_F(0x04c26f1d) /* 0.297469248 */, 19 },
+ /* 7849 */ { MAD_F(0x04c2a41b) /* 0.297519787 */, 19 },
+ /* 7850 */ { MAD_F(0x04c2d91b) /* 0.297570329 */, 19 },
+ /* 7851 */ { MAD_F(0x04c30e1a) /* 0.297620873 */, 19 },
+ /* 7852 */ { MAD_F(0x04c3431b) /* 0.297671418 */, 19 },
+ /* 7853 */ { MAD_F(0x04c3781c) /* 0.297721967 */, 19 },
+ /* 7854 */ { MAD_F(0x04c3ad1d) /* 0.297772517 */, 19 },
+ /* 7855 */ { MAD_F(0x04c3e21f) /* 0.297823069 */, 19 },
+
+ /* 7856 */ { MAD_F(0x04c41722) /* 0.297873624 */, 19 },
+ /* 7857 */ { MAD_F(0x04c44c25) /* 0.297924180 */, 19 },
+ /* 7858 */ { MAD_F(0x04c48129) /* 0.297974739 */, 19 },
+ /* 7859 */ { MAD_F(0x04c4b62d) /* 0.298025300 */, 19 },
+ /* 7860 */ { MAD_F(0x04c4eb32) /* 0.298075863 */, 19 },
+ /* 7861 */ { MAD_F(0x04c52038) /* 0.298126429 */, 19 },
+ /* 7862 */ { MAD_F(0x04c5553e) /* 0.298176996 */, 19 },
+ /* 7863 */ { MAD_F(0x04c58a44) /* 0.298227565 */, 19 },
+ /* 7864 */ { MAD_F(0x04c5bf4c) /* 0.298278137 */, 19 },
+ /* 7865 */ { MAD_F(0x04c5f453) /* 0.298328711 */, 19 },
+ /* 7866 */ { MAD_F(0x04c6295c) /* 0.298379287 */, 19 },
+ /* 7867 */ { MAD_F(0x04c65e65) /* 0.298429865 */, 19 },
+ /* 7868 */ { MAD_F(0x04c6936e) /* 0.298480445 */, 19 },
+ /* 7869 */ { MAD_F(0x04c6c878) /* 0.298531028 */, 19 },
+ /* 7870 */ { MAD_F(0x04c6fd83) /* 0.298581612 */, 19 },
+ /* 7871 */ { MAD_F(0x04c7328e) /* 0.298632199 */, 19 },
+
+ /* 7872 */ { MAD_F(0x04c7679a) /* 0.298682788 */, 19 },
+ /* 7873 */ { MAD_F(0x04c79ca7) /* 0.298733379 */, 19 },
+ /* 7874 */ { MAD_F(0x04c7d1b4) /* 0.298783972 */, 19 },
+ /* 7875 */ { MAD_F(0x04c806c1) /* 0.298834567 */, 19 },
+ /* 7876 */ { MAD_F(0x04c83bcf) /* 0.298885165 */, 19 },
+ /* 7877 */ { MAD_F(0x04c870de) /* 0.298935764 */, 19 },
+ /* 7878 */ { MAD_F(0x04c8a5ed) /* 0.298986366 */, 19 },
+ /* 7879 */ { MAD_F(0x04c8dafd) /* 0.299036970 */, 19 },
+ /* 7880 */ { MAD_F(0x04c9100d) /* 0.299087576 */, 19 },
+ /* 7881 */ { MAD_F(0x04c9451e) /* 0.299138184 */, 19 },
+ /* 7882 */ { MAD_F(0x04c97a30) /* 0.299188794 */, 19 },
+ /* 7883 */ { MAD_F(0x04c9af42) /* 0.299239406 */, 19 },
+ /* 7884 */ { MAD_F(0x04c9e455) /* 0.299290021 */, 19 },
+ /* 7885 */ { MAD_F(0x04ca1968) /* 0.299340638 */, 19 },
+ /* 7886 */ { MAD_F(0x04ca4e7c) /* 0.299391256 */, 19 },
+ /* 7887 */ { MAD_F(0x04ca8391) /* 0.299441877 */, 19 },
+
+ /* 7888 */ { MAD_F(0x04cab8a6) /* 0.299492500 */, 19 },
+ /* 7889 */ { MAD_F(0x04caedbb) /* 0.299543126 */, 19 },
+ /* 7890 */ { MAD_F(0x04cb22d1) /* 0.299593753 */, 19 },
+ /* 7891 */ { MAD_F(0x04cb57e8) /* 0.299644382 */, 19 },
+ /* 7892 */ { MAD_F(0x04cb8d00) /* 0.299695014 */, 19 },
+ /* 7893 */ { MAD_F(0x04cbc217) /* 0.299745648 */, 19 },
+ /* 7894 */ { MAD_F(0x04cbf730) /* 0.299796284 */, 19 },
+ /* 7895 */ { MAD_F(0x04cc2c49) /* 0.299846922 */, 19 },
+ /* 7896 */ { MAD_F(0x04cc6163) /* 0.299897562 */, 19 },
+ /* 7897 */ { MAD_F(0x04cc967d) /* 0.299948204 */, 19 },
+ /* 7898 */ { MAD_F(0x04cccb98) /* 0.299998849 */, 19 },
+ /* 7899 */ { MAD_F(0x04cd00b3) /* 0.300049495 */, 19 },
+ /* 7900 */ { MAD_F(0x04cd35cf) /* 0.300100144 */, 19 },
+ /* 7901 */ { MAD_F(0x04cd6aeb) /* 0.300150795 */, 19 },
+ /* 7902 */ { MAD_F(0x04cda008) /* 0.300201448 */, 19 },
+ /* 7903 */ { MAD_F(0x04cdd526) /* 0.300252103 */, 19 },
+
+ /* 7904 */ { MAD_F(0x04ce0a44) /* 0.300302761 */, 19 },
+ /* 7905 */ { MAD_F(0x04ce3f63) /* 0.300353420 */, 19 },
+ /* 7906 */ { MAD_F(0x04ce7482) /* 0.300404082 */, 19 },
+ /* 7907 */ { MAD_F(0x04cea9a2) /* 0.300454745 */, 19 },
+ /* 7908 */ { MAD_F(0x04cedec3) /* 0.300505411 */, 19 },
+ /* 7909 */ { MAD_F(0x04cf13e4) /* 0.300556079 */, 19 },
+ /* 7910 */ { MAD_F(0x04cf4906) /* 0.300606749 */, 19 },
+ /* 7911 */ { MAD_F(0x04cf7e28) /* 0.300657421 */, 19 },
+ /* 7912 */ { MAD_F(0x04cfb34b) /* 0.300708096 */, 19 },
+ /* 7913 */ { MAD_F(0x04cfe86e) /* 0.300758772 */, 19 },
+ /* 7914 */ { MAD_F(0x04d01d92) /* 0.300809451 */, 19 },
+ /* 7915 */ { MAD_F(0x04d052b6) /* 0.300860132 */, 19 },
+ /* 7916 */ { MAD_F(0x04d087db) /* 0.300910815 */, 19 },
+ /* 7917 */ { MAD_F(0x04d0bd01) /* 0.300961500 */, 19 },
+ /* 7918 */ { MAD_F(0x04d0f227) /* 0.301012187 */, 19 },
+ /* 7919 */ { MAD_F(0x04d1274e) /* 0.301062876 */, 19 },
+
+ /* 7920 */ { MAD_F(0x04d15c76) /* 0.301113568 */, 19 },
+ /* 7921 */ { MAD_F(0x04d1919e) /* 0.301164261 */, 19 },
+ /* 7922 */ { MAD_F(0x04d1c6c6) /* 0.301214957 */, 19 },
+ /* 7923 */ { MAD_F(0x04d1fbef) /* 0.301265655 */, 19 },
+ /* 7924 */ { MAD_F(0x04d23119) /* 0.301316355 */, 19 },
+ /* 7925 */ { MAD_F(0x04d26643) /* 0.301367057 */, 19 },
+ /* 7926 */ { MAD_F(0x04d29b6e) /* 0.301417761 */, 19 },
+ /* 7927 */ { MAD_F(0x04d2d099) /* 0.301468468 */, 19 },
+ /* 7928 */ { MAD_F(0x04d305c5) /* 0.301519176 */, 19 },
+ /* 7929 */ { MAD_F(0x04d33af2) /* 0.301569887 */, 19 },
+ /* 7930 */ { MAD_F(0x04d3701f) /* 0.301620599 */, 19 },
+ /* 7931 */ { MAD_F(0x04d3a54d) /* 0.301671314 */, 19 },
+ /* 7932 */ { MAD_F(0x04d3da7b) /* 0.301722031 */, 19 },
+ /* 7933 */ { MAD_F(0x04d40faa) /* 0.301772751 */, 19 },
+ /* 7934 */ { MAD_F(0x04d444d9) /* 0.301823472 */, 19 },
+ /* 7935 */ { MAD_F(0x04d47a09) /* 0.301874195 */, 19 },
+
+ /* 7936 */ { MAD_F(0x04d4af3a) /* 0.301924921 */, 19 },
+ /* 7937 */ { MAD_F(0x04d4e46b) /* 0.301975649 */, 19 },
+ /* 7938 */ { MAD_F(0x04d5199c) /* 0.302026378 */, 19 },
+ /* 7939 */ { MAD_F(0x04d54ecf) /* 0.302077110 */, 19 },
+ /* 7940 */ { MAD_F(0x04d58401) /* 0.302127845 */, 19 },
+ /* 7941 */ { MAD_F(0x04d5b935) /* 0.302178581 */, 19 },
+ /* 7942 */ { MAD_F(0x04d5ee69) /* 0.302229319 */, 19 },
+ /* 7943 */ { MAD_F(0x04d6239d) /* 0.302280060 */, 19 },
+ /* 7944 */ { MAD_F(0x04d658d2) /* 0.302330802 */, 19 },
+ /* 7945 */ { MAD_F(0x04d68e08) /* 0.302381547 */, 19 },
+ /* 7946 */ { MAD_F(0x04d6c33e) /* 0.302432294 */, 19 },
+ /* 7947 */ { MAD_F(0x04d6f875) /* 0.302483043 */, 19 },
+ /* 7948 */ { MAD_F(0x04d72dad) /* 0.302533794 */, 19 },
+ /* 7949 */ { MAD_F(0x04d762e5) /* 0.302584547 */, 19 },
+ /* 7950 */ { MAD_F(0x04d7981d) /* 0.302635303 */, 19 },
+ /* 7951 */ { MAD_F(0x04d7cd56) /* 0.302686060 */, 19 },
+
+ /* 7952 */ { MAD_F(0x04d80290) /* 0.302736820 */, 19 },
+ /* 7953 */ { MAD_F(0x04d837ca) /* 0.302787581 */, 19 },
+ /* 7954 */ { MAD_F(0x04d86d05) /* 0.302838345 */, 19 },
+ /* 7955 */ { MAD_F(0x04d8a240) /* 0.302889111 */, 19 },
+ /* 7956 */ { MAD_F(0x04d8d77c) /* 0.302939879 */, 19 },
+ /* 7957 */ { MAD_F(0x04d90cb9) /* 0.302990650 */, 19 },
+ /* 7958 */ { MAD_F(0x04d941f6) /* 0.303041422 */, 19 },
+ /* 7959 */ { MAD_F(0x04d97734) /* 0.303092197 */, 19 },
+ /* 7960 */ { MAD_F(0x04d9ac72) /* 0.303142973 */, 19 },
+ /* 7961 */ { MAD_F(0x04d9e1b1) /* 0.303193752 */, 19 },
+ /* 7962 */ { MAD_F(0x04da16f0) /* 0.303244533 */, 19 },
+ /* 7963 */ { MAD_F(0x04da4c30) /* 0.303295316 */, 19 },
+ /* 7964 */ { MAD_F(0x04da8171) /* 0.303346101 */, 19 },
+ /* 7965 */ { MAD_F(0x04dab6b2) /* 0.303396889 */, 19 },
+ /* 7966 */ { MAD_F(0x04daebf4) /* 0.303447678 */, 19 },
+ /* 7967 */ { MAD_F(0x04db2136) /* 0.303498469 */, 19 },
+
+ /* 7968 */ { MAD_F(0x04db5679) /* 0.303549263 */, 19 },
+ /* 7969 */ { MAD_F(0x04db8bbc) /* 0.303600059 */, 19 },
+ /* 7970 */ { MAD_F(0x04dbc100) /* 0.303650857 */, 19 },
+ /* 7971 */ { MAD_F(0x04dbf644) /* 0.303701657 */, 19 },
+ /* 7972 */ { MAD_F(0x04dc2b8a) /* 0.303752459 */, 19 },
+ /* 7973 */ { MAD_F(0x04dc60cf) /* 0.303803263 */, 19 },
+ /* 7974 */ { MAD_F(0x04dc9616) /* 0.303854070 */, 19 },
+ /* 7975 */ { MAD_F(0x04dccb5c) /* 0.303904878 */, 19 },
+ /* 7976 */ { MAD_F(0x04dd00a4) /* 0.303955689 */, 19 },
+ /* 7977 */ { MAD_F(0x04dd35ec) /* 0.304006502 */, 19 },
+ /* 7978 */ { MAD_F(0x04dd6b34) /* 0.304057317 */, 19 },
+ /* 7979 */ { MAD_F(0x04dda07d) /* 0.304108134 */, 19 },
+ /* 7980 */ { MAD_F(0x04ddd5c7) /* 0.304158953 */, 19 },
+ /* 7981 */ { MAD_F(0x04de0b11) /* 0.304209774 */, 19 },
+ /* 7982 */ { MAD_F(0x04de405c) /* 0.304260597 */, 19 },
+ /* 7983 */ { MAD_F(0x04de75a7) /* 0.304311423 */, 19 },
+
+ /* 7984 */ { MAD_F(0x04deaaf3) /* 0.304362251 */, 19 },
+ /* 7985 */ { MAD_F(0x04dee040) /* 0.304413080 */, 19 },
+ /* 7986 */ { MAD_F(0x04df158d) /* 0.304463912 */, 19 },
+ /* 7987 */ { MAD_F(0x04df4adb) /* 0.304514746 */, 19 },
+ /* 7988 */ { MAD_F(0x04df8029) /* 0.304565582 */, 19 },
+ /* 7989 */ { MAD_F(0x04dfb578) /* 0.304616421 */, 19 },
+ /* 7990 */ { MAD_F(0x04dfeac7) /* 0.304667261 */, 19 },
+ /* 7991 */ { MAD_F(0x04e02017) /* 0.304718103 */, 19 },
+ /* 7992 */ { MAD_F(0x04e05567) /* 0.304768948 */, 19 },
+ /* 7993 */ { MAD_F(0x04e08ab8) /* 0.304819795 */, 19 },
+ /* 7994 */ { MAD_F(0x04e0c00a) /* 0.304870644 */, 19 },
+ /* 7995 */ { MAD_F(0x04e0f55c) /* 0.304921495 */, 19 },
+ /* 7996 */ { MAD_F(0x04e12aaf) /* 0.304972348 */, 19 },
+ /* 7997 */ { MAD_F(0x04e16002) /* 0.305023203 */, 19 },
+ /* 7998 */ { MAD_F(0x04e19556) /* 0.305074060 */, 19 },
+ /* 7999 */ { MAD_F(0x04e1caab) /* 0.305124920 */, 19 },
+
+ /* 8000 */ { MAD_F(0x04e20000) /* 0.305175781 */, 19 },
+ /* 8001 */ { MAD_F(0x04e23555) /* 0.305226645 */, 19 },
+ /* 8002 */ { MAD_F(0x04e26aac) /* 0.305277511 */, 19 },
+ /* 8003 */ { MAD_F(0x04e2a002) /* 0.305328379 */, 19 },
+ /* 8004 */ { MAD_F(0x04e2d55a) /* 0.305379249 */, 19 },
+ /* 8005 */ { MAD_F(0x04e30ab2) /* 0.305430121 */, 19 },
+ /* 8006 */ { MAD_F(0x04e3400a) /* 0.305480995 */, 19 },
+ /* 8007 */ { MAD_F(0x04e37563) /* 0.305531872 */, 19 },
+ /* 8008 */ { MAD_F(0x04e3aabd) /* 0.305582750 */, 19 },
+ /* 8009 */ { MAD_F(0x04e3e017) /* 0.305633631 */, 19 },
+ /* 8010 */ { MAD_F(0x04e41572) /* 0.305684513 */, 19 },
+ /* 8011 */ { MAD_F(0x04e44acd) /* 0.305735398 */, 19 },
+ /* 8012 */ { MAD_F(0x04e48029) /* 0.305786285 */, 19 },
+ /* 8013 */ { MAD_F(0x04e4b585) /* 0.305837174 */, 19 },
+ /* 8014 */ { MAD_F(0x04e4eae2) /* 0.305888066 */, 19 },
+ /* 8015 */ { MAD_F(0x04e52040) /* 0.305938959 */, 19 },
+
+ /* 8016 */ { MAD_F(0x04e5559e) /* 0.305989854 */, 19 },
+ /* 8017 */ { MAD_F(0x04e58afd) /* 0.306040752 */, 19 },
+ /* 8018 */ { MAD_F(0x04e5c05c) /* 0.306091652 */, 19 },
+ /* 8019 */ { MAD_F(0x04e5f5bc) /* 0.306142554 */, 19 },
+ /* 8020 */ { MAD_F(0x04e62b1c) /* 0.306193457 */, 19 },
+ /* 8021 */ { MAD_F(0x04e6607d) /* 0.306244364 */, 19 },
+ /* 8022 */ { MAD_F(0x04e695df) /* 0.306295272 */, 19 },
+ /* 8023 */ { MAD_F(0x04e6cb41) /* 0.306346182 */, 19 },
+ /* 8024 */ { MAD_F(0x04e700a3) /* 0.306397094 */, 19 },
+ /* 8025 */ { MAD_F(0x04e73607) /* 0.306448009 */, 19 },
+ /* 8026 */ { MAD_F(0x04e76b6b) /* 0.306498925 */, 19 },
+ /* 8027 */ { MAD_F(0x04e7a0cf) /* 0.306549844 */, 19 },
+ /* 8028 */ { MAD_F(0x04e7d634) /* 0.306600765 */, 19 },
+ /* 8029 */ { MAD_F(0x04e80b99) /* 0.306651688 */, 19 },
+ /* 8030 */ { MAD_F(0x04e84100) /* 0.306702613 */, 19 },
+ /* 8031 */ { MAD_F(0x04e87666) /* 0.306753540 */, 19 },
+
+ /* 8032 */ { MAD_F(0x04e8abcd) /* 0.306804470 */, 19 },
+ /* 8033 */ { MAD_F(0x04e8e135) /* 0.306855401 */, 19 },
+ /* 8034 */ { MAD_F(0x04e9169e) /* 0.306906334 */, 19 },
+ /* 8035 */ { MAD_F(0x04e94c07) /* 0.306957270 */, 19 },
+ /* 8036 */ { MAD_F(0x04e98170) /* 0.307008208 */, 19 },
+ /* 8037 */ { MAD_F(0x04e9b6da) /* 0.307059148 */, 19 },
+ /* 8038 */ { MAD_F(0x04e9ec45) /* 0.307110090 */, 19 },
+ /* 8039 */ { MAD_F(0x04ea21b0) /* 0.307161034 */, 19 },
+ /* 8040 */ { MAD_F(0x04ea571c) /* 0.307211980 */, 19 },
+ /* 8041 */ { MAD_F(0x04ea8c88) /* 0.307262928 */, 19 },
+ /* 8042 */ { MAD_F(0x04eac1f5) /* 0.307313879 */, 19 },
+ /* 8043 */ { MAD_F(0x04eaf762) /* 0.307364831 */, 19 },
+ /* 8044 */ { MAD_F(0x04eb2cd0) /* 0.307415786 */, 19 },
+ /* 8045 */ { MAD_F(0x04eb623f) /* 0.307466743 */, 19 },
+ /* 8046 */ { MAD_F(0x04eb97ae) /* 0.307517702 */, 19 },
+ /* 8047 */ { MAD_F(0x04ebcd1e) /* 0.307568663 */, 19 },
+
+ /* 8048 */ { MAD_F(0x04ec028e) /* 0.307619626 */, 19 },
+ /* 8049 */ { MAD_F(0x04ec37ff) /* 0.307670591 */, 19 },
+ /* 8050 */ { MAD_F(0x04ec6d71) /* 0.307721558 */, 19 },
+ /* 8051 */ { MAD_F(0x04eca2e3) /* 0.307772528 */, 19 },
+ /* 8052 */ { MAD_F(0x04ecd855) /* 0.307823499 */, 19 },
+ /* 8053 */ { MAD_F(0x04ed0dc8) /* 0.307874473 */, 19 },
+ /* 8054 */ { MAD_F(0x04ed433c) /* 0.307925449 */, 19 },
+ /* 8055 */ { MAD_F(0x04ed78b0) /* 0.307976426 */, 19 },
+ /* 8056 */ { MAD_F(0x04edae25) /* 0.308027406 */, 19 },
+ /* 8057 */ { MAD_F(0x04ede39a) /* 0.308078389 */, 19 },
+ /* 8058 */ { MAD_F(0x04ee1910) /* 0.308129373 */, 19 },
+ /* 8059 */ { MAD_F(0x04ee4e87) /* 0.308180359 */, 19 },
+ /* 8060 */ { MAD_F(0x04ee83fe) /* 0.308231347 */, 19 },
+ /* 8061 */ { MAD_F(0x04eeb976) /* 0.308282338 */, 19 },
+ /* 8062 */ { MAD_F(0x04eeeeee) /* 0.308333331 */, 19 },
+ /* 8063 */ { MAD_F(0x04ef2467) /* 0.308384325 */, 19 },
+
+ /* 8064 */ { MAD_F(0x04ef59e0) /* 0.308435322 */, 19 },
+ /* 8065 */ { MAD_F(0x04ef8f5a) /* 0.308486321 */, 19 },
+ /* 8066 */ { MAD_F(0x04efc4d5) /* 0.308537322 */, 19 },
+ /* 8067 */ { MAD_F(0x04effa50) /* 0.308588325 */, 19 },
+ /* 8068 */ { MAD_F(0x04f02fcb) /* 0.308639331 */, 19 },
+ /* 8069 */ { MAD_F(0x04f06547) /* 0.308690338 */, 19 },
+ /* 8070 */ { MAD_F(0x04f09ac4) /* 0.308741348 */, 19 },
+ /* 8071 */ { MAD_F(0x04f0d041) /* 0.308792359 */, 19 },
+ /* 8072 */ { MAD_F(0x04f105bf) /* 0.308843373 */, 19 },
+ /* 8073 */ { MAD_F(0x04f13b3e) /* 0.308894389 */, 19 },
+ /* 8074 */ { MAD_F(0x04f170bd) /* 0.308945407 */, 19 },
+ /* 8075 */ { MAD_F(0x04f1a63c) /* 0.308996427 */, 19 },
+ /* 8076 */ { MAD_F(0x04f1dbbd) /* 0.309047449 */, 19 },
+ /* 8077 */ { MAD_F(0x04f2113d) /* 0.309098473 */, 19 },
+ /* 8078 */ { MAD_F(0x04f246bf) /* 0.309149499 */, 19 },
+ /* 8079 */ { MAD_F(0x04f27c40) /* 0.309200528 */, 19 },
+
+ /* 8080 */ { MAD_F(0x04f2b1c3) /* 0.309251558 */, 19 },
+ /* 8081 */ { MAD_F(0x04f2e746) /* 0.309302591 */, 19 },
+ /* 8082 */ { MAD_F(0x04f31cc9) /* 0.309353626 */, 19 },
+ /* 8083 */ { MAD_F(0x04f3524d) /* 0.309404663 */, 19 },
+ /* 8084 */ { MAD_F(0x04f387d2) /* 0.309455702 */, 19 },
+ /* 8085 */ { MAD_F(0x04f3bd57) /* 0.309506743 */, 19 },
+ /* 8086 */ { MAD_F(0x04f3f2dd) /* 0.309557786 */, 19 },
+ /* 8087 */ { MAD_F(0x04f42864) /* 0.309608831 */, 19 },
+ /* 8088 */ { MAD_F(0x04f45dea) /* 0.309659879 */, 19 },
+ /* 8089 */ { MAD_F(0x04f49372) /* 0.309710928 */, 19 },
+ /* 8090 */ { MAD_F(0x04f4c8fa) /* 0.309761980 */, 19 },
+ /* 8091 */ { MAD_F(0x04f4fe83) /* 0.309813033 */, 19 },
+ /* 8092 */ { MAD_F(0x04f5340c) /* 0.309864089 */, 19 },
+ /* 8093 */ { MAD_F(0x04f56996) /* 0.309915147 */, 19 },
+ /* 8094 */ { MAD_F(0x04f59f20) /* 0.309966207 */, 19 },
+ /* 8095 */ { MAD_F(0x04f5d4ab) /* 0.310017269 */, 19 },
+
+ /* 8096 */ { MAD_F(0x04f60a36) /* 0.310068333 */, 19 },
+ /* 8097 */ { MAD_F(0x04f63fc2) /* 0.310119400 */, 19 },
+ /* 8098 */ { MAD_F(0x04f6754f) /* 0.310170468 */, 19 },
+ /* 8099 */ { MAD_F(0x04f6aadc) /* 0.310221539 */, 19 },
+ /* 8100 */ { MAD_F(0x04f6e06a) /* 0.310272611 */, 19 },
+ /* 8101 */ { MAD_F(0x04f715f8) /* 0.310323686 */, 19 },
+ /* 8102 */ { MAD_F(0x04f74b87) /* 0.310374763 */, 19 },
+ /* 8103 */ { MAD_F(0x04f78116) /* 0.310425842 */, 19 },
+ /* 8104 */ { MAD_F(0x04f7b6a6) /* 0.310476923 */, 19 },
+ /* 8105 */ { MAD_F(0x04f7ec37) /* 0.310528006 */, 19 },
+ /* 8106 */ { MAD_F(0x04f821c8) /* 0.310579091 */, 19 },
+ /* 8107 */ { MAD_F(0x04f85759) /* 0.310630179 */, 19 },
+ /* 8108 */ { MAD_F(0x04f88cec) /* 0.310681268 */, 19 },
+ /* 8109 */ { MAD_F(0x04f8c27e) /* 0.310732360 */, 19 },
+ /* 8110 */ { MAD_F(0x04f8f812) /* 0.310783453 */, 19 },
+ /* 8111 */ { MAD_F(0x04f92da6) /* 0.310834549 */, 19 },
+
+ /* 8112 */ { MAD_F(0x04f9633a) /* 0.310885647 */, 19 },
+ /* 8113 */ { MAD_F(0x04f998cf) /* 0.310936747 */, 19 },
+ /* 8114 */ { MAD_F(0x04f9ce65) /* 0.310987849 */, 19 },
+ /* 8115 */ { MAD_F(0x04fa03fb) /* 0.311038953 */, 19 },
+ /* 8116 */ { MAD_F(0x04fa3992) /* 0.311090059 */, 19 },
+ /* 8117 */ { MAD_F(0x04fa6f29) /* 0.311141168 */, 19 },
+ /* 8118 */ { MAD_F(0x04faa4c1) /* 0.311192278 */, 19 },
+ /* 8119 */ { MAD_F(0x04fada59) /* 0.311243390 */, 19 },
+ /* 8120 */ { MAD_F(0x04fb0ff2) /* 0.311294505 */, 19 },
+ /* 8121 */ { MAD_F(0x04fb458c) /* 0.311345622 */, 19 },
+ /* 8122 */ { MAD_F(0x04fb7b26) /* 0.311396741 */, 19 },
+ /* 8123 */ { MAD_F(0x04fbb0c1) /* 0.311447862 */, 19 },
+ /* 8124 */ { MAD_F(0x04fbe65c) /* 0.311498985 */, 19 },
+ /* 8125 */ { MAD_F(0x04fc1bf8) /* 0.311550110 */, 19 },
+ /* 8126 */ { MAD_F(0x04fc5194) /* 0.311601237 */, 19 },
+ /* 8127 */ { MAD_F(0x04fc8731) /* 0.311652366 */, 19 },
+
+ /* 8128 */ { MAD_F(0x04fcbcce) /* 0.311703498 */, 19 },
+ /* 8129 */ { MAD_F(0x04fcf26c) /* 0.311754631 */, 19 },
+ /* 8130 */ { MAD_F(0x04fd280b) /* 0.311805767 */, 19 },
+ /* 8131 */ { MAD_F(0x04fd5daa) /* 0.311856905 */, 19 },
+ /* 8132 */ { MAD_F(0x04fd934a) /* 0.311908044 */, 19 },
+ /* 8133 */ { MAD_F(0x04fdc8ea) /* 0.311959186 */, 19 },
+ /* 8134 */ { MAD_F(0x04fdfe8b) /* 0.312010330 */, 19 },
+ /* 8135 */ { MAD_F(0x04fe342c) /* 0.312061476 */, 19 },
+ /* 8136 */ { MAD_F(0x04fe69ce) /* 0.312112625 */, 19 },
+ /* 8137 */ { MAD_F(0x04fe9f71) /* 0.312163775 */, 19 },
+ /* 8138 */ { MAD_F(0x04fed514) /* 0.312214927 */, 19 },
+ /* 8139 */ { MAD_F(0x04ff0ab8) /* 0.312266082 */, 19 },
+ /* 8140 */ { MAD_F(0x04ff405c) /* 0.312317238 */, 19 },
+ /* 8141 */ { MAD_F(0x04ff7601) /* 0.312368397 */, 19 },
+ /* 8142 */ { MAD_F(0x04ffaba6) /* 0.312419558 */, 19 },
+ /* 8143 */ { MAD_F(0x04ffe14c) /* 0.312470720 */, 19 },
+
+ /* 8144 */ { MAD_F(0x050016f3) /* 0.312521885 */, 19 },
+ /* 8145 */ { MAD_F(0x05004c9a) /* 0.312573052 */, 19 },
+ /* 8146 */ { MAD_F(0x05008241) /* 0.312624222 */, 19 },
+ /* 8147 */ { MAD_F(0x0500b7e9) /* 0.312675393 */, 19 },
+ /* 8148 */ { MAD_F(0x0500ed92) /* 0.312726566 */, 19 },
+ /* 8149 */ { MAD_F(0x0501233b) /* 0.312777742 */, 19 },
+ /* 8150 */ { MAD_F(0x050158e5) /* 0.312828919 */, 19 },
+ /* 8151 */ { MAD_F(0x05018e90) /* 0.312880099 */, 19 },
+ /* 8152 */ { MAD_F(0x0501c43b) /* 0.312931280 */, 19 },
+ /* 8153 */ { MAD_F(0x0501f9e6) /* 0.312982464 */, 19 },
+ /* 8154 */ { MAD_F(0x05022f92) /* 0.313033650 */, 19 },
+ /* 8155 */ { MAD_F(0x0502653f) /* 0.313084838 */, 19 },
+ /* 8156 */ { MAD_F(0x05029aec) /* 0.313136028 */, 19 },
+ /* 8157 */ { MAD_F(0x0502d09a) /* 0.313187220 */, 19 },
+ /* 8158 */ { MAD_F(0x05030648) /* 0.313238414 */, 19 },
+ /* 8159 */ { MAD_F(0x05033bf7) /* 0.313289611 */, 19 },
+
+ /* 8160 */ { MAD_F(0x050371a7) /* 0.313340809 */, 19 },
+ /* 8161 */ { MAD_F(0x0503a757) /* 0.313392010 */, 19 },
+ /* 8162 */ { MAD_F(0x0503dd07) /* 0.313443212 */, 19 },
+ /* 8163 */ { MAD_F(0x050412b9) /* 0.313494417 */, 19 },
+ /* 8164 */ { MAD_F(0x0504486a) /* 0.313545624 */, 19 },
+ /* 8165 */ { MAD_F(0x05047e1d) /* 0.313596833 */, 19 },
+ /* 8166 */ { MAD_F(0x0504b3cf) /* 0.313648044 */, 19 },
+ /* 8167 */ { MAD_F(0x0504e983) /* 0.313699257 */, 19 },
+ /* 8168 */ { MAD_F(0x05051f37) /* 0.313750472 */, 19 },
+ /* 8169 */ { MAD_F(0x050554eb) /* 0.313801689 */, 19 },
+ /* 8170 */ { MAD_F(0x05058aa0) /* 0.313852909 */, 19 },
+ /* 8171 */ { MAD_F(0x0505c056) /* 0.313904130 */, 19 },
+ /* 8172 */ { MAD_F(0x0505f60c) /* 0.313955354 */, 19 },
+ /* 8173 */ { MAD_F(0x05062bc3) /* 0.314006579 */, 19 },
+ /* 8174 */ { MAD_F(0x0506617a) /* 0.314057807 */, 19 },
+ /* 8175 */ { MAD_F(0x05069732) /* 0.314109037 */, 19 },
+
+ /* 8176 */ { MAD_F(0x0506cceb) /* 0.314160269 */, 19 },
+ /* 8177 */ { MAD_F(0x050702a4) /* 0.314211502 */, 19 },
+ /* 8178 */ { MAD_F(0x0507385d) /* 0.314262739 */, 19 },
+ /* 8179 */ { MAD_F(0x05076e17) /* 0.314313977 */, 19 },
+ /* 8180 */ { MAD_F(0x0507a3d2) /* 0.314365217 */, 19 },
+ /* 8181 */ { MAD_F(0x0507d98d) /* 0.314416459 */, 19 },
+ /* 8182 */ { MAD_F(0x05080f49) /* 0.314467704 */, 19 },
+ /* 8183 */ { MAD_F(0x05084506) /* 0.314518950 */, 19 },
+ /* 8184 */ { MAD_F(0x05087ac2) /* 0.314570199 */, 19 },
+ /* 8185 */ { MAD_F(0x0508b080) /* 0.314621449 */, 19 },
+ /* 8186 */ { MAD_F(0x0508e63e) /* 0.314672702 */, 19 },
+ /* 8187 */ { MAD_F(0x05091bfd) /* 0.314723957 */, 19 },
+ /* 8188 */ { MAD_F(0x050951bc) /* 0.314775214 */, 19 },
+ /* 8189 */ { MAD_F(0x0509877c) /* 0.314826473 */, 19 },
+ /* 8190 */ { MAD_F(0x0509bd3c) /* 0.314877734 */, 19 },
+ /* 8191 */ { MAD_F(0x0509f2fd) /* 0.314928997 */, 19 },
+
+ /* 8192 */ { MAD_F(0x050a28be) /* 0.314980262 */, 19 },
+ /* 8193 */ { MAD_F(0x050a5e80) /* 0.315031530 */, 19 },
+ /* 8194 */ { MAD_F(0x050a9443) /* 0.315082799 */, 19 },
+ /* 8195 */ { MAD_F(0x050aca06) /* 0.315134071 */, 19 },
+ /* 8196 */ { MAD_F(0x050affc9) /* 0.315185344 */, 19 },
+ /* 8197 */ { MAD_F(0x050b358e) /* 0.315236620 */, 19 },
+ /* 8198 */ { MAD_F(0x050b6b52) /* 0.315287898 */, 19 },
+ /* 8199 */ { MAD_F(0x050ba118) /* 0.315339178 */, 19 },
+ /* 8200 */ { MAD_F(0x050bd6de) /* 0.315390460 */, 19 },
+ /* 8201 */ { MAD_F(0x050c0ca4) /* 0.315441744 */, 19 },
+ /* 8202 */ { MAD_F(0x050c426b) /* 0.315493030 */, 19 },
+ /* 8203 */ { MAD_F(0x050c7833) /* 0.315544318 */, 19 },
+ /* 8204 */ { MAD_F(0x050cadfb) /* 0.315595608 */, 19 },
+ /* 8205 */ { MAD_F(0x050ce3c4) /* 0.315646901 */, 19 },
+ /* 8206 */ { MAD_F(0x050d198d) /* 0.315698195 */, 19 }
diff --git a/audio_codec/libmad/sf_table.dat b/audio_codec/libmad/sf_table.dat
new file mode 100755
index 0000000..db1484a
--- a/dev/null
+++ b/audio_codec/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: sf_table.dat,v 1.7 2004/01/23 09:41:33 rob Exp $
+ */
+
+/*
+ * 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/audio_codec/libmad/stream.c b/audio_codec/libmad/stream.c
new file mode 100644
index 0000000..fea06da
--- a/dev/null
+++ b/audio_codec/libmad/stream.c
@@ -0,0 +1,185 @@
+/*
+ * 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: stream.c,v 1.12 2004/02/05 09:02:39 rob Exp $
+ */
+
+# ifdef HAVE_CONFIG_H
+# include "config.h"
+# endif
+
+# include "global.h"
+
+# include <stdlib.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;
+ 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;
+
+ 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
+ */
+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
+ */
+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/audio_codec/libmad/stream.h b/audio_codec/libmad/stream.h
new file mode 100644
index 0000000..da6744d
--- a/dev/null
+++ b/audio_codec/libmad/stream.h
@@ -0,0 +1,111 @@
+/*
+ * 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: stream.h,v 1.20 2004/02/05 09:02:39 rob Exp $
+ */
+
+# 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 */
+ 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];
+ /* 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) */
+
+ unsigned int muted_samples;
+ unsigned int muted_count;
+};
+
+enum {
+ MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */
+ MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */
+# 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 *);
+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);
+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/audio_codec/libmad/synth.c b/audio_codec/libmad/synth.c
new file mode 100644
index 0000000..844af99
--- a/dev/null
+++ b/audio_codec/libmad/synth.c
@@ -0,0 +1,921 @@
+/*
+ * 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: synth.c,v 1.25 2004/01/23 09:41:33 rob Exp $
+ */
+
+# 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;
+}
+
+/*
+ * NAME: synth->mute()
+ * DESCRIPTION: zero all polyphase filterbank values, resetting synthesis
+ */
+void mad_synth_mute(struct mad_synth *synth)
+{
+ unsigned int ch, s, v;
+
+ for (ch = 0; ch < 2; ++ch) {
+ for (s = 0; s < 16; ++s) {
+ for (v = 0; v < 8; ++v) {
+ synth->filter[ch][0][0][s][v] = synth->filter[ch][0][1][s][v] =
+ synth->filter[ch][1][0][s][v] = synth->filter[ch][1][1][s][v] = 0;
+ }
+ }
+ }
+}
+
+/*
+ * 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 lose accuracy and performance */
+
+# 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(OPT_SPEED) && defined(MAD_F_MLX)
+# define OPT_DCTO
+# 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
+# undef OPT_DCTO
+# define MUL(x, y) mad_f_mul((x), (y))
+# 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) */
+
+# if defined(OPT_DCTO)
+# define costab1 MAD_F(0x7fd8878e)
+# define costab2 MAD_F(0x7f62368f)
+# define costab3 MAD_F(0x7e9d55fc)
+# define costab4 MAD_F(0x7d8a5f40)
+# define costab5 MAD_F(0x7c29fbee)
+# define costab6 MAD_F(0x7a7d055b)
+# define costab7 MAD_F(0x78848414)
+# define costab8 MAD_F(0x7641af3d)
+# define costab9 MAD_F(0x73b5ebd1)
+# define costab10 MAD_F(0x70e2cbc6)
+# define costab11 MAD_F(0x6dca0d14)
+# define costab12 MAD_F(0x6a6d98a4)
+# define costab13 MAD_F(0x66cf8120)
+# define costab14 MAD_F(0x62f201ac)
+# define costab15 MAD_F(0x5ed77c8a)
+# define costab16 MAD_F(0x5a82799a)
+# define costab17 MAD_F(0x55f5a4d2)
+# define costab18 MAD_F(0x5133cc94)
+# define costab19 MAD_F(0x4c3fdff4)
+# define costab20 MAD_F(0x471cece7)
+# define costab21 MAD_F(0x41ce1e65)
+# define costab22 MAD_F(0x3c56ba70)
+# define costab23 MAD_F(0x36ba2014)
+# define costab24 MAD_F(0x30fbc54d)
+# define costab25 MAD_F(0x2b1f34eb)
+# define costab26 MAD_F(0x25280c5e)
+# define costab27 MAD_F(0x1f19f97b)
+# define costab28 MAD_F(0x18f8b83c)
+# define costab29 MAD_F(0x12c8106f)
+# define costab30 MAD_F(0x0c8bd35e)
+# define costab31 MAD_F(0x0647d97c)
+# else
+# define costab1 MAD_F(0x0ffb10f2) /* 0.998795456 */
+# define costab2 MAD_F(0x0fec46d2) /* 0.995184727 */
+# define costab3 MAD_F(0x0fd3aac0) /* 0.989176510 */
+# define costab4 MAD_F(0x0fb14be8) /* 0.980785280 */
+# define costab5 MAD_F(0x0f853f7e) /* 0.970031253 */
+# define costab6 MAD_F(0x0f4fa0ab) /* 0.956940336 */
+# define costab7 MAD_F(0x0f109082) /* 0.941544065 */
+# define costab8 MAD_F(0x0ec835e8) /* 0.923879533 */
+# define costab9 MAD_F(0x0e76bd7a) /* 0.903989293 */
+# define costab10 MAD_F(0x0e1c5979) /* 0.881921264 */
+# define costab11 MAD_F(0x0db941a3) /* 0.857728610 */
+# define costab12 MAD_F(0x0d4db315) /* 0.831469612 */
+# define costab13 MAD_F(0x0cd9f024) /* 0.803207531 */
+# define costab14 MAD_F(0x0c5e4036) /* 0.773010453 */
+# define costab15 MAD_F(0x0bdaef91) /* 0.740951125 */
+# define costab16 MAD_F(0x0b504f33) /* 0.707106781 */
+# define costab17 MAD_F(0x0abeb49a) /* 0.671558955 */
+# define costab18 MAD_F(0x0a267993) /* 0.634393284 */
+# define costab19 MAD_F(0x0987fbfe) /* 0.595699304 */
+# define costab20 MAD_F(0x08e39d9d) /* 0.555570233 */
+# define costab21 MAD_F(0x0839c3cd) /* 0.514102744 */
+# define costab22 MAD_F(0x078ad74e) /* 0.471396737 */
+# define costab23 MAD_F(0x06d74402) /* 0.427555093 */
+# define costab24 MAD_F(0x061f78aa) /* 0.382683432 */
+# define costab25 MAD_F(0x0563e69d) /* 0.336889853 */
+# define costab26 MAD_F(0x04a5018c) /* 0.290284677 */
+# define costab27 MAD_F(0x03e33f2f) /* 0.242980180 */
+# define costab28 MAD_F(0x031f1708) /* 0.195090322 */
+# define costab29 MAD_F(0x0259020e) /* 0.146730474 */
+# define costab30 MAD_F(0x01917a6c) /* 0.098017140 */
+# define costab31 MAD_F(0x00c8fb30) /* 0.049067674 */
+# endif
+
+ 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
+
+/* 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] = {
+# include "D.dat"
+};
+
+# if defined(ASO_SYNTH)
+void synth_full(struct mad_synth *, struct mad_frame const *,
+ unsigned int, unsigned int);
+# else
+/*
+ * NAME: synth->full()
+ * DESCRIPTION: perform full frequency PCM synthesis
+ */
+static
+void synth_full(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 const(*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[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 32 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 + 30;
+
+ for (sb = 1; sb < 16; ++sb) {
+ ++fe;
+ ++Dptr;
+
+ /* D[32 - sb][i] == -D[sb][31 - i] */
+
+ 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 - pe;
+ ML0(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]);
+
+ ptr = *Dptr - po;
+ MLA(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]);
+
+ *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 += 16;
+
+ phase = (phase + 1) % 16;
+ }
+ }
+}
+# endif
+
+/*
+ * 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 const(*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[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;
+ }
+ }
+}
+
+/*
+ * 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;
+ void (*synth_frame)(struct mad_synth *, struct mad_frame const *,
+ unsigned int, unsigned int);
+
+ 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;
+
+ 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);
+
+ synth->phase = (synth->phase + ns) % 16;
+}
diff --git a/audio_codec/libmad/synth.h b/audio_codec/libmad/synth.h
new file mode 100644
index 0000000..fbeaf72
--- a/dev/null
+++ b/audio_codec/libmad/synth.h
@@ -0,0 +1,69 @@
+/*
+ * 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: synth.h,v 1.15 2004/01/23 09:41:33 rob Exp $
+ */
+
+# 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]; /* PCM output samples [ch][sample] */
+};
+
+struct mad_synth {
+ mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */
+ /* [ch][eo][peo][s][v] */
+
+ unsigned int phase; /* current processing phase */
+
+ struct mad_pcm pcm; /* PCM output */
+};
+
+/* single channel PCM selector */
+enum {
+ MAD_PCM_CHANNEL_SINGLE = 0
+};
+
+/* dual channel PCM selector */
+enum {
+ MAD_PCM_CHANNEL_DUAL_1 = 0,
+ MAD_PCM_CHANNEL_DUAL_2 = 1
+};
+
+/* stereo PCM selector */
+enum {
+ MAD_PCM_CHANNEL_STEREO_LEFT = 0,
+ MAD_PCM_CHANNEL_STEREO_RIGHT = 1
+};
+
+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/audio_codec/libmad/timer.c b/audio_codec/libmad/timer.c
new file mode 100644
index 0000000..ea80706
--- a/dev/null
+++ b/audio_codec/libmad/timer.c
@@ -0,0 +1,493 @@
+/*
+ * 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: timer.c,v 1.18 2004/01/23 09:41:33 rob Exp $
+ */
+
+# ifdef HAVE_CONFIG_H
+# include "config.h"
+# endif
+
+# include "global.h"
+
+# include <stdio.h>
+
+# ifdef HAVE_ASSERT_H
+# include <assert.h>
+# endif
+
+# include "timer.h"
+
+mad_timer_t const mad_timer_zero = { 0, 0 };
+
+/*
+ * NAME: timer->compare()
+ * DESCRIPTION: indicate relative order of two timers
+ */
+int mad_timer_compare(mad_timer_t timer1, mad_timer_t timer2)
+{
+ signed long diff;
+
+ diff = timer1.seconds - timer2.seconds;
+ if (diff < 0) {
+ return -1;
+ } else if (diff > 0) {
+ return +1;
+ }
+
+ diff = timer1.fraction - timer2.fraction;
+ if (diff < 0) {
+ return -1;
+ } else if (diff > 0) {
+ return +1;
+ }
+
+ return 0;
+}
+
+/*
+ * NAME: timer->negate()
+ * DESCRIPTION: invert the sign of a timer
+ */
+void mad_timer_negate(mad_timer_t *timer)
+{
+ timer->seconds = -timer->seconds;
+
+ if (timer->fraction) {
+ timer->seconds -= 1;
+ timer->fraction = MAD_TIMER_RESOLUTION - timer->fraction;
+ }
+}
+
+/*
+ * NAME: timer->abs()
+ * DESCRIPTION: return the absolute value of a timer
+ */
+mad_timer_t mad_timer_abs(mad_timer_t timer)
+{
+ if (timer.seconds < 0) {
+ mad_timer_negate(&timer);
+ }
+
+ return timer;
+}
+
+/*
+ * NAME: reduce_timer()
+ * DESCRIPTION: carry timer fraction into seconds
+ */
+static
+void reduce_timer(mad_timer_t *timer)
+{
+ timer->seconds += timer->fraction / MAD_TIMER_RESOLUTION;
+ timer->fraction %= MAD_TIMER_RESOLUTION;
+}
+
+/*
+ * NAME: gcd()
+ * DESCRIPTION: compute greatest common denominator
+ */
+static
+unsigned long gcd(unsigned long num1, unsigned long num2)
+{
+ unsigned long tmp;
+
+ while (num2) {
+ tmp = num2;
+ num2 = num1 % num2;
+ num1 = tmp;
+ }
+
+ return num1;
+}
+
+/*
+ * NAME: reduce_rational()
+ * DESCRIPTION: convert rational expression to lowest terms
+ */
+static
+void reduce_rational(unsigned long *numer, unsigned long *denom)
+{
+ unsigned long factor;
+
+ factor = gcd(*numer, *denom);
+
+ assert(factor != 0);
+
+ *numer /= factor;
+ *denom /= factor;
+}
+
+/*
+ * NAME: scale_rational()
+ * DESCRIPTION: solve numer/denom == ?/scale avoiding overflowing
+ */
+static
+unsigned long scale_rational(unsigned long numer, unsigned long denom,
+ unsigned long scale)
+{
+ reduce_rational(&numer, &denom);
+ reduce_rational(&scale, &denom);
+
+ assert(denom != 0);
+
+ if (denom < scale) {
+ return numer * (scale / denom) + numer * (scale % denom) / denom;
+ }
+ if (denom < numer) {
+ return scale * (numer / denom) + scale * (numer % denom) / denom;
+ }
+
+ return numer * scale / denom;
+}
+
+/*
+ * NAME: timer->set()
+ * DESCRIPTION: set timer to specific (positive) value
+ */
+void mad_timer_set(mad_timer_t *timer, unsigned long seconds,
+ unsigned long numer, unsigned long denom)
+{
+ timer->seconds = seconds;
+ if (numer >= denom && denom > 0) {
+ timer->seconds += numer / denom;
+ numer %= denom;
+ }
+
+ switch (denom) {
+ case 0:
+ case 1:
+ timer->fraction = 0;
+ break;
+
+ case MAD_TIMER_RESOLUTION:
+ timer->fraction = numer;
+ break;
+
+ case 1000:
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 1000);
+ break;
+
+ case 8000:
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 8000);
+ break;
+
+ case 11025:
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 11025);
+ break;
+
+ case 12000:
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 12000);
+ break;
+
+ case 16000:
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 16000);
+ break;
+
+ case 22050:
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 22050);
+ break;
+
+ case 24000:
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 24000);
+ break;
+
+ case 32000:
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 32000);
+ break;
+
+ case 44100:
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 44100);
+ break;
+
+ case 48000:
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 48000);
+ break;
+
+ default:
+ timer->fraction = scale_rational(numer, denom, MAD_TIMER_RESOLUTION);
+ break;
+ }
+
+ if (timer->fraction >= MAD_TIMER_RESOLUTION) {
+ reduce_timer(timer);
+ }
+}
+
+/*
+ * NAME: timer->add()
+ * DESCRIPTION: add one timer to another
+ */
+void mad_timer_add(mad_timer_t *timer, mad_timer_t incr)
+{
+ timer->seconds += incr.seconds;
+ timer->fraction += incr.fraction;
+
+ if (timer->fraction >= MAD_TIMER_RESOLUTION) {
+ reduce_timer(timer);
+ }
+}
+
+/*
+ * NAME: timer->multiply()
+ * DESCRIPTION: multiply a timer by a scalar value
+ */
+void mad_timer_multiply(mad_timer_t *timer, signed long scalar)
+{
+ mad_timer_t addend;
+ unsigned long factor;
+
+ factor = scalar;
+ if (scalar < 0) {
+ factor = -scalar;
+ mad_timer_negate(timer);
+ }
+
+ addend = *timer;
+ *timer = mad_timer_zero;
+
+ while (factor) {
+ if (factor & 1) {
+ mad_timer_add(timer, addend);
+ }
+
+ mad_timer_add(&addend, addend);
+ factor >>= 1;
+ }
+}
+
+/*
+ * NAME: timer->count()
+ * DESCRIPTION: return timer value in selected units
+ */
+signed long mad_timer_count(mad_timer_t timer, enum mad_units units)
+{
+ switch (units) {
+ case MAD_UNITS_HOURS:
+ return timer.seconds / 60 / 60;
+
+ case MAD_UNITS_MINUTES:
+ return timer.seconds / 60;
+
+ case MAD_UNITS_SECONDS:
+ return timer.seconds;
+
+ case MAD_UNITS_DECISECONDS:
+ case MAD_UNITS_CENTISECONDS:
+ case MAD_UNITS_MILLISECONDS:
+
+ case MAD_UNITS_8000_HZ:
+ case MAD_UNITS_11025_HZ:
+ case MAD_UNITS_12000_HZ:
+ case MAD_UNITS_16000_HZ:
+ case MAD_UNITS_22050_HZ:
+ case MAD_UNITS_24000_HZ:
+ case MAD_UNITS_32000_HZ:
+ case MAD_UNITS_44100_HZ:
+ case MAD_UNITS_48000_HZ:
+
+ case MAD_UNITS_24_FPS:
+ case MAD_UNITS_25_FPS:
+ case MAD_UNITS_30_FPS:
+ case MAD_UNITS_48_FPS:
+ case MAD_UNITS_50_FPS:
+ case MAD_UNITS_60_FPS:
+ case MAD_UNITS_75_FPS:
+ return timer.seconds * (signed long) units +
+ (signed long) scale_rational(timer.fraction, MAD_TIMER_RESOLUTION,
+ units);
+
+ case MAD_UNITS_23_976_FPS:
+ case MAD_UNITS_24_975_FPS:
+ case MAD_UNITS_29_97_FPS:
+ case MAD_UNITS_47_952_FPS:
+ case MAD_UNITS_49_95_FPS:
+ case MAD_UNITS_59_94_FPS:
+ return (mad_timer_count(timer, -units) + 1) * 1000 / 1001;
+ }
+
+ /* unsupported units */
+ return 0;
+}
+
+/*
+ * NAME: timer->fraction()
+ * DESCRIPTION: return fractional part of timer in arbitrary terms
+ */
+unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long denom)
+{
+ timer = mad_timer_abs(timer);
+
+ switch (denom) {
+ case 0:
+ return timer.fraction ?
+ MAD_TIMER_RESOLUTION / timer.fraction : MAD_TIMER_RESOLUTION + 1;
+
+ case MAD_TIMER_RESOLUTION:
+ return timer.fraction;
+
+ default:
+ return scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, denom);
+ }
+}
+
+/*
+ * NAME: timer->string()
+ * DESCRIPTION: write a string representation of a timer using a template
+ */
+void mad_timer_string(mad_timer_t timer,
+ char *dest, char const *format, enum mad_units units,
+ enum mad_units fracunits, unsigned long subparts)
+{
+ unsigned long hours, minutes, seconds, sub;
+ unsigned int frac;
+
+ timer = mad_timer_abs(timer);
+
+ seconds = timer.seconds;
+ frac = sub = 0;
+
+ switch (fracunits) {
+ case MAD_UNITS_HOURS:
+ case MAD_UNITS_MINUTES:
+ case MAD_UNITS_SECONDS:
+ break;
+
+ case MAD_UNITS_DECISECONDS:
+ case MAD_UNITS_CENTISECONDS:
+ case MAD_UNITS_MILLISECONDS:
+
+ case MAD_UNITS_8000_HZ:
+ case MAD_UNITS_11025_HZ:
+ case MAD_UNITS_12000_HZ:
+ case MAD_UNITS_16000_HZ:
+ case MAD_UNITS_22050_HZ:
+ case MAD_UNITS_24000_HZ:
+ case MAD_UNITS_32000_HZ:
+ case MAD_UNITS_44100_HZ:
+ case MAD_UNITS_48000_HZ:
+
+ case MAD_UNITS_24_FPS:
+ case MAD_UNITS_25_FPS:
+ case MAD_UNITS_30_FPS:
+ case MAD_UNITS_48_FPS:
+ case MAD_UNITS_50_FPS:
+ case MAD_UNITS_60_FPS:
+ case MAD_UNITS_75_FPS: {
+ unsigned long denom;
+
+ denom = MAD_TIMER_RESOLUTION / fracunits;
+
+ frac = timer.fraction / denom;
+ sub = scale_rational(timer.fraction % denom, denom, subparts);
+ }
+ break;
+
+ case MAD_UNITS_23_976_FPS:
+ case MAD_UNITS_24_975_FPS:
+ case MAD_UNITS_29_97_FPS:
+ case MAD_UNITS_47_952_FPS:
+ case MAD_UNITS_49_95_FPS:
+ case MAD_UNITS_59_94_FPS:
+ /* drop-frame encoding */
+ /* N.B. this is only well-defined for MAD_UNITS_29_97_FPS */
+ {
+ unsigned long frame, cycle, d, m;
+
+ frame = mad_timer_count(timer, fracunits);
+
+ cycle = -fracunits * 60 * 10 - (10 - 1) * 2;
+
+ d = frame / cycle;
+ m = frame % cycle;
+ frame += (10 - 1) * 2 * d;
+ if (m > 2) {
+ frame += 2 * ((m - 2) / (cycle / 10));
+ }
+
+ frac = frame % -fracunits;
+ seconds = frame / -fracunits;
+ }
+ break;
+ }
+
+ switch (units) {
+ case MAD_UNITS_HOURS:
+ minutes = seconds / 60;
+ hours = minutes / 60;
+
+ sprintf(dest, format,
+ hours,
+ (unsigned int)(minutes % 60),
+ (unsigned int)(seconds % 60),
+ frac, sub);
+ break;
+
+ case MAD_UNITS_MINUTES:
+ minutes = seconds / 60;
+
+ sprintf(dest, format,
+ minutes,
+ (unsigned int)(seconds % 60),
+ frac, sub);
+ break;
+
+ case MAD_UNITS_SECONDS:
+ sprintf(dest, format,
+ seconds,
+ frac, sub);
+ break;
+
+ case MAD_UNITS_23_976_FPS:
+ case MAD_UNITS_24_975_FPS:
+ case MAD_UNITS_29_97_FPS:
+ case MAD_UNITS_47_952_FPS:
+ case MAD_UNITS_49_95_FPS:
+ case MAD_UNITS_59_94_FPS:
+ if (fracunits < 0) {
+ /* not yet implemented */
+ sub = 0;
+ }
+
+ /* fall through */
+
+ case MAD_UNITS_DECISECONDS:
+ case MAD_UNITS_CENTISECONDS:
+ case MAD_UNITS_MILLISECONDS:
+
+ case MAD_UNITS_8000_HZ:
+ case MAD_UNITS_11025_HZ:
+ case MAD_UNITS_12000_HZ:
+ case MAD_UNITS_16000_HZ:
+ case MAD_UNITS_22050_HZ:
+ case MAD_UNITS_24000_HZ:
+ case MAD_UNITS_32000_HZ:
+ case MAD_UNITS_44100_HZ:
+ case MAD_UNITS_48000_HZ:
+
+ case MAD_UNITS_24_FPS:
+ case MAD_UNITS_25_FPS:
+ case MAD_UNITS_30_FPS:
+ case MAD_UNITS_48_FPS:
+ case MAD_UNITS_50_FPS:
+ case MAD_UNITS_60_FPS:
+ case MAD_UNITS_75_FPS:
+ sprintf(dest, format, mad_timer_count(timer, units), sub);
+ break;
+ }
+}
diff --git a/audio_codec/libmad/timer.h b/audio_codec/libmad/timer.h
new file mode 100644
index 0000000..39f8531
--- a/dev/null
+++ b/audio_codec/libmad/timer.h
@@ -0,0 +1,100 @@
+/*
+ * 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: timer.h,v 1.16 2004/01/23 09:41:33 rob Exp $
+ */
+
+# ifndef LIBMAD_TIMER_H
+# define LIBMAD_TIMER_H
+
+typedef struct {
+ signed long seconds; /* whole seconds */
+ unsigned long fraction; /* 1/MAD_TIMER_RESOLUTION seconds */
+} mad_timer_t;
+
+extern mad_timer_t const mad_timer_zero;
+
+# define MAD_TIMER_RESOLUTION 352800000UL
+
+enum mad_units {
+ MAD_UNITS_HOURS = -2,
+ MAD_UNITS_MINUTES = -1,
+ MAD_UNITS_SECONDS = 0,
+
+ /* metric units */
+
+ MAD_UNITS_DECISECONDS = 10,
+ MAD_UNITS_CENTISECONDS = 100,
+ MAD_UNITS_MILLISECONDS = 1000,
+
+ /* audio sample units */
+
+ MAD_UNITS_8000_HZ = 8000,
+ MAD_UNITS_11025_HZ = 11025,
+ MAD_UNITS_12000_HZ = 12000,
+
+ MAD_UNITS_16000_HZ = 16000,
+ MAD_UNITS_22050_HZ = 22050,
+ MAD_UNITS_24000_HZ = 24000,
+
+ MAD_UNITS_32000_HZ = 32000,
+ MAD_UNITS_44100_HZ = 44100,
+ MAD_UNITS_48000_HZ = 48000,
+
+ /* video frame/field units */
+
+ MAD_UNITS_24_FPS = 24,
+ MAD_UNITS_25_FPS = 25,
+ MAD_UNITS_30_FPS = 30,
+ MAD_UNITS_48_FPS = 48,
+ MAD_UNITS_50_FPS = 50,
+ MAD_UNITS_60_FPS = 60,
+
+ /* CD audio frames */
+
+ MAD_UNITS_75_FPS = 75,
+
+ /* video drop-frame units */
+
+ MAD_UNITS_23_976_FPS = -24,
+ MAD_UNITS_24_975_FPS = -25,
+ MAD_UNITS_29_97_FPS = -30,
+ MAD_UNITS_47_952_FPS = -48,
+ MAD_UNITS_49_95_FPS = -50,
+ MAD_UNITS_59_94_FPS = -60
+};
+
+# define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero))
+
+int mad_timer_compare(mad_timer_t, mad_timer_t);
+
+# define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero)
+
+void mad_timer_negate(mad_timer_t *);
+mad_timer_t mad_timer_abs(mad_timer_t);
+
+void mad_timer_set(mad_timer_t *, unsigned long, unsigned long, unsigned long);
+void mad_timer_add(mad_timer_t *, mad_timer_t);
+void mad_timer_multiply(mad_timer_t *, signed long);
+
+signed long mad_timer_count(mad_timer_t, enum mad_units);
+unsigned long mad_timer_fraction(mad_timer_t, unsigned long);
+void mad_timer_string(mad_timer_t, char *, char const *,
+ enum mad_units, enum mad_units, unsigned long);
+
+# endif
diff --git a/audio_codec/libmad/version.c b/audio_codec/libmad/version.c
new file mode 100644
index 0000000..7fa2f51
--- a/dev/null
+++ b/audio_codec/libmad/version.c
@@ -0,0 +1,91 @@
+/*
+ * 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: version.c,v 1.15 2004/01/23 09:41:33 rob Exp $
+ */
+
+# ifdef HAVE_CONFIG_H
+# include "config.h"
+# endif
+
+# include "global.h"
+
+# include "version.h"
+
+char const mad_version[] = "MPEG Audio Decoder " MAD_VERSION;
+char const mad_copyright[] = "Copyright (C) " MAD_PUBLISHYEAR " " MAD_AUTHOR;
+char const mad_author[] = MAD_AUTHOR " <" MAD_EMAIL ">";
+
+char const mad_build[] = ""
+# if defined(DEBUG)
+ "DEBUG "
+# elif defined(NDEBUG)
+ "NDEBUG "
+# endif
+
+# if defined(EXPERIMENTAL)
+ "EXPERIMENTAL "
+# endif
+
+# if defined(FPM_64BIT)
+ "FPM_64BIT "
+# elif defined(FPM_INTEL)
+ "FPM_INTEL "
+# elif defined(FPM_ARM)
+ "FPM_ARM "
+# elif defined(FPM_MIPS)
+ "FPM_MIPS "
+# elif defined(FPM_SPARC)
+ "FPM_SPARC "
+# elif defined(FPM_PPC)
+ "FPM_PPC "
+# elif defined(FPM_DEFAULT)
+ "FPM_DEFAULT "
+# endif
+
+# if defined(ASO_IMDCT)
+ "ASO_IMDCT "
+# endif
+# if defined(ASO_INTERLEAVE1)
+ "ASO_INTERLEAVE1 "
+# endif
+# if defined(ASO_INTERLEAVE2)
+ "ASO_INTERLEAVE2 "
+# endif
+# if defined(ASO_ZEROCHECK)
+ "ASO_ZEROCHECK "
+# endif
+
+# if defined(OPT_SPEED)
+ "OPT_SPEED "
+# elif defined(OPT_ACCURACY)
+ "OPT_ACCURACY "
+# endif
+
+# if defined(OPT_SSO)
+ "OPT_SSO "
+# endif
+
+# if defined(OPT_DCTO) /* never defined here */
+ "OPT_DCTO "
+# endif
+
+# if defined(OPT_STRICT)
+ "OPT_STRICT "
+# endif
+ ;
diff --git a/audio_codec/libmad/version.h b/audio_codec/libmad/version.h
new file mode 100644
index 0000000..8af6c89
--- a/dev/null
+++ b/audio_codec/libmad/version.h
@@ -0,0 +1,47 @@
+/*
+ * 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: version.h,v 1.26 2004/01/23 09:41:33 rob Exp $
+ */
+
+# ifndef LIBMAD_VERSION_H
+# define LIBMAD_VERSION_H
+
+# define MAD_VERSION_MAJOR 0
+# define MAD_VERSION_MINOR 15
+# define MAD_VERSION_PATCH 1
+# define MAD_VERSION_EXTRA " (beta)"
+
+# define MAD_VERSION_STRINGIZE(str) #str
+# define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num)
+
+# define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \
+ MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \
+ MAD_VERSION_STRING(MAD_VERSION_PATCH) \
+ MAD_VERSION_EXTRA
+
+# define MAD_PUBLISHYEAR "2000-2004"
+# define MAD_AUTHOR "Underbit Technologies, Inc."
+# define MAD_EMAIL "info@underbit.com"
+
+extern char const mad_version[];
+extern char const mad_copyright[];
+extern char const mad_author[];
+extern char const mad_build[];
+
+# endif
diff --git a/audio_codec/libpcm/Android.mk b/audio_codec/libpcm/Android.mk
new file mode 100755
index 0000000..80feb9a
--- a/dev/null
+++ b/audio_codec/libpcm/Android.mk
@@ -0,0 +1,11 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SHARED_LIBRARIES += libutils libmedia libz libbinder libdl libcutils libc
+LOCAL_MODULE := libpcm
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+LOCAL_ARM_MODE := arm
+LOCAL_MODULE_TAGS := optional
+include $(LOCAL_PATH)/../config.mk
+include $(BUILD_SHARED_LIBRARY)
diff --git a/audio_codec/libpcm/intreadwrite.h b/audio_codec/libpcm/intreadwrite.h
new file mode 100644
index 0000000..0954b10
--- a/dev/null
+++ b/audio_codec/libpcm/intreadwrite.h
@@ -0,0 +1,390 @@
+/*
+ * 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
+#ifndef __MW__
+#include <stdint.h>
+#endif
+//#include "bswap.h"
+
+/*
+ * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers.
+ */
+
+#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 AV_[RW]N helper macros to simplify definitions not provided
+ * by per-arch headers.
+ */
+
+#if HAVE_ATTRIBUTE_PACKED
+
+struct unaligned_64 {
+ uint64_t l;
+} __attribute__((packed));
+struct unaligned_32 {
+ uint32_t l;
+} __attribute__((packed));
+struct unaligned_16 {
+ uint16_t l;
+} __attribute__((packed));
+
+# define AV_RN(s, p) (((const struct unaligned_##s *) (p))->l)
+# define AV_WN(s, p, v) (((struct 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 uint##s##_t*)(p)))
+# define AV_WN(s, p, v) *((uint##s##_t*)(p)) = (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 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
+
+#endif /* AVUTIL_INTREADWRITE_H */
diff --git a/audio_codec/libpcm/pcm_decode.c b/audio_codec/libpcm/pcm_decode.c
new file mode 100644
index 0000000..af6b0b9
--- a/dev/null
+++ b/audio_codec/libpcm/pcm_decode.c
@@ -0,0 +1,780 @@
+#include <stdio.h>
+#include <intreadwrite.h>
+#include "adec-armdec-mgt.h"
+#include "audio-dec.h"
+#include "amports/aformat.h"
+#include <android/log.h>
+#include <sys/time.h>
+#include <stdint.h>
+
+#define LOG_TAG "PcmDecoder"
+#define PRINTF(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+/* 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.
+/* 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)
+
+#define CHECK_BLUERAY_PCM_HEADER
+#define pcm_buffer_size (1024*6)
+#define bluray_pcm_size (1024*17)
+#define LOCAL inline
+#define SIGN_BIT (0x80)
+#define QUANT_MASK (0xf)
+#define NSEGS (8)
+#define SEG_SHIFT (4)
+#define SEG_MASK (0x70)
+#define BIAS (0x84)
+static short table[256];
+
+typedef struct {
+ int ValidDataLen;
+ int UsedDataLen;
+ unsigned char *BufStart;
+ unsigned char *pcur;
+} pcm_read_ctl_t;
+
+typedef struct {
+ int pcm_channels;
+ int pcm_samplerate;
+ int bit_per_sample;
+ int jump_read_head_flag;
+ int frame_size_check;
+ int frame_size_check_flag;
+ int pcm_bluray_header;
+ int pcm_bluray_size;
+ unsigned char *pcm_buffer;
+ int lpcm_header_parsed;
+ int BlurayHeaderCheckDisable;
+} pcm_priv_data_t;
+
+static int pcm_read_init(pcm_read_ctl_t *pcm_read_ctx, unsigned char* inbuf, int size)
+{
+ pcm_read_ctx->ValidDataLen = size;
+ pcm_read_ctx->UsedDataLen = 0;
+ pcm_read_ctx->BufStart = inbuf;
+ pcm_read_ctx->pcur = inbuf;
+ return 0;
+}
+
+static int pcm_read(pcm_read_ctl_t *pcm_read_ctx, unsigned char* outbuf, int size)
+{
+ int bytes_read = 0;
+ if (size <= pcm_read_ctx->ValidDataLen) {
+ memcpy(outbuf, pcm_read_ctx->pcur, size);
+ pcm_read_ctx->ValidDataLen -= size;
+ pcm_read_ctx->UsedDataLen += size;
+ pcm_read_ctx->pcur += size;
+ bytes_read = size;
+ }
+ return bytes_read;
+}
+
+static int av_get_bits_per_sample(int codec_id)
+{
+ switch (codec_id) {
+ case AFORMAT_ALAW:
+ case AFORMAT_MULAW:
+ case AFORMAT_PCM_U8:
+ return 8;
+ case AFORMAT_PCM_S16BE:
+ case AFORMAT_PCM_S16LE:
+ return 16;
+ default:
+ return 0;
+ }
+}
+
+static int alaw2linear(unsigned char a_val)
+{
+ int t;
+ int seg;
+ a_val ^= 0x55;
+ t = a_val & QUANT_MASK;
+ seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT;
+ if (seg) {
+ t = (t + t + 1 + 32) << (seg + 2);
+ } else {
+ t = (t + t + 1) << 3;
+ }
+ return (a_val & SIGN_BIT) ? t : -t;
+}
+
+static int ulaw2linear(unsigned char u_val)
+{
+ int t;
+ u_val = ~u_val;
+ t = ((u_val & QUANT_MASK) << 3) + BIAS;
+ t <<= ((unsigned)u_val & SEG_MASK) >> SEG_SHIFT;
+ return (u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS);
+}
+
+/**
+ * Parse the header of a LPCM frame read from a MPEG-TS stream
+ * @param avctx the codec context
+ * @param header pointer to the first four bytes of the data packet
+ */
+static int pcm_bluray_pheader(pcm_read_ctl_t *pcm_read_ctl, aml_audio_dec_t *audec, char *header, int *bps)
+{
+ audio_decoder_operations_t *adec_ops = (audio_decoder_operations_t *)audec->adec_ops;
+ pcm_priv_data_t *pPcm_priv_data = (pcm_priv_data_t *)adec_ops->priv_dec_data;
+
+ uint8_t bits_per_samples[4] = { 0, 16, 20, 24 };
+ uint32_t channel_layouts[16] = {
+ 0, CH_LAYOUT_MONO, 0, CH_LAYOUT_STEREO, CH_LAYOUT_SURROUND,
+ CH_LAYOUT_2_1, CH_LAYOUT_4POINT0, CH_LAYOUT_2_2, CH_LAYOUT_5POINT0,
+ CH_LAYOUT_5POINT1, CH_LAYOUT_7POINT0, CH_LAYOUT_7POINT1, 0, 0, 0, 0
+ };
+ uint8_t channels[16] = {
+ 0, 1, 0, 2, 3, 3, 4, 4, 5, 6, 7, 8, 0, 0, 0, 0
+ };
+ int frame_size = header[0] << 8 | header[1];
+ uint8_t channel_layout = header[2] >> 4;
+ int frame_header = header[0] << 24 | header[1] << 16 | header[2] << 8 | header[3];
+
+ if (frame_header != pPcm_priv_data->pcm_bluray_header) {
+ PRINTF("[%s %d]NOTE:pcm_bluray_header: header = %02x%02x%02x%02x\n", __FUNCTION__, __LINE__, header[0], header[1], header[2], header[3]);
+ pPcm_priv_data->pcm_bluray_header = frame_header;
+ }
+ if (frame_size != pPcm_priv_data->pcm_bluray_size) {
+ PRINTF("[%s %d]bluray pcm frame size is %d\n", __FUNCTION__, __LINE__, frame_size);
+ pPcm_priv_data->pcm_bluray_size = frame_size;
+ }
+
+ /* get the sample depth and derive the sample format from it */
+ *bps = bits_per_samples[header[3] >> 6];
+ if (*bps == 0) {
+ PRINTF("[%s %d]unsupported sample datawitth (0)\n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+
+ /* get the sample rate. Not all values are known or exist. */
+ switch (header[2] & 0x0f) {
+ case 1:
+ pPcm_priv_data->pcm_samplerate = 48000;
+ break;
+ case 4:
+ pPcm_priv_data->pcm_samplerate = 96000;
+ break;
+ case 5:
+ pPcm_priv_data->pcm_samplerate = 192000;
+ break;
+ default:
+ pPcm_priv_data->pcm_samplerate = 0;
+ PRINTF("[%s %d]unsupported sample rate (%d)\n", __FUNCTION__, __LINE__, header[2] & 0x0f);
+ return -1;
+ }
+
+ /*
+ * get the channel number (and mapping). Not all values are known or exist.
+ * It must be noted that the number of channels in the MPEG stream can
+ * differ from the actual meaningful number, e.g. mono audio still has two
+ * channels, one being empty.
+ */
+ //avctx->channel_layout = channel_layouts[channel_layout];
+ pPcm_priv_data->pcm_channels = channels[channel_layout];
+ if (!pPcm_priv_data->pcm_channels) {
+ PRINTF("[%s %d]unsupported channel configuration (%d)\n", __FUNCTION__, __LINE__, channel_layout);
+ return -1;
+ }
+ return frame_size;
+}
+
+
+#define Emphasis_Off 0
+#define Emphasis_On 1
+#define Quantization_Word_16bit 0
+#define Quantization_Word_Reserved 0xff
+#define Audio_Sampling_44_1 1
+#define Audio_Sampling_48 2
+#define Audio_Sampling_Reserved 0xff
+#define Audio_channel_Dual_Mono 0
+#define Audio_channel_Stero 1
+#define Audio_channel_Reserved 0xff
+#define FramesPerAU 80 //according to spec of wifi display
+#define Wifi_Display_Private_Header_Size 4
+
+
+static int parse_wifi_display_pcm_header(aml_audio_dec_t *audec, char *header, int *bps)
+{
+ char number_of_frame_header, audio_emphasis, quant, sample, channel;
+ int frame_size = -1;
+ audio_decoder_operations_t *adec_ops = (audio_decoder_operations_t *)audec->adec_ops;
+ pcm_priv_data_t *pPcm_priv_data = (pcm_priv_data_t *)adec_ops->priv_dec_data;
+ //check sub id
+ if (header[0] == 0xa0) {
+ number_of_frame_header = header[1];
+ audio_emphasis = header[2] & 1;
+ quant = header[3] >> 6;
+ sample = (header[3] >> 3) & 7;
+ channel = header[3] & 7;
+
+ if (quant == Quantization_Word_16bit) {
+ *bps = 16;
+ } else {
+ PRINTF("[%s %d]using reserved bps %d\n", __FUNCTION__, __LINE__, *bps);
+ }
+
+ if (sample == Audio_Sampling_44_1) {
+ pPcm_priv_data->pcm_samplerate = 44100;
+ } else if (sample == Audio_Sampling_48) {
+ pPcm_priv_data->pcm_samplerate = 48000;
+ } else {
+ PRINTF("[%s %d]using reserved sample_rate %d\n", __FUNCTION__, __LINE__, audec->samplerate);
+ pPcm_priv_data->pcm_samplerate = audec->samplerate;
+ }
+
+ if (channel == Audio_channel_Dual_Mono) {
+ pPcm_priv_data->pcm_channels = 1; //note: this is not sure
+ } else if (channel == Audio_channel_Stero) {
+ pPcm_priv_data->pcm_channels = 2;
+ } else {
+ PRINTF("using reserved channel %d\n", audec->channels);
+ pPcm_priv_data->pcm_channels = audec->channels;
+ }
+ pPcm_priv_data->lpcm_header_parsed = 1;
+
+ frame_size = FramesPerAU * (*bps >> 3) * audec->channels * number_of_frame_header;
+ } else {
+ PRINTF("[%s %d]unknown sub id\n", __FUNCTION__, __LINE__);
+ }
+
+ return frame_size;
+}
+/**
+ * Read PCM samples macro
+ * @param type Datatype of native machine format
+ * @param endian bytestream_get_xxx() endian suffix
+ * @param src Source pointer (variable name)
+ * @param dst Destination pointer (variable name)
+ * @param n Total number of samples (variable name)
+ * @param shift Bitshift (bits)
+ * @param offset Sample value offset
+ */
+#define DEF_T(type, name, bytes, read, write) \
+ static type bytestream_get_ ## name(const uint8_t **b){\
+ (*b) += bytes;\
+ return read(*b - bytes);\
+ }\
+ static void bytestream_put_ ##name(uint8_t **b, const type value){\
+ write(*b, value);\
+ (*b) += bytes;\
+ }
+#define DEF(name, bytes, read, write) DEF_T(unsigned int, name, bytes, read, write)
+
+
+DEF(le32, 4, AV_RL32, AV_WL32)
+DEF(le24, 3, AV_RL24, AV_WL24)
+DEF(le16, 2, AV_RL16, AV_WL16)
+DEF(be32, 4, AV_RB32, AV_WB32)
+DEF(be24, 3, AV_RB24, AV_WB24)
+DEF(be16, 2, AV_RB16, AV_WB16)
+DEF(byte, 1, AV_RB8 , AV_WB8)
+
+#define DECODE(type, endian, src, dst, n, shift, offset) \
+ dst_##type = (type*)dst; \
+ for(;n>0;n--) { \
+ register type v = bytestream_get_##endian((const unsigned char**)&src); \
+ *dst_##type++ = (v - offset) << shift; \
+ } \
+ dst = (short*)dst_##type;
+
+
+static int pcm_init(aml_audio_dec_t *audec)
+{
+ int i;
+ audio_decoder_operations_t *adec_ops = NULL;
+ pcm_priv_data_t *pPcm_priv_data = NULL;
+
+ pPcm_priv_data = malloc(sizeof(pcm_priv_data_t));
+ if (pPcm_priv_data == NULL) {
+ PRINTF("[%s %d]malloc memory failed!\n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ memset(pPcm_priv_data, 0, sizeof(pcm_priv_data_t));
+ adec_ops = (audio_decoder_operations_t *)audec->adec_ops;
+ adec_ops->priv_dec_data = pPcm_priv_data;
+ adec_ops->nInBufSize = pcm_buffer_size;
+ adec_ops->nOutBufSize = 0;
+ pPcm_priv_data->pcm_buffer = malloc(bluray_pcm_size);
+ if (pPcm_priv_data->pcm_buffer == NULL) {
+ free(adec_ops->priv_dec_data);
+ adec_ops->priv_dec_data = NULL;
+ PRINTF("[%s %d]malloc memory failed!\n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ memset(pPcm_priv_data->pcm_buffer, 0, bluray_pcm_size);
+
+ PRINTF("[%s]audec->format/%d adec_ops->samplerate/%d adec_ops->channels/%d\n",
+ __FUNCTION__, audec->format, adec_ops->samplerate, adec_ops->channels);
+
+ pPcm_priv_data->pcm_samplerate = adec_ops->samplerate;
+ pPcm_priv_data->pcm_channels = adec_ops->channels;
+ if (audec->format == AFORMAT_PCM_BLURAY) {
+ pPcm_priv_data->pcm_bluray_size = 0;
+ pPcm_priv_data->pcm_bluray_header = 0;
+ pPcm_priv_data->frame_size_check = 0;
+ pPcm_priv_data->jump_read_head_flag = 0;
+ pPcm_priv_data->frame_size_check_flag = 1;
+
+#ifdef CHECK_BLUERAY_PCM_HEADER
+ pPcm_priv_data->frame_size_check_flag = 0;
+ if (/*!audec->extradata ||*/ audec->extradata_size != 4) {
+ free(pPcm_priv_data->pcm_buffer);
+ free(adec_ops->priv_dec_data);
+ adec_ops->priv_dec_data = NULL;
+ PRINTF("[%s %d] pcm_init failed: need extradata !\n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ memcpy(&pPcm_priv_data->pcm_bluray_header, audec->extradata, 4);
+ PRINTF("blueray frame 4 byte header[0x%x],[0x%x],[0x%x],[0x%x]\n", audec->extradata[0], audec->extradata[1], \
+ audec->extradata[2], audec->extradata[3]);
+#endif
+
+ return 0;
+ }
+
+ switch (audec->format) {
+ case AFORMAT_ALAW:
+ for (i = 0; i < 256; i++) {
+ table[i] = alaw2linear(i);
+ }
+ break;
+ case AFORMAT_MULAW:
+ for (i = 0; i < 256; i++) {
+ table[i] = ulaw2linear(i);
+ }
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+
+#define CHECK_DATA_ENOUGH(Ctl,NeedBytes,UsedSetIfNo) { \
+ if((Ctl)->ValidDataLen < (NeedBytes)){ \
+ PRINTF("[%s %d]NOTE--> no enough data\n",__FUNCTION__,__LINE__);\
+ (Ctl)->UsedDataLen-=(UsedSetIfNo); \
+ return -1; \
+ } \
+}
+
+
+
+static int check_frame_size(pcm_read_ctl_t *pcm_read_ctl, aml_audio_dec_t *audec , int *bps)
+{
+ int index;
+ int find_header_cnt = 0, first_header_pos = -1;
+ int size ;
+ int header, frame_size;
+ int first_head_pos = 0;
+ audio_decoder_operations_t *adec_ops = (audio_decoder_operations_t *)audec->adec_ops;
+ pcm_priv_data_t *pPcm_priv_data = (pcm_priv_data_t *)adec_ops->priv_dec_data;
+
+ CHECK_DATA_ENOUGH(pcm_read_ctl, 4, 0)
+ pcm_read(pcm_read_ctl, pPcm_priv_data->pcm_buffer, 4);
+
+ index = 0;
+ while (1) {
+ header = (pPcm_priv_data->pcm_buffer[0] << 24) | (pPcm_priv_data->pcm_buffer[1] << 16) | \
+ (pPcm_priv_data->pcm_buffer[2] << 8) | (pPcm_priv_data->pcm_buffer[3]);
+ if (header == pPcm_priv_data->pcm_bluray_header) {
+ break;
+ }
+ pPcm_priv_data->pcm_buffer[0] = pPcm_priv_data->pcm_buffer[1];
+ pPcm_priv_data->pcm_buffer[1] = pPcm_priv_data->pcm_buffer[2];
+ pPcm_priv_data->pcm_buffer[2] = pPcm_priv_data->pcm_buffer[3];
+ CHECK_DATA_ENOUGH(pcm_read_ctl, 1, 3)
+ pcm_read(pcm_read_ctl, &pPcm_priv_data->pcm_buffer[3], 1);
+ index++;
+ }
+
+ first_head_pos = pcm_read_ctl->UsedDataLen - 4;
+ PRINTF("[%s %d]First BluRay Header offset=%d\n", __FUNCTION__, __LINE__, first_head_pos);
+ //---------------------------------------------
+ frame_size = pcm_bluray_pheader(pcm_read_ctl, audec, pPcm_priv_data->pcm_buffer, bps);
+ if (frame_size > 0) {
+ PRINTF("[%s %d]frame_size from parser:%d\n", __FUNCTION__, __LINE__, frame_size);
+ CHECK_DATA_ENOUGH(pcm_read_ctl, frame_size, 4);
+
+ } else {
+ PRINTF("[%s %d]ERR: invalid frame_size from parser:%d\n", __FUNCTION__, __LINE__, frame_size);
+ pPcm_priv_data->frame_size_check_flag = 1;
+ return -1;
+ }
+
+ index = 1;
+ if (!pcm_read(pcm_read_ctl, &pPcm_priv_data->pcm_buffer[4], 1)) {
+ PRINTF("[%s %d]NOTE--> no enough data\n", __FUNCTION__, __LINE__);
+ pcm_read_ctl->UsedDataLen = first_head_pos;
+ return -1;
+ }
+
+ while (1) {
+ if (index + 3 == bluray_pcm_size) {
+ PRINTF("[%s %d]ExtraData(First Bluray FrmHeader)May be Broken,used Unchecked Mode..\n", __FUNCTION__, __LINE__);
+ pcm_read_ctl->UsedDataLen = first_head_pos;
+ pPcm_priv_data->frame_size_check_flag = 1;
+ pPcm_priv_data->jump_read_head_flag = 0;
+ pPcm_priv_data->frame_size_check = frame_size;
+ pPcm_priv_data->BlurayHeaderCheckDisable = 1;
+ return -1;
+ }
+ header = (pPcm_priv_data->pcm_buffer[index] << 24) | (pPcm_priv_data->pcm_buffer[index + 1] << 16) | \
+ (pPcm_priv_data->pcm_buffer[index + 2] << 8) | (pPcm_priv_data->pcm_buffer[index + 3]);
+ if (header == pPcm_priv_data->pcm_bluray_header) {
+ pPcm_priv_data->frame_size_check_flag = 1;
+ pPcm_priv_data->frame_size_check = index - 4;
+ pPcm_priv_data->jump_read_head_flag = 1;
+ PRINTF("frame_size_check=%d\n", pPcm_priv_data->frame_size_check);
+ break;
+ }
+
+ if (!pcm_read(pcm_read_ctl, &pPcm_priv_data->pcm_buffer[index + 4], 1)) {
+ PRINTF("[%s %d]NOTE--> no enough data\n", __FUNCTION__, __LINE__);
+ pcm_read_ctl->UsedDataLen = first_head_pos;
+ return -1;
+ }
+ index++;
+ }
+
+
+ memmove(pPcm_priv_data->pcm_buffer, &pPcm_priv_data->pcm_buffer[4], pPcm_priv_data->frame_size_check);
+ if (frame_size != pPcm_priv_data->frame_size_check) {
+ PRINTF("[%s %d]WARNING-->STREAM_ERR:frame_size!=frame_size_check %d/%d\n ",
+ __FUNCTION__, __LINE__, frame_size, pPcm_priv_data->frame_size_check);
+ frame_size = pPcm_priv_data->frame_size_check;
+ }
+ return frame_size;
+
+}
+
+static inline int16_t av_clip_int16(int a)
+{
+ if ((a + 32768) & ~65535) {
+ return (a >> 31) ^ 32767;
+ } else {
+ return a;
+ }
+}
+
+static int pcm_decode_frame(pcm_read_ctl_t *pcm_read_ctl, unsigned char *buf, int len, aml_audio_dec_t *audec)
+{
+ short *sample;
+ unsigned char *src;
+ int size = 0, n, i, j, bps = 16, wifi_display_drop_header = 0;
+ int sample_size;
+ unsigned int header;
+ int16_t *dst_int16_t;
+ int32_t *dst_int32_t;
+ int64_t *dst_int64_t;
+ uint16_t *dst_uint16_t;
+ uint32_t *dst_uint32_t;
+ int frame_size;
+ audio_decoder_operations_t *adec_ops = (audio_decoder_operations_t *)audec->adec_ops;
+ pcm_priv_data_t *pPcm_priv_data = (pcm_priv_data_t *)adec_ops->priv_dec_data;
+
+ sample = (short *)buf;
+ src = pPcm_priv_data->pcm_buffer;
+
+ if (audec->format == AFORMAT_PCM_BLURAY) {
+ int i, j;
+ int tmp_buf[10] = {0};
+ if (!pPcm_priv_data->frame_size_check_flag) {
+ frame_size = check_frame_size(pcm_read_ctl, audec, &bps);
+ if (frame_size < 0) {
+ return 0;
+ }
+ if (bps > 0) {
+ pPcm_priv_data->bit_per_sample = bps;
+ }
+ } else {
+ if (pPcm_priv_data->jump_read_head_flag == 1) {
+ frame_size = pPcm_priv_data->frame_size_check;
+ pPcm_priv_data->jump_read_head_flag = 0;
+ } else if (pPcm_priv_data->jump_read_head_flag == 0) {
+
+#ifdef CHECK_BLUERAY_PCM_HEADER
+ if (pcm_read(pcm_read_ctl, pPcm_priv_data->pcm_buffer, 4) == 0) {
+ return 0;
+ }
+ while (!pPcm_priv_data->BlurayHeaderCheckDisable) {
+ header = (pPcm_priv_data->pcm_buffer[0] << 24) | (pPcm_priv_data->pcm_buffer[1] << 16) | \
+ (pPcm_priv_data->pcm_buffer[2] << 8) | (pPcm_priv_data->pcm_buffer[3]);
+ if (header == pPcm_priv_data->pcm_bluray_header) {
+ break;
+ }
+ pPcm_priv_data->pcm_buffer[0] = pPcm_priv_data->pcm_buffer[1];
+ pPcm_priv_data->pcm_buffer[1] = pPcm_priv_data->pcm_buffer[2];
+ pPcm_priv_data->pcm_buffer[2] = pPcm_priv_data->pcm_buffer[3];
+ if (!pcm_read(pcm_read_ctl, &pPcm_priv_data->pcm_buffer[3], 1)) {
+ pcm_read_ctl->UsedDataLen -= 3;
+ return 0;
+ }
+ }
+#else
+ if (!pcm_read(pcm_read_ctl, pPcm_priv_data->pcm_buffer, 4)) {
+ return 0;
+ }
+#endif
+
+ frame_size = pcm_bluray_pheader(pPcm_priv_data, audec, pPcm_priv_data->pcm_buffer, &bps);
+ pPcm_priv_data->bit_per_sample = bps;
+ if (frame_size < 960 || frame_size > 17280) {
+ PRINTF("STREAM_ERR:illegal blueray frame size \n");
+ return 0;
+ }
+
+#ifdef CHECK_BLUERAY_PCM_HEADER
+ if (frame_size != pPcm_priv_data->frame_size_check && !pPcm_priv_data->BlurayHeaderCheckDisable) {
+ frame_size = pPcm_priv_data->frame_size_check;
+ }
+#endif
+
+ }
+ if (bps > 0) {
+ pPcm_priv_data->bit_per_sample = bps;
+ }
+
+ if (!pcm_read(pcm_read_ctl, pPcm_priv_data->pcm_buffer, frame_size)) {
+ pcm_read_ctl->UsedDataLen -= 4;
+ return 0;
+ }
+ }
+
+ if (pPcm_priv_data->bit_per_sample == 16) {
+ if (pPcm_priv_data->pcm_channels == 1) {
+ for (i = 0, j = 0; i < frame_size;) {
+ sample[j + 1] = sample[j] = (pPcm_priv_data->pcm_buffer[i] << 8) | pPcm_priv_data->pcm_buffer[i + 1];
+ i += 2;
+ j += 2;
+ }
+ } else if (pPcm_priv_data->pcm_channels == 2) {
+ for (i = 0, j = 0; i < frame_size;) {
+ sample[j++] = (pPcm_priv_data->pcm_buffer[i] << 8) | pPcm_priv_data->pcm_buffer[i + 1];
+ i += 2;
+ sample[j++] = (pPcm_priv_data->pcm_buffer[i] << 8) | pPcm_priv_data->pcm_buffer[i + 1];
+ i += 2;
+ }
+ } else if (pPcm_priv_data->pcm_channels > 2 && pPcm_priv_data->pcm_channels <= 8) {
+ int k;
+ memset(tmp_buf, 0, sizeof(tmp_buf));
+ for (i = 0, j = 0; i < frame_size;) {
+ for (k = 0; k < pPcm_priv_data->pcm_channels; k++) {
+ tmp_buf[k] = (int16_t)((pPcm_priv_data->pcm_buffer[i] << 8) | pPcm_priv_data->pcm_buffer[i + 1]);
+ i += 2;
+ }
+ //LoRo downmix:L R C Ls Rs LFE Lsr Rsr
+ sample[j++] = av_clip_int16(tmp_buf[0] + 0.707f * tmp_buf[2] + 0.707f * (tmp_buf[3] + tmp_buf[6])); //Lo=L+0.707C+0.707 (Ls+Lsr)
+ sample[j++] = av_clip_int16(tmp_buf[1] + 0.707f * tmp_buf[2] + 0.707f * (tmp_buf[4] + tmp_buf[7])); //Ro=R+0.707C+0.707(Rs+Rsr)
+ }
+ }
+ } else if (pPcm_priv_data->bit_per_sample == 24 || pPcm_priv_data->bit_per_sample == 20) {
+ int k;
+ memset(tmp_buf, 0, sizeof(tmp_buf));
+ if (pPcm_priv_data->pcm_channels == 1) {
+ for (i = 0, j = 0; i < frame_size;) {
+ sample[j++] = (pPcm_priv_data->pcm_buffer[i] << 8) | pPcm_priv_data->pcm_buffer[i + 1];
+ i += 3;
+ }
+ } else if (pPcm_priv_data->pcm_channels == 2) {
+ for (i = 0, j = 0; i < frame_size;) {
+ sample[j++] = (pPcm_priv_data->pcm_buffer[i] << 8) | pPcm_priv_data->pcm_buffer[i + 1];
+ i += 3;
+ sample[j++] = (pPcm_priv_data->pcm_buffer[i] << 8) | pPcm_priv_data->pcm_buffer[i + 1];
+ i += 3;
+ }
+ } else if (pPcm_priv_data->pcm_channels >= 2 && pPcm_priv_data->pcm_channels <= 8) {
+ int k;
+ memset(tmp_buf, 0, sizeof(tmp_buf));
+ for (i = 0, j = 0; i < frame_size;) {
+ for (k = 0; k < pPcm_priv_data->pcm_channels; k++) {
+ tmp_buf[k] = (int16_t)(pPcm_priv_data->pcm_buffer[i] << 8) | pPcm_priv_data->pcm_buffer[i + 1];
+ i += 3;
+ }
+ //LoRo downmix:L R C Ls Rs LFE Lsr Rsr
+ sample[j++] = av_clip_int16(tmp_buf[0] + 0.707f * tmp_buf[2] + 0.707f * (tmp_buf[3] + tmp_buf[6])); //Lo=L+0.707C+0.707 (Ls+Lsr)
+ sample[j++] = av_clip_int16(tmp_buf[1] + 0.707f * tmp_buf[2] + 0.707f * (tmp_buf[4] + tmp_buf[7])); //Ro=R+0.707C+0.707(Rs+Rsr)
+ }
+ }
+ } else {
+ PRINTF("[%s %d]blueray pcm is %d bps, don't process now\n", __FUNCTION__, __LINE__, pPcm_priv_data->bit_per_sample);
+ return 0;
+ }
+ return j * 2;
+ } else if (audec->format == AFORMAT_PCM_WIFIDISPLAY) {
+ //check audio info for wifi display LPCM, by zefeng.tong@amlogic.com
+ if (!pcm_read(pcm_read_ctl, pPcm_priv_data->pcm_buffer, Wifi_Display_Private_Header_Size)) {
+ return 0;
+ }
+
+ if (pPcm_priv_data->pcm_buffer[0] == 0xa0) {
+ frame_size = parse_wifi_display_pcm_header(audec, pPcm_priv_data->pcm_buffer, &bps);
+ if (!pcm_read(pcm_read_ctl, pPcm_priv_data->pcm_buffer, frame_size)) {
+ pcm_read_ctl->UsedDataLen -= Wifi_Display_Private_Header_Size;
+ return -1;
+ }
+ pPcm_priv_data->bit_per_sample = bps;
+ } else {
+ frame_size = Wifi_Display_Private_Header_Size; //transimit error or something?
+ }
+
+ if (pPcm_priv_data->bit_per_sample == 16) {
+ if (pPcm_priv_data->pcm_channels == 1) {
+ for (i = 0, j = 0; i < frame_size;) {
+ sample[j + 1] = sample[j] = (pPcm_priv_data->pcm_buffer[i] << 8) | pPcm_priv_data->pcm_buffer[i + 1];
+ i += 2;
+ j += 2;
+ }
+ } else if (pPcm_priv_data->pcm_channels == 2) {
+ for (i = 0, j = 0; i < frame_size;) {
+ sample[j++] = (pPcm_priv_data->pcm_buffer[i] << 8) | pPcm_priv_data->pcm_buffer[i + 1];
+ i += 2;
+ sample[j++] = (pPcm_priv_data->pcm_buffer[i] << 8) | pPcm_priv_data->pcm_buffer[i + 1];
+ i += 2;
+ }
+ }
+ return frame_size;
+ } else {
+ PRINTF("[%s %d]wifi display:unimplemented bps %d\n", __FUNCTION__, __LINE__, bps);
+ }
+
+ return 0;
+ }
+
+ unsigned byte_to_read = pcm_buffer_size;
+ while (pcm_read_ctl->ValidDataLen < byte_to_read) {
+ byte_to_read = byte_to_read >> 1;
+ }
+ size = pcm_read(pcm_read_ctl, pPcm_priv_data->pcm_buffer, byte_to_read);
+
+ sample_size = av_get_bits_per_sample(audec->format) / 8;
+ n = size / sample_size;
+
+ switch (audec->format) {
+ case AFORMAT_ALAW:
+ case AFORMAT_MULAW:
+ for (; n > 0; n--) {
+ *sample++ = table[*src++];
+ }
+ //dbuf.data_size = size *2;
+ size *= 2;
+ break;
+
+ case AFORMAT_PCM_S16LE: {
+ int i, j;
+ short tmp_buf[10];
+ short* p;
+ p = (short*)pPcm_priv_data->pcm_buffer;
+ if (pPcm_priv_data->pcm_channels == 6) {
+ for (i = 0, j = 0; (i + 6) < (size / 2);) {
+ *(tmp_buf) = p[i]; //L
+ *(tmp_buf + 1) = p[i + 1]; //R
+ *(tmp_buf + 2) = p[i + 2]; //C
+ i += 6;
+
+ sample[j++] = (*(tmp_buf) >> 1) + (*(tmp_buf + 2) >> 1);
+ sample[j++] = (*(tmp_buf + 1) >> 1) + (*(tmp_buf + 2) >> 1);
+ }
+ size = 2 * j;
+ } else {
+ memcpy(sample, src, n * sample_size);
+ }
+ //dbuf.data_size = size;
+
+ }
+ break;
+
+ case AFORMAT_PCM_S16BE:
+ DECODE(int16_t, be16, src, sample, n, 0, 0)
+ break;
+
+ case AFORMAT_PCM_U8:
+ for (; n > 0; n--) {
+ *sample++ = ((int) * src++ - 128) << 8;
+ }
+ //dbuf.data_size = size*2;
+ size *= 2;
+ break;
+
+ default:
+ PRINTF("[%s %d]Not support format audec->format=%d!\n", __FUNCTION__, __LINE__, audec->format);
+ break;
+ }
+
+ return size;
+}
+
+
+int audio_dec_init(audio_decoder_operations_t *adec_ops)
+{
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)(adec_ops->priv_data);
+ //PRINTF("\n\n[%s]BuildDate--%s BuildTime--%s", __FUNCTION__, __DATE__, __TIME__);
+ return pcm_init(audec);
+
+}
+
+int audio_dec_decode(audio_decoder_operations_t *adec_ops, char *outbuf, int *outlen, char *inbuf, int inlen)
+{
+ aml_audio_dec_t *audec = (aml_audio_dec_t *)(adec_ops->priv_data);
+ pcm_read_ctl_t pcm_read_ctl = {0};
+ pcm_read_init(&pcm_read_ctl, inbuf, inlen);
+ *outlen = pcm_decode_frame(&pcm_read_ctl, outbuf, *outlen, audec);
+ return pcm_read_ctl.UsedDataLen;
+
+}
+
+int audio_dec_release(audio_decoder_operations_t *adec_ops)
+{
+ pcm_priv_data_t *pPcm_priv_data = (pcm_priv_data_t *)adec_ops->priv_dec_data;
+ if (pPcm_priv_data != NULL && pPcm_priv_data->pcm_buffer) {
+ free(pPcm_priv_data->pcm_buffer);
+ free(pPcm_priv_data);
+ }
+ adec_ops->priv_dec_data = NULL;
+ return 0;
+}
+
+int audio_dec_getinfo(audio_decoder_operations_t *adec_ops, void *pAudioInfo)
+{
+ pcm_priv_data_t *pPcm_priv_data = (pcm_priv_data_t *)adec_ops->priv_dec_data;
+ ((AudioInfo *)pAudioInfo)->channels = pPcm_priv_data->pcm_channels > 2 ? 2 : pPcm_priv_data->pcm_channels;
+ ((AudioInfo *)pAudioInfo)->samplerate = pPcm_priv_data->pcm_samplerate;
+ return 0;
+}
+
+
+
diff --git a/audio_codec/libraac/Android.mk b/audio_codec/libraac/Android.mk
new file mode 100644
index 0000000..7458f94
--- a/dev/null
+++ b/audio_codec/libraac/Android.mk
@@ -0,0 +1,51 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libraac
+
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+#ifeq ($(TARGET_ARCH),arm)
+#LOCAL_SRC_FILES += sbrcov.s\
+# sbrqmfak.s\
+# sbrqmfsk.s
+#endif
+LOCAL_CFLAGS := -DHAVE_NEON=1 -DHAVE_CONFIG -DOPT_NEON -DREAL_IS_FLOAT -DAAC_ENABLE_SBR
+
+ifeq ($(TARGET_ARCH),arm)
+LOCAL_CFLAGS += -mfloat-abi=softfp -mfpu=neon
+endif
+
+LOCAL_ARM_MODE := arm
+LOCAL_C_INCLUDES := $(LOCAL_PATH)\
+ $(LOCAL_PATH)/include
+
+include $(BUILD_STATIC_LIBRARY)
+
+
+#########################################################################
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libraac
+
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+#ifeq ($(TARGET_ARCH),arm)
+#LOCAL_SRC_FILES += sbrcov.s\
+# sbrqmfak.s\
+# sbrqmfsk.s
+#endif
+LOCAL_CFLAGS := -DHAVE_NEON=1 -DHAVE_CONFIG -DOPT_NEON -DREAL_IS_FLOAT -DAAC_ENABLE_SBR
+
+ifeq ($(TARGET_ARCH),arm)
+LOCAL_CFLAGS += -mfloat-abi=softfp -mfpu=neon
+endif
+
+LOCAL_ARM_MODE := arm
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := $(LOCAL_PATH)\
+ $(LOCAL_PATH)/include
+
+LOCAL_SHARED_LIBRARIES += libutils libmedia libz libbinder libdl libcutils libc
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/audio_codec/libraac/aac_bitstream.c b/audio_codec/libraac/aac_bitstream.c
new file mode 100644
index 0000000..696447f
--- a/dev/null
+++ b/audio_codec/libraac/aac_bitstream.c
@@ -0,0 +1,200 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aac_bitstream.c,v 1.1.1.1.2.1 2005/05/04 18:21:58 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <stdlib.h>
+#include "aac_bitstream.h"
+
+/** The bitstream structure.
+ * The idea of the bitstream reader is to keep a cache word that has the machine's
+ * largest native size. This word keeps the next-to-read bits left-aligned so that
+ * on a read, one shift suffices.
+ * The cache word is only refilled if it does not contain enough bits to satisy a
+ * a read request. Because the refill only happens in multiple of 8 bits, the maximum
+ * read size that is guaranteed to be always fulfilled is the number of bits in a long
+ * minus 8 (or whatever the number of bits in a byte is).
+ */
+
+struct BITSTREAM {
+ const unsigned char *buffer ; /**< points to the buffer holding the bits */
+ const unsigned char *pkptr ; /**< read pointer */
+ unsigned long cache ; /**< cache, always holds next bits left-aligned. */
+ int cacheBitsLeft ; /**< number of bits left in cache */
+ int nBits ; /**< the number of bits in the buffer */
+ int inc ; /**< read direction (forward/backward) */
+} ;
+
+enum {
+ CACHEBITS = 8 * sizeof(unsigned long)
+} ;
+
+static void fillUp(struct BITSTREAM *pBitstream)
+{
+ unsigned long k = 0 ;
+
+ while (CACHEBITS - pBitstream->cacheBitsLeft >= 8) {
+ k = (k << 8) + *(pBitstream->pkptr) ;
+ (pBitstream->pkptr) += pBitstream->inc ;
+ pBitstream->cacheBitsLeft += 8 ;
+ }
+ pBitstream->cache |= (k << (CACHEBITS - pBitstream->cacheBitsLeft)) ;
+}
+
+/** read nBits bits from bitstream
+ * @param pBitstream the bitstream to read from
+ * @param nBits the number of bits to read. nBits must be <= 32, currently.
+ * @return the bits read, right-justified
+ */
+unsigned int readBits(struct BITSTREAM *pBitstream, int nBits)
+{
+ unsigned int data ;
+
+ if (pBitstream->cacheBitsLeft < nBits) {
+ fillUp(pBitstream) ;
+ }
+
+ data = pBitstream->cache >> (CACHEBITS - nBits) ;
+ pBitstream->cache <<= nBits ;
+ pBitstream->cacheBitsLeft -= nBits ;
+
+ return data ;
+}
+
+/** push bits back into the bitstream.
+ * This call is here to make look-ahead possible, where after reading the client
+ * may realize it has read too far ahead. It is guaranteed to succeed as long as
+ * you don't push more bits back than have been read in the last readBits() call.
+ * @param pBitstream the bitstream to push back into
+ * @param bits the bits to push back
+ * @param nBits the number of bits to push back.
+ * @return an error code, signalling success or failure.
+ */
+int unreadBits(struct BITSTREAM *pBitstream, int bits, int nBits)
+{
+ pBitstream->cache = (pBitstream->cache >> nBits) | (bits << (CACHEBITS - nBits)) ;
+ pBitstream->cacheBitsLeft += nBits ;
+ return pBitstream->cacheBitsLeft > (signed)CACHEBITS ? -1 : 0 ;
+}
+
+/** byte-align the bitstream read pointer. */
+void byteAlign(struct BITSTREAM *pBitstream)
+{
+ int adjust = (pBitstream->cacheBitsLeft & 7) ;
+ pBitstream->cache <<= adjust ;
+ pBitstream->cacheBitsLeft -= adjust ;
+}
+
+/** allocate memory for a new bitstream structure.
+ * @param ppBitstream a pointer to a bitstream handle, to be initialized on
+ * successfull return
+ * @param nBits the maximum number of bits this bitstream must be able to hold.
+ * nBits must be divisible by 32.
+ * @param pUserMem optional user-defined memory handle
+ * @param fpMalloc user-defined malloc() implementation
+ * @return an error code, signalling success or failure.
+ * @see reverseBitstream
+ */
+int newBitstream(struct BITSTREAM **ppBitstream, int nBits,
+ void* pUserMem, rm_malloc_func_ptr fpMalloc)
+{
+ struct BITSTREAM *pBitstream ;
+
+ pBitstream = (struct BITSTREAM *)fpMalloc(pUserMem, sizeof(struct BITSTREAM)) ;
+ if (!pBitstream || !ppBitstream) {
+ return -1 ;
+ }
+
+ pBitstream->cacheBitsLeft = 0 ;
+ *ppBitstream = pBitstream ;
+
+ return 0 ;
+}
+
+/** free memory associated with a bitstream structure.
+ * @param pBitstream a bitstream handle
+ * @param pUserMem optional user-defined memory handle
+ * @param fpFree user-defined free() implementation
+ */
+void deleteBitstream(struct BITSTREAM *pBitstream, void* pUserMem,
+ rm_free_func_ptr fpFree)
+{
+ if (pBitstream) {
+ fpFree(pUserMem, pBitstream) ;
+ }
+}
+
+/** feed nbits bits to the bitstream, byte-wise.
+ * @param pBitstream the bitstream into which to feed the bytes
+ * @param input the input from which to read the bytes
+ * @param nbits the number of bits in the input. nbits must be divisible by 32
+ * for reverseBitstream() to work.
+ * @return an error code, signalling success or failure.
+ * @see reverseBitstream
+ */
+
+int feedBitstream(struct BITSTREAM *pBitstream, const unsigned char *input, int nbits)
+{
+ pBitstream->buffer = input ;
+ pBitstream->nBits = nbits ;
+
+ return 0 ;
+}
+
+/** return the number of bits left until end-of-stream.
+ * @param pBitstream the bitstream
+ * @return the number of bits left
+ */
+
+int bitsLeftInBitstream(struct BITSTREAM *pBitstream)
+{
+ return pBitstream->nBits - (pBitstream->pkptr - pBitstream->buffer) * 8 + pBitstream->cacheBitsLeft ;
+}
+
+/** set bitstream position, relative to origin defined through feedBitstream().
+ * @param pBitstream the bitstream
+ * @param position the position in bits (must be multiple of 8, currently).
+ * Always measured from beginning, regardless of direction.
+ * @param direction the direction of reading (+1/-1)
+ */
+
+int setAtBitstream(struct BITSTREAM *pBitstream, int position, int direction)
+{
+ pBitstream->pkptr = pBitstream->buffer + (position >> 3) ;
+ pBitstream->cacheBitsLeft = 0 ;
+ pBitstream->cache = 0 ;
+ pBitstream->inc = direction ;
+ return 0 ;
+}
diff --git a/audio_codec/libraac/aac_bitstream.h b/audio_codec/libraac/aac_bitstream.h
new file mode 100644
index 0000000..26f2fd6
--- a/dev/null
+++ b/audio_codec/libraac/aac_bitstream.h
@@ -0,0 +1,133 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aac_bitstream.h,v 1.1.1.1.2.1 2005/05/04 18:21:58 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/* bitstream reader functions. No checking for end-of-bits included! */
+
+#ifndef _BITSTREAM_H_
+#define _BITSTREAM_H_
+
+#include "include/rm_memory.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /** The bitstream structure.
+ * The idea of the bitstream reader is to keep a cache word that has the machine's
+ * largest native size. This word keeps the next-to-read bits left-aligned so that
+ * on a read, one shift suffices.
+ * The cache word is only refilled if it does not contain enough bits to satisy a
+ * a read request. Because the refill only happens in multiple of 8 bits, the maximum
+ * read size that is guaranteed to be always fulfilled is the number of bits in a long
+ * minus 8 (or the number of bits in a byte).
+ */
+
+ struct BITSTREAM ;
+
+ /** read nBits bits from bitstream
+ * @param pBitstream the bitstream to read from
+ * @param nBits the number of bits to read. nBits must be <= 32, currently.
+ * @return the bits read, right-justified
+ */
+ unsigned int readBits(struct BITSTREAM *pBitstream, int nBits) ;
+
+ /** push bits back into the bitstream.
+ * This call is here to make look-ahead possible, where after reading the client
+ * may realize it has read too far ahead. It is guaranteed to succeed as long as
+ * you don't push more bits back than have been read in the last readBits() call.
+ * @param pBitstream the bitstream to push back into
+ * @param bits the bits to push back
+ * @param nBits the number of bits to push back.
+ * @return an error code, signalling success or failure.
+ */
+ int unreadBits(struct BITSTREAM *pBitstream, int bits, int nBits) ;
+
+ /** byte-align the bitstream read pointer. */
+ void byteAlign(struct BITSTREAM *pBitstream) ;
+
+ /** allocate memory for a new bitstream structure.
+ * @param ppBitstream a pointer to a bitstream handle, to be initialized on
+ * successfull return
+ * @param nBits the maximum number of bits this bitstream must be able to hold.
+ * nBits must be divisible by 32.
+ * @param pUserMem optional user-defined memory handle
+ * @param fpMalloc user-defined malloc() implementation
+ * @return an error code, signalling success or failure.
+ * @see reverseBitstream
+ */
+ int newBitstream(struct BITSTREAM **ppBitstream, int nBits,
+ void* pUserMem, rm_malloc_func_ptr fpMalloc) ;
+
+ /** free memory associated with a bitstream structure.
+ * @param pBitstream a bitstream handle
+ * @param pUserMem optional user-defined memory handle
+ * @param fpFree user-defined free() implementation
+ */
+ void deleteBitstream(struct BITSTREAM *pBitstream, void *pUserMem,
+ rm_free_func_ptr fpFree) ;
+
+ /** feed nbits bits to the bitstream, byte-wise.
+ * @param pBitstream the bitstream into which to feed the bytes
+ * @param input the input from which to read the bytes
+ * @param nbits the number of bits in the input. nbits must be divisible by 32
+ * for reverseBitstream() to work.
+ * @return an error code, signalling success or failure.
+ * @see reverseBitstream
+ */
+
+ int feedBitstream(struct BITSTREAM *pBitstream, const unsigned char *input, int nbits) ;
+
+ /** set bitstream position, relative to origin defined through feedBitstream().
+ * @param pBitstream the bitstream
+ * @param position the position in bits (must be multiple of 8, currently).
+ * Always measured from beginning, regardless of direction.
+ * @param direction the direction of reading (+1/-1)
+ */
+
+ int setAtBitstream(struct BITSTREAM *pBitstream, int position, int direction) ;
+
+ /** return the number of bits left until end-of-stream.
+ * @param pBitstream the bitstream
+ * @return the number of bits left
+ */
+ int bitsLeftInBitstream(struct BITSTREAM *pBitstream) ;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _BITSTREAM_H_ */
diff --git a/audio_codec/libraac/aac_decode.h b/audio_codec/libraac/aac_decode.h
new file mode 100644
index 0000000..98141e2
--- a/dev/null
+++ b/audio_codec/libraac/aac_decode.h
@@ -0,0 +1,148 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aac_decode.h,v 1.2.2.1 2005/05/04 18:21:58 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef AAC_DECODE_H
+#define AAC_DECODE_H
+
+#include "include/helix_types.h"
+#include "include/helix_result.h"
+#include "include/ra_decode.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* aac decode struct */
+ typedef struct aac_decode_struct {
+ void* pDecoder;
+ void* pFrameInfo;
+ UINT32 ulNumChannels;
+ UINT32 ulChannelMask;
+ UINT32 ulBlockSize;
+ UINT32 ulFrameSize;
+ UINT32 ulFramesPerBlock;
+ UINT32 ulSamplesPerFrame;
+ UINT32 ulSampleRateCore;
+ UINT32 ulSampleRateOut;
+ UINT32 ulDelayRemaining;
+ UINT32 ulSamplesToConceal;
+ HXBOOL bSBR;
+ } aac_decode;
+
+ /* aac decode interface */
+
+ /*
+ * aac_decode_init
+ */
+ HX_RESULT aac_decode_init(void* pInitParams,
+ UINT32 ulInitParamsSize,
+ ra_format_info* pStreamInfo,
+ void** pDecode,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+
+ /*
+ * aac_decode_reset
+ */
+ HX_RESULT aac_decode_reset(void* pDecode,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut);
+
+ /*
+ * aac_decode_conceal
+ */
+ HX_RESULT aac_decode_conceal(void* pDecode,
+ UINT32 ulNumSamples);
+
+ /*
+ * aac_decode_decode
+ */
+ HX_RESULT aac_decode_decode(void* pDecode,
+ UINT8* pData,
+ UINT32 ulNumBytes,
+ UINT32* pNumBytesConsumed,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut,
+ UINT32 ulFlags,
+ UINT32 ulTimeStamp);
+
+ /*
+ * aac_decode_getmaxsize
+ */
+ HX_RESULT aac_decode_getmaxsize(void* pDecode,
+ UINT32* pNumSamples);
+
+ /*
+ * aac_decode_getchannels
+ */
+ HX_RESULT aac_decode_getchannels(void* pDecode,
+ UINT32* pNumChannels);
+
+ /*
+ * aac_decode_getchannelmask
+ */
+ HX_RESULT aac_decode_getchannelmask(void* pDecode,
+ UINT32* pChannelMask);
+
+ /*
+ * aac_decode_getrate
+ */
+ HX_RESULT aac_decode_getrate(void* pDecode,
+ UINT32* pSampleRate);
+
+ /*
+ * aac_decode_getdelay
+ */
+ HX_RESULT aac_decode_getdelay(void* pDecode,
+ UINT32* pNumSamples);
+
+ /*
+ * aac_decode_close
+ */
+ HX_RESULT aac_decode_close(void* pDecode,
+ void* pUserMem,
+ rm_free_func_ptr fpFree);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef AAC_DECODE_H */
diff --git a/audio_codec/libraac/aac_decode_main.c b/audio_codec/libraac/aac_decode_main.c
new file mode 100644
index 0000000..d184927
--- a/dev/null
+++ b/audio_codec/libraac/aac_decode_main.c
@@ -0,0 +1,396 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aac_decode.c,v 1.2.2.1 2005/05/04 18:21:58 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <string.h>
+#include "include/helix_types.h"
+#include "include/helix_result.h"
+#include "aac_decode.h"
+#include "include/ra_format_info.h"
+#include "ga_config.h"
+#include "aac_bitstream.h"
+#include "aac_reorder.h"
+#include "aac_decode.h"
+#include "aacdec.h"
+#include <stdio.h>
+//#include <core/dsp.h>
+
+/*
+ * aac_decode_init
+ */
+HX_RESULT
+aac_decode_init(void* pInitParams,
+ UINT32 ulInitParamsSize,
+ ra_format_info* pStreamInfo,
+ void** pDecode,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree)
+{
+ HX_RESULT result = HXR_OK;
+ aac_decode* pDec;
+ AACFrameInfo *frameInfo;
+ ga_config_data configData;
+ UCHAR *pData;
+ UCHAR *inBuf;
+ INT16 *temp;
+ UINT32 numBytes, numBits;
+ UINT32 cfgType;
+
+ /* for MP4 bitstream parsing */
+ struct BITSTREAM *pBs = 0;
+
+ /* allocate the aac_decode struct */
+ pDec = (aac_decode*) fpMalloc(pUserMem, sizeof(aac_decode));
+ if (pDec == HXNULL) {
+ return HXR_OUTOFMEMORY;
+ }
+
+ memset(pDec, 0, sizeof(aac_decode));
+ *pDecode = (void *)pDec;
+
+ /* allocate the frame info struct */
+ pDec->pFrameInfo = fpMalloc(pUserMem, sizeof(AACFrameInfo));
+ frameInfo = (AACFrameInfo *) pDec->pFrameInfo;
+ /* allocate the decoder backend instance */
+ pDec->pDecoder = AACInitDecoder(1);
+ if (pDec->pFrameInfo == HXNULL || pDec->pDecoder == HXNULL) {
+ return HXR_OUTOFMEMORY;
+ }
+
+ /* save the stream info and init data we'll need later */
+ pDec->ulNumChannels = (UINT32)pStreamInfo->usNumChannels;
+ pDec->ulBlockSize = pStreamInfo->ulGranularity;
+ pDec->ulFrameSize = pStreamInfo->ulBitsPerFrame;
+ pDec->ulFramesPerBlock = pDec->ulBlockSize / pDec->ulFrameSize;
+ /* output frame size is doubled for safety in case of implicit SBR */
+ pDec->ulSamplesPerFrame = 1024 * pStreamInfo->usNumChannels * 2;
+ pDec->ulSampleRateCore = pStreamInfo->ulSampleRate;
+ pDec->ulSampleRateOut = pStreamInfo->ulActualRate;
+ if (pStreamInfo->ulOpaqueDataSize < 1) {
+ return HXR_FAIL; /* insufficient config data */
+ }
+
+ /* get the config data */
+ pData = (UCHAR *)pStreamInfo->pOpaqueData;
+ cfgType = pData[0];
+ inBuf = pData + 1;
+ numBytes = pStreamInfo->ulOpaqueDataSize - 1;
+
+ if (cfgType == 1) { /* ADTS Frame */
+ /* allocate temp buffer for decoding first ADTS frame */
+ temp = (INT16 *)fpMalloc(pUserMem, sizeof(INT16) * pDec->ulSamplesPerFrame);
+ if (temp == HXNULL) {
+ return HXR_OUTOFMEMORY;
+ } else {
+ /* decode ADTS frame from opaque data to get config data */
+ result = AACDecode(pDec->pDecoder, &inBuf, (INT32*)&numBytes, temp);
+ /* free the temp buffer */
+ fpFree(pUserMem, temp);
+ }
+
+ if (result == HXR_OK) {
+ /* get the config data struct from the decoder */
+ AACGetLastFrameInfo(pDec->pDecoder, frameInfo);
+
+ pDec->ulNumChannels = frameInfo->nChans;
+ pDec->ulSamplesPerFrame = frameInfo->outputSamps;
+ pDec->ulSampleRateCore = frameInfo->sampRateCore;
+ pDec->ulSampleRateOut = frameInfo->sampRateOut;
+ pDec->bSBR = (pDec->ulSampleRateCore != pDec->ulSampleRateOut);
+ }
+ } else if (cfgType == 2) { /* MP4 Audio Specific Config Data */
+ numBits = numBytes * 8;
+
+ if (newBitstream(&pBs, numBits, pUserMem, fpMalloc)) {
+ return HXR_FAIL;
+ }
+
+ feedBitstream(pBs, (const UCHAR *)inBuf, numBits);
+ setAtBitstream(pBs, 0, 1);
+ result = ga_config_get_data(pBs, &configData);
+ deleteBitstream(pBs, pUserMem, fpFree);
+ if (result != HXR_OK) { /* config data error */
+ return HXR_FAIL;
+ }
+
+ pDec->ulNumChannels = configData.numChannels;
+ pDec->ulSampleRateCore = configData.samplingFrequency;
+ pDec->ulSampleRateOut = configData.extensionSamplingFrequency;
+ pDec->bSBR = configData.bSBR;
+
+ /* ulSamplesPerFrame is set to the maximum possible output length.
+ * The config data has the initial output length, which might
+ * be doubled once the first frame is handed in (if AAC+ is
+ * signalled implicitly).
+ */
+ pDec->ulSamplesPerFrame = 2 * configData.frameLength * configData.numChannels;
+
+ /* setup decoder to handle raw data blocks */
+ frameInfo->nChans = pDec->ulNumChannels;
+ frameInfo->sampRateCore = pDec->ulSampleRateCore;
+
+ /* see MPEG4 spec for index of each object type */
+ if (configData.audioObjectType == 2) {
+ frameInfo->profile = AAC_PROFILE_LC;
+ } else if (configData.audioObjectType == 1) {
+ frameInfo->profile = AAC_PROFILE_MP;
+ } else if (configData.audioObjectType == 3) {
+ frameInfo->profile = AAC_PROFILE_SSR;
+ } else {
+ frameInfo->profile = AAC_PROFILE_LC; /* don't know - assume LC */
+ }
+ frameInfo->audio_send_by_frame = 0;
+ } else { /* unsupported config type */
+ return HXR_FAIL;
+ }
+
+ /* make certain that all the channels can be handled */
+ if (pDec->ulNumChannels > AAC_MAX_NCHANS) {
+ return HXR_UNSUPPORTED_AUDIO;
+ }
+
+ /* set the channel mask - custom maps not supported */
+ switch (pDec->ulNumChannels) {
+ case 1:
+ pDec->ulChannelMask = 0x00004; /* FC */
+ case 2:
+ pDec->ulChannelMask = 0x00003; /* FL,FR */
+ case 3:
+ pDec->ulChannelMask = 0x00007; /* FL,FR,FC */
+ case 4:
+ pDec->ulChannelMask = 0x00107; /* FL,FR,FC,BC */
+ case 5:
+ pDec->ulChannelMask = 0x00037; /* FL,FR,FC,BL,BR */
+ case 6:
+ pDec->ulChannelMask = 0x0003F; /* FL,FR,FC,LF,BL,BR */
+ default:
+ pDec->ulChannelMask = 0xFFFFF; /* Unknown */
+ }
+
+ /* set the delay samples */
+ pDec->ulDelayRemaining = pDec->ulSamplesPerFrame;
+
+ /* set decoder to handle raw data blocks */
+ AACSetRawBlockParams(pDec->pDecoder, 0, frameInfo);
+
+
+ return HXR_OK;
+}
+
+HX_RESULT
+aac_decode_reset(void* pDecode,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut)
+{
+ aac_decode* pDec = (aac_decode*) pDecode;
+ AACFlushCodec(pDec->pDecoder);
+ *pNumSamplesOut = 0;
+ pDec->ulSamplesToConceal = 0;
+
+ /* reset the delay compensation */
+ pDec->ulDelayRemaining = pDec->ulSamplesPerFrame;
+
+ return HXR_OK;
+}
+
+HX_RESULT
+aac_decode_conceal(void* pDecode,
+ UINT32 ulNumSamples)
+{
+ aac_decode* pDec = (aac_decode*) pDecode;
+ if (pDec->bSBR) {
+ pDec->ulSamplesToConceal = (ulNumSamples + 2 * AAC_MAX_NSAMPS - 1) / (2 * AAC_MAX_NSAMPS);
+ } else {
+ pDec->ulSamplesToConceal = (ulNumSamples + AAC_MAX_NSAMPS - 1) / AAC_MAX_NSAMPS;
+ }
+
+ return HXR_OK;
+}
+
+HX_RESULT
+aac_decode_decode(void* pDecode,
+ UINT8* pData,
+ UINT32 ulNumBytes,
+ UINT32* pNumBytesConsumed,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut,
+ UINT32 ulFlags,
+ UINT32 ulTimeStamp)
+{
+ HX_RESULT retVal = HXR_FAIL;
+ aac_decode* pDec = (aac_decode*) pDecode;
+ AACFrameInfo *frameInfo = pDec->pFrameInfo;
+ UINT32 lostFlag, maxSamplesOut;
+ UINT32 ulNumBytesRemaining;
+ UINT8* inBuf = pData;
+ UINT16* outBuf = pSamplesOut;
+
+ ulNumBytesRemaining = ulNumBytes;
+ *pNumBytesConsumed = 0;
+ *pNumSamplesOut = 0;
+
+ lostFlag = !(ulFlags & 1);
+
+ if (pDec->ulSamplesToConceal || lostFlag) {
+ if (lostFlag) { /* conceal one frame */
+ *pNumSamplesOut = pDec->ulSamplesPerFrame;
+ } else {
+ maxSamplesOut = pDec->ulSamplesPerFrame * pDec->ulFramesPerBlock;
+ *pNumSamplesOut = maxSamplesOut;
+ if (pDec->ulSamplesToConceal < maxSamplesOut) {
+ *pNumSamplesOut = pDec->ulSamplesToConceal;
+ }
+ pDec->ulSamplesToConceal -= *pNumSamplesOut;
+ }
+ /* just fill with silence */
+ memset(pSamplesOut, 0, *pNumSamplesOut * sizeof(INT16));
+ AACFlushCodec(pDec->pDecoder);
+
+ *pNumBytesConsumed = 0;
+ return HXR_OK;
+ }
+
+ retVal = AACDecode(pDec->pDecoder, &inBuf,
+ (INT32*)&ulNumBytesRemaining, (INT16*)outBuf);
+ if (retVal == ERR_AAC_NONE) {
+ AACGetLastFrameInfo(pDec->pDecoder, frameInfo);
+ AACReorderPCMChannels((INT16*)outBuf, frameInfo->outputSamps, frameInfo->nChans);
+ pDec->ulSampleRateCore = frameInfo->sampRateCore;
+ pDec->ulSampleRateOut = frameInfo->sampRateOut;
+ pDec->ulNumChannels = frameInfo->nChans;
+ *pNumSamplesOut = frameInfo->outputSamps;
+ *pNumBytesConsumed = ulNumBytes - ulNumBytesRemaining;
+ retVal = HXR_OK;
+ } else if (retVal == ERR_AAC_INDATA_UNDERFLOW) {
+ retVal = HXR_NO_DATA;
+ } else {
+ retVal = HXR_FAIL;
+ }
+
+ /* Zero out invalid output samples */
+ if (*pNumSamplesOut == 0) {
+ /* protect consumer ears by zeroing the output buffer */
+ memset(pSamplesOut, 0, pDec->ulSamplesPerFrame * sizeof(UINT16));
+ } else if (pDec->ulDelayRemaining > 0) { /* delay samples */
+ if (pDec->ulDelayRemaining >= *pNumSamplesOut) {
+ pDec->ulDelayRemaining -= *pNumSamplesOut;
+ *pNumSamplesOut = 0;
+ } else {
+ *pNumSamplesOut -= pDec->ulDelayRemaining;
+ memmove(pSamplesOut, pSamplesOut + pDec->ulDelayRemaining, *pNumSamplesOut);
+ pDec->ulDelayRemaining = 0;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT
+aac_decode_getmaxsize(void* pDecode,
+ UINT32* pNumSamples)
+{
+ aac_decode* pDec = (aac_decode *)pDecode;
+ *pNumSamples = pDec->ulSamplesPerFrame * pDec->ulFramesPerBlock;
+
+ return HXR_OK;
+}
+
+HX_RESULT
+aac_decode_getchannels(void* pDecode,
+ UINT32* pNumChannels)
+{
+ aac_decode* pDec = (aac_decode *)pDecode;
+ *pNumChannels = pDec->ulNumChannels;
+
+ return HXR_OK;
+}
+
+HX_RESULT
+aac_decode_getchannelmask(void* pDecode,
+ UINT32* pChannelMask)
+{
+ aac_decode* pDec = (aac_decode *)pDecode;
+ *pChannelMask = pDec->ulChannelMask;
+
+ return HXR_OK;
+}
+
+HX_RESULT
+aac_decode_getrate(void* pDecode,
+ UINT32* pSampleRate)
+{
+ aac_decode* pDec = (aac_decode *)pDecode;
+ *pSampleRate = pDec->ulSampleRateOut;
+
+ return HXR_OK;
+}
+
+HX_RESULT
+aac_decode_getdelay(void* pDecode,
+ UINT32* pNumSamples)
+{
+ aac_decode* pDec = (aac_decode *)pDecode;
+ /* delay compensation is handled internally */
+ *pNumSamples = 0;
+
+ return HXR_OK;
+}
+
+HX_RESULT
+aac_decode_close(void* pDecode,
+ void* pUserMem,
+ rm_free_func_ptr fpFree)
+{
+ aac_decode* pDec = (aac_decode *)pDecode;
+ /* free the aac decoder */
+ if (pDec->pDecoder) {
+ AACFreeDecoder(pDec->pDecoder);
+ pDec->pDecoder = HXNULL;
+ }
+ /* free the frame info struct */
+ if (pDec->pFrameInfo) {
+ fpFree(pUserMem, pDec->pFrameInfo);
+ pDec->pFrameInfo = HXNULL;
+ }
+ /* free the aac backend */
+ fpFree(pUserMem, pDec);
+ pDec = HXNULL;
+
+ return HXR_OK;
+}
diff --git a/audio_codec/libraac/aac_reorder.c b/audio_codec/libraac/aac_reorder.c
new file mode 100644
index 0000000..1a11813
--- a/dev/null
+++ b/audio_codec/libraac/aac_reorder.c
@@ -0,0 +1,85 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aac_reorder.c,v 1.1.1.1.2.1 2005/05/04 18:21:58 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "aac_reorder.h"
+
+void AACReorderPCMChannels(INT16 *pcmBuf, int nSamps, int nChans)
+{
+ int i, ch, chanMap[6];
+ INT16 tmpBuf[6];
+
+ switch (nChans) {
+ case 3:
+ chanMap[0] = 1; /* L */
+ chanMap[1] = 2; /* R */
+ chanMap[2] = 0; /* C */
+ break;
+ case 4:
+ chanMap[0] = 1; /* L */
+ chanMap[1] = 2; /* R */
+ chanMap[2] = 0; /* C */
+ chanMap[3] = 3; /* S */
+ break;
+ case 5:
+ chanMap[0] = 1; /* L */
+ chanMap[1] = 2; /* R */
+ chanMap[2] = 0; /* C */
+ chanMap[3] = 3; /* LS */
+ chanMap[4] = 4; /* RS */
+ break;
+ case 6:
+ chanMap[0] = 1; /* L */
+ chanMap[1] = 2; /* R */
+ chanMap[2] = 0; /* C */
+ chanMap[3] = 5; /* LFE */
+ chanMap[4] = 3; /* LS */
+ chanMap[5] = 4; /* RS */
+ break;
+ default:
+ return;
+ }
+
+ for (i = 0; i < nSamps; i += nChans) {
+ for (ch = 0; ch < nChans; ch++) {
+ tmpBuf[ch] = pcmBuf[chanMap[ch]];
+ }
+ for (ch = 0; ch < nChans; ch++) {
+ pcmBuf[ch] = tmpBuf[ch];
+ }
+ pcmBuf += nChans;
+ }
+}
diff --git a/audio_codec/libraac/aac_reorder.h b/audio_codec/libraac/aac_reorder.h
new file mode 100644
index 0000000..e4bbf60
--- a/dev/null
+++ b/audio_codec/libraac/aac_reorder.h
@@ -0,0 +1,53 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aac_reorder.h,v 1.1.1.1.2.1 2005/05/04 18:21:58 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef AAC_REORDER_H
+#define AAC_REORDER_H
+
+#include "include/helix_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ void AACReorderPCMChannels(INT16 *pcmBuf, int nSamps, int nChans);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef AAC_REORDER_H */
diff --git a/audio_codec/libraac/aaccommon.h b/audio_codec/libraac/aaccommon.h
new file mode 100644
index 0000000..85f1a91
--- a/dev/null
+++ b/audio_codec/libraac/aaccommon.h
@@ -0,0 +1,200 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aaccommon.h,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * aaccommon.h - implementation-independent API's, datatypes, and definitions
+ **************************************************************************************/
+
+#ifndef _AACCOMMON_H
+#define _AACCOMMON_H
+
+#include "aacdec.h"
+#include "statname.h"
+
+/* 12-bit syncword */
+#define SYNCWORDH 0xff
+#define SYNCWORDL 0xf0
+
+#define SYNCWORD0 0x67
+#define SYNCWORD1 0x89
+
+#define MAX_NCHANS_ELEM 2 /* max number of channels in any single bitstream element (SCE,CPE,CCE,LFE) */
+
+#define ADTS_HEADER_BYTES 7
+#define NUM_SAMPLE_RATES 12
+#define NUM_DEF_CHAN_MAPS 8
+#define NUM_ELEMENTS 8
+#define MAX_NUM_PCE_ADIF 16
+
+#define MAX_WIN_GROUPS 8
+#define MAX_SFB_SHORT 15
+#define MAX_SF_BANDS (MAX_SFB_SHORT*MAX_WIN_GROUPS) /* worst case = 15 sfb's * 8 windows for short block */
+#define MAX_MS_MASK_BYTES ((MAX_SF_BANDS + 7) >> 3)
+#define MAX_PRED_SFB 41
+#define MAX_TNS_FILTERS 8
+#define MAX_TNS_COEFS 60
+#define MAX_TNS_ORDER 20
+#define MAX_PULSES 4
+#define MAX_GAIN_BANDS 3
+#define MAX_GAIN_WIN 8
+#define MAX_GAIN_ADJUST 7
+
+#define NSAMPS_LONG 1024
+#define NSAMPS_SHORT 128
+
+#define NUM_SYN_ID_BITS 3
+#define NUM_INST_TAG_BITS 4
+
+#define EXT_SBR_DATA 0x0d
+#define EXT_SBR_DATA_CRC 0x0e
+
+#define IS_ADIF(p) ((p)[0] == 'A' && (p)[1] == 'D' && (p)[2] == 'I' && (p)[3] == 'F')
+#define GET_ELE_ID(p) ((AACElementID)(*(p) >> (8-NUM_SYN_ID_BITS)))
+
+/* AAC file format */
+enum {
+ AAC_FF_Unknown = 0, /* should be 0 on init */
+
+ AAC_FF_ADTS = 1,
+ AAC_FF_ADIF = 2,
+ AAC_FF_RAW = 3
+
+};
+
+/* syntactic element type */
+enum {
+ AAC_ID_INVALID = -1,
+
+ AAC_ID_SCE = 0,
+ AAC_ID_CPE = 1,
+ AAC_ID_CCE = 2,
+ AAC_ID_LFE = 3,
+ AAC_ID_DSE = 4,
+ AAC_ID_PCE = 5,
+ AAC_ID_FIL = 6,
+ AAC_ID_END = 7
+};
+
+typedef struct _AACDecInfo {
+ /* pointers to platform-specific state information */
+ void *psInfoBase; /* baseline MPEG-4 LC decoding */
+ void *psInfoSBR; /* MPEG-4 SBR decoding */
+
+ /* raw decoded data, before rounding to 16-bit PCM (for postprocessing such as SBR) */
+ void *rawSampleBuf[AAC_MAX_NCHANS];
+ int rawSampleBytes;
+ int rawSampleFBits;
+
+ /* fill data (can be used for processing SBR or other extensions) */
+ unsigned char *fillBuf;
+ int fillCount;
+ int fillExtType;
+
+ /* block information */
+ int prevBlockID;
+ int currBlockID;
+ int currInstTag;
+ int sbDeinterleaveReqd[MAX_NCHANS_ELEM];
+ int adtsBlocksLeft;
+
+ /* user-accessible info */
+ int bitRate;
+ int nChans;
+ int sampRate;
+ int profile;
+ int format;
+ int sbrEnabled;
+ int tnsUsed;
+ int pnsUsed;
+ int frameCount;
+ int byteParsed;
+ int sampleDecoded;
+ unsigned audio_send_by_frame;
+} AACDecInfo;
+
+/* decoder functions which must be implemented for each platform */
+AACDecInfo *AllocateBuffers(void);
+void FreeBuffers(AACDecInfo *aacDecInfo);
+void ClearBuffer(void *buf, int nBytes);
+
+int UnpackADTSHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail);
+int GetADTSChannelMapping(AACDecInfo *aacDecInfo, unsigned char *buf, int bitOffset, int bitsAvail);
+int UnpackADIFHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail);
+int SetRawBlockParams(AACDecInfo *aacDecInfo, int copyLast, int nChans, int sampRate, int profile);
+int PrepareRawBlock(AACDecInfo *aacDecInfo);
+int FlushCodec(AACDecInfo *aacDecInfo);
+
+int DecodeNextElement(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail);
+int DecodeNoiselessData(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail, int ch);
+
+int Dequantize(AACDecInfo *aacDecInfo, int ch);
+int StereoProcess(AACDecInfo *aacDecInfo);
+int DeinterleaveShortBlocks(AACDecInfo *aacDecInfo, int ch);
+int PNS(AACDecInfo *aacDecInfo, int ch);
+int TNSFilter(AACDecInfo *aacDecInfo, int ch);
+int IMDCT(AACDecInfo *aacDecInfo, int ch, int chBase, short *outbuf);
+
+/* SBR specific functions */
+int InitSBR(AACDecInfo *aacDecInfo);
+void FreeSBR(AACDecInfo *aacDecInfo);
+int DecodeSBRBitstream(AACDecInfo *aacDecInfo, int chBase);
+int DecodeSBRData(AACDecInfo *aacDecInfo, int chBase, short *outbuf);
+int FlushCodecSBR(AACDecInfo *aacDecInfo);
+
+/* aactabs.c - global ROM tables */
+extern const int sampRateTab[NUM_SAMPLE_RATES];
+extern const int predSFBMax[NUM_SAMPLE_RATES];
+extern const int channelMapTab[NUM_DEF_CHAN_MAPS];
+extern const int elementNumChans[NUM_ELEMENTS];
+extern const unsigned char sfBandTotalShort[NUM_SAMPLE_RATES];
+extern const unsigned char sfBandTotalLong[NUM_SAMPLE_RATES];
+extern const int sfBandTabShortOffset[NUM_SAMPLE_RATES];
+extern const short sfBandTabShort[76];
+extern const int sfBandTabLongOffset[NUM_SAMPLE_RATES];
+extern const short sfBandTabLong[325];
+extern const int tnsMaxBandsShortOffset[AAC_NUM_PROFILES];
+extern const unsigned char tnsMaxBandsShort[2 * NUM_SAMPLE_RATES];
+extern const unsigned char tnsMaxOrderShort[AAC_NUM_PROFILES];
+extern const int tnsMaxBandsLongOffset[AAC_NUM_PROFILES];
+extern const unsigned char tnsMaxBandsLong[2 * NUM_SAMPLE_RATES];
+extern const unsigned char tnsMaxOrderLong[AAC_NUM_PROFILES];
+
+#endif /* _AACCOMMON_H */
diff --git a/audio_codec/libraac/aacdec.c b/audio_codec/libraac/aacdec.c
new file mode 100644
index 0000000..aa553a1
--- a/dev/null
+++ b/audio_codec/libraac/aacdec.c
@@ -0,0 +1,607 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aacdec.c,v 1.1 2005/02/26 01:47:31 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * aacdec.c - platform-independent top level decoder API
+ **************************************************************************************/
+#include "aaccommon.h"
+#include "bitstream.h"
+//#include <core/dsp.h>
+#include <stdio.h>
+#include "aacdec.h"
+
+extern FILE*fpdbg;
+extern void RefillBitStream();
+extern void set_timestamp_len(unsigned val);
+extern void set_timestamp(unsigned val);
+
+int aac_need_align_bitstream = 0;
+int AACDataSource = 1;
+
+/**************************************************************************************
+ * Function: AACInitDecoder
+ *
+ * Description: allocate memory for platform-specific data
+ * clear all the user-accessible fields
+ * initialize SBR decoder if enabled
+ *
+ * Inputs: none
+ *
+ * Outputs: none
+ *
+ * Return: handle to AAC decoder instance, 0 if malloc fails
+ **************************************************************************************/
+HAACDecoder AACInitDecoder(int DataSource)
+{
+ AACDecInfo *aacDecInfo;
+
+ AACDataSource = DataSource;
+ aacDecInfo = AllocateBuffers();
+ if (!aacDecInfo) {
+ return 0;
+ }
+
+#ifdef AAC_ENABLE_SBR
+ if (InitSBR(aacDecInfo)) {
+ AACFreeDecoder(aacDecInfo);
+ return 0;
+ }
+#endif
+
+ if (AACDataSource == 0) {
+ InitBitStream();
+ }
+ return (HAACDecoder)aacDecInfo;
+}
+
+/**************************************************************************************
+ * Function: AACFreeDecoder
+ *
+ * Description: free platform-specific data allocated by AACInitDecoder
+ * free SBR decoder if enabled
+ *
+ * Inputs: valid AAC decoder instance pointer (HAACDecoder)
+ *
+ * Outputs: none
+ *
+ * Return: none
+ **************************************************************************************/
+void AACFreeDecoder(HAACDecoder hAACDecoder)
+{
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+
+ if (!aacDecInfo) {
+ return;
+ }
+
+#ifdef AAC_ENABLE_SBR
+ FreeSBR(aacDecInfo);
+#endif
+ FreeBuffers(aacDecInfo);
+}
+
+/**************************************************************************************
+ * Function: AACFindSyncWord
+ *
+ * Description: locate the next byte-alinged sync word in the raw AAC stream
+ *
+ * Inputs: buffer to search for sync word
+ * max number of bytes to search in buffer
+ *
+ * Outputs: none
+ *
+ * Return: offset to first sync word (bytes from start of buf)
+ * -1 if sync not found after searching nBytes
+ **************************************************************************************/
+int AACFindSyncWord(unsigned char *buf, int nBytes)
+{
+ int sync0 = 0;
+ int sync1 = 0;
+ int i;
+
+ if (AACDataSource == 0) {
+ while (1) {
+ sync0 = GetBits(0, 8);
+ if (sync0 != 0xff) {
+ continue;
+ }
+ sync1 = GetBits(0, 4);
+ if (sync1 != 0xf) {
+ GetBits(0, 4);
+ continue;
+ }
+ return 0;
+ }
+ return -1;
+ } else {
+ /* find byte-aligned syncword (12 bits = 0xFFF) */
+ for (i = 0; i < nBytes - 1; i++) {
+ if ((buf[i + 0] & SYNCWORDH) == SYNCWORDH && (buf[i + 1] & SYNCWORDL) == SYNCWORDL) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+}
+
+int AACFindSyncWordRaw(unsigned char *buf, int nBytes)
+{
+ int sync0 = 0;
+ int sync1 = 0;
+
+ if (AACDataSource == 0) {
+ while (1) {
+ sync0 = GetBits(0, 8);
+ if (sync0 != SYNCWORD0) {
+ continue;
+ }
+ sync1 = GetBits(0, 8);
+ if (sync1 != SYNCWORD1) {
+ continue;
+ }
+ RefillBitStream();
+ return 0;
+ }
+ }
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: AACGetLastFrameInfo
+ *
+ * Description: get info about last AAC frame decoded (number of samples decoded,
+ * sample rate, bit rate, etc.)
+ *
+ * Inputs: valid AAC decoder instance pointer (HAACDecoder)
+ * pointer to AACFrameInfo struct
+ *
+ * Outputs: filled-in AACFrameInfo struct
+ *
+ * Return: none
+ *
+ * Notes: call this right after calling AACDecode()
+ **************************************************************************************/
+void AACGetLastFrameInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo)
+{
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+
+ if (!aacDecInfo) {
+ aacFrameInfo->format = 0;
+ aacFrameInfo->bitRate = 0;
+ aacFrameInfo->nChans = 0;
+ aacFrameInfo->sampRateCore = 0;
+ aacFrameInfo->sampRateOut = 0;
+ aacFrameInfo->bitsPerSample = 0;
+ aacFrameInfo->outputSamps = 0;
+ aacFrameInfo->profile = 0;
+ aacFrameInfo->tnsUsed = 0;
+ aacFrameInfo->pnsUsed = 0;
+ } else {
+ aacFrameInfo->format = aacDecInfo->format;
+ aacFrameInfo->nChans = aacDecInfo->nChans;
+ aacFrameInfo->sampRateCore = aacDecInfo->sampRate;
+ aacFrameInfo->sampRateOut = aacDecInfo->sampRate * (aacDecInfo->sbrEnabled ? 2 : 1);
+ aacFrameInfo->bitsPerSample = 16;
+ aacFrameInfo->outputSamps = aacDecInfo->nChans * AAC_MAX_NSAMPS * (aacDecInfo->sbrEnabled ? 2 : 1);
+ aacFrameInfo->profile = aacDecInfo->profile;
+ aacFrameInfo->tnsUsed = aacDecInfo->tnsUsed;
+ aacFrameInfo->pnsUsed = aacDecInfo->pnsUsed;
+ }
+}
+
+void AACGetDecoderInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo)
+{
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+
+ if (aacDecInfo) {
+ aacFrameInfo->format = aacDecInfo->format;
+ aacFrameInfo->nChans = aacDecInfo->nChans;
+ aacFrameInfo->sampRateCore = aacDecInfo->sampRate;
+ aacFrameInfo->sampRateOut = aacDecInfo->sampRate * (aacDecInfo->sbrEnabled ? 2 : 1);
+ aacFrameInfo->bitsPerSample = 16;
+ aacFrameInfo->outputSamps = aacDecInfo->nChans * AAC_MAX_NSAMPS * (aacDecInfo->sbrEnabled ? 2 : 1);
+ aacFrameInfo->profile = aacDecInfo->profile;
+ aacFrameInfo->tnsUsed = aacDecInfo->tnsUsed;
+ aacFrameInfo->pnsUsed = aacDecInfo->pnsUsed;
+ aacFrameInfo->total_byte_parsed = aacDecInfo->byteParsed;
+ aacFrameInfo->total_sample_decoded = aacDecInfo->sampleDecoded;
+
+ if (aacDecInfo->bitRate) {
+ aacFrameInfo->bitRate = aacDecInfo->bitRate;
+ } else if (aacDecInfo->sampleDecoded > 0) {
+ aacFrameInfo->bitRate = (int)(((float)(aacDecInfo->byteParsed)) / ((float)aacDecInfo->sampleDecoded / (float)aacFrameInfo->sampRateOut)) << 3;
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: AACSetRawBlockParams
+ *
+ * Description: set internal state variables for decoding a stream of raw data blocks
+ *
+ * Inputs: valid AAC decoder instance pointer (HAACDecoder)
+ * flag indicating source of parameters
+ * AACFrameInfo struct, with the members nChans, sampRate, and profile
+ * optionally filled-in
+ *
+ * Outputs: updated codec state
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: if copyLast == 1, then the codec sets up its internal state (for
+ * decoding raw blocks) based on previously-decoded ADTS header info
+ * if copyLast == 0, then the codec uses the values passed in
+ * aacFrameInfo to configure its internal state (useful when the
+ * source is MP4 format, for example)
+ **************************************************************************************/
+int AACSetRawBlockParams(HAACDecoder hAACDecoder, int copyLast, AACFrameInfo *aacFrameInfo)
+{
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+
+ if (!aacDecInfo) {
+ return ERR_AAC_NULL_POINTER;
+ }
+
+ aacDecInfo->format = AAC_FF_RAW;
+ aacDecInfo->audio_send_by_frame = aacFrameInfo->audio_send_by_frame;
+ if (copyLast) {
+ return SetRawBlockParams(aacDecInfo, 1, 0, 0, 0);
+ } else {
+ return SetRawBlockParams(aacDecInfo, 0, aacFrameInfo->nChans, aacFrameInfo->sampRateCore, aacFrameInfo->profile);
+ }
+}
+
+/**************************************************************************************
+ * Function: AACFlushCodec
+ *
+ * Description: flush internal codec state (after seeking, for example)
+ *
+ * Inputs: valid AAC decoder instance pointer (HAACDecoder)
+ *
+ * Outputs: updated state variables in aacDecInfo
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int AACFlushCodec(HAACDecoder hAACDecoder)
+{
+ int ch;
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+
+ if (!aacDecInfo) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ /* reset common state variables which change per-frame
+ * don't touch state variables which are (usually) constant for entire clip
+ * (nChans, sampRate, profile, format, sbrEnabled)
+ */
+ aacDecInfo->prevBlockID = AAC_ID_INVALID;
+ aacDecInfo->currBlockID = AAC_ID_INVALID;
+ aacDecInfo->currInstTag = -1;
+ for (ch = 0; ch < MAX_NCHANS_ELEM; ch++) {
+ aacDecInfo->sbDeinterleaveReqd[ch] = 0;
+ }
+ aacDecInfo->adtsBlocksLeft = 0;
+ aacDecInfo->tnsUsed = 0;
+ aacDecInfo->pnsUsed = 0;
+
+ /* reset internal codec state (flush overlap buffers, etc.) */
+ FlushCodec(aacDecInfo);
+#ifdef AAC_ENABLE_SBR
+ FlushCodecSBR(aacDecInfo);
+#endif
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: AACDecode
+ *
+ * Description: decode AAC frame
+ *
+ * Inputs: valid AAC decoder instance pointer (HAACDecoder)
+ * double pointer to buffer of AAC data
+ * pointer to number of valid bytes remaining in inbuf
+ * pointer to outbuf, big enough to hold one frame of decoded PCM samples
+ * (outbuf must be double-sized if SBR enabled)
+ *
+ * Outputs: PCM data in outbuf, interleaved LRLRLR... if stereo
+ * number of output samples = 1024 per channel (2048 if SBR enabled)
+ * updated inbuf pointer
+ * updated bytesLeft
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: inbuf pointer and bytesLeft are not updated until whole frame is
+ * successfully decoded, so if ERR_AAC_INDATA_UNDERFLOW is returned
+ * just call AACDecode again with more data in inbuf
+ **************************************************************************************/
+int AACDecode(HAACDecoder hAACDecoder, unsigned char **inbuf, int *bytesLeft, short *outbuf)
+{
+ int err, offset, bitOffset, bitsAvail;
+ int ch, baseChan, baseChanSBR, elementChans;
+ unsigned char *inptr;
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+#ifdef AAC_ENABLE_SBR
+ int elementChansSBR;
+#endif
+ int data;
+ unsigned char buf[4];
+
+ if (AACDataSource == 0) {
+ if (aac_need_align_bitstream) {
+ ByteAlignBitstream(0);
+ aac_need_align_bitstream = 0;
+ }
+ }
+ if (!aacDecInfo) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ /* make local copies (see "Notes" above) */
+ if (AACDataSource == 1) {
+ inptr = *inbuf;
+ bitOffset = 0;
+ bitsAvail = (*bytesLeft) << 3;
+ } else {
+ data = GetBitsNoAdvance(NULL, 32);
+ buf[0] = data >> 24;
+ buf[1] = data >> 16;
+ buf[2] = data >> 8;
+ buf[3] = data;
+ if (buf[0] == 'A' && buf[1] == 'P' && buf[2] == 'T' && buf[3] == 'S') {
+ register unsigned char tmp0, tmp1, tmp2, tmp3;
+ AdvanceBitstream(NULL, 16); // skip "APTS"
+ AdvanceBitstream(NULL, 16);
+
+ // timestamp
+ tmp0 = GetBits(NULL, 8);
+ tmp1 = GetBits(NULL, 8);
+ tmp2 = GetBits(NULL, 8);
+ tmp3 = GetBits(NULL, 8);
+ set_timestamp((tmp0 << 24) | (tmp1 << 16) | (tmp2 << 8) | (tmp3));
+
+ // length
+ tmp0 = GetBits(NULL, 8);
+ tmp1 = GetBits(NULL, 8);
+ tmp2 = GetBits(NULL, 8);
+ tmp3 = GetBits(NULL, 8);
+ set_timestamp_len((tmp0 << 24) | (tmp1 << 16) | (tmp2 << 8) | (tmp3));
+
+ data = GetBitsNoAdvance(NULL, 32);
+ buf[0] = data >> 24;
+ buf[1] = data >> 16;
+ buf[2] = data >> 8;
+ buf[3] = data;
+ }
+ inptr = buf;
+ bitOffset = 0;
+ bitsAvail = 32;
+ }
+ /* first time through figure out what the file format is */
+ if (aacDecInfo->format == AAC_FF_Unknown) {
+ if (AACDataSource == 1) {
+ if (bitsAvail < 32) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+ if (IS_ADIF(inptr)) {
+ /* unpack ADIF header */
+ aacDecInfo->format = AAC_FF_ADIF;
+ err = UnpackADIFHeader(aacDecInfo, &inptr, &bitOffset, &bitsAvail);
+ if (err) {
+ return err;
+ }
+ } else {
+ /* assume ADTS by default */
+ aacDecInfo->format = AAC_FF_ADTS;
+ }
+ }
+ /* if ADTS, search for start of next frame */
+ if (aacDecInfo->format == AAC_FF_ADTS) {
+ /* can have 1-4 raw data blocks per ADTS frame (header only present for first one) */
+ if (aacDecInfo->adtsBlocksLeft == 0) {
+ offset = AACFindSyncWord(inptr, bitsAvail >> 3);
+ if (AACDataSource == 1) {
+ if (offset < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ inptr += offset;
+ bitsAvail -= (offset << 3);
+ }
+ err = UnpackADTSHeader(aacDecInfo, &inptr, &bitOffset, &bitsAvail);
+ if (err) {
+ return err;
+ }
+
+ if (aacDecInfo->nChans == -1) {
+ /* figure out implicit channel mapping if necessary */
+ err = GetADTSChannelMapping(aacDecInfo, inptr, bitOffset, bitsAvail);
+ if (err) {
+ return err;
+ }
+ }
+ }
+ aacDecInfo->adtsBlocksLeft--;
+ } else if (aacDecInfo->format == AAC_FF_RAW) {
+ if (AACDataSource == 0) {
+ /* skip raw header*/
+ if (aacDecInfo->audio_send_by_frame) {
+ offset = AACFindSyncWordRaw(inptr, bitsAvail >> 3);
+ }
+ }
+ err = PrepareRawBlock(aacDecInfo);
+ if (err) {
+ return err;
+ }
+ }
+
+ /* check for valid number of channels */
+ if (aacDecInfo->nChans > AAC_MAX_NCHANS || aacDecInfo->nChans <= 0) {
+ //printk("AAC ERR: ERR_AAC_NCHANS_TOO_HIGH\n");
+ return ERR_AAC_NCHANS_TOO_HIGH;
+ }
+
+ /* will be set later if active in this frame */
+ aacDecInfo->tnsUsed = 0;
+ aacDecInfo->pnsUsed = 0;
+
+ bitOffset = 0;
+ baseChan = 0;
+ baseChanSBR = 0;
+ do {
+ /* parse next syntactic element */
+ err = DecodeNextElement(aacDecInfo, &inptr, &bitOffset, &bitsAvail);
+ if (err) {
+ return err;
+ }
+
+ elementChans = elementNumChans[aacDecInfo->currBlockID];
+ if (baseChan + elementChans > AAC_MAX_NCHANS) {
+ return ERR_AAC_NCHANS_TOO_HIGH;
+ }
+
+ /* noiseless decoder and dequantizer */
+ for (ch = 0; ch < elementChans; ch++) {
+ err = DecodeNoiselessData(aacDecInfo, &inptr, &bitOffset, &bitsAvail, ch);
+ if (err) {
+ return err;
+ }
+
+ if (Dequantize(aacDecInfo, ch)) {
+ return ERR_AAC_DEQUANT;
+ }
+ }
+
+ /* mid-side and intensity stereo */
+ if (aacDecInfo->currBlockID == AAC_ID_CPE) {
+ if (StereoProcess(aacDecInfo)) {
+ return ERR_AAC_STEREO_PROCESS;
+ }
+ }
+
+ /* PNS, TNS, inverse transform */
+ for (ch = 0; ch < elementChans; ch++) {
+ if (PNS(aacDecInfo, ch)) {
+ return ERR_AAC_PNS;
+ }
+
+ if (aacDecInfo->sbDeinterleaveReqd[ch]) {
+ /* deinterleave short blocks, if required */
+ if (DeinterleaveShortBlocks(aacDecInfo, ch)) {
+ return ERR_AAC_SHORT_BLOCK_DEINT;
+ }
+ aacDecInfo->sbDeinterleaveReqd[ch] = 0;
+ }
+
+ if (TNSFilter(aacDecInfo, ch)) {
+ return ERR_AAC_TNS;
+ }
+
+ if (IMDCT(aacDecInfo, ch, baseChan + ch, outbuf)) {
+ return ERR_AAC_IMDCT;
+ }
+ }
+
+#ifdef AAC_ENABLE_SBR
+ if (aacDecInfo->sbrEnabled && (aacDecInfo->currBlockID == AAC_ID_FIL || aacDecInfo->currBlockID == AAC_ID_LFE)) {
+ if (aacDecInfo->currBlockID == AAC_ID_LFE) {
+ elementChansSBR = elementNumChans[AAC_ID_LFE];
+ } else if (aacDecInfo->currBlockID == AAC_ID_FIL && (aacDecInfo->prevBlockID == AAC_ID_SCE || aacDecInfo->prevBlockID == AAC_ID_CPE)) {
+ elementChansSBR = elementNumChans[aacDecInfo->prevBlockID];
+ } else {
+ elementChansSBR = 0;
+ }
+
+ if (baseChanSBR + elementChansSBR > AAC_MAX_NCHANS) {
+ return ERR_AAC_SBR_NCHANS_TOO_HIGH;
+ }
+
+ /* parse SBR extension data if present (contained in a fill element) */
+ if (DecodeSBRBitstream(aacDecInfo, baseChanSBR)) {
+ return ERR_AAC_SBR_BITSTREAM;
+ }
+
+ /* apply SBR */
+ if (DecodeSBRData(aacDecInfo, baseChanSBR, outbuf)) {
+ return ERR_AAC_SBR_DATA;
+ }
+
+ baseChanSBR += elementChansSBR;
+ }
+#endif
+
+ baseChan += elementChans;
+ } while (aacDecInfo->currBlockID != AAC_ID_END);
+ if (AACDataSource == 1) {
+ /* byte align after each raw_data_block */
+ if (bitOffset) {
+ inptr++;
+ bitsAvail -= (8 - bitOffset);
+ bitOffset = 0;
+ if (bitsAvail < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+ } else {
+ //trace("align\n");
+ ByteAlignBitstream(0);
+ }
+
+ /* update pointers */
+ if (AACDataSource == 1) {
+ aacDecInfo->frameCount++;
+ aacDecInfo->byteParsed += inptr - *inbuf;
+ aacDecInfo->sampleDecoded += AAC_MAX_NSAMPS * (aacDecInfo->sbrEnabled ? 2 : 1);
+ *bytesLeft -= (inptr - *inbuf);
+ *inbuf = inptr;
+ } else {
+ aacDecInfo->frameCount++;
+ aacDecInfo->byteParsed = CalcBitsUsed(0, 0, 0) >> 3;
+ aacDecInfo->sampleDecoded += AAC_MAX_NSAMPS * (aacDecInfo->sbrEnabled ? 2 : 1);
+ *bytesLeft -= (CalcBitsUsed(0, 0, 0) >> 3);
+ // *inbuf = *inbuf+;
+ }
+
+
+
+ return ERR_AAC_NONE;
+}
+
diff --git a/audio_codec/libraac/aacdec.h b/audio_codec/libraac/aacdec.h
new file mode 100644
index 0000000..f730209
--- a/dev/null
+++ b/audio_codec/libraac/aacdec.h
@@ -0,0 +1,200 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aacdec.h,v 1.8 2005/11/10 00:15:08 margotm Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * aacdec.h - public C API for AAC decoder
+ **************************************************************************************/
+
+#ifndef _AACDEC_H
+#define _AACDEC_H
+
+#define _ARC32
+
+#if defined(_WIN32) && !defined(_WIN32_WCE)
+#
+#elif defined(_WIN32) && defined(_WIN32_WCE) && defined(ARM)
+#
+#elif defined(_WIN32) && defined(WINCE_EMULATOR)
+#
+#elif defined (__arm) && defined (__ARMCC_VERSION)
+#
+#elif defined(_SYMBIAN) && defined(__WINS__)
+#
+#elif defined(__GNUC__) && defined(__arm__)
+#
+#elif defined(__GNUC__) && defined(__i386__)
+#
+#elif defined(__GNUC__) && defined(__amd64__)
+#
+#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__))
+#
+#elif defined(_OPENWAVE_SIMULATOR) || defined(_OPENWAVE_ARMULATOR)
+#
+#elif defined(_SOLARIS) && !defined(__GNUC__)
+#
+#elif defined(_ARC32)
+#define __inline _Inline_
+#else
+#error No platform defined. See valid options in aacdec.h
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* according to spec (13818-7 section 8.2.2, 14496-3 section 4.5.3)
+ * max size of input buffer =
+ * 6144 bits = 768 bytes per SCE or CCE-I
+ * 12288 bits = 1536 bytes per CPE
+ * 0 bits = 0 bytes per CCE-D (uses bits from the SCE/CPE/CCE-I it is coupled to)
+ */
+#ifndef AAC_MAX_NCHANS /* if max channels isn't set in makefile, */
+#define AAC_MAX_NCHANS 2 /* set to default max number of channels */
+#endif
+#define AAC_MAX_NSAMPS 1024
+#define AAC_MAINBUF_SIZE (768 * AAC_MAX_NCHANS)
+
+#define AAC_NUM_PROFILES 3
+#define AAC_PROFILE_MP 0
+#define AAC_PROFILE_LC 1
+#define AAC_PROFILE_SSR 2
+
+#define AAC_INPUTBUF_SIZE (2 * AAC_MAINBUF_SIZE * AAC_MAX_NCHANS) /* pick something big enough to hold a bunch of frames */
+
+ /* define these to enable decoder features */
+#ifdef __ARC600__
+#define HELIX_FEATURE_AUDIO_CODEC_AAC_SBR
+#endif /* __ARC600__ */
+#if defined(HELIX_FEATURE_AUDIO_CODEC_AAC_SBR)
+#define AAC_ENABLE_SBR
+#endif // HELIX_FEATURE_AUDIO_CODEC_AAC_SBR.
+#define AAC_ENABLE_MPEG4
+
+#ifdef AAC_ENABLE_SBR
+#define SBR_MUL 2
+#else
+#define SBR_MUL 1
+#endif
+
+ enum {
+ ERR_AAC_NONE = 0,
+ ERR_AAC_INDATA_UNDERFLOW = -1,
+ ERR_AAC_NULL_POINTER = -2,
+ ERR_AAC_INVALID_ADTS_HEADER = -3,
+ ERR_AAC_INVALID_ADIF_HEADER = -4,
+ ERR_AAC_INVALID_FRAME = -5,
+ ERR_AAC_MPEG4_UNSUPPORTED = -6,
+ ERR_AAC_CHANNEL_MAP = -7,
+ ERR_AAC_SYNTAX_ELEMENT = -8,
+
+ ERR_AAC_DEQUANT = -9,
+ ERR_AAC_STEREO_PROCESS = -10,
+ ERR_AAC_PNS = -11,
+ ERR_AAC_SHORT_BLOCK_DEINT = -12,
+ ERR_AAC_TNS = -13,
+ ERR_AAC_IMDCT = -14,
+ ERR_AAC_NCHANS_TOO_HIGH = -15,
+
+ ERR_AAC_SBR_INIT = -16,
+ ERR_AAC_SBR_BITSTREAM = -17,
+ ERR_AAC_SBR_DATA = -18,
+ ERR_AAC_SBR_PCM_FORMAT = -19,
+ ERR_AAC_SBR_NCHANS_TOO_HIGH = -20,
+ ERR_AAC_SBR_SINGLERATE_UNSUPPORTED = -21,
+
+ ERR_AAC_RAWBLOCK_PARAMS = -22,
+
+ ERR_UNKNOWN = -9999
+ };
+
+ typedef struct _AACIOBuf {
+ int bytesLeft;
+ unsigned char *readPtr;
+ unsigned char readBuf[AAC_INPUTBUF_SIZE];
+ short outBuf[AAC_MAX_NCHANS * AAC_MAX_NSAMPS * SBR_MUL];
+ } AACIOBuf;
+
+ typedef struct _AACFrameInfo { // should keep same as _audio_codec_config_aacdec_t in audio_codec_aac.h
+ int bitRate;
+ int nChans;
+ int sampRateCore;
+ int sampRateOut;
+ int bitsPerSample;
+ int outputSamps;
+ int profile;
+ int tnsUsed;
+ int pnsUsed;
+ int format;
+ unsigned total_byte_parsed;
+ unsigned total_sample_decoded;
+ unsigned audio_send_by_frame;
+ //#ifndef PRE_APOLLO
+ unsigned char *extra_data;
+ unsigned extradata_len;
+ //#endif
+ } AACFrameInfo;
+
+ typedef void *HAACDecoder;
+ typedef void *HAACIOBuf;
+
+ /* public C API */
+ HAACDecoder AACInitDecoder(int);
+ void AACFreeDecoder(HAACDecoder hAACDecoder);
+ int AACDecode(HAACDecoder hAACDecoder, unsigned char **inbuf, int *bytesLeft, short *outbuf);
+
+ int AACFindSyncWord(unsigned char *buf, int nBytes);
+ void AACGetLastFrameInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo);
+ void AACGetDecoderInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo);
+ int AACSetRawBlockParams(HAACDecoder hAACDecoder, int copyLast, AACFrameInfo *aacFrameInfo);
+ int AACFlushCodec(HAACDecoder hAACDecoder);
+
+#ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT
+ int AACInitTrigtabsFloat(void);
+ void AACFreeTrigtabsFloat(void);
+#endif
+
+ extern int AACDataSource;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _AACDEC_H */
diff --git a/audio_codec/libraac/aactabs.c b/audio_codec/libraac/aactabs.c
new file mode 100644
index 0000000..3cade7d
--- a/dev/null
+++ b/audio_codec/libraac/aactabs.c
@@ -0,0 +1,157 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aactabs.c,v 1.1 2005/02/26 01:47:31 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * aactabs.c - platform-independent tables for AAC decoder (global, read-only)
+ **************************************************************************************/
+
+#include "aaccommon.h"
+
+/* sample rates (table 4.5.1) */
+const int sampRateTab[NUM_SAMPLE_RATES] = {
+ 96000, 88200, 64000, 48000, 44100, 32000,
+ 24000, 22050, 16000, 12000, 11025, 8000
+};
+
+/* max scalefactor band for prediction (main profile only) */
+const int predSFBMax[NUM_SAMPLE_RATES] = {
+ 33, 33, 38, 40, 40, 40, 41, 41, 37, 37, 37, 34
+};
+
+/* channel mapping (table 1.6.3.4) (-1 = unknown, so need to determine mapping based on rules in 8.5.1) */
+const int channelMapTab[NUM_DEF_CHAN_MAPS] = {
+ -1, 1, 2, 3, 4, 5, 6, 8
+};
+
+/* number of channels in each element (SCE, CPE, etc.)
+ * see AACElementID in aaccommon.h
+ */
+const int elementNumChans[NUM_ELEMENTS] = {
+ 1, 2, 0, 1, 0, 0, 0, 0
+};
+
+/* total number of scale factor bands in one window */
+const unsigned char sfBandTotalShort[NUM_SAMPLE_RATES] = {
+ 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15
+};
+
+const unsigned char sfBandTotalLong[NUM_SAMPLE_RATES] = {
+ 41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40
+};
+
+/* scale factor band tables */
+const int sfBandTabShortOffset[NUM_SAMPLE_RATES] = {0, 0, 0, 13, 13, 13, 28, 28, 44, 44, 44, 60};
+
+const short sfBandTabShort[76] = {
+ /* short block 64, 88, 96 kHz [13] (tables 4.5.24, 4.5.26) */
+ 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128,
+
+ /* short block 32, 44, 48 kHz [15] (table 4.5.15) */
+ 0, 4, 8, 12, 16, 20, 28, 36, 44, 56, 68, 80, 96, 112, 128,
+
+ /* short block 22, 24 kHz [16] (table 4.5.22) */
+ 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 64, 76, 92, 108, 128,
+
+ /* short block 11, 12, 16 kHz [16] (table 4.5.20) */
+ 0, 4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 60, 72, 88, 108, 128,
+
+ /* short block 8 kHz [16] (table 4.5.18) */
+ 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 128
+};
+
+const int sfBandTabLongOffset[NUM_SAMPLE_RATES] = {0, 0, 42, 90, 90, 140, 192, 192, 240, 240, 240, 284};
+
+const short sfBandTabLong[325] = {
+ /* long block 88, 96 kHz [42] (table 4.5.25) */
+ 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,
+
+ /* long block 64 kHz [48] (table 4.5.13) */
+ 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,
+
+ /* long block 44, 48 kHz [50] (table 4.5.14) */
+ 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,
+
+ /* long block 32 kHz [52] (table 4.5.16) */
+ 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,
+
+ /* long block 22, 24 kHz [48] (table 4.5.21) */
+ 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,
+
+ /* long block 11, 12, 16 kHz [44] (table 4.5.19) */
+ 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,
+
+ /* long block 8 kHz [41] (table 4.5.17) */
+ 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
+};
+
+
+/* TNS max bands (table 4.139) and max order (table 4.138) */
+const int tnsMaxBandsShortOffset[AAC_NUM_PROFILES] = {0, 0, 12};
+
+const unsigned char tnsMaxBandsShort[2 * NUM_SAMPLE_RATES] = {
+ 9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, /* short block, Main/LC */
+ 7, 7, 7, 6, 6, 6, 7, 7, 8, 8, 8, 7 /* short block, SSR */
+};
+
+const unsigned char tnsMaxOrderShort[AAC_NUM_PROFILES] = {7, 7, 7};
+
+const int tnsMaxBandsLongOffset[AAC_NUM_PROFILES] = {0, 0, 12};
+
+const unsigned char tnsMaxBandsLong[2 * NUM_SAMPLE_RATES] = {
+ 31, 31, 34, 40, 42, 51, 46, 46, 42, 42, 42, 39, /* long block, Main/LC */
+ 28, 28, 27, 26, 26, 26, 29, 29, 23, 23, 23, 19, /* long block, SSR */
+};
+
+const unsigned char tnsMaxOrderLong[AAC_NUM_PROFILES] = {20, 12, 12};
diff --git a/audio_codec/libraac/assembly.h b/audio_codec/libraac/assembly.h
new file mode 100644
index 0000000..aeee62b
--- a/dev/null
+++ b/audio_codec/libraac/assembly.h
@@ -0,0 +1,147 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: assembly.h,v 1.7 2005/11/10 00:04:40 margotm Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * assembly.h - inline assembly language functions and prototypes
+ *
+ * MULSHIFT32(x, y) signed multiply of two 32-bit integers (x and y),
+ * returns top 32-bits of 64-bit result
+ * CLIPTOSHORT(x) convert 32-bit integer to 16-bit short,
+ * clipping to [-32768, 32767]
+ * FASTABS(x) branchless absolute value of signed integer x
+ * CLZ(x) count leading zeros on signed integer x
+ * MADD64(sum64, x, y) 64-bit multiply accumulate: sum64 += (x*y)
+ **************************************************************************************/
+
+#ifndef _ASSEMBLY_H
+#define _ASSEMBLY_H
+
+/* toolchain: ARM gcc
+ * target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier)
+ */
+
+#if defined(__aarch64__)
+static __inline__ int MULSHIFT32(int x, int y)
+{
+ long c;
+ c = (long)x * y;
+ return (int)c;
+}
+#else
+static __inline__ int MULSHIFT32(int x, int y)
+{
+ int zlow;
+ __asm__ volatile("smull %0,%1,%2,%3" : "=&r"(zlow), "=r"(y) : "r"(x), "1"(y) : "cc");
+ return y;
+}
+#endif
+static __inline__ short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline__ int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline__ int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return (sizeof(int) * 8);
+ }
+
+ numZeros = 0;
+ while (!(x & 0x80000000)) {
+ numZeros++;
+ x <<= 1;
+ }
+
+ return numZeros;
+}
+
+typedef long long Word64;
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* ARM ADS = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+#if defined(__aarch64__)
+static __inline__ Word64 MADD64(Word64 sum64, int x, int y)
+{
+ sum64 += (long)x * y;
+
+ return sum64;
+}
+#else
+static __inline__ Word64 MADD64(Word64 sum64, int x, int y)
+{
+ U64 u;
+ u.w64 = sum64;
+
+ __asm__ volatile("smlal %0,%1,%2,%3" : "+&r"(u.r.lo32), "+&r"(u.r.hi32) : "r"(x), "r"(y) : "cc");
+
+ return u.w64;
+}
+#endif
+
+#endif /* _ASSEMBLY_H */
diff --git a/audio_codec/libraac/bitstream.c b/audio_codec/libraac/bitstream.c
new file mode 100644
index 0000000..06c509b
--- a/dev/null
+++ b/audio_codec/libraac/bitstream.c
@@ -0,0 +1,451 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: bitstream.c,v 1.2 2005/09/27 20:31:11 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * bitstream.c - bitstream parsing functions
+ **************************************************************************************/
+//#include <core/dsp.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "bitstream.h"
+#include "raac_decode.h"
+#include <android/log.h>
+
+#define LOG_TAG "codec_raac"
+#define raac_print(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+
+static unsigned int iCache0 = 0;
+static unsigned int iCache1 = 0;
+static int cacheBit0 = 0;
+static int cacheBit1 = 0;
+static int bitsUsed = 0;
+
+extern cook_IObuf cook_input;
+//extern cook_IObuf cook_output;
+
+void InitBitStream()
+{
+ iCache0 = 0;
+ iCache1 = 0;
+ cacheBit0 = 0;
+ cacheBit1 = 0;
+ bitsUsed = 0;
+}
+
+unsigned char GetByte()
+{
+ unsigned int val = 0; //read_byte();
+ if (cook_input.buf != NULL && cook_input.buf_len > 0) {
+ val = (unsigned int)cook_input.buf[0];
+ memcpy(cook_input.buf, cook_input.buf + 1, cook_input.buf_len - 1);
+ cook_input.buf_len -= 1;
+ cook_input.cousume += 1;
+ cook_input.all_consume += 1;
+ } else {
+ raac_print("GetByte() failed, because cook_input.buf has not data\n");
+ }
+ return val;
+}
+void RefillBitStream()
+{
+ int nBits = 32 - cacheBit0;
+ while (nBits) {
+ iCache0 |= (GetByte() << (32 - cacheBit0 - 8));
+ cacheBit0 += 8;
+ nBits -= 8;
+ }
+}
+
+/**************************************************************************************
+ * Function: SetBitstreamPointer
+ *
+ * Description: initialize bitstream reader
+ *
+ * Inputs: pointer to BitStreamInfo struct
+ * number of bytes in bitstream
+ * pointer to byte-aligned buffer of data to read from
+ *
+ * Outputs: initialized bitstream info struct
+ *
+ * Return: none
+ **************************************************************************************/
+void SetBitstreamPointer(BitStreamInfo *bsi, int nBytes, unsigned char *buf)
+{
+ if (AACDataSource == 1) {
+ /* init bitstream */
+ bsi->bytePtr = buf;
+ bsi->iCache = 0; /* 4-byte unsigned int */
+ bsi->cachedBits = 0; /* i.e. zero bits in cache */
+ bsi->nBytes = nBytes;
+ }
+}
+
+/**************************************************************************************
+ * Function: RefillBitstreamCache
+ *
+ * Description: read new data from bitstream buffer into 32-bit cache
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ *
+ * Outputs: updated bitstream info struct
+ *
+ * Return: none
+ *
+ * Notes: only call when iCache is completely drained (resets bitOffset to 0)
+ * always loads 4 new bytes except when bsi->nBytes < 4 (end of buffer)
+ * stores data as big-endian in cache, regardless of machine endian-ness
+ **************************************************************************************/
+static void RefillBitstreamCache(BitStreamInfo *bsi)
+{
+ int nBytes = bsi->nBytes;
+
+ /* optimize for common case, independent of machine endian-ness */
+ if (nBytes >= 4) {
+ bsi->iCache = (*bsi->bytePtr++) << 24;
+ bsi->iCache |= (*bsi->bytePtr++) << 16;
+ bsi->iCache |= (*bsi->bytePtr++) << 8;
+ bsi->iCache |= (*bsi->bytePtr++);
+ bsi->cachedBits = 32;
+ bsi->nBytes -= 4;
+ } else {
+ bsi->iCache = 0;
+ while (nBytes--) {
+ bsi->iCache |= (*bsi->bytePtr++);
+ bsi->iCache <<= 8;
+ }
+ bsi->iCache <<= ((3 - bsi->nBytes) * 8);
+ bsi->cachedBits = 8 * bsi->nBytes;
+ bsi->nBytes = 0;
+ }
+}
+
+/**************************************************************************************
+ * Function: GetBits
+ *
+ * Description: get bits from bitstream, advance bitstream pointer
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ * number of bits to get from bitstream
+ *
+ * Outputs: updated bitstream info struct
+ *
+ * Return: the next nBits bits of data from bitstream buffer
+ *
+ * Notes: nBits must be in range [0, 31], nBits outside this range masked by 0x1f
+ * for speed, does not indicate error if you overrun bit buffer
+ * if nBits == 0, returns 0
+ **************************************************************************************/
+unsigned int GetBits(BitStreamInfo *bsi, int nBits)
+{
+ unsigned int data = 0;
+ unsigned int lowBits = 0;
+
+ if (AACDataSource == 1) {
+ nBits &= 0x1f; /* nBits mod 32 to avoid unpredictable results like >> by negative amount */
+ data = bsi->iCache >> (31 - nBits); /* unsigned >> so zero-extend */
+ data >>= 1; /* do as >> 31, >> 1 so that nBits = 0 works okay (returns 0) */
+ bsi->iCache <<= nBits; /* left-justify cache */
+ bsi->cachedBits -= nBits; /* how many bits have we drawn from the cache so far */
+
+ /* if we cross an int boundary, refill the cache */
+ if (bsi->cachedBits < 0) {
+ lowBits = -bsi->cachedBits;
+ RefillBitstreamCache(bsi);
+ data |= bsi->iCache >> (32 - lowBits); /* get the low-order bits */
+
+ bsi->cachedBits -= lowBits; /* how many bits have we drawn from the cache so far */
+ bsi->iCache <<= lowBits; /* left-justify cache */
+ }
+
+ return data;
+ } else {
+ if (!nBits) {
+ return 0;
+ }
+ nBits = (nBits > 32) ? 32 : nBits;
+ bitsUsed += nBits;
+ if (cacheBit1 > 0) {
+ if (nBits > cacheBit1) {
+ if (cacheBit1 == 0) { // if shift above 32, the instruction shift 0
+ data = 0;
+ } else {
+ data = iCache1 >> (32 - cacheBit1);
+ }
+ nBits -= cacheBit1;
+ data <<= nBits;
+ iCache1 = 0;
+ cacheBit1 = 0;
+ } else {
+ data = iCache1 >> (32 - nBits);
+ cacheBit1 -= nBits;
+ iCache1 <<= nBits;
+ return data;
+ }
+ }
+
+ if (nBits > cacheBit0) {
+ if (cacheBit0) {
+ data |= iCache0 >> (32 - cacheBit0);
+ }
+ nBits -= cacheBit0;
+ data <<= nBits;
+ iCache0 = 0;
+ iCache0 = GetByte();
+ iCache0 <<= 8;
+ iCache0 |= GetByte();
+ iCache0 <<= 8;
+ iCache0 |= GetByte();
+ iCache0 <<= 8;
+ iCache0 |= GetByte();
+ cacheBit0 = 32;
+ }
+ if (nBits) {
+ data |= iCache0 >> (32 - nBits);
+ }
+ iCache0 <<= nBits;
+ cacheBit0 -= nBits;
+ return data;
+ }
+}
+
+/**************************************************************************************
+ * Function: GetBitsNoAdvance
+ *
+ * Description: get bits from bitstream, do not advance bitstream pointer
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ * number of bits to get from bitstream
+ *
+ * Outputs: none (state of BitStreamInfo struct left unchanged)
+ *
+ * Return: the next nBits bits of data from bitstream buffer
+ *
+ * Notes: nBits must be in range [0, 31], nBits outside this range masked by 0x1f
+ * for speed, does not indicate error if you overrun bit buffer
+ * if nBits == 0, returns 0
+ **************************************************************************************/
+unsigned int GetBitsNoAdvance(BitStreamInfo *bsi, int nBits)
+{
+ unsigned char *buf = NULL;
+ unsigned int data = 0;
+ unsigned int iCache = 0;
+ signed int lowBits = 0;
+
+ if (AACDataSource == 1) {
+ nBits &= 0x1f; /* nBits mod 32 to avoid unpredictable results like >> by negative amount */
+ data = bsi->iCache >> (31 - nBits); /* unsigned >> so zero-extend */
+ data >>= 1; /* do as >> 31, >> 1 so that nBits = 0 works okay (returns 0) */
+ lowBits = nBits - bsi->cachedBits; /* how many bits do we have left to read */
+
+ /* if we cross an int boundary, read next bytes in buffer */
+ if (lowBits > 0) {
+ iCache = 0;
+ buf = bsi->bytePtr;
+ while (lowBits > 0) {
+ iCache <<= 8;
+ if (buf < bsi->bytePtr + bsi->nBytes) {
+ iCache |= (unsigned int) * buf++;
+ }
+ lowBits -= 8;
+ }
+ lowBits = -lowBits;
+ data |= iCache >> lowBits;
+ }
+ return data;
+ } else {
+ if (!nBits) {
+ return 0;
+ }
+ nBits = (nBits > 32) ? 32 : nBits;
+
+ if (nBits > (cacheBit0 + cacheBit1)) {
+ data = ((iCache1 >> (32 - cacheBit1)) << cacheBit0);
+
+ if (cacheBit0) {
+ data |= (iCache0 >> (32 - cacheBit0));
+ }
+
+ iCache1 = data << (32 - cacheBit0 - cacheBit1);
+ cacheBit1 = cacheBit0 + cacheBit1;
+ nBits -= cacheBit1;
+ data <<= nBits;
+
+ iCache0 = GetByte();
+ iCache0 <<= 8;
+ iCache0 |= GetByte();
+ iCache0 <<= 8;
+ iCache0 |= GetByte();
+ iCache0 <<= 8;
+ iCache0 |= GetByte();
+
+ cacheBit0 = 32;
+ } else if (nBits > cacheBit1) {
+ if (cacheBit1) {
+ data = iCache1 >> (32 - cacheBit1);
+ }
+ nBits -= cacheBit1;
+ data <<= nBits;
+ } else {
+ //if(nBits<cacheBit1)
+ data = iCache1 >> (32 - nBits);
+ //cacheBit1 -= nBits;
+ //iCache1 <<= nBits;
+ return data;
+ }
+ if (nBits) {
+ data |= (iCache0 >> (32 - nBits));
+ }
+
+ return data;
+ }
+}
+
+/**************************************************************************************
+ * Function: AdvanceBitstream
+ *
+ * Description: move bitstream pointer ahead
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ * number of bits to advance bitstream
+ *
+ * Outputs: updated bitstream info struct
+ *
+ * Return: none
+ *
+ * Notes: generally used following GetBitsNoAdvance(bsi, maxBits)
+ **************************************************************************************/
+void AdvanceBitstream(BitStreamInfo *bsi, int nBits)
+{
+ if (AACDataSource == 1) {
+ nBits &= 0x1f;
+ if (nBits > bsi->cachedBits) {
+ nBits -= bsi->cachedBits;
+ RefillBitstreamCache(bsi);
+ }
+ bsi->iCache <<= nBits;
+ bsi->cachedBits -= nBits;
+ } else {
+ if (!nBits) {
+ return;
+ }
+ nBits &= 0x1f;
+ bitsUsed += nBits;
+ if (cacheBit1 > 0) {
+ if (nBits > cacheBit1) {
+ nBits -= cacheBit1;
+ cacheBit1 = 0;
+ iCache1 = 0;
+ } else {
+ cacheBit1 -= nBits;
+ iCache1 <<= nBits;
+ return;
+ }
+ }
+ if (nBits > cacheBit0) {
+ nBits -= cacheBit0;
+ cacheBit0 = 0;
+ iCache0 = GetByte();
+ iCache0 <<= 8;
+ iCache0 |= GetByte();
+ iCache0 <<= 8;
+ iCache0 |= GetByte();
+ iCache0 <<= 8;
+ iCache0 |= GetByte();
+ cacheBit0 = 32;
+ }
+ cacheBit0 -= nBits;
+ iCache0 <<= nBits;
+ }
+}
+
+/**************************************************************************************
+ * Function: CalcBitsUsed
+ *
+ * Description: calculate how many bits have been read from bitstream
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ * pointer to start of bitstream buffer
+ * bit offset into first byte of startBuf (0-7)
+ *
+ * Outputs: none
+ *
+ * Return: number of bits read from bitstream, as offset from startBuf:startOffset
+ **************************************************************************************/
+int CalcBitsUsed(BitStreamInfo *bsi, unsigned char *startBuf, int startOffset)
+{
+ int bitsUsed = 0;
+ if (AACDataSource == 1) {
+ bitsUsed = (bsi->bytePtr - startBuf) * 8;
+ bitsUsed -= bsi->cachedBits;
+ bitsUsed -= startOffset;
+
+ return bitsUsed;
+ } else {
+ return bitsUsed;
+ }
+}
+
+/**************************************************************************************
+ * Function: ByteAlignBitstream
+ *
+ * Description: bump bitstream pointer to start of next byte
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ *
+ * Outputs: byte-aligned bitstream BitStreamInfo struct
+ *
+ * Return: none
+ *
+ * Notes: if bitstream is already byte-aligned, do nothing
+ **************************************************************************************/
+void ByteAlignBitstream(BitStreamInfo *bsi)
+{
+ int offset = 0;
+
+ if (AACDataSource == 1) {
+ offset = bsi->cachedBits & 0x07;
+ AdvanceBitstream(bsi, offset);
+ } else {
+ GetBits(0, (cacheBit0 + cacheBit1) & 7);
+ }
+}
diff --git a/audio_codec/libraac/bitstream.h b/audio_codec/libraac/bitstream.h
new file mode 100644
index 0000000..30c957f
--- a/dev/null
+++ b/audio_codec/libraac/bitstream.h
@@ -0,0 +1,76 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: bitstream.h,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * bitstream.h - definitions of bitstream handling functions
+ **************************************************************************************/
+
+#ifndef _BITSTREAM_H
+#define _BITSTREAM_H
+
+#include "aaccommon.h"
+
+/* additional external symbols to name-mangle for static linking */
+#define SetBitstreamPointer STATNAME(SetBitstreamPointer)
+#define GetBits STATNAME(GetBits)
+#define GetBitsNoAdvance STATNAME(GetBitsNoAdvance)
+#define AdvanceBitstream STATNAME(AdvanceBitstream)
+#define CalcBitsUsed STATNAME(CalcBitsUsed)
+#define ByteAlignBitstream STATNAME(ByteAlignBitstream)
+
+typedef struct _BitStreamInfo {
+ unsigned char *bytePtr;
+ unsigned int iCache;
+ int cachedBits;
+ int nBytes;
+} BitStreamInfo;
+
+/* bitstream.c */
+void SetBitstreamPointer(BitStreamInfo *bsi, int nBytes, unsigned char *buf);
+
+void InitBitStream();
+unsigned int GetBits(BitStreamInfo *bsi, int nBits);
+unsigned int GetBitsNoAdvance(BitStreamInfo *bsi, int nBits);
+void AdvanceBitstream(BitStreamInfo *bsi, int nBits);
+int CalcBitsUsed(BitStreamInfo *bsi, unsigned char *startBuf, int startOffset);
+void ByteAlignBitstream(BitStreamInfo *bsi);
+
+#endif /* _BITSTREAM_H */
diff --git a/audio_codec/libraac/buffers.c b/audio_codec/libraac/buffers.c
new file mode 100644
index 0000000..1e73078
--- a/dev/null
+++ b/audio_codec/libraac/buffers.c
@@ -0,0 +1,132 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: buffers.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * buffers.c - allocation and deallocation of internal AAC decoder buffers
+ **************************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include "aaccommon.h"
+//#include <core/dsp.h>
+#include "coder.h"
+
+/**************************************************************************************
+ * Function: ClearBuffer
+ *
+ * Description: fill buffer with 0's
+ *
+ * Inputs: pointer to buffer
+ * number of bytes to fill with 0
+ *
+ * Outputs: cleared buffer
+ *
+ * Return: none
+ *
+ * Notes: slow, platform-independent equivalent to memset(buf, 0, nBytes)
+ **************************************************************************************/
+void ClearBuffer(void *buf, int nBytes)
+{
+ unsigned char *cbuf = (unsigned char *)buf;
+ memset(cbuf, 0, nBytes);
+ return;
+}
+
+
+/**************************************************************************************
+ * Function: AllocateBuffers
+ *
+ * Description: allocate all the memory needed for the AAC decoder
+ *
+ * Inputs: none
+ *
+ * Outputs: none
+ *
+ * Return: pointer to AACDecInfo structure, cleared to all 0's (except for
+ * pointer to platform-specific data structure)
+ *
+ * Notes: if one or more mallocs fail, function frees any buffers already
+ * allocated before returning
+ **************************************************************************************/
+AACDecInfo *AllocateBuffers(void)
+{
+ AACDecInfo *gi;
+ /* create new Gecko2Info structure */
+ gi = (AACDecInfo *)malloc(sizeof(AACDecInfo));
+ if (!gi) {
+ return 0;
+ }
+ ClearBuffer(gi, sizeof(AACDecInfo));
+ gi->psInfoBase = (PSInfoBase *)malloc(sizeof(PSInfoBase));
+ if (!gi->psInfoBase) {
+ return 0;
+ }
+ ClearBuffer(gi->psInfoBase , sizeof(PSInfoBase));
+
+ return gi;
+}
+
+#define SAFE_FREE(x) {if (x) free(x); (x) = 0;} /* helper macro */
+
+/**************************************************************************************
+ * Function: FreeBuffers
+ *
+ * Description: frees all the memory used by the AAC decoder
+ *
+ * Inputs: pointer to initialized AACDecInfo structure
+ *
+ * Outputs: none
+ *
+ * Return: none
+ *
+ * Notes: safe to call even if some buffers were not allocated (uses SAFE_FREE)
+ **************************************************************************************/
+void FreeBuffers(AACDecInfo *aacDecInfo)
+{
+ if (!aacDecInfo) {
+ return;
+ }
+
+ SAFE_FREE(aacDecInfo->psInfoBase);
+ SAFE_FREE(aacDecInfo);
+}
+
diff --git a/audio_codec/libraac/coder.h b/audio_codec/libraac/coder.h
new file mode 100644
index 0000000..1d626d4
--- a/dev/null
+++ b/audio_codec/libraac/coder.h
@@ -0,0 +1,370 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: coder.h,v 1.2 2005/06/27 21:06:00 gwright Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * coder.h - definitions of platform-specific data structures, functions, and tables
+ **************************************************************************************/
+
+#ifndef _CODER_H
+#define _CODER_H
+
+#include "aaccommon.h"
+#include "bitstream.h"
+#include "aacdec.h"
+
+#ifndef ASSERT
+#if defined(_WIN32) && defined(_M_IX86) && (defined (_DEBUG) || defined (REL_ENABLE_ASSERTS))
+#define ASSERT(x) if (!(x)) __asm int 3;
+#else
+#define ASSERT(x) /* do nothing */
+#endif
+#endif
+
+#ifndef MAX
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+#ifndef MIN
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+#define NWINDOWS_LONG 1
+#define NWINDOWS_SHORT 8
+
+#define DATA_BUF_SIZE 510 /* max count = 255 + 255 */
+#define FILL_BUF_SIZE 269 /* max count = 15 + 255 - 1*/
+#define ADIF_COPYID_SIZE 9
+#define MAX_COMMENT_BYTES 255
+
+#define MAX_NUM_FCE 15
+#define MAX_NUM_SCE 15
+#define MAX_NUM_BCE 15
+#define MAX_NUM_LCE 3
+#define MAX_NUM_ADE 7
+#define MAX_NUM_CCE 15
+
+#define CHAN_ELEM_IS_CPE(x) (((x) & 0x10) >> 4) /* bit 4 = SCE/CPE flag */
+#define CHAN_ELEM_GET_TAG(x) (((x) & 0x0f) >> 0) /* bits 3-0 = instance tag */
+
+#define CHAN_ELEM_SET_CPE(x) (((x) & 0x01) << 4) /* bit 4 = SCE/CPE flag */
+#define CHAN_ELEM_SET_TAG(x) (((x) & 0x0f) << 0) /* bits 3-0 = instance tag */
+
+#define MAX_HUFF_BITS 20
+#define HUFFTAB_SPEC_OFFSET 1
+
+/* do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) */
+#define CLIP_2N_SHIFT(y, n) { \
+ int sign = (y) >> 31; \
+ if (sign != (y) >> (30 - (n))) { \
+ (y) = sign ^ (0x3fffffff); \
+ } else { \
+ (y) = (y) << (n); \
+ } \
+ }
+
+/* clip to [-2^n, 2^n-1], valid range of n = [1, 30] */
+#define CLIP_2N(val, n) { \
+ if ((val) >> 31 != (val) >> (n)) \
+ (val) = ((val) >> 31) ^ ((1 << (n)) - 1); \
+ }
+
+#define SF_DQ_OFFSET 15
+#define FBITS_OUT_DQ 20
+#define FBITS_OUT_DQ_OFF (FBITS_OUT_DQ - SF_DQ_OFFSET) /* number of fraction bits out of dequant, including 2^15 bias */
+
+#define FBITS_IN_IMDCT FBITS_OUT_DQ_OFF /* number of fraction bits into IMDCT */
+#define GBITS_IN_DCT4 4 /* min guard bits in for DCT4 */
+
+#define FBITS_LOST_DCT4 1 /* number of fraction bits lost (>> out) in DCT-IV */
+#define FBITS_LOST_WND 1 /* number of fraction bits lost (>> out) in synthesis window (neg = gain frac bits) */
+#define FBITS_LOST_IMDCT (FBITS_LOST_DCT4 + FBITS_LOST_WND)
+#define FBITS_OUT_IMDCT (FBITS_IN_IMDCT - FBITS_LOST_IMDCT)
+
+#define NUM_IMDCT_SIZES 2
+
+/* additional external symbols to name-mangle for static linking */
+#define DecodeProgramConfigElement STATNAME(DecodeProgramConfigElement)
+#define DecodeHuffmanScalar STATNAME(DecodeHuffmanScalar)
+#define DecodeSpectrumLong STATNAME(DecodeSpectrumLong)
+#define DecodeSpectrumShort STATNAME(DecodeSpectrumShort)
+#define DecodeICSInfo STATNAME(DecodeICSInfo)
+#define DCT4 STATNAME(DCT4)
+#define R4FFT STATNAME(R4FFT)
+
+#define DecWindowOverlapNoClip STATNAME(DecWindowOverlapNoClip)
+#define DecWindowOverlapLongStartNoClip STATNAME(DecWindowOverlapLongStartNoClip)
+#define DecWindowOverlapLongStopNoClip STATNAME(DecWindowOverlapLongStopNoClip)
+#define DecWindowOverlapShortNoClip STATNAME(DecWindowOverlapShortNoClip)
+
+#define huffTabSpecInfo STATNAME(huffTabSpecInfo)
+#define huffTabSpec STATNAME(huffTabSpec)
+#define huffTabScaleFactInfo STATNAME(huffTabScaleFactInfo)
+#define huffTabScaleFact STATNAME(huffTabScaleFact)
+#define cos4sin4tab STATNAME(cos4sin4tab)
+#define cos4sin4tabOffset STATNAME(cos4sin4tabOffset)
+#define cos1sin1tab STATNAME(cos1sin1tab)
+#define sinWindow STATNAME(sinWindow)
+#define sinWindowOffset STATNAME(sinWindowOffset)
+#define kbdWindow STATNAME(kbdWindow)
+#define kbdWindowOffset STATNAME(kbdWindowOffset)
+#define bitrevtab STATNAME(bitrevtab)
+#define bitrevtabOffset STATNAME(bitrevtabOffset)
+#define uniqueIDTab STATNAME(uniqueIDTab)
+#define twidTabEven STATNAME(twidTabEven)
+#define twidTabOdd STATNAME(twidTabOdd)
+
+typedef struct _HuffInfo {
+ int maxBits; /* number of bits in longest codeword */
+ unsigned char count[MAX_HUFF_BITS]; /* count[i] = number of codes with length i+1 bits */
+ int offset; /* offset into symbol table */
+} HuffInfo;
+
+typedef struct _PulseInfo {
+ unsigned char pulseDataPresent;
+ unsigned char numPulse;
+ unsigned char startSFB;
+ unsigned char offset[MAX_PULSES];
+ unsigned char amp[MAX_PULSES];
+} PulseInfo;
+
+typedef struct _TNSInfo {
+ unsigned char tnsDataPresent;
+ unsigned char numFilt[MAX_TNS_FILTERS]; /* max 1 filter each for 8 short windows, or 3 filters for 1 long window */
+ unsigned char coefRes[MAX_TNS_FILTERS];
+ unsigned char length[MAX_TNS_FILTERS];
+ unsigned char order[MAX_TNS_FILTERS];
+ unsigned char dir[MAX_TNS_FILTERS];
+ signed char coef[MAX_TNS_COEFS]; /* max 3 filters * 20 coefs for 1 long window, or 1 filter * 7 coefs for each of 8 short windows */
+} TNSInfo;
+
+typedef struct _GainControlInfo {
+ unsigned char gainControlDataPresent;
+ unsigned char maxBand;
+ unsigned char adjNum[MAX_GAIN_BANDS][MAX_GAIN_WIN];
+ unsigned char alevCode[MAX_GAIN_BANDS][MAX_GAIN_WIN][MAX_GAIN_ADJUST];
+ unsigned char alocCode[MAX_GAIN_BANDS][MAX_GAIN_WIN][MAX_GAIN_ADJUST];
+} GainControlInfo;
+
+typedef struct _ICSInfo {
+ unsigned char icsResBit;
+ unsigned char winSequence;
+ unsigned char winShape;
+ unsigned char maxSFB;
+ unsigned char sfGroup;
+ unsigned char predictorDataPresent;
+ unsigned char predictorReset;
+ unsigned char predictorResetGroupNum;
+ unsigned char predictionUsed[MAX_PRED_SFB];
+ unsigned char numWinGroup;
+ unsigned char winGroupLen[MAX_WIN_GROUPS];
+} ICSInfo;
+
+typedef struct _ADTSHeader {
+ /* fixed */
+ unsigned char id; /* MPEG bit - should be 1 */
+ unsigned char layer; /* MPEG layer - should be 0 */
+ unsigned char protectBit; /* 0 = CRC word follows, 1 = no CRC word */
+ unsigned char profile; /* 0 = main, 1 = LC, 2 = SSR, 3 = reserved */
+ unsigned char sampRateIdx; /* sample rate index range = [0, 11] */
+ unsigned char privateBit; /* ignore */
+ unsigned char channelConfig; /* 0 = implicit, >0 = use default table */
+ unsigned char origCopy; /* 0 = copy, 1 = original */
+ unsigned char home; /* ignore */
+
+ /* variable */
+ unsigned char copyBit; /* 1 bit of the 72-bit copyright ID (transmitted as 1 bit per frame) */
+ unsigned char copyStart; /* 1 = this bit starts the 72-bit ID, 0 = it does not */
+ int frameLength; /* length of frame */
+ int bufferFull; /* number of 32-bit words left in enc buffer, 0x7FF = VBR */
+ unsigned char numRawDataBlocks; /* number of raw data blocks in frame */
+
+ /* CRC */
+ int crcCheckWord; /* 16-bit CRC check word (present if protectBit == 0) */
+} ADTSHeader;
+
+typedef struct _ADIFHeader {
+ unsigned char copyBit; /* 0 = no copyright ID, 1 = 72-bit copyright ID follows immediately */
+ unsigned char origCopy; /* 0 = copy, 1 = original */
+ unsigned char home; /* ignore */
+ unsigned char bsType; /* bitstream type: 0 = CBR, 1 = VBR */
+ int bitRate; /* bitRate: CBR = bits/sec, VBR = peak bits/frame, 0 = unknown */
+ unsigned char numPCE; /* number of program config elements (max = 16) */
+ int bufferFull; /* bits left in bit reservoir */
+ unsigned char copyID[ADIF_COPYID_SIZE]; /* optional 72-bit copyright ID */
+} ADIFHeader;
+
+/* sizeof(ProgConfigElement) = 82 bytes (if KEEP_PCE_COMMENTS not defined) */
+typedef struct _ProgConfigElement {
+ unsigned char elemInstTag; /* element instance tag */
+ unsigned char profile; /* 0 = main, 1 = LC, 2 = SSR, 3 = reserved */
+ unsigned char sampRateIdx; /* sample rate index range = [0, 11] */
+ unsigned char numFCE; /* number of front channel elements (max = 15) */
+ unsigned char numSCE; /* number of side channel elements (max = 15) */
+ unsigned char numBCE; /* number of back channel elements (max = 15) */
+ unsigned char numLCE; /* number of LFE channel elements (max = 3) */
+ unsigned char numADE; /* number of associated data elements (max = 7) */
+ unsigned char numCCE; /* number of valid channel coupling elements (max = 15) */
+ unsigned char monoMixdown; /* mono mixdown: bit 4 = present flag, bits 3-0 = element number */
+ unsigned char stereoMixdown; /* stereo mixdown: bit 4 = present flag, bits 3-0 = element number */
+ unsigned char matrixMixdown; /* matrix mixdown: bit 4 = present flag, bit 3 = unused,
+ bits 2-1 = index, bit 0 = pseudo-surround enable */
+ unsigned char fce[MAX_NUM_FCE]; /* front element channel pair: bit 4 = SCE/CPE flag, bits 3-0 = inst tag */
+ unsigned char sce[MAX_NUM_SCE]; /* side element channel pair: bit 4 = SCE/CPE flag, bits 3-0 = inst tag */
+ unsigned char bce[MAX_NUM_BCE]; /* back element channel pair: bit 4 = SCE/CPE flag, bits 3-0 = inst tag */
+ unsigned char lce[MAX_NUM_LCE]; /* instance tag for LFE elements */
+ unsigned char ade[MAX_NUM_ADE]; /* instance tag for ADE elements */
+ unsigned char cce[MAX_NUM_BCE]; /* channel coupling elements: bit 4 = switching flag, bits 3-0 = inst tag */
+
+#ifdef KEEP_PCE_COMMENTS
+ /* make this optional - if not enabled, decoder will just skip comments */
+ unsigned char commentBytes;
+ unsigned char commentField[MAX_COMMENT_BYTES];
+#endif
+
+} ProgConfigElement;
+
+/* state info struct for baseline (MPEG-4 LC) decoding */
+typedef struct _PSInfoBase {
+ /* header information */
+ ADTSHeader fhADTS;
+ ADIFHeader fhADIF;
+ ProgConfigElement pce[MAX_NUM_PCE_ADIF];
+ int dataCount;
+ unsigned char dataBuf[DATA_BUF_SIZE];
+ int fillCount;
+ unsigned char fillBuf[FILL_BUF_SIZE];
+
+ /* state information which is the same throughout whole frame */
+ int nChans;
+ int useImpChanMap;
+ int sampRateIdx;
+
+ /* state information which can be overwritten by subsequent elements within frame */
+ ICSInfo icsInfo[MAX_NCHANS_ELEM];
+
+ int commonWin;
+ short scaleFactors[MAX_NCHANS_ELEM][MAX_SF_BANDS];
+ unsigned char sfbCodeBook[MAX_NCHANS_ELEM][MAX_SF_BANDS];
+
+ int msMaskPresent;
+ unsigned char msMaskBits[MAX_MS_MASK_BYTES];
+
+ int pnsUsed[MAX_NCHANS_ELEM];
+ int pnsLastVal;
+ int intensityUsed[MAX_NCHANS_ELEM];
+
+ PulseInfo pulseInfo[MAX_NCHANS_ELEM];
+
+ TNSInfo tnsInfo[MAX_NCHANS_ELEM];
+ int tnsLPCBuf[MAX_TNS_ORDER];
+ int tnsWorkBuf[MAX_TNS_ORDER];
+
+ GainControlInfo gainControlInfo[MAX_NCHANS_ELEM];
+
+ int gbCurrent[MAX_NCHANS_ELEM];
+ int coef[MAX_NCHANS_ELEM][AAC_MAX_NSAMPS];
+#ifdef AAC_ENABLE_SBR
+ int sbrWorkBuf[MAX_NCHANS_ELEM][AAC_MAX_NSAMPS];
+#endif
+ /* state information which must be saved for each element and used in next frame */
+ int overlap[AAC_MAX_NCHANS][AAC_MAX_NSAMPS];
+ int prevWinShape[AAC_MAX_NCHANS];
+
+} PSInfoBase;
+
+/* private implementation-specific functions */
+
+/* decelmnt.c */
+int DecodeProgramConfigElement(ProgConfigElement *pce, BitStreamInfo *bsi);
+
+/* huffman.c */
+int DecodeHuffmanScalar(const signed short *huffTab, const HuffInfo *huffTabInfo, unsigned int bitBuf, signed int *val);
+void DecodeSpectrumLong(PSInfoBase *psi, BitStreamInfo *bsi, int ch);
+void DecodeSpectrumShort(PSInfoBase *psi, BitStreamInfo *bsi, int ch);
+
+/* noiseless.c */
+void DecodeICSInfo(BitStreamInfo *bsi, ICSInfo *icsInfo, int sampRateIdx);
+
+/* dct4.c */
+void DCT4(int tabidx, int *coef, int gb);
+
+/* fft.c */
+void R4FFT(int tabidx, int *x);
+
+/* sbrimdct.c */
+void DecWindowOverlapNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev);
+void DecWindowOverlapLongStartNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev);
+void DecWindowOverlapLongStopNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev);
+void DecWindowOverlapShortNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev);
+
+/* hufftabs.c */
+extern const HuffInfo huffTabSpecInfo[11];
+extern const signed short huffTabSpec[1241];
+extern const HuffInfo huffTabScaleFactInfo;
+extern const signed short huffTabScaleFact[121];
+
+/* trigtabs.c */
+extern const int cos4sin4tabOffset[NUM_IMDCT_SIZES];
+extern const int sinWindowOffset[NUM_IMDCT_SIZES];
+extern const int kbdWindowOffset[NUM_IMDCT_SIZES];
+extern const unsigned char bitrevtab[17 + 129];
+extern const int bitrevtabOffset[NUM_IMDCT_SIZES];
+
+#ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT
+/* trigtabs_fltgen.c */
+extern int cos4sin4tab[128 + 1024];
+extern int cos1sin1tab[514];
+extern int sinWindow[128 + 1024];
+extern int kbdWindow[128 + 1024];
+extern int twidTabEven[4 * 6 + 16 * 6 + 64 * 6];
+extern int twidTabOdd[8 * 6 + 32 * 6 + 128 * 6];
+#else
+/* trigtabs.c */
+extern const int cos4sin4tab[128 + 1024];
+extern const int cos1sin1tab[514];
+extern const int sinWindow[128 + 1024];
+extern const int kbdWindow[128 + 1024];
+extern const int twidTabEven[4 * 6 + 16 * 6 + 64 * 6];
+extern const int twidTabOdd[8 * 6 + 32 * 6 + 128 * 6];
+#endif
+
+#endif /* _CODER_H */
+
diff --git a/audio_codec/libraac/dct4.c b/audio_codec/libraac/dct4.c
new file mode 100644
index 0000000..cb0a77b
--- a/dev/null
+++ b/audio_codec/libraac/dct4.c
@@ -0,0 +1,339 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: dct4.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * dct4.c - optimized DCT-IV
+ **************************************************************************************/
+
+#include "coder.h"
+
+#include "assembly.h"
+
+
+static const int nmdctTab[NUM_IMDCT_SIZES] = {128, 1024};
+static const int postSkip[NUM_IMDCT_SIZES] = {15, 1};
+
+/**************************************************************************************
+ * Function: PreMultiply
+ *
+ * Description: pre-twiddle stage of DCT4
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmdct samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: minimum 1 GB in, 2 GB out, gains 5 (short) or 8 (long) frac bits
+ * i.e. gains 2-7= -5 int bits (short) or 2-10 = -8 int bits (long)
+ * normalization by -1/N is rolled into tables here (see trigtabs.c)
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ **************************************************************************************/
+static void PreMultiply(int tabidx, int *zbuf1)
+{
+ int i, nmdct, ar1, ai1, ar2, ai2, z1, z2;
+ int t, cms2, cps2a, sin2a, cps2b, sin2b;
+ int *zbuf2;
+ const int *csptr;
+
+ nmdct = nmdctTab[tabidx];
+ zbuf2 = zbuf1 + nmdct - 1;
+ csptr = cos4sin4tab + cos4sin4tabOffset[tabidx];
+
+ /* whole thing should fit in registers - verify that compiler does this */
+ for (i = nmdct >> 2; i != 0; i--) {
+ /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */
+ cps2a = *csptr++;
+ sin2a = *csptr++;
+ cps2b = *csptr++;
+ sin2b = *csptr++;
+
+ ar1 = *(zbuf1 + 0);
+ ai2 = *(zbuf1 + 1);
+ ai1 = *(zbuf2 + 0);
+ ar2 = *(zbuf2 - 1);
+
+ /* gain 2 ints bit from MULSHIFT32 by Q30, but drop 7 or 10 int bits from table scaling of 1/M
+ * max per-sample gain (ignoring implicit scaling) = MAX(sin(angle)+cos(angle)) = 1.414
+ * i.e. gain 1 GB since worst case is sin(angle) = cos(angle) = 0.707 (Q30), gain 2 from
+ * extra sign bits, and eat one in adding
+ */
+ t = MULSHIFT32(sin2a, ar1 + ai1);
+ z2 = MULSHIFT32(cps2a, ai1) - t;
+ cms2 = cps2a - 2 * sin2a;
+ z1 = MULSHIFT32(cms2, ar1) + t;
+ *zbuf1++ = z1; /* cos*ar1 + sin*ai1 */
+ *zbuf1++ = z2; /* cos*ai1 - sin*ar1 */
+
+ t = MULSHIFT32(sin2b, ar2 + ai2);
+ z2 = MULSHIFT32(cps2b, ai2) - t;
+ cms2 = cps2b - 2 * sin2b;
+ z1 = MULSHIFT32(cms2, ar2) + t;
+ *zbuf2-- = z2; /* cos*ai2 - sin*ar2 */
+ *zbuf2-- = z1; /* cos*ar2 + sin*ai2 */
+ }
+}
+
+/**************************************************************************************
+ * Function: PostMultiply
+ *
+ * Description: post-twiddle stage of DCT4
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmdct samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: minimum 1 GB in, 2 GB out - gains 2 int bits
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ **************************************************************************************/
+static void PostMultiply(int tabidx, int *fft1)
+{
+ int i, nmdct, ar1, ai1, ar2, ai2, skipFactor;
+ int t, cms2, cps2, sin2;
+ int *fft2;
+ const int *csptr;
+
+ nmdct = nmdctTab[tabidx];
+ csptr = cos1sin1tab;
+ skipFactor = postSkip[tabidx];
+ fft2 = fft1 + nmdct - 1;
+
+ /* load coeffs for first pass
+ * cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin)
+ */
+ cps2 = *csptr++;
+ sin2 = *csptr;
+ csptr += skipFactor;
+ cms2 = cps2 - 2 * sin2;
+
+ for (i = nmdct >> 2; i != 0; i--) {
+ ar1 = *(fft1 + 0);
+ ai1 = *(fft1 + 1);
+ ar2 = *(fft2 - 1);
+ ai2 = *(fft2 + 0);
+
+ /* gain 2 ints bit from MULSHIFT32 by Q30
+ * max per-sample gain = MAX(sin(angle)+cos(angle)) = 1.414
+ * i.e. gain 1 GB since worst case is sin(angle) = cos(angle) = 0.707 (Q30), gain 2 from
+ * extra sign bits, and eat one in adding
+ */
+ t = MULSHIFT32(sin2, ar1 + ai1);
+ *fft2-- = t - MULSHIFT32(cps2, ai1); /* sin*ar1 - cos*ai1 */
+ *fft1++ = t + MULSHIFT32(cms2, ar1); /* cos*ar1 + sin*ai1 */
+ cps2 = *csptr++;
+ sin2 = *csptr;
+ csptr += skipFactor;
+
+ ai2 = -ai2;
+ t = MULSHIFT32(sin2, ar2 + ai2);
+ *fft2-- = t - MULSHIFT32(cps2, ai2); /* sin*ar1 - cos*ai1 */
+ cms2 = cps2 - 2 * sin2;
+ *fft1++ = t + MULSHIFT32(cms2, ar2); /* cos*ar1 + sin*ai1 */
+ }
+}
+
+/**************************************************************************************
+ * Function: PreMultiplyRescale
+ *
+ * Description: pre-twiddle stage of DCT4, with rescaling for extra guard bits
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmdct samples
+ * number of guard bits to add to input before processing
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: see notes on PreMultiply(), above
+ **************************************************************************************/
+static void PreMultiplyRescale(int tabidx, int *zbuf1, int es)
+{
+ int i, nmdct, ar1, ai1, ar2, ai2, z1, z2;
+ int t, cms2, cps2a, sin2a, cps2b, sin2b;
+ int *zbuf2;
+ const int *csptr;
+
+ nmdct = nmdctTab[tabidx];
+ zbuf2 = zbuf1 + nmdct - 1;
+ csptr = cos4sin4tab + cos4sin4tabOffset[tabidx];
+
+ /* whole thing should fit in registers - verify that compiler does this */
+ for (i = nmdct >> 2; i != 0; i--) {
+ /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */
+ cps2a = *csptr++;
+ sin2a = *csptr++;
+ cps2b = *csptr++;
+ sin2b = *csptr++;
+
+ ar1 = *(zbuf1 + 0) >> es;
+ ai1 = *(zbuf2 + 0) >> es;
+ ai2 = *(zbuf1 + 1) >> es;
+
+ t = MULSHIFT32(sin2a, ar1 + ai1);
+ z2 = MULSHIFT32(cps2a, ai1) - t;
+ cms2 = cps2a - 2 * sin2a;
+ z1 = MULSHIFT32(cms2, ar1) + t;
+ *zbuf1++ = z1;
+ *zbuf1++ = z2;
+
+ ar2 = *(zbuf2 - 1) >> es; /* do here to free up register used for es */
+
+ t = MULSHIFT32(sin2b, ar2 + ai2);
+ z2 = MULSHIFT32(cps2b, ai2) - t;
+ cms2 = cps2b - 2 * sin2b;
+ z1 = MULSHIFT32(cms2, ar2) + t;
+ *zbuf2-- = z2;
+ *zbuf2-- = z1;
+
+ }
+}
+
+/**************************************************************************************
+ * Function: PostMultiplyRescale
+ *
+ * Description: post-twiddle stage of DCT4, with rescaling for extra guard bits
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmdct samples
+ * number of guard bits to remove from output
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: clips output to [-2^30, 2^30 - 1], guaranteeing at least 1 guard bit
+ * see notes on PostMultiply(), above
+ **************************************************************************************/
+static void PostMultiplyRescale(int tabidx, int *fft1, int es)
+{
+ int i, nmdct, ar1, ai1, ar2, ai2, skipFactor, z;
+ int t, cs2, sin2;
+ int *fft2;
+ const int *csptr;
+
+ nmdct = nmdctTab[tabidx];
+ csptr = cos1sin1tab;
+ skipFactor = postSkip[tabidx];
+ fft2 = fft1 + nmdct - 1;
+
+ /* load coeffs for first pass
+ * cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin)
+ */
+ cs2 = *csptr++;
+ sin2 = *csptr;
+ csptr += skipFactor;
+
+ for (i = nmdct >> 2; i != 0; i--) {
+ ar1 = *(fft1 + 0);
+ ai1 = *(fft1 + 1);
+ ai2 = *(fft2 + 0);
+
+ t = MULSHIFT32(sin2, ar1 + ai1);
+ z = t - MULSHIFT32(cs2, ai1);
+ CLIP_2N_SHIFT(z, es);
+ *fft2-- = z;
+ cs2 -= 2 * sin2;
+ z = t + MULSHIFT32(cs2, ar1);
+ CLIP_2N_SHIFT(z, es);
+ *fft1++ = z;
+
+ cs2 = *csptr++;
+ sin2 = *csptr;
+ csptr += skipFactor;
+
+ ar2 = *fft2;
+ ai2 = -ai2;
+ t = MULSHIFT32(sin2, ar2 + ai2);
+ z = t - MULSHIFT32(cs2, ai2);
+ CLIP_2N_SHIFT(z, es);
+ *fft2-- = z;
+ cs2 -= 2 * sin2;
+ z = t + MULSHIFT32(cs2, ar2);
+ CLIP_2N_SHIFT(z, es);
+ *fft1++ = z;
+ cs2 += 2 * sin2;
+ }
+}
+
+/**************************************************************************************
+ * Function: DCT4
+ *
+ * Description: type-IV DCT
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmdct samples
+ * number of guard bits in the input buffer
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: operates in-place
+ * if number of guard bits in input is < GBITS_IN_DCT4, the input is
+ * scaled (>>) before the DCT4 and rescaled (<<, with clipping) after
+ * the DCT4 (rare)
+ * the output has FBITS_LOST_DCT4 fewer fraction bits than the input
+ * the output will always have at least 1 guard bit (GBITS_IN_DCT4 >= 4)
+ * int bits gained per stage (PreMul + FFT + PostMul)
+ * short blocks = (-5 + 4 + 2) = 1 total
+ * long blocks = (-8 + 7 + 2) = 1 total
+ **************************************************************************************/
+void DCT4(int tabidx, int *coef, int gb)
+{
+ int es;
+
+ /* fast in-place DCT-IV - adds guard bits if necessary */
+ if (gb < GBITS_IN_DCT4) {
+ es = GBITS_IN_DCT4 - gb;
+ PreMultiplyRescale(tabidx, coef, es);
+ R4FFT(tabidx, coef);
+ PostMultiplyRescale(tabidx, coef, es);
+ } else {
+ PreMultiply(tabidx, coef);
+ R4FFT(tabidx, coef);
+ PostMultiply(tabidx, coef);
+ }
+}
diff --git a/audio_codec/libraac/decelmnt.c b/audio_codec/libraac/decelmnt.c
new file mode 100644
index 0000000..075174d
--- a/dev/null
+++ b/audio_codec/libraac/decelmnt.c
@@ -0,0 +1,451 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: decelmnt.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * decelmnt.c - syntactic element decoding
+ **************************************************************************************/
+
+#include "coder.h"
+//#include <core/dsp.h>
+#include <stdio.h>
+#include "aacdec.h"
+
+/**************************************************************************************
+ * Function: DecodeSingleChannelElement
+ *
+ * Description: decode one SCE
+ *
+ * Inputs: BitStreamInfo struct pointing to start of SCE (14496-3, table 4.4.4)
+ *
+ * Outputs: updated element instance tag
+ *
+ * Return: 0 if successful, -1 if error
+ *
+ * Notes: doesn't decode individual channel stream (part of DecodeNoiselessData)
+ **************************************************************************************/
+static int DecodeSingleChannelElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
+{
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+
+ /* read instance tag */
+ aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS);
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeChannelPairElement
+ *
+ * Description: decode one CPE
+ *
+ * Inputs: BitStreamInfo struct pointing to start of CPE (14496-3, table 4.4.5)
+ *
+ * Outputs: updated element instance tag
+ * updated commonWin
+ * updated ICS info, if commonWin == 1
+ * updated mid-side stereo info, if commonWin == 1
+ *
+ * Return: 0 if successful, -1 if error
+ *
+ * Notes: doesn't decode individual channel stream (part of DecodeNoiselessData)
+ **************************************************************************************/
+static int DecodeChannelPairElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
+{
+ int sfb, gp, maskOffset;
+ unsigned char currBit, *maskPtr;
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = psi->icsInfo;
+
+ /* read instance tag */
+ aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS);
+
+ /* read common window flag and mid-side info (if present)
+ * store msMask bits in psi->msMaskBits[] as follows:
+ * long blocks - pack bits for each SFB in range [0, maxSFB) starting with lsb of msMaskBits[0]
+ * short blocks - pack bits for each SFB in range [0, maxSFB), for each group [0, 7]
+ * msMaskPresent = 0 means no M/S coding
+ * = 1 means psi->msMaskBits contains 1 bit per SFB to toggle M/S coding
+ * = 2 means all SFB's are M/S coded (so psi->msMaskBits is not needed)
+ */
+ psi->commonWin = GetBits(bsi, 1);
+ if (psi->commonWin) {
+ DecodeICSInfo(bsi, icsInfo, psi->sampRateIdx);
+ psi->msMaskPresent = GetBits(bsi, 2);
+ if (psi->msMaskPresent == 1) {
+ maskPtr = psi->msMaskBits;
+ *maskPtr = 0;
+ maskOffset = 0;
+ for (gp = 0; gp < icsInfo->numWinGroup; gp++) {
+ for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) {
+ currBit = (unsigned char)GetBits(bsi, 1);
+ *maskPtr |= currBit << maskOffset;
+ if (++maskOffset == 8) {
+ maskPtr++;
+ *maskPtr = 0;
+ maskOffset = 0;
+ }
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeLFEChannelElement
+ *
+ * Description: decode one LFE
+ *
+ * Inputs: BitStreamInfo struct pointing to start of LFE (14496-3, table 4.4.9)
+ *
+ * Outputs: updated element instance tag
+ *
+ * Return: 0 if successful, -1 if error
+ *
+ * Notes: doesn't decode individual channel stream (part of DecodeNoiselessData)
+ **************************************************************************************/
+static int DecodeLFEChannelElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
+{
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+
+ /* read instance tag */
+ aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS);
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeDataStreamElement
+ *
+ * Description: decode one DSE
+ *
+ * Inputs: BitStreamInfo struct pointing to start of DSE (14496-3, table 4.4.10)
+ *
+ * Outputs: updated element instance tag
+ * filled in data stream buffer
+ *
+ * Return: 0 if successful, -1 if error
+ **************************************************************************************/
+static int DecodeDataStreamElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
+{
+ unsigned int byteAlign, dataCount;
+ unsigned char *dataBuf;
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS);
+ byteAlign = GetBits(bsi, 1);
+ dataCount = GetBits(bsi, 8);
+ if (dataCount == 255) {
+ dataCount += GetBits(bsi, 8);
+ }
+
+ if (byteAlign) {
+ ByteAlignBitstream(bsi);
+ }
+
+ psi->dataCount = dataCount;
+ dataBuf = psi->dataBuf;
+ while (dataCount--) {
+ *dataBuf++ = GetBits(bsi, 8);
+ }
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeProgramConfigElement
+ *
+ * Description: decode one PCE
+ *
+ * Inputs: BitStreamInfo struct pointing to start of PCE (14496-3, table 4.4.2)
+ *
+ * Outputs: filled-in ProgConfigElement struct
+ * updated BitStreamInfo struct
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: #define KEEP_PCE_COMMENTS to save the comment field of the PCE
+ * (otherwise we just skip it in the bitstream, to save memory)
+ **************************************************************************************/
+int DecodeProgramConfigElement(ProgConfigElement *pce, BitStreamInfo *bsi)
+{
+ int i;
+
+ pce->elemInstTag = GetBits(bsi, 4);
+ pce->profile = GetBits(bsi, 2);
+ pce->sampRateIdx = GetBits(bsi, 4);
+ pce->numFCE = GetBits(bsi, 4);
+ pce->numSCE = GetBits(bsi, 4);
+ pce->numBCE = GetBits(bsi, 4);
+ pce->numLCE = GetBits(bsi, 2);
+ pce->numADE = GetBits(bsi, 3);
+ pce->numCCE = GetBits(bsi, 4);
+
+ pce->monoMixdown = GetBits(bsi, 1) << 4; /* present flag */
+ if (pce->monoMixdown) {
+ pce->monoMixdown |= GetBits(bsi, 4); /* element number */
+ }
+
+ pce->stereoMixdown = GetBits(bsi, 1) << 4; /* present flag */
+ if (pce->stereoMixdown) {
+ pce->stereoMixdown |= GetBits(bsi, 4); /* element number */
+ }
+
+ pce->matrixMixdown = GetBits(bsi, 1) << 4; /* present flag */
+ if (pce->matrixMixdown) {
+ pce->matrixMixdown |= GetBits(bsi, 2) << 1; /* index */
+ pce->matrixMixdown |= GetBits(bsi, 1); /* pseudo-surround enable */
+ }
+
+ for (i = 0; i < pce->numFCE; i++) {
+ pce->fce[i] = GetBits(bsi, 1) << 4; /* is_cpe flag */
+ pce->fce[i] |= GetBits(bsi, 4); /* tag select */
+ }
+
+ for (i = 0; i < pce->numSCE; i++) {
+ pce->sce[i] = GetBits(bsi, 1) << 4; /* is_cpe flag */
+ pce->sce[i] |= GetBits(bsi, 4); /* tag select */
+ }
+
+ for (i = 0; i < pce->numBCE; i++) {
+ pce->bce[i] = GetBits(bsi, 1) << 4; /* is_cpe flag */
+ pce->bce[i] |= GetBits(bsi, 4); /* tag select */
+ }
+
+ for (i = 0; i < pce->numLCE; i++) {
+ pce->lce[i] = GetBits(bsi, 4); /* tag select */
+ }
+
+ for (i = 0; i < pce->numADE; i++) {
+ pce->ade[i] = GetBits(bsi, 4); /* tag select */
+ }
+
+ for (i = 0; i < pce->numCCE; i++) {
+ pce->cce[i] = GetBits(bsi, 1) << 4; /* independent/dependent flag */
+ pce->cce[i] |= GetBits(bsi, 4); /* tag select */
+ }
+
+
+ ByteAlignBitstream(bsi);
+
+#ifdef KEEP_PCE_COMMENTS
+ pce->commentBytes = GetBits(bsi, 8);
+ for (i = 0; i < pce->commentBytes; i++) {
+ pce->commentField[i] = GetBits(bsi, 8);
+ }
+#else
+ /* eat comment bytes and throw away */
+ i = GetBits(bsi, 8);
+ while (i--) {
+ GetBits(bsi, 8);
+ }
+#endif
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeFillElement
+ *
+ * Description: decode one fill element
+ *
+ * Inputs: BitStreamInfo struct pointing to start of fill element
+ * (14496-3, table 4.4.11)
+ *
+ * Outputs: updated element instance tag
+ * unpacked extension payload
+ *
+ * Return: 0 if successful, -1 if error
+ **************************************************************************************/
+static int DecodeFillElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
+{
+ unsigned int fillCount;
+ unsigned char *fillBuf;
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ fillCount = GetBits(bsi, 4);
+ if (fillCount == 15) {
+ fillCount += (GetBits(bsi, 8) - 1);
+ }
+
+ psi->fillCount = fillCount;
+ fillBuf = psi->fillBuf;
+ while (fillCount--) {
+ *fillBuf++ = GetBits(bsi, 8);
+ }
+
+ aacDecInfo->currInstTag = -1; /* fill elements don't have instance tag */
+ aacDecInfo->fillExtType = 0;
+
+#ifdef AAC_ENABLE_SBR
+ /* check for SBR
+ * aacDecInfo->sbrEnabled is sticky (reset each raw_data_block), so for multichannel
+ * need to verify that all SCE/CPE/ICCE have valid SBR fill element following, and
+ * must upsample by 2 for LFE
+ */
+ if (psi->fillCount > 0) {
+ aacDecInfo->fillExtType = (int)((psi->fillBuf[0] >> 4) & 0x0f);
+ if (aacDecInfo->fillExtType == EXT_SBR_DATA || aacDecInfo->fillExtType == EXT_SBR_DATA_CRC) {
+ aacDecInfo->sbrEnabled = 1;
+ }
+ }
+#endif
+
+ aacDecInfo->fillBuf = psi->fillBuf;
+ aacDecInfo->fillCount = psi->fillCount;
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeNextElement
+ *
+ * Description: decode next syntactic element in AAC frame
+ *
+ * Inputs: valid AACDecInfo struct
+ * double pointer to buffer containing next element
+ * pointer to bit offset
+ * pointer to number of valid bits remaining in buf
+ *
+ * Outputs: type of element decoded (aacDecInfo->currBlockID)
+ * type of element decoded last time (aacDecInfo->prevBlockID)
+ * updated aacDecInfo state, depending on which element was decoded
+ * updated buffer pointer
+ * updated bit offset
+ * updated number of available bits
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int DecodeNextElement(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail)
+{
+ int err, bitsUsed;
+ PSInfoBase *psi;
+ BitStreamInfo bsi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ /* init bitstream reader */
+ if (AACDataSource == 1) {
+ SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf);
+ GetBits(&bsi, *bitOffset);
+ }
+
+ /* read element ID (save last ID for SBR purposes) */
+ aacDecInfo->prevBlockID = aacDecInfo->currBlockID;
+ aacDecInfo->currBlockID = GetBits(&bsi, NUM_SYN_ID_BITS);
+
+ /* set defaults (could be overwritten by DecodeXXXElement(), depending on currBlockID) */
+ psi->commonWin = 0;
+
+ err = 0;
+ switch (aacDecInfo->currBlockID) {
+ case AAC_ID_SCE:
+ err = DecodeSingleChannelElement(aacDecInfo, &bsi);
+ break;
+ case AAC_ID_CPE:
+ err = DecodeChannelPairElement(aacDecInfo, &bsi);
+ break;
+ case AAC_ID_CCE:
+ /* TODO - implement CCE decoding */
+ break;
+ case AAC_ID_LFE:
+ err = DecodeLFEChannelElement(aacDecInfo, &bsi);
+ break;
+ case AAC_ID_DSE:
+ err = DecodeDataStreamElement(aacDecInfo, &bsi);
+ break;
+ case AAC_ID_PCE:
+ err = DecodeProgramConfigElement(psi->pce + 0, &bsi);
+ break;
+ case AAC_ID_FIL:
+ err = DecodeFillElement(aacDecInfo, &bsi);
+ break;
+ case AAC_ID_END:
+ break;
+ }
+ if (err) {
+ return ERR_AAC_SYNTAX_ELEMENT;
+ }
+
+ if (AACDataSource == 1) {
+ /* update bitstream reader */
+ bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset);
+ *buf += (bitsUsed + *bitOffset) >> 3;
+ *bitOffset = (bitsUsed + *bitOffset) & 0x07;
+ *bitsAvail -= bitsUsed;
+
+ if (*bitsAvail < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+ return ERR_AAC_NONE;
+}
+
diff --git a/audio_codec/libraac/dequant.c b/audio_codec/libraac/dequant.c
new file mode 100644
index 0000000..e60517a
--- a/dev/null
+++ b/audio_codec/libraac/dequant.c
@@ -0,0 +1,382 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: dequant.c,v 1.2 2005/05/20 18:05:41 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * dequant.c - transform coefficient dequantization and short-block deinterleaving
+ **************************************************************************************/
+
+#include "coder.h"
+
+#include "assembly.h"
+
+//#include <core/dsp.h>
+#include <stdio.h>
+
+
+#define SF_OFFSET 100
+
+/* pow(2, i/4.0) for i = [0,1,2,3], format = Q30 */
+static const int pow14[4] = {
+ 0x40000000, 0x4c1bf829, 0x5a82799a, 0x6ba27e65
+};
+
+/* pow(2, i/4.0) * pow(j, 4.0/3.0) for i = [0,1,2,3], j = [0,1,2,...,15]
+ * format = Q28 for j = [0-3], Q25 for j = [4-15]
+ */
+static const int pow43_14[4][16] = {
+ {
+ 0x00000000, 0x10000000, 0x285145f3, 0x453a5cdb, /* Q28 */
+ 0x0cb2ff53, 0x111989d6, 0x15ce31c8, 0x1ac7f203, /* Q25 */
+ 0x20000000, 0x257106b9, 0x2b16b4a3, 0x30ed74b4, /* Q25 */
+ 0x36f23fa5, 0x3d227bd3, 0x437be656, 0x49fc823c, /* Q25 */
+ },
+ {
+ 0x00000000, 0x1306fe0a, 0x2ff221af, 0x52538f52,
+ 0x0f1a1bf4, 0x1455ccc2, 0x19ee62a8, 0x1fd92396,
+ 0x260dfc14, 0x2c8694d8, 0x333dcb29, 0x3a2f5c7a,
+ 0x4157aed5, 0x48b3aaa3, 0x50409f76, 0x57fc3010,
+ },
+ {
+ 0x00000000, 0x16a09e66, 0x39047c0f, 0x61e734aa,
+ 0x11f59ac4, 0x182ec633, 0x1ed66a45, 0x25dfc55a,
+ 0x2d413ccd, 0x34f3462d, 0x3cefc603, 0x4531ab69,
+ 0x4db4adf8, 0x56752054, 0x5f6fcfcd, 0x68a1eca1,
+ },
+ {
+ 0x00000000, 0x1ae89f99, 0x43ce3e4b, 0x746d57b2,
+ 0x155b8109, 0x1cc21cdc, 0x24ac1839, 0x2d0a479e,
+ 0x35d13f33, 0x3ef80748, 0x48775c93, 0x524938cd,
+ 0x5c68841d, 0x66d0df0a, 0x717e7bfe, 0x7c6e0305,
+ },
+};
+
+/* pow(j, 4.0 / 3.0) for j = [16,17,18,...,63], format = Q23 */
+static const int pow43[48] = {
+ 0x1428a2fa, 0x15db1bd6, 0x1796302c, 0x19598d85,
+ 0x1b24e8bb, 0x1cf7fcfa, 0x1ed28af2, 0x20b4582a,
+ 0x229d2e6e, 0x248cdb55, 0x26832fda, 0x28800000,
+ 0x2a832287, 0x2c8c70a8, 0x2e9bc5d8, 0x30b0ff99,
+ 0x32cbfd4a, 0x34eca001, 0x3712ca62, 0x393e6088,
+ 0x3b6f47e0, 0x3da56717, 0x3fe0a5fc, 0x4220ed72,
+ 0x44662758, 0x46b03e7c, 0x48ff1e87, 0x4b52b3f3,
+ 0x4daaebfd, 0x5007b497, 0x5268fc62, 0x54ceb29c,
+ 0x5738c721, 0x59a72a59, 0x5c19cd35, 0x5e90a129,
+ 0x610b9821, 0x638aa47f, 0x660db90f, 0x6894c90b,
+ 0x6b1fc80c, 0x6daeaa0d, 0x70416360, 0x72d7e8b0,
+ 0x75722ef9, 0x78102b85, 0x7ab1d3ec, 0x7d571e09,
+};
+
+/* sqrt(0.5), format = Q31 */
+#define SQRTHALF 0x5a82799a
+
+/* Minimax polynomial approximation to pow(x, 4/3), over the range
+ * poly43lo: x = [0.5, 0.7071]
+ * poly43hi: x = [0.7071, 1.0]
+ *
+ * Relative error < 1E-7
+ * Coefs are scaled by 4, 2, 1, 0.5, 0.25
+ */
+static const int poly43lo[5] = { 0x29a0bda9, 0xb02e4828, 0x5957aa1b, 0x236c498d, 0xff581859 };
+static const int poly43hi[5] = { 0x10852163, 0xd333f6a4, 0x46e9408b, 0x27c2cef0, 0xfef577b4 };
+
+/* pow2exp[i] = pow(2, i*4/3) exponent */
+static const int pow2exp[8] = { 14, 13, 11, 10, 9, 7, 6, 5 };
+
+/* pow2exp[i] = pow(2, i*4/3) fraction */
+static const int pow2frac[8] = {
+ 0x6597fa94, 0x50a28be6, 0x7fffffff, 0x6597fa94,
+ 0x50a28be6, 0x7fffffff, 0x6597fa94, 0x50a28be6
+};
+
+/**************************************************************************************
+ * Function: DequantBlock
+ *
+ * Description: dequantize one block of transform coefficients (in-place)
+ *
+ * Inputs: quantized transform coefficients, range = [0, 8191]
+ * number of samples to dequantize
+ * scalefactor for this block of data, range = [0, 256]
+ *
+ * Outputs: dequantized transform coefficients in Q(FBITS_OUT_DQ_OFF)
+ *
+ * Return: guard bit mask (OR of abs value of all dequantized coefs)
+ *
+ * Notes: applies dequant formula y = pow(x, 4.0/3.0) * pow(2, (scale - 100)/4.0)
+ * * pow(2, FBITS_OUT_DQ_OFF)
+ * clips outputs to Q(FBITS_OUT_DQ_OFF)
+ * output has no minimum number of guard bits
+ **************************************************************************************/
+static int DequantBlock(int *inbuf, int nSamps, int scale)
+{
+ int iSamp, scalef, scalei, x, y, gbMask, shift, tab4[4];
+ const int *tab16, *coef;
+
+ if (nSamps <= 0) {
+ return 0;
+ }
+
+ scale -= SF_OFFSET; /* new range = [-100, 156] */
+
+ /* with two's complement numbers, scalei/scalef factorization works for pos and neg values of scale:
+ * [+4...+7] >> 2 = +1, [ 0...+3] >> 2 = 0, [-4...-1] >> 2 = -1, [-8...-5] >> 2 = -2 ...
+ * (-1 & 0x3) = 3, (-2 & 0x3) = 2, (-3 & 0x3) = 1, (0 & 0x3) = 0
+ *
+ * Example: 2^(-5/4) = 2^(-1) * 2^(-1/4) = 2^-2 * 2^(3/4)
+ */
+ tab16 = pow43_14[scale & 0x3];
+ scalef = pow14[scale & 0x3];
+ scalei = (scale >> 2) + FBITS_OUT_DQ_OFF;
+
+ /* cache first 4 values:
+ * tab16[j] = Q28 for j = [0,3]
+ * tab4[x] = x^(4.0/3.0) * 2^(0.25*scale), Q(FBITS_OUT_DQ_OFF)
+ */
+ shift = 28 - scalei;
+ if (shift > 31) {
+ tab4[0] = tab4[1] = tab4[2] = tab4[3] = 0;
+ } else if (shift <= 0) {
+ shift = -shift;
+ if (shift > 31) {
+ shift = 31;
+ }
+ for (x = 0; x < 4; x++) {
+ y = tab16[x];
+ if (y > (0x7fffffff >> shift)) {
+ y = 0x7fffffff; /* clip (rare) */
+ } else {
+ y <<= shift;
+ }
+ tab4[x] = y;
+ }
+ } else {
+ tab4[0] = 0;
+ tab4[1] = tab16[1] >> shift;
+ tab4[2] = tab16[2] >> shift;
+ tab4[3] = tab16[3] >> shift;
+ }
+
+ gbMask = 0;
+ do {
+ iSamp = *inbuf;
+ x = FASTABS(iSamp);
+
+ if (x < 4) {
+ y = tab4[x];
+ } else {
+
+ if (x < 16) {
+ /* result: y = Q25 (tab16 = Q25) */
+ y = tab16[x];
+ shift = 25 - scalei;
+ } else if (x < 64) {
+ /* result: y = Q21 (pow43tab[j] = Q23, scalef = Q30) */
+ y = pow43[x - 16];
+ shift = 21 - scalei;
+ y = MULSHIFT32(y, scalef);
+ } else {
+ /* normalize to [0x40000000, 0x7fffffff]
+ * input x = [64, 8191] = [64, 2^13-1]
+ * ranges:
+ * shift = 7: 64 - 127
+ * shift = 6: 128 - 255
+ * shift = 5: 256 - 511
+ * shift = 4: 512 - 1023
+ * shift = 3: 1024 - 2047
+ * shift = 2: 2048 - 4095
+ * shift = 1: 4096 - 8191
+ */
+ x <<= 17;
+ shift = 0;
+ if (x < 0x08000000) {
+ x <<= 4, shift += 4;
+ }
+ if (x < 0x20000000) {
+ x <<= 2, shift += 2;
+ }
+ if (x < 0x40000000) {
+ x <<= 1, shift += 1;
+ }
+
+ coef = (x < SQRTHALF) ? poly43lo : poly43hi;
+
+ /* polynomial */
+ y = coef[0];
+ y = MULSHIFT32(y, x) + coef[1];
+ y = MULSHIFT32(y, x) + coef[2];
+ y = MULSHIFT32(y, x) + coef[3];
+ y = MULSHIFT32(y, x) + coef[4];
+ y = MULSHIFT32(y, pow2frac[shift]) << 3;
+
+ /* fractional scale
+ * result: y = Q21 (pow43tab[j] = Q23, scalef = Q30)
+ */
+ y = MULSHIFT32(y, scalef); /* now y is Q24 */
+ shift = 24 - scalei - pow2exp[shift];
+ }
+
+ /* integer scale */
+ if (shift <= 0) {
+ shift = -shift;
+ if (shift > 31) {
+ shift = 31;
+ }
+
+ if (y > (0x7fffffff >> shift)) {
+ y = 0x7fffffff; /* clip (rare) */
+ } else {
+ y <<= shift;
+ }
+ } else {
+ if (shift > 31) {
+ shift = 31;
+ }
+ y >>= shift;
+ }
+ }
+
+ /* sign and store (gbMask used to count GB's) */
+ gbMask |= y;
+
+ /* apply sign */
+ iSamp >>= 31;
+ y ^= iSamp;
+ y -= iSamp;
+
+ *inbuf++ = y;
+ } while (--nSamps);
+
+ return gbMask;
+}
+
+/**************************************************************************************
+ * Function: Dequantize
+ *
+ * Description: dequantize all transform coefficients for one channel
+ *
+ * Inputs: valid AACDecInfo struct (including unpacked, quantized coefficients)
+ * index of current channel
+ *
+ * Outputs: dequantized coefficients, including short-block deinterleaving
+ * flags indicating if intensity and/or PNS is active
+ * minimum guard bit count for dequantized coefficients
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int Dequantize(AACDecInfo *aacDecInfo, int ch)
+{
+ int gp, cb, sfb, win, width, nSamps, gbMask;
+ int *coef;
+ const short *sfbTab;
+ unsigned char *sfbCodeBook;
+ short *scaleFactors;
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ if (icsInfo->winSequence == 2) {
+ sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_SHORT;
+ } else {
+ sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_LONG;
+ }
+ coef = psi->coef[ch];
+ sfbCodeBook = psi->sfbCodeBook[ch];
+ scaleFactors = psi->scaleFactors[ch];
+
+ psi->intensityUsed[ch] = 0;
+ psi->pnsUsed[ch] = 0;
+ gbMask = 0;
+ for (gp = 0; gp < icsInfo->numWinGroup; gp++) {
+ for (win = 0; win < icsInfo->winGroupLen[gp]; win++) {
+ for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) {
+ /* dequantize one scalefactor band (not necessary if codebook is intensity or PNS)
+ * for zero codebook, still run dequantizer in case non-zero pulse data was added
+ */
+ cb = (int)(sfbCodeBook[sfb]);
+ width = sfbTab[sfb + 1] - sfbTab[sfb];
+ if (cb >= 0 && cb <= 11) {
+ gbMask |= DequantBlock(coef, width, scaleFactors[sfb]);
+ } else if (cb == 13) {
+ psi->pnsUsed[ch] = 1;
+ } else if (cb == 14 || cb == 15) {
+ psi->intensityUsed[ch] = 1; /* should only happen if ch == 1 */
+ }
+ coef += width;
+ }
+ coef += (nSamps - sfbTab[icsInfo->maxSFB]);
+ }
+ sfbCodeBook += icsInfo->maxSFB;
+ scaleFactors += icsInfo->maxSFB;
+ }
+ aacDecInfo->pnsUsed |= psi->pnsUsed[ch]; /* set flag if PNS used for any channel */
+
+ /* calculate number of guard bits in dequantized data */
+ psi->gbCurrent[ch] = CLZ(gbMask) - 1;
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: DeinterleaveShortBlocks
+ *
+ * Description: deinterleave transform coefficients in short blocks for one channel
+ *
+ * Inputs: valid AACDecInfo struct (including unpacked, quantized coefficients)
+ * index of current channel
+ *
+ * Outputs: deinterleaved coefficients (window groups into 8 separate windows)
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: only necessary if deinterleaving not part of Huffman decoding
+ **************************************************************************************/
+int DeinterleaveShortBlocks(AACDecInfo *aacDecInfo, int ch)
+{
+ /* not used for this implementation - short block deinterleaving performed during Huffman decoding */
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/libraac/fft.c b/audio_codec/libraac/fft.c
new file mode 100644
index 0000000..e17a2bd
--- a/dev/null
+++ b/audio_codec/libraac/fft.c
@@ -0,0 +1,393 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: fft.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * fft.c - Ken's optimized radix-4 DIT FFT, optional radix-8 first pass for odd log2(N)
+ **************************************************************************************/
+
+#include "coder.h"
+
+#include "assembly.h"
+
+
+#define NUM_FFT_SIZES 2
+static const int nfftTab[NUM_FFT_SIZES] = {64, 512};
+static const int nfftlog2Tab[NUM_FFT_SIZES] = {6, 9};
+
+#define SQRT1_2 0x5a82799a /* sqrt(1/2) in Q31 */
+
+#define swapcplx(p0,p1) \
+ t = p0; t1 = *(&(p0)+1); p0 = p1; *(&(p0)+1) = *(&(p1)+1); p1 = t; *(&(p1)+1) = t1
+
+/**************************************************************************************
+ * Function: BitReverse
+ *
+ * Description: Ken's fast in-place bit reverse, using super-small table
+ *
+ * Inputs: buffer of samples
+ * table index (for transform size)
+ *
+ * Outputs: bit-reversed samples in same buffer
+ *
+ * Return: none
+ **************************************************************************************/
+static void BitReverse(int *inout, int tabidx)
+{
+ int *part0, *part1;
+ int a, b, t, t1;
+ const unsigned char* tab = bitrevtab + bitrevtabOffset[tabidx];
+ int nbits = nfftlog2Tab[tabidx];
+
+ part0 = inout;
+ part1 = inout + (1 << nbits);
+
+ while ((a = *tab++) != 0) {
+ b = *tab++;
+
+ swapcplx(part0[4 * a + 0], part0[4 * b + 0]); /* 0xxx0 <-> 0yyy0 */
+ swapcplx(part0[4 * a + 2], part1[4 * b + 0]); /* 0xxx1 <-> 1yyy0 */
+ swapcplx(part1[4 * a + 0], part0[4 * b + 2]); /* 1xxx0 <-> 0yyy1 */
+ swapcplx(part1[4 * a + 2], part1[4 * b + 2]); /* 1xxx1 <-> 1yyy1 */
+ }
+
+ do {
+ swapcplx(part0[4 * a + 2], part1[4 * a + 0]); /* 0xxx1 <-> 1xxx0 */
+ } while ((a = *tab++) != 0);
+}
+
+/**************************************************************************************
+ * Function: R4FirstPass
+ *
+ * Description: radix-4 trivial pass for decimation-in-time FFT
+ *
+ * Inputs: buffer of (bit-reversed) samples
+ * number of R4 butterflies per group (i.e. nfft / 4)
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 2 guard bits, gains no integer bits,
+ * guard bits out = guard bits in - 2
+ **************************************************************************************/
+static void R4FirstPass(int *x, int bg)
+{
+ int ar, ai, br, bi, cr, ci, dr, di;
+
+ for (; bg != 0; bg--) {
+
+ ar = x[0] + x[2];
+ br = x[0] - x[2];
+ ai = x[1] + x[3];
+ bi = x[1] - x[3];
+ cr = x[4] + x[6];
+ dr = x[4] - x[6];
+ ci = x[5] + x[7];
+ di = x[5] - x[7];
+
+ /* max per-sample gain = 4.0 (adding 4 inputs together) */
+ x[0] = ar + cr;
+ x[4] = ar - cr;
+ x[1] = ai + ci;
+ x[5] = ai - ci;
+ x[2] = br + di;
+ x[6] = br - di;
+ x[3] = bi - dr;
+ x[7] = bi + dr;
+
+ x += 8;
+ }
+}
+
+/**************************************************************************************
+ * Function: R8FirstPass
+ *
+ * Description: radix-8 trivial pass for decimation-in-time FFT
+ *
+ * Inputs: buffer of (bit-reversed) samples
+ * number of R8 butterflies per group (i.e. nfft / 8)
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 3 guard bits, gains 1 integer bit
+ * guard bits out = guard bits in - 3 (if inputs are full scale)
+ * or guard bits in - 2 (if inputs bounded to +/- sqrt(2)/2)
+ * see scaling comments in code
+ **************************************************************************************/
+static void R8FirstPass(int *x, int bg)
+{
+ int ar, ai, br, bi, cr, ci, dr, di;
+ int sr, si, tr, ti, ur, ui, vr, vi;
+ int wr, wi, xr, xi, yr, yi, zr, zi;
+
+ for (; bg != 0; bg--) {
+
+ ar = x[0] + x[2];
+ br = x[0] - x[2];
+ ai = x[1] + x[3];
+ bi = x[1] - x[3];
+ cr = x[4] + x[6];
+ dr = x[4] - x[6];
+ ci = x[5] + x[7];
+ di = x[5] - x[7];
+
+ sr = ar + cr;
+ ur = ar - cr;
+ si = ai + ci;
+ ui = ai - ci;
+ tr = br - di;
+ vr = br + di;
+ ti = bi + dr;
+ vi = bi - dr;
+
+ ar = x[ 8] + x[10];
+ br = x[ 8] - x[10];
+ ai = x[ 9] + x[11];
+ bi = x[ 9] - x[11];
+ cr = x[12] + x[14];
+ dr = x[12] - x[14];
+ ci = x[13] + x[15];
+ di = x[13] - x[15];
+
+ /* max gain of wr/wi/yr/yi vs input = 2
+ * (sum of 4 samples >> 1)
+ */
+ wr = (ar + cr) >> 1;
+ yr = (ar - cr) >> 1;
+ wi = (ai + ci) >> 1;
+ yi = (ai - ci) >> 1;
+
+ /* max gain of output vs input = 4
+ * (sum of 4 samples >> 1 + sum of 4 samples >> 1)
+ */
+ x[ 0] = (sr >> 1) + wr;
+ x[ 8] = (sr >> 1) - wr;
+ x[ 1] = (si >> 1) + wi;
+ x[ 9] = (si >> 1) - wi;
+ x[ 4] = (ur >> 1) + yi;
+ x[12] = (ur >> 1) - yi;
+ x[ 5] = (ui >> 1) - yr;
+ x[13] = (ui >> 1) + yr;
+
+ ar = br - di;
+ cr = br + di;
+ ai = bi + dr;
+ ci = bi - dr;
+
+ /* max gain of xr/xi/zr/zi vs input = 4*sqrt(2)/2 = 2*sqrt(2)
+ * (sum of 8 samples, multiply by sqrt(2)/2, implicit >> 1 from Q31)
+ */
+ xr = MULSHIFT32(SQRT1_2, ar - ai);
+ xi = MULSHIFT32(SQRT1_2, ar + ai);
+ zr = MULSHIFT32(SQRT1_2, cr - ci);
+ zi = MULSHIFT32(SQRT1_2, cr + ci);
+
+ /* max gain of output vs input = (2 + 2*sqrt(2) ~= 4.83)
+ * (sum of 4 samples >> 1, plus xr/xi/zr/zi with gain of 2*sqrt(2))
+ * in absolute terms, we have max gain of appx 9.656 (4 + 0.707*8)
+ * but we also gain 1 int bit (from MULSHIFT32 or from explicit >> 1)
+ */
+ x[ 6] = (tr >> 1) - xr;
+ x[14] = (tr >> 1) + xr;
+ x[ 7] = (ti >> 1) - xi;
+ x[15] = (ti >> 1) + xi;
+ x[ 2] = (vr >> 1) + zi;
+ x[10] = (vr >> 1) - zi;
+ x[ 3] = (vi >> 1) - zr;
+ x[11] = (vi >> 1) + zr;
+
+ x += 16;
+ }
+}
+
+/**************************************************************************************
+ * Function: R4Core
+ *
+ * Description: radix-4 pass for decimation-in-time FFT
+ *
+ * Inputs: buffer of samples
+ * number of R4 butterflies per group
+ * number of R4 groups per pass
+ * pointer to twiddle factors tables
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: gain 2 integer bits per pass (see scaling comments in code)
+ * min 1 GB in
+ * gbOut = gbIn - 1 (short block) or gbIn - 2 (long block)
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ **************************************************************************************/
+static void R4Core(int *x, int bg, int gp, int *wtab)
+{
+ int ar, ai, br, bi, cr, ci, dr, di, tr, ti;
+ int wd, ws, wi;
+ int i, j, step;
+ int *xptr, *wptr;
+
+ for (; bg != 0; gp <<= 2, bg >>= 2) {
+
+ step = 2 * gp;
+ xptr = x;
+
+ /* max per-sample gain, per group < 1 + 3*sqrt(2) ~= 5.25 if inputs x are full-scale
+ * do 3 groups for long block, 2 groups for short block (gain 2 int bits per group)
+ *
+ * very conservative scaling:
+ * group 1: max gain = 5.25, int bits gained = 2, gb used = 1 (2^3 = 8)
+ * group 2: max gain = 5.25^2 = 27.6, int bits gained = 4, gb used = 1 (2^5 = 32)
+ * group 3: max gain = 5.25^3 = 144.7, int bits gained = 6, gb used = 2 (2^8 = 256)
+ */
+ for (i = bg; i != 0; i--) {
+
+ wptr = wtab;
+
+ for (j = gp; j != 0; j--) {
+
+ ar = xptr[0];
+ ai = xptr[1];
+ xptr += step;
+
+ /* gain 2 int bits for br/bi, cr/ci, dr/di (MULSHIFT32 by Q30)
+ * gain 1 net GB
+ */
+ ws = wptr[0];
+ wi = wptr[1];
+ br = xptr[0];
+ bi = xptr[1];
+ wd = ws + 2 * wi;
+ tr = MULSHIFT32(wi, br + bi);
+ br = MULSHIFT32(wd, br) - tr; /* cos*br + sin*bi */
+ bi = MULSHIFT32(ws, bi) + tr; /* cos*bi - sin*br */
+ xptr += step;
+
+ ws = wptr[2];
+ wi = wptr[3];
+ cr = xptr[0];
+ ci = xptr[1];
+ wd = ws + 2 * wi;
+ tr = MULSHIFT32(wi, cr + ci);
+ cr = MULSHIFT32(wd, cr) - tr;
+ ci = MULSHIFT32(ws, ci) + tr;
+ xptr += step;
+
+ ws = wptr[4];
+ wi = wptr[5];
+ dr = xptr[0];
+ di = xptr[1];
+ wd = ws + 2 * wi;
+ tr = MULSHIFT32(wi, dr + di);
+ dr = MULSHIFT32(wd, dr) - tr;
+ di = MULSHIFT32(ws, di) + tr;
+ wptr += 6;
+
+ tr = ar;
+ ti = ai;
+ ar = (tr >> 2) - br;
+ ai = (ti >> 2) - bi;
+ br = (tr >> 2) + br;
+ bi = (ti >> 2) + bi;
+
+ tr = cr;
+ ti = ci;
+ cr = tr + dr;
+ ci = di - ti;
+ dr = tr - dr;
+ di = di + ti;
+
+ xptr[0] = ar + ci;
+ xptr[1] = ai + dr;
+ xptr -= step;
+ xptr[0] = br - cr;
+ xptr[1] = bi - di;
+ xptr -= step;
+ xptr[0] = ar - ci;
+ xptr[1] = ai - dr;
+ xptr -= step;
+ xptr[0] = br + cr;
+ xptr[1] = bi + di;
+ xptr += 2;
+ }
+ xptr += 3 * step;
+ }
+ wtab += 3 * step;
+ }
+}
+
+
+/**************************************************************************************
+ * Function: R4FFT
+ *
+ * Description: Ken's very fast in-place radix-4 decimation-in-time FFT
+ *
+ * Inputs: table index (for transform size)
+ * buffer of samples (non bit-reversed)
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 5 guard bits in for nfft <= 512
+ * gbOut = gbIn - 4 (assuming input is from PreMultiply)
+ * gains log2(nfft) - 2 int bits total
+ * so gain 7 int bits (LONG), 4 int bits (SHORT)
+ **************************************************************************************/
+void R4FFT(int tabidx, int *x)
+{
+ int order = nfftlog2Tab[tabidx];
+ int nfft = nfftTab[tabidx];
+
+ /* decimation in time */
+ BitReverse(x, tabidx);
+
+ if (order & 0x1) {
+ /* long block: order = 9, nfft = 512 */
+ R8FirstPass(x, nfft >> 3); /* gain 1 int bit, lose 2 GB */
+ R4Core(x, nfft >> 5, 8, (int *)twidTabOdd); /* gain 6 int bits, lose 2 GB */
+ } else {
+ /* short block: order = 6, nfft = 64 */
+ R4FirstPass(x, nfft >> 2); /* gain 0 int bits, lose 2 GB */
+ R4Core(x, nfft >> 4, 4, (int *)twidTabEven); /* gain 4 int bits, lose 1 GB */
+ }
+}
diff --git a/audio_codec/libraac/filefmt.c b/audio_codec/libraac/filefmt.c
new file mode 100644
index 0000000..cce8ba0
--- a/dev/null
+++ b/audio_codec/libraac/filefmt.c
@@ -0,0 +1,531 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: filefmt.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * filefmt.c - ADIF and ADTS header decoding, raw block handling
+ **************************************************************************************/
+
+#include "coder.h"
+//#include <core/dsp.h>
+#include <stdio.h>
+
+/**************************************************************************************
+* Function: UnpackADTSHeader
+*
+* Description: parse the ADTS frame header and initialize decoder state
+*
+* Inputs: valid AACDecInfo struct
+* double pointer to buffer with complete ADTS frame header (byte aligned)
+* header size = 7 bytes, plus 2 if CRC
+*
+* Outputs: filled in ADTS struct
+* updated buffer pointer
+* updated bit offset
+* updated number of available bits
+*
+* Return: 0 if successful, error code (< 0) if error
+*
+* TODO: test CRC
+* verify that fixed fields don't change between frames
+**************************************************************************************/
+int UnpackADTSHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail)
+{
+ int bitsUsed;
+ PSInfoBase *psi;
+ BitStreamInfo bsi;
+ ADTSHeader *fhADTS;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ fhADTS = &(psi->fhADTS);
+
+ if (AACDataSource == 1) {
+ /* init bitstream reader */
+ SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf);
+ GetBits(&bsi, *bitOffset);
+
+ /* verify that first 12 bits of header are syncword */
+ if (GetBits(&bsi, 12) != 0x0fff) {
+ return ERR_AAC_INVALID_ADTS_HEADER;
+ }
+ }
+ /* fixed fields - should not change from frame to frame */
+ fhADTS->id = GetBits(&bsi, 1);
+ fhADTS->layer = GetBits(&bsi, 2);
+ fhADTS->protectBit = GetBits(&bsi, 1);
+ fhADTS->profile = GetBits(&bsi, 2);
+ fhADTS->sampRateIdx = GetBits(&bsi, 4);
+ fhADTS->privateBit = GetBits(&bsi, 1);
+ fhADTS->channelConfig = GetBits(&bsi, 3);
+ fhADTS->origCopy = GetBits(&bsi, 1);
+ fhADTS->home = GetBits(&bsi, 1);
+
+ /* variable fields - can change from frame to frame */
+ fhADTS->copyBit = GetBits(&bsi, 1);
+ fhADTS->copyStart = GetBits(&bsi, 1);
+ fhADTS->frameLength = GetBits(&bsi, 13);
+ fhADTS->bufferFull = GetBits(&bsi, 11);
+ fhADTS->numRawDataBlocks = GetBits(&bsi, 2) + 1;
+
+ /* note - MPEG4 spec, correction 1 changes how CRC is handled when protectBit == 0 and numRawDataBlocks > 1 */
+ if (fhADTS->protectBit == 0) {
+ fhADTS->crcCheckWord = GetBits(&bsi, 16);
+ }
+
+ /* byte align */
+ ByteAlignBitstream(&bsi); /* should always be aligned anyway */
+
+ /* check validity of header */
+ if (fhADTS->layer != 0 || fhADTS->profile != AAC_PROFILE_LC ||
+ fhADTS->sampRateIdx >= NUM_SAMPLE_RATES || fhADTS->channelConfig >= NUM_DEF_CHAN_MAPS) {
+ return ERR_AAC_INVALID_ADTS_HEADER;
+ }
+
+#ifndef AAC_ENABLE_MPEG4
+ if (fhADTS->id != 1) {
+ return ERR_AAC_MPEG4_UNSUPPORTED;
+ }
+#endif
+
+ /* update codec info */
+ psi->sampRateIdx = fhADTS->sampRateIdx;
+ if (!psi->useImpChanMap) {
+ psi->nChans = channelMapTab[fhADTS->channelConfig];
+ }
+
+ /* syntactic element fields will be read from bitstream for each element */
+ aacDecInfo->prevBlockID = AAC_ID_INVALID;
+ aacDecInfo->currBlockID = AAC_ID_INVALID;
+ aacDecInfo->currInstTag = -1;
+
+ /* fill in user-accessible data (TODO - calc bitrate, handle tricky channel config cases) */
+ aacDecInfo->bitRate = 0;
+ aacDecInfo->nChans = psi->nChans;
+ aacDecInfo->sampRate = sampRateTab[psi->sampRateIdx];
+ aacDecInfo->profile = fhADTS->profile;
+ aacDecInfo->sbrEnabled = 0;
+ aacDecInfo->adtsBlocksLeft = fhADTS->numRawDataBlocks;
+
+ if (AACDataSource == 1) {
+ /* update bitstream reader */
+ bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset);
+ *buf += (bitsUsed + *bitOffset) >> 3;
+ *bitOffset = (bitsUsed + *bitOffset) & 0x07;
+ *bitsAvail -= bitsUsed ;
+ if (*bitsAvail < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: GetADTSChannelMapping
+ *
+ * Description: determine the number of channels from implicit mapping rules
+ *
+ * Inputs: valid AACDecInfo struct
+ * pointer to start of raw_data_block
+ * bit offset
+ * bits available
+ *
+ * Outputs: updated number of channels
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: calculates total number of channels using rules in 14496-3, 4.5.1.2.1
+ * does not attempt to deduce speaker geometry
+ **************************************************************************************/
+int GetADTSChannelMapping(AACDecInfo *aacDecInfo, unsigned char *buf, int bitOffset, int bitsAvail)
+{
+ int ch, nChans, elementChans, err;
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ nChans = 0;
+ do {
+ /* parse next syntactic element */
+ err = DecodeNextElement(aacDecInfo, &buf, &bitOffset, &bitsAvail);
+ if (err) {
+ return err;
+ }
+
+ elementChans = elementNumChans[aacDecInfo->currBlockID];
+ nChans += elementChans;
+
+ for (ch = 0; ch < elementChans; ch++) {
+ err = DecodeNoiselessData(aacDecInfo, &buf, &bitOffset, &bitsAvail, ch);
+ if (err) {
+ return err;
+ }
+ }
+ } while (aacDecInfo->currBlockID != AAC_ID_END);
+
+ if (nChans <= 0) {
+ return ERR_AAC_CHANNEL_MAP;
+ }
+
+ /* update number of channels in codec state and user-accessible info structs */
+ psi->nChans = nChans;
+ aacDecInfo->nChans = psi->nChans;
+ psi->useImpChanMap = 1;
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: GetNumChannelsADIF
+ *
+ * Description: get number of channels from program config elements in an ADIF file
+ *
+ * Inputs: array of filled-in program config element structures
+ * number of PCE's
+ *
+ * Outputs: none
+ *
+ * Return: total number of channels in file
+ * -1 if error (invalid number of PCE's or unsupported mode)
+ **************************************************************************************/
+static int GetNumChannelsADIF(ProgConfigElement *fhPCE, int nPCE)
+{
+ int i, j, nChans;
+
+ if (nPCE < 1 || nPCE > MAX_NUM_PCE_ADIF) {
+ return -1;
+ }
+
+ nChans = 0;
+ for (i = 0; i < nPCE; i++) {
+ /* for now: only support LC, no channel coupling */
+ if (fhPCE[i].profile != AAC_PROFILE_LC || fhPCE[i].numCCE > 0) {
+ return -1;
+ }
+
+ /* add up number of channels in all channel elements (assume all single-channel) */
+ nChans += fhPCE[i].numFCE;
+ nChans += fhPCE[i].numSCE;
+ nChans += fhPCE[i].numBCE;
+ nChans += fhPCE[i].numLCE;
+
+ /* add one more for every element which is a channel pair */
+ for (j = 0; j < fhPCE[i].numFCE; j++) {
+ if (CHAN_ELEM_IS_CPE(fhPCE[i].fce[j])) {
+ nChans++;
+ }
+ }
+ for (j = 0; j < fhPCE[i].numSCE; j++) {
+ if (CHAN_ELEM_IS_CPE(fhPCE[i].sce[j])) {
+ nChans++;
+ }
+ }
+ for (j = 0; j < fhPCE[i].numBCE; j++) {
+ if (CHAN_ELEM_IS_CPE(fhPCE[i].bce[j])) {
+ nChans++;
+ }
+ }
+
+ }
+
+ return nChans;
+}
+
+/**************************************************************************************
+ * Function: GetSampleRateIdxADIF
+ *
+ * Description: get sampling rate index from program config elements in an ADIF file
+ *
+ * Inputs: array of filled-in program config element structures
+ * number of PCE's
+ *
+ * Outputs: none
+ *
+ * Return: sample rate of file
+ * -1 if error (invalid number of PCE's or sample rate mismatch)
+ **************************************************************************************/
+static int GetSampleRateIdxADIF(ProgConfigElement *fhPCE, int nPCE)
+{
+ int i, idx;
+
+ if (nPCE < 1 || nPCE > MAX_NUM_PCE_ADIF) {
+ return -1;
+ }
+
+ /* make sure all PCE's have the same sample rate */
+ idx = fhPCE[0].sampRateIdx;
+ for (i = 1; i < nPCE; i++) {
+ if (fhPCE[i].sampRateIdx != idx) {
+ return -1;
+ }
+ }
+
+ return idx;
+}
+
+/**************************************************************************************
+ * Function: UnpackADIFHeader
+ *
+ * Description: parse the ADIF file header and initialize decoder state
+ *
+ * Inputs: valid AACDecInfo struct
+ * double pointer to buffer with complete ADIF header
+ * (starting at 'A' in 'ADIF' tag)
+ * pointer to bit offset
+ * pointer to number of valid bits remaining in inbuf
+ *
+ * Outputs: filled-in ADIF struct
+ * updated buffer pointer
+ * updated bit offset
+ * updated number of available bits
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int UnpackADIFHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail)
+{
+ int i, bitsUsed;
+ PSInfoBase *psi;
+ BitStreamInfo bsi;
+ ADIFHeader *fhADIF;
+ ProgConfigElement *pce;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ if (AACDataSource == 1) {
+ /* init bitstream reader */
+ SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf);
+ GetBits(&bsi, *bitOffset);
+ }
+
+ /* unpack ADIF file header */
+ fhADIF = &(psi->fhADIF);
+ pce = psi->pce;
+
+ /* verify that first 32 bits of header are "ADIF" */
+ if (GetBits(&bsi, 8) != 'A' || GetBits(&bsi, 8) != 'D' || GetBits(&bsi, 8) != 'I' || GetBits(&bsi, 8) != 'F') {
+ return ERR_AAC_INVALID_ADIF_HEADER;
+ }
+
+ /* read ADIF header fields */
+ fhADIF->copyBit = GetBits(&bsi, 1);
+ if (fhADIF->copyBit) {
+ for (i = 0; i < ADIF_COPYID_SIZE; i++) {
+ fhADIF->copyID[i] = GetBits(&bsi, 8);
+ }
+ }
+ fhADIF->origCopy = GetBits(&bsi, 1);
+ fhADIF->home = GetBits(&bsi, 1);
+ fhADIF->bsType = GetBits(&bsi, 1);
+ fhADIF->bitRate = GetBits(&bsi, 23);
+ fhADIF->numPCE = GetBits(&bsi, 4) + 1; /* add 1 (so range = [1, 16]) */
+ if (fhADIF->bsType == 0) {
+ fhADIF->bufferFull = GetBits(&bsi, 20);
+ }
+
+ /* parse all program config elements */
+ for (i = 0; i < fhADIF->numPCE; i++) {
+ DecodeProgramConfigElement(pce + i, &bsi);
+ }
+
+ /* byte align */
+ ByteAlignBitstream(&bsi);
+
+ /* update codec info */
+ psi->nChans = GetNumChannelsADIF(pce, fhADIF->numPCE);
+ psi->sampRateIdx = GetSampleRateIdxADIF(pce, fhADIF->numPCE);
+
+ /* check validity of header */
+ if (psi->nChans < 0 || psi->sampRateIdx < 0 || psi->sampRateIdx >= NUM_SAMPLE_RATES) {
+ return ERR_AAC_INVALID_ADIF_HEADER;
+ }
+
+ /* syntactic element fields will be read from bitstream for each element */
+ aacDecInfo->prevBlockID = AAC_ID_INVALID;
+ aacDecInfo->currBlockID = AAC_ID_INVALID;
+ aacDecInfo->currInstTag = -1;
+
+ /* fill in user-accessible data */
+ aacDecInfo->bitRate = fhADIF->bitRate;
+ aacDecInfo->nChans = psi->nChans;
+ aacDecInfo->sampRate = sampRateTab[psi->sampRateIdx];
+ aacDecInfo->profile = pce[0].profile;
+ aacDecInfo->sbrEnabled = 0;
+ if (AACDataSource == 1) {
+ /* update bitstream reader */
+ bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset);
+ *buf += (bitsUsed + *bitOffset) >> 3;
+ *bitOffset = (bitsUsed + *bitOffset) & 0x07;
+ *bitsAvail -= bitsUsed ;
+ if (*bitsAvail < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: SetRawBlockParams
+ *
+ * Description: set internal state variables for decoding a stream of raw data blocks
+ *
+ * Inputs: valid AACDecInfo struct
+ * flag indicating source of parameters (from previous headers or passed
+ * explicitly by caller)
+ * number of channels
+ * sample rate
+ * profile ID
+ *
+ * Outputs: updated state variables in aacDecInfo
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: if copyLast == 1, then psi->nChans, psi->sampRateIdx, and
+ * aacDecInfo->profile are not changed (it's assumed that we already
+ * set them, such as by a previous call to UnpackADTSHeader())
+ * if copyLast == 0, then the parameters we passed in are used instead
+ **************************************************************************************/
+int SetRawBlockParams(AACDecInfo *aacDecInfo, int copyLast, int nChans, int sampRate, int profile)
+{
+ int idx;
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ if (!copyLast) {
+ aacDecInfo->profile = profile;
+ psi->nChans = nChans;
+ for (idx = 0; idx < NUM_SAMPLE_RATES; idx++) {
+ if (sampRate == sampRateTab[idx]) {
+ psi->sampRateIdx = idx;
+ break;
+ }
+ }
+ if (idx == NUM_SAMPLE_RATES) {
+ return ERR_AAC_INVALID_FRAME;
+ }
+ }
+ aacDecInfo->nChans = psi->nChans;
+ aacDecInfo->sampRate = sampRateTab[psi->sampRateIdx];
+
+ /* check validity of header */
+ if (psi->sampRateIdx >= NUM_SAMPLE_RATES || psi->sampRateIdx < 0 || aacDecInfo->profile != AAC_PROFILE_LC) {
+ return ERR_AAC_RAWBLOCK_PARAMS;
+ }
+
+ return ERR_AAC_NONE;
+}
+/**************************************************************************************
+ * Function: PrepareRawBlock
+ *
+ * Description: reset per-block state variables for raw blocks (no ADTS/ADIF headers)
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: updated state variables in aacDecInfo
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int PrepareRawBlock(AACDecInfo *aacDecInfo)
+{
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ /* syntactic element fields will be read from bitstream for each element */
+ aacDecInfo->prevBlockID = AAC_ID_INVALID;
+ aacDecInfo->currBlockID = AAC_ID_INVALID;
+ aacDecInfo->currInstTag = -1;
+
+ /* fill in user-accessible data */
+ aacDecInfo->bitRate = 0;
+ aacDecInfo->sbrEnabled = 0;
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: FlushCodec
+ *
+ * Description: flush internal codec state (after seeking, for example)
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: updated state variables in aacDecInfo
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: only need to clear data which is persistent between frames
+ * (such as overlap buffer)
+ **************************************************************************************/
+int FlushCodec(AACDecInfo *aacDecInfo)
+{
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ ClearBuffer(psi->overlap, AAC_MAX_NCHANS * AAC_MAX_NSAMPS * sizeof(int));
+ ClearBuffer(psi->prevWinShape, AAC_MAX_NCHANS * sizeof(int));
+
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/libraac/ga_config.c b/audio_codec/libraac/ga_config.c
new file mode 100644
index 0000000..31bca7c
--- a/dev/null
+++ b/audio_codec/libraac/ga_config.c
@@ -0,0 +1,209 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: ga_config.c,v 1.1.1.1.2.1 2005/05/04 18:21:58 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/* parse an MPEG-4 general audio specific config structure from a bitstream */
+
+#include "ga_config.h"
+#include "aac_bitstream.h"
+
+const UINT32 aSampleRate[13] = {
+ 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000,
+ 11025, 8000, 7350
+};
+
+const UINT32 channelMapping[][4] = {
+ {0, 0, 0, 0},
+ {1, 0, 0, 0}, /* center */
+ {2, 0, 0, 0}, /* left, right */
+ {3, 0, 0, 0}, /* center, left, right */
+ {3, 0, 1, 0}, /* center, left, right, rear surround */
+ {3, 0, 2, 0}, /* center, left, right, left surround, right surround */
+ {3, 0, 2, 1}, /* center, left, right, left surround, right surround, lfe */
+ {5, 0, 2, 1}, /* center, left, right, left outside, right outside, left surround, right surround, lfe */
+};
+
+UINT32 ga_config_get_data(struct BITSTREAM *bs, ga_config_data *data)
+{
+ UINT32 i;
+ UINT32 index = 0;
+ UINT32 flag = 0;
+ UINT32 skip = 0;
+ UINT32 channelConfig = 0;
+
+ /* audio object type */
+ data->audioObjectType = readBits(bs, 5);
+
+ /* sampling frequency */
+ index = readBits(bs, 4);
+ if (index == 0xF) {
+ data->samplingFrequency = readBits(bs, 24);
+ } else {
+ data->samplingFrequency = aSampleRate[index];
+ }
+
+ /* channel configuration */
+ channelConfig = readBits(bs, 4);
+
+ /* sbr parameters */
+ if (data->audioObjectType == AACSBR) {
+ data->bSBR = TRUE;
+ index = readBits(bs, 4);
+ if (index == 0xF) {
+ data->extensionSamplingFrequency = readBits(bs, 24);
+ } else {
+ data->extensionSamplingFrequency = readBits(bs, 24);
+ }
+
+ data->audioObjectType = readBits(bs, 5);
+ } else {
+ data->extensionSamplingFrequency = data->samplingFrequency;
+ data->bSBR = FALSE;
+ }
+
+ /* make sure format is supported */
+ if (data->audioObjectType == AACMAIN ||
+ data->audioObjectType == AACLC ||
+ data->audioObjectType == AACLTP) {
+ flag = readBits(bs, 1);
+ data->frameLength = flag ? 960 : 1024;
+
+ flag = readBits(bs, 1);
+ if (flag) {
+ data->coreCoderDelay = readBits(bs, 14);
+ }
+
+ flag = readBits(bs, 1); /* extension flag - not defined */
+
+ if (channelConfig == 0) {
+ skip = readBits(bs, 4); /* ignore element instance tag */
+ skip = readBits(bs, 2); /* ignore object type */
+ skip = readBits(bs, 4); /* ignore sampling frequency index */
+
+ data->numFrontElements = readBits(bs, 4);
+ data->numSideElements = readBits(bs, 4);
+ data->numBackElements = readBits(bs, 4);
+ data->numLfeElements = readBits(bs, 2);
+ data->numAssocElements = readBits(bs, 3);
+ data->numValidCCElements = readBits(bs, 4);
+
+ if (readBits(bs, 1)) { /* mono mixdown present */
+ skip = readBits(bs, 4); /* ignore mixdown element */
+ }
+
+ if (readBits(bs, 1)) { /* stereo mixdown present */
+ skip = readBits(bs, 4); /* ignore mixdown element */
+ }
+
+ if (readBits(bs, 1)) { /* matrix mixdown present */
+ skip = readBits(bs, 2); /* ignore mixdown index */
+ skip = readBits(bs, 1); /* ignore surround enable */
+ }
+
+ for (i = 0; i < data->numFrontElements; i++) {
+ data->numFrontChannels += (1 + readBits(bs, 1));
+ skip = readBits(bs, 4); /* ignore tag select */
+ }
+ for (i = 0; i < data->numSideElements; i++) {
+ data->numSideChannels += (1 + readBits(bs, 1));
+ skip = readBits(bs, 4); /* ignore tag select */
+ }
+ for (i = 0; i < data->numBackElements; i++) {
+ data->numBackChannels += (1 + readBits(bs, 1));
+ skip = readBits(bs, 4); /* ignore tag select */
+ }
+ for (i = 0; i < data->numLfeElements; i++) {
+ skip = readBits(bs, 4); /* ignore tag select */
+ }
+ for (i = 0; i < data->numAssocElements; i++) {
+ skip = readBits(bs, 4); /* ignore tag select */
+ }
+ for (i = 0; i < data->numValidCCElements; i++) {
+ skip = readBits(bs, 1); /* ignore 'is_ind_sw' */
+ skip = readBits(bs, 4); /* ignore tag select */
+ }
+
+ byteAlign(bs);
+
+ /* ignore comment field data */
+ index = readBits(bs, 8);
+ for (i = 0; i < index; i++) {
+ skip = readBits(bs, 8);
+ }
+ } else {
+ if (channelConfig >= 8) {
+ return HXR_FAIL;
+ }
+
+ data->numFrontChannels = channelMapping[channelConfig][0];
+ data->numSideChannels = channelMapping[channelConfig][1];
+ data->numBackChannels = channelMapping[channelConfig][2];
+ data->numLfeElements = channelMapping[channelConfig][3];
+
+ data->numFrontElements = (data->numFrontChannels + 1) >> 1;
+ data->numSideElements = (data->numSideChannels + 1) >> 1;
+ data->numBackElements = (data->numBackChannels + 1) >> 1;
+ }
+
+ data->numChannels = data->numFrontChannels +
+ data->numSideChannels +
+ data->numBackChannels +
+ data->numLfeElements;
+
+ } else { /* format not supported */
+ return HXR_FAIL;
+ }
+
+ /* check for SBR info if there is enough data left in the bitstream */
+ if (!data->bSBR && bitsLeftInBitstream(bs) >= 16) {
+ if (readBits(bs, 11) == 0x2b7) {
+ if (readBits(bs, 5) == 5) {
+ data->bSBR = readBits(bs, 1);
+
+ if (data->bSBR) {
+ index = readBits(bs, 4);
+ if (index == 0xF) {
+ data->extensionSamplingFrequency = readBits(bs, 24);
+ } else {
+ data->extensionSamplingFrequency = aSampleRate[index];
+ }
+ }
+ }
+ }
+ }
+
+ return HXR_OK;
+}
diff --git a/audio_codec/libraac/ga_config.h b/audio_codec/libraac/ga_config.h
new file mode 100644
index 0000000..9f869e2
--- a/dev/null
+++ b/audio_codec/libraac/ga_config.h
@@ -0,0 +1,86 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: ga_config.h,v 1.1.1.1.2.1 2005/05/04 18:21:58 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/* parse an MPEG-4 general audio specific config structure from a bitstream */
+
+#ifndef GA_CONFIG_H
+#define GA_CONFIG_H
+
+#include "include/helix_types.h"
+#include "include/helix_result.h"
+#include "aac_bitstream.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ typedef struct ga_config_data_struct {
+ UINT32 audioObjectType;
+ UINT32 samplingFrequency;
+ UINT32 extensionSamplingFrequency;
+ UINT32 frameLength;
+ UINT32 coreCoderDelay;
+ UINT32 numChannels;
+ UINT32 numFrontChannels;
+ UINT32 numSideChannels;
+ UINT32 numBackChannels;
+ UINT32 numFrontElements;
+ UINT32 numSideElements;
+ UINT32 numBackElements;
+ UINT32 numLfeElements;
+ UINT32 numAssocElements;
+ UINT32 numValidCCElements;
+ HXBOOL bSBR;
+ } ga_config_data;
+
+ enum AudioObjectType {
+ AACMAIN = 1,
+ AACLC = 2,
+ AACSSR = 3,
+ AACLTP = 4,
+ AACSBR = 5,
+ AACSCALABLE = 6,
+ TWINVQ = 7
+ };
+
+ UINT32 ga_config_get_data(struct BITSTREAM *bs, ga_config_data *data);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef GA_CONFIG_H */
diff --git a/audio_codec/libraac/huffman.c b/audio_codec/libraac/huffman.c
new file mode 100644
index 0000000..2a5b869
--- a/dev/null
+++ b/audio_codec/libraac/huffman.c
@@ -0,0 +1,449 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: huffman.c,v 1.2 2005/05/24 16:01:55 albertofloyd Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * huffman.c - Huffman decoding
+ **************************************************************************************/
+
+#include "coder.h"
+
+/**************************************************************************************
+ * Function: DecodeHuffmanScalar
+ *
+ * Description: decode one Huffman symbol from bitstream
+ *
+ * Inputs: pointers to Huffman table and info struct
+ * left-aligned bit buffer with >= huffTabInfo->maxBits bits
+ *
+ * Outputs: decoded symbol in *val
+ *
+ * Return: number of bits in symbol
+ *
+ * Notes: assumes canonical Huffman codes:
+ * first CW always 0, we have "count" CW's of length "nBits" bits
+ * starting CW for codes of length nBits+1 =
+ * (startCW[nBits] + count[nBits]) << 1
+ * if there are no codes at nBits, then we just keep << 1 each time
+ * (since count[nBits] = 0)
+ **************************************************************************************/
+int DecodeHuffmanScalar(const signed short *huffTab, const HuffInfo *huffTabInfo, unsigned int bitBuf, signed int *val)
+{
+ unsigned int count, start, shift, t;
+ const unsigned char *countPtr;
+ const signed short *map;
+
+ map = huffTab + huffTabInfo->offset;
+ countPtr = huffTabInfo->count;
+
+ start = 0;
+ count = 0;
+ shift = 32;
+ do {
+ start += count;
+ start <<= 1;
+ map += count;
+ count = *countPtr++;
+ shift--;
+ t = (bitBuf >> shift) - start;
+ } while (t >= count);
+
+ *val = (signed int)map[t];
+ return (countPtr - huffTabInfo->count);
+}
+
+#define APPLY_SIGN(v, s) {(v) ^= ((signed int)(s) >> 31); (v) -= ((signed int)(s) >> 31);}
+
+#define GET_QUAD_SIGNBITS(v) (((unsigned int)(v) << 17) >> 29) /* bits 14-12, unsigned */
+#define GET_QUAD_W(v) (((signed int)(v) << 20) >> 29) /* bits 11-9, sign-extend */
+#define GET_QUAD_X(v) (((signed int)(v) << 23) >> 29) /* bits 8-6, sign-extend */
+#define GET_QUAD_Y(v) (((signed int)(v) << 26) >> 29) /* bits 5-3, sign-extend */
+#define GET_QUAD_Z(v) (((signed int)(v) << 29) >> 29) /* bits 2-0, sign-extend */
+
+#define GET_PAIR_SIGNBITS(v) (((unsigned int)(v) << 20) >> 30) /* bits 11-10, unsigned */
+#define GET_PAIR_Y(v) (((signed int)(v) << 22) >> 27) /* bits 9-5, sign-extend */
+#define GET_PAIR_Z(v) (((signed int)(v) << 27) >> 27) /* bits 4-0, sign-extend */
+
+#define GET_ESC_SIGNBITS(v) (((unsigned int)(v) << 18) >> 30) /* bits 13-12, unsigned */
+#define GET_ESC_Y(v) (((signed int)(v) << 20) >> 26) /* bits 11-6, sign-extend */
+#define GET_ESC_Z(v) (((signed int)(v) << 26) >> 26) /* bits 5-0, sign-extend */
+
+/**************************************************************************************
+ * Function: UnpackZeros
+ *
+ * Description: fill a section of coefficients with zeros
+ *
+ * Inputs: number of coefficients
+ *
+ * Outputs: nVals zeros, starting at coef
+ *
+ * Return: none
+ *
+ * Notes: assumes nVals is always a multiple of 4 because all scalefactor bands
+ * are a multiple of 4 coefficients long
+ **************************************************************************************/
+static void UnpackZeros(int nVals, int *coef)
+{
+ while (nVals > 0) {
+ *coef++ = 0;
+ *coef++ = 0;
+ *coef++ = 0;
+ *coef++ = 0;
+ nVals -= 4;
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackQuads
+ *
+ * Description: decode a section of 4-way vector Huffman coded coefficients
+ *
+ * Inputs BitStreamInfo struct pointing to start of codewords for this section
+ * index of Huffman codebook
+ * number of coefficients
+ *
+ * Outputs: nVals coefficients, starting at coef
+ *
+ * Return: none
+ *
+ * Notes: assumes nVals is always a multiple of 4 because all scalefactor bands
+ * are a multiple of 4 coefficients long
+ **************************************************************************************/
+static void UnpackQuads(BitStreamInfo *bsi, int cb, int nVals, int *coef)
+{
+ int w, x, y, z, maxBits, nCodeBits, nSignBits, val;
+ unsigned int bitBuf;
+
+ maxBits = huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET].maxBits + 4;
+ while (nVals > 0) {
+ /* decode quad */
+ bitBuf = GetBitsNoAdvance(bsi, maxBits) << (32 - maxBits);
+ nCodeBits = DecodeHuffmanScalar(huffTabSpec, &huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET], bitBuf, &val);
+
+ w = GET_QUAD_W(val);
+ x = GET_QUAD_X(val);
+ y = GET_QUAD_Y(val);
+ z = GET_QUAD_Z(val);
+
+ bitBuf <<= nCodeBits;
+ nSignBits = (int)GET_QUAD_SIGNBITS(val);
+ AdvanceBitstream(bsi, nCodeBits + nSignBits);
+ if (nSignBits) {
+ if (w) {
+ APPLY_SIGN(w, bitBuf);
+ bitBuf <<= 1;
+ }
+ if (x) {
+ APPLY_SIGN(x, bitBuf);
+ bitBuf <<= 1;
+ }
+ if (y) {
+ APPLY_SIGN(y, bitBuf);
+ bitBuf <<= 1;
+ }
+ if (z) {
+ APPLY_SIGN(z, bitBuf);
+ bitBuf <<= 1;
+ }
+ }
+ *coef++ = w;
+ *coef++ = x;
+ *coef++ = y;
+ *coef++ = z;
+ nVals -= 4;
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackPairsNoEsc
+ *
+ * Description: decode a section of 2-way vector Huffman coded coefficients,
+ * using non-esc tables (5 through 10)
+ *
+ * Inputs BitStreamInfo struct pointing to start of codewords for this section
+ * index of Huffman codebook (must not be the escape codebook)
+ * number of coefficients
+ *
+ * Outputs: nVals coefficients, starting at coef
+ *
+ * Return: none
+ *
+ * Notes: assumes nVals is always a multiple of 2 because all scalefactor bands
+ * are a multiple of 4 coefficients long
+ **************************************************************************************/
+static void UnpackPairsNoEsc(BitStreamInfo *bsi, int cb, int nVals, int *coef)
+{
+ int y, z, maxBits, nCodeBits, nSignBits, val;
+ unsigned int bitBuf;
+
+ maxBits = huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET].maxBits + 2;
+ while (nVals > 0) {
+ /* decode pair */
+ bitBuf = GetBitsNoAdvance(bsi, maxBits) << (32 - maxBits);
+ nCodeBits = DecodeHuffmanScalar(huffTabSpec, &huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET], bitBuf, &val);
+
+ y = GET_PAIR_Y(val);
+ z = GET_PAIR_Z(val);
+
+ bitBuf <<= nCodeBits;
+ nSignBits = GET_PAIR_SIGNBITS(val);
+ AdvanceBitstream(bsi, nCodeBits + nSignBits);
+ if (nSignBits) {
+ if (y) {
+ APPLY_SIGN(y, bitBuf);
+ bitBuf <<= 1;
+ }
+ if (z) {
+ APPLY_SIGN(z, bitBuf);
+ bitBuf <<= 1;
+ }
+ }
+ *coef++ = y;
+ *coef++ = z;
+ nVals -= 2;
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackPairsEsc
+ *
+ * Description: decode a section of 2-way vector Huffman coded coefficients,
+ * using esc table (11)
+ *
+ * Inputs BitStreamInfo struct pointing to start of codewords for this section
+ * index of Huffman codebook (must be the escape codebook)
+ * number of coefficients
+ *
+ * Outputs: nVals coefficients, starting at coef
+ *
+ * Return: none
+ *
+ * Notes: assumes nVals is always a multiple of 2 because all scalefactor bands
+ * are a multiple of 4 coefficients long
+ **************************************************************************************/
+static void UnpackPairsEsc(BitStreamInfo *bsi, int cb, int nVals, int *coef)
+{
+ int y, z, maxBits, nCodeBits, nSignBits, n, val;
+ unsigned int bitBuf;
+
+ maxBits = huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET].maxBits + 2;
+ while (nVals > 0) {
+ /* decode pair with escape value */
+ bitBuf = GetBitsNoAdvance(bsi, maxBits) << (32 - maxBits);
+ nCodeBits = DecodeHuffmanScalar(huffTabSpec, &huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET], bitBuf, &val);
+
+ y = GET_ESC_Y(val);
+ z = GET_ESC_Z(val);
+
+ bitBuf <<= nCodeBits;
+ nSignBits = GET_ESC_SIGNBITS(val);
+ AdvanceBitstream(bsi, nCodeBits + nSignBits);
+
+ if (y == 16) {
+ n = 4;
+ while (GetBits(bsi, 1) == 1) {
+ n++;
+ }
+ y = (1 << n) + GetBits(bsi, n);
+ }
+ if (z == 16) {
+ n = 4;
+ while (GetBits(bsi, 1) == 1) {
+ n++;
+ }
+ z = (1 << n) + GetBits(bsi, n);
+ }
+
+ if (nSignBits) {
+ if (y) {
+ APPLY_SIGN(y, bitBuf);
+ bitBuf <<= 1;
+ }
+ if (z) {
+ APPLY_SIGN(z, bitBuf);
+ bitBuf <<= 1;
+ }
+ }
+
+ *coef++ = y;
+ *coef++ = z;
+ nVals -= 2;
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodeSpectrumLong
+ *
+ * Description: decode transform coefficients for frame with one long block
+ *
+ * Inputs: platform specific info struct
+ * BitStreamInfo struct pointing to start of spectral data
+ * (14496-3, table 4.4.29)
+ * index of current channel
+ *
+ * Outputs: decoded, quantized coefficients for this channel
+ *
+ * Return: none
+ *
+ * Notes: adds in pulse data if present
+ * fills coefficient buffer with zeros in any region not coded with
+ * codebook in range [1, 11] (including sfb's above sfbMax)
+ **************************************************************************************/
+void DecodeSpectrumLong(PSInfoBase *psi, BitStreamInfo *bsi, int ch)
+{
+ int i, sfb, cb, nVals, offset;
+ const short *sfbTab;
+ unsigned char *sfbCodeBook;
+ int *coef;
+ ICSInfo *icsInfo;
+ PulseInfo *pi;
+
+ coef = psi->coef[ch];
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ /* decode long block */
+ sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx];
+ sfbCodeBook = psi->sfbCodeBook[ch];
+ for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) {
+ cb = *sfbCodeBook++;
+ nVals = sfbTab[sfb + 1] - sfbTab[sfb];
+
+ if (cb == 0) {
+ UnpackZeros(nVals, coef);
+ } else if (cb <= 4) {
+ UnpackQuads(bsi, cb, nVals, coef);
+ } else if (cb <= 10) {
+ UnpackPairsNoEsc(bsi, cb, nVals, coef);
+ } else if (cb == 11) {
+ UnpackPairsEsc(bsi, cb, nVals, coef);
+ } else {
+ UnpackZeros(nVals, coef);
+ }
+
+ coef += nVals;
+ }
+
+ /* fill with zeros above maxSFB */
+ nVals = NSAMPS_LONG - sfbTab[sfb];
+ UnpackZeros(nVals, coef);
+
+ /* add pulse data, if present */
+ pi = &psi->pulseInfo[ch];
+ if (pi->pulseDataPresent) {
+ coef = psi->coef[ch];
+ offset = sfbTab[pi->startSFB];
+ for (i = 0; i < pi->numPulse; i++) {
+ offset += pi->offset[i];
+ if (coef[offset] > 0) {
+ coef[offset] += pi->amp[i];
+ } else {
+ coef[offset] -= pi->amp[i];
+ }
+ }
+ ASSERT(offset < NSAMPS_LONG);
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodeSpectrumShort
+ *
+ * Description: decode transform coefficients for frame with eight short blocks
+ *
+ * Inputs: platform specific info struct
+ * BitStreamInfo struct pointing to start of spectral data
+ * (14496-3, table 4.4.29)
+ * index of current channel
+ *
+ * Outputs: decoded, quantized coefficients for this channel
+ *
+ * Return: none
+ *
+ * Notes: fills coefficient buffer with zeros in any region not coded with
+ * codebook in range [1, 11] (including sfb's above sfbMax)
+ * deinterleaves window groups into 8 windows
+ **************************************************************************************/
+void DecodeSpectrumShort(PSInfoBase *psi, BitStreamInfo *bsi, int ch)
+{
+ int gp, cb, nVals = 0, win, offset, sfb;
+ const short *sfbTab;
+ unsigned char *sfbCodeBook;
+ int *coef;
+ ICSInfo *icsInfo;
+
+ coef = psi->coef[ch];
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ /* decode short blocks, deinterleaving in-place */
+ sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx];
+ sfbCodeBook = psi->sfbCodeBook[ch];
+ for (gp = 0; gp < icsInfo->numWinGroup; gp++) {
+ for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) {
+ nVals = sfbTab[sfb + 1] - sfbTab[sfb];
+ cb = *sfbCodeBook++;
+
+ for (win = 0; win < icsInfo->winGroupLen[gp]; win++) {
+ offset = win * NSAMPS_SHORT;
+ if (cb == 0) {
+ UnpackZeros(nVals, coef + offset);
+ } else if (cb <= 4) {
+ UnpackQuads(bsi, cb, nVals, coef + offset);
+ } else if (cb <= 10) {
+ UnpackPairsNoEsc(bsi, cb, nVals, coef + offset);
+ } else if (cb == 11) {
+ UnpackPairsEsc(bsi, cb, nVals, coef + offset);
+ } else {
+ UnpackZeros(nVals, coef + offset);
+ }
+ }
+ coef += nVals;
+ }
+
+ /* fill with zeros above maxSFB */
+ for (win = 0; win < icsInfo->winGroupLen[gp]; win++) {
+ offset = win * NSAMPS_SHORT;
+ nVals = NSAMPS_SHORT - sfbTab[sfb];
+ UnpackZeros(nVals, coef + offset);
+ }
+ coef += nVals;
+ coef += (icsInfo->winGroupLen[gp] - 1) * NSAMPS_SHORT;
+ }
+
+ ASSERT(coef == psi->coef[ch] + NSAMPS_LONG);
+}
diff --git a/audio_codec/libraac/hufftabs.c b/audio_codec/libraac/hufftabs.c
new file mode 100644
index 0000000..e153a61
--- a/dev/null
+++ b/audio_codec/libraac/hufftabs.c
@@ -0,0 +1,177 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: hufftabs.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * hufftabs.c - Huffman symbol tables
+ **************************************************************************************/
+
+#include "coder.h"
+
+const HuffInfo huffTabSpecInfo[11] = {
+ /* table 0 not used */
+ {11, { 1, 0, 0, 0, 8, 0, 24, 0, 24, 8, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0},
+ { 9, { 0, 0, 1, 1, 7, 24, 15, 19, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 81},
+ {16, { 1, 0, 0, 4, 2, 6, 3, 5, 15, 15, 8, 9, 3, 3, 5, 2, 0, 0, 0, 0}, 162},
+ {12, { 0, 0, 0, 10, 6, 0, 9, 21, 8, 14, 11, 2, 0, 0, 0, 0, 0, 0, 0, 0}, 243},
+ {13, { 1, 0, 0, 4, 4, 0, 4, 12, 12, 12, 18, 10, 4, 0, 0, 0, 0, 0, 0, 0}, 324},
+ {11, { 0, 0, 0, 9, 0, 16, 13, 8, 23, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 405},
+ {12, { 1, 0, 2, 1, 0, 4, 5, 10, 14, 15, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0}, 486},
+ {10, { 0, 0, 1, 5, 7, 10, 14, 15, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 550},
+ {15, { 1, 0, 2, 1, 0, 4, 3, 8, 11, 20, 31, 38, 32, 14, 4, 0, 0, 0, 0, 0}, 614},
+ {12, { 0, 0, 0, 3, 8, 14, 17, 25, 31, 41, 22, 8, 0, 0, 0, 0, 0, 0, 0, 0}, 783},
+ {12, { 0, 0, 0, 2, 6, 7, 16, 59, 55, 95, 43, 6, 0, 0, 0, 0, 0, 0, 0, 0}, 952},
+};
+
+const signed short huffTabSpec[1241] = {
+ /* spectrum table 1 [81] (signed) */
+ 0x0000, 0x0200, 0x0e00, 0x0007, 0x0040, 0x0001, 0x0038, 0x0008, 0x01c0, 0x03c0, 0x0e40, 0x0039, 0x0078, 0x01c8, 0x000f, 0x0240,
+ 0x003f, 0x0fc0, 0x01f8, 0x0238, 0x0047, 0x0e08, 0x0009, 0x0208, 0x01c1, 0x0048, 0x0041, 0x0e38, 0x0201, 0x0e07, 0x0207, 0x0e01,
+ 0x01c7, 0x0278, 0x0e78, 0x03c8, 0x004f, 0x0079, 0x01c9, 0x01cf, 0x03f8, 0x0239, 0x007f, 0x0e48, 0x0e0f, 0x0fc8, 0x01f9, 0x03c1,
+ 0x03c7, 0x0e47, 0x0ff8, 0x01ff, 0x0049, 0x020f, 0x0241, 0x0e41, 0x0248, 0x0fc1, 0x0e3f, 0x0247, 0x023f, 0x0e39, 0x0fc7, 0x0e09,
+ 0x0209, 0x03cf, 0x0e79, 0x0e4f, 0x03f9, 0x0249, 0x0fc9, 0x027f, 0x0fcf, 0x0fff, 0x0279, 0x03c9, 0x0e49, 0x0e7f, 0x0ff9, 0x03ff,
+ 0x024f,
+ /* spectrum table 2 [81] (signed) */
+ 0x0000, 0x0200, 0x0e00, 0x0001, 0x0038, 0x0007, 0x01c0, 0x0008, 0x0040, 0x01c8, 0x0e40, 0x0078, 0x000f, 0x0047, 0x0039, 0x0e07,
+ 0x03c0, 0x0238, 0x0fc0, 0x003f, 0x0208, 0x0201, 0x01c1, 0x0e08, 0x0041, 0x01f8, 0x0e01, 0x01c7, 0x0e38, 0x0240, 0x0048, 0x0009,
+ 0x0207, 0x0079, 0x0239, 0x0e78, 0x01cf, 0x03c8, 0x0247, 0x0209, 0x0e48, 0x01f9, 0x0248, 0x0e0f, 0x0ff8, 0x0e39, 0x03f8, 0x0278,
+ 0x03c1, 0x0e47, 0x0fc8, 0x0e09, 0x0fc1, 0x0fc7, 0x01ff, 0x020f, 0x023f, 0x007f, 0x0049, 0x0e41, 0x0e3f, 0x004f, 0x03c7, 0x01c9,
+ 0x0241, 0x03cf, 0x0e79, 0x03f9, 0x0fff, 0x0e4f, 0x0e49, 0x0249, 0x0fcf, 0x03c9, 0x0e7f, 0x0fc9, 0x027f, 0x03ff, 0x0ff9, 0x0279,
+ 0x024f,
+ /* spectrum table 3 [81] (unsigned) */
+ 0x0000, 0x1200, 0x1001, 0x1040, 0x1008, 0x2240, 0x2009, 0x2048, 0x2041, 0x2208, 0x3049, 0x2201, 0x3248, 0x4249, 0x3209, 0x3241,
+ 0x1400, 0x1002, 0x200a, 0x2440, 0x3288, 0x2011, 0x3051, 0x2280, 0x304a, 0x3448, 0x1010, 0x2088, 0x2050, 0x1080, 0x2042, 0x2408,
+ 0x4289, 0x3089, 0x3250, 0x4251, 0x3281, 0x2210, 0x3211, 0x2081, 0x4449, 0x424a, 0x3441, 0x320a, 0x2012, 0x3052, 0x3488, 0x3290,
+ 0x2202, 0x2401, 0x3091, 0x2480, 0x4291, 0x3242, 0x3409, 0x4252, 0x4489, 0x2090, 0x308a, 0x3212, 0x3481, 0x3450, 0x3490, 0x3092,
+ 0x4491, 0x4451, 0x428a, 0x4292, 0x2082, 0x2410, 0x3282, 0x3411, 0x444a, 0x3442, 0x4492, 0x448a, 0x4452, 0x340a, 0x2402, 0x3482,
+ 0x3412,
+ /* spectrum table 4 [81] (unsigned) */
+ 0x4249, 0x3049, 0x3241, 0x3248, 0x3209, 0x1200, 0x2240, 0x0000, 0x2009, 0x2208, 0x2201, 0x2048, 0x1001, 0x2041, 0x1008, 0x1040,
+ 0x4449, 0x4251, 0x4289, 0x424a, 0x3448, 0x3441, 0x3288, 0x3409, 0x3051, 0x304a, 0x3250, 0x3089, 0x320a, 0x3281, 0x3242, 0x3211,
+ 0x2440, 0x2408, 0x2280, 0x2401, 0x2042, 0x2088, 0x200a, 0x2050, 0x2081, 0x2202, 0x2011, 0x2210, 0x1400, 0x1002, 0x1080, 0x1010,
+ 0x4291, 0x4489, 0x4451, 0x4252, 0x428a, 0x444a, 0x3290, 0x3488, 0x3450, 0x3091, 0x3052, 0x3481, 0x308a, 0x3411, 0x3212, 0x4491,
+ 0x3282, 0x340a, 0x3442, 0x4292, 0x4452, 0x448a, 0x2090, 0x2480, 0x2012, 0x2410, 0x2082, 0x2402, 0x4492, 0x3092, 0x3490, 0x3482,
+ 0x3412,
+ /* spectrum table 5 [81] (signed) */
+ 0x0000, 0x03e0, 0x0020, 0x0001, 0x001f, 0x003f, 0x03e1, 0x03ff, 0x0021, 0x03c0, 0x0002, 0x0040, 0x001e, 0x03df, 0x0041, 0x03fe,
+ 0x0022, 0x03c1, 0x005f, 0x03e2, 0x003e, 0x03a0, 0x0060, 0x001d, 0x0003, 0x03bf, 0x0023, 0x0061, 0x03fd, 0x03a1, 0x007f, 0x003d,
+ 0x03e3, 0x03c2, 0x0042, 0x03de, 0x005e, 0x03be, 0x007e, 0x03c3, 0x005d, 0x0062, 0x0043, 0x03a2, 0x03dd, 0x001c, 0x0380, 0x0081,
+ 0x0080, 0x039f, 0x0004, 0x009f, 0x03fc, 0x0024, 0x03e4, 0x0381, 0x003c, 0x007d, 0x03bd, 0x03a3, 0x03c4, 0x039e, 0x0082, 0x005c,
+ 0x0044, 0x0063, 0x0382, 0x03dc, 0x009e, 0x007c, 0x039d, 0x0383, 0x0064, 0x03a4, 0x0083, 0x009d, 0x03bc, 0x009c, 0x0384, 0x0084,
+ 0x039c,
+ /* spectrum table 6 [81] (signed) */
+ 0x0000, 0x0020, 0x001f, 0x0001, 0x03e0, 0x0021, 0x03e1, 0x003f, 0x03ff, 0x005f, 0x0041, 0x03c1, 0x03df, 0x03c0, 0x03e2, 0x0040,
+ 0x003e, 0x0022, 0x001e, 0x03fe, 0x0002, 0x005e, 0x03c2, 0x03de, 0x0042, 0x03a1, 0x0061, 0x007f, 0x03e3, 0x03bf, 0x0023, 0x003d,
+ 0x03fd, 0x0060, 0x03a0, 0x001d, 0x0003, 0x0062, 0x03be, 0x03c3, 0x0043, 0x007e, 0x005d, 0x03dd, 0x03a2, 0x0063, 0x007d, 0x03bd,
+ 0x03a3, 0x003c, 0x03fc, 0x0081, 0x0381, 0x039f, 0x0024, 0x009f, 0x03e4, 0x001c, 0x0382, 0x039e, 0x0044, 0x03dc, 0x0380, 0x0082,
+ 0x009e, 0x03c4, 0x0080, 0x005c, 0x0004, 0x03bc, 0x03a4, 0x007c, 0x009d, 0x0064, 0x0083, 0x0383, 0x039d, 0x0084, 0x0384, 0x039c,
+ 0x009c,
+ /* spectrum table 7 [64] (unsigned) */
+ 0x0000, 0x0420, 0x0401, 0x0821, 0x0841, 0x0822, 0x0440, 0x0402, 0x0861, 0x0823, 0x0842, 0x0460, 0x0403, 0x0843, 0x0862, 0x0824,
+ 0x0881, 0x0825, 0x08a1, 0x0863, 0x0844, 0x0404, 0x0480, 0x0882, 0x0845, 0x08a2, 0x0405, 0x08c1, 0x04a0, 0x0826, 0x0883, 0x0865,
+ 0x0864, 0x08a3, 0x0846, 0x08c2, 0x0827, 0x0866, 0x0406, 0x04c0, 0x0884, 0x08e1, 0x0885, 0x08e2, 0x08a4, 0x08c3, 0x0847, 0x08e3,
+ 0x08c4, 0x08a5, 0x0886, 0x0867, 0x04e0, 0x0407, 0x08c5, 0x08a6, 0x08e4, 0x0887, 0x08a7, 0x08e5, 0x08e6, 0x08c6, 0x08c7, 0x08e7,
+ /* spectrum table 8 [64] (unsigned) */
+ 0x0821, 0x0841, 0x0420, 0x0822, 0x0401, 0x0842, 0x0000, 0x0440, 0x0402, 0x0861, 0x0823, 0x0862, 0x0843, 0x0863, 0x0881, 0x0824,
+ 0x0882, 0x0844, 0x0460, 0x0403, 0x0883, 0x0864, 0x08a2, 0x08a1, 0x0845, 0x0825, 0x08a3, 0x0865, 0x0884, 0x08a4, 0x0404, 0x0885,
+ 0x0480, 0x0846, 0x08c2, 0x08c1, 0x0826, 0x0866, 0x08c3, 0x08a5, 0x04a0, 0x08c4, 0x0405, 0x0886, 0x08e1, 0x08e2, 0x0847, 0x08c5,
+ 0x08e3, 0x0827, 0x08a6, 0x0867, 0x08c6, 0x08e4, 0x04c0, 0x0887, 0x0406, 0x08e5, 0x08e6, 0x08c7, 0x08a7, 0x04e0, 0x0407, 0x08e7,
+ /* spectrum table 9 [169] (unsigned) */
+ 0x0000, 0x0420, 0x0401, 0x0821, 0x0841, 0x0822, 0x0440, 0x0402, 0x0861, 0x0842, 0x0823, 0x0460, 0x0403, 0x0843, 0x0862, 0x0824,
+ 0x0881, 0x0844, 0x0825, 0x0882, 0x0863, 0x0404, 0x0480, 0x08a1, 0x0845, 0x0826, 0x0864, 0x08a2, 0x08c1, 0x0883, 0x0405, 0x0846,
+ 0x04a0, 0x0827, 0x0865, 0x0828, 0x0901, 0x0884, 0x08a3, 0x08c2, 0x08e1, 0x0406, 0x0902, 0x0848, 0x0866, 0x0847, 0x0885, 0x0921,
+ 0x0829, 0x08e2, 0x04c0, 0x08a4, 0x08c3, 0x0903, 0x0407, 0x0922, 0x0868, 0x0886, 0x0867, 0x0408, 0x0941, 0x08c4, 0x0849, 0x08a5,
+ 0x0500, 0x04e0, 0x08e3, 0x0942, 0x0923, 0x0904, 0x082a, 0x08e4, 0x08c5, 0x08a6, 0x0888, 0x0887, 0x0869, 0x0961, 0x08a8, 0x0520,
+ 0x0905, 0x0943, 0x084a, 0x0409, 0x0962, 0x0924, 0x08c6, 0x0981, 0x0889, 0x0906, 0x082b, 0x0925, 0x0944, 0x08a7, 0x08e5, 0x084b,
+ 0x082c, 0x0982, 0x0963, 0x086a, 0x08a9, 0x08c7, 0x0907, 0x0964, 0x040a, 0x08e6, 0x0983, 0x0540, 0x0945, 0x088a, 0x08c8, 0x084c,
+ 0x0926, 0x0927, 0x088b, 0x0560, 0x08c9, 0x086b, 0x08aa, 0x0908, 0x08e8, 0x0985, 0x086c, 0x0965, 0x08e7, 0x0984, 0x0966, 0x0946,
+ 0x088c, 0x08e9, 0x08ab, 0x040b, 0x0986, 0x08ca, 0x0580, 0x0947, 0x08ac, 0x08ea, 0x0928, 0x040c, 0x0967, 0x0909, 0x0929, 0x0948,
+ 0x08eb, 0x0987, 0x08cb, 0x090b, 0x0968, 0x08ec, 0x08cc, 0x090a, 0x0949, 0x090c, 0x092a, 0x092b, 0x092c, 0x094b, 0x0989, 0x094a,
+ 0x0969, 0x0988, 0x096a, 0x098a, 0x098b, 0x094c, 0x096b, 0x096c, 0x098c,
+ /* spectrum table 10 [169] (unsigned) */
+ 0x0821, 0x0822, 0x0841, 0x0842, 0x0420, 0x0401, 0x0823, 0x0862, 0x0861, 0x0843, 0x0863, 0x0440, 0x0402, 0x0844, 0x0882, 0x0824,
+ 0x0881, 0x0000, 0x0883, 0x0864, 0x0460, 0x0403, 0x0884, 0x0845, 0x08a2, 0x0825, 0x08a1, 0x08a3, 0x0865, 0x08a4, 0x0885, 0x08c2,
+ 0x0846, 0x08c3, 0x0480, 0x08c1, 0x0404, 0x0826, 0x0866, 0x08a5, 0x08c4, 0x0886, 0x08c5, 0x08e2, 0x0867, 0x0847, 0x08a6, 0x0902,
+ 0x08e3, 0x04a0, 0x08e1, 0x0405, 0x0901, 0x0827, 0x0903, 0x08e4, 0x0887, 0x0848, 0x08c6, 0x08e5, 0x0828, 0x0868, 0x0904, 0x0888,
+ 0x08a7, 0x0905, 0x08a8, 0x08e6, 0x08c7, 0x0922, 0x04c0, 0x08c8, 0x0923, 0x0869, 0x0921, 0x0849, 0x0406, 0x0906, 0x0924, 0x0889,
+ 0x0942, 0x0829, 0x08e7, 0x0907, 0x0925, 0x08e8, 0x0943, 0x08a9, 0x0944, 0x084a, 0x0941, 0x086a, 0x0926, 0x08c9, 0x0500, 0x088a,
+ 0x04e0, 0x0962, 0x08e9, 0x0963, 0x0946, 0x082a, 0x0961, 0x0927, 0x0407, 0x0908, 0x0945, 0x086b, 0x08aa, 0x0909, 0x0965, 0x0408,
+ 0x0964, 0x084b, 0x08ea, 0x08ca, 0x0947, 0x088b, 0x082b, 0x0982, 0x0928, 0x0983, 0x0966, 0x08ab, 0x0984, 0x0967, 0x0985, 0x086c,
+ 0x08cb, 0x0520, 0x0948, 0x0540, 0x0981, 0x0409, 0x088c, 0x0929, 0x0986, 0x084c, 0x090a, 0x092a, 0x082c, 0x0968, 0x0987, 0x08eb,
+ 0x08ac, 0x08cc, 0x0949, 0x090b, 0x0988, 0x040a, 0x08ec, 0x0560, 0x094a, 0x0969, 0x096a, 0x040b, 0x096b, 0x092b, 0x094b, 0x0580,
+ 0x090c, 0x0989, 0x094c, 0x092c, 0x096c, 0x098b, 0x040c, 0x098a, 0x098c,
+ /* spectrum table 11 [289] (unsigned) */
+ 0x0000, 0x2041, 0x2410, 0x1040, 0x1001, 0x2081, 0x2042, 0x2082, 0x2043, 0x20c1, 0x20c2, 0x1080, 0x2083, 0x1002, 0x20c3, 0x2101,
+ 0x2044, 0x2102, 0x2084, 0x2103, 0x20c4, 0x10c0, 0x1003, 0x2141, 0x2142, 0x2085, 0x2104, 0x2045, 0x2143, 0x20c5, 0x2144, 0x2105,
+ 0x2182, 0x2086, 0x2181, 0x2183, 0x20c6, 0x2046, 0x2110, 0x20d0, 0x2405, 0x2403, 0x2404, 0x2184, 0x2406, 0x1100, 0x2106, 0x1004,
+ 0x2090, 0x2145, 0x2150, 0x2407, 0x2402, 0x2408, 0x2087, 0x21c2, 0x20c7, 0x2185, 0x2146, 0x2190, 0x240a, 0x21c3, 0x21c1, 0x2409,
+ 0x21d0, 0x2050, 0x2047, 0x2107, 0x240b, 0x21c4, 0x240c, 0x2210, 0x2401, 0x2186, 0x2250, 0x2088, 0x2147, 0x2290, 0x240d, 0x2203,
+ 0x2202, 0x20c8, 0x1140, 0x240e, 0x22d0, 0x21c5, 0x2108, 0x2187, 0x21c6, 0x1005, 0x2204, 0x240f, 0x2310, 0x2048, 0x2201, 0x2390,
+ 0x2148, 0x2350, 0x20c9, 0x2205, 0x21c7, 0x2089, 0x2206, 0x2242, 0x2243, 0x23d0, 0x2109, 0x2188, 0x1180, 0x2244, 0x2149, 0x2207,
+ 0x21c8, 0x2049, 0x2283, 0x1006, 0x2282, 0x2241, 0x2245, 0x210a, 0x208a, 0x2246, 0x20ca, 0x2189, 0x2284, 0x2208, 0x2285, 0x2247,
+ 0x22c3, 0x204a, 0x11c0, 0x2286, 0x21c9, 0x20cb, 0x214a, 0x2281, 0x210b, 0x22c2, 0x2342, 0x218a, 0x2343, 0x208b, 0x1400, 0x214b,
+ 0x22c5, 0x22c4, 0x2248, 0x21ca, 0x2209, 0x1010, 0x210d, 0x1007, 0x20cd, 0x22c6, 0x2341, 0x2344, 0x2303, 0x208d, 0x2345, 0x220a,
+ 0x218b, 0x2288, 0x2287, 0x2382, 0x2304, 0x204b, 0x210c, 0x22c1, 0x20cc, 0x204d, 0x2302, 0x21cb, 0x20ce, 0x214c, 0x214d, 0x2384,
+ 0x210e, 0x22c7, 0x2383, 0x2305, 0x2346, 0x2306, 0x1200, 0x22c8, 0x208c, 0x2249, 0x2385, 0x218d, 0x228a, 0x23c2, 0x220b, 0x224a,
+ 0x2386, 0x2289, 0x214e, 0x22c9, 0x2381, 0x208e, 0x218c, 0x204c, 0x2348, 0x1008, 0x2347, 0x21cc, 0x2307, 0x21cd, 0x23c3, 0x2301,
+ 0x218e, 0x208f, 0x23c5, 0x23c4, 0x204e, 0x224b, 0x210f, 0x2387, 0x220d, 0x2349, 0x220c, 0x214f, 0x20cf, 0x228b, 0x22ca, 0x2308,
+ 0x23c6, 0x23c7, 0x220e, 0x23c1, 0x21ce, 0x1240, 0x1009, 0x224d, 0x224c, 0x2309, 0x2388, 0x228d, 0x2389, 0x230a, 0x218f, 0x21cf,
+ 0x224e, 0x23c8, 0x22cb, 0x22ce, 0x204f, 0x228c, 0x228e, 0x234b, 0x234a, 0x22cd, 0x22cc, 0x220f, 0x238b, 0x234c, 0x230d, 0x23c9,
+ 0x238a, 0x1280, 0x230b, 0x224f, 0x100a, 0x230c, 0x12c0, 0x230e, 0x228f, 0x234d, 0x100d, 0x238c, 0x23ca, 0x23cb, 0x22cf, 0x238d,
+ 0x1340, 0x100b, 0x234e, 0x23cc, 0x23cd, 0x230f, 0x1380, 0x238e, 0x234f, 0x1300, 0x238f, 0x100e, 0x100c, 0x23ce, 0x13c0, 0x100f,
+ 0x23cf,
+};
+
+const HuffInfo huffTabScaleFactInfo =
+{19, { 1, 0, 1, 3, 2, 4, 3, 5, 4, 6, 6, 6, 5, 8, 4, 7, 3, 7, 46, 0}, 0};
+
+/* note - includes offset of -60 (4.6.2.3 in spec) */
+const signed short huffTabScaleFact[121] = {
+ /* scale factor table [121] */
+ 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, 14, -14, 16, 15, 17,
+ 18, -15, -17, -16, 19, -18, -19, 20, -20, 21, -21, 22, -22, 23, -23, -25,
+ 25, -27, -24, -26, 24, -28, 27, 29, -30, -29, 26, -31, -34, -33, -32, -36,
+ 28, -35, -38, -37, 30, -39, -41, -57, -59, -58, -60, 38, 39, 40, 41, 42,
+ 57, 37, 31, 32, 33, 34, 35, 36, 44, 51, 52, 53, 54, 55, 56, 50,
+ 45, 46, 47, 48, 49, 58, -54, -52, -51, -50, -55, 43, 60, 59, -56, -53,
+ -45, -44, -42, -40, -43, -49, -48, -46, -47,
+};
+
diff --git a/audio_codec/libraac/imdct.c b/audio_codec/libraac/imdct.c
new file mode 100644
index 0000000..4eb4f0b
--- a/dev/null
+++ b/audio_codec/libraac/imdct.c
@@ -0,0 +1,598 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: imdct.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * imdct.c - inverse MDCT
+ **************************************************************************************/
+
+#include "coder.h"
+
+#include "assembly.h"
+
+#include "aacdec.h"
+
+#define RND_VAL (1 << (FBITS_OUT_IMDCT-1))
+
+#ifndef AAC_ENABLE_SBR
+
+/**************************************************************************************
+ * Function: DecWindowOverlap
+ *
+ * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM,
+ * for winSequence LONG-LONG
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * number of channels
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans
+ *
+ * Return: none
+ *
+ * Notes: this processes one channel at a time, but skips every other sample in
+ * the output buffer (pcm) for stereo interleaving
+ * this should fit in registers on ARM
+ *
+ * TODO: ARM5E version with saturating overlap/add (QADD)
+ * asm code with free pointer updates, better load scheduling
+ **************************************************************************************/
+static void DecWindowOverlap(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev)
+{
+ int in, w0, w1, f0, f1;
+ int *buf1, *over1;
+ short *pcm1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ pcm1 = pcm0 + (1024 - 1) * nChans;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ if (winTypeCurr == winTypePrev) {
+ /* cut window loads in half since current and overlap sections use same symmetric window */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ } else {
+ /* different windows for current and overlap parts - should still fit in registers on ARM w/o stack spill */
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapLongStart
+ *
+ * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM,
+ * for winSequence LONG-START
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * number of channels
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans
+ *
+ * Return: none
+ *
+ * Notes: this processes one channel at a time, but skips every other sample in
+ * the output buffer (pcm) for stereo interleaving
+ * this should fit in registers on ARM
+ *
+ * TODO: ARM5E version with saturating overlap/add (QADD)
+ * asm code with free pointer updates, better load scheduling
+ **************************************************************************************/
+static void DecWindowOverlapLongStart(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1;
+ short *pcm1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ pcm1 = pcm0 + (1024 - 1) * nChans;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ i = 448; /* 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ in = *buf1--;
+
+ *over1-- = 0; /* Wn = 0 for n = (2047, 2046, ... 1600) */
+ *over0++ = in >> 1; /* Wn = 1 for n = (1024, 1025, ... 1471) */
+ } while (--i);
+
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+
+ /* do 64 more loops - 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ w0 = *wndCurr++; /* W[0], W[1], ... --> W[255], W[254], ... */
+ w1 = *wndCurr++; /* W[127], W[126], ... --> W[128], W[129], ... */
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in); /* Wn = short window for n = (1599, 1598, ... , 1536) */
+ *over0++ = MULSHIFT32(w1, in); /* Wn = short window for n = (1472, 1473, ... , 1535) */
+ } while (over0 < over1);
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapLongStop
+ *
+ * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM,
+ * for winSequence LONG-STOP
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * number of channels
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans
+ *
+ * Return: none
+ *
+ * Notes: this processes one channel at a time, but skips every other sample in
+ * the output buffer (pcm) for stereo interleaving
+ * this should fit in registers on ARM
+ *
+ * TODO: ARM5E version with saturating overlap/add (QADD)
+ * asm code with free pointer updates, better load scheduling
+ **************************************************************************************/
+static void DecWindowOverlapLongStop(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1;
+ short *pcm1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ pcm1 = pcm0 + (1024 - 1) * nChans;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+
+ i = 448; /* 2 outputs, 2 overlaps per loop */
+ do {
+ /* Wn = 0 for n = (0, 1, ... 447) */
+ /* Wn = 1 for n = (576, 577, ... 1023) */
+ in = *buf0++;
+ f1 = in >> 1; /* scale since skipping multiply by Q31 */
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (--i);
+
+ /* do 64 more loops - 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++; /* W[0], W[1], ...W[63] */
+ w1 = *wndPrev++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapShort
+ *
+ * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM,
+ * for winSequence EIGHT-SHORT (does all 8 short blocks)
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * number of channels
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans
+ *
+ * Return: none
+ *
+ * Notes: this processes one channel at a time, but skips every other sample in
+ * the output buffer (pcm) for stereo interleaving
+ * this should fit in registers on ARM
+ *
+ * TODO: ARM5E version with saturating overlap/add (QADD)
+ * asm code with free pointer updates, better load scheduling
+ **************************************************************************************/
+static void DecWindowOverlapShort(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1;
+ short *pcm1;
+ const int *wndPrev, *wndCurr;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+
+ /* pcm[0-447] = 0 + overlap[0-447] */
+ i = 448;
+ do {
+ f0 = *over0++;
+ f1 = *over0++;
+ *pcm0 = CLIPTOSHORT((f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+ *pcm0 = CLIPTOSHORT((f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+ i -= 2;
+ } while (i);
+
+ /* pcm[448-575] = Wp[0-127] * block0[0-127] + overlap[448-575] */
+ pcm1 = pcm0 + (128 - 1) * nChans;
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ do {
+ w0 = *wndPrev++; /* W[0], W[1], ...W[63] */
+ w1 = *wndPrev++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ /* save over0/over1 for next short block, in the slots just vacated */
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+
+ /* pcm[576-703] = Wc[128-255] * block0[128-255] + Wc[0-127] * block1[0-127] + overlap[576-703]
+ * pcm[704-831] = Wc[128-255] * block1[128-255] + Wc[0-127] * block2[0-127] + overlap[704-831]
+ * pcm[832-959] = Wc[128-255] * block2[128-255] + Wc[0-127] * block3[0-127] + overlap[832-959]
+ */
+ for (i = 0; i < 3; i++) {
+ pcm0 += 64 * nChans;
+ pcm1 = pcm0 + (128 - 1) * nChans;
+ over0 += 64;
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *(over0 - 128); /* from last short block */
+ in += *(over0 + 0); /* from last full frame */
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *(over1 - 128); /* from last short block */
+ in += *(over1 + 0); /* from last full frame */
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ /* save over0/over1 for next short block, in the slots just vacated */
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+
+ /* pcm[960-1023] = Wc[128-191] * block3[128-191] + Wc[0-63] * block4[0-63] + overlap[960-1023]
+ * over[0-63] = Wc[192-255] * block3[192-255] + Wc[64-127] * block4[64-127]
+ */
+ pcm0 += 64 * nChans;
+ over0 -= 832; /* points at overlap[64] */
+ over1 = over0 + 128 - 1; /* points at overlap[191] */
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *(over0 + 768); /* from last short block */
+ in += *(over0 + 896); /* from last full frame */
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *(over1 + 768); /* from last short block */
+ *(over1 - 128) = in + f1;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in); /* save in overlap[128-191] */
+ *over0++ = MULSHIFT32(w1, in); /* save in overlap[64-127] */
+ } while (over0 < over1);
+
+ /* over0 now points at overlap[128] */
+
+ /* over[64-191] = Wc[128-255] * block4[128-255] + Wc[0-127] * block5[0-127]
+ * over[192-319] = Wc[128-255] * block5[128-255] + Wc[0-127] * block6[0-127]
+ * over[320-447] = Wc[128-255] * block6[128-255] + Wc[0-127] * block7[0-127]
+ * over[448-576] = Wc[128-255] * block7[128-255]
+ */
+ for (i = 0; i < 3; i++) {
+ over0 += 64;
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ /* from last short block */
+ *(over0 - 128) -= f0;
+ *(over1 - 128) += f1;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+
+ /* over[576-1024] = 0 */
+ i = 448;
+ over0 += 64;
+ do {
+ *over0++ = 0;
+ *over0++ = 0;
+ *over0++ = 0;
+ *over0++ = 0;
+ i -= 4;
+ } while (i);
+}
+
+#endif /* !AAC_ENABLE_SBR */
+
+/**************************************************************************************
+ * Function: IMDCT
+ *
+ * Description: inverse transform and convert to 16-bit PCM
+ *
+ * Inputs: valid AACDecInfo struct
+ * index of current channel (0 for SCE/LFE, 0 or 1 for CPE)
+ * output channel (range = [0, nChans-1])
+ *
+ * Outputs: complete frame of decoded PCM, after inverse transform
+ *
+ * Return: 0 if successful, -1 if error
+ *
+ * Notes: If AAC_ENABLE_SBR is defined at compile time then window + overlap
+ * does NOT clip to 16-bit PCM and does NOT interleave channels
+ * If AAC_ENABLE_SBR is NOT defined at compile time, then window + overlap
+ * does clip to 16-bit PCM and interleaves channels
+ * If SBR is enabled at compile time, but we don't know whether it is
+ * actually used for this frame (e.g. the first frame of a stream),
+ * we need to produce both clipped 16-bit PCM in outbuf AND
+ * unclipped 32-bit PCM in the SBR input buffer. In this case we make
+ * a separate pass over the 32-bit PCM to produce 16-bit PCM output.
+ * This inflicts a slight performance hit when decoding non-SBR files.
+ **************************************************************************************/
+int IMDCT(AACDecInfo *aacDecInfo, int ch, int chOut, short *outbuf)
+{
+ int i;
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+ outbuf += chOut;
+
+ /* optimized type-IV DCT (operates inplace) */
+ if (icsInfo->winSequence == 2) {
+ /* 8 short blocks */
+ for (i = 0; i < 8; i++) {
+ DCT4(0, psi->coef[ch] + i * 128, psi->gbCurrent[ch]);
+ }
+ } else {
+ /* 1 long block */
+ DCT4(1, psi->coef[ch], psi->gbCurrent[ch]);
+ }
+
+#ifdef AAC_ENABLE_SBR
+ /* window, overlap-add, don't clip to short (send to SBR decoder)
+ * store the decoded 32-bit samples in top half (second AAC_MAX_NSAMPS samples) of coef buffer
+ */
+ if (icsInfo->winSequence == 0) {
+ DecWindowOverlapNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 1) {
+ DecWindowOverlapLongStartNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 2) {
+ DecWindowOverlapShortNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 3) {
+ DecWindowOverlapLongStopNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]);
+ }
+
+ if (!aacDecInfo->sbrEnabled) {
+ for (i = 0; i < AAC_MAX_NSAMPS; i++) {
+ *outbuf = CLIPTOSHORT((psi->sbrWorkBuf[ch][i] + RND_VAL) >> FBITS_OUT_IMDCT);
+ outbuf += aacDecInfo->nChans;
+ }
+ }
+
+ aacDecInfo->rawSampleBuf[ch] = psi->sbrWorkBuf[ch];
+ aacDecInfo->rawSampleBytes = sizeof(int);
+ aacDecInfo->rawSampleFBits = FBITS_OUT_IMDCT;
+#else
+ /* window, overlap-add, round to PCM - optimized for each window sequence */
+ if (icsInfo->winSequence == 0) {
+ DecWindowOverlap(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 1) {
+ DecWindowOverlapLongStart(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 2) {
+ DecWindowOverlapShort(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 3) {
+ DecWindowOverlapLongStop(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]);
+ }
+
+ aacDecInfo->rawSampleBuf[ch] = 0;
+ aacDecInfo->rawSampleBytes = 0;
+ aacDecInfo->rawSampleFBits = 0;
+#endif
+
+ psi->prevWinShape[chOut] = icsInfo->winShape;
+
+ return 0;
+}
diff --git a/audio_codec/libraac/include/challenge.h b/audio_codec/libraac/include/challenge.h
new file mode 100644
index 0000000..3f9540f
--- a/dev/null
+++ b/audio_codec/libraac/include/challenge.h
@@ -0,0 +1,132 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: challenge.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef _CHALLENGE_H_
+#define _CHALLENGE_H_
+
+#include "helix_types.h"
+#include "helix_utils.h"
+#include "rm_memory.h"
+
+
+
+/*
+ * The original Challange structure and methods. Used in the
+ * Old PNA and as the first round in the new RTSP Challenge.
+ */
+struct Challenge {
+ BYTE text[33];
+ BYTE response[33];
+};
+
+struct Challenge* CreateChallenge(INT32 k1,
+ INT32 k2,
+ BYTE* k3,
+ BYTE* k4);
+
+struct Challenge* CreateChallengeFromPool(INT32 k1,
+ INT32 k2,
+ BYTE* k3,
+ BYTE* k4,
+ rm_malloc_func_ptr fpMalloc,
+ void* pMemoryPool);
+
+BYTE* ChallengeResponse1(BYTE* k1, BYTE* k2,
+ INT32 k3, INT32 k4,
+ struct Challenge* ch);
+BYTE* ChallengeResponse2(BYTE* k1, BYTE* k2,
+ INT32 k3, INT32 k4,
+ struct Challenge* ch);
+
+
+
+/*
+ * The new RTSP Challenge structure and methods
+ */
+struct RealChallenge {
+ BYTE challenge[33];
+ BYTE response[41];
+ BYTE trap[9];
+};
+
+
+struct RealChallenge* CreateRealChallenge();
+struct RealChallenge* CreateRealChallengeFromPool(rm_malloc_func_ptr fpMalloc,
+ void* pMemoryPool);
+BYTE* RealChallengeResponse1(BYTE* k1, BYTE* k2,
+ INT32 k3, INT32 k4,
+ struct RealChallenge* rch);
+BYTE* RealChallengeResponse2(BYTE* k1, BYTE* k2,
+ INT32 k3, INT32 k4,
+ struct RealChallenge* rch);
+
+
+void CalcCompanyIDKey(const char* companyID,
+ const char* starttime,
+ const char* guid,
+ const char* challenge,
+ const char* copyright,
+ UCHAR* outputKey);
+
+INT32 BinTo64(const BYTE* pInBuf, INT32 len, char* pOutBuf);
+
+
+/* Support constants and values */
+extern const INT32 G2_BETA_EXPIRATION;
+
+extern const INT32 RC_MAGIC1;
+extern const INT32 RC_MAGIC2;
+extern const INT32 RC_MAGIC3;
+extern const INT32 RC_MAGIC4;
+
+extern const unsigned char pRCMagic1[];
+extern const unsigned char pRCMagic2[];
+
+
+// This UUID was added in the 5.0 player to allow us to identify
+// players from Progressive Networks. Other companies licensing this
+// code must be assigned a different UUID.
+#define HX_COMPANY_ID "92c4d14a-fa51-4bcb-8a67-7ac286f0ff7e"
+#define HX_COMPANY_ID_KEY_SIZE 16
+
+
+extern const unsigned char HX_MAGIC_TXT_1[];
+extern const char pMagic2[];
+
+
+
+#endif /*_CHALLENGE_H_*/
diff --git a/audio_codec/libraac/include/codec_defines.h b/audio_codec/libraac/include/codec_defines.h
new file mode 100644
index 0000000..c143a75
--- a/dev/null
+++ b/audio_codec/libraac/include/codec_defines.h
@@ -0,0 +1,93 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: codec_defines.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef CODEC_DEFINES_H
+#define CODEC_DEFINES_H
+
+/* Audio codec defines */
+#define RA_FORMAT_ID 0x2E7261FD /* RealAudio Stream */
+#define RA_NO_INTERLEAVER 0x496E7430 /* 'Int0' (no interleaver) */
+#define RA_INTERLEAVER_SIPR 0x73697072 /* interleaver used for SIPRO codec ("sipr") */
+#define RA_INTERLEAVER_GENR 0x67656E72 /* interleaver used for ra8lbr and ra8hbr codecs ("genr") */
+#define RA_INTERLEAVER_VBRS 0x76627273 /* Simple VBR interleaver ("vbrs") */
+#define RA_INTERLEAVER_VBRF 0x76627266 /* Simple VBR interleaver (with possibly fragmenting) ("vbrf") */
+
+/* Video codec defines */
+#define HX_MEDIA_AUDIO 0x4155444FL /* 'AUDO' */
+#define HX_MEDIA_VIDEO 0x5649444FL /* 'VIDO' */
+
+#define HX_RVTRVIDEO_ID 0x52565452 /* 'RVTR' (for rv20 codec) */
+#define HX_RVTR_RV30_ID 0x52565432 /* 'RVT2' (for rv30 codec) */
+#define HX_RV20VIDEO_ID 0x52563230 /* 'RV20' */
+#define HX_RV30VIDEO_ID 0x52563330 /* 'RV30' */
+#define HX_RV40VIDEO_ID 0x52563430 /* 'RV40' */
+#define HX_RVG2VIDEO_ID 0x52564732 /* 'RVG2' (raw TCK format) */
+#define HX_RV89COMBO_ID 0x54524F4D /* 'TROM' (raw TCK format) */
+
+#define RV20_MAJOR_BITSTREAM_VERSION 2
+
+#define RV30_MAJOR_BITSTREAM_VERSION 3
+#define RV30_BITSTREAM_VERSION 2
+#define RV30_PRODUCT_RELEASE 0
+#define RV30_FRONTEND_VERSION 2
+
+#define RV40_MAJOR_BITSTREAM_VERSION 4
+#define RV40_BITSTREAM_VERSION 0
+#define RV40_PRODUCT_RELEASE 2
+#define RV40_FRONTEND_VERSION 0
+
+#define RAW_BITSTREAM_MINOR_VERSION 128
+
+#define RAW_RVG2_MAJOR_VERSION 2
+#define RAW_RVG2_BITSTREAM_VERSION RAW_BITSTREAM_MINOR_VERSION
+#define RAW_RVG2_PRODUCT_RELEASE 0
+#define RAW_RVG2_FRONTEND_VERSION 0
+
+#define RAW_RV8_MAJOR_VERSION 3
+#define RAW_RV8_BITSTREAM_VERSION RAW_BITSTREAM_MINOR_VERSION
+#define RAW_RV8_PRODUCT_RELEASE 0
+#define RAW_RV8_FRONTEND_VERSION 0
+
+#define RAW_RV9_MAJOR_VERSION 4
+#define RAW_RV9_BITSTREAM_VERSION RAW_BITSTREAM_MINOR_VERSION
+#define RAW_RV9_PRODUCT_RELEASE 0
+#define RAW_RV9_FRONTEND_VERSION 0
+
+#define WIDTHBYTES(i) ((unsigned long)((i+31)&(~31))/8) /* ULONG aligned ! */
+#define T_YUV420 10
+
+#endif /* #ifndef CODEC_DEFINES_H */
diff --git a/audio_codec/libraac/include/gecko2codec.h b/audio_codec/libraac/include/gecko2codec.h
new file mode 100644
index 0000000..0eda1f0
--- a/dev/null
+++ b/audio_codec/libraac/include/gecko2codec.h
@@ -0,0 +1,60 @@
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * gecko2codec.h - public C API for Gecko2 decoder
+ **************************************************************************************/
+
+#ifndef _GECKO2CODEC_H
+#define _GECKO2CODEC_H
+
+//#include "includes.h"
+#define _ARC32
+
+#if defined(_WIN32) && !defined(_WIN32_WCE)
+
+#elif defined(_WIN32) && defined(_WIN32_WCE) && defined(ARM)
+
+#elif defined(_WIN32) && defined(WINCE_EMULATOR)
+
+#elif defined(ARM_ADS)
+
+#elif defined(_SYMBIAN) && defined(__WINS__)
+
+#elif defined(__GNUC__) && defined(ARM)
+
+#elif defined(__GNUC__) && defined(__i386__)
+
+#elif defined(_OPENWAVE)
+
+#elif defined(_ARC32)
+
+#else
+#error No platform defined. See valid options in gecko2codec.h.
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef void *HGecko2Decoder;
+
+ enum {
+ ERR_GECKO2_NONE = 0,
+ ERR_GECKO2_INVALID_SIDEINFO = -1,
+
+ ERR_UNKNOWN = -9999
+ };
+
+ /* public API */
+ HGecko2Decoder Gecko2InitDecoder(int nSamples, int nChannels, int nRegions, int nFrameBits, int sampRate, int cplStart, int cplQbits, int *codingDelay);
+ void Gecko2FreeDecoder(HGecko2Decoder hGecko2Decoder);
+ int Gecko2Decode(HGecko2Decoder hGecko2Decoder, unsigned char *codebuf, int lostflag, short *outbuf, unsigned timestamp);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _GECKO2CODEC_H */
+
diff --git a/audio_codec/libraac/include/helix_config.h b/audio_codec/libraac/include/helix_config.h
new file mode 100644
index 0000000..2b7b500
--- a/dev/null
+++ b/audio_codec/libraac/include/helix_config.h
@@ -0,0 +1,92 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: helix_config.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef HELIX_CONFIG_H
+#define HELIX_CONFIG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+
+ /********************************************************************
+ *
+ * This file contains system wide configuration options. Please look
+ * through all the config options below to make sure the SDK is tuned
+ * best for your system.
+ *
+ ********************************************************************
+ */
+
+
+ /*
+ * Endian'ness.
+ *
+ * This package supports both compile-time and run-time determination
+ * of CPU byte ordering. If ARCH_IS_BIG_ENDIAN is defined as 0, the
+ * code will be compiled to run only on little-endian CPUs; if
+ * ARCH_IS_BIG_ENDIAN is defined as non-zero, the code will be
+ * compiled to run only on big-endian CPUs; if ARCH_IS_BIG_ENDIAN is
+ * not defined, the code will be compiled to run on either big- or
+ * little-endian CPUs, but will run slightly less efficiently on
+ * either one than if ARCH_IS_BIG_ENDIAN is defined.
+ *
+ * If you run on a BIG engian box uncomment this:
+ *
+ * #define ARCH_IS_BIG_ENDIAN 1
+ *
+ * If you are on a LITTLE engian box uncomment this:
+ *
+ * #define ARCH_IS_BIG_ENDIAN 0
+ *
+ * Or you can just leave it undefined and have it determined
+ * at runtime.
+ *
+ */
+
+
+
+
+
+
+
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef HELIX_CONFIG_H */
diff --git a/audio_codec/libraac/include/helix_mime_types.h b/audio_codec/libraac/include/helix_mime_types.h
new file mode 100644
index 0000000..b848bd6
--- a/dev/null
+++ b/audio_codec/libraac/include/helix_mime_types.h
@@ -0,0 +1,56 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: helix_mime_types.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef HELIX_MIME_TYPES_H
+#define HELIX_MIME_TYPES_H
+
+#define REALAUDIO_MIME_TYPE "audio/x-pn-realaudio"
+#define REALAUDIO_MULTIRATE_MIME_TYPE "audio/x-pn-multirate-realaudio"
+#define REALAUDIO_ENCRYPTED_MIME_TYPE "audio/x-pn-realaudio-encrypted"
+#define REALVIDEO_MIME_TYPE "video/x-pn-realvideo"
+#define REALVIDEO_MULTIRATE_MIME_TYPE "video/x-pn-multirate-realvideo"
+#define REALVIDEO_ENCRYPTED_MIME_TYPE "video/x-pn-realvideo-encrypted"
+#define REALEVENT_MIME_TYPE "application/x-pn-realevent"
+#define REALEVENT_ENCRYPTED_MIME_TYPE "application/x-pn-realevent-encrypted"
+#define REALIMAGEMAP_MIME_TYPE "application/x-pn-imagemap"
+#define REALIMAGEMAP_ENCRYPTED_MIME_TYPE "application/x-pn-imagemap-encrypted"
+#define IMAGEMAP_MIME_TYPE "image_map/x-pn-realvideo"
+#define IMAGEMAP_ENCRYPTED_MIME_TYPE "image_map/x-pn-realvideo-encrypted"
+#define SYNCMM_MIME_TYPE "syncMM/x-pn-realvideo"
+#define SYNCMM_ENCRYPTED_MIME_TYPE "syncMM/x-pn-realvideo-encrypted"
+
+#endif /* #ifndef HELIX_MIME_TYPES_H */
diff --git a/audio_codec/libraac/include/helix_result.h b/audio_codec/libraac/include/helix_result.h
new file mode 100644
index 0000000..6c600b4
--- a/dev/null
+++ b/audio_codec/libraac/include/helix_result.h
@@ -0,0 +1,107 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: helix_result.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef HELIX_RESULT_H
+#define HELIX_RESULT_H
+
+#include "helix_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* Definition of HX_RESULT */
+#ifndef HX_RESULT
+ typedef INT32 HX_RESULT;
+#endif /* #ifndef HX_RESULT */
+
+ /* FACILITY_ITF defintion */
+#ifndef FACILITY_ITF
+#define FACILITY_ITF 4
+#endif
+
+ /* General error definition macro */
+#ifndef MAKE_HX_FACILITY_RESULT
+#define MAKE_HX_FACILITY_RESULT(sev,fac,code) \
+ ((HX_RESULT) (((UINT32)(sev) << 31) | ((UINT32)(fac)<<16) | ((UINT32)(code))))
+#endif /* #ifndef MAKE_HX_FACILITY_RESULT */
+
+ /* Error definition macros with fac == FACILITY_ITF */
+#ifndef MAKE_HX_RESULT
+#define MAKE_HX_RESULT(sev,fac,code) MAKE_HX_FACILITY_RESULT(sev, FACILITY_ITF, ((fac << 6) | (code)))
+#endif /* #ifndef MAKE_HX_RESULT */
+
+#define SS_GLO 0 /* General errors */
+#define SS_NET 1 /* Networking errors */
+#define SS_FIL 2 /* File errors */
+#define SS_DEC 8 /* Decoder errors */
+#define SS_DPR 63 /* Deprecated errors */
+
+#define HXR_NOTIMPL MAKE_HX_FACILITY_RESULT(1,0,0x4001) /* 80004001 */
+#define HXR_OUTOFMEMORY MAKE_HX_FACILITY_RESULT(1,7,0x000e) /* 8007000e */
+#define HXR_INVALID_PARAMETER MAKE_HX_FACILITY_RESULT(1,7,0x0057) /* 80070057 */
+#define HXR_NOINTERFACE MAKE_HX_FACILITY_RESULT(1,0,0x4002) /* 80004002 */
+#define HXR_POINTER MAKE_HX_FACILITY_RESULT(1,0,0x4003) /* 80004003 */
+#define HXR_FAIL MAKE_HX_FACILITY_RESULT(1,0,0x4005) /* 80004005 */
+#define HXR_ACCESSDENIED MAKE_HX_FACILITY_RESULT(1,7,0x0005) /* 80070005 */
+#define HXR_OK MAKE_HX_FACILITY_RESULT(0,0,0) /* 00000000 */
+
+#define HXR_INVALID_VERSION MAKE_HX_RESULT(1,SS_GLO,5) /* 80040005 */
+#define HXR_UNEXPECTED MAKE_HX_RESULT(1,SS_GLO,9) /* 80040009 */
+#define HXR_UNSUPPORTED_AUDIO MAKE_HX_RESULT(1,SS_GLO,15) /* 8004000f */
+#define HXR_NOT_SUPPORTED MAKE_HX_RESULT(1,SS_GLO,33) /* 80040021 */
+
+#define HXR_NO_DATA MAKE_HX_RESULT(0,SS_NET,2) /* 00040042 */
+
+#define HXR_AT_END MAKE_HX_RESULT(0,SS_FIL,0) /* 00040080 */
+#define HXR_INVALID_FILE MAKE_HX_RESULT(1,SS_FIL,1) /* 80040081 */
+#define HXR_CORRUPT_FILE MAKE_HX_RESULT(1,SS_FIL,17) /* 80040091 */
+#define HXR_READ_ERROR MAKE_HX_RESULT(1,SS_FIL,18) /* 80040092 */
+
+#define HXR_BAD_FORMAT MAKE_HX_RESULT(1,SS_DPR,1) /* 80040fc1 */
+
+#define HXR_DEC_NOT_FOUND MAKE_HX_RESULT(1,SS_DEC,1) /* 80040201 */
+
+ /* Define success and failure macros */
+#define HX_SUCCEEDED(status) (((UINT32) (status) >> 31) == 0)
+#define HX_FAILED(status) (((UINT32) (status) >> 31) != 0)
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef HELIX_RESULT_H */
diff --git a/audio_codec/libraac/include/helix_types.h b/audio_codec/libraac/include/helix_types.h
new file mode 100644
index 0000000..fbb7d56
--- a/dev/null
+++ b/audio_codec/libraac/include/helix_types.h
@@ -0,0 +1,305 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: helix_types.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef HELIX_TYPES_H
+#define HELIX_TYPES_H
+//#include <core/dsp.h>
+#include "string.h"
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /*
+ * INT8 Type definition
+ *
+ * INT8 is a signed 8-bit type
+ */
+#ifndef INT8
+
+#if defined(_SYMBIAN)
+ typedef TInt8 INT8;
+#else /* #if defined(_SYMBIAN) */
+ typedef char INT8;
+#endif /* #if defined(_SYMBIAN) */
+
+#endif /* #ifndef INT8 */
+
+
+ /*
+ * CHAR - signed 8-bit value
+ */
+ typedef INT8 CHAR;
+
+
+ /*
+ * UINT8 Type definition
+ *
+ * UINT8 is an unsigned 8-bit type
+ */
+#ifndef UINT8
+
+#if defined(_SYMBIAN)
+ typedef TUint8 UINT8;
+#else /* #if defined(_SYMBIAN) */
+ typedef unsigned char UINT8;
+#endif /* #if defined(_SYMBIAN) */
+
+#endif /* #ifndef UINT8 */
+
+ /*
+ * BYTE Type definition
+ *
+ * BYTE is another name for a UINT8
+ */
+ typedef UINT8 BYTE;
+
+ /*
+ * UCHAR Unsigned 8 bit value.
+ *
+ */
+ typedef UINT8 UCHAR;
+
+ /*
+ * INT16 Type definition
+ *
+ * INT16 is a signed 16-bit type
+ */
+#ifndef INT16
+
+#if defined(_SYMBIAN)
+ typedef TInt16 INT16;
+#else /* #if defined(_SYMBIAN) */
+ typedef short int INT16;
+#endif /* #if defined(_SYMBIAN) */
+
+#endif /* #ifndef INT16 */
+
+ /*
+ * UINT16 Type definition
+ *
+ * UINT16 is an unsigned 16-bit type
+ */
+#ifndef UINT16
+
+#if defined(_SYMBIAN)
+ typedef TUint16 UINT16;
+#else /* #if defined(_SYMBIAN) */
+ typedef unsigned short int UINT16;
+#endif /* #if defined(_SYMBIAN) */
+
+#endif /* #ifndef UINT16 */
+
+ /*
+ * INT32 Type definition
+ *
+ * INT32 is a signed 32-bit type
+ */
+#ifndef INT32
+
+#if defined(_SYMBIAN)
+ typedef TInt32 INT32;
+#elif defined(_UNIX) && defined(_LONG_IS_64)
+ typedef int INT32;
+#elif defined(_VXWORKS)
+ typedef int INT32;
+#else
+ typedef int INT32;
+#endif
+
+#endif /* #ifndef INT32 */
+
+ /*
+ * LONG32 Type definition
+ *
+ * LONG32 is another name for a INT32
+ */
+ typedef INT32 LONG32;
+
+ /*
+ * UINT32 Type definition
+ *
+ * UINT32 is an unsigned 32-bit type
+ */
+#ifndef UINT32
+
+#if defined(_SYMBIAN)
+ typedef TUint32 UINT32;
+#elif defined(_UNIX) && defined(_LONG_IS_64)
+ typedef unsigned int UINT32;
+#elif defined(_VXWORKS)
+ typedef unsigned int UINT32;
+#else
+ typedef unsigned long UINT32;
+#endif
+
+#endif /* #ifndef UINT32 */
+
+ /*
+ * UFIXED32 Type definition
+ *
+ * UFIXED32 is another name for a UINT32
+ */
+ typedef UINT32 UFIXED32;
+
+ /*
+ * ULONG32 Type definition
+ *
+ * ULONG32 is another name for a UINT32
+ */
+ typedef UINT32 ULONG32;
+
+ /*
+ * HX_MOFTAG Type definition
+ *
+ * HX_MOFTAG is of type UINT32
+ */
+ typedef UINT32 HX_MOFTAG;
+
+ /*
+ * HXBOOL Type definition
+ *
+ * HXBOOL is a boolean type
+ */
+#ifndef HXBOOL
+
+#if defined(_SYMBIAN)
+ typedef TBool HXBOOL;
+#else /* #if defined(_SYMBIAN) */
+ typedef int HXBOOL;
+#endif /* #if defined(_SYMBIAN) */
+
+#endif /* #ifndef HXBOOL */
+
+ /*
+ * BOOL Type definition
+ *
+ * BOOL is another name for a HXBOOL
+ */
+ typedef HXBOOL BOOL;
+
+ /*
+ * TRUE and FALSE definitions
+ */
+#ifdef TRUE
+#undef TRUE
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifdef FALSE
+#undef FALSE
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+ /*
+ * HX_BITFIELD Type definition
+ *
+ * HX_BITFIELD is a bitfield type. It would
+ * be used in conjunction with a field width
+ * parameter like this:
+ *
+ * HX_BITFIELD foo:2;
+ */
+#ifndef HX_BITFIELD
+
+ typedef unsigned char HX_BITFIELD;
+
+#endif
+
+ /*
+ * HXFLOAT Type definition
+ *
+ * HXFLOAT is a single-precision floating-point type
+ */
+#ifndef HXFLOAT
+
+ typedef float HXFLOAT;
+
+#endif /* #ifndef HXFLOAT */
+
+ /*
+ * HXDOUBLE Type definition
+ *
+ * HXDOUBLE is a double-precision floating-point type
+ */
+#ifndef HXDOUBLE
+
+ typedef double HXDOUBLE;
+
+#endif /* #ifndef HXDOUBLE */
+
+ /*
+ * HXNULL definition
+ */
+#ifndef HXNULL
+#define HXNULL ((void *)0)
+#endif
+
+ /*
+ * Helix DATE type.
+ */
+
+#define HX_YEAR_OFFSET 1900
+
+ typedef struct system_time {
+ UINT16 second; /* 0-59 */
+ UINT16 minute; /* 0-59 */
+ UINT16 hour; /* 0-23 */
+ UINT16 dayofweek; /* 0-6 (Sunday = 0) */
+ UINT16 dayofmonth;/* 1-31 */
+ UINT16 dayofyear; /* 1-366 (January 1 = 1) */
+ UINT16 month; /* 1-12 (January = 1) */
+ UINT16 year; /* year - 1900 or (year - HX_YEAR_OFFSET) */
+ INT16 gmtDelta; /* Greenwich Mean Time Delta in +/- hours */
+ } HX_DATETIME;
+
+ HX_DATETIME HX_GET_DATETIME(void);
+
+#define HXEXPORT_PTR *
+#define HXEXPORT
+#define ENTRYPOINT(func) func
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef HELIX_TYPES_H */
diff --git a/audio_codec/libraac/include/helix_utils.h b/audio_codec/libraac/include/helix_utils.h
new file mode 100644
index 0000000..40450ca
--- a/dev/null
+++ b/audio_codec/libraac/include/helix_utils.h
@@ -0,0 +1,106 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: helix_utils.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef HELIX_UTILS_H
+#define HELIX_UTILS_H
+
+#include "helix_config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+
+ /*
+ * General support macros
+ *
+ */
+
+#define HX_MAX(a, b) (((a) > (b)) ? (a) : (b))
+#define HX_MIN(a, b) (((a) < (b)) ? (a) : (b))
+
+ /*
+ * Macro: IS_BIG_ENDIAN()
+ *
+ * Endianness detection macro.
+ * Requires local test_int = 0xFF for correct operation.
+ * Set ARCH_IS_BIG_ENDIAN in helix_config.h for best performance.
+ *
+ */
+
+#if !defined(ARCH_IS_BIG_ENDIAN)
+#define IS_BIG_ENDIAN(test_int) ((*((char*)&test_int)) == 0)
+#else
+#define IS_BIG_ENDIAN(test_int) ARCH_IS_BIG_ENDIAN
+#endif
+
+ /*
+ * Macro: HX_GET_MAJOR_VERSION()
+ *
+ * Given the encoded product version,
+ * returns the major version number.
+ */
+#define HX_GET_MAJOR_VERSION(prodVer) ((prodVer >> 28) & 0xF)
+
+ /*
+ * Macro: HX_GET_MINOR_VERSION()
+ *
+ * Given the encoded product version,
+ * returns the minor version number.
+ */
+#define HX_GET_MINOR_VERSION(prodVer) ((prodVer >> 20) & 0xFF)
+
+ /*
+ * Macro: HX_ENCODE_PROD_VERSION()
+ *
+ * Given the major version, minor version,
+ * release number, and build number,
+ * returns the encoded product version.
+ */
+#define HX_ENCODE_PROD_VERSION(major,minor,release,build) \
+ ((ULONG32)((ULONG32)major << 28) | ((ULONG32)minor << 20) | \
+ ((ULONG32)release << 12) | (ULONG32)build)
+
+#define HX_GET_PRIVATE_FIELD(ulversion)(ulversion & (UINT32)0xFF)
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+
+#endif /* HELIX_UTILS_H */
+
diff --git a/audio_codec/libraac/include/md5.h b/audio_codec/libraac/include/md5.h
new file mode 100644
index 0000000..7cec16c
--- a/dev/null
+++ b/audio_codec/libraac/include/md5.h
@@ -0,0 +1,113 @@
+/*
+ Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved.
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ L. Peter Deutsch
+ ghost@aladdin.com
+
+ */
+
+/*
+ Independent implementation of MD5 (RFC 1321).
+
+ This code implements the MD5 Algorithm defined in RFC 1321, whose
+ text is available at
+ http://www.ietf.org/rfc/rfc1321.txt
+ The code is derived from the text of the RFC, including the test suite
+ (section A.5) but excluding the rest of Appendix A. It does not include
+ any code or documentation that is identified in the RFC as being
+ copyrighted.
+
+ The original and principal author of md5.h is L. Peter Deutsch
+ <ghost@aladdin.com>. Other authors are noted in the change history
+ that follows (in reverse chronological order):
+
+ 2002-04-13 lpd Removed support for non-ANSI compilers; removed
+ references to Ghostscript; clarified derivation from RFC 1321;
+ now handles byte order either statically or dynamically.
+ 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
+ 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
+ added conditionalization for C++ compilation from Martin
+ Purschke <purschke@bnl.gov>.
+ 1999-05-03 lpd Original version.
+ */
+
+#ifndef md5_INCLUDED
+# define md5_INCLUDED
+
+
+#include "helix_types.h"
+/*
+ * These should cause all callers and callees of the md5_
+ * function names to use a unique Helix specific name space
+ * of HX_md5_xxx. This will facilitate the inclusion of our
+ * code into code bases that also use the md5_ functions.
+ */
+
+#define md5_init HX_md5_init
+#define md5_append HX_md5_append
+#define md5_finish HX_md5_finish
+#define MD5End HX_MD5End
+#define MD5Data HX_MD5Data
+
+
+/*
+ * This package supports both compile-time and run-time determination of CPU
+ * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be
+ * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is
+ * defined as non-zero, the code will be compiled to run only on big-endian
+ * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to
+ * run on either big- or little-endian CPUs, but will run slightly less
+ * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined.
+ */
+
+typedef unsigned char md5_byte_t; /* 8-bit byte */
+typedef unsigned int md5_word_t; /* 32-bit word */
+
+/* Define the state of the MD5 Algorithm. */
+typedef struct md5_state_s {
+ md5_word_t count[2]; /* message length in bits, lsw first */
+ md5_word_t abcd[4]; /* digest buffer */
+ md5_byte_t buf[64]; /* accumulate block */
+} md5_state_t;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /* Initialize the algorithm. */
+ void md5_init(md5_state_t *pms);
+
+ /* Append a string to the message. */
+ void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
+
+ /* Finish the message and return the digest. */
+ /* changed order to match expected usage. */
+ void md5_finish(md5_byte_t digest[16], md5_state_t *pms);
+
+
+ char * MD5End(md5_state_t *ctx, char *p);
+ char * MD5Data(char *, const unsigned char *, unsigned int);
+
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
+#endif /* md5_INCLUDED */
diff --git a/audio_codec/libraac/include/memory_utils.h b/audio_codec/libraac/include/memory_utils.h
new file mode 100644
index 0000000..3c8992c
--- a/dev/null
+++ b/audio_codec/libraac/include/memory_utils.h
@@ -0,0 +1,58 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: memory_utils.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef MEMORY_UTILS_H
+#define MEMORY_UTILS_H
+
+//#include "includes.h"
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+
+HX_RESULT rm_enforce_buffer_min_size(void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree,
+ BYTE** ppBuf,
+ UINT32* pulCurLen,
+ UINT32 ulReqLen);
+
+BYTE* copy_buffer(void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ BYTE* pBuf,
+ UINT32 ulLen);
+
+#endif /* #ifndef MEMORY_UTILS_H */
diff --git a/audio_codec/libraac/include/pack_utils.h b/audio_codec/libraac/include/pack_utils.h
new file mode 100644
index 0000000..d5bf21f
--- a/dev/null
+++ b/audio_codec/libraac/include/pack_utils.h
@@ -0,0 +1,93 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: pack_utils.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef PACK_UTILS_H
+#define PACK_UTILS_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+
+/* Pack a 32-bit value big-endian */
+void rm_pack32(UINT32 ulValue, BYTE** ppBuf, UINT32* pulLen);
+/* Pack a 32-bit value little-endian */
+void rm_pack32_le(UINT32 ulValue, BYTE** ppBuf, UINT32* pulLen);
+/* Pack a 16-bit value big-endian */
+void rm_pack16(UINT16 usValue, BYTE** ppBuf, UINT32* pulLen);
+/* Pack a 16-bit value little-endian */
+void rm_pack16_le(UINT16 usValue, BYTE** ppBuf, UINT32* pulLen);
+void rm_pack8(BYTE ucValue, BYTE** ppBuf, UINT32* pulLen);
+
+/* Unpacking utilties */
+UINT32 rm_unpack32(BYTE** ppBuf, UINT32* pulLen);
+UINT16 rm_unpack16(BYTE** ppBuf, UINT32* pulLen);
+/* rm_unpack32() and rm_unpack16() have the side
+ * effect of incrementing *ppBuf and decrementing
+ * *pulLen. The functions below (rm_unpack32_nse()
+ * rm_unpack16_nse()) do not change pBuf and ulLen.
+ * That is, they have No Side Effect, hence the suffix
+ * _nse.
+ */
+UINT32 rm_unpack32_nse(BYTE* pBuf, UINT32 ulLen);
+UINT16 rm_unpack16_nse(BYTE* pBuf, UINT32 ulLen);
+BYTE rm_unpack8(BYTE** ppBuf, UINT32* pulLen);
+HX_RESULT rm_unpack_string(BYTE** ppBuf,
+ UINT32* pulLen,
+ UINT32 ulStrLen,
+ char** ppStr,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+HX_RESULT rm_unpack_buffer(BYTE** ppBuf,
+ UINT32* pulLen,
+ UINT32 ulBufLen,
+ BYTE** ppUnPackBuf,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+HX_RESULT rm_unpack_array(BYTE** ppBuf,
+ UINT32* pulLen,
+ UINT32 ulNumElem,
+ UINT32 ulElemSize,
+ void** ppArr,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+
+UINT32 rm_unpack32_from_byte_string(BYTE** ppBuf, UINT32* pulLen);
+
+#endif /* #ifndef PACK_UTILS_H */
diff --git a/audio_codec/libraac/include/packet_defines.h b/audio_codec/libraac/include/packet_defines.h
new file mode 100644
index 0000000..5339f36
--- a/dev/null
+++ b/audio_codec/libraac/include/packet_defines.h
@@ -0,0 +1,48 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: packet_defines.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef PACKET_DEFINES_H
+#define PACKET_DEFINES_H
+
+#define HX_KEYFRAME_FLAG 0x0002
+#define HX_KEYFRAME_RULE 0
+#define HX_NONKEYFRAME_RULE 1
+#define HX_THINNING_RULE 2
+#define HX_ASM_SWITCH_ON 1
+#define HX_ASM_SWITCH_OFF 2
+
+#endif /* #ifndef PACKET_DEFINES_H */
diff --git a/audio_codec/libraac/include/ra8lbr_decode.h b/audio_codec/libraac/include/ra8lbr_decode.h
new file mode 100644
index 0000000..ef39e6f
--- a/dev/null
+++ b/audio_codec/libraac/include/ra8lbr_decode.h
@@ -0,0 +1,161 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: ra8lbr_decode.h,v 1.2.2.1 2005/05/04 18:21:53 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RA8LBR_DECODE_H
+#define RA8LBR_DECODE_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "ra_decode.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* ra8lbr decode struct */
+ typedef struct ra8lbr_decode_struct {
+ void* pDecoder;
+ UINT32 ulNumChannels;
+ UINT32 ulChannelMask;
+ UINT32 ulFrameSize;
+ UINT32 ulFramesPerBlock;
+ UINT32 ulSamplesPerFrame;
+ UINT32 ulSampleRate;
+ UINT32 ulDelayFrames;
+ UINT32 ulDelayRemaining;
+ UINT32 ulFramesToConceal;
+ UCHAR* pFlushData;
+ } ra8lbr_decode;
+
+ /* ra8lbr opaque data struct */
+ typedef struct ra8lbr_data_struct {
+ INT32 version;
+ INT16 nSamples;
+ INT16 nRegions;
+ INT32 delay;
+ UINT16 cplStart ;
+ UINT16 cplQBits ;
+ INT32 channelMask ;
+ } ra8lbr_data;
+
+ /* ra8lbr decode interface */
+
+ /*
+ * ra8lbr_decode_init
+ */
+ HX_RESULT ra8lbr_decode_init(void* pInitParams,
+ UINT32 ulInitParamsSize,
+ ra_format_info* pStreamInfo,
+ void** pDecode,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+
+ /*
+ * ra8lbr_decode_reset
+ */
+ HX_RESULT ra8lbr_decode_reset(void* pDecode,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut);
+
+ /*
+ * ra8lbr_decode_conceal
+ */
+ HX_RESULT ra8lbr_decode_conceal(void* pDecode,
+ UINT32 ulNumSamples);
+
+ /*
+ * ra8lbr_decode_decode
+ */
+ HX_RESULT ra8lbr_decode_decode(void* pDecode,
+ UINT8* pData,
+ UINT32 ulNumBytes,
+ UINT32* pNumBytesConsumed,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut,
+ UINT32 ulFlags,
+ UINT32 ulTimeStamp);
+
+ /*
+ * ra8lbr_decode_getmaxsize
+ */
+ HX_RESULT ra8lbr_decode_getmaxsize(void* pDecode,
+ UINT32* pNumSamples);
+
+ /*
+ * ra8lbr_decode_getchannels
+ */
+ HX_RESULT ra8lbr_decode_getchannels(void* pDecode,
+ UINT32* pNumChannels);
+
+ /*
+ * ra8lbr_decode_getchannelmask
+ */
+ HX_RESULT ra8lbr_decode_getchannelmask(void* pDecode,
+ UINT32* pChannelMask);
+
+ /*
+ * ra8lbr_decode_getrate
+ */
+ HX_RESULT ra8lbr_decode_getrate(void* pDecode,
+ UINT32* pSampleRate);
+
+ /*
+ * ra8lbr_decode_getdelay
+ */
+ HX_RESULT ra8lbr_decode_getdelay(void* pDecode,
+ UINT32* pNumSamples);
+
+ /*
+ * ra8lbr_decode_close
+ */
+ HX_RESULT ra8lbr_decode_close(void* pDecode,
+ void* pUserMem,
+ rm_free_func_ptr fpFree);
+
+ HX_RESULT ra8lbr_unpack_opaque_data(ra8lbr_data* pData,
+ UINT8* pBuf,
+ UINT32 ulLength);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RA8LBR_DECODE_H */
diff --git a/audio_codec/libraac/include/ra_backend.h b/audio_codec/libraac/include/ra_backend.h
new file mode 100644
index 0000000..d351c5b
--- a/dev/null
+++ b/audio_codec/libraac/include/ra_backend.h
@@ -0,0 +1,94 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: ra_backend.h,v 1.2.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RA_BACKEND_H__
+#define RA_BACKEND_H__
+
+/* Unified RealAudio decoder backend interface */
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+#include "ra_format_info.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* ra decoder backend interface */
+
+ typedef HX_RESULT(*ra_decode_init_func_ptr)(void* pInitParams,
+ UINT32 ulInitParamsSize,
+ ra_format_info* pStreamInfo,
+ void** pDecode,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+ typedef HX_RESULT(*ra_decode_reset_func_ptr)(void* pDecode,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut);
+ typedef HX_RESULT(*ra_decode_conceal_func_ptr)(void* pDecode,
+ UINT32 ulNumSamples);
+ typedef HX_RESULT(*ra_decode_decode_func_ptr)(void* pDecode,
+ UINT8* pData,
+ UINT32 ulNumBytes,
+ UINT32* pNumBytesConsumed,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut,
+ UINT32 ulFlags,
+ UINT32 ulTimeStamp);
+ typedef HX_RESULT(*ra_decode_getmaxsize_func_ptr)(void* pDecode,
+ UINT32* pNumSamples);
+ typedef HX_RESULT(*ra_decode_getchannels_func_ptr)(void* pDecode,
+ UINT32* pNumChannels);
+ typedef HX_RESULT(*ra_decode_getchannelmask_func_ptr)(void* pDecode,
+ UINT32* pChannelMask);
+ typedef HX_RESULT(*ra_decode_getrate_func_ptr)(void* pDecode,
+ UINT32* pSampleRate);
+ typedef HX_RESULT(*ra_decode_getdelay_func_ptr)(void* pDecode,
+ UINT32* pNumSamples);
+ typedef HX_RESULT(*ra_decode_close_func_ptr)(void* pDecode,
+ void* pUserMem,
+ rm_free_func_ptr fpFree);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RA_BACKEND_H__ */
diff --git a/audio_codec/libraac/include/ra_decode.h b/audio_codec/libraac/include/ra_decode.h
new file mode 100644
index 0000000..b51ec0c
--- a/dev/null
+++ b/audio_codec/libraac/include/ra_decode.h
@@ -0,0 +1,183 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: ra_decode.h,v 1.2.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RA_DECODE_H
+#define RA_DECODE_H
+
+/* Simple unified decoder frontend for RealAudio */
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+#include "rm_error.h"
+#include "ra_format_info.h"
+#include "ra_backend.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* The ra_decode struct contains the RealAudio decoder frontend
+ * function pointers and pointers to the backend. */
+
+ typedef struct ra_decode_struct {
+ void* pUserError;
+ rm_error_func_ptr fpError;
+ void* pUserMem;
+ rm_malloc_func_ptr fpMalloc;
+ rm_free_func_ptr fpFree;
+
+ ra_decode_init_func_ptr fpInit;
+ ra_decode_reset_func_ptr fpReset;
+ ra_decode_conceal_func_ptr fpConceal;
+ ra_decode_decode_func_ptr fpDecode;
+ ra_decode_getmaxsize_func_ptr fpGetMaxSize;
+ ra_decode_getchannels_func_ptr fpGetChannels;
+ ra_decode_getchannelmask_func_ptr fpGetChannelMask;
+ ra_decode_getrate_func_ptr fpGetSampleRate;
+ ra_decode_getdelay_func_ptr fpMaxSamp;
+ ra_decode_close_func_ptr fpClose;
+
+ void* pDecode;
+ } ra_decode;
+
+ /* ra_decode_create()
+ * Creates RA decoder frontend struct, copies memory utilities.
+ * Returns struct pointer on success, NULL on failure. */
+ ra_decode* ra_decode_create(void* pUserError,
+ rm_error_func_ptr fpError);
+
+ ra_decode* ra_decode_create2(void* pUserError,
+ rm_error_func_ptr fpError,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+
+ /* ra_decode_destroy()
+ * Deletes the decoder backend and frontend instances. */
+ void ra_decode_destroy(ra_decode* pFrontEnd);
+
+ /* ra_decode_init()
+ * Selects decoder backend with fourCC code.
+ * Calls decoder backend init function with init params.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_init(ra_decode* pFrontEnd,
+ UINT32 ulFourCC,
+ void* pInitParams,
+ UINT32 ulInitParamsSize,
+ ra_format_info* pStreamInfo);
+
+ /* ra_decode_reset()
+ * Calls decoder backend reset function.
+ * Depending on which codec is in use, *pNumSamplesOut samples may
+ * be flushed. After reset, the decoder returns to its initial state.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_reset(ra_decode* pFrontEnd,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut);
+
+ /* ra_decode_conceal()
+ * Calls decoder backend conceal function.
+ * On successive calls to ra_decode_decode(), the decoder will attempt
+ * to conceal ulNumSamples. No input data should be sent while concealed
+ * frames are being produced. Once the decoder has exhausted the concealed
+ * samples, it can proceed normally with decoding valid input data.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_conceal(ra_decode* pFrontEnd,
+ UINT32 ulNumSamples);
+
+ /* ra_decode_decode()
+ * Calls decoder backend decode function.
+ * pData : input data (compressed frame).
+ * ulNumBytes : input data size in bytes.
+ * pNumBytesConsumed : amount of input data consumed by decoder.
+ * pSamplesOut : output data (uncompressed frame).
+ * ulNumSamplesAvail : size of output buffer.
+ * pNumSamplesOut : amount of ouput data produced by decoder.
+ * ulFlags : control flags for decoder.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_decode(ra_decode* pFrontEnd,
+ UINT8* pData,
+ UINT32 ulNumBytes,
+ UINT32* pNumBytesConsumed,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut,
+ UINT32 ulFlags,
+ UINT32 ulTimeStamp);
+
+
+ /**************** Accessor Functions *******************/
+ /* ra_decode_getmaxsize()
+ * pNumSamples receives the maximum number of samples produced
+ * by the decoder in response to a call to ra_decode_decode().
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_getmaxsize(ra_decode* pFrontEnd,
+ UINT32* pNumSamples);
+
+ /* ra_decode_getchannels()
+ * pNumChannels receives the number of audio channels in the bitstream.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_getchannels(ra_decode* pFrontEnd,
+ UINT32* pNumChannels);
+
+ /* ra_decode_getchannelmask()
+ * pChannelMask receives the 32-bit mapping of the audio output channels.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_getchannelmask(ra_decode* pFrontEnd,
+ UINT32* pChannelMask);
+
+ /* ra_decode_getrate()
+ * pSampleRate receives the sampling rate of the output samples.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_getrate(ra_decode* pFrontEnd,
+ UINT32* pSampleRate);
+
+ /* ra_decode_getdelay()
+ * pNumSamples receives the number of invalid output samples
+ * produced by the decoder at startup.
+ * If non-zero, it is up to the user to discard these samples.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT ra_decode_getdelay(ra_decode* pFrontEnd,
+ UINT32* pNumSamples);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RA_DECODE_H */
diff --git a/audio_codec/libraac/include/ra_depack.h b/audio_codec/libraac/include/ra_depack.h
new file mode 100644
index 0000000..aedfd64
--- a/dev/null
+++ b/audio_codec/libraac/include/ra_depack.h
@@ -0,0 +1,177 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: ra_depack.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RA_DEPACK_H
+#define RA_DEPACK_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_error.h"
+#include "rm_memory.h"
+#include "rm_stream.h"
+#include "rm_packet.h"
+#include "ra_format_info.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* Encoded audio block definition. */
+ typedef struct ra_block_struct {
+ BYTE* pData;
+ UINT32 ulDataLen;
+ UINT32 ulTimestamp;
+ UINT32 ulDataFlags;
+ } ra_block;
+
+ /* Callback functions */
+ typedef HX_RESULT(*ra_block_avail_func_ptr)(void* pAvail,
+ UINT32 ulSubStream,
+ ra_block* block);
+
+ /*
+ * ra_depack definition. Opaque to user.
+ */
+ typedef void ra_depack;
+
+ /*
+ * ra_depack_create
+ *
+ * Users should use this function if they don't need to
+ * customize their memory allocation routines. In this
+ * case, the SDK will use malloc() and free() for
+ * memory allocation.
+ */
+ ra_depack* ra_depack_create(void* pAvail,
+ ra_block_avail_func_ptr fpAvail,
+ void* pUserError,
+ rm_error_func_ptr fpError);
+
+ /*
+ * ra_depack_create2
+ *
+ * Users should use this function if they need to
+ * customize the memory allocation routines.
+ */
+ ra_depack* ra_depack_create2(void* pAvail,
+ ra_block_avail_func_ptr fpAvail,
+ void* pUserError,
+ rm_error_func_ptr fpError,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+
+ /*
+ * ra_depack_init
+ *
+ * The depacketizer will be initialized with a RealAudio stream header.
+ */
+ HX_RESULT ra_depack_init(ra_depack* pDepack, rm_stream_header* pHdr);
+
+ /*
+ * ra_depack_get_num_substreams
+ *
+ * This accessor function tells how many audio substreams there are
+ * in this audio stream. For single-rate files, this will be 1. For
+ * SureStream audio streams, this could be greater than 1.
+ */
+ UINT32 ra_depack_get_num_substreams(ra_depack* pDepack);
+
+ /*
+ * ra_depack_get_codec_4cc
+ *
+ * This accessor function returns the 4cc of the codec. This 4cc
+ * will be used to determine which codec to use for this substream.
+ */
+ UINT32 ra_depack_get_codec_4cc(ra_depack* pDepack, UINT32 ulSubStream);
+
+ /*
+ * ra_depack_get_codec_init_info
+ *
+ * This function fills in the structure which is used to initialize the codec.
+ */
+ HX_RESULT ra_depack_get_codec_init_info(ra_depack* pDepack,
+ UINT32 ulSubStream,
+ ra_format_info** ppInfo);
+
+ /*
+ * ra_depack_destroy_codec_init_info
+ *
+ * This function frees the memory associated with the ra_format_info object
+ * created by ra_depack_get_codec_init_info().
+ */
+ void ra_depack_destroy_codec_init_info(ra_depack* pDepack,
+ ra_format_info** ppInfo);
+
+ /*
+ * ra_depack_add_packet
+ *
+ * Put an audio packet into the depacketizer. When enough data is
+ * present to deinterleave, then the user will be called back
+ * on the rm_block_avail_func_ptr set in ra_depack_create().
+ */
+ HX_RESULT ra_depack_add_packet(ra_depack* pDepack, rm_packet* pPacket);
+
+ /*
+ * ra_depack_destroy_block
+ *
+ * This method cleans up a block received via the
+ * ra_block_avail_func_ptr callback.
+ */
+ void ra_depack_destroy_block(ra_depack* pDepack, ra_block** ppBlock);
+
+ /*
+ * ra_depack_seek
+ *
+ * The user calls this function if the stream is seeked. It
+ * should be called before passing any post-seek packets.
+ */
+ HX_RESULT ra_depack_seek(ra_depack* pDepack, UINT32 ulTime);
+
+ /*
+ * ra_depack_destroy
+ *
+ * This cleans up all memory allocated by the ra_depack_* calls
+ */
+ void ra_depack_destroy(ra_depack** ppDepack);
+
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RA_DEPACK_H */
diff --git a/audio_codec/libraac/include/ra_format_info.h b/audio_codec/libraac/include/ra_format_info.h
new file mode 100644
index 0000000..98293ff
--- a/dev/null
+++ b/audio_codec/libraac/include/ra_format_info.h
@@ -0,0 +1,60 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: ra_format_info.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RA_FORMAT_INFO_H
+#define RA_FORMAT_INFO_H
+
+#include "helix_types.h"
+
+/*
+ * ra_format_info struct
+ *
+ */
+typedef struct ra_format_info_struct {
+ UINT32 ulSampleRate;
+ UINT32 ulActualRate;
+ UINT16 usBitsPerSample;
+ UINT16 usNumChannels;
+ UINT16 usAudioQuality;
+ UINT16 usFlavorIndex;
+ UINT32 ulBitsPerFrame;
+ UINT32 ulGranularity;
+ UINT32 ulOpaqueDataSize;
+ BYTE* pOpaqueData;
+} ra_format_info;
+
+#endif /* #ifndef RA_FORMAT_INFO_H */
diff --git a/audio_codec/libraac/include/rasl.h b/audio_codec/libraac/include/rasl.h
new file mode 100644
index 0000000..9eff866
--- a/dev/null
+++ b/audio_codec/libraac/include/rasl.h
@@ -0,0 +1,71 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rasl.h,v 1.1.1.1.2.1 2005/05/04 18:21:33 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RASL_H
+#define RASL_H
+
+#include "helix_types.h"
+
+/* Must regenerate table if these are changed! */
+#define RA50_NCODEBYTES 18.5 /* bytes per 5.0kbps sl frame */
+#define RA65_NCODEBYTES 14.5 /* bytes per 6.5kbps sl frame */
+#define RA85_NCODEBYTES 19 /* bytes per 8.5kbps sl frame */
+#define RA160_NCODEBYTES 20 /* bytes per 16.0kbps sl frame */
+
+#define RA50_NCODEBITS 148 /* bits per 5.0kbps sl frame */
+#define RA65_NCODEBITS 116 /* bits per 6.5kbps sl frame */
+#define RA85_NCODEBITS 152 /* bits per 8.5kbps sl frame */
+#define RA160_NCODEBITS 160 /* bits per 16.0kbps sl frame */
+
+#define RASL_MAXCODEBYTES 20 /* max bytes per sl frame */
+#define RASL_NFRAMES 16 /* frames per block - must match codec */
+#define RASL_NBLOCKS 6 /* blocks to interleave across */
+#define RASL_BLOCK_NUM(i) ((i) >> 4) /* assumes RASL_NFRAMES = 16 */
+#define RASL_BLOCK_OFF(i) ((i) & 0xf) /* assumes RASL_NFRAMES = 16 */
+
+
+void RASL_DeInterleave(char *buf, unsigned long ulBufSize, int type, ULONG32 * pFlags);
+
+void ra_bitcopy(unsigned char* toPtr,
+ unsigned long ulToBufSize,
+ unsigned char* fromPtr,
+ unsigned long ulFromBufSize,
+ int bitOffsetTo,
+ int bitOffsetFrom,
+ int numBits);
+
+#endif /* #ifndef RASL_H */
diff --git a/audio_codec/libraac/include/rdtpck.h b/audio_codec/libraac/include/rdtpck.h
new file mode 100644
index 0000000..68251cd
--- a/dev/null
+++ b/audio_codec/libraac/include/rdtpck.h
@@ -0,0 +1,153 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rdtpck.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RDTPACKET_H
+#define RDTPACKET_H
+
+#include <string.h>
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+ /*
+ *
+ * Packet util functions and types
+ *
+ */
+
+#define RDT_ASM_ACTION_PKT 0xFF00
+#define RDT_BW_REPORT_PKT 0xFF01
+#define RDT_ACK_PKT 0xFF02
+#define RDT_RTT_REQUEST_PKT 0xFF03
+#define RDT_RTT_RESPONSE_PKT 0xFF04
+#define RDT_CONGESTION_PKT 0xFF05
+#define RDT_STREAM_END_PKT 0xFF06
+#define RDT_REPORT_PKT 0xFF07
+#define RDT_LATENCY_REPORT_PKT 0xFF08
+#define RDT_TRANS_INFO_RQST_PKT 0xFF09
+#define RDT_TRANS_INFO_RESP_PKT 0xFF0A
+#define RDT_BANDWIDTH_PROBE_PKT 0xFF0B
+
+#define RDT_DATA_PACKET 0xFFFE
+#define RDT_UNKNOWN_TYPE 0xFFFF
+
+
+
+ /*
+ *
+ * The tngpkt.h file included below is auto-generated from the master
+ * header file which contains the bit by bit definitions of the packet
+ * structures(tngpkt.pm). The structures defined in tngpkt.h are
+ * easier to use compared to the actual packet definitions in
+ * tngpkt.pm. tngpkt.h also includes pack and unpack functions that
+ * can convert these structures to and from the binary wire format of
+ * the different packet types.
+ *
+ */
+#include "tngpkt.h"
+
+
+ /* All seq numbers will be marked as lost [beg, end]. */
+ /* Caller is responsible for free'ing the bit-field that is allocated
+ * ( "pkt->data.data").
+ */
+ void createNAKPacket(struct TNGACKPacket* pkt,
+ UINT16 unStreamNum,
+ UINT16 unBegSeqNum,
+ UINT16 unEndSeqNum
+ );
+
+ void createNAKPacketFromPool(struct TNGACKPacket* pkt,
+ UINT16 unStreamNum,
+ UINT16 unBegSeqNum,
+ UINT16 unEndSeqNum,
+ rm_malloc_func_ptr fpMalloc,
+ void* pMemoryPool
+ );
+
+
+
+ /* All seq numbers will be marked as received [beg, end]. The caller
+ * must free the 'pkt->data.data' malloc'ed memory.
+ */
+ void createACKPacket(struct TNGACKPacket* pkt,
+ UINT16 unStreamNum,
+ UINT16 unBegSeqNum,
+ UINT16 unEndSeqNum
+ );
+
+ void createACKPacketFromPool(struct TNGACKPacket* pkt,
+ UINT16 unStreamNum,
+ UINT16 unBegSeqNum,
+ UINT16 unEndSeqNum,
+ rm_malloc_func_ptr fpMalloc,
+ void* pMemoryPool
+ );
+
+ /*
+ * Returns the packet type of the packet in the buffer that was just
+ * read off of the wire
+ */
+ UINT16 GetRDTPacketType(UINT8* pBuf, UINT32 nLen);
+
+
+
+ /*
+ * Marshalling inline funcs.
+ */
+
+ UINT8 getbyte(UINT8* data);
+ UINT16 getshort(UINT8* data);
+ INT32 getlong(UINT8* data);
+ void putbyte(UINT8* data, INT8 v);
+ void putshort(UINT8* data, UINT16 v);
+ void putlong(UINT8* data, UINT32 v);
+ UINT8* addbyte(UINT8* cp, UINT8 data);
+ UINT8* addshort(UINT8* cp, UINT16 data);
+ UINT8* addlong(UINT8* cp, UINT32 data);
+ UINT8* addstring(UINT8* cp, const UINT8* string, int len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RDTPACKET_H */
diff --git a/audio_codec/libraac/include/rm_error.h b/audio_codec/libraac/include/rm_error.h
new file mode 100644
index 0000000..b052baf
--- a/dev/null
+++ b/audio_codec/libraac/include/rm_error.h
@@ -0,0 +1,54 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_error.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_ERROR_H
+#define RM_ERROR_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ typedef void (*rm_error_func_ptr)(void* pUserError, HX_RESULT err, const char* msg);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RM_ERROR_H */
diff --git a/audio_codec/libraac/include/rm_error_default.h b/audio_codec/libraac/include/rm_error_default.h
new file mode 100644
index 0000000..2d6da08
--- a/dev/null
+++ b/audio_codec/libraac/include/rm_error_default.h
@@ -0,0 +1,53 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_error_default.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_ERROR_DEFAULT_H
+#define RM_ERROR_DEFAULT_H
+
+#include "helix_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ void rm_error_default(void* pUserError, HX_RESULT err, const char* msg);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RM_ERROR_DEFAULT_H */
diff --git a/audio_codec/libraac/include/rm_io_default.h b/audio_codec/libraac/include/rm_io_default.h
new file mode 100644
index 0000000..d1e3323
--- a/dev/null
+++ b/audio_codec/libraac/include/rm_io_default.h
@@ -0,0 +1,49 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_io_default.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_IO_DEFAULT_H
+#define RM_IO_DEFAULT_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+
+UINT32 rm_io_default_read(void* pUserRead, BYTE* pBuf, UINT32 ulBytesToRead);
+void rm_io_default_seek(void* pUserRead, UINT32 ulOffset, UINT32 ulOrigin);
+UINT32 rm_io_datasrc_read(void* pUserRead, BYTE* pBuf, UINT32 ulBytesToRead);
+void rm_io_datasrc_seek(void* pUserRead, UINT32 ulOffset, UINT32 ulOrigin);
+
+#endif /* #ifndef RM_IO_DEFAULT_H */
diff --git a/audio_codec/libraac/include/rm_memory.h b/audio_codec/libraac/include/rm_memory.h
new file mode 100644
index 0000000..81e2919
--- a/dev/null
+++ b/audio_codec/libraac/include/rm_memory.h
@@ -0,0 +1,54 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_memory.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_MEMORY_H
+#define RM_MEMORY_H
+
+#include "helix_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ typedef void* (*rm_malloc_func_ptr)(void* pUserMem, UINT32 ulSize);
+ typedef void (*rm_free_func_ptr)(void* pUserMem, void* ptr);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RM_MEMORY_H */
diff --git a/audio_codec/libraac/include/rm_memory_default.h b/audio_codec/libraac/include/rm_memory_default.h
new file mode 100644
index 0000000..297e441
--- a/dev/null
+++ b/audio_codec/libraac/include/rm_memory_default.h
@@ -0,0 +1,46 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_memory_default.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_MEMORY_DEFAULT_H
+#define RM_MEMORY_DEFAULT_H
+
+#include "helix_types.h"
+
+void* rm_memory_default_malloc(void* pUserMem, UINT32 ulSize);
+void rm_memory_default_free(void* pUserMem, void* ptr);
+
+#endif /* RM_MEMORY_DEFAULT_H */
diff --git a/audio_codec/libraac/include/rm_packet.h b/audio_codec/libraac/include/rm_packet.h
new file mode 100644
index 0000000..e9c47ee
--- a/dev/null
+++ b/audio_codec/libraac/include/rm_packet.h
@@ -0,0 +1,80 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_packet.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_PACKET_H
+#define RM_PACKET_H
+
+#include "helix_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /*
+ * Packet struct
+ *
+ * Users are strongly encouraged to use the
+ * accessor functions below to retrieve information
+ * from the packet, since the definition of this
+ * struct may change in the future.
+ */
+ typedef struct rm_packet_struct {
+ UINT32 ulTime;
+ UINT16 usStream;
+ UINT16 usASMFlags;
+ BYTE ucASMRule;
+ BYTE ucLost;
+ UINT16 usDataLen;
+ BYTE* pData;
+ } rm_packet;
+
+ /*
+ * Packet Accessor functions
+ */
+ UINT32 rm_packet_get_timestamp(rm_packet* packet);
+ UINT32 rm_packet_get_stream_number(rm_packet* packet);
+ UINT32 rm_packet_get_asm_flags(rm_packet* packet);
+ UINT32 rm_packet_get_asm_rule_number(rm_packet* packet);
+ UINT32 rm_packet_get_data_length(rm_packet* packet);
+ BYTE* rm_packet_get_data(rm_packet* packet);
+ HXBOOL rm_packet_is_lost(rm_packet* packet);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RM_PACKET_H */
diff --git a/audio_codec/libraac/include/rm_parse.h b/audio_codec/libraac/include/rm_parse.h
new file mode 100644
index 0000000..6bec67b
--- a/dev/null
+++ b/audio_codec/libraac/include/rm_parse.h
@@ -0,0 +1,302 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_parse.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_PARSE_H
+#define RM_PARSE_H
+
+#include <stdio.h>
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+#include "rm_error.h"
+#include "rm_property.h"
+#include "rm_stream.h"
+#include "rm_packet.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /*
+ * Seek origin definitions - these are
+ * exactly the same as the respective
+ * definitions in <stdio.h>
+ */
+#define HX_SEEK_ORIGIN_SET 0
+#define HX_SEEK_ORIGIN_CUR 1
+#define HX_SEEK_ORIGIN_END 2
+
+ /* Function pointer definitions */
+ typedef UINT32(*rm_read_func_ptr)(void* pUserRead,
+ BYTE* pBuf, /* Must be at least ulBytesToRead long */
+ UINT32 ulBytesToRead);
+ typedef void (*rm_seek_func_ptr)(void* pUserRead,
+ UINT32 ulOffset,
+ UINT32 ulOrigin);
+
+ /*
+ * rm_parser definition. This is opaque to the user.
+ */
+ typedef void rm_parser;
+
+ /*
+ * rm_parser_is_rm_file()
+ *
+ * Function which examines pBuf[0] up through pBuf[ulSize-1] and
+ * tries to determine if the buffer contains the beginning of an .rm file
+ */
+ HXBOOL rm_parser_is_rm_file(BYTE* pBuf, UINT32 ulSize);
+
+ /*
+ * rm_parser_create
+ *
+ * This creates an rm_parser object. The user may provide an
+ * optional error reporting function as well as a void*
+ * which will be passed into fpError. If fpError is NULL, then
+ * the parser will not print out any error messages by default
+ * and the user will have to interpret the error by the
+ * return value.
+ */
+ rm_parser* rm_parser_create(void* pError,
+ rm_error_func_ptr fpError);
+
+ /*
+ * rm_parser_create2
+ *
+ * This creates an rm_parser object, using custom memory
+ * allocation and free functions that the user provides.
+ * If fpMalloc or fpFree are NULL, then the default
+ * allocation and free functions will be used.
+ */
+ rm_parser* rm_parser_create2(void* pError,
+ rm_error_func_ptr fpError,
+ void* pMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+
+ /*
+ * rm_parser_init_stdio
+ *
+ * Users would call this is they wanted to use stdio. This file
+ * would need to already be fopen()'d and would need to be fclose()'d
+ * after the library was finished. The parsing library would only
+ * call fread(), fseek(), and perhaps ftell() on it.
+ */
+ HX_RESULT rm_parser_init_stdio(rm_parser* pParser,
+ FILE* fp);
+
+ /*
+ * rm_parser_init_io
+ *
+ * If the user didn't want to use stdio, they would call
+ * this function to set up their own I/O.
+ */
+ HX_RESULT rm_parser_init_io(rm_parser* pParser,
+ void* pUserRead,
+ rm_read_func_ptr fpRead,
+ rm_seek_func_ptr fpSeek);
+
+ /*
+ * rm_parser_read_headers
+ *
+ * This function reads all the headers at the beginning
+ * of an .rm file. After this function is called,
+ * then the rm_get_xxx accessor functions can be
+ * called to get information about the file as a whole.
+ */
+ HX_RESULT rm_parser_read_headers(rm_parser* pParser);
+
+ /*
+ * File Info Accessor functions
+ *
+ * The most commonly-used properties of an .rm file can
+ * be accessed via the rm_parser_get_xxx accessor functions
+ * below. These functions return information about the .rm file as
+ * a whole, as opposed to stream header properties, which give
+ * information about a particular stream (i.e. - audio stream
+ * or video stream).
+ *
+ * For the title meta-data, the user can determine if this information
+ * is present by calling rm_parser_get_title_length(). This length
+ * is the length in bytes of the string INCLUDING the null
+ * terminator. If the title meta-data IS present, then the user
+ * can get read-only access to the title by calling rm_parser_get_title().
+ * The user must not alter the memory that is returned; otherwise undefined
+ * behavior will result.
+ *
+ * The same applies for author, copyright, and comment meta-data.
+ */
+ UINT32 rm_parser_get_max_bit_rate(rm_parser* pParser);
+ UINT32 rm_parser_get_avg_bit_rate(rm_parser* pParser);
+ UINT32 rm_parser_get_max_packet_size(rm_parser* pParser);
+ UINT32 rm_parser_get_avg_packet_size(rm_parser* pParser);
+ UINT32 rm_parser_get_num_packets(rm_parser* pParser);
+ UINT32 rm_parser_get_duration(rm_parser* pParser);
+ UINT32 rm_parser_get_preroll(rm_parser* pParser);
+ const char* rm_parser_get_title(rm_parser* pParser);
+ const char* rm_parser_get_author(rm_parser* pParser);
+ const char* rm_parser_get_copyright(rm_parser* pParser);
+ const char* rm_parser_get_comment(rm_parser* pParser);
+ UINT32 rm_parser_get_num_streams(rm_parser* pParser);
+ UINT32 rm_parser_get_stream_number(rm_parser* pParser, UINT32 ulStreamNum);
+
+ /*
+ * General file property accessors
+ *
+ * The most commonly-used properties of an .rm file
+ * can be obtained with the rm_parser_get_xxx accessors above.
+ * Alternatively, all of the file-level properties may
+ * be obtained as an array of rm_property structs. This
+ * array will include all of the common-used properties
+ * above as well as any other properties that may be
+ * present in the file.
+ */
+ HX_RESULT rm_parser_get_file_properties(rm_parser* pParser,
+ rm_property** ppProp,
+ UINT32* pulNumProps);
+
+ /*
+ * This function destroys an array of properties created
+ * by either rm_parser_get_file_properties or
+ * by rm_parser_get_stream_properties.
+ */
+ void rm_parser_destroy_properties(rm_parser* pParser,
+ rm_property** ppProp,
+ UINT32* pulNumProps);
+
+ /*
+ * rm_parser_get_stream_header
+ *
+ * This retrieves a stream header from the file. The number
+ * of stream headers in the file can be found by calling
+ * rm_get_num_streams(). Stream header properties may
+ * be obtained by using the accessor functions found
+ * in rm_stream.h. These accessors cover the most
+ * commonly used properties. The entire set of properties
+ * may be retrieved using rm_parser_get_stream_properties().
+ */
+ HX_RESULT rm_parser_get_stream_header(rm_parser* pParser,
+ UINT32 ulStreamNum,
+ rm_stream_header** ppHdr);
+
+ /*
+ * rm_parser_destroy_stream_header
+ *
+ * This function frees any memory associated with
+ * a stream header obtained by calling rm_parser_get_stream_header().
+ */
+ void rm_parser_destroy_stream_header(rm_parser* pParser,
+ rm_stream_header** ppHdr);
+
+ /*
+ * rm_parser_get_packet
+ *
+ * After the headers had been read, the user can repeatedly
+ * call this function to retrieve packets from the .rm file.
+ */
+ HX_RESULT rm_parser_get_packet(rm_parser* pParser,
+ rm_packet** ppPacket);
+
+ /*
+ * rm_parser_destroy_packet
+ *
+ * This is called to clean up packets created by
+ * calls to rm_parser_get_packet().
+ */
+ void rm_parser_destroy_packet(rm_parser* pParser,
+ rm_packet** ppPacket);
+
+ /*
+ * rm_parser_seek
+ *
+ * The user can call this function to seek to a
+ * certain time in the .rm file
+ */
+ HX_RESULT rm_parser_seek(rm_parser* pParser,
+ UINT32 ulTime);
+
+ /*
+ * rm_parser_seek
+ *
+ * The user can call this function to seek to a
+ * certain offset in the .rm file
+ */
+ void rm_parser_file_seek(rm_parser* pParser, UINT32 ulOffset);
+
+ /*
+ * rm_parser_skip
+ *
+ * The user can call this function to skip to a
+ * certain offset from current position
+ */
+ void rm_parser_file_skip(rm_parser* pParser, UINT32 ulOffset);
+
+ /*
+ * rm_parser_build_seek_table
+ *
+ * The user can call this function to build a seek table
+ * by index in the .rm file
+ */
+ HX_RESULT rm_parser_build_seek_table(rm_parser* pParser);
+
+ /*
+ * rm_parser_seek_in_seek_table
+ *
+ * The user can call this function to seek in the seek table
+ * to find a certain time in the .rm file
+ */
+ HX_RESULT rm_parser_seek_in_seek_table(rm_parser* pParser, INT32 lStreamNumber, UINT32 ulSeekTime, INT32 lDirection, UINT32* pulFoundTime, UINT32* pulDataOffset, UINT32* pulIndex);
+
+ /*
+ * rm_parser_destroy
+ *
+ * The user calls this to clean up
+ */
+ void rm_parser_destroy(rm_parser** ppParser);
+
+ UINT32 rm_parser_get_data_size(rm_parser* pParser);
+ UINT32 rm_parser_get_data_offset(rm_parser* pParser);
+ UINT32 rm_parser_get_index_offset(rm_parser* pParser);
+ void rm_parser_set_index_offset(rm_parser* pParser, UINT32 offset);
+ void rm_parser_set_stream(rm_parser** ppParser, UINT32 ulStreamNum);
+ void rm_parser_set_stream_size(rm_parser* pParser, UINT32 ulStreamSize);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RM_PARSE_H */
diff --git a/audio_codec/libraac/include/rm_property.h b/audio_codec/libraac/include/rm_property.h
new file mode 100644
index 0000000..f27c557
--- a/dev/null
+++ b/audio_codec/libraac/include/rm_property.h
@@ -0,0 +1,107 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_property.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_PROPERTY_H
+#define RM_PROPERTY_H
+
+#include "helix_types.h"
+
+#define RM_PROPERTY_TYPE_UINT32 0
+#define RM_PROPERTY_TYPE_BUFFER 1
+#define RM_PROPERTY_TYPE_CSTRING 2
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /*
+ * Property struct
+ *
+ * This struct can hold a UINT32 property, a CString
+ * property, or a buffer property. The members
+ * of this struct are as follows:
+ *
+ * pName: NULL-terminated string which holds the name
+ * ulType: This can be either RM_PROPERTY_TYPE_UINT32,
+ * RM_PROPERTY_TYPE_BUFFER, or RM_PROPERTY_TYPE_CSTRING.
+ * pValue and ulValueLen:
+ * 1) For type RM_PROPERTY_TYPE_UINT32, the value is held in
+ * the pValue pointer itself and ulValueLen is 0.
+ * 2) For type RM_PROPERTY_TYPE_BUFFER, the value is held in
+ * the buffer pointed to by pValue and the length of
+ * the buffer is ulValueLen.
+ * 3) For type RM_PROPERTY_TYPE_CSTRING, the value is a
+ * NULL terminated string in pValue. Therefore the pValue
+ * pointer can be re-cast as a (const char*) and the value
+ * string read from it. ulValueLen holds a length that
+ * is AT LEAST strlen((const char*) pValue) + 1. It may
+ * be more than that, so do not rely on ulValueLen being
+ * equal to strlen((const char*) pValue) + 1.
+ */
+
+ typedef struct rm_property_struct {
+ char* pName;
+ UINT32 ulType;
+ BYTE* pValue;
+ UINT32 ulValueLen;
+ } rm_property;
+
+ /*
+ * rm_property Accessor Functions
+ *
+ * Users are strongly encouraged to use these accessor
+ * functions to retrieve information from the
+ * rm_property struct, since the definition of rm_property
+ * may change in the future.
+ *
+ * When retrieving the property name, the user should first
+ * call rm_property_get_name_length() to see that the name
+ * length is greater than 0. After that, the user can get
+ * read-only access to the name by calling rm_property_get_name().
+ */
+ const char* rm_property_get_name(rm_property* prop);
+ UINT32 rm_property_get_type(rm_property* prop);
+ UINT32 rm_property_get_value_uint32(rm_property* prop);
+ const char* rm_property_get_value_cstring(rm_property* prop);
+ UINT32 rm_property_get_value_buffer_length(rm_property* prop);
+ BYTE* rm_property_get_value_buffer(rm_property* prop);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RM_PROPERTY_H */
diff --git a/audio_codec/libraac/include/rm_stream.h b/audio_codec/libraac/include/rm_stream.h
new file mode 100644
index 0000000..4728070
--- a/dev/null
+++ b/audio_codec/libraac/include/rm_stream.h
@@ -0,0 +1,115 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_stream.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_STREAM_H
+#define RM_STREAM_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_property.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /*
+ * Stream header definition.
+ *
+ * Users are strongly encouraged to use the accessor
+ * functions below to retrieve information from the
+ * rm_stream_header struct, since the definition
+ * may change in the future.
+ */
+ typedef struct rm_stream_header_struct {
+ char* pMimeType;
+ char* pStreamName;
+ UINT32 ulStreamNumber;
+ UINT32 ulMaxBitRate;
+ UINT32 ulAvgBitRate;
+ UINT32 ulMaxPacketSize;
+ UINT32 ulAvgPacketSize;
+ UINT32 ulDuration;
+ UINT32 ulPreroll;
+ UINT32 ulStartTime;
+ UINT32 ulStartOffset;
+ UINT32 ulStreamSize;
+ UINT32 ulOpaqueDataLen;
+ BYTE* pOpaqueData;
+ UINT32 ulNumProperties;
+ rm_property* pProperty;
+ } rm_stream_header;
+
+ /*
+ * These are the accessor functions used to retrieve
+ * information from the stream header
+ */
+ UINT32 rm_stream_get_number(rm_stream_header* hdr);
+ UINT32 rm_stream_get_max_bit_rate(rm_stream_header* hdr);
+ UINT32 rm_stream_get_avg_bit_rate(rm_stream_header* hdr);
+ UINT32 rm_stream_get_max_packet_size(rm_stream_header* hdr);
+ UINT32 rm_stream_get_avg_packet_size(rm_stream_header* hdr);
+ UINT32 rm_stream_get_start_time(rm_stream_header* hdr);
+ UINT32 rm_stream_get_preroll(rm_stream_header* hdr);
+ UINT32 rm_stream_get_duration(rm_stream_header* hdr);
+ UINT32 rm_stream_get_data_offset(rm_stream_header* hdr);
+ UINT32 rm_stream_get_data_size(rm_stream_header* hdr);
+ const char* rm_stream_get_name(rm_stream_header* hdr);
+ const char* rm_stream_get_mime_type(rm_stream_header* hdr);
+ UINT32 rm_stream_get_properties(rm_stream_header* hdr, rm_property** ppProp);
+ HXBOOL rm_stream_is_realaudio(rm_stream_header* hdr);
+ HXBOOL rm_stream_is_realvideo(rm_stream_header* hdr);
+ HXBOOL rm_stream_is_realevent(rm_stream_header* hdr);
+ HXBOOL rm_stream_is_realaudio_mimetype(const char* pszStr);
+ HXBOOL rm_stream_is_realvideo_mimetype(const char* pszStr);
+ HXBOOL rm_stream_is_realevent_mimetype(const char* pszStr);
+ HXBOOL rm_stream_is_real_mimetype(const char* pszStr);
+ HX_RESULT rm_stream_get_property_int(rm_stream_header* hdr,
+ const char* pszStr,
+ UINT32* pulVal);
+ HX_RESULT rm_stream_get_property_buf(rm_stream_header* hdr,
+ const char* pszStr,
+ BYTE** ppBuf,
+ UINT32* pulLen);
+ HX_RESULT rm_stream_get_property_str(rm_stream_header* hdr,
+ const char* pszStr,
+ char** ppszStr);
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RM_STREAM_H */
diff --git a/audio_codec/libraac/include/rm_stream_internal.h b/audio_codec/libraac/include/rm_stream_internal.h
new file mode 100644
index 0000000..52c26aa
--- a/dev/null
+++ b/audio_codec/libraac/include/rm_stream_internal.h
@@ -0,0 +1,77 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_stream_internal.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_STREAM_INTERNAL_H
+#define RM_STREAM_INTERNAL_H
+
+#include "helix_types.h"
+#include "rm_property.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /*
+ * Internal stream header struct
+ *
+ * The public definition of rm_stream_header
+ * is void - opaque to the user. Properties of the
+ * stream header are accessed via accessor functions
+ * by the user.
+ */
+ typedef struct rm_stream_header_internal_struct {
+ char* pMimeType;
+ char* pStreamName;
+ UINT32 ulStreamNumber;
+ UINT32 ulMaxBitRate;
+ UINT32 ulAvgBitRate;
+ UINT32 ulMaxPacketSize;
+ UINT32 ulAvgPacketSize;
+ UINT32 ulDuration;
+ UINT32 ulPreroll;
+ UINT32 ulStartTime;
+ UINT32 ulOpaqueDataLen;
+ BYTE* pOpaqueData;
+ UINT32 ulNumProperties;
+ rm_property* pProperty;
+ } rm_stream_header_internal;
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RM_STREAM_INTERNAL_H */
diff --git a/audio_codec/libraac/include/rv20backend.h b/audio_codec/libraac/include/rv20backend.h
new file mode 100644
index 0000000..34afdef
--- a/dev/null
+++ b/audio_codec/libraac/include/rv20backend.h
@@ -0,0 +1,69 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv20backend.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV20BACKEND_H__
+#define RV20BACKEND_H__
+
+#include "helix_types.h"
+#include "helix_result.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ //HX_RESULT _RV20toYUV420CustomMessage(UINT32 *msg_id, void *global);
+ HX_RESULT _RV20toYUV420CustomMessage(void *msg_id, void *global);
+
+ HX_RESULT _RV20toYUV420HiveMessage(UINT32 *msg_id, void *global);
+
+ HX_RESULT _RV20toYUV420Transform(
+ UCHAR *pRV10Packets,
+ UCHAR *pDecodedFrameBuffer,
+ void *pInputParams,
+ void *pOutputParams,
+ void *global
+ );
+
+ HX_RESULT _RV20toYUV420Free(void *global);
+
+ HX_RESULT _RV20toYUV420Init(void *prv10Init, void **decoderState);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RV20BACKEND_H__ */
diff --git a/audio_codec/libraac/include/rv30backend.h b/audio_codec/libraac/include/rv30backend.h
new file mode 100644
index 0000000..a882ba0
--- a/dev/null
+++ b/audio_codec/libraac/include/rv30backend.h
@@ -0,0 +1,68 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv30backend.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV30BACKEND_H__
+#define RV30BACKEND_H__
+
+#include "helix_types.h"
+#include "helix_result.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ HX_RESULT _RV40toYUV420CustomMessage(UINT32 *msg_id, void *global);
+
+ HX_RESULT _RV40toYUV420HiveMessage(UINT32 *msg_id, void *global);
+
+ HX_RESULT _RV40toYUV420Transform(
+ UCHAR *pRV20Packets,
+ UCHAR *pDecodedFrameBuffer,
+ void *pInputParams,
+ void *pOutputParams,
+ void *global
+ );
+
+ HX_RESULT _RV40toYUV420Free(void *global);
+
+ HX_RESULT _RV40toYUV420Init(void *prv10Init, void **decoderState);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RV30BACKEND_H__ */
diff --git a/audio_codec/libraac/include/rv_backend.h b/audio_codec/libraac/include/rv_backend.h
new file mode 100644
index 0000000..992306a
--- a/dev/null
+++ b/audio_codec/libraac/include/rv_backend.h
@@ -0,0 +1,84 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_backend.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV_BACKEND_H__
+#define RV_BACKEND_H__
+
+/* Unified RealVideo decoder backend interface */
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rv_format_info.h"
+#include "rv_backend_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* rv decoder backend interface */
+
+ typedef HX_RESULT(*rv_backend_init_fp)(void *prv10Init,
+ void **global);
+ typedef HX_RESULT(*rv_backend_decode_fp)(UCHAR *pRV10Packets,
+ UCHAR *pDecodedFrameBuffer,
+ void *pInputParams,
+ void *pOutputParams,
+ void *global);
+ typedef HX_RESULT(*rv_backend_custom_message_fp)(UINT32 *msg_id,
+ void *global);
+ typedef HX_RESULT(*rv_backend_hive_message_fp)(UINT32 *msg,
+ void *global);
+ typedef HX_RESULT(*rv_backend_free_fp)(void* global);
+
+
+ /* The rv_backend struct contains the RealVideo decoder backend
+ * function pointers. */
+
+ typedef struct rv_backend_struct {
+ rv_backend_init_fp fpInit;
+ rv_backend_decode_fp fpDecode;
+ rv_backend_custom_message_fp fpCustomMessage;
+ rv_backend_hive_message_fp fpHiveMessage;
+ rv_backend_free_fp fpFree;
+ } rv_backend;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RV_BACKEND_H__ */
diff --git a/audio_codec/libraac/include/rv_backend_types.h b/audio_codec/libraac/include/rv_backend_types.h
new file mode 100644
index 0000000..0655d15
--- a/dev/null
+++ b/audio_codec/libraac/include/rv_backend_types.h
@@ -0,0 +1,198 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_backend_types.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV_BACKEND_TYPES_H
+#define RV_BACKEND_TYPES_H
+
+#include "rv_format_info.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ typedef struct rv_backend_init_params_struct {
+ UINT16 usOuttype;
+ UINT16 usPels;
+ UINT16 usLines;
+ UINT16 usPadWidth; /* number of columns of padding on right to get 16 x 16 block*/
+ UINT16 usPadHeight; /* number of rows of padding on bottom to get 16 x 16 block*/
+
+ UINT16 pad_to_32; /* to keep struct member alignment independent of */
+ /* compiler options */
+ UINT32 ulInvariants;
+ /* ulInvariants specifies the invariant picture header bits */
+ INT32 bPacketization;
+ UINT32 ulStreamVersion;
+ } rv_backend_init_params;
+
+ typedef struct rv_backend_in_params_struct {
+ UINT32 dataLength;
+ INT32 bInterpolateImage;
+ UINT32 numDataSegments;
+ rv_segment *pDataSegments;
+ UINT32 flags;
+ /* 'flags' should be initialized by the front-end before each */
+ /* invocation to decompress a frame. It is not updated by the decoder. */
+ /* */
+ /* If it contains RV_DECODE_MORE_FRAMES, it informs the decoder */
+ /* that it is being called to extract the second or subsequent */
+ /* frame that the decoder is emitting for a given input frame. */
+ /* The front-end should set this only in response to seeing */
+ /* an RV_DECODE_MORE_FRAMES indication in H263DecoderOutParams. */
+ /* */
+ /* If it contains RV_DECODE_DONT_DRAW, it informs the decoder */
+ /* that it should decode the image (in order to produce a valid */
+ /* reference frame for subsequent decoding), but that no image */
+ /* should be returned. This provides a "hurry-up" mechanism. */
+ UINT32 timestamp;
+ } rv_backend_in_params;
+
+ typedef struct rv_backend_out_params_struct {
+ UINT32 numFrames;
+ UINT32 notes;
+ /* 'notes' is assigned by the transform function during each call to */
+ /* decompress a frame. If upon return the notes parameter contains */
+ /* the indication RV_DECODE_MORE_FRAMES, then the front-end */
+ /* should invoke the decoder again to decompress the same image. */
+ /* For this additional invocation, the front-end should first set */
+ /* the RV_DECODE_MORE_FRAMES bit in the 'H263DecoderInParams.flags' */
+ /* member, to indicate to the decoder that it is being invoked to */
+ /* extract the next frame. */
+ /* The front-end should continue invoking the decoder until the */
+ /* RV_DECODE_MORE_FRAMES bit is not set in the 'notes' member. */
+ /* For each invocation to decompress a frame in the same "MORE_FRAMES" */
+ /* loop, the front-end should send in the same input image. */
+ /* */
+ /* If the decoder has no frames to return for display, 'numFrames' will */
+ /* be set to zero. To avoid redundancy, the decoder does *not* set */
+ /* the RV_DECODE_DONT_DRAW bit in 'notes' in this case. */
+
+
+ UINT32 timestamp;
+ /* The 'temporal_offset' parameter is used in conjunction with the */
+ /* RV_DECODE_MORE_FRAMES note, to assist the front-end in */
+ /* determining when to display each returned frame. */
+ /* If the decoder sets this to T upon return, the front-end should */
+ /* attempt to display the returned image T milliseconds relative to */
+ /* the front-end's idea of the presentation time corresponding to */
+ /* the input image. */
+ /* Be aware that this is a signed value, and will typically be */
+ /* negative. */
+
+ UINT32 width;
+ UINT32 height;
+ /* Width and height of the returned frame. */
+ /* This is the width and the height as signalled in the bitstream. */
+
+ } rv_backend_out_params;
+
+
+ /* definitions for output parameter notes */
+
+#define RV_DECODE_MORE_FRAMES 0x00000001
+#define RV_DECODE_DONT_DRAW 0x00000002
+#define RV_DECODE_KEY_FRAME 0x00000004
+ /* Indicates that the decompressed image is a key frame. */
+ /* Note that enhancement layer EI frames are not key frames, in the */
+ /* traditional sense, because they have dependencies on lower layer */
+ /* frames. */
+
+#define RV_DECODE_B_FRAME 0x00000008
+ /* Indicates that the decompressed image is a B frame. */
+ /* At most one of PIA_DDN_KEY_FRAME and PIA_DDN_B_FRAME will be set. */
+
+#define RV_DECODE_DEBLOCKING_FILTER 0x00000010
+ /* Indicates that the returned frame has gone through the */
+ /* deblocking filter. */
+
+#define RV_DECODE_FRU_FRAME 0x00000020
+ /* Indicates that the decompressed image is a B frame. */
+ /* At most one of PIA_DDN_KEY_FRAME and PIA_DDN_B_FRAME will be set. */
+
+#define RV_DECODE_SCRAMBLED_BUFFER 0x00000040
+ /* Indicates that the input buffer is scrambled for security */
+ /* decoder should de-scramble the buffer before use it */
+
+#define RV_DECODE_LAST_FRAME 0x00000200
+ /* Indicates that the accompanying input frame is the last in the */
+ /* current sequence. If input frame is a dummy frame, the decoder */
+ /* flushes the latency frame to the output. */
+
+ /* definitions for decoding opaque data in bitstream header */
+ /* Defines match ilvcmsg.h so that ulSPOExtra == rv10init.invariants */
+#define RV40_SPO_FLAG_UNRESTRICTEDMV 0x00000001 /* ANNEX D */
+#define RV40_SPO_FLAG_EXTENDMVRANGE 0x00000002 /* IMPLIES NEW VLC TABLES */
+#define RV40_SPO_FLAG_ADVMOTIONPRED 0x00000004 /* ANNEX F */
+#define RV40_SPO_FLAG_ADVINTRA 0x00000008 /* ANNEX I */
+#define RV40_SPO_FLAG_INLOOPDEBLOCK 0x00000010 /* ANNEX J */
+#define RV40_SPO_FLAG_SLICEMODE 0x00000020 /* ANNEX K */
+#define RV40_SPO_FLAG_SLICESHAPE 0x00000040 /* 0: free running; 1: rect */
+#define RV40_SPO_FLAG_SLICEORDER 0x00000080 /* 0: sequential; 1: arbitrary */
+#define RV40_SPO_FLAG_REFPICTSELECTION 0x00000100 /* ANNEX N */
+#define RV40_SPO_FLAG_INDEPENDSEGMENT 0x00000200 /* ANNEX R */
+#define RV40_SPO_FLAG_ALTVLCTAB 0x00000400 /* ANNEX S */
+#define RV40_SPO_FLAG_MODCHROMAQUANT 0x00000800 /* ANNEX T */
+#define RV40_SPO_FLAG_BFRAMES 0x00001000 /* SETS DECODE PHASE */
+#define RV40_SPO_BITS_DEBLOCK_STRENGTH 0x0000e000 /* deblocking strength */
+#define RV40_SPO_BITS_NUMRESAMPLE_IMAGES 0x00070000 /* max of 8 RPR images sizes */
+#define RV40_SPO_FLAG_FRUFLAG 0x00080000 /* FRU BOOL: if 1 then OFF; */
+#define RV40_SPO_FLAG_FLIP_FLIP_INTL 0x00100000 /* FLIP-FLOP interlacing; */
+#define RV40_SPO_FLAG_INTERLACE 0x00200000 /* de-interlacing prefilter has been applied; */
+#define RV40_SPO_FLAG_MULTIPASS 0x00400000 /* encoded with multipass; */
+#define RV40_SPO_FLAG_INV_TELECINE 0x00800000 /* inverse-telecine prefilter has been applied; */
+#define RV40_SPO_FLAG_VBR_ENCODE 0x01000000 /* encoded using VBR; */
+#define RV40_SPO_BITS_DEBLOCK_SHIFT 13
+#define RV40_SPO_BITS_NUMRESAMPLE_IMAGES_SHIFT 16
+
+#define OUT_OF_DATE_DECODER 0x00000001
+#define OK_VERSION 0x00000000
+
+#define CORRUPTED_BITSTREAM 0x00
+#define OK_DECODE 0x0f
+#define INCOMPLETE_FRAME 0xffff
+#define MALLOC_FAILURE 0x1111
+
+#define RV10_DITHER_PARAMS 0x00001001
+#define RV10_POSTFILTER_PARAMS 0x00001002
+#define RV10_ADVANCED_MP_PARAMS 0x0001003
+#define RV10_TEMPORALINTERP_PARAMS 0x00001004
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* RV_BACKEND_TYPES_H */
diff --git a/audio_codec/libraac/include/rv_decode.h b/audio_codec/libraac/include/rv_decode.h
new file mode 100644
index 0000000..6d9c0d9
--- a/dev/null
+++ b/audio_codec/libraac/include/rv_decode.h
@@ -0,0 +1,208 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_decode.h,v 1.1.1.1.2.2 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV_DECODE_H__
+#define RV_DECODE_H__
+
+/* Simple unified decoder frontend for RealVideo */
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+#include "rm_error.h"
+#include "rv_format_info.h"
+#include "rv_decode_message.h"
+#include "rv_backend.h"
+#include "rv_backend_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* The rv_decode struct contains the RealVideo decoder frontend
+ * state variables and backend instance pointer. */
+
+ typedef struct rv_decode_struct {
+ rm_error_func_ptr fpError;
+ /* User defined error function. */
+
+ void* pUserError;
+ /* User defined parameter for error function. */
+
+ rm_malloc_func_ptr fpMalloc;
+ /* User defined malloc function. */
+
+ rm_free_func_ptr fpFree;
+ /* User defined free function. */
+
+ void* pUserMem;
+ /* User defined parameter for malloc and free functions. */
+
+ UINT32 ulSPOExtra;
+ /* The SPO Extra bits. Opaque data appended to bitstream header. */
+
+ UINT32 ulStreamVersion;
+ /* The stream version. Opaque data following the SPO Extra bits. */
+
+ UINT32 ulMajorBitstreamVersion;
+ /* The major bitstream version. Indicates RV7, RV8, RV9, etc. */
+
+ UINT32 ulMinorBitstreamVersion;
+ /* The minor bitstream version. Indicates minor revision or RAW. */
+
+ UINT32 ulNumResampledImageSizes;
+ /* The number of RPR sizes. Optional RV7 and RV8 opaque data. */
+
+ UINT32 ulEncodeSize;
+ /* The maximum encoded frame dimensions. Optional RV9 opaque data.*/
+
+ UINT32 ulLargestPels;
+ /* The maximum encoded frame width. */
+
+ UINT32 ulLargestLines;
+ /* The maximum encoded frame height. */
+
+ UINT32 pDimensions[2 * (8 + 1)];
+ /* Table of encoded dimensions, including RPR sizes. */
+
+ UINT32 ulOutSize;
+ /* The maximum size of the output frame in bytes. */
+
+ UINT32 ulECCMask;
+ /* Mask for identifying ECC packets. */
+
+ UINT32 bInputFrameIsReference;
+ /* Identifies whether input frame is a key frame or not. */
+
+ UINT32 ulInputFrameQuant;
+ /* The input frame quantization parameter. */
+
+ rv_format_info *pBitstreamHeader;
+ /* The bitstream header. */
+
+ rv_frame *pInputFrame;
+ /* Pointer to the input frame struct. */
+
+ void *pDecodeState;
+ /* Pointer to decoder backend state. */
+
+ rv_backend *pDecode;
+ /* Decoder backend function pointers. */
+
+ rv_backend_init_params pInitParams;
+ /* Initialization parameters for the decoder backend. */
+
+ rv_backend_in_params pInputParams;
+ /* The decoder backend input parameter struct. */
+
+ rv_backend_out_params pOutputParams;
+ /* The decoder backend output parameter struct. */
+
+ } rv_decode;
+
+ /* rv_decode_create()
+ * Creates RV decoder frontend struct, copies memory utilities.
+ * Returns struct pointer on success, NULL on failure. */
+ rv_decode* rv_decode_create(void* pUserError, rm_error_func_ptr fpError);
+
+ rv_decode* rv_decode_create2(void* pUserError, rm_error_func_ptr fpError,
+ void* pUserMem, rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+
+ /* rv_decode_destroy()
+ * Deletes decoder backend instance, followed by frontend. */
+ void rv_decode_destroy(rv_decode* pFrontEnd);
+
+ /* rv_decode_init()
+ * Reads bitstream header, selects and initializes decoder backend.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT rv_decode_init(rv_decode* pFrontEnd, rv_format_info* pHeader);
+
+ /* rv_decode_stream_input()
+ * Reads frame header and fills decoder input parameters struct. If there
+ * is packet loss and ECC packets exist, error correction is attempted.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT rv_decode_stream_input(rv_decode* pFrontEnd, rv_frame* pFrame);
+
+ /* rv_decode_stream_decode()
+ * Calls decoder backend to decode issued frame and produce an output frame.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT rv_decode_stream_decode(rv_decode* pFrontEnd, UINT8* pOutput);
+
+ /* rv_decode_stream_flush()
+ * Flushes the latency frame from the decoder backend after the last frame
+ * is delivered and decoded before a pause or the end-of-file.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT rv_decode_stream_flush(rv_decode* pFrontEnd, UINT8* pOutput);
+
+ /* rv_decode_custom_message()
+ * Sends a custom message to the decoder backend.
+ * Returns zero on success, negative result indicates failure. */
+ HX_RESULT rv_decode_custom_message(rv_decode* pFrontEnd, RV_Custom_Message_ID *pMsg_id);
+
+
+ /**************** Accessor Functions *******************/
+ /* rv_decode_max_output_size()
+ * Returns maximum size of YUV 4:2:0 output buffer in bytes. */
+ UINT32 rv_decode_max_output_size(rv_decode* pFrontEnd);
+
+ /* rv_decode_get_output_size()
+ * Returns size of most recent YUV 4:2:0 output buffer in bytes. */
+ UINT32 rv_decode_get_output_size(rv_decode* pFrontEnd);
+
+ /* rv_decode_get_output_dimensions()
+ * Returns width and height of most recent YUV output buffer. */
+ HX_RESULT rv_decode_get_output_dimensions(rv_decode* pFrontEnd, UINT32* pWidth,
+ UINT32* pHeight);
+
+ /* rv_decode_frame_valid()
+ * Checks decoder output parameters to see there is a valid output frame.
+ * Returns non-zero value if a valid output frame exists, else zero. */
+ UINT32 rv_decode_frame_valid(rv_decode* pFrontEnd);
+
+ /* rv_decode_more_frames()
+ * Checks decoder output parameters to see if more output frames can be
+ * produced without additional input frames.
+ * Returns non-zero value if more frames can be
+ * produced without additional input, else zero. */
+ UINT32 rv_decode_more_frames(rv_decode* pFrontEnd);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RV_DECODE_H__ */
diff --git a/audio_codec/libraac/include/rv_decode_message.h b/audio_codec/libraac/include/rv_decode_message.h
new file mode 100644
index 0000000..63d5e6e
--- a/dev/null
+++ b/audio_codec/libraac/include/rv_decode_message.h
@@ -0,0 +1,492 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_decode_message.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV_DECODE_MESSAGE_H
+#define RV_DECODE_MESSAGE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* Define CPU scalability constants. Though these values range from */
+ /* 0 to 100, they are *not* intended to indicate a CPU utilization percentage. */
+
+#define CPU_Scalability_Maximum 100
+ /* Maximum value for CPU usage setting: */
+ /* no shortcuts taken, best possible quality at the cost of higher */
+ /* CPU usage. This value is typically used for "off-line" compression. */
+
+#define CPU_Scalability_Minimum 0
+ /* Minimum value for CPU usage setting: */
+ /* all implemented shortcuts taken, reduced CPU usage at the cost */
+ /* of reduced video quality. */
+
+#define CPU_Scalability_Default 50
+ /* Default value for CPU usage setting: */
+ /* this represents the normal mode of operation and is equivalent */
+ /* to previously not choosing a CPU usage setting. */
+
+#define RV89COMBO_MSG_ID_Decoder_CPU_Scalability 2002
+ /* Allows for the setting and getting of the decoders CPU scalability parameter */
+
+ /* */
+ /* Define formats for representing custom codec messages. */
+ /* Custom codec messages have semantics unknown to the HIVE/RV layer. */
+ /* The messages are defined by the underlying codec, and typically documented */
+ /* for use by applications. */
+ /* */
+
+ /* RV_Custom_Message_ID identifies a specific custom message. These */
+ /* identifiers are not guaranteed to be unique among different codecs. */
+ /* Thus an application using such messages, must have knowledge regarding */
+ /* which codec is being used, and what custom messages it supports. */
+ /* A codec will typically distribute a header file that defines its */
+ /* custom messages. */
+ /* */
+ /* Specific custom messages will be passed into a codec via a structure whose */
+ /* first member is a RV_Custom_Message_ID, and additional parameters */
+ /* understood by the application and the codec. The size of each such */
+ /* custom message structure is variable, depending on the specific message id. */
+ /* Messages that require no values other than a message id, can be indicated */
+ /* by using the RV_Custom_Message_ID as is. For such messages, there is no */
+ /* need to wrap the message id within another structure. */
+
+ typedef UINT32 RV_Custom_Message_ID;
+
+ /* RV_MSG_Simple is a structure used to pass custom messages which */
+ /* take one or two 32-bit values. The "message_id" member identifies a */
+ /* particular message, and the "value1" and "value2" members specify the */
+ /* 32-bit values. The interpretation of the values depends on the message id. */
+ /* They could be simple booleans (zero or non-zero), or arbitrary integers. */
+ /* Some messages will use only value1, and not value2. */
+
+ typedef struct {
+
+ RV_Custom_Message_ID message_id;
+
+ INT32 value1;
+ INT32 value2;
+
+ } RV_MSG_Simple;
+
+
+ /* The RV_MSG_DISABLE, RV_MSG_ENABLE and RV_MSG_GET values may be used as */
+ /* controls when manipulating boolean-valued custom messages. Typically, */
+ /* such messages will employ the RV_MSG_Simple structure. The message_id */
+ /* will identify a boolean-valued option being manipulated. The "value1" */
+ /* member will be set to one of RV_MSG_DISABLE, RV_MSG_ENABLE or RV_MSG_GET. */
+ /* Depending on the message id, "value2" may specify additional information */
+ /* such as a layer number for scalable video sequences. */
+ /* */
+ /* When value1 is RV_MSG_DISABLE or RV_MSG_ENABLE, the specified option */
+ /* will be disabled or enabled, respectively. */
+ /* When value1 is RV_MSG_GET, the current setting for the option (zero for */
+ /* disabled and non-zero for enabled) will be returned in "value2". */
+
+#define RV_MSG_DISABLE 0
+#define RV_MSG_ENABLE 1
+#define RV_MSG_GET 2
+
+ /* The RV_MSG_SET control, along with RV_MSG_GET, provide an alternative */
+ /* way in which custom messages might use the RV_MSG_Simple structure. */
+ /* When value1 is RV_MSG_SET, value2 indicates the value which is being */
+ /* applied. The message_id provides the context to which value2 applies. */
+ /* Again, refer to the documentation describing each custom message to see */
+ /* if it uses RV_MSG_GET and RV_MSG_SET, or if it uses RV_MSG_DISABLE, */
+ /* RV_MSG_ENABLE and RV_MSG_GET. */
+
+#define RV_MSG_SET 3
+
+
+
+
+
+ /* Decoder postfilters: */
+ /* - the smoothing postfilter is designed to remove general compression */
+ /* artifacts, mosquito noise, and ringing noise. */
+ /* - the annex J deblocking filter when used as a postfilter (annex J */
+ /* not encoded in bitstream), removes blocking artifacts (block */
+ /* edges) almost as efficiently as when used in-the-loop, i.e. encoded */
+ /* in bitstream. */
+ /* For the most video quality improvement, both filters should be used. */
+ /* However, each filter takes up a certain amount of CPU cycles, and */
+ /* for large formats, it may be too computationally expensive to use */
+ /* both. */
+ /* These filters are more effective, the lower the bitrate. */
+
+ /* */
+ /* Define a custom decoder message for enabling the smoothing postfilter. */
+ /* */
+ /* This message must be sent with the RV_MSG_Simple structure. */
+ /* Its value1 member should be RV_MSG_DISABLE, RV_MSG_ENABLE or RV_MSG_GET. */
+ /* Its value2 is only used for RV_MSG_GET, in which case it is used to */
+ /* return the current setting. */
+ /* */
+#define RV_MSG_ID_Smoothing_Postfilter 17
+
+ /* Define a decoder message that helps the decoder determine when to display */
+ /* frames. */
+ /* */
+ /* The SNR, spatial and temporal scalability features of H.263+ Annex O */
+ /* have the property that frames are received at the decoder out of order, */
+ /* or that multiple frames (enhancement layers) are received at the decoder */
+ /* yet only one of these frames should be displayed. */
+ /* */
+ /* In the absence of apriori knowledge regarding the video sequence it is */
+ /* going to receive, an H.263+ decoder might not know when it is okay to */
+ /* go ahead and display a picture it has just decoded. */
+ /* */
+ /* To help solve this problem, the ILVC decoder can operate in two modes. */
+ /* The first and default mode is termed "no latency". In this scenario, */
+ /* the decoder assumes it will not be receiving B frames nor enhancement */
+ /* layers. The decoder will decode and display the very first frame it sees. */
+ /* If the decoder encounters any B frames or enhancement layers, it then */
+ /* goes into latency mode (described below). When B frames or enhancement */
+ /* layers are present under latency mode, some of these frame types will */
+ /* not be displayed by the decoder at the beginning of a video sequence. */
+ /* This is because the decoder either already displayed a frame for the */
+ /* same temporal reference point, or because the decoder no longer has */
+ /* the appropriate reference frames from which to decode a B frame. */
+ /* */
+ /* Under latency mode, the decoder will generally not display a decoded frame, */
+ /* until it has detected that no enhancement layer frames or dependent */
+ /* B frames will be coming. This detection usually occurs when a subsequent */
+ /* non-B frame is encountered. This mode has the advantage that no frames */
+ /* will be dropped at the beginning of a sequence. The disadvantage is that */
+ /* a latency of one or more temporal references is introduced before a frame */
+ /* is displayed. */
+ /* */
+ /* This message must be sent with the RV_MSG_Simple structure. */
+ /* Its value1 member should be RV_MSG_DISABLE, RV_MSG_ENABLE or RV_MSG_GET. */
+ /* For RV_MSG_GET, the current setting is returned in value2. */
+
+#define RV_MSG_ID_Latency_Display_Mode 21
+
+
+
+ /* */
+ /* Define a custom decoder message that enables/disables the error */
+ /* concealment in the decoder. */
+ /* */
+ /* This message must be sent with the RV_MSG_Simple structure. */
+ /* Its value1 member should be RV_MSG_DISABLE, RV_MSG_ENABLE or RV_MSG_GET. */
+ /* Its value2 is only used for RV_MSG_GET, in which case it is used to */
+ /* return the current setting. */
+ /* */
+#define RV_MSG_ID_Error_Concealment 23
+
+
+ /* #define RV_MSG_ID_* = 24; */
+ /* // Obsolete, do not use 24. */
+ /* #define RV_MSG_ID_* = 25; */
+ /* // Obsolete, do not use 25. */
+
+ /* */
+ /* Define a custom decoder message to be used when decoding a non-compliant */
+ /* H.263+ bitstream, that informs the decoder about information which is */
+ /* normally gleaned from parsing the picture header. In this scenario, the */
+ /* encoder is generating a bitstream having a lean and mean picture header. */
+ /* The invariant picture header contents are sent over the wire only once, */
+ /* prior to streaming any bitstreams. */
+ /* */
+#define RV_MSG_ID_Set_Picture_Header_Invariants 26
+ /* */
+ /* This message must be sent with the RV_MSG_Simple structure. */
+ /* Its value1 member is interpreted as a bit mask, described below. */
+ /* Its value2 member is not used. */
+ /* */
+ /* The following bits should be set or cleared, as appropriate, to indicate */
+ /* which codec options will be enabled or disabled for the video sequence. */
+ /* If any of these change, then the changes should be communicated to the */
+ /* decoder via this custom message prior to it seeing any input frames */
+ /* having the new state. */
+ /* */
+
+
+#define RV_MSG_SPHI_Slice_Structured_Mode 0x20
+
+
+ /* */
+ /* Define messages that are used with the RealVideo bitstream, */
+ /* to communicate the locations of slice boundaries between the front-end */
+ /* codec and the back-end encoder or decoder. */
+ /* */
+
+ typedef struct {
+ UINT32 is_valid;
+ UINT32 offset;
+ } RV_Segment_Info;
+ /* The RV_Segment_Info structure *MUST* be structurally equivalent */
+ /* to the PNCODEC_SEGMENTINFO structure defined in the RealVideo */
+ /* front-end. Typically an array of these structures is allocated, */
+ /* with each element describing one slice in a compressed bit stream. */
+ /* For the output of an encoder, is_valid is always true. 'offset' */
+ /* indicates the offset of a slice within an associated bitstream. */
+ /* The first slice is at offset 0. */
+
+ typedef struct {
+ RV_Custom_Message_ID message_id;
+ /* message_id must be RV_MSG_ID_Get_Encode_Segment_Info */
+ /* or RV_MSG_ID_Set_Decode_Segment_Info. */
+
+ UINT32 number_of_segments;
+
+ RV_Segment_Info *segment_info;
+ } RV_Segment_Info_MSG;
+
+
+#define RV_MSG_ID_Set_Decode_Segment_Info 28
+ /* This message, sent with the RV_Segment_Info_MSG structure, is used */
+ /* to specify slice information to the decoder just prior to decoding */
+ /* a bitstream. */
+ /* number_of_segments should be set to one less than the number of */
+ /* slices in the frame about to be decoded. */
+ /* segment_info should point to an array of RV_Segment_Info */
+ /* structures, which point to the slice offsets of the bitstream */
+ /* that will be decoded next. */
+
+
+
+ /* */
+ /* Define a custom decoder message for setting the smoothing postfilter's */
+ /* strength. The strength ranges from 0 to RV_Maximum_Smoothing_Strength, */
+ /* inclusive. */
+ /* */
+ /* This message must be sent with the RV_MSG_Simple structure. */
+ /* Its value1 member should be RV_MSG_SET or RV_MSG_GET. */
+ /* For RV_MSG_SET, value2 should be assigned the desired strength setting. */
+ /* For RV_MSG_GET, value2 is assigned upon return to the current strength */
+ /* setting. */
+ /* */
+#define RV_MSG_ID_Smoothing_Strength 30
+
+#define RV_Maximum_Smoothing_Strength 3
+#define RV_Default_Smoothing_Strength 1
+
+
+
+ /* Define a message to set the number of sizes, as well as the list of sizes */
+ /* that are to be used for RealVideo-style RPR */
+ /* This information is transmitted in the SPO (once). The front-end uses */
+ /* the RV_MSG_ID_Set_RVDecoder_RPR_Data to communicate this information */
+ /* to the back-end. Then, if num_sizes != 0, the back-end will read the */
+ /* following information from the slice header: */
+ /* .. */
+ /* [TR (as before)] */
+ /* if num_sizes != 0 */
+ /* PCTSZ = getbits(log2(num_sizes)) */
+ /* [MBA (as before)] */
+ /* .. */
+
+
+#define RV_MSG_ID_Set_RVDecoder_RPR_Sizes 36
+
+ typedef struct {
+
+ RV_Custom_Message_ID message_id;
+ /* message_id must be RV_MSG_ID_Set_RVDecoder_RPR_Sizes. */
+
+ UINT32 num_sizes;
+ /* The number of sizes to be used (switched between). */
+ /* This number should include the original image size. */
+ /* The maximum number of sizes is currently limited to 8. */
+
+
+ UINT32 *sizes;
+ /* Pointer to array of image sizes. The array should have the */
+ /* following format: */
+ /* for (i = 0; i < num_sizes; i++) { */
+ /* UINT32 horizontal_size[i] */
+ /* UINT32 vertical_size[i] */
+ /* } */
+ /* This array should include the original image size */
+ /* The order of sizes is not important. The decoder will */
+ /* use PCTSZ as an index to look up in the array: */
+ /* new_width = horizontal_size[PCTSZ] */
+ /* new_height = vertical_size[PCTSZ] */
+
+ } RV_MSG_RVDecoder_RPR_Sizes;
+
+
+
+
+ /* Define a custom message to obtain timings for parts of the decode */
+ /* For now, only the smoothing filte is interesting. */
+ /* More could be added later */
+
+#define RV_MSG_ID_Get_Decoder_Timings 42
+ typedef struct {
+
+ RV_Custom_Message_ID message_id;
+
+ double smoothing_time;
+ double fru_time;
+ } RV_MSG_Get_Decoder_Timings;
+
+
+ /* */
+ /* Define a custom message to set the video surface hardware */
+ /* allocator and its properties */
+
+#define RV_MSG_ID_Hw_Video_Memory 43
+ /* */
+ /* This message must be sent with the RV_MSG_Simple structure. */
+ /* Its value1 member should be RV_MSG_DISABLE, RV_MSG_ENABLE or RV_MSG_GET. */
+ /* For RV_MSG_GET, the current number of frame buffers is returned in value2, */
+ /* and RV_MSG_ENABLE or RV_MSG_DISABLE returned in value1 */
+
+
+ /* */
+ /* Define a custom message to perform postfiltering into video */
+ /* memory */
+ /* */
+#define RV_MSG_ID_PostfilterFrame 44
+ typedef struct {
+
+ RV_Custom_Message_ID message_id;
+ UINT8 * data;
+ UINT8 * dest_buffer;
+ UINT32 dest_pitch;
+ INT32 cid_dest_color_format;
+ UINT32 flags;
+ } RV_MSG_PostfilterFrame;
+
+
+
+ /* */
+ /* Define a custom message to release frame from video */
+ /* memory. */
+ /* 'data' is a pointer to a DecodedFrame structure */
+ /* */
+
+#define RV_MSG_ID_ReleaseFrame 45
+ typedef struct {
+
+ RV_Custom_Message_ID message_id;
+ UINT8 * data;
+ } RV_MSG_ReleaseFrame;
+
+
+ /* */
+ /* Define a custom message to retrieve latest DecodedFrame data */
+ /* */
+#define RV_MSG_ID_RetrieveFrame 46
+ typedef struct {
+
+ RV_Custom_Message_ID message_id;
+ void * frame;
+ } RV_MSG_RetrieveFrame;
+
+
+ /* */
+ /* Define a custom message to set the relied callback function */
+ /* that is the function to be called in the renderer in case */
+ /* it needs to blit (flip) a frame */
+ /* */
+
+#define RV_MSG_ID_SetReliefCallback 48
+ typedef struct {
+
+ RV_Custom_Message_ID message_id;
+ void * cmtm;
+ /* pointer to PN_CMTM struct (pncodec.h) */
+ } RV_MSG_SetReliefCallback;
+
+ /* */
+ /* Define a custom message that enables/disables FRU */
+ /* */
+#define RV_MSG_ID_Frame_Rate_Upsampling 49
+
+
+
+ /* */
+ /* Define a custom message to get CPU performance counters from the decoder. */
+ /* */
+#define RV_MSG_ID_Get_Decoder_Performance_Counters 52
+
+ typedef struct {
+ RV_Custom_Message_ID message_id;
+ UINT32 uNumCounters;
+ UINT32 *pCounters;
+ } RV_MSG_Get_Decoder_Performance_Counters;
+
+
+ /* */
+ /* Define a custom message to enable and disable multithreading in the decoder */
+ /* */
+#define RV_MSG_ID_Decoder_Multi_Threading 54
+
+ /* */
+ /* Define a custom message to enable decoding of beta streams with multiple threads */
+ /* */
+#define RV_MSG_ID_Decoder_Beta_Stream 55
+
+ /* */
+ /* Define a custom message to signal RV8 bitstream */
+ /* */
+#define RV_MSG_ID_RealVideo8 56
+
+ /* */
+ /* Define a custom message to retrieve latest DecodedFrame data */
+ /* */
+#define RV_MSG_ID_RetrieveFrameData 57
+ typedef struct {
+
+ RV_Custom_Message_ID message_id;
+ void * m_data;
+ UINT8 * m_pYPlane;
+ UINT8 * m_pUPlane;
+ UINT8 * m_pVPlane;
+ UINT32 m_pitch;
+ UINT32 m_width;
+ UINT32 m_height;
+ } RV_MSG_RetrieveFrameData;
+
+
+
+ /* */
+ /* Note to developers: */
+ /* */
+ /* Next available message ID is 58. */
+ /* But 100 and above might already be in use, in "ccustmsg.h", so be careful. */
+ /* */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RV_DECODE_MESSAGE_H */
diff --git a/audio_codec/libraac/include/rv_depack.h b/audio_codec/libraac/include/rv_depack.h
new file mode 100644
index 0000000..f5a2878
--- a/dev/null
+++ b/audio_codec/libraac/include/rv_depack.h
@@ -0,0 +1,162 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_depack.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV_DEPACK_H
+#define RV_DEPACK_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_error.h"
+#include "rm_memory.h"
+#include "rm_stream.h"
+#include "rm_packet.h"
+#include "rv_format_info.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+ /* Callback functions */
+ typedef HX_RESULT(*rv_frame_avail_func_ptr)(void* pAvail, UINT32 ulSubStreamNum, rv_frame* frame);
+
+ /*
+ * rv_depack definition. Opaque to user.
+ */
+ typedef void rv_depack;
+
+ /*
+ * rv_depack_create
+ */
+ rv_depack* rv_depack_create(void* pAvail,
+ rv_frame_avail_func_ptr fpAvail,
+ void* pUserError,
+ rm_error_func_ptr fpError);
+
+ /*
+ * rv_depack_create2
+ *
+ * This is the same as rv_depack_create(), but it allows
+ * the user to use custom memory allocation and free functions.
+ */
+ rv_depack* rv_depack_create2(void* pAvail,
+ rv_frame_avail_func_ptr fpAvail,
+ void* pUserError,
+ rm_error_func_ptr fpError,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree);
+
+ /*
+ * rv_depack_init
+ *
+ * This is initialized with a RealVideo rm_stream_header struct.
+ */
+ HX_RESULT rv_depack_init(rv_depack* pDepack, rm_stream_header* header);
+
+ /*
+ * rv_depack_get_num_substreams
+ *
+ * This accessor function tells how many video substreams there are
+ * in this video stream. For single-rate video streams, this will be 1. For
+ * SureStream video streams, this could be greater than 1.
+ */
+ UINT32 rv_depack_get_num_substreams(rv_depack* pDepack);
+
+ /*
+ * rv_depack_get_codec_4cc
+ *
+ * This accessor function returns the 4cc of the codec. This 4cc
+ * will be used to determine which codec to use. RealVideo always
+ * uses the same codec for all substreams.
+ */
+ UINT32 rv_depack_get_codec_4cc(rv_depack* pDepack);
+
+ /*
+ * rv_depack_get_codec_init_info
+ *
+ * This function fills in the structure which is used to initialize the codec.
+ */
+ HX_RESULT rv_depack_get_codec_init_info(rv_depack* pDepack, rv_format_info** ppInfo);
+
+ /*
+ * rv_depack_destroy_codec_init_info
+ *
+ * This function frees the memory associated with the rv_format_info object
+ * created by rv_depack_get_codec_init_info().
+ */
+ void rv_depack_destroy_codec_init_info(rv_depack* pDepack, rv_format_info** ppInfo);
+
+ /*
+ * rv_depack_add_packet
+ *
+ * Put a video packet into the depacketizer. When enough data is
+ * present to depacketize, then the user will be called back
+ * on the rv_frame_avail_func_ptr set in rv_depack_create().
+ */
+ HX_RESULT rv_depack_add_packet(rv_depack* pDepack, rm_packet* packet);
+
+ /*
+ * rv_depack_destroy_frame
+ *
+ * This cleans up a frame that was returned via
+ * the rv_frame_avail_func_ptr.
+ */
+ void rv_depack_destroy_frame(rv_depack* pDepack, rv_frame** ppFrame);
+
+ /*
+ * rv_depack_seek
+ *
+ * The user calls this function if the stream is seeked. It
+ * should be called before passing any post-seek packets. After calling
+ * rv_depack_seek(), no more pre-seek packets should be
+ * passed into rv_depack_add_packet().
+ */
+ HX_RESULT rv_depack_seek(rv_depack* pDepack, UINT32 ulTime);
+
+ /*
+ * rv_depack_destroy
+ *
+ * This cleans up all memory allocated by the rv_depack_* calls
+ */
+ void rv_depack_destroy(rv_depack** ppDepack);
+
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RV_DEPACK_H */
diff --git a/audio_codec/libraac/include/rv_format_info.h b/audio_codec/libraac/include/rv_format_info.h
new file mode 100644
index 0000000..29554fe
--- a/dev/null
+++ b/audio_codec/libraac/include/rv_format_info.h
@@ -0,0 +1,91 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_format_info.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV_FORMAT_INFO_H
+#define RV_FORMAT_INFO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* #ifdef __cplusplus */
+
+#include "helix_types.h"
+
+ typedef struct rv_format_info_struct {
+ UINT32 ulLength;
+ UINT32 ulMOFTag;
+ UINT32 ulSubMOFTag;
+ UINT16 usWidth;
+ UINT16 usHeight;
+ UINT16 usBitCount;
+ UINT16 usPadWidth;
+ UINT16 usPadHeight;
+ UFIXED32 ufFramesPerSecond;
+ UINT32 ulOpaqueDataSize;
+ BYTE* pOpaqueData;
+ } rv_format_info;
+
+ /*
+ * RV frame struct.
+ */
+ typedef struct rv_segment_struct {
+ HXBOOL bIsValid;
+ UINT32 ulOffset;
+ } rv_segment;
+
+ typedef struct rv_frame_struct {
+ UINT32 ulDataLen;
+ BYTE* pData;
+ UINT32 ulTimestamp;
+ UINT16 usSequenceNum;
+ UINT16 usFlags;
+ HXBOOL bLastPacket;
+ UINT32 ulNumSegments;
+ rv_segment* pSegment;
+ } rv_frame;
+
+#define BYTE_SWAP_UINT16(A) ((((UINT16)(A) & 0xff00) >> 8) | \
+ (((UINT16)(A) & 0x00ff) << 8))
+#define BYTE_SWAP_UINT32(A) ((((UINT32)(A) & 0xff000000) >> 24) | \
+ (((UINT32)(A) & 0x00ff0000) >> 8) | \
+ (((UINT32)(A) & 0x0000ff00) << 8) | \
+ (((UINT32)(A) & 0x000000ff) << 24))
+
+#ifdef __cplusplus
+}
+#endif /* #ifdef __cplusplus */
+
+#endif /* #ifndef RV_FORMAT_INFO_H */
diff --git a/audio_codec/libraac/include/statname.h b/audio_codec/libraac/include/statname.h
new file mode 100644
index 0000000..9ceacce
--- a/dev/null
+++ b/audio_codec/libraac/include/statname.h
@@ -0,0 +1,118 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: statname.h,v 1.6 2005/04/27 19:20:50 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2002 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point RealAudio 8 decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * October 2003
+ *
+ * statname.h - name mangling macros for static linking
+ **************************************************************************************/
+
+#ifndef _STATNAME_H
+#define _STATNAME_H
+
+/* define STAT_PREFIX to a unique name for static linking
+ * all the C functions and global variables will be mangled by the preprocessor
+ * e.g. void FFT(int *fftbuf) becomes void cook_FFT(int *fftbuf)
+ */
+#define STAT_PREFIX cook
+
+#define STATCC1(x,y,z) STATCC2(x,y,z)
+#define STATCC2(x,y,z) x##y##z
+
+#ifdef STAT_PREFIX
+#define STATNAME(func) STATCC1(STAT_PREFIX, _, func)
+#else
+#define STATNAME(func) func
+#endif
+
+/* global functions */
+#define AllocateBuffers STATNAME(AllocateBuffers)
+#define FreeBuffers STATNAME(FreeBuffers)
+
+#define DecodeSideInfo STATNAME(DecodeSideInfo)
+#define GetBits STATNAME(GetBits)
+#define AdvanceBitstream STATNAME(AdvanceBitstream)
+
+#define DecodeHuffmanScalar STATNAME(DecodeHuffmanScalar)
+
+#define DecodeGainInfo STATNAME(DecodeGainInfo)
+#define CopyGainInfo STATNAME(CopyGainInfo)
+
+#define JointDecodeMLT STATNAME(JointDecodeMLT)
+#define DecodeCoupleInfo STATNAME(DecodeCoupleInfo)
+
+#define DecodeEnvelope STATNAME(DecodeEnvelope)
+#define CategorizeAndExpand STATNAME(CategorizeAndExpand)
+#define DecodeTransform STATNAME(DecodeTransform)
+
+#define IMLTNoWindow STATNAME(IMLTNoWindow)
+#define R4FFT STATNAME(R4FFT)
+
+#define DecWindowWithAttacks STATNAME(DecWindowWithAttacks)
+#define DecWindowNoAttacks STATNAME(DecWindowNoAttacks)
+
+/* global (const) data */
+#define pkkey STATNAME(pkkey)
+
+#define huffTabCoupleInfo STATNAME(huffTabCoupleInfo)
+#define huffTabCouple STATNAME(huffTabCouple)
+#define huffTabPowerInfo STATNAME(huffTabPowerInfo)
+#define huffTabPower STATNAME(huffTabPower)
+#define huffTabVectorInfo STATNAME(huffTabVectorInfo)
+#define huffTabVector STATNAME(huffTabVector)
+
+#define nmltTab STATNAME(nmltTab)
+#define window STATNAME(window)
+#define windowOffset STATNAME(windowOffset)
+#define cos4sin4tab STATNAME(cos4sin4tab)
+#define cos4sin4tabOffset STATNAME(cos4sin4tabOffset)
+#define cos1sin1tab STATNAME(cos1sin1tab)
+#define uniqueIDTab STATNAME(uniqueIDTab)
+#define bitrevtab STATNAME(bitrevtab)
+#define bitrevtabOffset STATNAME(bitrevtabOffset)
+#define twidTabEven STATNAME(twidTabEven)
+#define twidTabOdd STATNAME(twidTabOdd)
+
+/* assembly functions - either inline or in separate asm file */
+#define MULSHIFT32 STATNAME(MULSHIFT32)
+#define CLIPTOSHORT STATNAME(CLIPTOSHORT)
+#define FASTABS STATNAME(FASTABS)
+#define CLZ STATNAME(CLZ)
+
+#endif /* _STATNAME_H */
diff --git a/audio_codec/libraac/include/stream_hdr_structs.h b/audio_codec/libraac/include/stream_hdr_structs.h
new file mode 100644
index 0000000..433270f
--- a/dev/null
+++ b/audio_codec/libraac/include/stream_hdr_structs.h
@@ -0,0 +1,66 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: stream_hdr_structs.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef STREAM_HDR_STRUCTS_H
+#define STREAM_HDR_STRUCTS_H
+
+#include "helix_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* map an ASM rule to some other property */
+ typedef struct rm_rule_map_struct {
+ UINT32 ulNumRules;
+ UINT32* pulMap;
+ } rm_rule_map;
+
+ /* rm multistream header -- surestream */
+ typedef struct rm_multistream_hdr_struct {
+ UINT32 ulID; /* unique identifier for this header */
+ rm_rule_map rule2SubStream; /* mapping of ASM rule number to substream */
+ UINT32 ulNumSubStreams; /* number of substreams */
+ } rm_multistream_hdr;
+
+#define RM_MULTIHEADER_OBJECT 0x4D4C5449 /* 'MLTI' */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef STREAM_HDR_STRUCTS_H */
diff --git a/audio_codec/libraac/include/stream_hdr_utils.h b/audio_codec/libraac/include/stream_hdr_utils.h
new file mode 100644
index 0000000..2f5d4d3
--- a/dev/null
+++ b/audio_codec/libraac/include/stream_hdr_utils.h
@@ -0,0 +1,77 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: stream_hdr_utils.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef STREAM_HDR_UTILS_H
+#define STREAM_HDR_UTILS_H
+
+#include "helix_types.h"
+#include "helix_result.h"
+#include "rm_memory.h"
+#include "stream_hdr_structs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ HX_RESULT rm_unpack_rule_map(BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree,
+ void* pUserMem,
+ rm_rule_map* pMap);
+
+ void rm_cleanup_rule_map(rm_free_func_ptr fpFree,
+ void* pUserMem,
+ rm_rule_map* pMap);
+
+ HX_RESULT rm_unpack_multistream_hdr(BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree,
+ void* pUserMem,
+ rm_multistream_hdr* hdr);
+
+ void rm_cleanup_multistream_hdr(rm_free_func_ptr fpFree,
+ void* pUserMem,
+ rm_multistream_hdr* hdr);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef STREAM_HDR_UTILS_H */
diff --git a/audio_codec/libraac/include/string_utils.h b/audio_codec/libraac/include/string_utils.h
new file mode 100644
index 0000000..5337f52
--- a/dev/null
+++ b/audio_codec/libraac/include/string_utils.h
@@ -0,0 +1,62 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: string_utils.h,v 1.1.1.1.2.1 2005/05/04 18:21:22 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef STRING_UTILS_H
+#define STRING_UTILS_H
+
+#include "helix_types.h"
+#include "rm_memory.h"
+/* Create and copy a string */
+char* copy_string(void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ const char* pszStr);
+
+/* Free a string */
+void free_string(void* pUserMem,
+ rm_free_func_ptr fpFree,
+ char** ppszStr);
+
+#if defined(_WINDOWS)
+
+int strcasecmp(const char* pszStr1, const char* pszStr2);
+int strncasecmp(const char* pszStr1, const char* pszStr2, int len);
+
+#elif defined(_UNIX)
+#include <strings.h>
+#endif
+
+#endif /* #ifndef STRING_UTILS_H */
diff --git a/audio_codec/libraac/include/tngpkt.h b/audio_codec/libraac/include/tngpkt.h
new file mode 100644
index 0000000..3e2d0af
--- a/dev/null
+++ b/audio_codec/libraac/include/tngpkt.h
@@ -0,0 +1,400 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: tngpkt.h,v 1.1.1.1.2.1 2005/05/04 18:20:57 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+ * This is generated code, do not modify. Look in
+ * /home/gregory/helix/protocol/transport/rdt/pub/tngpkt.pm to make
+ * modifications
+ */
+
+#include "helix_types.h"
+#include "rm_memory.h"
+
+#ifndef PMC_PREDEFINED_TYPES
+#define PMC_PREDEFINED_TYPES
+
+typedef char* pmc_string;
+
+typedef struct _buffer {
+ UINT32 len;
+ INT8* data;
+} buffer;
+#endif/*PMC_PREDEFINED_TYPES*/
+
+
+#ifndef _TNGPKT_H_
+#define _TNGPKT_H_
+
+struct TNGDataPacket {
+ UINT8 length_included_flag;
+ UINT8 need_reliable_flag;
+ UINT8 stream_id;
+ UINT8 is_reliable;
+ UINT16 seq_no;
+ UINT16 _packlenwhendone;
+ UINT8 back_to_back_packet;
+ UINT8 slow_data;
+ UINT8 asm_rule_number;
+ UINT32 timestamp;
+ UINT16 stream_id_expansion;
+ UINT16 total_reliable;
+ UINT16 asm_rule_number_expansion;
+ buffer data;
+};
+
+const UINT32 TNGDataPacket_static_size();
+UINT8* TNGDataPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGDataPacket* pkt);
+UINT8* TNGDataPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGDataPacket* pkt);
+
+struct TNGMultiCastDataPacket {
+ UINT8 length_included_flag;
+ UINT8 need_reliable_flag;
+ UINT8 stream_id;
+ UINT8 is_reliable;
+ UINT16 seq_no;
+ UINT16 length;
+ UINT8 back_to_back_packet;
+ UINT8 slow_data;
+ UINT8 asm_rule_number;
+ UINT8 group_seq_no;
+ UINT32 timestamp;
+ UINT16 stream_id_expansion;
+ UINT16 total_reliable;
+ UINT16 asm_rule_number_expansion;
+ buffer data;
+};
+
+const UINT32 TNGMultiCastDataPacket_static_size();
+
+UINT8* TNGMultiCastDataPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGMultiCastDataPacket* pkt);
+UINT8* TNGMultiCastDataPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGMultiCastDataPacket* pkt);
+
+
+struct TNGASMActionPacket {
+ UINT8 length_included_flag;
+ UINT8 stream_id;
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT16 packet_type;
+ UINT16 reliable_seq_no;
+ UINT16 length;
+ UINT16 stream_id_expansion;
+ buffer data;
+};
+
+const UINT32 TNGASMActionPacket_static_size();
+UINT8* TNGASMActionPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGASMActionPacket* pkt);
+
+UINT8* TNGASMActionPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGASMActionPacket* pkt);
+
+
+
+struct TNGBandwidthReportPacket {
+ UINT8 length_included_flag;
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 dummy2;
+ UINT16 packet_type;
+ UINT16 length;
+ UINT16 interval;
+ UINT32 bandwidth;
+ UINT8 sequence;
+};
+
+const UINT32 TNGBandwidthReportPacket_static_size();
+UINT8* TNGBandwidthReportPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGBandwidthReportPacket* pkt);
+UINT8* TNGBandwidthReportPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGBandwidthReportPacket* pkt);
+
+
+
+struct TNGReportPacket {
+ UINT8 length_included_flag;
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 dummy2;
+ UINT16 packet_type;
+ UINT16 length;
+ buffer data;
+};
+
+const UINT32 TNGReportPacket_static_size();
+UINT8* TNGReportPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGReportPacket* pkt);
+UINT8* TNGReportPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGReportPacket* pkt);
+
+
+
+struct TNGACKPacket {
+ UINT8 length_included_flag;
+ UINT8 lost_high;
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT16 packet_type;
+ UINT16 length;
+ buffer data;
+};
+
+const UINT32 TNGACKPacket_static_size();
+UINT8* TNGACKPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGACKPacket* pkt);
+UINT8* TNGACKPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGACKPacket* pkt);
+
+
+struct TNGRTTRequestPacket {
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 dummy2;
+ UINT8 dummy3;
+ UINT16 packet_type;
+};
+
+const UINT32 TNGRTTRequestPacket_static_size();
+UINT8* TNGRTTRequestPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGRTTRequestPacket* pkt);
+UINT8* TNGRTTRequestPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGRTTRequestPacket* pkt);
+
+struct TNGRTTResponsePacket {
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 dummy2;
+ UINT8 dummy3;
+ UINT16 packet_type;
+ UINT32 timestamp_sec;
+ UINT32 timestamp_usec;
+};
+
+const UINT32 TNGRTTResponsePacket_static_size();
+UINT8* TNGRTTResponsePacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGRTTResponsePacket* pkt);
+UINT8* TNGRTTResponsePacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGRTTResponsePacket* pkt);
+
+
+struct TNGCongestionPacket {
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 dummy2;
+ UINT8 dummy3;
+ UINT16 packet_type;
+ INT32 xmit_multiplier;
+ INT32 recv_multiplier;
+};
+
+const UINT32 TNGCongestionPacket_static_size();
+UINT8* TNGCongestionPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGCongestionPacket* pkt);
+UINT8* TNGCongestionPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGCongestionPacket* pkt);
+
+
+struct TNGStreamEndPacket {
+ UINT8 need_reliable_flag;
+ UINT8 stream_id;
+ UINT8 packet_sent;
+ UINT8 ext_flag;
+ UINT16 packet_type;
+ UINT16 seq_no;
+ UINT32 timestamp;
+ UINT16 stream_id_expansion;
+ UINT16 total_reliable;
+ UINT8 reason_dummy[3];
+ UINT32 reason_code;
+ pmc_string reason_text;
+};
+
+const UINT32 TNGStreamEndPacket_static_size();
+UINT8* TNGStreamEndPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGStreamEndPacket* pkt);
+
+/* TNGStreamEndPacket_unpack will malloc room for the reason_text.
+ * You must free this memory or it will be leaked */
+UINT8* TNGStreamEndPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGStreamEndPacket* pkt);
+
+UINT8* TNGStreamEndPacket_unpack_fromPool(UINT8* buf,
+ UINT32 len,
+ struct TNGStreamEndPacket* pkt,
+ rm_malloc_func_ptr fpMalloc,
+ void* pMemoryPool);
+
+
+
+
+struct TNGLatencyReportPacket {
+ UINT8 length_included_flag;
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 dummy2;
+ UINT16 packet_type;
+ UINT16 length;
+ UINT32 server_out_time;
+};
+
+const UINT32 TNGLatencyReportPacket_static_size();
+UINT8* TNGLatencyReportPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGLatencyReportPacket* pkt);
+UINT8* TNGLatencyReportPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGLatencyReportPacket* pkt);
+
+
+
+
+/*
+ * RDTFeatureLevel 3 packets
+ */
+
+struct RDTTransportInfoRequestPacket {
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 request_rtt_info;
+ UINT8 request_buffer_info;
+ UINT16 packet_type;
+ UINT32 request_time_ms;
+};
+
+const UINT32 RDTTransportInfoRequestPacket_static_size();
+UINT8* RDTTransportInfoRequestPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct RDTTransportInfoRequestPacket* pkt);
+UINT8* RDTTransportInfoRequestPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct RDTTransportInfoRequestPacket* pkt);
+
+
+
+
+struct RDTBufferInfo {
+ UINT16 stream_id;
+ UINT32 lowest_timestamp;
+ UINT32 highest_timestamp;
+ UINT32 bytes_buffered;
+};
+
+const UINT32 RDTBufferInfo_static_size();
+UINT8* RDTBufferInfo_pack(UINT8* buf,
+ UINT32 len, struct RDTBufferInfo* pkt);
+UINT8* RDTBufferInfo_unpack(UINT8* buf,
+ UINT32 len, struct RDTBufferInfo* pkt);
+
+
+
+
+struct RDTTransportInfoResponsePacket {
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 has_rtt_info;
+ UINT8 is_delayed;
+ UINT8 has_buffer_info;
+ UINT16 packet_type;
+ UINT32 request_time_ms;
+ UINT32 response_time_ms;
+ UINT16 buffer_info_count;
+ struct RDTBufferInfo *buffer_info;
+};
+
+const UINT32 RDTTransportInfoResponsePacket_static_size();
+UINT8* RDTTransportInfoResponsePacket_pack(UINT8* buf,
+ UINT32 len,
+ struct RDTTransportInfoResponsePacket* pkt);
+UINT8* RDTTransportInfoResponsePacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct RDTTransportInfoResponsePacket* pkt);
+
+UINT8* RDTTransportInfoResponsePacket_unpack_fromPool(UINT8* buf,
+ UINT32 len,
+ struct RDTTransportInfoResponsePacket* pkt,
+ rm_malloc_func_ptr fpMalloc,
+ void* pMemoryPool);
+
+
+
+
+
+
+struct TNGBWProbingPacket {
+ UINT8 length_included_flag;
+ UINT8 dummy0;
+ UINT8 dummy1;
+ UINT8 dummy2;
+ UINT16 packet_type;
+ UINT16 length;
+ UINT8 seq_no;
+ UINT32 timestamp;
+ buffer data;
+};
+
+const UINT32 TNGBWProbingPacket_static_size();
+UINT8* TNGBWProbingPacket_pack(UINT8* buf,
+ UINT32 len,
+ struct TNGBWProbingPacket* pkt);
+UINT8* TNGBWProbingPacket_unpack(UINT8* buf,
+ UINT32 len,
+ struct TNGBWProbingPacket* pkt);
+#endif /* _TNGPKT_H_ */
diff --git a/audio_codec/libraac/memory_utils.c b/audio_codec/libraac/memory_utils.c
new file mode 100644
index 0000000..b7d46b2
--- a/dev/null
+++ b/audio_codec/libraac/memory_utils.c
@@ -0,0 +1,100 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: memory_utils.c,v 1.1.1.1.2.1 2005/05/04 18:21:23 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <memory.h>
+#include "../include/helix_types.h"
+#include "../include/helix_result.h"
+#include "../include/rm_memory.h"
+#include "../include/memory_utils.h"
+
+HX_RESULT rm_enforce_buffer_min_size(void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree,
+ BYTE** ppBuf,
+ UINT32* pulCurLen,
+ UINT32 ulReqLen)
+{
+ HX_RESULT retVal = HXR_OUTOFMEMORY;
+
+ if (fpMalloc && fpFree && ppBuf && pulCurLen) {
+ if (ulReqLen > *pulCurLen) {
+ /* Allocate a new buffer */
+ BYTE* pBuf = fpMalloc(pUserMem, ulReqLen);
+ if (pBuf) {
+ /* Was the old buffer allocated? */
+ if (*ppBuf && *pulCurLen > 0) {
+ /* Copy the old buffer into the new one */
+ memcpy(pBuf, *ppBuf, *pulCurLen);
+ /* Free the old buffer */
+ fpFree(pUserMem, *ppBuf);
+ }
+ /* Assign the buffer out parameter */
+ *ppBuf = pBuf;
+ /* Change the current size to the requested size */
+ *pulCurLen = ulReqLen;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ } else {
+ /* Current buffer size is adequate - don't
+ * have to do anything here.
+ */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+BYTE* copy_buffer(void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ BYTE* pBuf,
+ UINT32 ulLen)
+{
+ BYTE* pRet = HXNULL;
+
+ if (fpMalloc && pBuf && ulLen) {
+ /* Allocate a buffer */
+ pRet = (BYTE*) fpMalloc(pUserMem, ulLen);
+ if (pRet) {
+ /* Copy the buffer */
+ memcpy(pRet, pBuf, ulLen);
+ }
+ }
+
+ return pRet;
+}
diff --git a/audio_codec/libraac/noiseless.c b/audio_codec/libraac/noiseless.c
new file mode 100644
index 0000000..f782f39
--- a/dev/null
+++ b/audio_codec/libraac/noiseless.c
@@ -0,0 +1,503 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: noiseless.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * noiseless.c - decode channel info, scalefactors, quantized coefficients,
+ * scalefactor band codebook, and TNS coefficients from bitstream
+ **************************************************************************************/
+
+#include "coder.h"
+//#include <core/dsp.h>
+#include <stdio.h>
+
+
+/**************************************************************************************
+ * Function: DecodeICSInfo
+ *
+ * Description: decode individual channel stream info
+ *
+ * Inputs: BitStreamInfo struct pointing to start of ICS info
+ * (14496-3, table 4.4.6)
+ * sample rate index
+ *
+ * Outputs: updated icsInfo struct
+ *
+ * Return: none
+ **************************************************************************************/
+void DecodeICSInfo(BitStreamInfo *bsi, ICSInfo *icsInfo, int sampRateIdx)
+{
+ int sfb, g, mask;
+
+ icsInfo->icsResBit = GetBits(bsi, 1);
+ icsInfo->winSequence = GetBits(bsi, 2);
+ icsInfo->winShape = GetBits(bsi, 1);
+ if (icsInfo->winSequence == 2) {
+ /* short block */
+ icsInfo->maxSFB = GetBits(bsi, 4);
+ icsInfo->sfGroup = GetBits(bsi, 7);
+ icsInfo->numWinGroup = 1;
+ icsInfo->winGroupLen[0] = 1;
+ mask = 0x40; /* start with bit 6 */
+ for (g = 0; g < 7; g++) {
+ if (icsInfo->sfGroup & mask) {
+ icsInfo->winGroupLen[icsInfo->numWinGroup - 1]++;
+ } else {
+ icsInfo->numWinGroup++;
+ icsInfo->winGroupLen[icsInfo->numWinGroup - 1] = 1;
+ }
+ mask >>= 1;
+ }
+ } else {
+ /* long block */
+ icsInfo->maxSFB = GetBits(bsi, 6);
+ icsInfo->predictorDataPresent = GetBits(bsi, 1);
+ if (icsInfo->predictorDataPresent) {
+ icsInfo->predictorReset = GetBits(bsi, 1);
+ if (icsInfo->predictorReset) {
+ icsInfo->predictorResetGroupNum = GetBits(bsi, 5);
+ }
+ for (sfb = 0; sfb < MIN(icsInfo->maxSFB, predSFBMax[sampRateIdx]); sfb++) {
+ icsInfo->predictionUsed[sfb] = GetBits(bsi, 1);
+ }
+ }
+ icsInfo->numWinGroup = 1;
+ icsInfo->winGroupLen[0] = 1;
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodeSectionData
+ *
+ * Description: decode section data (scale factor band groupings and
+ * associated Huffman codebooks)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of ICS info
+ * (14496-3, table 4.4.25)
+ * window sequence (short or long blocks)
+ * number of window groups (1 for long blocks, 1-8 for short blocks)
+ * max coded scalefactor band
+ *
+ * Outputs: index of Huffman codebook for each scalefactor band in each section
+ *
+ * Return: none
+ *
+ * Notes: sectCB, sectEnd, sfbCodeBook, ordered by window groups for short blocks
+ **************************************************************************************/
+static void DecodeSectionData(BitStreamInfo *bsi, int winSequence, int numWinGrp, int maxSFB, unsigned char *sfbCodeBook)
+{
+ int g, cb, sfb;
+ int sectLen, sectLenBits, sectLenIncr, sectEscapeVal;
+
+ sectLenBits = (winSequence == 2 ? 3 : 5);
+ sectEscapeVal = (1 << sectLenBits) - 1;
+
+ for (g = 0; g < numWinGrp; g++) {
+ sfb = 0;
+ while (sfb < maxSFB) {
+ cb = GetBits(bsi, 4); /* next section codebook */
+ sectLen = 0;
+ do {
+ sectLenIncr = GetBits(bsi, sectLenBits);
+ sectLen += sectLenIncr;
+ } while (sectLenIncr == sectEscapeVal);
+
+ sfb += sectLen;
+ while (sectLen--) {
+ *sfbCodeBook++ = (unsigned char)cb;
+ }
+ }
+ ASSERT(sfb == maxSFB);
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodeOneScaleFactor
+ *
+ * Description: decode one scalefactor using scalefactor Huffman codebook
+ *
+ * Inputs: BitStreamInfo struct pointing to start of next coded scalefactor
+ *
+ * Outputs: updated BitstreamInfo struct
+ *
+ * Return: one decoded scalefactor, including index_offset of -60
+ **************************************************************************************/
+static int DecodeOneScaleFactor(BitStreamInfo *bsi)
+{
+ int nBits, val;
+ unsigned int bitBuf;
+
+ /* decode next scalefactor from bitstream */
+ bitBuf = GetBitsNoAdvance(bsi, huffTabScaleFactInfo.maxBits) << (32 - huffTabScaleFactInfo.maxBits);
+ nBits = DecodeHuffmanScalar(huffTabScaleFact, &huffTabScaleFactInfo, bitBuf, &val);
+ AdvanceBitstream(bsi, nBits);
+
+ return val;
+}
+
+/**************************************************************************************
+ * Function: DecodeScaleFactors
+ *
+ * Description: decode scalefactors, PNS energy, and intensity stereo weights
+ *
+ * Inputs: BitStreamInfo struct pointing to start of ICS info
+ * (14496-3, table 4.4.26)
+ * number of window groups (1 for long blocks, 1-8 for short blocks)
+ * max coded scalefactor band
+ * global gain (starting value for differential scalefactor coding)
+ * index of Huffman codebook for each scalefactor band in each section
+ *
+ * Outputs: decoded scalefactor for each section
+ *
+ * Return: none
+ *
+ * Notes: sfbCodeBook, scaleFactors ordered by window groups for short blocks
+ * for section with codebook 13, scaleFactors buffer has decoded PNS
+ * energy instead of regular scalefactor
+ * for section with codebook 14 or 15, scaleFactors buffer has intensity
+ * stereo weight instead of regular scalefactor
+ **************************************************************************************/
+static void DecodeScaleFactors(BitStreamInfo *bsi, int numWinGrp, int maxSFB, int globalGain,
+ unsigned char *sfbCodeBook, short *scaleFactors)
+{
+ int g, sfbCB, nrg, npf, val, sf, is;
+
+ /* starting values for differential coding */
+ sf = globalGain;
+ is = 0;
+ nrg = globalGain - 90 - 256;
+ npf = 1;
+
+ for (g = 0; g < numWinGrp * maxSFB; g++) {
+ sfbCB = *sfbCodeBook++;
+
+ if (sfbCB == 14 || sfbCB == 15) {
+ /* intensity stereo - differential coding */
+ val = DecodeOneScaleFactor(bsi);
+ is += val;
+ *scaleFactors++ = (short)is;
+ } else if (sfbCB == 13) {
+ /* PNS - first energy is directly coded, rest are Huffman coded (npf = noise_pcm_flag) */
+ if (npf) {
+ val = GetBits(bsi, 9);
+ npf = 0;
+ } else {
+ val = DecodeOneScaleFactor(bsi);
+ }
+ nrg += val;
+ *scaleFactors++ = (short)nrg;
+ } else if (sfbCB >= 1 && sfbCB <= 11) {
+ /* regular (non-zero) region - differential coding */
+ val = DecodeOneScaleFactor(bsi);
+ sf += val;
+ *scaleFactors++ = (short)sf;
+ } else {
+ /* inactive scalefactor band if codebook 0 */
+ *scaleFactors++ = 0;
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodePulseInfo
+ *
+ * Description: decode pulse information
+ *
+ * Inputs: BitStreamInfo struct pointing to start of pulse info
+ * (14496-3, table 4.4.7)
+ *
+ * Outputs: updated PulseInfo struct
+ *
+ * Return: none
+ **************************************************************************************/
+static void DecodePulseInfo(BitStreamInfo *bsi, PulseInfo *pi)
+{
+ int i;
+
+ pi->numPulse = GetBits(bsi, 2) + 1; /* add 1 here */
+ pi->startSFB = GetBits(bsi, 6);
+ for (i = 0; i < pi->numPulse; i++) {
+ pi->offset[i] = GetBits(bsi, 5);
+ pi->amp[i] = GetBits(bsi, 4);
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodeTNSInfo
+ *
+ * Description: decode TNS filter information
+ *
+ * Inputs: BitStreamInfo struct pointing to start of TNS info
+ * (14496-3, table 4.4.27)
+ * window sequence (short or long blocks)
+ *
+ * Outputs: updated TNSInfo struct
+ * buffer of decoded (signed) TNS filter coefficients
+ *
+ * Return: none
+ **************************************************************************************/
+static void DecodeTNSInfo(BitStreamInfo *bsi, int winSequence, TNSInfo *ti, signed char *tnsCoef)
+{
+ int i, w, f, coefBits, compress;
+ signed char c, s, n;
+ signed char sgnMask[3] = { 0x02, 0x04, 0x08};
+ signed char negMask[3] = {~0x03, ~0x07, ~0x0f};
+ unsigned char *filtLength, *filtOrder, *filtDir;
+
+ filtLength = ti->length;
+ filtOrder = ti->order;
+ filtDir = ti->dir;
+
+ if (winSequence == 2) {
+ /* short blocks */
+ for (w = 0; w < NWINDOWS_SHORT; w++) {
+ ti->numFilt[w] = GetBits(bsi, 1);
+ if (ti->numFilt[w]) {
+ ti->coefRes[w] = GetBits(bsi, 1) + 3;
+ *filtLength = GetBits(bsi, 4);
+ *filtOrder = GetBits(bsi, 3);
+ if (*filtOrder) {
+ *filtDir++ = GetBits(bsi, 1);
+ compress = GetBits(bsi, 1);
+ coefBits = (int)ti->coefRes[w] - compress; /* 2, 3, or 4 */
+ s = sgnMask[coefBits - 2];
+ n = negMask[coefBits - 2];
+ for (i = 0; i < *filtOrder; i++) {
+ c = GetBits(bsi, coefBits);
+ if (c & s) {
+ c |= n;
+ }
+ *tnsCoef++ = c;
+ }
+ }
+ filtLength++;
+ filtOrder++;
+ }
+ }
+ } else {
+ /* long blocks */
+ ti->numFilt[0] = GetBits(bsi, 2);
+ if (ti->numFilt[0]) {
+ ti->coefRes[0] = GetBits(bsi, 1) + 3;
+ }
+ for (f = 0; f < ti->numFilt[0]; f++) {
+ *filtLength = GetBits(bsi, 6);
+ *filtOrder = GetBits(bsi, 5);
+ if (*filtOrder) {
+ *filtDir++ = GetBits(bsi, 1);
+ compress = GetBits(bsi, 1);
+ coefBits = (int)ti->coefRes[0] - compress; /* 2, 3, or 4 */
+ s = sgnMask[coefBits - 2];
+ n = negMask[coefBits - 2];
+ for (i = 0; i < *filtOrder; i++) {
+ c = GetBits(bsi, coefBits);
+ if (c & s) {
+ c |= n;
+ }
+ *tnsCoef++ = c;
+ }
+ }
+ filtLength++;
+ filtOrder++;
+ }
+ }
+}
+
+/* bitstream field lengths for gain control data:
+ * gainBits[winSequence][0] = maxWindow (how many gain windows there are)
+ * gainBits[winSequence][1] = locBitsZero (bits for alocCode if window == 0)
+ * gainBits[winSequence][2] = locBits (bits for alocCode if window != 0)
+ */
+static const unsigned char gainBits[4][3] = {
+ {1, 5, 5}, /* long */
+ {2, 4, 2}, /* start */
+ {8, 2, 2}, /* short */
+ {2, 4, 5}, /* stop */
+};
+
+/**************************************************************************************
+ * Function: DecodeGainControlInfo
+ *
+ * Description: decode gain control information (SSR profile only)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of gain control info
+ * (14496-3, table 4.4.12)
+ * window sequence (short or long blocks)
+ *
+ * Outputs: updated GainControlInfo struct
+ *
+ * Return: none
+ **************************************************************************************/
+static void DecodeGainControlInfo(BitStreamInfo *bsi, int winSequence, GainControlInfo *gi)
+{
+ int bd, wd, ad;
+ int locBits, locBitsZero, maxWin;
+
+ gi->maxBand = GetBits(bsi, 2);
+ maxWin = (int)gainBits[winSequence][0];
+ locBitsZero = (int)gainBits[winSequence][1];
+ locBits = (int)gainBits[winSequence][2];
+
+ for (bd = 1; bd <= gi->maxBand; bd++) {
+ for (wd = 0; wd < maxWin; wd++) {
+ gi->adjNum[bd][wd] = GetBits(bsi, 3);
+ for (ad = 0; ad < gi->adjNum[bd][wd]; ad++) {
+ gi->alevCode[bd][wd][ad] = GetBits(bsi, 4);
+ gi->alocCode[bd][wd][ad] = GetBits(bsi, (wd == 0 ? locBitsZero : locBits));
+ }
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodeICS
+ *
+ * Description: decode individual channel stream
+ *
+ * Inputs: platform specific info struct
+ * BitStreamInfo struct pointing to start of individual channel stream
+ * (14496-3, table 4.4.24)
+ * index of current channel
+ *
+ * Outputs: updated section data, scale factor data, pulse data, TNS data,
+ * and gain control data
+ *
+ * Return: none
+ **************************************************************************************/
+static void DecodeICS(PSInfoBase *psi, BitStreamInfo *bsi, int ch)
+{
+ int globalGain;
+ ICSInfo *icsInfo;
+ PulseInfo *pi;
+ TNSInfo *ti;
+ GainControlInfo *gi;
+
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ globalGain = GetBits(bsi, 8);
+ if (!psi->commonWin) {
+ DecodeICSInfo(bsi, icsInfo, psi->sampRateIdx);
+ }
+
+ DecodeSectionData(bsi, icsInfo->winSequence, icsInfo->numWinGroup, icsInfo->maxSFB, psi->sfbCodeBook[ch]);
+
+ DecodeScaleFactors(bsi, icsInfo->numWinGroup, icsInfo->maxSFB, globalGain, psi->sfbCodeBook[ch], psi->scaleFactors[ch]);
+
+ pi = &psi->pulseInfo[ch];
+ pi->pulseDataPresent = GetBits(bsi, 1);
+ if (pi->pulseDataPresent) {
+ DecodePulseInfo(bsi, pi);
+ }
+
+ ti = &psi->tnsInfo[ch];
+ ti->tnsDataPresent = GetBits(bsi, 1);
+ if (ti->tnsDataPresent) {
+ DecodeTNSInfo(bsi, icsInfo->winSequence, ti, ti->coef);
+ }
+
+ gi = &psi->gainControlInfo[ch];
+ gi->gainControlDataPresent = GetBits(bsi, 1);
+ if (gi->gainControlDataPresent) {
+ DecodeGainControlInfo(bsi, icsInfo->winSequence, gi);
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodeNoiselessData
+ *
+ * Description: decode noiseless data (side info and transform coefficients)
+ *
+ * Inputs: valid AACDecInfo struct
+ * double pointer to buffer pointing to start of individual channel stream
+ * (14496-3, table 4.4.24)
+ * pointer to bit offset
+ * pointer to number of valid bits remaining in buf
+ * index of current channel
+ *
+ * Outputs: updated global gain, section data, scale factor data, pulse data,
+ * TNS data, gain control data, and spectral data
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int DecodeNoiselessData(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail, int ch)
+{
+ int bitsUsed;
+ BitStreamInfo bsi;
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ if (AACDataSource == 1) {
+ SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf);
+ GetBits(&bsi, *bitOffset);
+ } else {
+ if (((*bitsAvail + 7) >> 3) < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+
+ DecodeICS(psi, &bsi, ch);
+
+ if (icsInfo->winSequence == 2) {
+ DecodeSpectrumShort(psi, &bsi, ch);
+ } else {
+ DecodeSpectrumLong(psi, &bsi, ch);
+ }
+
+ if (AACDataSource == 1) {
+ bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset);
+ *buf += ((bitsUsed + *bitOffset) >> 3);
+ *bitOffset = ((bitsUsed + *bitOffset) & 0x07);
+ *bitsAvail -= bitsUsed;
+ if (*bitsAvail < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+ aacDecInfo->sbDeinterleaveReqd[ch] = 0;
+ aacDecInfo->tnsUsed |= psi->tnsInfo[ch].tnsDataPresent; /* set flag if TNS used for any channel */
+
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/libraac/pack_utils.c b/audio_codec/libraac/pack_utils.c
new file mode 100644
index 0000000..fd0935a
--- a/dev/null
+++ b/audio_codec/libraac/pack_utils.c
@@ -0,0 +1,306 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: pack_utils.c,v 1.2.2.1 2005/05/04 18:21:23 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <memory.h>
+#include "../include/helix_types.h"
+#include "../include/helix_result.h"
+#include "../include/rm_memory.h"
+#include "../include/memory_utils.h"
+#include "../include/pack_utils.h"
+
+void rm_pack32(UINT32 ulValue, BYTE** ppBuf, UINT32* pulLen)
+{
+ if (ppBuf && pulLen && *pulLen >= 4) {
+ BYTE* pBuf = *ppBuf;
+ pBuf[0] = (BYTE)((ulValue & 0xFF000000) >> 24);
+ pBuf[1] = (BYTE)((ulValue & 0x00FF0000) >> 16);
+ pBuf[2] = (BYTE)((ulValue & 0x0000FF00) >> 8);
+ pBuf[3] = (BYTE)(ulValue & 0x000000FF);
+ *ppBuf += 4;
+ *pulLen -= 4;
+ }
+}
+
+void rm_pack32_le(UINT32 ulValue, BYTE** ppBuf, UINT32* pulLen)
+{
+ if (ppBuf && pulLen && *pulLen >= 4) {
+ BYTE* pBuf = *ppBuf;
+ pBuf[0] = (BYTE)(ulValue & 0x000000FF);
+ pBuf[1] = (BYTE)((ulValue & 0x0000FF00) >> 8);
+ pBuf[2] = (BYTE)((ulValue & 0x00FF0000) >> 16);
+ pBuf[3] = (BYTE)((ulValue & 0xFF000000) >> 24);
+ *ppBuf += 4;
+ *pulLen -= 4;
+ }
+}
+
+void rm_pack16(UINT16 usValue, BYTE** ppBuf, UINT32* pulLen)
+{
+ if (ppBuf && pulLen && *pulLen >= 2) {
+ BYTE* pBuf = *ppBuf;
+ pBuf[0] = (BYTE)((usValue & 0x0000FF00) >> 8);
+ pBuf[1] = (BYTE)(usValue & 0x000000FF);
+ *ppBuf += 2;
+ *pulLen -= 2;
+ }
+}
+
+void rm_pack16_le(UINT16 usValue, BYTE** ppBuf, UINT32* pulLen)
+{
+ if (ppBuf && pulLen && *pulLen >= 2) {
+ BYTE* pBuf = *ppBuf;
+ pBuf[0] = (BYTE)(usValue & 0x000000FF);
+ pBuf[1] = (BYTE)((usValue & 0x0000FF00) >> 8);
+ *ppBuf += 2;
+ *pulLen -= 2;
+ }
+}
+
+void rm_pack8(BYTE ucValue, BYTE** ppBuf, UINT32* pulLen)
+{
+ if (ppBuf && pulLen && *pulLen > 0) {
+ BYTE* pBuf = *ppBuf;
+ pBuf[0] = (BYTE) ucValue;
+ *ppBuf += 1;
+ *pulLen -= 1;
+ }
+}
+
+UINT32 rm_unpack32(BYTE** ppBuf, UINT32* pulLen)
+{
+ UINT32 ulRet = 0;
+
+ if (ppBuf && pulLen && *pulLen >= 4) {
+ BYTE* pBuf = *ppBuf;
+ ulRet = (pBuf[0] << 24) | (pBuf[1] << 16) | (pBuf[2] << 8) | pBuf[3];
+ *ppBuf += 4;
+ *pulLen -= 4;
+ }
+
+ return ulRet;
+}
+
+UINT16 rm_unpack16(BYTE** ppBuf, UINT32* pulLen)
+{
+ UINT16 usRet = 0;
+
+ if (ppBuf && pulLen && *pulLen >= 2) {
+ BYTE* pBuf = *ppBuf;
+ usRet = (pBuf[0] << 8) | pBuf[1];
+ *ppBuf += 2;
+ *pulLen -= 2;
+ }
+
+ return usRet;
+}
+
+UINT32 rm_unpack32_nse(BYTE* pBuf, UINT32 ulLen)
+{
+ UINT32 ulRet = 0;
+
+ if (pBuf && ulLen >= 4) {
+ ulRet = (pBuf[0] << 24) | (pBuf[1] << 16) | (pBuf[2] << 8) | pBuf[3];
+ }
+
+ return ulRet;
+}
+
+UINT16 rm_unpack16_nse(BYTE* pBuf, UINT32 ulLen)
+{
+ UINT16 usRet = 0;
+
+ if (pBuf && ulLen >= 2) {
+ usRet = (pBuf[0] << 8) | pBuf[1];
+ }
+
+ return usRet;
+}
+
+BYTE rm_unpack8(BYTE** ppBuf, UINT32* pulLen)
+{
+ BYTE ucRet = 0;
+
+ if (ppBuf && pulLen && *pulLen > 0) {
+ BYTE* pBuf = *ppBuf;
+ ucRet = pBuf[0];
+ *ppBuf += 1;
+ *pulLen -= 1;
+ }
+
+ return ucRet;
+}
+
+HX_RESULT rm_unpack_string(BYTE** ppBuf,
+ UINT32* pulLen,
+ UINT32 ulStrLen,
+ char** ppStr,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (ppBuf && pulLen && *pulLen >= ulStrLen && ppStr && fpMalloc && fpFree) {
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Do we actually have a string to unpack? */
+ if (ulStrLen) {
+ /* If the string is already allocated, free it */
+ if (*ppStr) {
+ fpFree(pUserMem, *ppStr);
+ *ppStr = HXNULL;
+ }
+ /* Allocate a buffer that it one more byte than the length */
+ *ppStr = (char*) fpMalloc(pUserMem, ulStrLen + 1);
+ if (*ppStr) {
+ /* Copy the string buffer in */
+ memcpy(*ppStr, *ppBuf, ulStrLen);
+ /* Put a NULL terminator on the end */
+ (*ppStr)[ulStrLen] = '\0';
+ /* Update the parsing buffer counters */
+ *ppBuf += ulStrLen;
+ *pulLen -= ulStrLen;
+ } else {
+ retVal = HXR_OUTOFMEMORY;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_unpack_buffer(BYTE** ppBuf,
+ UINT32* pulLen,
+ UINT32 ulBufLen,
+ BYTE** ppUnPackBuf,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (ppBuf && pulLen && *pulLen >= ulBufLen && ppUnPackBuf && fpMalloc && fpFree) {
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Do we have a buffer? */
+ if (ulBufLen) {
+ /* If the string is already allocated, free it */
+ if (*ppUnPackBuf) {
+ fpFree(pUserMem, *ppUnPackBuf);
+ *ppUnPackBuf = HXNULL;
+ }
+ /* Allocate a buffer that it one more byte than the length */
+ *ppUnPackBuf = (BYTE*) fpMalloc(pUserMem, ulBufLen);
+ if (*ppUnPackBuf) {
+ /* Copy the string buffer in */
+ memcpy(*ppUnPackBuf, *ppBuf, ulBufLen);
+ /* Update the parsing buffer counters */
+ *ppBuf += ulBufLen;
+ *pulLen -= ulBufLen;
+ } else {
+ retVal = HXR_OUTOFMEMORY;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_unpack_array(BYTE** ppBuf,
+ UINT32* pulLen,
+ UINT32 ulNumElem,
+ UINT32 ulElemSize,
+ void** ppArr,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (ppBuf && pulLen && *pulLen >= ulNumElem * ulElemSize &&
+ ppArr && fpMalloc && fpFree) {
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Do we have any elements? */
+ if (ulNumElem) {
+ /* If the array is already allocated, then free it */
+ if (*ppArr) {
+ fpFree(pUserMem, *ppArr);
+ *ppArr = HXNULL;
+ }
+ /* Allocate space for the array */
+ *ppArr = fpMalloc(pUserMem, ulNumElem * ulElemSize);
+ if (*ppArr) {
+ /* Is this a UINT32 or a UINT16? */
+ UINT32 i = 0;
+ if (ulElemSize == sizeof(UINT32)) {
+ /* Unpack UINT32s */
+ UINT32* pArr32 = (UINT32*) * ppArr;
+ for (i = 0; i < ulNumElem; i++) {
+ pArr32[i] = rm_unpack32(ppBuf, pulLen);
+ }
+ } else if (ulElemSize == sizeof(UINT16)) {
+ /* Unpack UINT16s */
+ UINT16* pArr16 = (UINT16*) * ppArr;
+ for (i = 0; i < ulNumElem; i++) {
+ pArr16[i] = rm_unpack16(ppBuf, pulLen);
+ }
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ } else {
+ retVal = HXR_OUTOFMEMORY;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+UINT32 rm_unpack32_from_byte_string(BYTE** ppBuf, UINT32* pulLen)
+{
+ UINT32 ulRet = 0;
+
+ if (ppBuf && *ppBuf && pulLen && *pulLen) {
+ UINT32 ulStrLen = rm_unpack8(ppBuf, pulLen);
+ if (ulStrLen == 4 && *pulLen >= ulStrLen) {
+ ulRet = rm_unpack32(ppBuf, pulLen);
+ }
+ }
+
+ return ulRet;
+}
diff --git a/audio_codec/libraac/pns.c b/audio_codec/libraac/pns.c
new file mode 100644
index 0000000..179206c
--- a/dev/null
+++ b/audio_codec/libraac/pns.c
@@ -0,0 +1,369 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: pns.c,v 1.2 2005/03/10 17:01:56 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * pns.c - perceptual noise substitution
+ **************************************************************************************/
+
+#include "coder.h"
+
+#include "assembly.h"
+
+
+/**************************************************************************************
+ * Function: Get32BitVal
+ *
+ * Description: generate 32-bit unsigned random number
+ *
+ * Inputs: last number calculated (seed, first time through)
+ *
+ * Outputs: new number, saved in *last
+ *
+ * Return: 32-bit number, uniformly distributed between [0, 2^32)
+ *
+ * Notes: uses simple linear congruential generator
+ **************************************************************************************/
+static unsigned int Get32BitVal(unsigned int *last)
+{
+ unsigned int r = *last;
+
+ /* use same coefs as MPEG reference code (classic LCG)
+ * use unsigned multiply to force reliable wraparound behavior in C (mod 2^32)
+ */
+ r = (1664525U * r) + 1013904223U;
+ *last = r;
+
+ return r;
+}
+
+/* pow(2, i/4.0) for i = [0,1,2,3], format = Q30 */
+static const int pow14[4] = {
+ 0x40000000, 0x4c1bf829, 0x5a82799a, 0x6ba27e65
+};
+
+#define NUM_ITER_INVSQRT 4
+
+#define X0_COEF_2 0xc0000000 /* Q29: -2.0 */
+#define X0_OFF_2 0x60000000 /* Q29: 3.0 */
+#define Q26_3 0x0c000000 /* Q26: 3.0 */
+
+/**************************************************************************************
+ * Function: InvRootR
+ *
+ * Description: use Newton's method to solve for x = 1/sqrt(r)
+ *
+ * Inputs: r in Q30 format, range = [0.25, 1] (normalize inputs to this range)
+ *
+ * Outputs: none
+ *
+ * Return: x = Q29, range = (1, 2)
+ *
+ * Notes: guaranteed to converge and not overflow for any r in this range
+ *
+ * xn+1 = xn - f(xn)/f'(xn)
+ * f(x) = 1/sqrt(r) - x = 0 (find root)
+ * = 1/x^2 - r
+ * f'(x) = -2/x^3
+ *
+ * so xn+1 = xn/2 * (3 - r*xn^2)
+ *
+ * NUM_ITER_INVSQRT = 3, maxDiff = 1.3747e-02
+ * NUM_ITER_INVSQRT = 4, maxDiff = 3.9832e-04
+ **************************************************************************************/
+static int InvRootR(int r)
+{
+ int i, xn, t;
+
+ /* use linear equation for initial guess
+ * x0 = -2*r + 3 (so x0 always >= correct answer in range [0.25, 1))
+ * xn = Q29 (at every step)
+ */
+ xn = (MULSHIFT32(r, X0_COEF_2) << 2) + X0_OFF_2;
+
+ for (i = 0; i < NUM_ITER_INVSQRT; i++) {
+ t = MULSHIFT32(xn, xn); /* Q26 = Q29*Q29 */
+ t = Q26_3 - (MULSHIFT32(r, t) << 2); /* Q26 = Q26 - (Q31*Q26 << 1) */
+ xn = MULSHIFT32(xn, t) << (6 - 1); /* Q29 = (Q29*Q26 << 6), and -1 for division by 2 */
+ }
+
+ /* clip to range (1.0, 2.0)
+ * (because of rounding, this can converge to xn slightly > 2.0 when r is near 0.25)
+ */
+ if (xn >> 30) {
+ xn = (1 << 30) - 1;
+ }
+
+ return xn;
+}
+
+/**************************************************************************************
+ * Function: ScaleNoiseVector
+ *
+ * Description: apply scaling to vector of noise coefficients for one scalefactor band
+ *
+ * Inputs: unscaled coefficients
+ * number of coefficients in vector (one scalefactor band of coefs)
+ * scalefactor for this band (i.e. noise energy)
+ *
+ * Outputs: nVals coefficients in Q(FBITS_OUT_DQ_OFF)
+ *
+ * Return: guard bit mask (OR of abs value of all noise coefs)
+ **************************************************************************************/
+static int ScaleNoiseVector(int *coef, int nVals, int sf)
+{
+ int i, c, spec, energy, sq, scalef, scalei, invSqrtEnergy, z, gbMask;
+
+ energy = 0;
+ for (i = 0; i < nVals; i++) {
+ spec = coef[i];
+
+ /* max nVals = max SFB width = 96, so energy can gain < 2^7 bits in accumulation */
+ sq = (spec * spec) >> 8; /* spec*spec range = (-2^30, 2^30) */
+ energy += sq;
+ }
+
+ /* unless nVals == 1 (or the number generator is broken...), this should not happen */
+ if (energy == 0) {
+ return 0; /* coef[i] must = 0 for i = [0, nVals-1], so gbMask = 0 */
+ }
+
+ /* pow(2, sf/4) * pow(2, FBITS_OUT_DQ_OFF) */
+ scalef = pow14[sf & 0x3];
+ scalei = (sf >> 2) + FBITS_OUT_DQ_OFF;
+
+ /* energy has implied factor of 2^-8 since we shifted the accumulator
+ * normalize energy to range [0.25, 1.0), calculate 1/sqrt(1), and denormalize
+ * i.e. divide input by 2^(30-z) and convert to Q30
+ * output of 1/sqrt(i) now has extra factor of 2^((30-z)/2)
+ * for energy > 0, z is an even number between 0 and 28
+ * final scaling of invSqrtEnergy:
+ * 2^(15 - z/2) to compensate for implicit 2^(30-z) factor in input
+ * +4 to compensate for implicit 2^-8 factor in input
+ */
+ z = CLZ(energy) - 2; /* energy has at least 2 leading zeros (see acc loop) */
+ z &= 0xfffffffe; /* force even */
+ invSqrtEnergy = InvRootR(energy << z); /* energy << z must be in range [0x10000000, 0x40000000] */
+ scalei -= (15 - z / 2 + 4); /* nInt = 1/sqrt(energy) in Q29 */
+
+ /* normalize for final scaling */
+ z = CLZ(invSqrtEnergy) - 1;
+ invSqrtEnergy <<= z;
+ scalei -= (z - 3 - 2); /* -2 for scalef, z-3 for invSqrtEnergy */
+ scalef = MULSHIFT32(scalef, invSqrtEnergy); /* scalef (input) = Q30, invSqrtEnergy = Q29 * 2^z */
+ gbMask = 0;
+
+ if (scalei < 0) {
+ scalei = -scalei;
+ if (scalei > 31) {
+ scalei = 31;
+ }
+ for (i = 0; i < nVals; i++) {
+ c = MULSHIFT32(coef[i], scalef) >> scalei;
+ gbMask |= FASTABS(c);
+ coef[i] = c;
+ }
+ } else {
+ /* for scalei <= 16, no clipping possible (coef[i] is < 2^15 before scaling)
+ * for scalei > 16, just saturate exponent (rare)
+ * scalef is close to full-scale (since we normalized invSqrtEnergy)
+ * remember, we are just producing noise here
+ */
+ if (scalei > 16) {
+ scalei = 16;
+ }
+ for (i = 0; i < nVals; i++) {
+ c = MULSHIFT32(coef[i] << scalei, scalef);
+ coef[i] = c;
+ gbMask |= FASTABS(c);
+ }
+ }
+
+ return gbMask;
+}
+
+/**************************************************************************************
+ * Function: GenerateNoiseVector
+ *
+ * Description: create vector of noise coefficients for one scalefactor band
+ *
+ * Inputs: seed for number generator
+ * number of coefficients to generate
+ *
+ * Outputs: buffer of nVals coefficients, range = [-2^15, 2^15)
+ * updated seed for number generator
+ *
+ * Return: none
+ **************************************************************************************/
+static void GenerateNoiseVector(int *coef, int *last, int nVals)
+{
+ int i;
+
+ for (i = 0; i < nVals; i++) {
+ coef[i] = ((signed int)Get32BitVal((unsigned int *)last)) >> 16;
+ }
+}
+
+/**************************************************************************************
+ * Function: CopyNoiseVector
+ *
+ * Description: copy vector of noise coefficients for one scalefactor band from L to R
+ *
+ * Inputs: buffer of left coefficients
+ * number of coefficients to copy
+ *
+ * Outputs: buffer of right coefficients
+ *
+ * Return: none
+ **************************************************************************************/
+static void CopyNoiseVector(int *coefL, int *coefR, int nVals)
+{
+ int i;
+
+ for (i = 0; i < nVals; i++) {
+ coefR[i] = coefL[i];
+ }
+}
+
+/**************************************************************************************
+ * Function: PNS
+ *
+ * Description: apply perceptual noise substitution, if enabled (MPEG-4 only)
+ *
+ * Inputs: valid AACDecInfo struct
+ * index of current channel
+ *
+ * Outputs: shaped noise in scalefactor bands where PNS is active
+ * updated minimum guard bit count for this channel
+ *
+ * Return: 0 if successful, -1 if error
+ **************************************************************************************/
+int PNS(AACDecInfo *aacDecInfo, int ch)
+{
+ int gp, sfb, win, width, nSamps, gb, gbMask;
+ int *coef;
+ const short *sfbTab;
+ unsigned char *sfbCodeBook;
+ short *scaleFactors;
+ int msMaskOffset, checkCorr, genNew;
+ unsigned char msMask;
+ unsigned char *msMaskPtr;
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ if (!psi->pnsUsed[ch]) {
+ return 0;
+ }
+
+ if (icsInfo->winSequence == 2) {
+ sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_SHORT;
+ } else {
+ sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_LONG;
+ }
+ coef = psi->coef[ch];
+ sfbCodeBook = psi->sfbCodeBook[ch];
+ scaleFactors = psi->scaleFactors[ch];
+ checkCorr = (aacDecInfo->currBlockID == AAC_ID_CPE && psi->commonWin == 1 ? 1 : 0);
+
+ gbMask = 0;
+ for (gp = 0; gp < icsInfo->numWinGroup; gp++) {
+ for (win = 0; win < icsInfo->winGroupLen[gp]; win++) {
+ msMaskPtr = psi->msMaskBits + ((gp * icsInfo->maxSFB) >> 3);
+ msMaskOffset = ((gp * icsInfo->maxSFB) & 0x07);
+ msMask = (*msMaskPtr++) >> msMaskOffset;
+
+ for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) {
+ width = sfbTab[sfb + 1] - sfbTab[sfb];
+ if (sfbCodeBook[sfb] == 13) {
+ if (ch == 0) {
+ /* generate new vector, copy into ch 1 if it's possible that the channels will be correlated
+ * if ch 1 has PNS enabled for this SFB but it's uncorrelated (i.e. ms_used == 0),
+ * the copied values will be overwritten when we process ch 1
+ */
+ GenerateNoiseVector(coef, &psi->pnsLastVal, width);
+ if (checkCorr && psi->sfbCodeBook[1][gp * icsInfo->maxSFB + sfb] == 13) {
+ CopyNoiseVector(coef, psi->coef[1] + (coef - psi->coef[0]), width);
+ }
+ } else {
+ /* generate new vector if no correlation between channels */
+ genNew = 1;
+ if (checkCorr && psi->sfbCodeBook[0][gp * icsInfo->maxSFB + sfb] == 13) {
+ if ((psi->msMaskPresent == 1 && (msMask & 0x01)) || psi->msMaskPresent == 2) {
+ genNew = 0;
+ }
+ }
+ if (genNew) {
+ GenerateNoiseVector(coef, &psi->pnsLastVal, width);
+ }
+ }
+ gbMask |= ScaleNoiseVector(coef, width, psi->scaleFactors[ch][gp * icsInfo->maxSFB + sfb]);
+ }
+ coef += width;
+
+ /* get next mask bit (should be branchless on ARM) */
+ msMask >>= 1;
+ if (++msMaskOffset == 8) {
+ msMask = *msMaskPtr++;
+ msMaskOffset = 0;
+ }
+ }
+ coef += (nSamps - sfbTab[icsInfo->maxSFB]);
+ }
+ sfbCodeBook += icsInfo->maxSFB;
+ scaleFactors += icsInfo->maxSFB;
+ }
+
+ /* update guard bit count if necessary */
+ gb = CLZ(gbMask) - 1;
+ if (psi->gbCurrent[ch] > gb) {
+ psi->gbCurrent[ch] = gb;
+ }
+
+ return 0;
+}
diff --git a/audio_codec/libraac/ra_depack.c b/audio_codec/libraac/ra_depack.c
new file mode 100644
index 0000000..b78c8f0
--- a/dev/null
+++ b/audio_codec/libraac/ra_depack.c
@@ -0,0 +1,230 @@
+#include <memory.h>
+#include "../include/helix_types.h"
+#include "../include/helix_result.h"
+#include "../include/ra_depack.h"
+#include "ra_depack_internal.h"
+#include "../include/rm_memory_default.h"
+#include "../include/rm_error_default.h"
+#include "../include/memory_utils.h"
+#include "../include/stream_hdr_utils.h"
+
+ra_depack* ra_depack_create(void* pAvail,
+ ra_block_avail_func_ptr fpAvail,
+ void* pUserError,
+ rm_error_func_ptr fpError)
+{
+ return ra_depack_create2(pAvail,
+ fpAvail,
+ pUserError,
+ fpError,
+ HXNULL,
+ rm_memory_default_malloc,
+ rm_memory_default_free);
+}
+
+ra_depack* ra_depack_create2(void* pAvail,
+ ra_block_avail_func_ptr fpAvail,
+ void* pUserError,
+ rm_error_func_ptr fpError,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree)
+{
+ ra_depack* pRet = HXNULL;
+
+ if (fpAvail && fpMalloc && fpFree) {
+ /* Allocate space for the ra_depack_internal struct
+ * by using the passed-in malloc function
+ */
+ ra_depack_internal* pInt =
+ (ra_depack_internal*) fpMalloc(pUserMem, sizeof(ra_depack_internal));
+ if (pInt) {
+ /* Zero out the struct */
+ memset((void*) pInt, 0, sizeof(ra_depack_internal));
+ /* Assign the frame callback members */
+ pInt->pAvail = pAvail;
+ pInt->fpAvail = fpAvail;
+ /*
+ * Assign the error members. If the caller did not
+ * provide an error callback, then use the default
+ * rm_error_default().
+ */
+ if (fpError) {
+ pInt->fpError = fpError;
+ pInt->pUserError = pUserError;
+ } else {
+ pInt->fpError = rm_error_default;
+ pInt->pUserError = HXNULL;
+ }
+ /* Assign the memory functions */
+ pInt->fpMalloc = fpMalloc;
+ pInt->fpFree = fpFree;
+ pInt->pUserMem = pUserMem;
+ /* Assign the return value */
+ pRet = (ra_depack*) pInt;
+ }
+ }
+
+ return pRet;
+}
+
+HX_RESULT ra_depack_init(ra_depack* pDepack, rm_stream_header* header)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pDepack && header) {
+ /* Get the internal struct */
+ ra_depack_internal* pInt = (ra_depack_internal*) pDepack;
+ /* Call the internal init */
+ retVal = ra_depacki_init(pInt, header);
+ }
+
+ return retVal;
+}
+
+UINT32 ra_depack_get_num_substreams(ra_depack* pDepack)
+{
+ UINT32 ulRet = 0;
+
+ if (pDepack) {
+ /* Get the internal struct */
+ ra_depack_internal* pInt = (ra_depack_internal*) pDepack;
+ /* Return the number of substreams */
+ ulRet = pInt->multiStreamHdr.ulNumSubStreams;
+ }
+
+ return ulRet;
+}
+
+UINT32 ra_depack_get_codec_4cc(ra_depack* pDepack, UINT32 ulSubStream)
+{
+ UINT32 ulRet = 0;
+
+ if (pDepack) {
+ /* Get the internal struct */
+ ra_depack_internal* pInt = (ra_depack_internal*) pDepack;
+ /* Make sure the substream index is legal */
+ if (pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ ulRet = pInt->pSubStreamHdr[ulSubStream].ulCodecID;
+ }
+ }
+
+ return ulRet;
+}
+
+HX_RESULT ra_depack_get_codec_init_info(ra_depack* pDepack,
+ UINT32 ulSubStream,
+ ra_format_info** ppInfo)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pDepack && ppInfo) {
+ /* Init local variables */
+ UINT32 ulSize = sizeof(ra_format_info);
+ ra_format_info* pInfo = HXNULL;
+ /* Get the internal struct */
+ ra_depack_internal* pInt = (ra_depack_internal*) pDepack;
+ /* Allocate space for the struct */
+ pInfo = ra_depacki_malloc(pInt, ulSize);
+ if (pInfo) {
+ /* NULL out the memory */
+ memset(pInfo, 0, ulSize);
+ /* Fill in the init info struct */
+ retVal = ra_depacki_get_format_info(pInt, ulSubStream, pInfo);
+ if (retVal == HXR_OK) {
+ /* Assign the out parameter */
+ *ppInfo = pInfo;
+ } else {
+ /* We failed so free the memory we allocated */
+ ra_depacki_free(pInt, pInfo);
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void ra_depack_destroy_codec_init_info(ra_depack* pDepack, ra_format_info** ppInfo)
+{
+ if (pDepack && ppInfo && *ppInfo) {
+ /* Get the internal struct */
+ ra_depack_internal* pInt = (ra_depack_internal*) pDepack;
+ /* Clean up the format info struct */
+ ra_depacki_cleanup_format_info(pInt, *ppInfo);
+ /* Delete the memory associated with it */
+ ra_depacki_free(pInt, *ppInfo);
+ /* NULL the pointer out */
+ *ppInfo = HXNULL;
+ }
+}
+
+HX_RESULT ra_depack_add_packet(ra_depack* pDepack, rm_packet* packet)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pDepack && packet) {
+ /* Get the internal struct */
+ ra_depack_internal* pInt = (ra_depack_internal*) pDepack;
+ /* Call the internal function */
+ retVal = ra_depacki_add_packet(pInt, packet);
+ }
+
+ return retVal;
+}
+
+void ra_depack_destroy_block(ra_depack* pDepack, ra_block** ppBlock)
+{
+ if (pDepack && ppBlock && *ppBlock) {
+ /* Get the internal struct */
+ ra_depack_internal* pInt = (ra_depack_internal*) pDepack;
+ /* Free the data */
+ if ((*ppBlock)->pData) {
+ ra_depacki_free(pInt, (*ppBlock)->pData);
+ (*ppBlock)->pData = HXNULL;
+ }
+ /* Free the memory itself */
+ ra_depacki_free(pInt, *ppBlock);
+ /* Null out the pointer */
+ *ppBlock = HXNULL;
+ }
+}
+
+HX_RESULT ra_depack_seek(ra_depack* pDepack, UINT32 ulTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pDepack) {
+ /* Get the internal struct */
+ ra_depack_internal* pInt = (ra_depack_internal*) pDepack;
+ /* Call the internal seek function */
+ retVal = ra_depacki_seek(pInt, ulTime);
+ }
+
+ return retVal;
+}
+
+void ra_depack_destroy(ra_depack** ppDepack)
+{
+ if (ppDepack) {
+ ra_depack_internal* pInt = (ra_depack_internal*) * ppDepack;
+ if (pInt && pInt->fpFree) {
+ /* Save a pointer to fpFree and pUserMem */
+ rm_free_func_ptr fpFree = pInt->fpFree;
+ void* pUserMem = pInt->pUserMem;
+ /* Clean up multistream header */
+ rm_cleanup_multistream_hdr(fpFree, pUserMem, &pInt->multiStreamHdr);
+ /* Clean up rule map */
+ rm_cleanup_rule_map(fpFree, pUserMem, &pInt->rule2Flag);
+ /* Clean up the substream header array */
+ ra_depacki_cleanup_substream_hdr_array(pInt);
+ /* Null everything out */
+ memset(pInt, 0, sizeof(ra_depack_internal));
+ /* Free the rm_parser_internal struct memory */
+ fpFree(pUserMem, pInt);
+ /* NULL out the pointer */
+ *ppDepack = HXNULL;
+ }
+ }
+}
+
diff --git a/audio_codec/libraac/ra_depack_internal.c b/audio_codec/libraac/ra_depack_internal.c
new file mode 100644
index 0000000..4fcdd05
--- a/dev/null
+++ b/audio_codec/libraac/ra_depack_internal.c
@@ -0,0 +1,1713 @@
+#include <stdio.h>
+#include <string.h>
+#include <memory.h>
+#include "../include/helix_types.h"
+#include "../include/helix_result.h"
+#include "../include/pack_utils.h"
+#include "../include/string_utils.h"
+#include "../include/memory_utils.h"
+#include "../include/packet_defines.h"
+#include "../include/codec_defines.h"
+#include "../include/stream_hdr_utils.h"
+#include "ra_depack_internal.h"
+#include "../include/rasl.h"
+
+/* Defines */
+#define TIMESTAMP_GAP_FUDGE_FACTOR 1 /* Maximum non-loss, non-seek gap in ms between packets */
+#define INITIAL_FRAG_BUFFER_SIZE 2048 /* Initial size of frag buffer */
+#define RA_COPY_BUF 0
+
+void* ra_depacki_malloc(ra_depack_internal* pInt, UINT32 ulSize)
+{
+ void* pRet = HXNULL;
+
+ if (pInt && pInt->fpMalloc) {
+ pRet = pInt->fpMalloc(pInt->pUserMem, ulSize);
+ }
+
+ return pRet;
+}
+
+void ra_depacki_free(ra_depack_internal* pInt, void* pMem)
+{
+ if (pInt && pInt->fpFree) {
+ pInt->fpFree(pInt->pUserMem, pMem);
+ }
+}
+
+HX_RESULT ra_depacki_init(ra_depack_internal* pInt, rm_stream_header* hdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && hdr) {
+ /* Initialize local variables */
+ UINT32 ulTmp = 0;
+ BYTE* pTmp = HXNULL;
+ UINT32 i = 0;
+ /* Check if we have a "HasRelativeTS" property - OK if we don't */
+ if (HX_SUCCEEDED(rm_stream_get_property_int(hdr, "TrackStartTime", &ulTmp))) {
+ pInt->bForceTrackStartTime = TRUE;
+ pInt->ulTrackStartTime = ulTmp;
+ }
+ /* Check if we have a "ZeroTimeOffset" property - OK if we don't */
+ if (HX_SUCCEEDED(rm_stream_get_property_int(hdr, "TrackEndTime", &ulTmp))) {
+ pInt->bForceTrackEndTime = TRUE;
+ pInt->ulTrackEndTime = ulTmp;
+ }
+ /* Check if we have an EndTime property */
+ if (HX_SUCCEEDED(rm_stream_get_property_int(hdr, "EndTime", &ulTmp))) {
+ pInt->bHasEndTime = TRUE;
+ pInt->ulEndTime = ulTmp;
+ }
+ /* Copy the stream duration */
+ pInt->ulStreamDuration = hdr->ulDuration;
+ /* If we have an end time, then clip the duration */
+ if (pInt->bHasEndTime &&
+ pInt->ulEndTime &&
+ pInt->ulStreamDuration > pInt->ulEndTime) {
+ pInt->ulStreamDuration = pInt->ulEndTime;
+ }
+ if (pInt->ulStreamDuration == 0) {
+ pInt->ulStreamDuration = 0x7fffffff;
+ }
+ /* Check if we have a "RMFF 1.0 Flags" property */
+ retVal = rm_stream_get_property_buf(hdr, "RMFF 1.0 Flags", &pTmp, &ulTmp);
+ if (retVal == HXR_OK) {
+ /* Parse the "RMFF 1.0 Flags" property */
+ retVal = ra_depacki_unpack_rule_map(pInt, &pInt->rule2Flag,
+ &pTmp, &ulTmp);
+ if (retVal == HXR_OK) {
+ /* Get the "OpaqueData" property */
+ retVal = rm_stream_get_property_buf(hdr, "OpaqueData", &pTmp, &ulTmp);
+ if (retVal == HXR_OK) {
+ /* Unpack the opaque data */
+ retVal = ra_depacki_unpack_opaque_data(pInt, pTmp, ulTmp);
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_unpack_rule_map(ra_depack_internal* pInt,
+ rm_rule_map* pMap,
+ BYTE** ppBuf,
+ UINT32* pulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ retVal = rm_unpack_rule_map(ppBuf, pulLen,
+ pInt->fpMalloc,
+ pInt->fpFree,
+ pInt->pUserMem,
+ pMap);
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_unpack_multistream_hdr(ra_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ retVal = rm_unpack_multistream_hdr(ppBuf, pulLen,
+ pInt->fpMalloc,
+ pInt->fpFree,
+ pInt->pUserMem,
+ &pInt->multiStreamHdr);
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_unpack_opaque_data(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pBuf && ulLen >= 4) {
+ /* Initialize local variables */
+ UINT32 ulSize = 0;
+ UINT32 ulID = 0;
+ UINT32 i = 0;
+ UINT32 ulTmp = 0;
+ /*
+ * If the first four bytes are MLTI, then we
+ * know the opaque data contains a multistream header
+ * followed by several normal headers. So first we
+ * need to check the first four bytes.
+ */
+ ulID = rm_unpack32(&pBuf, &ulLen);
+ /* Now back up 4 bytes */
+ pBuf -= 4;
+ ulLen += 4;
+ /* Is this a multistream header? */
+ if (ulID == RM_MULTIHEADER_OBJECT) {
+ /* Unpack the multistream header */
+ retVal = ra_depacki_unpack_multistream_hdr(pInt, &pBuf, &ulLen);
+ if (retVal == HXR_OK) {
+ pInt->bStreamSwitchable = TRUE;
+ }
+ } else if (ulID == RA_FORMAT_ID) {
+ /* Single-rate stream */
+ pInt->multiStreamHdr.ulNumSubStreams = 1;
+ /* Clear the stream switchable flag */
+ pInt->bStreamSwitchable = FALSE;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ /* Clean up any existing substream header array */
+ ra_depacki_cleanup_substream_hdr_array(pInt);
+ /* Set the return value */
+ retVal = HXR_FAIL;
+ /* Allocate space for substream header array */
+ ulSize = pInt->multiStreamHdr.ulNumSubStreams * sizeof(ra_substream_hdr);
+ pInt->pSubStreamHdr = (ra_substream_hdr*) ra_depacki_malloc(pInt, ulSize);
+ if (pInt->pSubStreamHdr) {
+ /* NULL out the memory */
+ memset(pInt->pSubStreamHdr, 0, ulSize);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Loop through and unpack each substream header */
+ for (i = 0; i < pInt->multiStreamHdr.ulNumSubStreams && retVal == HXR_OK; i++) {
+ /* Is this a multiheader? */
+ if (pInt->bStreamSwitchable) {
+ /*
+ * If this is a multistream header, then there
+ * is a 4-byte length in front of every substream header
+ */
+ if (ulLen >= 4) {
+ ulSize = rm_unpack32(&pBuf, &ulLen);
+ } else {
+ retVal = HXR_FAIL;
+ }
+ } else {
+ /*
+ * If this is not a multi-stream header, then
+ * the rest of the buffer is a single substream header
+ */
+ ulSize = ulLen;
+ }
+ /* Make sure we have enough parsing buffer */
+ if (ulLen >= ulSize) {
+ /* Now unpack an substream header */
+ retVal = ra_depacki_unpack_substream_hdr(pInt, pBuf, ulSize,
+ &pInt->pSubStreamHdr[i]);
+ if (retVal == HXR_OK) {
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[i];
+ /*
+ * If the interleaver ID is either VBRS of VBRF,
+ * then this is a VBR stream.
+ */
+ if (pHdr->ulInterleaverID == RA_INTERLEAVER_VBRS ||
+ pHdr->ulInterleaverID == RA_INTERLEAVER_VBRF) {
+ pHdr->bIsVBR = TRUE;
+ }
+ /* Compute the number of codec frames per superblock */
+ if (pHdr->ulCodecFrameSize) {
+ pHdr->ulNumCodecFrames = pHdr->ulInterleaveBlockSize *
+ pHdr->ulInterleaveFactor /
+ pHdr->ulCodecFrameSize;
+ }
+ /* Compute the ms per block */
+ if (pHdr->ulBytesPerMin) {
+ pHdr->dBlockDuration = ((double) pHdr->ulInterleaveBlockSize) *
+ 60000.0 /
+ ((double) pHdr->ulBytesPerMin);
+ }
+ /* Compute the superblock size and time */
+ pHdr->ulSuperBlockSize = pHdr->ulInterleaveBlockSize *
+ pHdr->ulInterleaveFactor;
+ pHdr->ulSuperBlockTime = (UINT32)(pHdr->dBlockDuration *
+ ((double) pHdr->ulInterleaveFactor));
+ /* Is this stream VBR? */
+ if (pHdr->bIsVBR) {
+ /* Init the last sent block end time */
+ pHdr->ulLastSentEndTime = 0;
+ /*
+ * Init the frag buffer members. The frag buffer
+ * willl be set up the first time it is needed.
+ */
+ pHdr->pFragBuffer = HXNULL;
+ pHdr->ulFragBufferSize = 0;
+ pHdr->ulFragBufferOffset = 0;
+ pHdr->ulFragBufferTime = 0;
+ } else {
+ /* Set the return value */
+ retVal = HXR_OUTOFMEMORY;
+ /* Set the superblock keyframe time */
+ pHdr->bHasKeyTime = FALSE;
+ pHdr->ulKeyTime = 0;
+ /* Allocate the interleaved buffer */
+ pHdr->pIBuffer = (BYTE*) ra_depacki_malloc(pInt, pHdr->ulSuperBlockSize);
+ if (pHdr->pIBuffer) {
+ /* Zero out the buffer */
+ memset(pHdr->pIBuffer, 0, pHdr->ulSuperBlockSize);
+ /* Allocate the de-interleaved buffer */
+ pHdr->pDBuffer = (BYTE*) ra_depacki_malloc(pInt, pHdr->ulSuperBlockSize);
+ if (pHdr->pDBuffer) {
+ /* Zero out the buffer */
+ memset(pHdr->pDBuffer, 0, pHdr->ulSuperBlockSize);
+ /* Allocate the interleaved flags */
+ ulTmp = pHdr->ulInterleaveFactor * sizeof(UINT32);
+ pHdr->pIPresentFlags = (UINT32*) ra_depacki_malloc(pInt, ulTmp);
+ if (pHdr->pIPresentFlags) {
+ /* Zero out the flags */
+ memset(pHdr->pIPresentFlags, 0, ulTmp);
+ /* Allocate the de-interleaved flags */
+ pHdr->pDPresentFlags = (UINT32*) ra_depacki_malloc(pInt, ulTmp);
+ if (pHdr->pDPresentFlags) {
+ /* Null out the memory */
+ memset(pHdr->pDPresentFlags, 0, ulTmp);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* If this is GENR interleaving, then init the tables */
+ if (pHdr->ulInterleaverID == RA_INTERLEAVER_GENR) {
+ retVal = ra_depacki_init_genr(pInt, i);
+ }
+ }
+ }
+ }
+ }
+ }
+ /* Update the buffer cursors */
+ pBuf += ulSize;
+ ulLen -= ulSize;
+ }
+ } else {
+ retVal = HXR_FAIL;
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void ra_depacki_cleanup_substream_hdr(ra_depack_internal* pInt,
+ ra_substream_hdr* hdr)
+{
+ if (pInt && hdr) {
+ if (hdr->pulInterleavePattern) {
+ ra_depacki_free(pInt, hdr->pulInterleavePattern);
+ hdr->pulInterleavePattern = HXNULL;
+ }
+ if (hdr->pOpaqueData) {
+ ra_depacki_free(pInt, hdr->pOpaqueData);
+ hdr->pOpaqueData = HXNULL;
+ }
+ if (hdr->pFragBuffer) {
+ ra_depacki_free(pInt, hdr->pFragBuffer);
+ hdr->pFragBuffer = HXNULL;
+ }
+ if (hdr->pIBuffer) {
+ ra_depacki_free(pInt, hdr->pIBuffer);
+ hdr->pIBuffer = HXNULL;
+ }
+ if (hdr->pDBuffer) {
+ ra_depacki_free(pInt, hdr->pDBuffer);
+ hdr->pDBuffer = HXNULL;
+ }
+ if (hdr->pIPresentFlags) {
+ ra_depacki_free(pInt, hdr->pIPresentFlags);
+ hdr->pIPresentFlags = HXNULL;
+ }
+ if (hdr->pDPresentFlags) {
+ ra_depacki_free(pInt, hdr->pDPresentFlags);
+ hdr->pDPresentFlags = HXNULL;
+ }
+ if (hdr->pulGENRPattern) {
+ ra_depacki_free(pInt, hdr->pulGENRPattern);
+ hdr->pulGENRPattern = HXNULL;
+ }
+ if (hdr->pulGENRBlockNum) {
+ ra_depacki_free(pInt, hdr->pulGENRBlockNum);
+ hdr->pulGENRBlockNum = HXNULL;
+ }
+ if (hdr->pulGENRBlockOffset) {
+ ra_depacki_free(pInt, hdr->pulGENRBlockOffset);
+ hdr->pulGENRBlockOffset = HXNULL;
+ }
+ }
+}
+
+void ra_depacki_cleanup_substream_hdr_array(ra_depack_internal* pInt)
+{
+ if (pInt && pInt->pSubStreamHdr) {
+ UINT32 i = 0;
+ for (i = 0; i < pInt->multiStreamHdr.ulNumSubStreams; i++) {
+ ra_depacki_cleanup_substream_hdr(pInt, &pInt->pSubStreamHdr[i]);
+ }
+ /* Free the header array */
+ ra_depacki_free(pInt, pInt->pSubStreamHdr);
+ /* NULL out the pointer */
+ pInt->pSubStreamHdr = HXNULL;
+ }
+}
+
+HX_RESULT ra_depacki_unpack_substream_hdr(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ ra_substream_hdr* pHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pBuf && ulLen >= 6 && pHdr) {
+ UINT32 ulID = 0;
+ UINT16 usVersion = 0;
+ /* Clean up any existing header info */
+ ra_depacki_cleanup_substream_hdr(pInt, pHdr);
+ /* Read the ID and the RAFormat version */
+ ulID = rm_unpack32(&pBuf, &ulLen);
+ usVersion = rm_unpack16(&pBuf, &ulLen);
+ /* Sanity check on ID */
+ if (ulID == RA_FORMAT_ID) {
+ /* Switch based on RAFormat version */
+ switch (usVersion) {
+ case 3:
+ retVal = ra_depacki_unpack_raformat3(pInt, pBuf, ulLen, pHdr);
+ break;
+ case 4:
+ retVal = ra_depacki_unpack_raformat4(pInt, pBuf, ulLen, pHdr);
+ break;
+ case 5:
+ retVal = ra_depacki_unpack_raformat5(pInt, pBuf, ulLen, pHdr);
+ break;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_unpack_raformat3(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ ra_substream_hdr* pHdr)
+{
+ return HXR_NOTIMPL;
+}
+
+HX_RESULT ra_depacki_unpack_raformat4(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ ra_substream_hdr* pHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pBuf && ulLen >= 63 && pHdr) {
+ /* Init local variables */
+ UINT32 ulSize = 0;
+ UINT32 i = 0;
+ /* Skip first 10 bytes */
+ pBuf += 10;
+ ulLen -= 10;
+ /* Read the version and revision */
+ pHdr->usRAFormatVersion = rm_unpack16(&pBuf, &ulLen);
+ pHdr->usRAFormatRevision = rm_unpack16(&pBuf, &ulLen);
+ /* Sanity check */
+ if (pHdr->usRAFormatVersion == 4 &&
+ pHdr->usRAFormatRevision == 0) {
+ pHdr->usHeaderBytes = rm_unpack16(&pBuf, &ulLen);
+ pHdr->usFlavorIndex = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulGranularity = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulTotalBytes = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulBytesPerMin = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulBytesPerMin2 = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulInterleaveFactor = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulInterleaveBlockSize = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulUserData = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulSampleRate = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulSampleRate >>= 16;
+ pHdr->ulSampleSize = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulChannels = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulInterleaverID = rm_unpack32_from_byte_string(&pBuf, &ulLen);
+ pHdr->ulCodecID = rm_unpack32_from_byte_string(&pBuf, &ulLen);
+ pHdr->bIsInterleaved = rm_unpack8(&pBuf, &ulLen);
+ pHdr->bCopyByte = rm_unpack8(&pBuf, &ulLen);
+ pHdr->ucStreamType = rm_unpack8(&pBuf, &ulLen);
+ /*
+ * If the bIsInterleaved flag says we are
+ * not interleaved, then make sure the
+ * interleaverID is set to no interleaver.
+ */
+ if (!pHdr->bIsInterleaved) {
+ pHdr->ulInterleaverID = RA_NO_INTERLEAVER;
+ }
+ /* If the interleave factor is 0, make it 1. */
+ if (!pHdr->ulInterleaveFactor) {
+ pHdr->ulInterleaveFactor = 1;
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_unpack_raformat5(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ ra_substream_hdr* pHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pBuf && ulLen >= 68 && pHdr) {
+ /* Init local variables */
+ UINT32 ulSize = 0;
+ UINT32 i = 0;
+ /* Skip first 10 bytes */
+ pBuf += 10;
+ ulLen -= 10;
+ /* Read the version and revision */
+ pHdr->usRAFormatVersion = rm_unpack16(&pBuf, &ulLen);
+ pHdr->usRAFormatRevision = rm_unpack16(&pBuf, &ulLen);
+ /* Sanity check */
+ if (pHdr->usRAFormatVersion == 5 &&
+ pHdr->usRAFormatRevision == 0) {
+ pHdr->usHeaderBytes = rm_unpack16(&pBuf, &ulLen);
+ pHdr->usFlavorIndex = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulGranularity = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulTotalBytes = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulBytesPerMin = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulBytesPerMin2 = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulInterleaveFactor = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulInterleaveBlockSize = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulCodecFrameSize = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulUserData = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulSampleRate = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulSampleRate >>= 16;
+ pHdr->ulActualSampleRate = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulActualSampleRate >>= 16;
+ pHdr->ulSampleSize = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulChannels = rm_unpack16(&pBuf, &ulLen);
+ pHdr->ulInterleaverID = rm_unpack32(&pBuf, &ulLen);
+ pHdr->ulCodecID = rm_unpack32(&pBuf, &ulLen);
+ pHdr->bIsInterleaved = rm_unpack8(&pBuf, &ulLen);
+ pHdr->bCopyByte = rm_unpack8(&pBuf, &ulLen);
+ pHdr->ucStreamType = rm_unpack8(&pBuf, &ulLen);
+ pHdr->ucScatterType = rm_unpack8(&pBuf, &ulLen);
+ pHdr->ulNumCodecFrames = pHdr->ulInterleaveFactor *
+ pHdr->ulInterleaveBlockSize /
+ pHdr->ulCodecFrameSize;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /*
+ * If ucScatterType is non-zero, then we have
+ * to read in an interleave pattern.
+ */
+ if (pHdr->ucScatterType) {
+ /* Set the return value */
+ retVal = HXR_FAIL;
+ /* Allocate space for the interleave pattern */
+ ulSize = pHdr->ulNumCodecFrames * sizeof(UINT32);
+ pHdr->pulInterleavePattern = ra_depacki_malloc(pInt, ulSize);
+ if (pHdr->pulInterleavePattern) {
+ /* NULL out all the memory */
+ memset(pHdr->pulInterleavePattern, 0, ulSize);
+ /* Make sure we have enough parsing buffer left */
+ if (ulLen >= ulSize) {
+ /* Read in the interleave pattern */
+ for (i = 0; i < pHdr->ulNumCodecFrames; i++) {
+ pHdr->pulInterleavePattern[i] = rm_unpack16(&pBuf, &ulLen);
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ if (retVal == HXR_OK) {
+ /* Set the return value */
+ retVal = HXR_FAIL;
+ /* Make sure we have four bytes */
+ if (ulLen >= 4) {
+ /* Read in the opaque data size */
+ pHdr->ulOpaqueDataSize = rm_unpack32(&pBuf, &ulLen);
+ /* Make sure we have this much parsing space left */
+ if ((ulLen >= pHdr->ulOpaqueDataSize) && (pHdr->ulOpaqueDataSize > 0)) {
+ /* Allocate the buffer */
+ pHdr->pOpaqueData = ra_depacki_malloc(pInt, pHdr->ulOpaqueDataSize);
+ if (pHdr->pOpaqueData) {
+ /* Copy the opaque data */
+ memcpy(pHdr->pOpaqueData, pBuf, pHdr->ulOpaqueDataSize);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /*
+ * If the bIsInterleaved flag says we are
+ * not interleaved, then make sure the
+ * interleaverID is set to no interleaver.
+ */
+ if (!pHdr->bIsInterleaved) {
+ pHdr->ulInterleaverID = RA_NO_INTERLEAVER;
+ }
+ /* If the interleave factor is 0, make it 1. */
+ if (!pHdr->ulInterleaveFactor) {
+ pHdr->ulInterleaveFactor = 1;
+ }
+ }
+ } else if (pHdr->ulOpaqueDataSize == 0) {
+ retVal = HXR_OK;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_get_format_info(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ ra_format_info* pInfo)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInfo && pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Init local variables */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ if (pHdr) {
+ /* Clean up any existing format info */
+ ra_depacki_cleanup_format_info(pInt, pInfo);
+ /* Assign members */
+ pInfo->ulSampleRate = pHdr->ulSampleRate;
+ pInfo->ulActualRate = pHdr->ulActualSampleRate;
+ pInfo->usBitsPerSample = (UINT16) pHdr->ulSampleSize;
+ pInfo->usNumChannels = (UINT16) pHdr->ulChannels;
+ pInfo->usAudioQuality = 100;
+ pInfo->usFlavorIndex = pHdr->usFlavorIndex;
+ pInfo->ulBitsPerFrame = pHdr->ulCodecFrameSize;
+ pInfo->ulGranularity = pHdr->ulGranularity;
+ pInfo->ulOpaqueDataSize = pHdr->ulOpaqueDataSize;
+ /* Copy the opaque data buffer */
+ pInfo->pOpaqueData = copy_buffer(pInt->pUserMem,
+ pInt->fpMalloc,
+ pHdr->pOpaqueData,
+ pHdr->ulOpaqueDataSize);
+ if (!pInfo->ulOpaqueDataSize || pInfo->pOpaqueData) {
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void ra_depacki_cleanup_format_info(ra_depack_internal* pInt,
+ ra_format_info* pInfo)
+{
+ if (pInt && pInfo && pInfo->pOpaqueData) {
+ ra_depacki_free(pInt, pInfo->pOpaqueData);
+ pInfo->pOpaqueData = HXNULL;
+ }
+}
+
+UINT32 ra_depacki_rule_to_flags(ra_depack_internal* pInt, UINT32 ulRule)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt && pInt->rule2Flag.pulMap &&
+ ulRule < pInt->rule2Flag.ulNumRules) {
+ ulRet = pInt->rule2Flag.pulMap[ulRule];
+ }
+
+ return ulRet;
+}
+
+HXBOOL ra_depacki_is_keyframe_rule(ra_depack_internal* pInt, UINT32 ulRule)
+{
+ UINT32 ulFlag = ra_depacki_rule_to_flags(pInt, ulRule);
+ return (ulFlag & HX_KEYFRAME_FLAG ? TRUE : FALSE);
+}
+
+UINT32 ra_depacki_rule_to_substream(ra_depack_internal* pInt, UINT32 ulRule)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt && pInt->multiStreamHdr.rule2SubStream.pulMap &&
+ ulRule < pInt->multiStreamHdr.rule2SubStream.ulNumRules) {
+ ulRet = pInt->multiStreamHdr.rule2SubStream.pulMap[ulRule];
+ }
+
+ return ulRet;
+}
+
+HX_RESULT ra_depacki_add_packet(ra_depack_internal* pInt,
+ rm_packet* pPacket)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pPacket) {
+ /* Init local variables */
+ UINT32 i = 0;
+ /* Was this packet lost? */
+ if (!pPacket->ucLost) {
+ /* This packet was not lost, so we can look up the substream. */
+ UINT32 ulSubStream = ra_depacki_rule_to_substream(pInt, pPacket->ucASMRule);
+ /* Sanity check */
+ if (pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Is this substream VBR? */
+ if (pInt->pSubStreamHdr[ulSubStream].bIsVBR) {
+ /* Add the VBR packet */
+ retVal = ra_depacki_add_vbr_packet(pInt, ulSubStream, pPacket);
+ } else {
+ /* Add the non-VBR packet */
+ retVal = ra_depacki_add_non_vbr_packet(pInt, ulSubStream, pPacket);
+ }
+ }
+ } else {
+ /* Are we multistream or single-stream? */
+ if (pInt->bStreamSwitchable) {
+ /*
+ * We are multi-stream. Therefore, we don't know which
+ * substream this packet came from. So we simply set the
+ * flag saying some loss happened in each substream.
+ */
+ for (i = 0; i < pInt->multiStreamHdr.ulNumSubStreams; i++) {
+ pInt->pSubStreamHdr[i].bLossOccurred = TRUE;
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ } else {
+ /*
+ * We are single substream, so we just pass the
+ * lost packet on. It has to be substream 0, of course.
+ */
+ if (pInt->pSubStreamHdr &&
+ pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Is the single substream VBR? */
+ if (pInt->pSubStreamHdr[0].bIsVBR) {
+ retVal = ra_depacki_add_vbr_packet(pInt, 0, pPacket);
+ } else {
+ retVal = ra_depacki_add_non_vbr_packet(pInt, 0, pPacket);
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_add_vbr_packet(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ rm_packet* pPacket)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pPacket) {
+ /* Is the packet lost? */
+ if (!pPacket->ucLost) {
+ /* Packet was not lost */
+ if (pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /* Init local variables */
+ UINT32 ulNumAU = 0;
+ HXBOOL bFrag = FALSE;
+ UINT32 ulAUSize = 0;
+ UINT32 ulAUFragSize = 0;
+ UINT32 i = 0;
+ /* Parse this VBR packet */
+ retVal = ra_depacki_parse_vbr_packet(pInt, pPacket, &ulNumAU, &bFrag,
+ &ulAUSize, &ulAUFragSize);
+ if (retVal == HXR_OK) {
+ /*
+ * Are we within the tolerance? We expect to
+ * be if we didn't seek. Otherwise, we had loss.
+ */
+ if (pPacket->ulTime > pHdr->ulLastSentEndTime + TIMESTAMP_GAP_FUDGE_FACTOR &&
+ !pHdr->bSeeked) {
+ /* We need to send some loss packets */
+ retVal = ra_depacki_generate_and_send_loss(pInt,
+ ulSubStream,
+ pHdr->ulLastSentEndTime,
+ pPacket->ulTime);
+ if (retVal == HXR_OK) {
+ pHdr->ulLastSentEndTime = pPacket->ulTime;
+ }
+ }
+ /* Have we just seeked? */
+ if (pHdr->bSeeked) {
+ /* Clear any remaining fragment */
+ ra_depacki_clear_frag_buffer(pInt, pHdr);
+ /* Set the last sent time to this time */
+ pHdr->ulLastSentEndTime = pPacket->ulTime;
+ /* Clear the seeked flag */
+ pHdr->bSeeked = FALSE;
+ }
+ /* Does this packet hold a fragmented AU? */
+ if (bFrag) {
+ /* Handle the fragmented packet */
+ retVal = ra_depacki_handle_frag_packet(pInt, ulSubStream, pPacket,
+ ulAUSize, ulAUFragSize);
+ } else {
+ /* Handle the non-fragmented packet */
+ retVal = ra_depacki_handle_nonfrag_packet(pInt, ulSubStream,
+ pPacket, ulNumAU);
+ }
+ }
+ }
+ } else {
+ /* Packet is lost - not an error */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_add_non_vbr_packet(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ rm_packet* pPacket)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pPacket && pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Init local variables */
+ HXBOOL bKey = FALSE;
+ HXDOUBLE dTimeDiff = 0.0;
+ HXDOUBLE dBlockNum = 0;
+ UINT32 ulBlockNum = 0;
+ HXDOUBLE dTSOffset = 0.0;
+ UINT32 ulTSOffset = 0;
+ UINT32 ulPacketTime = pPacket->ulTime;
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /* Is the packet lost? */
+ if (!pPacket->ucLost) {
+ /* Is this a keyframe packet? */
+ bKey = ra_depacki_is_keyframe_rule(pInt, pPacket->ucASMRule);
+ /*
+ * We need to determine the index of this block
+ * in this superblock. We will do this by knowing
+ * the timestamp of this packet (block), the timestamp
+ * of the key block in this superblock, and the block
+ * duration. First we make sure we have a key block time.
+ */
+ if (bKey && !pHdr->bHasKeyTime) {
+ /* We note the timestamp of this key block */
+ pHdr->ulKeyTime = pPacket->ulTime;
+ /* Set the flag saying we have a key time */
+ pHdr->bHasKeyTime = TRUE;
+ }
+ /* Now we should have a key time */
+ if (pHdr->bHasKeyTime && ulPacketTime >= pHdr->ulKeyTime) {
+ /*
+ * Have we yet determined whether or
+ * not we need to adjust timestamps?
+ */
+ if (!pHdr->bKnowIfAdjustNeeded) {
+ /*
+ * If the last packet was not lost and was a
+ * keyframe and this packet is not a keyframe
+ * and the timestamps are the same, then we need
+ * to adjust timestamps.
+ */
+ if (pHdr->bHasLastPacket &&
+ !pHdr->lastPacket.ucLost &&
+ !bKey) {
+ /* Is this timestamp the same as the last packets? */
+ if (ulPacketTime == pHdr->lastPacket.ulTime) {
+ pHdr->bAdjustTimestamps = TRUE;
+ } else {
+ pHdr->bAdjustTimestamps = FALSE;
+ }
+ /* Now we know */
+ pHdr->bKnowIfAdjustNeeded = TRUE;
+ }
+ }
+ /* Do we need to adjust timestamps? */
+ if (pHdr->bKnowIfAdjustNeeded &&
+ pHdr->bAdjustTimestamps &&
+ !bKey) {
+ dTSOffset = pHdr->ulBlockCount * pHdr->dBlockDuration;
+ ulTSOffset = (UINT32)(dTSOffset + 0.5);
+ ulPacketTime += ulTSOffset;
+ }
+ /* Compute the index of the block within the superblock */
+ dTimeDiff = (HXDOUBLE)(ulPacketTime - pHdr->ulKeyTime);
+#ifndef __ARC600__
+ if (pHdr->dBlockDuration)
+#else
+ if (pHdr->dBlockDuration == 0.0) {
+ ;
+ } else
+#endif
+ {
+ dBlockNum = dTimeDiff / pHdr->dBlockDuration;
+ }
+ ulBlockNum = (UINT32)(dBlockNum + 0.5);
+ /* Is this block beyond our superblock? */
+ if (ulBlockNum >= pHdr->ulInterleaveFactor) {
+ /*
+ * We must have had loss at the end of the
+ * previous superblock, since we have received
+ * a packet in the next superblock without having
+ * sent the current superblock. Therefore, we attempt
+ * to finish out the current superblock and send it.
+ */
+ retVal = ra_depacki_deinterleave_send(pInt, ulSubStream);
+ if (retVal == HXR_OK) {
+ /* Now we need to update the block index */
+ if (bKey) {
+ /*
+ * This packet is a keyframe packet, so
+ * we simply assign the new time and set
+ * the block index to 0.
+ */
+ pHdr->ulKeyTime = pPacket->ulTime;
+ ulBlockNum = 0;
+ } else {
+ /*
+ * This is not a keyframe packet, so we need to
+ * keep adding the superblock time to the key time
+ * and keep subtracting interleave factor to the block
+ * index until we reach the range [0,intereaveFactor-1]
+ * for the index.
+ */
+ do {
+ pHdr->ulKeyTime += pHdr->ulSuperBlockTime;
+ ulBlockNum -= pHdr->ulInterleaveFactor;
+ } while (ulBlockNum < pHdr->ulInterleaveFactor);
+ }
+ }
+ }
+ /* Sanity check on buffer copy parameters */
+ if (ulBlockNum < pHdr->ulInterleaveFactor &&
+ ((UINT32) pPacket->usDataLen) == pHdr->ulInterleaveBlockSize &&
+ pHdr->pIPresentFlags) {
+ /* Copy the data into the interleave buffer */
+ memcpy(pHdr->pIBuffer + ulBlockNum * pHdr->ulInterleaveBlockSize,
+ pPacket->pData,
+ pHdr->ulInterleaveBlockSize);
+ /* Set all the flags to be present for this block */
+ pHdr->pIPresentFlags[ulBlockNum] = 0xFFFFFFFF;
+ /* Increment the block count in this superblock */
+ pHdr->ulBlockCount++;
+ /* Is this the last block in the superblock? */
+ if (ulBlockNum == pHdr->ulInterleaveFactor - 1) {
+ /* Deinterleave and send the blocks */
+ retVal = ra_depacki_deinterleave_send(pInt, ulSubStream);
+ } else {
+ /* Not ready to send yet. Clear the return */
+ retVal = HXR_OK;
+ }
+ }
+ } else {
+ /*
+ * We don't have a key block time or the key block time
+ * that we have is greater than the packet time, so we
+ * can't compute what slot this block should be in. This
+ * probably occurred because of loss at the beginning of the
+ * stream. We have to throw this packet away.
+ */
+ retVal = HXR_OK;
+ }
+ } else {
+ /*
+ * The packet was lost. For now, don't do anything
+ * with the packet. We will deduce loss based entirely
+ * on timestamps for now.
+ */
+ retVal = HXR_OK;
+ }
+ /* Save the information about the last packet */
+ pHdr->lastPacket.ulTime = pPacket->ulTime;
+ pHdr->lastPacket.usStream = pPacket->usStream;
+ pHdr->lastPacket.usASMFlags = pPacket->usASMFlags;
+ pHdr->lastPacket.ucASMRule = pPacket->ucASMRule;
+ pHdr->lastPacket.ucLost = pPacket->ucLost;
+ pHdr->bHasLastPacket = TRUE;
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_parse_vbr_packet(ra_depack_internal* pInt,
+ rm_packet* pPacket,
+ UINT32* pulNumAU,
+ HXBOOL* pbFragmented,
+ UINT32* pulAUSize,
+ UINT32* pulAUFragSize)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pPacket && pulNumAU && pbFragmented &&
+ pulAUSize && pulAUFragSize &&
+ pPacket->pData && pPacket->usDataLen) {
+ /* Init local variables */
+ BYTE* pBuf = pPacket->pData;
+ UINT32 ulSize = pPacket->usDataLen;
+ UINT32 ulPacketSize = ulSize;
+ UINT32 ulAUHeaderSizeBits = 0;
+ UINT32 ulAUHeaderSize = 0;
+ UINT32 ulNumAU = 0;
+ UINT32 ulAUSize = 0;
+ UINT32 ulAUSizeTotal = 0;
+ UINT32 i = 0;
+ UINT32 ulExpectedSize = 0;
+ /* Sanity check on size */
+ if (ulSize >= 2) {
+ /* Get the AU header size in bits */
+ ulAUHeaderSizeBits = rm_unpack16(&pBuf, &ulSize);
+ /* Convert to bytes (rounding up to next byte) */
+ ulAUHeaderSize = (ulAUHeaderSizeBits + 7) >> 3;
+ /*
+ * Sanity check to make sure that the AU header size is
+ * greater than 0 and a multiple of 2 bytes
+ */
+ if (ulAUHeaderSize && !(ulAUHeaderSize & 1)) {
+ /*
+ * Since we know that each AU header is 2 bytes, then
+ * we know that the number of AU's in this packet is
+ * ulAUHeaderSize / 2.
+ */
+ ulNumAU = ulAUHeaderSize >> 1;
+ /*
+ * The audio/mpeg-generic spec says that each packet
+ * can either have a complete AU, a fragment of a single
+ * AU, or multiple complete AUs. Therefore, if the
+ * number of AUs is greater than 1, then we know we
+ * have ulNumAU *complete* AUs. Therefore, for more
+ * than one AU, we know what the exact size of the
+ * packet should be, and that should match up with
+ * the data size of the packet.
+ */
+ retVal = HXR_OK;
+ for (i = 0; i < ulNumAU && retVal == HXR_OK; i++) {
+ if (ulSize >= 2) {
+ ulAUSize = rm_unpack16(&pBuf, &ulSize);
+ ulAUSizeTotal += ulAUSize;
+ } else {
+ retVal = HXR_FAIL;
+ }
+ }
+ if (retVal == HXR_OK) {
+ /* Compute the expected size of the packet */
+ ulExpectedSize = 2 + /* AU header size (16 bits) */
+ ulNumAU * 2 + /* AU sizes */
+ ulAUSizeTotal; /* the AU's themselves */
+ /*
+ * Check this against the actual size. If we have
+ * 1 AU, then the expected size can be greater than
+ * the actual size due to fragmentation. If we have
+ * more than more AU, then the expected size MUST
+ * match the actual size.
+ */
+ if (ulNumAU > 1) {
+ if (ulExpectedSize == ulPacketSize) {
+ /* Multiple AUs, no fragmentation */
+ *pbFragmented = FALSE;
+ } else {
+ /* Something wrong */
+ retVal = HXR_FAIL;
+ }
+ } else if (ulNumAU == 1) {
+ if (ulExpectedSize > ulPacketSize) {
+ /* Fragmented single AU */
+ *pbFragmented = TRUE;
+ } else {
+ /* Single AU, no fragmentation */
+ *pbFragmented = FALSE;
+ }
+ /* Set the AU size */
+ *pulAUSize = ulAUSizeTotal;
+ *pulAUFragSize = ulPacketSize - 4;
+ }
+ /* Assign the number of AU out parameter */
+ if (retVal == HXR_OK) {
+ *pulNumAU = ulNumAU;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_generate_and_send_loss(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ UINT32 ulFirstStartTime,
+ UINT32 ulLastEndTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && ulSubStream < pInt->multiStreamHdr.ulNumSubStreams &&
+ ulLastEndTime > ulFirstStartTime) {
+ HXDOUBLE dAUDuration = pInt->pSubStreamHdr[ulSubStream].dBlockDuration;
+ HXDOUBLE dDiff = ulLastEndTime - ulFirstStartTime;
+ UINT32 ulNumLossPackets = 0;
+ UINT32 i = 0;
+ UINT32 ulTSOffset = 0;
+ UINT32 ulTime = 0;
+ /* Compute the number of packets */
+#ifndef __ARC600__
+ if (dAUDuration != 0.0)
+#else
+ if (dAUDuration == 0.0) {
+ ;
+ } else
+#endif
+ {
+ ulNumLossPackets = (UINT32)(dDiff / dAUDuration);
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Generate loss packets */
+ for (i = 0; i < ulNumLossPackets && HX_SUCCEEDED(retVal); i++) {
+ ulTSOffset = (UINT32)(i * dAUDuration);
+ ulTime = ulFirstStartTime + ulTSOffset;
+ retVal = ra_depacki_send_block(pInt,
+ ulSubStream,
+ HXNULL,
+ 0,
+ ulTime,
+ 0); /* Flags of 0 indicate loss */
+ }
+ }
+
+ return retVal;
+}
+
+#if RA_COPY_BUF
+void ra_depacki_free_block(ra_block* pBlock)
+{
+ /* Free the data */
+ if (pBlock->pData) {
+ AVMem_free(pBlock->pData);
+ pBlock->pData = HXNULL;
+ }
+}
+#endif
+
+HX_RESULT ra_depacki_send_block(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ UINT32 ulTime,
+ UINT32 ulFlags)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->fpAvail) {
+ /* Allocate space for a ra_block structure */
+ ra_block Block;
+ memset(&Block, 0, sizeof(Block));
+ {
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Copy the buffer */
+ if (pBuf && ulLen) {
+#if RA_COPY_BUF
+ Block.pData = copy_buffer(pInt->pUserMem,
+ pInt->fpMalloc,
+ pBuf, ulLen);
+ if (Block.pData) {
+ Block.ulDataLen = ulLen;
+ } else {
+ retVal = HXR_OUTOFMEMORY;
+ }
+#else
+ Block.pData = pBuf;
+ Block.ulDataLen = ulLen;
+#endif
+ }
+ if (retVal == HXR_OK) {
+ /* Assign the timestamp and flags */
+ Block.ulTimestamp = ulTime;
+ Block.ulDataFlags = ulFlags;
+ /* Send the block */
+ retVal = pInt->fpAvail(pInt->pAvail,
+ ulSubStream,
+ &Block);
+ }
+#if RA_COPY_BUF
+ ra_depacki_free_block(&Block);
+#endif
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_handle_frag_packet(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ rm_packet* pPacket,
+ UINT32 ulAUSize,
+ UINT32 ulAUFragSize)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr && pPacket &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ UINT32 ulPacketSize = (UINT32) pPacket->usDataLen;
+ UINT32 ulPacketOffset = (ulPacketSize >= ulAUFragSize ?
+ ulPacketSize - ulAUFragSize : 0);
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Have we allocated the frag buffer yet? */
+ if (!pHdr->pFragBuffer) {
+ retVal = ra_depacki_init_frag_buffer(pInt, pHdr);
+ }
+ if (HX_SUCCEEDED(retVal)) {
+ /*
+ * Do we have a current fragment, and if so, is it
+ * a different timestamp from this fragment?
+ */
+ if (pHdr->bHasFrag && pHdr->ulFragBufferTime != pPacket->ulTime) {
+ /* Clear the frag buffer */
+ ra_depacki_clear_frag_buffer(pInt, pHdr);
+ }
+ /*
+ * Are we currently processing a fragment? If not,
+ * then initialize this fragment, resizing the
+ * buffer if necessary.
+ */
+ if (!pHdr->bHasFrag) {
+ /* Make sure the buffer size is big enough */
+ if (ulAUSize > pHdr->ulFragBufferSize) {
+ retVal = ra_depacki_resize_frag_buffer(pInt, pHdr, ulAUSize);
+ }
+ if (HX_SUCCEEDED(retVal)) {
+ /* Init the members for this fragment */
+ pHdr->ulFragBufferOffset = 0;
+ pHdr->ulFragBufferTime = pPacket->ulTime;
+ pHdr->ulFragBufferAUSize = ulAUSize;
+ pHdr->bHasFrag = TRUE;
+ }
+ }
+ if (HX_SUCCEEDED(retVal)) {
+ /* Make sure we have room for the memcpy */
+ if (pHdr->ulFragBufferOffset + ulAUFragSize <= pHdr->ulFragBufferSize &&
+ ulPacketOffset + ulAUFragSize <= ulPacketSize) {
+ /* Copy this buffer in */
+ memcpy(pHdr->pFragBuffer + pHdr->ulFragBufferOffset,
+ pPacket->pData + ulPacketOffset,
+ ulAUFragSize);
+ /* Update the frag buffer offset */
+ pHdr->ulFragBufferOffset += ulAUFragSize;
+ /* Have we finished the fragmented AU? */
+ if (pHdr->ulFragBufferOffset >= pHdr->ulFragBufferAUSize) {
+ /* Send the frag buffer */
+ retVal = ra_depacki_send_block(pInt, ulSubStream,
+ pHdr->pFragBuffer,
+ pHdr->ulFragBufferAUSize,
+ pHdr->ulFragBufferTime,
+ 0xFFFFFFFF);
+ /* Whether we succeed or not, clear the frag buffer */
+ ra_depacki_clear_frag_buffer(pInt, pHdr);
+ }
+ } else {
+ retVal = HXR_FAIL;
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_handle_nonfrag_packet(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ rm_packet* pPacket,
+ UINT32 ulNumAU)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr && pPacket &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Init the local variables */
+ UINT32 ulAUDataSizeSum = 0;
+ UINT32 i = 0;
+ BYTE* pBuf = pPacket->pData;
+ UINT32 ulLen = pPacket->usDataLen;
+ UINT32 ulTSOffset = 0;
+ UINT32 ulAUSize = 0;
+ UINT32 ulBufOffset = 0;
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /*
+ * We can clear the frag queue. If there was no
+ * loss in the last fragmented AU, then it was
+ * cleared after the packet was created. If there
+ * WAS loss in the last fragmented AU, then we
+ * just handled it by generating loss packets.
+ */
+ ra_depacki_clear_frag_buffer(pInt, pHdr);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Step through the packet sending blocks */
+ for (i = 0; i < ulNumAU && HX_SUCCEEDED(retVal); i++) {
+ /* Set the return value */
+ retVal = HXR_FAIL;
+ /* Compute the time offset for this block */
+ ulTSOffset = (UINT32)(i * pHdr->dBlockDuration);
+ /* Compute the buffer offset for the AU size */
+ ulBufOffset = 2 + (i << 1);
+ /* Sanity check on packet size */
+ if (ulBufOffset + 1 < ulLen) {
+ /* Parse out the size of this AU */
+ ulAUSize = rm_unpack16_nse(pBuf + ulBufOffset,
+ ulLen - ulBufOffset);
+ /* Compute the offset of the AU */
+ ulBufOffset = 2 + ulNumAU * 2 + ulAUDataSizeSum;
+ /* Sanity check on size */
+ if (ulBufOffset + ulAUSize <= ulLen) {
+ /* Send this AU */
+ retVal = ra_depacki_send_block(pInt,
+ ulSubStream,
+ pBuf + ulBufOffset,
+ ulAUSize,
+ pPacket->ulTime + ulTSOffset,
+ 0xFFFFFFFF);
+ if (retVal == HXR_OK) {
+ /* Update the AU data size sum */
+ ulAUDataSizeSum += ulAUSize;
+ }
+ }
+ }
+ }
+ if (HX_SUCCEEDED(retVal)) {
+ /* Update the end time of the last block sent */
+ ulTSOffset = (UINT32)(ulNumAU * pHdr->dBlockDuration);
+ pHdr->ulLastSentEndTime = pPacket->ulTime + ulTSOffset;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_init_frag_buffer(ra_depack_internal* pInt,
+ ra_substream_hdr* pHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pHdr && !pHdr->pFragBuffer) {
+ /* Allocate the frag buffer */
+ pHdr->pFragBuffer = ra_depacki_malloc(pInt, INITIAL_FRAG_BUFFER_SIZE);
+ if (pHdr->pFragBuffer) {
+ /* Zero out the buffer */
+ memset(pHdr->pFragBuffer, 0, INITIAL_FRAG_BUFFER_SIZE);
+ /* Init the members */
+ pHdr->ulFragBufferSize = INITIAL_FRAG_BUFFER_SIZE;
+ pHdr->ulFragBufferTime = 0;
+ pHdr->ulFragBufferOffset = 0;
+ pHdr->ulFragBufferAUSize = 0;
+ pHdr->bHasFrag = FALSE;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_resize_frag_buffer(ra_depack_internal* pInt,
+ ra_substream_hdr* pHdr,
+ UINT32 ulNewSize)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pHdr && pHdr->pFragBuffer) {
+ /* Allocate a new buffer */
+ BYTE* pNewBuf = ra_depacki_malloc(pInt, ulNewSize);
+ if (pNewBuf) {
+ /* Copy the old buffer */
+ if (pHdr->ulFragBufferOffset) {
+ memcpy(pNewBuf, pHdr->pFragBuffer, pHdr->ulFragBufferOffset);
+ }
+ /* NULL out the rest of the buffer */
+ memset(pNewBuf + pHdr->ulFragBufferOffset, 0,
+ ulNewSize - pHdr->ulFragBufferOffset);
+ /* Free the old buffer */
+ ra_depacki_free(pInt, pHdr->pFragBuffer);
+ /* Assign the members. We won't change time or offset */
+ pHdr->pFragBuffer = pNewBuf;
+ pHdr->ulFragBufferSize = ulNewSize;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+void ra_depacki_clear_frag_buffer(ra_depack_internal* pInt,
+ ra_substream_hdr* hdr)
+{
+ if (pInt && hdr && hdr->bHasFrag) {
+ /* Clear the frag buffer members */
+ hdr->bHasFrag = FALSE;
+ hdr->ulFragBufferAUSize = 0;
+ hdr->ulFragBufferOffset = 0;
+ hdr->ulFragBufferTime = 0;
+ }
+}
+
+HX_RESULT ra_depacki_seek(ra_depack_internal* pInt, UINT32 ulTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr) {
+ /*
+ * Loop through all the substream headers
+ * and set the bSeeked flag.
+ */
+ UINT32 i = 0;
+ for (i = 0; i < pInt->multiStreamHdr.ulNumSubStreams; i++) {
+ pInt->pSubStreamHdr[i].bSeeked = TRUE;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_deinterleave_send(ra_depack_internal* pInt, UINT32 ulSubStream)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams &&
+ pInt->fpAvail) {
+ /* Init local variables */
+ UINT32 i = 0;
+ UINT32 ulTimeOffset = 0;
+ UINT32 ulTimestamp = 0;
+ HXDOUBLE dTimeOffset = 0.0;
+ ra_block Block;
+ /* Deinterleave the superblock */
+ retVal = ra_depacki_deinterleave(pInt, ulSubStream);
+ if (retVal == HXR_OK) {
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /* Send the blocks from the deinterleave buffer */
+ for (i = 0; i < pHdr->ulBlockCount && HX_SUCCEEDED(retVal); i++) {
+ /* Set the return value */
+ retVal = HXR_OUTOFMEMORY;
+ /* Compute the time offset for this block */
+ dTimeOffset = i * pHdr->dBlockDuration;
+ ulTimeOffset = (UINT32) dTimeOffset;
+ ulTimestamp = pHdr->ulKeyTime + ulTimeOffset;
+ /* Make sure the time is less than the stream duration */
+ if (ulTimestamp <= pInt->ulStreamDuration) {
+#if RA_COPY_BUF
+ /* Alloc and copy the buffer */
+ Block.pData = copy_buffer(pInt->pUserMem,
+ pInt->fpMalloc,
+ pHdr->pDBuffer + i * pHdr->ulInterleaveBlockSize,
+ pHdr->ulInterleaveBlockSize);
+#else
+ Block.pData = pHdr->pDBuffer + i * pHdr->ulInterleaveBlockSize;
+#endif
+ if (Block.pData) {
+ Block.ulDataLen = pHdr->ulInterleaveBlockSize;
+ Block.ulTimestamp = ulTimestamp;
+ Block.ulDataFlags = pHdr->pDPresentFlags[i];
+ /* Send the block */
+ retVal = pInt->fpAvail(pInt->pAvail, ulSubStream, &Block);
+ }
+#if RA_COPY_BUF
+ ra_depacki_free_block(&Block);
+#endif
+ } else {
+ /*
+ * Block is after the stream duration, so clear
+ * the return value and break out of the loop.
+ */
+ retVal = HXR_OK;
+ break;
+ }
+ }
+ /* Clear the interleaving buffers */
+ memset(pHdr->pIBuffer, 0, pHdr->ulSuperBlockSize);
+ memset(pHdr->pDBuffer, 0, pHdr->ulSuperBlockSize);
+ memset(pHdr->pIPresentFlags, 0, pHdr->ulInterleaveFactor * sizeof(UINT32));
+ memset(pHdr->pDPresentFlags, 0, pHdr->ulInterleaveFactor * sizeof(UINT32));
+ /* Clear the state */
+ pHdr->bHasKeyTime = FALSE;
+ pHdr->ulKeyTime = 0;
+ pHdr->ulBlockCount = 0;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_deinterleave(ra_depack_internal* pInt, UINT32 ulSubStream)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Get the interleaver ID */
+ UINT32 ulID = pInt->pSubStreamHdr[ulSubStream].ulInterleaverID;
+ /* Switch based on ID */
+ switch (ulID) {
+#if 0
+ case RA_INTERLEAVER_SIPR:
+ retVal = ra_depacki_deinterleave_sipr(pInt, ulSubStream);
+ break;
+#endif
+ case RA_INTERLEAVER_GENR:
+ retVal = ra_depacki_deinterleave_genr(pInt, ulSubStream);
+ break;
+ case RA_NO_INTERLEAVER:
+ retVal = ra_depacki_deinterleave_no(pInt, ulSubStream);
+ break;
+ }
+ }
+
+ return retVal;
+}
+
+#if 0
+HX_RESULT ra_depacki_deinterleave_sipr(ra_depack_internal* pInt, UINT32 ulSubStream)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /* Sanity check */
+ if (pHdr->pIBuffer && pHdr->pDBuffer &&
+ pHdr->pIPresentFlags && pHdr->pDPresentFlags) {
+ /*
+ * This is an in-place interleaving, so copy from
+ * pIBuffer to pDBuffer and then we will do the
+ * de-interleaving in-place in pDBuffer.
+ */
+ memcpy(pHdr->pDBuffer, pHdr->pIBuffer, pHdr->ulSuperBlockSize);
+ /* Copy the flags */
+ memcpy(pHdr->pDPresentFlags, pHdr->pIPresentFlags,
+ pHdr->ulInterleaveFactor * sizeof(UINT32));
+ /* Do the de-interleave */
+ RASL_DeInterleave((char*) pHdr->pDBuffer,
+ pHdr->ulSuperBlockSize,
+ pHdr->usFlavorIndex,
+ pHdr->pDPresentFlags);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+#endif
+
+HX_RESULT ra_depacki_init_genr(ra_depack_internal* pInt, UINT32 ulSubStream)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Init local variables */
+ UINT32 ulFramesPerBlock = 0;
+ UINT32 ulSize = 0;
+ UINT32 ulBlockIndx = 0;
+ UINT32 ulFrameIndx = 0;
+ UINT32 ulIndx = 0;
+ UINT32 i = 0;
+ UINT32 j = 0;
+ UINT32 ulCount = 0;
+ HXBOOL bEven = FALSE;
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /* Sanity check */
+ if (pHdr->ulCodecFrameSize && pHdr->ulNumCodecFrames) {
+ /* Compute the codec frames per block */
+ ulFramesPerBlock = pHdr->ulInterleaveBlockSize / pHdr->ulCodecFrameSize;
+ /* Allocate space for the block num and offset */
+ ulSize = pHdr->ulNumCodecFrames * sizeof(UINT32);
+ pHdr->pulGENRBlockNum = (UINT32*) ra_depacki_malloc(pInt, ulSize);
+ if (pHdr->pulGENRBlockNum) {
+ pHdr->pulGENRBlockOffset = (UINT32*) ra_depacki_malloc(pInt, ulSize);
+ if (pHdr->pulGENRBlockOffset) {
+ pHdr->pulGENRPattern = (UINT32*) ra_depacki_malloc(pInt, ulSize);
+ if (pHdr->pulGENRPattern) {
+ /* Initialize the block num and offset arrays */
+ for (ulBlockIndx = 0; ulBlockIndx < pHdr->ulInterleaveFactor; ulBlockIndx++) {
+ for (ulFrameIndx = 0; ulFrameIndx < ulFramesPerBlock; ulFrameIndx++) {
+ ulIndx = ulBlockIndx * ulFramesPerBlock + ulFrameIndx;
+ pHdr->pulGENRBlockNum[ulIndx] = ulBlockIndx;
+ pHdr->pulGENRBlockOffset[ulIndx] = ulFrameIndx;
+ }
+ }
+ /* Do we have a pattern from the stream header? */
+ if (pHdr->pulInterleavePattern) {
+ /* Copy the pattern from the stream header */
+ memcpy(pHdr->pulGENRPattern,
+ pHdr->pulInterleavePattern,
+ ulSize);
+ /*
+ * Check the pattern for validity by making sure
+ * that each frame index is used once and only
+ * once in the interleave pattern.
+ */
+ retVal = HXR_OK;
+ for (i = 0; i < pHdr->ulNumCodecFrames; i++) {
+ /* Init the count */
+ ulCount = 0;
+ /* Count how many times index i appears in table */
+ for (j = 0; j < pHdr->ulNumCodecFrames; j++) {
+ if (pHdr->pulGENRPattern[j] == i) {
+ ulCount++;
+ }
+ }
+ /* Make sure it's just once */
+ if (ulCount != 1) {
+ retVal = HXR_FAIL;
+ break;
+ }
+ }
+ } else {
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /*
+ * We don't have a stream header pattern, so
+ * we generate the standard interleave pattern.
+ */
+ if (pHdr->ulInterleaveFactor == 1) {
+ for (i = 0; i < pHdr->ulNumCodecFrames; i++) {
+ pHdr->pulGENRPattern[i] = i;
+ }
+ } else {
+ bEven = TRUE;
+ ulCount = 0;
+ ulBlockIndx = 0;
+ ulFrameIndx = 0;
+ while (ulCount < pHdr->ulNumCodecFrames) {
+ pHdr->pulGENRPattern[ulCount] = ulBlockIndx * ulFramesPerBlock + ulFrameIndx;
+ ulCount++;
+ ulBlockIndx += 2;
+ if (ulBlockIndx >= pHdr->ulInterleaveFactor) {
+ if (bEven) {
+ bEven = FALSE;
+ ulBlockIndx = 1;
+ } else {
+ bEven = TRUE;
+ ulBlockIndx = 0;
+ ulFrameIndx++;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_deinterleave_genr(ra_depack_internal* pInt, UINT32 ulSubStream)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Init local variables */
+ UINT32 fi = 0;
+ UINT32 fo = 0;
+ UINT32 ulBlkIndxIn = 0;
+ UINT32 ulBlkIndxOut = 0;
+ UINT32 ulBlkOffset = 0;
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /* Sanity check */
+ if (pHdr->pIBuffer && pHdr->pDBuffer &&
+ pHdr->pIPresentFlags && pHdr->pDPresentFlags) {
+ /* Set all the output flags to present initially */
+ memset(pHdr->pDPresentFlags, 0xFF,
+ pHdr->ulInterleaveFactor * sizeof(UINT32));
+ /* Deinterleave the data */
+ for (fo = 0; fo < pHdr->ulNumCodecFrames; fo++) {
+ /* Copy the data */
+ fi = pHdr->pulGENRPattern[fo];
+ memcpy(pHdr->pDBuffer + fo * pHdr->ulCodecFrameSize,
+ pHdr->pIBuffer + fi * pHdr->ulCodecFrameSize,
+ pHdr->ulCodecFrameSize);
+ /* Look up which block this frame comes from */
+ ulBlkIndxIn = pHdr->pulGENRBlockNum[fi];
+ /* Is this codec frame present? */
+ if (!pHdr->pIPresentFlags[ulBlkIndxIn]) {
+ /*
+ * Frame was part of a lost block. So clear
+ * the bit that says the frame was present.
+ */
+ ulBlkIndxOut = pHdr->pulGENRBlockNum[fo];
+ ulBlkOffset = pHdr->pulGENRBlockOffset[fo];
+ pHdr->pDPresentFlags[ulBlkIndxOut] ^= (1 << ulBlkOffset);
+ }
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT ra_depacki_deinterleave_no(ra_depack_internal* pInt, UINT32 ulSubStream)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pSubStreamHdr &&
+ ulSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Init local variables */
+ UINT32 fi = 0;
+ UINT32 fo = 0;
+ UINT32 ulBlkIndxIn = 0;
+ UINT32 ulBlkIndxOut = 0;
+ UINT32 ulBlkOffset = 0;
+ /* Get the substream header */
+ ra_substream_hdr* pHdr = &pInt->pSubStreamHdr[ulSubStream];
+ /* Sanity check */
+ if (pHdr->pIBuffer && pHdr->pDBuffer &&
+ pHdr->pIPresentFlags && pHdr->pDPresentFlags) {
+ /* Set all the output flags to present initially */
+ memset(pHdr->pDPresentFlags, 0xFF,
+ pHdr->ulInterleaveFactor * sizeof(UINT32));
+ /* Deinterleave the data */
+ for (fo = 0; fo < pHdr->ulNumCodecFrames; fo++) {
+ /* Copy the data */
+ fi = fo;
+ memcpy(pHdr->pDBuffer + fo * pHdr->ulCodecFrameSize,
+ pHdr->pIBuffer + fi * pHdr->ulCodecFrameSize,
+ pHdr->ulCodecFrameSize);
+ /* Look up which block this frame comes from */
+ ulBlkIndxIn = pHdr->pulGENRBlockNum[fi];
+ /* Is this codec frame present? */
+ if (!pHdr->pIPresentFlags[ulBlkIndxIn]) {
+ /*
+ * Frame was part of a lost block. So clear
+ * the bit that says the frame was present.
+ */
+ ulBlkIndxOut = pHdr->pulGENRBlockNum[fo];
+ ulBlkOffset = pHdr->pulGENRBlockOffset[fo];
+ pHdr->pDPresentFlags[ulBlkIndxOut] ^= (1 << ulBlkOffset);
+ }
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
diff --git a/audio_codec/libraac/ra_depack_internal.h b/audio_codec/libraac/ra_depack_internal.h
new file mode 100644
index 0000000..e9d155c
--- a/dev/null
+++ b/audio_codec/libraac/ra_depack_internal.h
@@ -0,0 +1,232 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: ra_depack_internal.h,v 1.1.1.1.2.1 2005/05/04 18:21:33 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RA_DEPACK_INTERNAL_H
+#define RA_DEPACK_INTERNAL_H
+
+#include "../include/helix_types.h"
+#include "../include/helix_result.h"
+#include "../include/rm_memory.h"
+#include "../include/rm_error.h"
+#include "../include/ra_depack.h"
+#include "../include/stream_hdr_structs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /*
+ * Internal substream header struct
+ */
+ typedef struct ra_substream_hdr_struct {
+ UINT16 usRAFormatVersion; /* 3, 4, or 5 */
+ UINT16 usRAFormatRevision; /* should be 0 */
+ UINT16 usHeaderBytes; /* size of raheader info */
+ UINT16 usFlavorIndex; /* compression type */
+ UINT32 ulGranularity; /* size of one block of encoded data */
+ UINT32 ulTotalBytes; /* total bytes of ra data */
+ UINT32 ulBytesPerMin; /* data rate of encoded and interleaved data */
+ UINT32 ulBytesPerMin2; /* data rate of interleaved or non-interleaved data */
+ UINT32 ulInterleaveFactor; /* number of blocks per superblock */
+ UINT32 ulInterleaveBlockSize; /* size of each interleave block */
+ UINT32 ulCodecFrameSize; /* size of each audio frame */
+ UINT32 ulUserData; /* extra field for user data */
+ UINT32 ulSampleRate; /* sample rate of decoded audio */
+ UINT32 ulActualSampleRate; /* sample rate of decoded audio */
+ UINT32 ulSampleSize; /* bits per sample in decoded audio */
+ UINT32 ulChannels; /* number of audio channels in decoded audio */
+ UINT32 ulInterleaverID; /* interleaver 4cc */
+ UINT32 ulCodecID; /* codec 4cc */
+ BYTE bIsInterleaved; /* 1 if file has been interleaved */
+ BYTE bCopyByte; /* copy enable byte, if 1 allow copies (SelectiveRecord) */
+ BYTE ucStreamType; /* i.e. LIVE_STREAM, FILE_STREAM */
+ BYTE ucScatterType; /* the interleave pattern type 0==cyclic,1==pattern */
+ UINT32 ulNumCodecFrames; /* number of codec frames in a superblock */
+ UINT32* pulInterleavePattern; /* the pattern of interleave if not cyclic */
+ UINT32 ulOpaqueDataSize; /* size of the codec specific data */
+ BYTE* pOpaqueData; /* codec specific data */
+ HXDOUBLE dBlockDuration; /* Duration in ms of audio "block" */
+ UINT32 ulLastSentEndTime; /* Ending time of last sent audio frame */
+ BYTE* pFragBuffer; /* Intermediate buffer for reconstructing VBR packets */
+ UINT32 ulFragBufferSize; /* Size of intermediate buffer */
+ UINT32 ulFragBufferAUSize; /* Size of AU being reconstructed */
+ UINT32 ulFragBufferOffset; /* Current offset within AU */
+ UINT32 ulFragBufferTime; /* Timestamp of AU being reconstructed */
+ UINT32 ulSuperBlockSize; /* ulInterleaveBlockSize * ulInterleaveFactor */
+ UINT32 ulSuperBlockTime; /* dBlockDuration * ulInterleaveFactor */
+ UINT32 ulKeyTime; /* Timestamp of keyframe packet */
+ BYTE* pIBuffer; /* Buffer holding interleaved blocks */
+ BYTE* pDBuffer; /* Buffer holding de-interleaved blocks */
+ UINT32* pIPresentFlags; /* number of UINT32s: ulInterleaveBlockSize */
+ UINT32* pDPresentFlags; /* number of UINT32s: ulInterleaveBlockSize */
+ UINT32 ulBlockCount; /* number of blocks currently in superblock */
+ UINT32* pulGENRPattern; /* Interleave pattern for GENR interleaver */
+ UINT32* pulGENRBlockNum;
+ UINT32* pulGENRBlockOffset;
+ rm_packet lastPacket;
+ HX_BITFIELD bIsVBR : 1;
+ HX_BITFIELD bSeeked : 1;
+ HX_BITFIELD bLossOccurred : 1;
+ HX_BITFIELD bHasKeyTime : 1; /* Do we have a time for the key slot? */
+ HX_BITFIELD bHasFrag : 1;
+ HX_BITFIELD bAdjustTimestamps : 1;
+ HX_BITFIELD bKnowIfAdjustNeeded : 1;
+ HX_BITFIELD bHasLastPacket : 1;
+ } ra_substream_hdr;
+
+ /*
+ * Internal ra_depack struct
+ */
+ typedef struct ra_depack_internal_struct {
+ void* pAvail;
+ ra_block_avail_func_ptr fpAvail;
+ rm_error_func_ptr fpError;
+ void* pUserError;
+ rm_malloc_func_ptr fpMalloc;
+ rm_free_func_ptr fpFree;
+ void* pUserMem;
+ rm_rule_map rule2Flag;
+ rm_multistream_hdr multiStreamHdr;
+ ra_substream_hdr* pSubStreamHdr;
+ UINT32 ulTrackStartTime;
+ UINT32 ulTrackEndTime;
+ UINT32 ulEndTime;
+ UINT32 ulStreamDuration;
+ HX_BITFIELD bForceTrackStartTime : 1;
+ HX_BITFIELD bForceTrackEndTime : 1;
+ HX_BITFIELD bStreamSwitchable : 1;
+ HX_BITFIELD bAllVBR : 1;
+ HX_BITFIELD bAllNonVBR : 1;
+ HX_BITFIELD bHasEndTime : 1;
+ } ra_depack_internal;
+
+ /*
+ * Internal ra_depack functions
+ */
+ void* ra_depacki_malloc(ra_depack_internal* pInt, UINT32 ulSize);
+ void ra_depacki_free(ra_depack_internal* pInt, void* pMem);
+ HX_RESULT ra_depacki_init(ra_depack_internal* pInt, rm_stream_header* hdr);
+ HX_RESULT ra_depacki_unpack_rule_map(ra_depack_internal* pInt,
+ rm_rule_map* pMap,
+ BYTE** ppBuf,
+ UINT32* pulLen);
+ HX_RESULT ra_depacki_unpack_multistream_hdr(ra_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen);
+ HX_RESULT ra_depacki_unpack_opaque_data(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen);
+ void ra_depacki_cleanup_substream_hdr(ra_depack_internal* pInt,
+ ra_substream_hdr* hdr);
+ void ra_depacki_cleanup_substream_hdr_array(ra_depack_internal* pInt);
+ HX_RESULT ra_depacki_unpack_substream_hdr(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ ra_substream_hdr* pHdr);
+ HX_RESULT ra_depacki_unpack_raformat3(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ ra_substream_hdr* pHdr);
+ HX_RESULT ra_depacki_unpack_raformat4(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ ra_substream_hdr* pHdr);
+ HX_RESULT ra_depacki_unpack_raformat5(ra_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ ra_substream_hdr* pHdr);
+ HX_RESULT ra_depacki_get_format_info(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ ra_format_info* pInfo);
+ void ra_depacki_cleanup_format_info(ra_depack_internal* pInt,
+ ra_format_info* pInfo);
+ UINT32 ra_depacki_rule_to_flags(ra_depack_internal* pInt, UINT32 ulRule);
+ HXBOOL ra_depacki_is_keyframe_rule(ra_depack_internal* pInt, UINT32 ulRule);
+ UINT32 ra_depacki_rule_to_substream(ra_depack_internal* pInt, UINT32 ulRule);
+ HX_RESULT ra_depacki_add_packet(ra_depack_internal* pInt,
+ rm_packet* pPacket);
+ HX_RESULT ra_depacki_add_vbr_packet(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ rm_packet* pPacket);
+ HX_RESULT ra_depacki_add_non_vbr_packet(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ rm_packet* pPacket);
+ HX_RESULT ra_depacki_parse_vbr_packet(ra_depack_internal* pInt,
+ rm_packet* pPacket,
+ UINT32* pulNumAU,
+ HXBOOL* pbFragmented,
+ UINT32* pulAUSize,
+ UINT32* pulAUFragSize);
+ HX_RESULT ra_depacki_generate_and_send_loss(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ UINT32 ulFirstStartTime,
+ UINT32 ulLastEndTime);
+ HX_RESULT ra_depacki_send_block(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ BYTE* pBuf,
+ UINT32 ulLen,
+ UINT32 ulTime,
+ UINT32 ulFlags);
+ HX_RESULT ra_depacki_handle_frag_packet(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ rm_packet* pPacket,
+ UINT32 ulAUSize,
+ UINT32 ulAUFragSize);
+ HX_RESULT ra_depacki_handle_nonfrag_packet(ra_depack_internal* pInt,
+ UINT32 ulSubStream,
+ rm_packet* pPacket,
+ UINT32 ulNumAU);
+ HX_RESULT ra_depacki_init_frag_buffer(ra_depack_internal* pInt,
+ ra_substream_hdr* pHdr);
+ HX_RESULT ra_depacki_resize_frag_buffer(ra_depack_internal* pInt,
+ ra_substream_hdr* pHdr,
+ UINT32 ulNewSize);
+ void ra_depacki_clear_frag_buffer(ra_depack_internal* pInt,
+ ra_substream_hdr* hdr);
+ HX_RESULT ra_depacki_seek(ra_depack_internal* pInt, UINT32 ulTime);
+ HX_RESULT ra_depacki_deinterleave_send(ra_depack_internal* pInt, UINT32 ulSubStream);
+ HX_RESULT ra_depacki_deinterleave(ra_depack_internal* pInt, UINT32 ulSubStream);
+ HX_RESULT ra_depacki_deinterleave_sipr(ra_depack_internal* pInt, UINT32 ulSubStream);
+ HX_RESULT ra_depacki_init_genr(ra_depack_internal* pInt, UINT32 ulSubStream);
+ HX_RESULT ra_depacki_deinterleave_genr(ra_depack_internal* pInt, UINT32 ulSubStream);
+ HX_RESULT ra_depacki_deinterleave_no(ra_depack_internal* pInt, UINT32 ulSubStream);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef RA_DEPACK_INTERNAL_H */
diff --git a/audio_codec/libraac/raac_decode.c b/audio_codec/libraac/raac_decode.c
new file mode 100644
index 0000000..99528f1
--- a/dev/null
+++ b/audio_codec/libraac/raac_decode.c
@@ -0,0 +1,854 @@
+#include <stdio.h>
+#include <limits.h>
+//#include <asm/cache.h>
+
+#ifndef __MW__
+#include <inttypes.h>
+#else
+#include <core/types.h>
+#endif
+#include "raac_decode.h"
+#include "aac_decode.h"
+#include "include/rm_parse.h"
+#include "include/ra_depack.h"
+#include "include/ra_decode.h"
+
+#include "include/rm_memory_default.h"
+#include "aacdec.h"
+
+#include "../../amadec/adec-armdec-mgt.h"
+
+#include <android/log.h>
+
+#define LOG_TAG "RaacDecoder"
+#define raac_print(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+#define DefaultReadSize 32*1024
+#define DefaultOutBufSize 370*1024
+
+typedef struct {
+ rm_parser* pParser;
+ ra_depack* pDepack;
+ ra_decode* pDecode;
+ ra_format_info* pRaInfo;
+ rm_packet* pPacket;
+ ra_block* pBlock;
+ rm_stream_header* pHdr;
+ UINT32 usStreamNum;
+} rm_info_t;
+
+#define AUDIO_EXTRA_DATA_SIZE (2048*2)
+
+struct audio_info {
+ int valid;
+ int sample_rate;
+ int channels;
+ int bitrate;
+ int codec_id;
+ int block_align;
+ int extradata_size;
+ char extradata[AUDIO_EXTRA_DATA_SIZE];
+};
+
+struct frame_info {
+ int len;
+ unsigned long offset;/*steam start to here*/
+ unsigned long buffered_len;/*data buffer in dsp,pcm datalen*/
+ int reversed[1];/*for cache aligned 32 bytes*/
+};
+
+cook_IObuf cook_input;
+cook_IObuf cook_output;
+
+struct frame_info cur_frame;
+static unsigned aac_timestamplen = 0;
+static unsigned aac_timestamp = 0;
+static raac_decoder_info_t raac_dec_info ;
+static rm_info_t raac_info ;
+static char file_header[AUDIO_EXTRA_DATA_SIZE];
+#pragma align_to(64,file_header)
+static char *cur_read_ptr = file_header;
+
+void set_timestamp(unsigned val)
+{
+ aac_timestamp = val;
+}
+
+void set_timestamp_len(unsigned val)
+{
+ aac_timestamplen = val;
+}
+
+ra_decode*
+ra_decode_create2(void* pUserError,
+ rm_error_func_ptr fpError,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree)
+{
+ ra_decode* pRet = HXNULL;
+
+ if (fpMalloc && fpFree) {
+ pRet = (ra_decode*) fpMalloc(pUserMem, sizeof(ra_decode));
+
+ if (pRet) {
+ /* Zero out the struct */
+ memset((void*) pRet, 0, sizeof(ra_decode));
+ /* Assign the error function */
+ pRet->fpError = fpError;
+ pRet->pUserError = pUserError;
+ /* Assign the memory functions */
+ pRet->fpMalloc = fpMalloc;
+ pRet->fpFree = fpFree;
+ pRet->pUserMem = pUserMem;
+ }
+ }
+
+ return pRet;
+}
+
+ra_decode*
+ra_decode_create(void* pUserError,
+ rm_error_func_ptr fpError)
+{
+ return ra_decode_create2(pUserError,
+ fpError,
+ HXNULL,
+ rm_memory_default_malloc,
+ rm_memory_default_free);
+}
+
+/* ra_decode_destroy()
+ * Deletes the decoder backend and frontend instances. */
+void
+ra_decode_destroy(ra_decode* pFrontEnd)
+{
+ rm_free_func_ptr fpFree;
+ void* pUserMem;
+
+ if (pFrontEnd && pFrontEnd->fpFree) {
+ /* Save a pointer to fpFree and pUserMem */
+ fpFree = pFrontEnd->fpFree;
+ pUserMem = pFrontEnd->pUserMem;
+
+ if (pFrontEnd->pDecode && pFrontEnd->fpClose) {
+ /* Free the decoder instance and backend */
+ pFrontEnd->fpClose(pFrontEnd->pDecode,
+ pUserMem,
+ fpFree);
+ }
+
+ /* Free the ra_decode struct memory */
+ fpFree(pUserMem, pFrontEnd);
+ }
+}
+
+/* ra_decode_init()
+ * Selects decoder backend with fourCC code.
+ * Calls decoder backend init function with init params.
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_init(ra_decode* pFrontEnd,
+ UINT32 ulFourCC,
+ void* pInitParams,
+ UINT32 ulInitParamsSize,
+ ra_format_info* pStreamInfo)
+{
+ HX_RESULT retVal = HXR_OK;
+
+ /* Assign the backend function pointers */
+ if (ulFourCC == 0x72616163 || /* 'raac' */
+ ulFourCC == 0x72616370) { /* 'racp' */
+ pFrontEnd->fpInit = aac_decode_init;
+ pFrontEnd->fpReset = aac_decode_reset;
+ pFrontEnd->fpConceal = aac_decode_conceal;
+ pFrontEnd->fpDecode = aac_decode_decode;
+ pFrontEnd->fpGetMaxSize = aac_decode_getmaxsize;
+ pFrontEnd->fpGetChannels = aac_decode_getchannels;
+ pFrontEnd->fpGetChannelMask = aac_decode_getchannelmask;
+ pFrontEnd->fpGetSampleRate = aac_decode_getrate;
+ pFrontEnd->fpMaxSamp = aac_decode_getdelay;
+ pFrontEnd->fpClose = aac_decode_close;
+ } else {
+ /* error - codec not supported */
+ raac_print(" cook decode: not supported fourcc\n");
+ retVal = HXR_DEC_NOT_FOUND;
+ }
+
+ if (retVal == HXR_OK && pFrontEnd && pFrontEnd->fpInit && pStreamInfo) {
+ retVal = pFrontEnd->fpInit(pInitParams, ulInitParamsSize, pStreamInfo,
+ &pFrontEnd->pDecode, pFrontEnd->pUserMem,
+ pFrontEnd->fpMalloc, pFrontEnd->fpFree);
+ }
+
+ return retVal;
+}
+
+/* ra_decode_reset()
+ * Calls decoder backend reset function.
+ * Depending on which codec is in use, *pNumSamplesOut samples may
+ * be flushed. After reset, the decoder returns to its initial state.
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_reset(ra_decode* pFrontEnd,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pFrontEnd && pFrontEnd->fpReset) {
+ retVal = pFrontEnd->fpReset(pFrontEnd->pDecode, pSamplesOut,
+ ulNumSamplesAvail, pNumSamplesOut);
+ }
+
+ return retVal;
+}
+
+/* ra_decode_conceal()
+ * Calls decoder backend conceal function.
+ * On successive calls to ra_decode_decode(), the decoder will attempt
+ * to conceal ulNumSamples. No input data should be sent while concealed
+ * frames are being produced. Once the decoder has exhausted the concealed
+ * samples, it can proceed normally with decoding valid input data.
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_conceal(ra_decode* pFrontEnd,
+ UINT32 ulNumSamples)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pFrontEnd && pFrontEnd->fpConceal) {
+ retVal = pFrontEnd->fpConceal(pFrontEnd->pDecode, ulNumSamples);
+ }
+
+ return retVal;
+}
+
+/* ra_decode_decode()
+ * Calls decoder backend decode function.
+ * pData : input data (compressed frame).
+ * ulNumBytes : input data size in bytes.
+ * pNumBytesConsumed : amount of input data consumed by decoder.
+ * pSamplesOut : output data (uncompressed frame).
+ * ulNumSamplesAvail : size of output buffer.
+ * pNumSamplesOut : amount of ouput data produced by decoder.
+ * ulFlags : control flags for decoder.
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_decode(ra_decode* pFrontEnd,
+ UINT8* pData,
+ UINT32 ulNumBytes,
+ UINT32* pNumBytesConsumed,
+ UINT16* pSamplesOut,
+ UINT32 ulNumSamplesAvail,
+ UINT32* pNumSamplesOut,
+ UINT32 ulFlags,
+ UINT32 ulTimeStamp)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pFrontEnd && pFrontEnd->fpDecode) {
+ retVal = pFrontEnd->fpDecode(pFrontEnd->pDecode, pData, ulNumBytes,
+ pNumBytesConsumed, pSamplesOut,
+ ulNumSamplesAvail, pNumSamplesOut, ulFlags, ulTimeStamp);
+ }
+
+ return retVal;
+}
+
+
+/**************** Accessor Functions *******************/
+/* ra_decode_getmaxsize()
+ * pNumSamples receives the maximum number of samples produced
+ * by the decoder in response to a call to ra_decode_decode().
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_getmaxsize(ra_decode* pFrontEnd,
+ UINT32* pNumSamples)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pFrontEnd && pFrontEnd->fpGetMaxSize) {
+ retVal = pFrontEnd->fpGetMaxSize(pFrontEnd->pDecode, pNumSamples);
+ }
+
+ return retVal;
+}
+
+/* ra_decode_getchannels()
+ * pNumChannels receives the number of audio channels in the bitstream.
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_getchannels(ra_decode* pFrontEnd,
+ UINT32* pNumChannels)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pFrontEnd && pFrontEnd->fpGetChannels) {
+ retVal = pFrontEnd->fpGetChannels(pFrontEnd->pDecode, pNumChannels);
+ }
+
+ return retVal;
+}
+
+/* ra_decode_getchannelmask()
+ * pChannelMask receives the 32-bit mapping of the audio output channels.
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_getchannelmask(ra_decode* pFrontEnd,
+ UINT32* pChannelMask)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pFrontEnd && pFrontEnd->fpGetChannelMask) {
+ retVal = pFrontEnd->fpGetChannelMask(pFrontEnd->pDecode, pChannelMask);
+ }
+
+ return retVal;
+}
+
+/* ra_decode_getrate()
+ * pSampleRate receives the sampling rate of the output samples.
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_getrate(ra_decode* pFrontEnd,
+ UINT32* pSampleRate)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pFrontEnd && pFrontEnd->fpGetSampleRate) {
+ retVal = pFrontEnd->fpGetSampleRate(pFrontEnd->pDecode, pSampleRate);
+ }
+
+ return retVal;
+}
+
+/* ra_decode_getdelay()
+ * pNumSamples receives the number of invalid output samples
+ * produced by the decoder at startup.
+ * If non-zero, it is up to the user to discard these samples.
+ * Returns zero on success, negative result indicates failure. */
+HX_RESULT
+ra_decode_getdelay(ra_decode* pFrontEnd,
+ UINT32* pNumSamples)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pFrontEnd && pFrontEnd->fpMaxSamp) {
+ retVal = pFrontEnd->fpMaxSamp(pFrontEnd->pDecode, pNumSamples);
+ }
+
+ return retVal;
+}
+
+
+void rm_error(void* pError, HX_RESULT result, const char* pszMsg)
+{
+ //dsp_mailbox_send(1,M1B_IRQ7_DECODE_FATAL_ERR, 1, NULL, 0);
+ //trans_err_code(DECODE_FATAL_ERR);
+ raac_print("rm_error pError=0x%08x result=0x%08x msg=%s\n", pError, result, pszMsg);
+ //while(1);
+}
+//static int raac_decode_frame(unsigned char *buf, int maxlen, struct frame_fmt *fmt)
+int audio_dec_decode(audio_decoder_operations_t *adec_ops, char *outbuf, int *outlen, char *inbuf, int inlen)
+{
+ HX_RESULT retVal = HXR_OK;
+ UINT32 ulBytesConsumed = 0;
+ UINT32 ulTotalConsumed = 0;
+ UINT32 ulBytesLeft = 0;
+ UINT32 ulNumSamplesOut = 0;
+ UINT32 ulMaxSamples = 0;
+ UINT32 out_data_len = 0;
+
+ if (inlen > 0) {
+ int len = inlen - cook_input.buf_len;
+ int read_len;
+ read_len = (inlen > cook_input.buf_max) ? cook_input.buf_max : inlen;
+ if (len > 0) {
+ memcpy(cook_input.buf + cook_input.buf_len,
+ inbuf + cook_input.buf_len, read_len - cook_input.buf_len);
+ cook_input.buf_len += read_len - cook_input.buf_len;
+ }
+ }
+ //libcook_print("audio_dec_decoder cook_input.buf_len = %d\n", cook_input.buf_len);
+ while (cook_output.buf_len <= 0) {
+ retVal = rm_parser_get_packet(raac_info.pParser, &raac_info.pPacket);
+ if (retVal == HXR_OK) {
+ //if (ra_info.pPacket->usStream == ra_info.usStreamNum)
+ {
+ retVal = ra_depack_add_packet(raac_info.pDepack, raac_info.pPacket);
+
+ }
+ rm_parser_destroy_packet(raac_info.pParser, &raac_info.pPacket);
+ }
+ if (retVal != HXR_OK) {
+ raac_print("cook_decode_frame£º add packet failed\n");
+ break;
+ }
+ }
+
+ *outlen = 0;
+ if (cook_output.buf_len > 0) {
+ memcpy(outbuf, cook_output.buf, cook_output.buf_len);
+ (*outlen) = cook_output.buf_len;
+ cook_output.buf_len = 0;
+ }
+
+ int ret = 0;
+ //ret = ra_dec_info.decoded_size + cook_input.cousume;
+ ret = cook_input.cousume;
+ //libcook_print("ret decoder = %d\n", ret);
+ cook_input.cousume = 0;
+ adec_ops->pts = cur_frame.offset;
+ cur_frame.offset = 0;
+ return ret;
+ //return raac_dec_info.decoded_size;
+}
+
+
+UINT32 rm_io_read(void* pUserRead, BYTE* pBuf, UINT32 ulBytesToRead)
+{
+ memcpy(pBuf, cur_read_ptr, ulBytesToRead);
+ cur_read_ptr = cur_read_ptr + ulBytesToRead;
+ if ((unsigned)(cur_read_ptr - file_header) > AUDIO_EXTRA_DATA_SIZE) {
+ //trans_err_code(DECODE_INIT_ERR);
+ raac_print("warning :: raac.read byte exceed the the buffer then sent,%d \n", (unsigned)(cur_read_ptr - file_header));
+ while (1) {
+ ;
+ }
+ }
+ return ulBytesToRead;
+}
+void rm_io_seek(void* pUserRead, UINT32 ulOffset, UINT32 ulOrigin)
+{
+ if (ulOrigin == HX_SEEK_ORIGIN_CUR) {
+ cur_read_ptr += ulOffset;
+ } else if (ulOrigin == HX_SEEK_ORIGIN_SET) {
+ cur_read_ptr = (char *)pUserRead + ulOffset;
+ } else if (ulOrigin == HX_SEEK_ORIGIN_END) {
+ cur_read_ptr = sizeof(file_header) + (char *)pUserRead - ulOffset;
+ }
+ if ((unsigned)(cur_read_ptr - file_header) > AUDIO_EXTRA_DATA_SIZE) {
+ //trans_err_code(DECODE_INIT_ERR);
+ raac_print("warning :: raac.seek buffer pos exceed the the buffer then sent,%d \n", (unsigned)(cur_read_ptr - file_header));
+ while (1) {
+ ;
+ }
+ }
+
+}
+unsigned rm_ab_read(void* pUserRead, BYTE* pBuf, UINT32 ulBytesToRead)
+{
+ int ret = 0;
+#if 0
+ if (pBuf && ulBytesToRead) {
+ ret = read_buffer(pBuf, ulBytesToRead);
+ }
+ return ret;
+#endif
+ if (pBuf && ulBytesToRead) {
+ ret = (ulBytesToRead > cook_input.buf_len) ? cook_input.buf_len : ulBytesToRead;
+ memcpy(pBuf, cook_input.buf, ret);
+ if (ret < cook_input.buf_len) {
+ memcpy(cook_input.buf, (cook_input.buf + ret), cook_input.buf_len - ret);
+ }
+ cook_input.buf_len -= ret;
+ }
+ cook_input.cousume += ret;
+ cook_input.all_consume += ret;
+ return ret;
+}
+void rm_ab_seek(void* pUserRead, UINT32 ulOffset, UINT32 ulOrigin)
+{
+ int i;
+#if 0
+ if (ulOrigin == HX_SEEK_ORIGIN_CUR) {
+ for (i = 0; i < ulOffset; i++) {
+ read_byte();
+ }
+ }
+#endif
+ if (ulOrigin == HX_SEEK_ORIGIN_CUR) {
+ if (ulOffset <= cook_input.buf_len) {
+ //memcpy(cook_input.buf, cook_input.buf + ulOffset, cook_input.buf_len - ulOffset);
+ cook_input.buf_len -= ulOffset;
+ cook_input.cousume += ulOffset;
+ //cook_input.all_consume += ulOffset;
+ memcpy(cook_input.buf, cook_input.buf + ulOffset, cook_input.buf_len);
+ } else {
+ raac_print("rm_ab_seek failed\n");
+ }
+ }
+
+}
+HX_RESULT _raac_block_available(void* pAvail, UINT32 ulSubStream, ra_block* pBlock)
+{
+ int len = 0, wlen;
+ int offset = 0;
+ HX_RESULT retVal = HXR_OK;
+ UINT32 ulBytesConsumed = 0;
+ UINT32 ulTotalConsumed = 0;
+ UINT32 ulBytesLeft = 0;
+ UINT32 ulNumSamplesOut = 0;
+ UINT32 ulMaxSamples = 0;
+ UINT32 out_data_len = 0;
+ UINT32 delay_pts = 0;
+ //BYTE* buf = raac_dec_info.input_buf;//passed from the audio dec thread
+ rm_info_t* pInfo = (rm_info_t*) pAvail;
+ if (pAvail && pBlock && pBlock->pData && pBlock->ulDataLen) {
+ ulBytesLeft = pBlock->ulDataLen;
+ while (retVal == HXR_OK && ulBytesLeft) {
+ retVal = ra_decode_decode(raac_dec_info.pDecode,
+ pBlock->pData + pBlock->ulDataLen - ulBytesLeft,
+ ulBytesLeft,
+ &ulBytesConsumed,
+ (UINT16*)raac_dec_info.pOutBuf,
+ raac_dec_info.ulOutBufSize / 2,
+ &ulNumSamplesOut,
+ pBlock->ulDataFlags,
+ pBlock->ulTimestamp * 90);
+
+ if (retVal == HXR_OK) {
+ if (ulBytesConsumed) {
+ ulBytesLeft -= ulBytesConsumed;
+ }
+ if (ulNumSamplesOut) {
+ len = ulNumSamplesOut * 2;
+ }
+ } else if (retVal == HXR_NO_DATA) {
+ raac_print("raac decode not enough data.\n");
+ return 0;
+ } else {
+ raac_print("raac decode error.\n");
+ return 0;
+ }
+ //#if 0
+ //raac_print("ulTimestamp=%ld\n", pBlock->ulTimestamp);
+ cur_frame.offset = pBlock->ulTimestamp * 90 + 1;
+ cur_frame.buffered_len = 0;
+ cur_frame.len = 0;
+ delay_pts += ulNumSamplesOut;//(ulNumSamplesOut/raac_info.pRaInfo->usNumChannels)*90 /(raac_info.pRaInfo->ulSampleRate / 1000);
+ //refresh_swap_register1(cur_frame.offset+delay_pts, len);
+ //#endif
+ memcpy(cook_output.buf + cook_output.buf_len, raac_dec_info.pOutBuf, len);
+ cook_output.buf_len += len;
+ len = 0;
+ }
+ delay_pts = (delay_pts / raac_info.pRaInfo->usNumChannels) * 90 / (raac_info.pRaInfo->ulSampleRate / 1000);
+ cur_frame.offset += delay_pts;
+ raac_dec_info.decoded_size = out_data_len;
+ }
+ return retVal;
+}
+//static int raac_decode_init(struct frame_fmt * fmt)
+int audio_dec_init(audio_decoder_operations_t *adec_ops)
+{
+ //raac_print("\n\n[%s]BuildDate--%s BuildTime--%s", __FUNCTION__, __DATE__, __TIME__);
+ raac_print("enter into %s:%d\n", __FUNCTION__, __LINE__);
+ HX_RESULT retVal = HXR_OK;
+ unsigned ulNumStreams = 0;
+ rm_parser* pParser = HXNULL;
+ rm_stream_header *pHdr = HXNULL;
+ ra_depack *pRADpack = HXNULL;
+ ra_format_info *pRAInfo = HXNULL;
+ int i;
+#if 0
+ struct audio_info *real_data;
+ real_data = (struct audio_info *)fmt->private_data;
+ if (!real_data || !real_data->extradata) {
+ raac_print("[raac decode],got extra data failed\n");
+ return -1;
+ }
+#endif
+ struct audio_info real_data;
+
+ real_data.bitrate = adec_ops->bps;
+ real_data.channels = adec_ops->channels;
+ real_data.extradata_size = adec_ops->extradata_size;
+ real_data.sample_rate = adec_ops->samplerate;
+
+ adec_ops->nInBufSize = DefaultReadSize;
+ adec_ops->nOutBufSize = DefaultOutBufSize;
+ raac_print("%s:%d\n", __FUNCTION__, __LINE__);
+ memset(real_data.extradata, 0, AUDIO_EXTRA_DATA_SIZE);
+ raac_print("%d,%d\n", real_data.extradata_size, adec_ops->extradata_size);
+ for (i = 0; i < real_data.extradata_size; i++) {
+ real_data.extradata[i] = adec_ops->extradata[i];
+ }
+
+ raac_print("raac audioinfo four data [0x%x], [0x%x],[0x%x],[0x%x],[0x%x],[0x%x],[0x%x],[0x%x],\n", real_data.extradata[0], \
+ real_data.extradata[1], real_data.extradata[2], real_data.extradata[3], \
+ real_data.extradata[4], real_data.extradata[5], real_data.extradata[6], real_data.extradata[7]);
+
+ memcpy(file_header, real_data.extradata, AUDIO_EXTRA_DATA_SIZE);
+
+ if (cook_input.buf == NULL) {
+ cook_input.buf = (BYTE *)malloc(DefaultReadSize * sizeof(BYTE));
+ if (cook_input.buf != NULL) {
+ memset(cook_input.buf, 0, DefaultReadSize);
+ cook_input.buf_len = 0;
+ cook_input.buf_max = DefaultReadSize;
+ cook_input.cousume = 0;
+ cook_input.all_consume = 0;
+ } else {
+ raac_print("inbuf malloc failed\n");
+ return -1;
+ }
+ }
+ if (cook_output.buf == NULL) {
+ cook_output.buf = (BYTE *)malloc(DefaultOutBufSize * sizeof(BYTE));
+ if (cook_output.buf != NULL) {
+ memset(cook_output.buf, 0, DefaultOutBufSize);
+ cook_output.buf_len = 0;
+ cook_output.buf_max = DefaultOutBufSize;
+ cook_output.cousume = 0;
+ } else {
+ raac_print("outbuf malloc failed\n");
+ return -1;
+ }
+ }
+
+ if (cook_input.buf == NULL || cook_output.buf == NULL) {
+ raac_print("malloc buf failed\n");
+ return -1;
+
+ }
+ //dsp_cache_wback((unsigned)file_header,AUDIO_EXTRA_DATA_SIZE);
+ cur_frame.offset = 0;
+
+ unsigned ulCodec4CC = 0;
+ //int i;
+ /*clear up the decoder structure */
+ memset(&raac_dec_info, 0, sizeof(raac_decoder_info_t));
+ memset(&raac_info, 0, sizeof(rm_info_t));
+ cur_read_ptr = file_header;
+
+ /* Create the parser struct */
+ pParser = rm_parser_create(NULL, rm_error);
+ if (!pParser) {
+ raac_print("[raac decode],create parser failed\n");
+ return -1;
+ }
+ /* Set the stream into the parser */
+#if 0
+ for (i = 0; i < 1; i++) {
+ raac_print("%d header data [0x%x],[0x%x],[0x%x],[0x%x],[0x%x],[0x%x],[0x%x],[0x%x]\n\t", i, \
+ file_header[i * 8 + 0], file_header[i * 8 + 1], file_header[i * 8 + 2], file_header[i * 8 + 3], \
+ file_header[i * 8 + 4], file_header[i * 8 + 5], file_header[i * 8 + 6], file_header[i * 8 + 7]);
+ }
+#endif /* 0 */
+ retVal = rm_parser_init_io(pParser, file_header, rm_io_read, rm_io_seek);
+ if (retVal != HXR_OK) {
+ raac_print("[raac decode], parser init IO failed,errid %d\n", retVal);
+ rm_parser_destroy(&pParser);
+ return -1;
+ }
+ /* Read all the headers at the beginning of the .rm file */
+ retVal = rm_parser_read_headers(pParser);
+ if (retVal != HXR_OK) {
+ raac_print("[raac decode], parser read header failed,errid %d\n", retVal);
+ rm_parser_destroy(&pParser);
+ return -1;
+ }
+ raac_print("raac: rm_parser_read_headers finished \n");
+ /* Get the number of streams */
+ ulNumStreams = rm_parser_get_num_streams(pParser);
+ if (ulNumStreams == 0) {
+ raac_print("[raac decode], no stream found\n");
+ rm_parser_destroy(&pParser);
+ return -1;
+ }
+ for (i = 0; i < ulNumStreams && retVal == HXR_OK; i++) {
+ retVal = rm_parser_get_stream_header(pParser, i, &pHdr);
+ if (retVal == HXR_OK) {
+ if (rm_stream_is_realaudio(pHdr)) {
+ /* Create the RealAudio depacketizer */
+ pRADpack = ra_depack_create((void*)pParser, _raac_block_available, NULL, rm_error);
+ if (!pRADpack) {
+ raac_print("[raac decode], create depack failed\n");
+ rm_parser_destroy_stream_header(pParser, &pHdr);
+ rm_parser_destroy(&pParser);
+ return -1;
+ }
+ /* Initialize the RA depacketizer with the stream header */
+ retVal = ra_depack_init(pRADpack, pHdr);
+ if (retVal != HXR_OK) {
+ raac_print("[raac decode],init depack failed,errid %d\n", retVal);
+ ra_depack_destroy(&pRADpack);
+ rm_parser_destroy_stream_header(pParser, &pHdr);
+ rm_parser_destroy(&pParser);
+ return -1;
+ }
+ /*
+ * Get the codec 4CC of substream 0. We
+ * arbitrarily choose substream 0 here.
+ */
+ ulCodec4CC = ra_depack_get_codec_4cc(pRADpack, 0);
+ if (ulCodec4CC == 0x636F6F6B) { /* cook */
+ retVal = ra_depack_get_codec_init_info(pRADpack, 0, &pRAInfo);
+ raac_info.pRaInfo = pRAInfo;
+ } else if ((ulCodec4CC == 0x72616163) || (ulCodec4CC == 0x72616370))
+ /* raac racp */
+ {
+ retVal = ra_depack_get_codec_init_info(pRADpack, 0, &pRAInfo);
+ raac_info.pRaInfo = pRAInfo;
+ }
+ raac_info.pDepack = pRADpack;
+ }
+ rm_parser_destroy_stream_header(pParser, &pHdr);
+ }
+ raac_print("raac rm_parser_get_stream_header finished\n");
+ }
+ /* Set the stream into the parser */
+ retVal = rm_parser_init_io(pParser, 0, rm_ab_read, rm_ab_seek);
+ if (retVal != HXR_OK) {
+ if (pRADpack) {
+ ra_depack_destroy(&pRADpack);
+ raac_info.pDepack = NULL;
+ }
+ if (pParser) {
+ rm_parser_destroy(&pParser);
+ }
+ raac_print("[raac decode],rm_parser_init_io failed,errid %d\n", retVal);
+ return -1;
+ }
+ raac_info.pParser = pParser;
+ rm_parser_set_stream(&pParser, 0);
+ rm_parser_file_seek(pParser, 0);
+ raac_dec_info.pDecode = ra_decode_create(HXNULL, rm_error);
+ if (retVal != HXR_OK) {
+ if (pRADpack) {
+ ra_depack_destroy(&pRADpack);
+ raac_info.pDepack = NULL;
+ }
+ if (pParser) {
+ rm_parser_destroy(&pParser);
+ }
+ raac_print("[raac decode],ra_decode_create failed,errid %d\n", retVal);
+ return -1;
+ }
+ raac_dec_info.ulStatus = RADEC_PLAY;
+ raac_dec_info.ulTotalSample = 0;
+ raac_dec_info.ulTotalSamplePlayed = 0;
+ UINT32 ulBufSize = 2048/*max sample*/ * 2/*max channel*/ * sizeof(UINT16) * SBR_MUL;
+ raac_dec_info.ulOutBufSize = ulBufSize;
+ raac_dec_info.pOutBuf = (BYTE*) malloc(raac_dec_info.ulOutBufSize);
+ if (raac_dec_info.pOutBuf == NULL) {
+ if (pRADpack) {
+ ra_depack_destroy(&pRADpack);
+ raac_info.pDepack = NULL;
+ }
+ if (pParser) {
+ rm_parser_destroy(&pParser);
+ raac_info.pParser = NULL;
+ }
+ raac_print("[raac decode],dsp malloc failed,request %s bytes\n", raac_dec_info.ulOutBufSize);
+ return -1;
+ }
+ retVal = ra_decode_init(raac_dec_info.pDecode, ulCodec4CC, HXNULL, 0, raac_info.pRaInfo);
+ if (retVal != HXR_OK) {
+ if (pRADpack) {
+ ra_depack_destroy(&pRADpack);
+ raac_info.pDepack = NULL;
+ }
+ if (pParser) {
+ rm_parser_destroy(&pParser);
+ raac_info.pParser = NULL;
+ }
+ raac_print("[raac decode],ra_decode_init failed,errid %d\n", retVal);
+ return -1;
+ }
+ //fmt->valid=CHANNEL_VALID | SAMPLE_RATE_VALID | DATA_WIDTH_VALID;
+ //fmt->channel_num = raac_info.pRaInfo->usNumChannels;
+ //fmt->data_width = 16;
+#if 0//def AAC_ENABLE_SBR
+ //fmt->sample_rate = raac_info.pRaInfo->ulActualRate;
+#else
+ //fmt->sample_rate = raac_info.pRaInfo->ulSampleRate;
+ aac_decode *pdec = (aac_decode *)raac_dec_info.pDecode->pDecode;
+ if (pdec /*&& pdec->ulSampleRateCore*/) {
+ //fmt->sample_rate = pdec->ulSampleRateCore;
+ raac_print("actual sr %d, sr %d,sbr %d,core sr %d,dec aac sr %d \n", raac_info.pRaInfo->ulActualRate, \
+ raac_info.pRaInfo->ulSampleRate, pdec->bSBR, \
+ pdec->ulSampleRateCore, pdec->ulSampleRateOut);
+ }
+#endif
+
+ return 0;
+}
+
+void ra_depack_cleanup(void)
+{
+ /* Destroy the codec init info */
+ if (raac_info.pRaInfo) {
+ ra_depack_destroy_codec_init_info(raac_info.pDepack, &raac_info.pRaInfo);
+ }
+ /* Destroy the depacketizer */
+ if (raac_info.pDepack) {
+ ra_depack_destroy(&raac_info.pDepack);
+ }
+ /* If we have a packet, destroy it */
+ if (raac_info.pPacket) {
+ rm_parser_destroy_packet(raac_info.pParser, &raac_info.pPacket);
+ }
+ if (raac_info.pParser) {
+ rm_parser_destroy(&raac_info.pParser);
+ }
+ memset(&raac_info, 0, sizeof(raac_info));
+}
+
+
+//static int raac_decode_release(void)
+int audio_dec_release(audio_decoder_operations_t *adec_ops)
+{
+ if (cook_input.buf != NULL) {
+ free(cook_input.buf);
+ cook_input.buf = NULL;
+ }
+ if (cook_output.buf != NULL) {
+ free(cook_output.buf);
+ cook_output.buf = NULL;
+ }
+
+ ra_decode_destroy(raac_dec_info.pDecode);
+ raac_dec_info.pDecode = HXNULL;
+ if (raac_dec_info.pOutBuf) {
+ free(raac_dec_info.pOutBuf);
+ raac_dec_info.pOutBuf = HXNULL;
+ }
+ raac_dec_info.ulStatus = RADEC_IDLE;
+ ra_depack_cleanup();
+ raac_print(" raac decoder release\n");
+
+ return 0;
+}
+
+int audio_dec_getinfo(audio_decoder_operations_t *adec_ops, void *pAudioInfo)
+{
+ aac_decode *pdec = (aac_decode *)raac_dec_info.pDecode->pDecode;
+ if (pdec) {
+ ((AudioInfo *)pAudioInfo)->channels = pdec->ulNumChannels;
+ ((AudioInfo *)pAudioInfo)->samplerate = pdec->ulSampleRateOut;
+ }
+ return 0;
+}
+
+
+#if 0
+static struct codec_type raac_codec = {
+ .name = "raac",
+ .init = raac_decode_init,
+ .release = raac_decode_release,
+ .decode_frame = raac_decode_frame,
+};
+
+
+void __used raac_codec_init(void)
+{
+ raac_print("register raac lib \n");
+ register_codec(&raac_codec);
+}
+
+CODEC_INIT(raac_codec_init);
+#endif
diff --git a/audio_codec/libraac/raac_decode.h b/audio_codec/libraac/raac_decode.h
new file mode 100644
index 0000000..1816f09
--- a/dev/null
+++ b/audio_codec/libraac/raac_decode.h
@@ -0,0 +1,37 @@
+#ifndef _AUDIO_CODEC_RAAC_H
+#define _AUDIO_CODEC_RAAC_H
+
+#include "include/rm_parse.h"
+#include "include/ra_depack.h"
+#include "include/ra_decode.h"
+
+
+typedef struct {
+ ra_decode* pDecode;
+ ra_format_info* pRaInfo;
+ BYTE* pOutBuf;
+ UINT32 ulOutBufSize;
+ UINT32 ulTotalSample;
+ UINT32 ulTotalSamplePlayed;
+ UINT32 ulStatus;
+ UINT32 input_buffer_size;
+ BYTE* input_buf;
+ UINT32 decoded_size;
+
+} raac_decoder_info_t;
+
+typedef struct {
+ BYTE *buf;
+ int buf_len;
+ int buf_max;
+ int cousume;
+ int all_consume;
+} cook_IObuf;
+
+#define RADEC_IDLE 0
+#define RADEC_INIT 1
+#define RADEC_PLAY 2
+#define RADEC_PAUSE 3
+
+#define USE_C_DECODER
+#endif
diff --git a/audio_codec/libraac/rm_error_default.c b/audio_codec/libraac/rm_error_default.c
new file mode 100644
index 0000000..f687516
--- a/dev/null
+++ b/audio_codec/libraac/rm_error_default.c
@@ -0,0 +1,60 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_error_default.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <stdio.h>
+//#include "includes.h"
+#include "../include/rm_error.h"
+#include "../include/rm_error_default.h"
+
+#include <android/log.h>
+
+#define LOG_TAG "codec_raac"
+#define raac_print(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+
+void rm_error_default(void* pUserError, HX_RESULT err, const char* msg)
+{
+ if (msg) {
+ raac_print(
+ "rm_error_default(pUserError=0x%08x,err=0x%08x,msg=%s\n",
+ pUserError, err, msg);
+ } else {
+ raac_print(
+ "rm_error_default(pUserError=0x%08x,err=0x%08x\n",
+ pUserError, err);
+ }
+}
diff --git a/audio_codec/libraac/rm_io_default.c b/audio_codec/libraac/rm_io_default.c
new file mode 100644
index 0000000..39d6878
--- a/dev/null
+++ b/audio_codec/libraac/rm_io_default.c
@@ -0,0 +1,101 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_io_default.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+//#include "includes.h"
+//#include "avtimer.h"
+//#include "aw_windows.h"
+//#include "datasrc.h"
+
+#include "../include/helix_types.h"
+#include "../include/rm_io_default.h"
+#include "../include/rm_parse.h"
+
+UINT32 rm_io_default_read(void* pUserRead, BYTE* pBuf, UINT32 ulBytesToRead)
+{
+ UINT32 ulRet = 0;
+#if 0
+ if (pBuf && ulBytesToRead) {
+ /* For default, the void* is a FILE* */
+ INT32 fp = (INT32) pUserRead;
+ /* Read the number of bytes requested */
+ ulRet = (UINT32) read(fp, pBuf, ulBytesToRead);
+ }
+#endif
+ return ulRet;
+}
+
+void rm_io_default_seek(void* pUserRead, UINT32 ulOffset, UINT32 ulOrigin)
+{
+#if 0
+ {
+ /* For default, the void* is a FILE* */
+ INT32 fp = (INT32) pUserRead;
+ /* Do the seek */
+ lseek(fp, ulOffset, ulOrigin);
+ }
+#endif
+}
+
+UINT32 rm_io_datasrc_read(void* pUserRead, BYTE* pBuf, UINT32 ulBytesToRead)
+{
+ UINT32 ulRet = 0;
+#if 0
+ DataSrc_t *ds = (DataSrc_t*)pUserRead;
+
+ if (ds && pBuf && ulBytesToRead) {
+ ulRet = DataSrcRead(ds, pBuf, ulBytesToRead);
+ }
+#endif
+ return ulRet;
+}
+
+void rm_io_datasrc_seek(void* pUserRead, UINT32 ulOffset, UINT32 ulOrigin)
+{
+#if 0
+ DataSrc_t *ds = (DataSrc_t*)pUserRead;
+
+ if (ds) {
+ if (ulOrigin == HX_SEEK_ORIGIN_CUR) {
+ DataSrcSeek(ds, ulOffset, SEEK_CUR);
+ } else if (ulOrigin == HX_SEEK_ORIGIN_SET) {
+ DataSrcSeek(ds, ulOffset, SEEK_SET);
+ } else if (ulOrigin == HX_SEEK_ORIGIN_END) {
+ DataSrcSeek(ds, ulOffset, SEEK_END);
+ }
+ }
+#endif
+}
diff --git a/audio_codec/libraac/rm_memory_default.c b/audio_codec/libraac/rm_memory_default.c
new file mode 100644
index 0000000..e5ed9f0
--- a/dev/null
+++ b/audio_codec/libraac/rm_memory_default.c
@@ -0,0 +1,54 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_memory_default.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+//#include "includes.h"
+#include "../include/rm_memory.h"
+#include "../include/rm_memory_default.h"
+
+void* rm_memory_default_malloc(void* pUserMem, UINT32 ulSize)
+{
+ return (void *)malloc(ulSize);
+}
+
+void rm_memory_default_free(void* pUserMem, void* ptr)
+{
+ free(ptr);
+}
diff --git a/audio_codec/libraac/rm_packet.c b/audio_codec/libraac/rm_packet.c
new file mode 100644
index 0000000..0a7630b
--- a/dev/null
+++ b/audio_codec/libraac/rm_packet.c
@@ -0,0 +1,117 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_packet.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "../include/helix_types.h"
+#include "../include/rm_packet.h"
+
+UINT32 rm_packet_get_timestamp(rm_packet* packet)
+{
+ UINT32 ulRet = 0;
+
+ if (packet) {
+ ulRet = packet->ulTime;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_packet_get_stream_number(rm_packet* packet)
+{
+ UINT32 ulRet = 0;
+
+ if (packet) {
+ ulRet = packet->usStream;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_packet_get_asm_flags(rm_packet* packet)
+{
+ UINT32 ulRet = 0;
+
+ if (packet) {
+ ulRet = packet->usASMFlags;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_packet_get_asm_rule_number(rm_packet* packet)
+{
+ UINT32 ulRet = 0;
+
+ if (packet) {
+ ulRet = packet->ucASMRule;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_packet_get_data_length(rm_packet* packet)
+{
+ UINT32 ulRet = 0;
+
+ if (packet) {
+ ulRet = packet->usDataLen;
+ }
+
+ return ulRet;
+}
+
+BYTE* rm_packet_get_data(rm_packet* packet)
+{
+ BYTE* pRet = HXNULL;
+
+ if (packet) {
+ pRet = packet->pData;
+ }
+
+ return pRet;
+}
+
+HXBOOL rm_packet_is_lost(rm_packet* packet)
+{
+ HXBOOL bRet = FALSE;
+
+ if (packet) {
+ bRet = (packet->ucLost ? TRUE : FALSE);
+ }
+
+ return bRet;
+}
+
diff --git a/audio_codec/libraac/rm_parser.c b/audio_codec/libraac/rm_parser.c
new file mode 100644
index 0000000..80c2c83
--- a/dev/null
+++ b/audio_codec/libraac/rm_parser.c
@@ -0,0 +1,649 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_parser.c,v 1.1.1.1.2.1 2005/05/04 18:21:36 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <stdio.h>
+#include <memory.h>
+#include "../include/helix_types.h"
+#include "../include/helix_result.h"
+#include "../include/rm_parse.h"
+#include "rm_parser_internal.h"
+#include "../include/rm_memory_default.h"
+#include "../include/rm_error_default.h"
+#include "../include/rm_io_default.h"
+#include "../include/memory_utils.h"
+#include "../include/pack_utils.h"
+
+/*
+ * We will create a buffer of this size to handle
+ * reading of headers. The buffer will get increased
+ * in size if we encounter a header bigger than this
+ * size. Therefore, we would like to pick a reasonable
+ * size so that the we don't have lots of little
+ * allocations. This size should be the maximum
+ * of the expected size of the headers in the .rm file.
+ *
+ * XXXMEH - run lots of .rm files to see what a good
+ * size to pick.
+ */
+#define RM_PARSER_INITIAL_READ_BUFFER_SIZE 256
+
+HXBOOL rm_parser_is_rm_file(BYTE* pBuf, UINT32 ulSize)
+{
+ HXBOOL bRet = FALSE;
+
+ /* Look for magic number ".RMF" at the beginning */
+ if (ulSize >= 4) {
+ UINT32 ulID = rm_unpack32(&pBuf, &ulSize);
+ if (ulID == RM_HEADER_OBJECT) {
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+rm_parser* rm_parser_create(void* pError,
+ rm_error_func_ptr fpError)
+{
+ return rm_parser_create2(pError,
+ fpError,
+ HXNULL,
+ rm_memory_default_malloc,
+ rm_memory_default_free);
+}
+
+rm_parser* rm_parser_create2(void* pError,
+ rm_error_func_ptr fpError,
+ void* pMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree)
+{
+ rm_parser* pRet = HXNULL;
+
+ if (fpMalloc) {
+ /* Allocate space for the rm_parser_internal struct
+ * by using the passed-in malloc function
+ */
+ rm_parser_internal* pInt = (rm_parser_internal*) fpMalloc(pMem, sizeof(rm_parser_internal));
+ if (pInt) {
+ /* Zero out the struct */
+ memset((void*) pInt, 0, sizeof(rm_parser_internal));
+ /*
+ * Assign the error members. If the user did not
+ * provide an error callback, then use the default
+ * rm_error_default().
+ */
+ if (fpError) {
+ pInt->fpError = fpError;
+ pInt->pUserError = pError;
+ } else {
+ pInt->fpError = rm_error_default;
+ pInt->pUserError = HXNULL;
+ }
+ /* Assign the memory functions */
+ pInt->fpMalloc = fpMalloc;
+ pInt->fpFree = fpFree;
+ pInt->pUserMem = pMem;
+ /* Assign the return value */
+ pRet = (rm_parser*) pInt;
+ }
+ }
+
+ return pRet;
+}
+
+HX_RESULT rm_parser_init_stdio(rm_parser* pParser,
+ FILE* fp)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser && fp) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Assign the default io functions */
+ pInt->fpRead = rm_io_default_read;
+ pInt->fpSeek = rm_io_default_seek;
+ pInt->pUserRead = (void*) fp;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parser_init_io(rm_parser* pParser,
+ void* pUserRead,
+ rm_read_func_ptr fpRead,
+ rm_seek_func_ptr fpSeek)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser && fpRead && fpSeek) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Assign the default io functions */
+ pInt->fpRead = fpRead;
+ pInt->fpSeek = fpSeek;
+ pInt->pUserRead = pUserRead;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parser_read_headers(rm_parser* pParser)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Allocate the read buffer if necessary */
+ if (!pInt->pReadBuffer) {
+ retVal = rm_enforce_buffer_min_size(pInt->pUserMem,
+ pInt->fpMalloc,
+ pInt->fpFree,
+ &pInt->pReadBuffer,
+ &pInt->ulReadBufferSize,
+ RM_PARSER_INITIAL_READ_BUFFER_SIZE);
+ if (retVal == HXR_OK) {
+ /* Set the number of bytes read to zero */
+ pInt->ulNumBytesRead = 0;
+ }
+ }
+ if (retVal == HXR_OK) {
+ retVal = rm_parseri_read_all_headers(pInt);
+ }
+ }
+
+ return retVal;
+}
+
+
+UINT32 rm_parser_get_max_bit_rate(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.max_bit_rate;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_avg_bit_rate(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.avg_bit_rate;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_max_packet_size(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.max_pkt_size;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_avg_packet_size(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.avg_pkt_size;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_num_packets(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.num_pkts;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_duration(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.duration;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_preroll(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.preroll;
+ }
+
+ return ulRet;
+}
+
+void rm_parser_set_index_offset(rm_parser* pParser, UINT32 offset)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ((rm_parser_internal*) pParser)->propHdr.index_offset = offset;
+ }
+}
+
+UINT32 rm_parser_get_index_offset(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.index_offset;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_data_offset(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->propHdr.data_offset;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_data_size(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->pDataHdr[0].size;
+ }
+
+ return ulRet;
+}
+
+const char* rm_parser_get_title(rm_parser* pParser)
+{
+ const char* pRet = HXNULL;
+
+ if (pParser) {
+ pRet = (const char*)((rm_parser_internal*) pParser)->contHdr.title;
+ }
+
+ return pRet;
+}
+
+const char* rm_parser_get_author(rm_parser* pParser)
+{
+ const char* pRet = HXNULL;
+
+ if (pParser) {
+ pRet = (const char*)((rm_parser_internal*) pParser)->contHdr.author;
+ }
+
+ return pRet;
+}
+
+const char* rm_parser_get_copyright(rm_parser* pParser)
+{
+ const char* pRet = HXNULL;
+
+ if (pParser) {
+ pRet = (const char*)((rm_parser_internal*) pParser)->contHdr.copyright;
+ }
+
+ return pRet;
+}
+
+const char* rm_parser_get_comment(rm_parser* pParser)
+{
+ const char* pRet = HXNULL;
+
+ if (pParser) {
+ pRet = (const char*)((rm_parser_internal*) pParser)->contHdr.comment;
+ }
+
+ return pRet;
+}
+
+UINT32 rm_parser_get_num_streams(rm_parser* pParser)
+{
+ UINT32 ulRet = 0;
+
+ if (pParser) {
+ ulRet = ((rm_parser_internal*) pParser)->ulNumStreams;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parser_get_stream_number(rm_parser* pParser, UINT32 ulStreamNum)
+{
+ UINT32 ulRet = 0xffffffff;
+
+ if (pParser) {
+ ulRet = rm_parseri_get_stream_number((rm_parser_internal*) pParser, ulStreamNum);
+ }
+ return ulRet;
+}
+
+void rm_parser_set_stream_size(rm_parser* pParser, UINT32 ulStreamSize)
+{
+ if (pParser) {
+ rm_parseri_set_stream_size((rm_parser_internal*) pParser, ulStreamSize);
+ }
+}
+
+HX_RESULT rm_parser_get_file_properties(rm_parser* pParser,
+ rm_property** ppProp,
+ UINT32* pulNumProps)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser && ppProp && pulNumProps) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ if (pInt->fpMalloc && pInt->fpFree) {
+ /* Get the number of file properties */
+ UINT32 ulNum = rm_parseri_get_num_file_properties(pInt);
+ if (ulNum) {
+ /* Compute the size of the rm_property array */
+ UINT32 ulSize = ulNum * sizeof(rm_property);
+ /* Allocate an array of this size */
+ rm_property* pPropArr = pInt->fpMalloc(pInt->pUserMem, ulSize);
+ if (pPropArr) {
+ /* NULL out the memory */
+ memset(pPropArr, 0, ulSize);
+ /* Collect the properties */
+ retVal = rm_parseri_get_file_properties(pInt, pPropArr, ulNum);
+ if (retVal == HXR_OK) {
+ /* Assign the out parameters */
+ *ppProp = pPropArr;
+ *pulNumProps = ulNum;
+ } else {
+ /* Free the array */
+ pInt->fpFree(pInt->pUserMem, pPropArr);
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rm_parser_destroy_properties(rm_parser* pParser,
+ rm_property** ppProp,
+ UINT32* pulNumProps)
+{
+ if (pParser && ppProp && pulNumProps && *ppProp && *pulNumProps) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ if (pInt->fpFree) {
+ /* Get the pointer to the array */
+ rm_property* pProp = *ppProp;
+ /* Clean up the properties */
+ UINT32 i = 0;
+ for (i = 0; i < *pulNumProps; i++) {
+ rm_parseri_cleanup_rm_property(pInt, &pProp[i]);
+ }
+ /* Free the memory */
+ pInt->fpFree(pInt->pUserMem, pProp);
+ /* NULL out the pointer */
+ *ppProp = HXNULL;
+ /* Zero out the number of properties */
+ *pulNumProps = 0;
+ }
+ }
+}
+
+HX_RESULT rm_parser_get_stream_header(rm_parser* pParser,
+ UINT32 ulStreamNum,
+ rm_stream_header** ppHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser && ppHdr) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ if (pInt->fpMalloc) {
+ rm_stream_header* pHdr = (rm_stream_header*) pInt->fpMalloc(pInt->pUserMem,
+ sizeof(rm_stream_header));
+ if (pHdr) {
+ /* NULL out the memory */
+ memset(pHdr, 0, sizeof(rm_stream_header));
+ /* Copy the stream header */
+ retVal = rm_parseri_copy_stream_header(pInt, ulStreamNum, pHdr);
+ if (retVal == HXR_OK) {
+ /* Assign the out parameter */
+ *ppHdr = pHdr;
+ } else {
+ /* Clean up the stream header */
+ rm_parseri_cleanup_stream_header(pInt, pHdr);
+ /* Free the memory we allocated */
+ pInt->fpFree(pInt->pUserMem, pHdr);
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rm_parser_destroy_stream_header(rm_parser* pParser,
+ rm_stream_header** ppHdr)
+{
+ if (pParser && ppHdr && *ppHdr) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Cleanup the stream header */
+ rm_parseri_cleanup_stream_header(pInt, *ppHdr);
+ /* Free the memory associated with this header */
+ pInt->fpFree(pInt->pUserMem, *ppHdr);
+ /* NULL out the pointer */
+ *ppHdr = HXNULL;
+ }
+}
+
+HX_RESULT rm_parser_get_packet(rm_parser* pParser,
+ rm_packet** ppPacket)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser && ppPacket) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Read the next packet */
+ retVal = rm_parseri_read_next_packet(pInt, ppPacket);
+ }
+
+ return retVal;
+}
+
+void rm_parser_destroy_packet(rm_parser* pParser,
+ rm_packet** ppPacket)
+{
+ if (pParser && ppPacket && *ppPacket) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ if (pInt->fpFree) {
+ /* Free the packet data */
+ if ((*ppPacket)->pData) {
+ pInt->fpFree(pInt->pUserMem, (*ppPacket)->pData);
+ (*ppPacket)->pData = HXNULL;
+ }
+ /* Free the packet */
+ pInt->fpFree(pInt->pUserMem, *ppPacket);
+ *ppPacket = HXNULL;
+ }
+ }
+}
+
+HX_RESULT rm_parser_seek(rm_parser* pParser,
+ UINT32 ulTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Read the next packet */
+ retVal = rm_parseri_seek(pInt, ulTime);
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parser_build_seek_table(rm_parser* pParser)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Read the next packet */
+ retVal = rm_parseri_build_seek_table(pInt);
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parser_seek_in_seek_table(rm_parser* pParser, INT32 lStreamNumber, UINT32 ulSeekTime, INT32 lDirection, UINT32* pulFoundTime, UINT32* pulDataOffset, UINT32* pulIndex)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Read the next packet */
+ retVal = rm_parseri_search_seek_tables(pInt, lStreamNumber, ulSeekTime, lDirection, pulFoundTime, pulDataOffset, pulIndex);
+ }
+
+ return retVal;
+}
+
+void rm_parser_file_seek(rm_parser* pParser, UINT32 ulOffset)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Read the next packet */
+ rm_parseri_file_seek(pInt, ulOffset, HX_SEEK_ORIGIN_SET);
+ }
+}
+
+void rm_parser_file_skip(rm_parser* pParser, UINT32 ulOffset)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pParser) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) pParser;
+ /* Read the next packet */
+ rm_parseri_file_seek(pInt, ulOffset, HX_SEEK_ORIGIN_CUR);
+ }
+}
+
+void rm_parser_destroy(rm_parser** ppParser)
+{
+ if (ppParser) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) * ppParser;
+ if (pInt && pInt->fpFree) {
+ /* Save a pointer to fpFree and pUserMem */
+ rm_free_func_ptr fpFree = pInt->fpFree;
+ void* pUserMem = pInt->pUserMem;
+ /* Clean up the content header */
+ rm_parseri_cleanup_content_hdr(pInt);
+ /* Clean up the media props headers */
+ rm_parseri_cleanup_all_media_props_hdrs(pInt);
+ /* Clean up all logical stream headers */
+ rm_parseri_cleanup_all_logical_stream_hdrs(pInt);
+ /* Clean up the logical fileinfo header */
+ rm_parseri_cleanup_logical_fileinfo_hdr(pInt);
+ //rm_parseri_cleanup_logical_stream_hdr(pInt, pInt->pLogicalFileInfo);
+ /* Clean up the read buffer */
+ rm_parseri_cleanup_read_buffer(pInt);
+ /* Free the stream num map */
+ rm_parseri_cleanup_stream_num_map(pInt);
+ /* Clean up the stream info array */
+ rm_parseri_cleanup_stream_info_array(pInt);
+ /* Clean up the stream header array */
+ rm_parseri_cleanup_all_stream_headers(pInt);
+ /* Clean up the data header */
+ rm_parseri_cleanup_all_data_headers(pInt);
+ /* Null everything out */
+ memset(pInt, 0, sizeof(rm_parser_internal));
+ /* Free the rm_parser_internal struct memory */
+ fpFree(pUserMem, pInt);
+ /* NULL out the pointer */
+ *ppParser = HXNULL;
+ }
+ }
+}
+
+void rm_parser_set_stream(rm_parser** ppParser, UINT32 ulStreamNum)
+{
+ if (ppParser) {
+ /* Get the internal parser struct */
+ rm_parser_internal* pInt = (rm_parser_internal*) * ppParser;
+ pInt->ulCurrentStream = ulStreamNum;
+ rm_parseri_file_seek(pInt, pInt->pMediaPropsHdr[pInt->ulCurrentStream].start_offset, HX_SEEK_ORIGIN_SET);
+ }
+} \ No newline at end of file
diff --git a/audio_codec/libraac/rm_parser_internal.c b/audio_codec/libraac/rm_parser_internal.c
new file mode 100644
index 0000000..f0ac95a
--- a/dev/null
+++ b/audio_codec/libraac/rm_parser_internal.c
@@ -0,0 +1,3342 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_parser_internal.c,v 1.2.2.1 2005/05/04 18:21:36 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <memory.h>
+//#include "includes.h"
+//#include "ioapi.h"
+//#include "datasrc.h"
+#include "../include/helix_types.h"
+#include "../include/helix_result.h"
+#include "../include/helix_utils.h"
+#include "rm_parser_internal.h"
+#include "../include/rm_memory_default.h"
+#include "../include/memory_utils.h"
+#include "../include/pack_utils.h"
+#include "../include/string_utils.h"
+#include "../include/rm_stream.h"
+#include "../include/packet_defines.h"
+#include "../include/rv_format_info.h"
+
+#define RM_PARSER_LOGICAL_PREFIX "logical-"
+#define RM_PARSER_LOGICAL_FILEINFO "logical-fileinfo"
+#define RM_PARSER_NUM_RULE_BOOKS 9
+#define RM_PARSER_RULE_BOOK_BUFFER_SIZE 320 /* Big enough for format string and args */
+
+#define RM_PARSER_LOGICAL_MULTIRATE_VIDEO "logical-video/x-pn-multirate-realvideo"
+#define RM_PARSER_LOGICAL_MULTIRATE_AUDIO "logical-audio/x-pn-multirate-realaudio"
+
+static const char* g_pszRuleBook[] = {
+ /* VBR Real streams when max_bit_rate != 0 */
+ "priority=%lu,AverageBandwidth=%lu,MaximumBandwidth=%lu,"
+ "TimeStampDelivery=TRUE,PNMKeyFrameRule=T;"
+ "OnDepend=\"0\",priority=%lu,AverageBandwidth=0,MaximumBandwidth=0,"
+ "TimeStampDelivery=TRUE,PNMNonKeyFrameRule=T;",
+ /* VBR Real streams when max_bit_rate == 0 */
+ "priority=%lu,AverageBandwidth=%lu,TimeStampDelivery=TRUE,PNMKeyFrameRule=T;"
+ "OnDepend=\"0\",priority=%lu,AverageBandwidth=0,TimeStampDelivery=TRUE,PNMNonKeyFrameRule=T;",
+ /* Non-real-datatype VBR streams when max_bit_rate != 0 */
+ "Marker=0,AverageBandwidth=%lu,MaximumBandwidth=%lu,TimeStampDelivery=TRUE;"
+ "Marker=1,AverageBandwidth=0,MaximumBandwidth=0,TimeStampDelivery=TRUE;",
+ /* Non-real-datatype VBR streams when max_bit_rate == 0 && avg_bit_rate != 0 */
+ "Marker=0,AverageBandwidth=%lu,TimeStampDelivery=TRUE;"
+ "Marker=1,AverageBandwidth=0,TimeStampDelivery=TRUE;",
+ /* Non-real-datatype VBR streams when max_bit_rate == 0 && avg_bit_rate == 0 */
+ "Marker=0,TimeStampDelivery=TRUE;"
+ "Marker=1,TimeStampDelivery=TRUE;",
+ /* CBR RealVideo */
+ "#($Bandwidth >= %lu),priority=9,averagebandwidth=%lu,PNMKeyFrameRule=T;"
+ "#($Bandwidth >= %lu),OnDepend=\"0\",priority=5,averagebandwidth=0,PNMNonKeyFrameRule=T;"
+ "#($Bandwidth < %lu),priority=9,timestampdelivery=T,DropByN=T,PNMThinningRule=T;",
+ /* RealEvent streams */
+ "TimeStampDelivery=T,priority=10,PNMKeyFrameRule=T;"
+ "TimeStampDelivery=T,priority=10,PNMNonKeyFrameRule=T;",
+ /* CBR RealAudio streams */
+ "priority=5,averagebandwidth=%lu,PNMKeyFrameRule=T;"
+ "priority=5,averagebandwidth=0,PNMNonKeyFrameRule=T,OnDepend=\"0\",OffDepend=\"0\";",
+ /* CBR non-real-datatype streams */
+ "Marker=0,priority=5,averagebandwidth=%lu;"
+ "Marker=1,priority=5,averagebandwidth=0;"
+};
+
+HX_RESULT rm_parseri_unpack_generic_hdr(rm_parser_internal* pInt, struct rm_generic_hdr* h)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && h) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ if (ulLen >= 10) {
+ /* Unpack the rm_generic_hdr */
+ h->id = rm_unpack32(&pBuf, &ulLen);
+ h->size = rm_unpack32(&pBuf, &ulLen);
+ h->version = rm_unpack16(&pBuf, &ulLen);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+
+HX_RESULT rm_parseri_unpack_file_hdr(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ if (ulLen >= 18) {
+ /* Unpack the rm_file_hdr */
+ pInt->fileHdr.id = rm_unpack32(&pBuf, &ulLen);
+ pInt->fileHdr.size = rm_unpack32(&pBuf, &ulLen);
+ pInt->fileHdr.version = rm_unpack16(&pBuf, &ulLen);
+ pInt->fileHdr.file_version = rm_unpack32(&pBuf, &ulLen);
+ pInt->fileHdr.num_headers = rm_unpack32(&pBuf, &ulLen);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ } else if (ulLen == 16) {
+ /* Unpack the rm_file_hdr */
+ pInt->fileHdr.id = rm_unpack32(&pBuf, &ulLen);
+ pInt->fileHdr.size = rm_unpack32(&pBuf, &ulLen);
+ pInt->fileHdr.version = rm_unpack16(&pBuf, &ulLen);
+ if (pInt->fileHdr.version == 0) {
+ pInt->fileHdr.file_version = rm_unpack16(&pBuf, &ulLen);
+ pInt->fileHdr.num_headers = rm_unpack32(&pBuf, &ulLen);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_unpack_properties_hdr(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ if (ulLen >= 50) {
+ /* Unpack the rm_properties_hdr */
+ pInt->propHdr.id = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.size = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.version = rm_unpack16(&pBuf, &ulLen);
+ pInt->propHdr.max_bit_rate = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.avg_bit_rate = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.max_pkt_size = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.avg_pkt_size = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.num_pkts = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.duration = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.preroll = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.index_offset = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.data_offset = rm_unpack32(&pBuf, &ulLen);
+ pInt->propHdr.num_streams = rm_unpack16(&pBuf, &ulLen);
+ pInt->propHdr.flags = rm_unpack16(&pBuf, &ulLen);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_unpack_content_hdr(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ if (ulLen >= 12) {
+ /* Unpack the rm_content_hdr */
+ pInt->contHdr.id = rm_unpack32(&pBuf, &ulLen);
+ pInt->contHdr.size = rm_unpack32(&pBuf, &ulLen);
+ pInt->contHdr.version = rm_unpack16(&pBuf, &ulLen);
+ pInt->contHdr.title_sz = rm_unpack16(&pBuf, &ulLen);
+ if (ulLen >= (UINT32) pInt->contHdr.title_sz + 2) {
+ rm_unpack_string(&pBuf, &ulLen, pInt->contHdr.title_sz,
+ &pInt->contHdr.title, pInt->pUserMem,
+ pInt->fpMalloc, pInt->fpFree);
+ pInt->contHdr.author_sz = rm_unpack16(&pBuf, &ulLen);
+ if (ulLen >= (UINT32) pInt->contHdr.author_sz + 2) {
+ rm_unpack_string(&pBuf, &ulLen, pInt->contHdr.author_sz,
+ &pInt->contHdr.author, pInt->pUserMem,
+ pInt->fpMalloc, pInt->fpFree);
+ pInt->contHdr.copyright_sz = rm_unpack16(&pBuf, &ulLen);
+ if (ulLen >= (UINT32) pInt->contHdr.copyright_sz + 2) {
+ rm_unpack_string(&pBuf, &ulLen, pInt->contHdr.copyright_sz,
+ &pInt->contHdr.copyright, pInt->pUserMem,
+ pInt->fpMalloc, pInt->fpFree);
+ pInt->contHdr.comment_sz = rm_unpack16(&pBuf, &ulLen);
+ if (ulLen >= pInt->contHdr.comment_sz) {
+ rm_unpack_string(&pBuf, &ulLen, pInt->contHdr.comment_sz,
+ &pInt->contHdr.comment, pInt->pUserMem,
+ pInt->fpMalloc, pInt->fpFree);
+ if (ulLen >= 4) {
+ if (RM_DATA_OBJECT == rm_unpack32_nse(pBuf, ulLen)) {
+ rm_parseri_file_seek(pInt, pInt->ulCurFileOffset - ulLen, HX_SEEK_ORIGIN_SET);
+ }
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rm_parseri_cleanup_content_hdr(rm_parser_internal* pInt)
+{
+ if (pInt) {
+ /* Delete the title string */
+ if (pInt->contHdr.title) {
+ rm_parseri_free(pInt, pInt->contHdr.title);
+ pInt->contHdr.title = HXNULL;
+ }
+ /* Delete the author string */
+ if (pInt->contHdr.author) {
+ rm_parseri_free(pInt, pInt->contHdr.author);
+ pInt->contHdr.author = HXNULL;
+ }
+ /* Delete the copyright string */
+ if (pInt->contHdr.copyright) {
+ rm_parseri_free(pInt, pInt->contHdr.copyright);
+ pInt->contHdr.copyright = HXNULL;
+ }
+ /* Delete the comment string */
+ if (pInt->contHdr.comment) {
+ rm_parseri_free(pInt, pInt->contHdr.comment);
+ pInt->contHdr.comment = HXNULL;
+ }
+ }
+}
+
+HX_RESULT rm_parseri_unpack_media_props_hdr(rm_parser_internal* pInt,
+ struct rm_media_props_hdr* h)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && h) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ /* Unpack the rm_media_props_hdr */
+ if (ulLen >= 41) {
+ h->id = rm_unpack32(&pBuf, &ulLen);
+ h->size = rm_unpack32(&pBuf, &ulLen);
+ h->version = rm_unpack16(&pBuf, &ulLen);
+ h->stream_num = rm_unpack16(&pBuf, &ulLen);
+ h->max_bit_rate = rm_unpack32(&pBuf, &ulLen);
+ h->avg_bit_rate = rm_unpack32(&pBuf, &ulLen);
+ h->max_pkt_size = rm_unpack32(&pBuf, &ulLen);
+ h->avg_pkt_size = rm_unpack32(&pBuf, &ulLen);
+ h->start_time = rm_unpack32(&pBuf, &ulLen);
+ h->preroll = rm_unpack32(&pBuf, &ulLen);
+ h->duration = rm_unpack32(&pBuf, &ulLen);
+ h->stream_name_sz = rm_unpack8(&pBuf, &ulLen);
+ if (ulLen >= (UINT32) h->stream_name_sz + 1) {
+ rm_unpack_string(&pBuf, &ulLen, h->stream_name_sz, &h->stream_name,
+ pInt->pUserMem, pInt->fpMalloc, pInt->fpFree);
+ h->mime_type_sz = rm_unpack8(&pBuf, &ulLen);
+ if (ulLen >= (UINT32) h->mime_type_sz + 4) {
+ rm_unpack_string(&pBuf, &ulLen, h->mime_type_sz, &h->mime_type,
+ pInt->pUserMem, pInt->fpMalloc, pInt->fpFree);
+ h->type_spec_sz = rm_unpack32(&pBuf, &ulLen);
+ if (ulLen >= (UINT32) h->type_spec_sz) {
+ rm_unpack_buffer(&pBuf, &ulLen, h->type_spec_sz, &h->type_spec,
+ pInt->pUserMem, pInt->fpMalloc, pInt->fpFree);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rm_parseri_cleanup_media_props_hdr(rm_parser_internal* pInt,
+ struct rm_media_props_hdr* h)
+{
+ if (pInt && h) {
+ /* Delete the stream name string */
+ if (h->stream_name) {
+ rm_parseri_free(pInt, h->stream_name);
+ h->stream_name = HXNULL;
+ }
+ /* Delete the mime type string */
+ if (h->mime_type) {
+ rm_parseri_free(pInt, h->mime_type);
+ h->mime_type = HXNULL;
+ }
+ /* Delete the type specific data buffer */
+ if (h->type_spec) {
+ rm_parseri_free(pInt, h->type_spec);
+ h->type_spec = HXNULL;
+ }
+ }
+}
+
+void rm_parseri_cleanup_all_media_props_hdrs(rm_parser_internal* pInt)
+{
+ if (pInt && pInt->pMediaPropsHdr) {
+ /* Clean up each individual media properties header */
+ UINT32 i = 0;
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ rm_parseri_cleanup_media_props_hdr(pInt, &pInt->pMediaPropsHdr[i]);
+ }
+ /* Free the memory for the array */
+ rm_parseri_free(pInt, pInt->pMediaPropsHdr);
+ /* Zero out the number of media props headers */
+ pInt->ulNumMediaPropsHdrs = 0;
+ pInt->ulNumMediaPropsHdrsAlloc = 0;
+ /* Null out the pointer */
+ pInt->pMediaPropsHdr = HXNULL;
+ }
+}
+
+HX_RESULT rm_parseri_unpack_name_value_map(rm_parser_internal* pInt,
+ struct rm_name_value_map* pMap,
+ BYTE** ppBuf, UINT32* pulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pMap && ppBuf && pulLen && *pulLen >= 7) {
+ /* Unpack the name-value map struct */
+ pMap->size = rm_unpack32(ppBuf, pulLen);
+ pMap->version = rm_unpack16(ppBuf, pulLen);
+ pMap->name_sz = rm_unpack8(ppBuf, pulLen);
+ if (*pulLen >= (UINT32) pMap->name_sz + 6) {
+ rm_unpack_string(ppBuf, pulLen, pMap->name_sz, &pMap->name,
+ pInt->pUserMem, pInt->fpMalloc, pInt->fpFree);
+ pMap->type = rm_unpack32(ppBuf, pulLen);
+ pMap->value_sz = rm_unpack16(ppBuf, pulLen);
+ if (*pulLen >= pMap->value_sz) {
+ rm_unpack_buffer(ppBuf, pulLen, pMap->value_sz, &pMap->value,
+ pInt->pUserMem, pInt->fpMalloc, pInt->fpFree);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rm_parseri_cleanup_name_value_map(rm_parser_internal* pInt,
+ struct rm_name_value_map* h)
+{
+ if (pInt && h) {
+ /* Delete the name string */
+ if (h->name) {
+ rm_parseri_free(pInt, h->name);
+ h->name = HXNULL;
+ }
+ /* Delete the value buffer */
+ if (h->value) {
+ rm_parseri_free(pInt, h->value);
+ h->value = HXNULL;
+ }
+ }
+}
+
+void rm_parseri_cleanup_all_name_value_maps(rm_parser_internal* pInt,
+ struct rm_logical_stream_hdr* h)
+{
+ if (pInt && h && h->props) {
+ /* Clean up each name-value pair */
+ UINT16 i = 0;
+ for (i = 0; i < h->num_props; i++) {
+ rm_parseri_cleanup_name_value_map(pInt, &h->props[i]);
+ }
+ /* Free the array of props */
+ rm_parseri_free(pInt, h->props);
+ /* Zero out the number of props */
+ h->num_props = 0;
+ /* NULL out the pointer */
+ h->props = HXNULL;
+ }
+}
+
+HX_RESULT rm_parseri_unpack_logical_stream_hdr(rm_parser_internal* pInt,
+ struct rm_media_props_hdr* mh,
+ struct rm_logical_stream_hdr* h)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && mh && mh->type_spec && mh->type_spec_sz > 0 && h) {
+ /* Assign temporary variables */
+ BYTE* pBuf = mh->type_spec;
+ UINT32 ulLen = mh->type_spec_sz;
+ UINT32 ulSize = 0;
+ UINT16 i = 0;
+ /* Parse the logical stream header */
+ if (ulLen >= 8) {
+ h->size = rm_unpack32(&pBuf, &ulLen);
+ h->version = rm_unpack16(&pBuf, &ulLen);
+ h->num_physical_streams = rm_unpack16(&pBuf, &ulLen);
+ if (ulLen >= (UINT32) 6 * h->num_physical_streams + 2) {
+ rm_unpack_array(&pBuf, &ulLen, h->num_physical_streams, sizeof(UINT16),
+ (void**) &h->physical_stream_num, pInt->pUserMem,
+ pInt->fpMalloc, pInt->fpFree);
+ rm_unpack_array(&pBuf, &ulLen, h->num_physical_streams, sizeof(UINT32),
+ (void**) &h->data_offsets, pInt->pUserMem,
+ pInt->fpMalloc, pInt->fpFree);
+ h->num_rules = rm_unpack16(&pBuf, &ulLen);
+ if (ulLen >= (UINT32) h->num_rules * 2 + 2) {
+ rm_unpack_array(&pBuf, &ulLen, h->num_rules, sizeof(UINT16),
+ (void**) &h->rule_stream_map, pInt->pUserMem,
+ pInt->fpMalloc, pInt->fpFree);
+ h->num_props = rm_unpack16(&pBuf, &ulLen);
+ /* Clean up any existing name-value pairs */
+ rm_parseri_cleanup_all_name_value_maps(pInt, h);
+ /* Allocate an array of name value pairs */
+ ulSize = h->num_props * sizeof(struct rm_name_value_map);
+ if (ulSize) {
+ h->props = (struct rm_name_value_map*) rm_parseri_malloc(pInt, ulSize);
+ if (h->props) {
+ /* NULL out the memory */
+ memset(h->props, 0, ulSize);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Unpack each of the name-value pairs */
+ for (i = 0; i < h->num_props && retVal == HXR_OK; i++) {
+ retVal = rm_parseri_unpack_name_value_map(pInt, &h->props[i],
+ &pBuf, &ulLen);
+ }
+ }
+ } else {
+ /* No properties - not an error */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+UINT32 rm_parseri_get_num_logical_streams(rm_parser_internal* pInt)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt && pInt->pMediaPropsHdr) {
+ UINT32 i = 0;
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ const char* pszMimeType = (const char*) pInt->pMediaPropsHdr[i].mime_type;
+ if (rm_parseri_is_logical_stream_mime_type(pszMimeType)) {
+ ulRet++;
+ }
+ }
+ }
+
+ return ulRet;
+}
+
+HXBOOL rm_parseri_is_logical_fileinfo_present(rm_parser_internal* pInt, UINT32* pulIndx)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pInt && pInt->pMediaPropsHdr && pulIndx) {
+ UINT32 i = 0;
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ const char* pszMimeType = (const char*) pInt->pMediaPropsHdr[i].mime_type;
+ if (rm_parseri_is_logical_fileinfo_mime_type(pszMimeType)) {
+ bRet = TRUE;
+ *pulIndx = i;
+ break;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+void rm_parseri_cleanup_logical_fileinfo_hdr(rm_parser_internal* pInt)
+{
+ if (pInt && pInt->pLogicalFileInfo) {
+ /* Clean up the struct */
+ rm_parseri_cleanup_logical_stream_hdr(pInt, pInt->pLogicalFileInfo);
+ /* Free the struct memory */
+ rm_parseri_free(pInt, pInt->pLogicalFileInfo);
+ /* NULL out the pointer */
+ pInt->pLogicalFileInfo = HXNULL;
+ }
+}
+
+HX_RESULT rm_parseri_unpack_all_logical_stream_hdrs(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ /* Declare some local variables we need later */
+ UINT32 ulSize = 0;
+ UINT32 ulIndx = 0;
+ UINT32 i = 0;
+ /* Get the number of media props headers that are logical streams */
+ UINT32 ulNumLogical = rm_parseri_get_num_logical_streams(pInt);
+ if (ulNumLogical) {
+ /* Free any existing logical stream array */
+ rm_parseri_cleanup_all_logical_stream_hdrs(pInt);
+ /* Compute the size of the logical stream header array */
+ ulSize = ulNumLogical * sizeof(struct rm_logical_stream_hdr);
+ /* Allocate the array of logical stream headers */
+ pInt->pLogicalStreamHdr =
+ (struct rm_logical_stream_hdr*) rm_parseri_malloc(pInt, ulSize);
+ if (pInt->pLogicalStreamHdr) {
+ /* Zero out the memory */
+ memset(pInt->pLogicalStreamHdr, 0, ulSize);
+ /* Assign the number of logical stream headers */
+ pInt->ulNumLogicalStreamHdrs = ulNumLogical;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /*
+ * Loop through all the media properties headers, and
+ * if a header is a logical stream, then unpack it
+ */
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs && retVal == HXR_OK; i++) {
+ const char* pszMimeType = (const char*) pInt->pMediaPropsHdr[i].mime_type;
+ if (rm_parseri_is_logical_stream_mime_type(pszMimeType)) {
+ /*
+ * Unpack the logical stream. We don't have
+ * to worry about ulIndx being less than
+ * ulNumLogicalStreamHdrs since we already
+ * guaranteed above that ulNumLogicalStreamHdrs
+ * was correct.
+ */
+ retVal = rm_parseri_unpack_logical_stream_hdr(pInt,
+ &pInt->pMediaPropsHdr[i],
+ &pInt->pLogicalStreamHdr[ulIndx]);
+ if (retVal == HXR_OK) {
+ ulIndx++;
+ } else {
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal, "Failed to parse logical stream header.");
+ }
+ }
+ }
+ }
+ } else {
+ /* No logical streams - single-rate file */
+ retVal = HXR_OK;
+ }
+ if (retVal == HXR_OK) {
+ /* Clean up any existing logical-fileinfo header */
+ rm_parseri_cleanup_logical_fileinfo_hdr(pInt);
+ /* Do we have a logical-fileinfo header? */
+ if (rm_parseri_is_logical_fileinfo_present(pInt, &ulIndx)) {
+ /* Compute the size of the logical fileinfo */
+ ulSize = sizeof(struct rm_logical_stream_hdr);
+ /* Allocate space for the struct */
+ pInt->pLogicalFileInfo =
+ (struct rm_logical_stream_hdr*) rm_parseri_malloc(pInt, ulSize);
+ if (pInt->pLogicalFileInfo) {
+ /* Zero out the memory */
+ memset(pInt->pLogicalFileInfo, 0, ulSize);
+ /* Unpack the logical-fileinfo struct */
+ retVal = rm_parseri_unpack_logical_stream_hdr(pInt,
+ &pInt->pMediaPropsHdr[ulIndx],
+ pInt->pLogicalFileInfo);
+ if (retVal != HXR_OK) {
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal, "Failed to parse logical-fileinfo header.");
+ }
+ } else {
+ retVal = HXR_OUTOFMEMORY;
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rm_parseri_cleanup_logical_stream_hdr(rm_parser_internal* pInt,
+ struct rm_logical_stream_hdr* h)
+{
+ if (pInt && h) {
+ /* Delete the stream number array */
+ if (h->physical_stream_num) {
+ rm_parseri_free(pInt, h->physical_stream_num);
+ h->physical_stream_num = HXNULL;
+ }
+ /* Delete the data offsets array */
+ if (h->data_offsets) {
+ rm_parseri_free(pInt, h->data_offsets);
+ h->data_offsets = HXNULL;
+ }
+ /* Delete the rule-to-stream map */
+ if (h->rule_stream_map) {
+ rm_parseri_free(pInt, h->rule_stream_map);
+ h->rule_stream_map = HXNULL;
+ }
+ /* Clean up the logical stream props */
+ rm_parseri_cleanup_all_name_value_maps(pInt, h);
+ }
+}
+
+void rm_parseri_cleanup_all_logical_stream_hdrs(rm_parser_internal* pInt)
+{
+ if (pInt && pInt->pLogicalStreamHdr) {
+ /* Clean up the individual logical stream headers */
+ UINT32 i = 0;
+ for (i = 0; i < pInt->ulNumLogicalStreamHdrs; i++) {
+ rm_parseri_cleanup_logical_stream_hdr(pInt, &pInt->pLogicalStreamHdr[i]);
+ }
+ /* Free the memory of the array */
+ rm_parseri_free(pInt, pInt->pLogicalStreamHdr);
+ /* NULL out the array pointer */
+ pInt->pLogicalStreamHdr = HXNULL;
+ /* Zero out the array size and number of headers */
+ pInt->ulNumLogicalStreamHdrs = 0;
+ }
+}
+
+HX_RESULT rm_parseri_allocate_media_props_hdrs(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_OUTOFMEMORY;
+
+ if (pInt) {
+ UINT32 ulSize = 0;
+ /* Clean up any existing media properties header array */
+ rm_parseri_cleanup_all_media_props_hdrs(pInt);
+ /*
+ * Compute the number of stream properties headers
+ * we need to allocate. Normally this is propHdr.num_streams,
+ * but for file version > 0, it is possible to have file-info
+ * header for each stream but not all of them may be present.
+ */
+ pInt->ulNumMediaPropsHdrsAlloc = pInt->propHdr.num_streams;
+ if (pInt->fileHdr.file_version != 0) {
+ if (pInt->ulNumMediaPropsHdrsAlloc > 2) {
+ pInt->ulNumMediaPropsHdrsAlloc = (pInt->ulNumMediaPropsHdrsAlloc - 1) * 2;
+ }
+ }
+ /* Calculate the size of the stream property header array */
+ ulSize = pInt->ulNumMediaPropsHdrsAlloc * sizeof(struct rm_media_props_hdr);
+ /* Allocate the number of media properties headers */
+ pInt->pMediaPropsHdr =
+ (struct rm_media_props_hdr*) rm_parseri_malloc(pInt, ulSize);
+ if (pInt->pMediaPropsHdr) {
+ /* NULL out the memory */
+ memset((void*) pInt->pMediaPropsHdr, 0, ulSize);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+void rm_parseri_cleanup_read_buffer(rm_parser_internal* pInt)
+{
+ if (pInt && pInt->pReadBuffer) {
+ rm_parseri_free(pInt, pInt->pReadBuffer);
+ pInt->pReadBuffer = HXNULL;
+ pInt->ulReadBufferSize = 0;
+ pInt->ulNumBytesRead = 0;
+ }
+}
+
+UINT32 rm_parseri_get_media_props_hdr_stream_num(rm_parser_internal* pInt)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt && pInt->pReadBuffer && pInt->ulNumBytesRead >= 12) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ /* Skip directly to the stream_num */
+ pBuf += 10;
+ ulLen -= 10;
+ /* Unpack the stream_num. */
+ ulRet = (UINT32) rm_unpack16(&pBuf, &ulLen);
+ }
+
+ return ulRet;
+}
+
+HXBOOL rm_parseri_is_logical_stream_mime_type(const char* pszMimeType)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pszMimeType) {
+ if (!rm_parseri_is_logical_fileinfo_mime_type(pszMimeType)) {
+ if (!strncmp(pszMimeType, RM_PARSER_LOGICAL_PREFIX,
+ strlen(RM_PARSER_LOGICAL_PREFIX))) {
+ bRet = TRUE;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+HXBOOL rm_parseri_is_logical_fileinfo_mime_type(const char* pszMimeType)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pszMimeType) {
+ if (!strcmp(pszMimeType, RM_PARSER_LOGICAL_FILEINFO)) {
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+HX_RESULT rm_parseri_read_next_header(rm_parser_internal* pInt, UINT32* pulID)
+{
+ HX_RESULT retVal = HXR_UNEXPECTED;
+ if (pInt && pulID) {
+ struct rm_generic_hdr genHdr;
+ UINT32 ulHeaderSize = 0;
+ UINT32 ulBytesToRead = 0;
+ UINT32 ulNumBytesRead = 0;
+ /* Set the return value */
+ retVal = HXR_READ_ERROR;
+ /* Read a generic header into the read buffer */
+ ulBytesToRead = RM_PARSER_GENERIC_HDR_SIZE;
+ ulNumBytesRead = rm_parseri_file_read(pInt, ulBytesToRead, 0);
+ /* Make sure we read enough */
+ if (ulNumBytesRead == ulBytesToRead) {
+ /* Unpack a generic header */
+ rm_parseri_unpack_generic_hdr(pInt, &genHdr);
+ /*
+ * Compute the size of the header. For
+ * most header types, this will be the size specified
+ * in the "size" field. However, for data chunk headers and
+ * index chunk headers, the "size" also includes the CONTENTS
+ * of the chunk (all the packets or all the index records).
+ * So for those chunks we must special case them.
+ */
+ ulHeaderSize = genHdr.size;
+ if (genHdr.id == RM_DATA_OBJECT) {
+ ulHeaderSize = RM_PARSER_DATA_CHUNK_HEADER_SIZE;
+ } else if (genHdr.id == RM_INDEX_OBJECT) {
+ ulHeaderSize = RM_PARSER_INDEX_HEADER_SIZE;
+ }
+ /* Now compute how many bytes we still need to read */
+ if (ulHeaderSize > RM_PARSER_GENERIC_HDR_SIZE) {
+ /* some incomplete downloaded file filled with 0xffffffff by downloader */
+ if (ulHeaderSize != 0xffffffff) {
+ ulBytesToRead = ulHeaderSize - RM_PARSER_GENERIC_HDR_SIZE;
+ /* Read the rest of the chunk */
+ ulNumBytesRead = rm_parseri_file_read(pInt, ulBytesToRead, RM_PARSER_GENERIC_HDR_SIZE);
+ if (ulNumBytesRead == ulBytesToRead) {
+ /* Assign the header id to the out parameter */
+ *pulID = genHdr.id;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ } else {
+ /* Call back to error interface */
+ rm_parseri_error(pInt, retVal, "Could not read chunk data.");
+ }
+ } else {
+ /* Call back to error interface */
+ rm_parseri_error(pInt, retVal, "Could not read chunk data.");
+ }
+ }
+ } else {
+ /* Call back to error interface */
+ rm_parseri_error(pInt, retVal, "Could not read chunk header.");
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_read_next_packet_header(rm_parser_internal* pInt,
+ struct rm_pkt_hdr* pPktHdr)
+{
+ HX_RESULT retVal = HXR_UNEXPECTED;
+
+ if (pInt) {
+ UINT32 ulNumBytesRead = 0;
+ /* Change the error return */
+ retVal = HXR_READ_ERROR;
+ /* Read the packet header into the read buffer */
+ ulNumBytesRead = rm_parseri_file_read(pInt, RM_PARSER_PACKET_HEADER_SIZE, 0);
+ if (ulNumBytesRead == RM_PARSER_PACKET_HEADER_SIZE) {
+ /* Unpack the packet header */
+ retVal = rm_parseri_unpack_pkt_hdr(pInt, pPktHdr);
+ } else {
+ /* Call back to error interface */
+ rm_parseri_error(pInt, retVal, "Could not read packet header.");
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_setup_interleaved_streams(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_NOT_SUPPORTED;
+
+ if (pInt && pInt->pMediaPropsHdr && pInt->ulNumMediaPropsHdrs) {
+ /* Declare some locals we'll need later */
+ struct rm_media_props_hdr* pTmp = HXNULL;
+ UINT32 ulNumInterleaved = 0;
+ /* Allocate a temporary array of HXBOOLs */
+ UINT32 ulSize = pInt->ulNumMediaPropsHdrs * sizeof(HXBOOL);
+ HXBOOL* pInterleaved = (HXBOOL*) rm_parseri_malloc(pInt, ulSize);
+ if (pInterleaved) {
+ /* Init them all the TRUE */
+ UINT32 i = 0;
+ UINT32 j = 0;
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ pInterleaved[i] = TRUE;
+ }
+ /*
+ * Now run through the all the logical streams
+ * and remove the physical streams
+ */
+ for (i = 0; i < pInt->ulNumLogicalStreamHdrs; i++) {
+ for (j = 0; j < (UINT32) pInt->pLogicalStreamHdr[i].num_physical_streams; j++) {
+ pInterleaved[pInt->pLogicalStreamHdr[i].physical_stream_num[j]] = FALSE;
+ }
+ }
+ /*
+ * Now remove the media props headers that
+ * are actually logical stream and logical fileinfo headers.
+ */
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ const char* pszMimeType = (const char*) pInt->pMediaPropsHdr[i].mime_type;
+ if (rm_parseri_is_logical_stream_mime_type(pszMimeType) ||
+ rm_parseri_is_logical_fileinfo_mime_type(pszMimeType)) {
+ pInterleaved[i] = FALSE;
+ }
+ }
+ /* Now count the interleaved streams */
+ ulNumInterleaved = 0;
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ if (pInterleaved[i]) {
+ ulNumInterleaved++;
+ }
+ }
+ /* Do we have any interleaved streams? */
+ if (ulNumInterleaved) {
+ /* Allocate a new array of media props headers */
+ retVal = HXR_OUTOFMEMORY;
+ ulSize = ulNumInterleaved * sizeof(struct rm_media_props_hdr);
+ pTmp = (struct rm_media_props_hdr*) rm_parseri_malloc(pInt, ulSize);
+ if (pTmp) {
+ /* Copy the media props headers which are interleaved */
+ j = 0;
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ if (pInterleaved[i]) {
+ pInt->pMediaPropsHdr[i].start_offset = pInt->propHdr.data_offset;
+ pTmp[j++] = pInt->pMediaPropsHdr[i];
+ } else {
+ rm_parseri_cleanup_media_props_hdr(pInt, &pInt->pMediaPropsHdr[i]);
+ }
+ }
+ /* Free the logical stream array. */
+ rm_parseri_cleanup_all_logical_stream_hdrs(pInt);
+ /* Delete the memory associated with the old media props array */
+ rm_parseri_free(pInt, pInt->pMediaPropsHdr);
+ /* Replace the old media props array with the new one */
+ pInt->pMediaPropsHdr = pTmp;
+ /* Update the number of media props headers */
+ pInt->ulNumMediaPropsHdrs = ulNumInterleaved;
+ pInt->ulNumMediaPropsHdrsAlloc = ulNumInterleaved;
+ /* Update the number of streams */
+ pInt->ulNumStreams = ulNumInterleaved;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ /* Free the temporary array */
+ rm_parseri_free(pInt, pInterleaved);
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_unpack_logical_multirate_type_spec(rm_parser_internal* pInt, UINT32 index)
+{
+ HX_RESULT retVal = HXR_NOT_SUPPORTED;
+ UINT16 *pStreamNum;
+ unsigned char *pOffset;
+ UINT16 num_stream = 0;
+ int w = 0xFF; /* For run-time endianness detection */
+ int i, j;
+ UINT16 stream_num;
+ UINT32 start_offset;
+
+ if (pInt->pMediaPropsHdr[index].type_spec) {
+ memcpy(&num_stream, pInt->pMediaPropsHdr[index].type_spec + 6, sizeof(UINT16));
+ num_stream = IS_BIG_ENDIAN(w) ? num_stream : BYTE_SWAP_UINT16(num_stream);
+ if (num_stream) {
+ pStreamNum = (UINT16*)(pInt->pMediaPropsHdr[index].type_spec + 8);
+ pOffset = (unsigned char*)(pInt->pMediaPropsHdr[index].type_spec + 8 + num_stream * sizeof(UINT16));
+ for (i = 0; i < num_stream; i++) {
+ memcpy(&stream_num, pStreamNum, sizeof(UINT16));
+ stream_num = IS_BIG_ENDIAN(w) ? stream_num : BYTE_SWAP_UINT16(stream_num);
+ for (j = 0; j < pInt->ulNumMediaPropsHdrs; j++) {
+ if (pInt->pMediaPropsHdr[j].stream_num == stream_num) {
+ memcpy((char*)&start_offset, (char*)pOffset, sizeof(UINT32));
+ pInt->pMediaPropsHdr[j].start_offset = IS_BIG_ENDIAN(w) ? start_offset : BYTE_SWAP_UINT32(start_offset);
+ break;
+ }
+ }
+ pStreamNum++;
+ pOffset += 4;
+ }
+ retVal = HXR_OK;
+ }
+ }
+ return retVal;
+}
+
+HX_RESULT rm_parseri_setup_multirate_streams(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_NOT_SUPPORTED;
+
+ if (pInt && pInt->pMediaPropsHdr && pInt->ulNumMediaPropsHdrs) {
+ /* Declare some locals we'll need later */
+ struct rm_media_props_hdr* pTmp = HXNULL;
+ UINT32 ulNumInterleaved = 0;
+ /* Allocate a temporary array of HXBOOLs */
+ UINT32 ulSize = pInt->ulNumMediaPropsHdrs * sizeof(HXBOOL);
+ HXBOOL* pInterleaved = (HXBOOL*) rm_parseri_malloc(pInt, ulSize);
+ if (pInterleaved) {
+ UINT32 i = 0;
+ UINT32 j = 0;
+ /*
+ * Now get info from logical headers.
+ */
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ const char* pszMimeType = (const char*) pInt->pMediaPropsHdr[i].mime_type;
+ if ((!strcmp(pszMimeType, RM_PARSER_LOGICAL_MULTIRATE_VIDEO)) ||
+ (!strcmp(pszMimeType, RM_PARSER_LOGICAL_MULTIRATE_AUDIO))) {
+ rm_parseri_unpack_logical_multirate_type_spec(pInt, i);
+ }
+ }
+ /*
+ * Now remove the media props headers that
+ * are actually logical stream and logical fileinfo headers.
+ */
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ const char* pszMimeType = (const char*) pInt->pMediaPropsHdr[i].mime_type;
+ if (rm_stream_is_realaudio_mimetype(pszMimeType) ||
+ rm_stream_is_realvideo_mimetype(pszMimeType)) {
+ pInterleaved[i] = TRUE;
+ ulNumInterleaved++;
+ } else {
+ pInterleaved[i] = FALSE;
+ }
+ }
+
+ /* Do we have any streams? */
+ if (ulNumInterleaved > 0) {
+ /* Allocate a new array of media props headers */
+ retVal = HXR_OUTOFMEMORY;
+ ulSize = ulNumInterleaved * sizeof(struct rm_media_props_hdr);
+ pTmp = (struct rm_media_props_hdr*) rm_parseri_malloc(pInt, ulSize);
+ if (pTmp) {
+ /* Copy the media props headers which are interleaved */
+ j = 0;
+ for (i = 0; i < pInt->ulNumMediaPropsHdrs; i++) {
+ if (pInterleaved[i]) {
+ pTmp[j++] = pInt->pMediaPropsHdr[i];
+ } else {
+ rm_parseri_cleanup_media_props_hdr(pInt, &pInt->pMediaPropsHdr[i]);
+ }
+ }
+ /* Free the logical stream array. */
+ rm_parseri_cleanup_all_logical_stream_hdrs(pInt);
+ /* Delete the memory associated with the old media props array */
+ rm_parseri_free(pInt, pInt->pMediaPropsHdr);
+ /* Replace the old media props array with the new one */
+ pInt->pMediaPropsHdr = pTmp;
+ /* Update the number of media props headers */
+ pInt->ulNumMediaPropsHdrs = ulNumInterleaved;
+ pInt->ulNumMediaPropsHdrsAlloc = ulNumInterleaved;
+ /* Update the number of streams */
+ pInt->ulNumStreams = ulNumInterleaved;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ /* Free the temporary array */
+ rm_parseri_free(pInt, pInterleaved);
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_read_all_headers(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ /* Declare the chunk id local variable */
+ UINT32 ulID = 0;
+ /* Seek back to the beginning of the file */
+ rm_parseri_file_seek(pInt, 0, HX_SEEK_ORIGIN_SET);
+ /* Read the first header */
+ retVal = rm_parseri_read_next_header(pInt, &ulID);
+ if (retVal == HXR_OK) {
+ /*
+ * If we don't encounter a RM_HEADER_OBJECT at the
+ * beginning of the file, then that's a problem.
+ */
+ if (ulID == RM_HEADER_OBJECT) {
+ /* Unpack the .rm file header */
+ retVal = rm_parseri_unpack_file_hdr(pInt);
+ if (retVal == HXR_OK) {
+ /*
+ * Check the version of this file header struct
+ * as well as the file_version to make sure we
+ * support this version of the .rm file.
+ */
+ if ((pInt->fileHdr.version == 0 || pInt->fileHdr.version == 1) &&
+ (pInt->fileHdr.file_version == 0 || pInt->fileHdr.file_version == 1)) {
+ /*
+ * Now loop and unpack until we have either unpacked
+ * the number of headers specified in the file header
+ * or we reach the first data chunk.
+ */
+ HXBOOL bDone = FALSE;
+ UINT32 i = 0;
+ for (i = 0; i < pInt->fileHdr.num_headers && !bDone && retVal == HXR_OK; i++) {
+ /* Read the next header into the read buffer */
+ retVal = rm_parseri_read_next_header(pInt, &ulID);
+ if (retVal == HXR_OK) {
+ /* Switch based on chunk 4cc */
+ switch (ulID) {
+ case RM_PROPERTIES_OBJECT: {
+ /* Unpack the clip properties header */
+ retVal = rm_parseri_unpack_properties_hdr(pInt);
+ if (retVal == HXR_OK) {
+ /* Allocate the media props array */
+ retVal = rm_parseri_allocate_media_props_hdrs(pInt);
+ if (retVal == HXR_OK) {
+ /* Init the number of media props headers we've seen */
+ pInt->ulNumMediaPropsHdrs = 0;
+ }
+ }
+ }
+ break;
+ case RM_MEDIA_PROPERTIES_OBJECT: {
+ /*
+ * Media properties headers aren't necessarily
+ * ordered in the file by stream_num. However, we would like
+ * be able to index them by stream_num. Therefore, we will
+ * first parse out the stream_num member and then place
+ * it in the array at that index.
+ */
+ UINT32 ulStreamNum = rm_parseri_get_media_props_hdr_stream_num(pInt);
+ if (ulStreamNum < pInt->ulNumMediaPropsHdrsAlloc) {
+ /* Unpack the media properties header */
+ retVal = rm_parseri_unpack_media_props_hdr(pInt, &pInt->pMediaPropsHdr[ulStreamNum]);
+ /* Increment the number of properties we've read */
+ if (retVal == HXR_OK) {
+ /* Increment the number of media props headers we've seen */
+ pInt->ulNumMediaPropsHdrs++;
+ } else {
+ /* Parsing of media props header failed. */
+ retVal = HXR_CORRUPT_FILE;
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal, "Failed to parse media props header - possibly a corrupt file.");
+ }
+ } else {
+ /* Illegal stream number */
+ retVal = HXR_CORRUPT_FILE;
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal, "Illegal stream number - possibly a corrupt file.");
+ }
+ }
+ break;
+ case RM_CONTENT_OBJECT: {
+ retVal = rm_parseri_unpack_content_hdr(pInt);
+ if (retVal != HXR_OK) {
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal,
+ "Failed to parse content header - possibly a corrupt file.");
+ }
+ }
+ break;
+ case RM_DATA_OBJECT: {
+ bDone = TRUE;
+ }
+ break;
+ }
+ }
+ }
+ if (retVal == HXR_OK) {
+ /* Parse all the logical stream headers */
+ retVal = rm_parseri_unpack_all_logical_stream_hdrs(pInt);
+ if (retVal == HXR_OK) {
+ /*
+ * Currently we only support single-rate files and
+ * SureStream files who have a backward-compatible
+ * single-rate section. So know we must determine
+ * if we can play this file.
+ */
+ retVal = rm_parseri_setup_interleaved_streams(pInt);
+ if (retVal == HXR_OK) {
+ pInt->ulInterleavedStreamsFlag = 1;
+ /* Create some structures to hold stream info */
+ retVal = rm_parseri_create_stream_structures(pInt);
+ if (retVal == HXR_OK) {
+ /*
+ * We will examine the first few packets
+ * of each stream to determine if there is
+ * a packet time offset.
+ */
+ pInt->pDataHdr = rm_parseri_malloc(pInt, sizeof(struct rm_data_hdr));
+ if (pInt->pDataHdr) {
+ retVal = rm_parseri_examine_initial_packets(pInt, 0);
+ if (retVal == HXR_OK) {
+ /* Create the stream headers */
+ retVal = rm_parseri_create_all_stream_headers(pInt);
+ }
+ } else {
+ retVal = HXR_OUTOFMEMORY;
+ }
+ }
+ } else {
+ pInt->ulInterleavedStreamsFlag = 0;
+ retVal = rm_parseri_setup_multirate_streams(pInt);
+ if (retVal == HXR_OK) {
+ /* Create some structures to hold stream info */
+ retVal = rm_parseri_create_stream_structures(pInt);
+ if (retVal == HXR_OK) {
+ /*
+ * We will examine the first few packets
+ * of each stream to determine if there is
+ * a packet time offset.
+ */
+ pInt->pDataHdr = rm_parseri_malloc(pInt, pInt->ulNumStreams * sizeof(struct rm_data_hdr));
+ if (pInt->pDataHdr) {
+ UINT32 j = 0;
+ for (j = 0; j < pInt->ulNumStreams; j++) {
+ retVal = rm_parseri_examine_initial_packets(pInt, j);
+ if (retVal != HXR_OK) {
+ break;
+ }
+ }
+ if (retVal == HXR_OK) {
+ /* Create the stream headers */
+ retVal = rm_parseri_create_all_stream_headers(pInt);
+ }
+ } else {
+ retVal = HXR_OUTOFMEMORY;
+ }
+ } else {
+ /*
+ * This is a surestream file which has not backwards-compatible
+ * streams, which we do not support.
+ */
+ retVal = HXR_NOT_SUPPORTED;
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal,
+ "Unsupported file (SureStream file with no "
+ "compatible streams)");
+ }
+ } else {
+ retVal = HXR_NOT_SUPPORTED;
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal,
+ "Unsupported file (SureStream file with no "
+ "compatible streams)");
+ }
+ }
+ }
+ }
+ } else {
+ /*
+ * This is a later version than we support */
+ retVal = HXR_NOT_SUPPORTED;
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal, "Unsupported file header version.");
+ }
+ }
+ } else {
+ /*
+ * The first four bytes of the file were
+ * not what we expected. This is likely not
+ * an .rm file.
+ * XXXMEH: is there a better error code for this?
+ */
+ retVal = HXR_NOT_SUPPORTED;
+ /* Call back to the error interface */
+ rm_parseri_error(pInt, retVal,
+ "First four bytes are are not \".RMF\" - this is not an .rm file");
+ }
+ }
+ }
+
+ return retVal;
+}
+
+UINT32 rm_parseri_get_num_file_properties(rm_parser_internal* pInt)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt) {
+ /*
+ * We always put the "StreamCount" and "Flags" properties.
+ */
+ ulRet += 2;
+ /* If we have a real datatype, then we will add "IsRealDataType" */
+ if (rm_parseri_has_real_data_type(pInt)) {
+ ulRet++;
+ }
+ /*
+ * If we have a logical-fileinfo header, we will put in
+ * all the properties in it.
+ */
+ if (pInt->pLogicalFileInfo) {
+ ulRet += pInt->pLogicalFileInfo->num_props;
+ }
+ /* Add "Title", "Author", "Copyright" if present */
+ if (pInt->contHdr.title) {
+ ulRet++;
+ }
+ if (pInt->contHdr.author) {
+ ulRet++;
+ }
+ if (pInt->contHdr.copyright) {
+ ulRet++;
+ }
+ }
+
+ return ulRet;
+}
+
+HX_RESULT rm_parseri_get_file_properties(rm_parser_internal* pInt,
+ rm_property* pProp, UINT32 ulNumProp)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pProp && ulNumProp) {
+ /* Init the counter */
+ UINT32 ulIndex = 0;
+ /* "StreamCount" property */
+ retVal = rm_parseri_set_rm_property(pInt, &pProp[ulIndex++], "StreamCount",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) pInt->ulNumStreams, 0);
+
+ if (retVal == HXR_OK) {
+ retVal = rm_parseri_set_rm_property(pInt, &pProp[ulIndex++], "Flags",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) pInt->propHdr.flags, 0);
+ }
+ if (retVal == HXR_OK &&
+ rm_parseri_has_real_data_type(pInt)) {
+ retVal = rm_parseri_set_rm_property(pInt, &pProp[ulIndex++], "IsRealDataType",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) 1, 0);
+ }
+ if (retVal == HXR_OK && pInt->contHdr.title) {
+ retVal = rm_parseri_set_rm_property(pInt, &pProp[ulIndex++], "Title",
+ RM_PROPERTY_TYPE_BUFFER,
+ (void*) pInt->contHdr.title,
+ strlen(pInt->contHdr.title) + 1);
+ }
+ if (retVal == HXR_OK && pInt->contHdr.author) {
+ retVal = rm_parseri_set_rm_property(pInt, &pProp[ulIndex++], "Author",
+ RM_PROPERTY_TYPE_BUFFER,
+ (void*) pInt->contHdr.author,
+ strlen(pInt->contHdr.author) + 1);
+ }
+ if (retVal == HXR_OK && pInt->contHdr.copyright) {
+ retVal = rm_parseri_set_rm_property(pInt, &pProp[ulIndex++], "Copyright",
+ RM_PROPERTY_TYPE_BUFFER,
+ (void*) pInt->contHdr.copyright,
+ strlen(pInt->contHdr.copyright) + 1);
+ }
+ if (pInt->pLogicalFileInfo) {
+ UINT32 i = 0;
+ for (i = 0; i < (UINT32) pInt->pLogicalFileInfo->num_props && retVal == HXR_OK; i++) {
+ struct rm_name_value_map* pMap = &pInt->pLogicalFileInfo->props[i];
+ UINT32 ulLength = pMap->value_sz;
+ if (pMap->type != RM_PROPERTY_TYPE_BUFFER) {
+ ulLength = 0;
+ }
+ retVal = rm_parseri_set_rm_property(pInt, &pProp[ulIndex++],
+ (const char*) pMap->name,
+ pMap->type, pMap->value, ulLength);
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HXBOOL rm_parseri_has_real_data_type(rm_parser_internal* pInt)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pInt) {
+ bRet = pInt->bIsRealDataType;
+ }
+
+ return bRet;
+}
+
+HX_RESULT rm_parseri_set_rm_property(rm_parser_internal* pInt, rm_property* pProp,
+ const char* pszName, UINT32 ulType,
+ void* pValue, UINT32 ulValueLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pProp && pszName) {
+ /* Cleanup the existing property */
+ rm_parseri_cleanup_rm_property(pInt, pProp);
+ /* Allocate space for the name */
+ pProp->pName = (char*) rm_parseri_malloc(pInt, strlen(pszName) + 1);
+ if (pProp->pName) {
+ /* Copy the string */
+ strcpy(pProp->pName, pszName);
+ /* Copy the type */
+ pProp->ulType = ulType;
+ /* What type is this property? */
+ switch (ulType) {
+ case RM_PROPERTY_TYPE_UINT32: {
+ pProp->pValue = pValue;
+ pProp->ulValueLen = 0;
+ retVal = HXR_OK;
+ }
+ break;
+ case RM_PROPERTY_TYPE_BUFFER: {
+ pProp->pValue = (BYTE*) rm_parseri_malloc(pInt, ulValueLen);
+ if (pProp->pValue) {
+ /* Copy the string */
+ memcpy(pProp->pValue, pValue, ulValueLen);
+ /* Assign the length */
+ pProp->ulValueLen = ulValueLen;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ break;
+ case RM_PROPERTY_TYPE_CSTRING: {
+ const char* pszValue = (const char*) pValue;
+ UINT32 ulLen = (UINT32) strlen(pszValue) + 1;
+ pProp->pValue = (BYTE*) rm_parseri_malloc(pInt, ulLen);
+ if (pProp->pValue) {
+ /* Copy the string */
+ strcpy((char*) pProp->pValue, pszValue);
+ /* Assign the length */
+ pProp->ulValueLen = ulLen;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rm_parseri_cleanup_rm_property(rm_parser_internal* pInt, rm_property* pProp)
+{
+ if (pInt && pProp) {
+ /* Free the name string */
+ if (pProp->pName) {
+ rm_parseri_free(pInt, pProp->pName);
+ pProp->pName = HXNULL;
+ }
+ /*
+ * If this is a RM_PROPERTY_TYPE_BUFFER or RM_PROPERTY_TYPE_CSTRING
+ * property, then the pValue is an allocated buffer. If this
+ * is an RM_PROPERTY_TYPE_UINT32 property, then pValue doesn't
+ * have any buffer associated with it.
+ */
+ if (pProp->pValue && pProp->ulType != RM_PROPERTY_TYPE_UINT32) {
+ rm_parseri_free(pInt, pProp->pValue);
+ pProp->pValue = HXNULL;
+ }
+ }
+}
+
+void rm_parseri_cleanup_stream_num_map(rm_parser_internal* pInt)
+{
+ if (pInt && pInt->pulStreamNumMap) {
+ rm_parseri_free(pInt, pInt->pulStreamNumMap);
+ pInt->pulStreamNumMap = HXNULL;
+ pInt->ulStreamNumMapSize = 0;
+ }
+}
+
+void rm_parseri_cleanup_stream_info(rm_parser_internal* pInt, struct rm_stream_info* pInfo)
+{
+ if (pInt) {
+ /* Free the index entry array */
+ if (pInfo->seekTable.pEntry) {
+ rm_parseri_free(pInt, pInfo->seekTable.pEntry);
+ pInfo->seekTable.pEntry = HXNULL;
+ }
+ }
+}
+
+void rm_parseri_cleanup_stream_info_array(rm_parser_internal* pInt)
+{
+ if (pInt && pInt->pStreamInfo) {
+ /* Clean up each individual stream info */
+ UINT32 i = 0;
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ rm_parseri_cleanup_stream_info(pInt, &pInt->pStreamInfo[i]);
+ }
+ /* Clean up the array */
+ rm_parseri_free(pInt, pInt->pStreamInfo);
+ pInt->pStreamInfo = HXNULL;
+ }
+}
+
+HX_RESULT rm_parseri_create_stream_structures(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->ulNumStreams) {
+ /*
+ * Compute the max stream number and the
+ * max duration across all streams.
+ */
+ UINT32 i = 0;
+ UINT32 ulSize = 0;
+ UINT32 ulMaxStreamNum = pInt->pMediaPropsHdr[0].stream_num;
+ UINT32 ulMaxDuration = pInt->pMediaPropsHdr[0].duration;
+ UINT32 ulIndexMaxEntries = RM_INDEX_MAX_ENTRIES;
+ UINT32 ulIndexTimeGranularity = ulMaxDuration / ulIndexMaxEntries;
+ for (i = 1; i < pInt->ulNumStreams; i++) {
+ if (pInt->pMediaPropsHdr[i].stream_num > ulMaxStreamNum) {
+ ulMaxStreamNum = pInt->pMediaPropsHdr[i].stream_num;
+ }
+ if (pInt->pMediaPropsHdr[i].duration > ulMaxDuration) {
+ ulMaxDuration = pInt->pMediaPropsHdr[i].duration;
+ }
+ }
+ /* Assign the max duration */
+ pInt->ulMaxDuration = ulMaxDuration;
+ /* Free any existing stream number map */
+ rm_parseri_cleanup_stream_num_map(pInt);
+ /* Allocate the stream number map */
+ pInt->ulStreamNumMapSize = ulMaxStreamNum + 1;
+ ulSize = pInt->ulStreamNumMapSize * sizeof(UINT32);
+ pInt->pulStreamNumMap = (UINT32*) rm_parseri_malloc(pInt, ulSize);
+ if (pInt->pulStreamNumMap) {
+ /* Initialize all the stream numbers in the map */
+ for (i = 0; i < pInt->ulStreamNumMapSize; i++) {
+ pInt->pulStreamNumMap[i] = RM_NO_STREAM_SET;
+ }
+ /*
+ * The stream number maps maps stream number to
+ * the index in the pMediaPropsHdr array.
+ */
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ pInt->pulStreamNumMap[pInt->pMediaPropsHdr[i].stream_num] = i;
+ }
+ /* Clean up any existing stream info array */
+ rm_parseri_cleanup_stream_info_array(pInt);
+ /* Allocate a stream info array */
+ ulSize = pInt->ulNumStreams * sizeof(struct rm_stream_info);
+ pInt->pStreamInfo = (struct rm_stream_info*) rm_parseri_malloc(pInt, ulSize);
+ if (pInt->pStreamInfo) {
+ /* Zero out the array */
+ memset(pInt->pStreamInfo, 0, ulSize);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Compute the index table parameters */
+ if (ulIndexTimeGranularity > RM_INDEX_MAX_TIME_GRANULARITY) {
+ ulIndexTimeGranularity = RM_INDEX_MAX_TIME_GRANULARITY;
+ ulIndexMaxEntries = ulMaxDuration / ulIndexTimeGranularity;
+ if (ulIndexMaxEntries > RM_INDEX_MAX_ENTRIES) {
+ ulIndexMaxEntries = RM_INDEX_MAX_ENTRIES;
+ }
+ } else if (ulIndexTimeGranularity < RM_INDEX_MIN_TIME_GRANULARITY) {
+ ulIndexTimeGranularity = RM_INDEX_MIN_TIME_GRANULARITY;
+ ulIndexMaxEntries = ulMaxDuration / ulIndexTimeGranularity;
+ if (ulIndexMaxEntries < RM_INDEX_MIN_ENTRIES) {
+ ulIndexMaxEntries = RM_INDEX_MIN_ENTRIES;
+ }
+ }
+ ulSize = ulIndexMaxEntries * sizeof(struct rm_seek_table_entry);
+ /* Initialize the stream info */
+ for (i = 0; i < pInt->ulNumStreams && retVal == HXR_OK; i++) {
+ /* Initialize the type flag */
+ if (pInt->pMediaPropsHdr[i].mime_type) {
+ const char* pszStr = (const char*) pInt->pMediaPropsHdr[i].mime_type;
+ if (rm_stream_is_realaudio_mimetype(pszStr)) {
+ pInt->pStreamInfo[i].bIsRealAudio = TRUE;
+ pInt->bIsRealDataType = TRUE;
+ } else if (rm_stream_is_realvideo_mimetype(pszStr)) {
+ pInt->pStreamInfo[i].bIsRealVideo = TRUE;
+ pInt->bIsRealDataType = TRUE;
+ } else if (rm_stream_is_realevent_mimetype(pszStr)) {
+ pInt->pStreamInfo[i].bIsRealEvent = TRUE;
+ pInt->bIsRealDataType = TRUE;
+ }
+ }
+ /* Initialize the index table */
+ pInt->pStreamInfo[i].seekTable.pEntry =
+ (struct rm_seek_table_entry*) rm_parseri_malloc(pInt, ulSize);
+ if (pInt->pStreamInfo[i].seekTable.pEntry) {
+ /* Zero out the memory */
+ memset(pInt->pStreamInfo[i].seekTable.pEntry, 0, ulSize);
+ /* Init the parameters */
+ pInt->pStreamInfo[i].seekTable.ulMaxEntries = ulIndexMaxEntries;
+ pInt->pStreamInfo[i].seekTable.ulTimeGranularity = ulIndexTimeGranularity;
+ pInt->pStreamInfo[i].seekTable.ulNumEntries = 0;
+ pInt->pStreamInfo[i].seekTable.ulLastTime = 0;
+ pInt->pStreamInfo[i].seekTable.ulRangeTime = 0;
+ } else {
+ retVal = HXR_OUTOFMEMORY;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_examine_initial_packets(rm_parser_internal* pInt, UINT32 ulStreamNum)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ struct rm_pkt_hdr hdr;
+ UINT32 ulID = 0;
+ UINT32 i = 0;
+ UINT32 j = 0;
+ /* Seek to the data offset mentioned in the properties header */
+ rm_parseri_file_seek(pInt, pInt->pMediaPropsHdr[ulStreamNum].start_offset, HX_SEEK_ORIGIN_SET);
+ /*
+ * Read the next header into the read buffer,
+ * which should be a data chunk
+ */
+ retVal = rm_parseri_read_next_header(pInt, &ulID);
+ if (retVal == HXR_OK) {
+ /* Make sure it's a data chunk */
+ if (ulID == RM_DATA_OBJECT) {
+ /* Parse the data chunk header */
+ retVal = rm_parseri_unpack_data_hdr(pInt, ulStreamNum);
+ if (retVal == HXR_OK) {
+ /* Initialize the minimum first packet timestamp */
+ pInt->ulMinFirstPacketTime = 0xFFFFFFFF;
+ /*
+ * Now we will look at the first few packet headers
+ * until either we have seen at least one packet
+ * of each stream or we have verified that the
+ * minimum timestamp across all streams is 0.
+ * We will loop as though we will look at all
+ * packets, but we will break out long before that.
+ */
+ for (i = 0; i < pInt->pDataHdr[ulStreamNum].num_pkts && retVal == HXR_OK; i++) {
+ retVal = rm_parseri_read_next_packet_header(pInt, &hdr);
+ if (retVal == HXR_OK) {
+ /* Translate the stream number */
+ UINT32 ulStreamNum = rm_parseri_translate_stream_number(pInt, hdr.stream_num);
+ if (ulStreamNum != RM_NO_STREAM_SET) {
+ /* Save the first timestamp of each stream */
+ if (!pInt->pStreamInfo[ulStreamNum].bSeenFirstPacketTimeStamp) {
+ pInt->pStreamInfo[ulStreamNum].ulLastTimeStamp = hdr.timestamp;
+ pInt->pStreamInfo[ulStreamNum].bSeenFirstPacketTimeStamp = TRUE;
+ /* Update the min first timestamp */
+ if (hdr.timestamp < pInt->ulMinFirstPacketTime) {
+ pInt->ulMinFirstPacketTime = hdr.timestamp;
+ }
+ }
+ /* Check if we've seen the first timestamp of all streams */
+ for (j = 0; j < pInt->ulNumStreams; j++) {
+ if (!pInt->pStreamInfo[ulStreamNum].bSeenFirstPacketTimeStamp) {
+ break;
+ }
+ }
+ /*
+ * Stop if we've seen a packet from each stream
+ * or if we've already seen a timestamp of 0.
+ */
+ if (j == pInt->ulNumStreams || pInt->ulMinFirstPacketTime == 0) {
+ /* Re-init the last timestamp for each stream */
+ for (j = 0; j < pInt->ulNumStreams; j++) {
+ pInt->pStreamInfo[j].ulLastTimeStamp = 0xFFFFFFFF;
+ pInt->pStreamInfo[j].ulLastRule = 0;
+ }
+ /* Seek back to right after the data chunk header */
+ rm_parseri_file_seek(pInt,
+ pInt->pMediaPropsHdr[ulStreamNum].start_offset +
+ RM_PARSER_DATA_CHUNK_HEADER_SIZE,
+ HX_SEEK_ORIGIN_SET);
+ /* Break out of the packet loop */
+ break;
+ } else {
+ /*
+ * We need to keep reading packets, so
+ * seek past the data of this packet.
+ */
+ rm_parseri_file_seek(pInt,
+ hdr.length - hdr.header_len,
+ HX_SEEK_ORIGIN_CUR);
+ }
+ } else {
+ retVal = HXR_INVALID_FILE;
+ }
+ }
+ }
+ }
+ } else {
+ retVal = HXR_INVALID_FILE;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_unpack_data_hdr(rm_parser_internal* pInt, UINT32 DataNum)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ if (ulLen >= RM_PARSER_DATA_CHUNK_HEADER_SIZE) {
+ /* Unpack the rm_data_hdr */
+ pInt->pDataHdr[DataNum].id = rm_unpack32(&pBuf, &ulLen);
+ pInt->pDataHdr[DataNum].size = rm_unpack32(&pBuf, &ulLen);
+ pInt->pDataHdr[DataNum].version = rm_unpack16(&pBuf, &ulLen);
+ pInt->pDataHdr[DataNum].num_pkts = rm_unpack32(&pBuf, &ulLen);
+ pInt->pDataHdr[DataNum].next_data_hdr = rm_unpack32(&pBuf, &ulLen);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_unpack_pkt_hdr(rm_parser_internal* pInt,
+ struct rm_pkt_hdr* pPktHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ if (ulLen >= RM_PARSER_PACKET_HEADER_SIZE) {
+ /* Unpack the rm_pkt_hdr */
+ pPktHdr->version = rm_unpack16(&pBuf, &ulLen);
+ pPktHdr->length = rm_unpack16(&pBuf, &ulLen);
+ pPktHdr->stream_num = rm_unpack16(&pBuf, &ulLen);
+ pPktHdr->timestamp = rm_unpack32(&pBuf, &ulLen);
+ pPktHdr->flags = rm_unpack16(&pBuf, &ulLen);
+ if (pPktHdr->version == 1) {
+ rm_parseri_file_read(pInt, 1, 0);
+ pPktHdr->header_len = 13;
+ if (pPktHdr->flags == 0) {
+ pPktHdr->flags = 2;
+ }
+ } else {
+ pPktHdr->header_len = 12;
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_unpack_index_hdr(rm_parser_internal* pInt,
+ struct rm_index_hdr* hdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && hdr) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ if (ulLen >= RM_PARSER_INDEX_HEADER_SIZE) {
+ /* Unpack the rm_index_hdr */
+ hdr->id = rm_unpack32(&pBuf, &ulLen);
+ hdr->size = rm_unpack32(&pBuf, &ulLen);
+ hdr->version = rm_unpack16(&pBuf, &ulLen);
+ hdr->num_recs = rm_unpack32(&pBuf, &ulLen);
+ hdr->stream_num = rm_unpack16(&pBuf, &ulLen);
+ hdr->next_index_hdr = rm_unpack32(&pBuf, &ulLen);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_unpack_index_rec(rm_parser_internal* pInt,
+ struct rm_index_rec* rec)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && rec) {
+ /* Assign temporary variables */
+ BYTE* pBuf = pInt->pReadBuffer;
+ UINT32 ulLen = pInt->ulNumBytesRead;
+ if (ulLen >= RM_PARSER_INDEX_RECORD_SIZE) {
+ /* Unpack the rm_index_rec */
+ rec->version = rm_unpack16(&pBuf, &ulLen);
+ rec->timestamp = rm_unpack32(&pBuf, &ulLen);
+ rec->offset = rm_unpack32(&pBuf, &ulLen);
+ rec->num_pkts = rm_unpack32(&pBuf, &ulLen);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_read_next_index_rec(rm_parser_internal* pInt,
+ struct rm_index_rec* rec)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && rec) {
+ UINT32 ulNumBytesRead = 0;
+ /* Change the error return */
+ retVal = HXR_READ_ERROR;
+ /* Read the packet header into the read buffer */
+ ulNumBytesRead = rm_parseri_file_read(pInt, RM_PARSER_INDEX_RECORD_SIZE, 0);
+ if (ulNumBytesRead == RM_PARSER_INDEX_RECORD_SIZE) {
+ /* Unpack the packet header */
+ retVal = rm_parseri_unpack_index_rec(pInt, rec);
+ }
+ }
+
+ return retVal;
+}
+
+UINT32 rm_parseri_translate_stream_number(rm_parser_internal* pInt, UINT32 ulNum)
+{
+ UINT32 ulRet = RM_NO_STREAM_SET;
+
+ if (pInt && pInt->pulStreamNumMap && ulNum < pInt->ulStreamNumMapSize) {
+ ulRet = pInt->pulStreamNumMap[ulNum];
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parseri_get_stream_number(rm_parser_internal* pInt, UINT32 ulNum)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt && pInt->pulStreamNumMap) {
+ for (ulRet = 0; ulRet < pInt->ulStreamNumMapSize; ulRet++) {
+ if (pInt->pulStreamNumMap[ulRet] == ulNum) {
+ return ulRet;
+ }
+ }
+ }
+ ulRet = RM_NO_STREAM_SET;
+ return ulRet;
+}
+
+HX_RESULT rm_parseri_create_all_stream_headers(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->ulNumStreams) {
+ UINT32 i = 0;
+ UINT32 ulSize = 0;
+ /* Clean up any existing stream headers */
+ rm_parseri_cleanup_all_stream_headers(pInt);
+ /* Allocate memory for the stream header array */
+ ulSize = pInt->ulNumStreams * sizeof(rm_stream_header);
+ pInt->pStreamHdr = (rm_stream_header*) rm_parseri_malloc(pInt, ulSize);
+ if (pInt->pStreamHdr) {
+ /* NULL out the memory */
+ memset(pInt->pStreamHdr, 0, ulSize);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Create all stream headers */
+ for (i = 0; i < pInt->ulNumStreams && retVal == HXR_OK; i++) {
+ retVal = rm_parseri_create_stream_header(pInt, i, &pInt->pStreamHdr[i]);
+ }
+ }
+ }
+ return retVal;
+}
+
+HX_RESULT rm_parseri_create_stream_header(rm_parser_internal* pInt, UINT32 i, rm_stream_header* hdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pMediaPropsHdr && i < pInt->ulNumStreams && hdr) {
+ UINT32 ulNumProps = 0;
+ UINT32 ulSize = 0;
+ /*
+ * Count the number of properties. Passing in
+ * HXNULL and 0 means just count and don't set
+ * the properties
+ */
+ ulNumProps = rm_parseri_count_set_stream_header_props(pInt, i, hdr,
+ HXNULL, 0);
+ if (ulNumProps) {
+ /* Compute the size of the array */
+ ulSize = ulNumProps * sizeof(rm_property);
+ /* Allocate the array */
+ hdr->pProperty = (rm_property*) rm_parseri_malloc(pInt, ulSize);
+ if (hdr->pProperty) {
+ /* NULL out the array */
+ memset(hdr->pProperty, 0, ulSize);
+ /* Set the number of properties */
+ hdr->ulNumProperties = ulNumProps;
+ /* Call again, but this time pass in array */
+ rm_parseri_count_set_stream_header_props(pInt, i, hdr,
+ hdr->pProperty,
+ hdr->ulNumProperties);
+ /*
+ * Now set the properties for which we
+ * have dedicated convenience members. These
+ * are also duplicated in the rm_property array.
+ */
+ hdr->ulStreamNumber = i;
+ hdr->ulMaxBitRate = pInt->pMediaPropsHdr[i].max_bit_rate;
+ hdr->ulAvgBitRate = pInt->pMediaPropsHdr[i].avg_bit_rate;
+ hdr->ulMaxPacketSize = pInt->pMediaPropsHdr[i].max_pkt_size;
+ hdr->ulAvgPacketSize = pInt->pMediaPropsHdr[i].avg_pkt_size;
+ hdr->ulDuration = pInt->pMediaPropsHdr[i].duration;
+ hdr->ulPreroll = pInt->pMediaPropsHdr[i].preroll;
+ hdr->ulStartTime = pInt->pMediaPropsHdr[i].start_time;
+ hdr->ulStartOffset = pInt->pMediaPropsHdr[i].start_offset;
+ if (pInt->ulInterleavedStreamsFlag) {
+ hdr->ulStreamSize = pInt->pDataHdr->size;
+ } else {
+ hdr->ulStreamSize = pInt->pDataHdr[i].size;
+ }
+ hdr->pMimeType = copy_string(pInt->pUserMem, pInt->fpMalloc,
+ (const char*) pInt->pMediaPropsHdr[i].mime_type);
+ hdr->pStreamName = copy_string(pInt->pUserMem, pInt->fpMalloc,
+ (const char*) pInt->pMediaPropsHdr[i].stream_name);
+ hdr->pOpaqueData = copy_buffer(pInt->pUserMem, pInt->fpMalloc,
+ pInt->pMediaPropsHdr[i].type_spec,
+ pInt->pMediaPropsHdr[i].type_spec_sz);
+ hdr->ulOpaqueDataLen = pInt->pMediaPropsHdr[i].type_spec_sz;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ return retVal;
+}
+
+void rm_parseri_cleanup_all_stream_headers(rm_parser_internal* pInt)
+{
+ if (pInt && pInt->pStreamHdr) {
+ /* Free the memory associated with each stream header */
+ UINT32 i = 0;
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ rm_parseri_cleanup_stream_header(pInt, &pInt->pStreamHdr[i]);
+ }
+ /* Free the memory for the array */
+ rm_parseri_free(pInt, pInt->pStreamHdr);
+ /* NULL out the pointer */
+ pInt->pStreamHdr = HXNULL;
+ }
+}
+
+void rm_parseri_cleanup_stream_header(rm_parser_internal* pInt, rm_stream_header* hdr)
+{
+ if (pInt && hdr) {
+ /* Free the mime type string */
+ if (hdr->pMimeType) {
+ rm_parseri_free(pInt, hdr->pMimeType);
+ hdr->pMimeType = HXNULL;
+ }
+ /* Free the stream name string */
+ if (hdr->pStreamName) {
+ rm_parseri_free(pInt, hdr->pStreamName);
+ hdr->pStreamName = HXNULL;
+ }
+ /* Free the opaque data buffer */
+ if (hdr->pOpaqueData) {
+ rm_parseri_free(pInt, hdr->pOpaqueData);
+ hdr->pOpaqueData = HXNULL;
+ hdr->ulOpaqueDataLen = 0;
+ }
+ /* Do we have any properties? */
+ if (hdr->pProperty) {
+ /* Clean up each individual rm_property */
+ UINT32 i = 0;
+ for (i = 0; i < hdr->ulNumProperties; i++) {
+ rm_parseri_cleanup_rm_property(pInt, &hdr->pProperty[i]);
+ }
+ /* Free the memory for the property array */
+ rm_parseri_free(pInt, hdr->pProperty);
+ /* Null out the pointer */
+ hdr->pProperty = HXNULL;
+ hdr->ulNumProperties = 0;
+ }
+ }
+}
+
+void rm_parseri_cleanup_all_data_headers(rm_parser_internal* pInt)
+{
+ if (pInt && pInt->pDataHdr) {
+ rm_parseri_free(pInt, pInt->pDataHdr);
+ pInt->pDataHdr = HXNULL;
+ }
+}
+
+UINT32 rm_parseri_count_set_stream_header_props(rm_parser_internal* pInt, UINT32 i,
+ rm_stream_header* hdr,
+ rm_property* pProp, UINT32 ulNumProps)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt && i < pInt->ulNumStreams && hdr) {
+ /* Initialize some local variables used later */
+ UINT32 ulDuration = pInt->pMediaPropsHdr[i].duration;
+ UINT32 ulPreroll = pInt->pMediaPropsHdr[i].preroll;
+ UINT32 ulStreamingPreroll = 0;
+ UINT32 ulOldPreroll = 0;
+ UINT32 ulPreDecBufSize = 0;
+ UINT32 ulPreDecBufTime = 0;
+ HXDOUBLE dPreDecBufSize = 0.0;
+ HXBOOL bIsVBR = (pInt->pMediaPropsHdr[i].max_bit_rate !=
+ pInt->pMediaPropsHdr[i].avg_bit_rate ? TRUE : FALSE);
+ HXBOOL bHasPreDataProps = FALSE;
+ HXDOUBLE dPreData = 0.0;
+ UINT32 ulPreData = 0;
+ char* pASMRuleBook = HXNULL;
+ BYTE* pBuf = HXNULL;
+ UINT32 ulLen = 0;
+ BYTE ucRuleToFlag[8];
+ /* Set/count the "StreamNumber" property */
+
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "StreamNumber",
+ RM_PROPERTY_TYPE_UINT32, (void*) i, 0);
+ }
+ ulRet++;
+ /* Set/count the "MaxBitRate" property */
+ if (pInt->pMediaPropsHdr[i].max_bit_rate) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "MaxBitRate",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) pInt->pMediaPropsHdr[i].max_bit_rate, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "AvgBitRate" property */
+ if (pInt->pMediaPropsHdr[i].avg_bit_rate) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "AvgBitRate",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) pInt->pMediaPropsHdr[i].avg_bit_rate, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "MaxPacketSize" property */
+ if (pInt->pMediaPropsHdr[i].max_pkt_size) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "MaxPacketSize",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) pInt->pMediaPropsHdr[i].max_pkt_size, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "AvgPacketSize" property */
+ if (pInt->pMediaPropsHdr[i].avg_pkt_size) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "AvgPacketSize",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) pInt->pMediaPropsHdr[i].avg_pkt_size, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "StartTime" property */
+ if (pInt->pMediaPropsHdr[i].start_time) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "StartTime",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) pInt->pMediaPropsHdr[i].start_time, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "MimeType" property */
+ if (pInt->pMediaPropsHdr[i].mime_type) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "MimeType",
+ RM_PROPERTY_TYPE_CSTRING,
+ (void*) pInt->pMediaPropsHdr[i].mime_type, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "StreamName" property */
+ if (pInt->pMediaPropsHdr[i].stream_name) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "StreamName",
+ RM_PROPERTY_TYPE_CSTRING,
+ (void*) pInt->pMediaPropsHdr[i].stream_name, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "OpaqueData" property */
+ if (pInt->pMediaPropsHdr[i].type_spec) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "OpaqueData",
+ RM_PROPERTY_TYPE_BUFFER,
+ (void*) pInt->pMediaPropsHdr[i].type_spec,
+ pInt->pMediaPropsHdr[i].type_spec_sz);
+ }
+ ulRet++;
+ }
+ /* Set/count the "intrinsicDurationType" property */
+ if (pInt->pStreamInfo[i].bIsRealAudio ||
+ pInt->pStreamInfo[i].bIsRealVideo ||
+ pInt->pStreamInfo[i].bIsRealEvent) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "intrinsicDurationType",
+ RM_PROPERTY_TYPE_CSTRING,
+ (void*) "intrinsicDurationContinuous", 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "EndTime" property */
+ if (pInt->pMediaPropsHdr[i].duration > pInt->propHdr.duration) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "EndTime",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) pInt->propHdr.duration, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "EndOneRuleEndAll" property */
+ if (pInt->pStreamInfo[i].bIsRealAudio ||
+ pInt->pStreamInfo[i].bIsRealVideo) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "EndOneRuleEndAll",
+ RM_PROPERTY_TYPE_UINT32, (void*) 1, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "CanBeStoppedAnyTime" property */
+ if (pInt->pStreamInfo[i].bIsRealEvent) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "CanBeStoppedAnyTime",
+ RM_PROPERTY_TYPE_UINT32, (void*) 1, 0);
+ }
+ ulRet++;
+ }
+ /* Do some adjustments to duration */
+ if (pInt->pStreamInfo[i].bIsRealEvent) {
+ /*
+ * If this is an event stream, then set the stream duration
+ * to the maximum duration across all streams.
+ */
+ ulDuration = pInt->ulMaxDuration;
+ }
+ /* Subtract off the min first packet time */
+ if (ulDuration > pInt->ulMinFirstPacketTime) {
+ ulDuration -= pInt->ulMinFirstPacketTime;
+ }
+ /* Set/count the "Duration" property */
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "Duration",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) ulDuration, 0);
+ }
+ ulRet++;
+ /* Do some adjustments to preroll values */
+ if (pInt->pStreamInfo[i].bIsRealAudio) {
+ /* Save the preroll */
+ ulOldPreroll = ulPreroll;
+ /*
+ * RealAudio streams need to have 2 superblocks as the preroll value.
+ * Encoders put one superblock duration as the preroll.
+ */
+ ulPreroll = (ulPreroll ? ulPreroll * 2 : 6000);
+ }
+ if (pInt->pStreamInfo[i].bIsRealVideo ||
+ pInt->pStreamInfo[i].bIsRealAudio) {
+ /* Compute the pre-decode buffer size */
+ if (pInt->pStreamInfo[i].bIsRealVideo) {
+ /* For VBR stream, the PreDecBufTime is the same as the actual preroll */
+ if (bIsVBR) {
+ ulPreDecBufTime = ulPreroll;
+ }
+ /*
+ * If actual preroll is less than 1 sec, set preroll
+ * and PreDecBufTime to 1 sec more than ActualPreroll
+ */
+ if (ulPreroll < 1000) {
+ if (ulOldPreroll == 0) {
+ ulOldPreroll = ulPreroll;
+ }
+ ulPreroll += 1000;
+ if (!bIsVBR) {
+ ulPreDecBufTime = ulPreroll;
+ }
+ } else if (!bIsVBR) {
+ /*
+ * Otherwise for CBR set the PreDecBufTime to
+ * twice the actual preroll
+ */
+ ulPreDecBufTime = ulPreroll * 2;
+ }
+ /* Now compute pre-decode buffer size, rounding up */
+ dPreDecBufSize = (((HXDOUBLE) ulPreDecBufTime) *
+ ((HXDOUBLE) pInt->pMediaPropsHdr[i].max_bit_rate) +
+ 7999.0) / 8000.0;
+ ulPreDecBufSize = (UINT32) dPreDecBufSize;
+ }
+ /*
+ * Cap the preroll at 5000 ms.
+ * XXXMEH - this assumes local playback
+ */
+ if (ulPreroll > 5000) {
+ if (!ulOldPreroll) {
+ ulOldPreroll = ulPreroll;
+ }
+ ulStreamingPreroll = ulPreroll;
+ ulPreroll = 5000;
+ }
+ }
+ /* Set/count the "Preroll" property */
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "Preroll",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) ulPreroll, 0);
+ }
+ ulRet++;
+ /* Set/count the "ActualPreroll" property */
+ if (ulOldPreroll) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "ActualPreroll",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) ulOldPreroll, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "StreamingPreroll" property */
+ if (ulStreamingPreroll) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "StreamingPreroll",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) ulStreamingPreroll, 0);
+ }
+ ulRet++;
+ }
+ /* Set/count the "X-PreDecBufSize" property */
+ if (ulPreDecBufSize) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "X-PreDecBufSize",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) ulPreDecBufSize, 0);
+ }
+ ulRet++;
+ }
+ /* Create the ASM rule book string */
+ pASMRuleBook = rm_parseri_create_asm_rulebook(pInt,
+ pInt->pStreamInfo[i].bIsRealVideo,
+ pInt->pStreamInfo[i].bIsRealEvent,
+ (pInt->pMediaPropsHdr[i].type_spec_sz ? TRUE : FALSE),
+ pInt->pMediaPropsHdr[i].max_bit_rate,
+ pInt->pMediaPropsHdr[i].avg_bit_rate,
+ &bHasPreDataProps);
+ if (pASMRuleBook) {
+ /* Set/count the "ASMRuleBook" property */
+ if (pProp) {
+ /* Set it into the property */
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "ASMRuleBook",
+ RM_PROPERTY_TYPE_CSTRING,
+ (void*) pASMRuleBook, 0);
+ }
+ ulRet++;
+ }
+ /* Free the string */
+ free_string(pInt->pUserMem, pInt->fpFree, &pASMRuleBook);
+ /* Set/count the pre-data related properties */
+ if (bHasPreDataProps) {
+ dPreData = ((HXDOUBLE) ulPreroll) *
+ ((HXDOUBLE) pInt->pMediaPropsHdr[i].max_bit_rate) /
+ 8000.0;
+ ulPreData = (UINT32)(dPreData + 0.5);
+ if (ulPreData) {
+ if (pProp) {
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "PreData",
+ RM_PROPERTY_TYPE_UINT32,
+ (void*) ulPreData, 0);
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet + 1], "PreDataAtStart",
+ RM_PROPERTY_TYPE_UINT32, (void*) 1, 0);
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet + 2], "PreDataAfterSeek",
+ RM_PROPERTY_TYPE_UINT32, (void*) 1, 0);
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet + 3], "PrerollAfterSeek",
+ RM_PROPERTY_TYPE_UINT32, (void*) 1, 0);
+ }
+ ulRet += 4;
+ }
+ }
+ /* Set/count the "RMFF 1.0 Flags" property */
+ if (pInt->pStreamInfo[i].bIsRealVideo ||
+ pInt->pStreamInfo[i].bIsRealEvent ||
+ pInt->pMediaPropsHdr[i].type_spec_sz) {
+ if (pProp) {
+ if (pInt->pStreamInfo[i].bIsRealVideo) {
+ /*
+ * For video streams, we will set 3 rules. Rule 0
+ * is a keyframe rule, rule 1 is a non-keyframe rule,
+ * and rule 2 is a keyframe (thinning) rule.
+ */
+ BYTE* pBuf = &ucRuleToFlag[0];
+ UINT32 ulLen = 8;
+ rm_pack16(3, &pBuf, &ulLen);
+ rm_pack16(HX_KEYFRAME_FLAG, &pBuf, &ulLen);
+ rm_pack16(0, &pBuf, &ulLen);
+ rm_pack16(HX_KEYFRAME_FLAG, &pBuf, &ulLen);
+ /* Set the property */
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "RMFF 1.0 Flags",
+ RM_PROPERTY_TYPE_BUFFER,
+ (void*) &ucRuleToFlag[0], 8);
+ } else if (pInt->pStreamInfo[i].bIsRealEvent ||
+ pInt->pMediaPropsHdr[i].type_spec_sz) {
+ /*
+ * For non-video streams, we will set 2 rules. Rule 0
+ * is a keyframe rule, rule 1 is a non-keyframe rule.
+ */
+ BYTE* pBuf = &ucRuleToFlag[0];
+ UINT32 ulLen = 8;
+ rm_pack16(2, &pBuf, &ulLen);
+ rm_pack16(HX_KEYFRAME_FLAG, &pBuf, &ulLen);
+ rm_pack16(0, &pBuf, &ulLen);
+ /* Set the property */
+ rm_parseri_set_rm_property(pInt, &pProp[ulRet], "RMFF 1.0 Flags",
+ RM_PROPERTY_TYPE_BUFFER,
+ (void*) &ucRuleToFlag[0], 6);
+ }
+ }
+ ulRet++;
+ }
+ }
+ return ulRet;
+}
+
+char* rm_parseri_create_asm_rulebook(rm_parser_internal* pInt, HXBOOL bIsRealVideo,
+ HXBOOL bIsRealEvent, HXBOOL bHasOpaqueData,
+ UINT32 ulMaxBitRate, UINT32 ulAvgBitRate,
+ HXBOOL* pbHasPreDataProps)
+{
+ char* pRet = HXNULL;
+
+ if (pInt && pbHasPreDataProps) {
+ HXBOOL bIsVBR = (ulMaxBitRate != ulAvgBitRate ? TRUE : FALSE);
+ /* Allocate the output buffer */
+ pRet = (char*) rm_parseri_malloc(pInt, RM_PARSER_RULE_BOOK_BUFFER_SIZE);
+ if (pRet) {
+ /* Is this a RealVideo stream? */
+ if (bIsRealVideo) {
+ /* Is this VBR? */
+ if (bIsVBR) {
+ if (ulMaxBitRate) {
+ /* VBR RealVideo with max_bit_rate != 0 */
+ strcpy(pRet, g_pszRuleBook[0]);//, 9, ulAvgBitRate, ulMaxBitRate, 5);
+ } else {
+ /* VBR RealVideo with max_bit_rate == 0 */
+ strcpy(pRet, g_pszRuleBook[1]);//, 9, ulAvgBitRate, 5);
+ }
+ /* Set the PreData flag */
+ *pbHasPreDataProps = TRUE;
+ } else {
+ /* CBR video */
+ strcpy(pRet, g_pszRuleBook[5]);//, ulAvgBitRate, ulAvgBitRate,
+ // ulAvgBitRate, ulAvgBitRate);
+ }
+ } else if (bIsRealEvent || bHasOpaqueData) {
+ /* This is most likely an event or audio stream */
+ if (bIsRealEvent) {
+ /* RealEvent stream */
+ strcpy(pRet, g_pszRuleBook[6]);
+ } else if (bIsVBR) {
+ /* Most likely an audio stream */
+ if (ulMaxBitRate) {
+ /* VBR RealAudio with max_bit_rate != 0 */
+ strcpy(pRet, g_pszRuleBook[0]);//, 5, ulAvgBitRate, ulMaxBitRate, 5);
+ } else {
+ /* VBR RealAudio with max_bit_rate == 0 */
+ strcpy(pRet, g_pszRuleBook[1]);//, 5, ulAvgBitRate, 5);
+ }
+ /* Set the PreData flag */
+ *pbHasPreDataProps = TRUE;
+ } else {
+ /* CBR RealAudio */
+ strcpy(pRet, g_pszRuleBook[7]);//, ulAvgBitRate);
+ }
+ } else {
+ /* Non-RealAudio/RealVideo/RealEvent streams */
+ if (bIsVBR) {
+ if (ulMaxBitRate) {
+ strcpy(pRet, g_pszRuleBook[2]);//, ulAvgBitRate, ulMaxBitRate);
+ } else if (ulAvgBitRate) {
+ strcpy(pRet, g_pszRuleBook[3]);//, ulAvgBitRate);
+ } else {
+ strcpy(pRet, g_pszRuleBook[4]);
+ }
+ } else {
+ /* CBR Non-RealAudio/RealVideo/RealEvent streams */
+ strcpy(pRet, g_pszRuleBook[8]);//, ulAvgBitRate);
+ }
+ }
+ }
+ }
+
+ return pRet;
+}
+
+HX_RESULT rm_parseri_read_next_packet(rm_parser_internal* pInt, rm_packet** ppPacket)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && ppPacket) {
+ /* Make sure we're still in the range of the data chunk */
+ if (pInt->ulCurFileOffset < pInt->pMediaPropsHdr[pInt->ulCurrentStream].start_offset + pInt->pDataHdr[pInt->ulCurrentStream].size) {
+ /* More packets to go - read the next one */
+ struct rm_pkt_hdr hdr;
+ rm_packet* pPacket = HXNULL;
+ UINT32 ulStreamNum = 0;
+ UINT32 ulASMRule = 0;
+ UINT32 ulASMFlags = 0;
+ UINT32 ulLastPacketTime = 0;
+ UINT32 ulLastRule = 0;
+ UINT32 ulBytesRead = 0;
+ UINT32 ulDataSize = 0;
+ UINT32 ulPacketOffset = 0;
+ HXBOOL bSkipPacket = FALSE;
+ do {
+ retVal = rm_parseri_read_next_packet_header(pInt, &hdr);
+ if (retVal == HXR_OK) {
+ /* Assume the worst */
+ retVal = HXR_FAIL;
+ /* Translate the stream number */
+ ulStreamNum = rm_parseri_translate_stream_number(pInt, hdr.stream_num);
+ if (ulStreamNum != RM_NO_STREAM_SET) {
+ /* Get the rm_stream_info for this stream */
+ struct rm_stream_info* pInfo = &pInt->pStreamInfo[ulStreamNum];
+ if (pInfo) {
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Are we currently looking for keyframes? */
+ if (pInt->ulKeyframesNeeded) {
+ /*
+ * Is this a keyframe, and do we need a keyframe
+ * for this stream?
+ */
+ if (!pInfo->bNeedKeyframe ||
+ ((hdr.flags & HX_KEYFRAME_FLAG) &&
+ (!pInfo->keyFramePacket.bValid ||
+ hdr.timestamp >= pInfo->keyFramePacket.ulTimestamp))) {
+ if (pInfo->bNeedKeyframe) {
+ pInfo->bNeedKeyframe = FALSE;
+ pInt->ulKeyframesNeeded--;
+ }
+ bSkipPacket = FALSE;
+ } else {
+ /*
+ * We need keyframes for this stream and
+ * this is not a keyframe.
+ */
+ bSkipPacket = TRUE;
+ /* Seek past the data of this packet */
+ rm_parseri_file_seek(pInt,
+ hdr.length - hdr.header_len,
+ HX_SEEK_ORIGIN_CUR);
+ }
+ } else {
+ bSkipPacket = FALSE;
+ }
+ }
+ } else {
+ /* Got a stream number we didn't expect */
+ retVal = HXR_CORRUPT_FILE;
+ /* Call back to error interface */
+ rm_parseri_error(pInt, retVal, "Unexpected stream number in packet.");
+ }
+ }
+ } while (HX_SUCCEEDED(retVal) && bSkipPacket);
+ /* Have we found a packet? */
+ if (HX_SUCCEEDED(retVal)) {
+ /* Get the last packet time and rule for this stream */
+ ulLastPacketTime = pInt->pStreamInfo[ulStreamNum].ulLastTimeStamp;
+ ulLastRule = pInt->pStreamInfo[ulStreamNum].ulLastRule;
+ /* Determine the ASM rules and flags */
+ if (pInt->pStreamInfo[ulStreamNum].bIsRealVideo) {
+ /*
+ * If the time stamp for this packet is different from
+ * the timestamp of the next packet and either this packet
+ * is a keyframe or the last packet was a keyframe we can
+ * switch on this packet
+ */
+ if (hdr.timestamp != ulLastPacketTime &&
+ (hdr.flags & HX_KEYFRAME_FLAG ||
+ ulLastRule == HX_KEYFRAME_RULE ||
+ ulLastRule == HX_THINNING_RULE)) {
+ ulASMFlags = HX_ASM_SWITCH_ON | HX_ASM_SWITCH_OFF;
+ } else if (hdr.timestamp != ulLastPacketTime) {
+ /* If this is part of a different frame, we can switch off */
+ ulASMFlags = HX_ASM_SWITCH_OFF;
+ } else {
+ /*
+ * If this packet has the same timestamp as the previous
+ * packet we cannot switch on or switch off here.
+ */
+ ulASMFlags = 0;
+ }
+ /* Assign the ASM rule */
+ ulASMRule = (hdr.flags & HX_KEYFRAME_FLAG ? HX_KEYFRAME_RULE : HX_NONKEYFRAME_RULE);
+ } else if (pInt->pStreamInfo[ulStreamNum].bIsRealAudio) {
+ /*
+ * For audio, the first block of the super block and the second block
+ * of the super block are ON since the first block and the second block
+ * are the first packets on their respective rule numbers
+ */
+ if (hdr.flags & HX_KEYFRAME_FLAG || ulLastRule == HX_KEYFRAME_RULE) {
+ ulASMFlags = HX_ASM_SWITCH_ON | HX_ASM_SWITCH_OFF;
+ } else {
+ ulASMFlags = HX_ASM_SWITCH_OFF;
+ }
+ /* Assign the ASM rule */
+ ulASMRule = (hdr.flags & HX_KEYFRAME_FLAG ? HX_KEYFRAME_RULE : HX_NONKEYFRAME_RULE);
+ } else {
+ /* Assign the ASM flags */
+ ulASMFlags = HX_ASM_SWITCH_OFF;
+ ulASMFlags |= (hdr.flags & HX_KEYFRAME_FLAG ? HX_ASM_SWITCH_ON : 0);
+ /* Is this an event stream or file version 0? */
+ if (pInt->pStreamInfo[ulStreamNum].bIsRealEvent ||
+ pInt->fileHdr.file_version == 0) {
+ ulASMRule = (hdr.flags & HX_KEYFRAME_FLAG ? HX_KEYFRAME_RULE : HX_NONKEYFRAME_RULE);
+ } else {
+ /*
+ * In case of non-RM streams version 1 or later, the rule
+ * number is recorded directly into the upper 8 bits of the
+ * flags field (packet_group)
+ */
+ ulASMRule = (UINT32)((hdr.flags >> 8) & 0x00FF);
+ }
+ }
+ /* Set the return value */
+ retVal = HXR_OUTOFMEMORY;
+ /* Allocate space for the rm_packet */
+ pPacket = (rm_packet*) rm_parseri_malloc(pInt, sizeof(rm_packet));
+ if (pPacket) {
+ /* NULL out the packet */
+ memset(pPacket, 0, sizeof(rm_packet));
+ /* Compute the data size */
+ ulDataSize = hdr.length - hdr.header_len;
+ /* Allocate space for the data */
+ pPacket->pData = (BYTE*) rm_parseri_malloc(pInt, ulDataSize);
+ if (pPacket->pData) {
+ /* Read the data into the buffer */
+ ulBytesRead = rm_parseri_file_read_buffer(pInt, pPacket->pData, ulDataSize);
+ if (ulBytesRead == ulDataSize) {
+ /* Assign the packet parameters */
+ pPacket->ulTime = hdr.timestamp;
+ pPacket->usStream = (UINT16) ulStreamNum;
+ pPacket->usASMFlags = (UINT16) ulASMFlags;
+ pPacket->ucASMRule = (BYTE) ulASMRule;
+ pPacket->ucLost = FALSE;
+ pPacket->usDataLen = (UINT16) ulDataSize;
+ /* Update the last timestamp and rule */
+ pInt->pStreamInfo[ulStreamNum].ulLastTimeStamp = hdr.timestamp;
+ pInt->pStreamInfo[ulStreamNum].ulLastRule = ulASMRule;
+ /* Compute the file offset of this packet */
+ ulPacketOffset = pInt->ulCurFileOffset -
+ ulDataSize - hdr.header_len;
+ /* Update the seek table */
+ rm_parseri_update_seek_table(pInt,
+ ulStreamNum,
+ hdr.timestamp,
+ ulPacketOffset,
+ hdr.flags);
+ /* Assign the out parameter */
+ *ppPacket = pPacket;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ } else {
+ /* Could not read packet data */
+ retVal = HXR_READ_ERROR;
+ /* Call back to error interface */
+ rm_parseri_error(pInt, retVal, "Could not read packet data.");
+ }
+ }
+ if (retVal != HXR_OK) {
+ /* Free the packet data */
+ if (pPacket->pData) {
+ rm_parseri_free(pInt, pPacket->pData);
+ pPacket->pData = HXNULL;
+ }
+ /* Free the packet */
+ rm_parseri_free(pInt, pPacket);
+ pPacket = HXNULL;
+ }
+ }
+ }
+ } else {
+ /* We are finished reading packets from this chunk */
+ retVal = HXR_AT_END;
+ }
+ }
+
+ return retVal;
+}
+
+UINT32 rm_parseri_file_read(rm_parser_internal* pInt, UINT32 ulBytesToRead, UINT32 ulReadBufferOffset)
+{
+ UINT32 ulRet = 0;
+ // DataSrc_t *ds = pInt->pUserRead;
+ UINT8 err;
+
+ if (pInt && pInt->fpRead) {
+ /* Make sure our read buffer is big enough */
+ HX_RESULT rv = rm_enforce_buffer_min_size(pInt->pUserMem,
+ pInt->fpMalloc,
+ pInt->fpFree,
+ &pInt->pReadBuffer,
+ &pInt->ulReadBufferSize,
+ ulReadBufferOffset + ulBytesToRead);
+ if (rv == HXR_OK) {
+ // if (ds&&ds->streaming_sem)
+ // AVMutexPend(ds->streaming_sem, 0, &err);
+ /* Seek the file */
+ pInt->fpSeek(pInt->pUserRead, pInt->ulCurFileOffset, HX_SEEK_ORIGIN_SET);
+ /* Read in ulBytesToRead bytes */
+ ulRet = pInt->fpRead(pInt->pUserRead,
+ pInt->pReadBuffer + ulReadBufferOffset,
+ ulBytesToRead);
+ /* Save the number of bytes in read buffer */
+ pInt->ulNumBytesRead = ulRet + ulReadBufferOffset;
+ /* Advance the current file offset */
+ pInt->ulCurFileOffset += ulRet;
+ // if (ds&&ds->streaming_sem)
+ // AVMutexPost(ds->streaming_sem);
+ }
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_parseri_file_read_buffer(rm_parser_internal* pInt, BYTE* pBuf, UINT32 ulBytesToRead)
+{
+ UINT32 ulRet = 0;
+ // DataSrc_t *ds = pInt->pUserRead;
+ UINT8 err;
+
+ if (pInt && pInt->fpRead) {
+ // if (ds&&ds->streaming_sem)
+ // AVMutexPend(ds->streaming_sem, 0, &err);
+ /* Seek the file */
+ pInt->fpSeek(pInt->pUserRead, pInt->ulCurFileOffset, HX_SEEK_ORIGIN_SET);
+ /* Read in ulBytesToRead bytes */
+ ulRet = pInt->fpRead(pInt->pUserRead, pBuf, ulBytesToRead);
+ /* Advance the current file offset */
+ pInt->ulCurFileOffset += ulRet;
+ // if (ds&&ds->streaming_sem)
+ // AVMutexPost(ds->streaming_sem);
+ }
+
+ return ulRet;
+}
+
+void rm_parseri_file_seek(rm_parser_internal* pInt, UINT32 ulOffset, UINT32 ulOrigin)
+{
+ if (pInt && pInt->fpSeek) {
+ /* Seek the file */
+ pInt->fpSeek(pInt->pUserRead, ulOffset, ulOrigin);
+ /* Update the current file offset */
+ if (ulOrigin == HX_SEEK_ORIGIN_SET) {
+ pInt->ulCurFileOffset = ulOffset;
+ } else if (ulOrigin == HX_SEEK_ORIGIN_CUR) {
+ pInt->ulCurFileOffset += ulOffset;
+ } else if (ulOrigin == HX_SEEK_ORIGIN_END) {
+ /*
+ * XXXMEH - don't know file size, so not sure what to do here.
+ * We could require ftell-like functionality, or we could
+ * require some type of fstat-like functionality.
+ */
+ rm_parseri_error(pInt, HXR_NOT_SUPPORTED, "File seek with end origin attempted - not suported.");
+ }
+ }
+}
+
+void rm_parseri_set_stream_size(rm_parser_internal* pInt, UINT32 stream_size)
+{
+ if (pInt) {
+ UINT32 i = 0;
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ if (pInt->pStreamHdr[i].ulStreamSize == RM_PARSER_DATA_CHUNK_HEADER_SIZE) {
+ pInt->pStreamHdr[i].ulStreamSize = stream_size;
+ }
+ if (pInt->pDataHdr[i].size == RM_PARSER_DATA_CHUNK_HEADER_SIZE) {
+ pInt->pDataHdr[i].size = stream_size;
+ }
+ }
+ }
+}
+
+HX_RESULT rm_parseri_copy_stream_header(rm_parser_internal* pInt, UINT32 i, rm_stream_header* pHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pHdr && i < pInt->ulNumStreams && pInt->pStreamHdr) {
+ UINT32 j = 0;
+ UINT32 ulSize = 0;
+ /* Clean up any existing header */
+ rm_parseri_cleanup_stream_header(pInt, pHdr);
+ /* Copy the hard-coded members */
+ pHdr->ulStreamNumber = pInt->pStreamHdr[i].ulStreamNumber;
+ pHdr->ulMaxBitRate = pInt->pStreamHdr[i].ulMaxBitRate;
+ pHdr->ulAvgBitRate = pInt->pStreamHdr[i].ulAvgBitRate;
+ pHdr->ulMaxPacketSize = pInt->pStreamHdr[i].ulMaxPacketSize;
+ pHdr->ulAvgPacketSize = pInt->pStreamHdr[i].ulAvgPacketSize;
+ pHdr->ulDuration = pInt->pStreamHdr[i].ulDuration;
+ pHdr->ulPreroll = pInt->pStreamHdr[i].ulPreroll;
+ pHdr->ulStartTime = pInt->pStreamHdr[i].ulStartTime;
+ pHdr->ulStartOffset = pInt->pStreamHdr[i].ulStartOffset;
+ pHdr->ulStreamSize = pInt->pStreamHdr[i].ulStreamSize;
+ pHdr->pMimeType = copy_string(pInt->pUserMem, pInt->fpMalloc,
+ pInt->pStreamHdr[i].pMimeType);
+ pHdr->pStreamName = copy_string(pInt->pUserMem, pInt->fpMalloc,
+ pInt->pStreamHdr[i].pStreamName);
+ pHdr->pOpaqueData = copy_buffer(pInt->pUserMem, pInt->fpMalloc,
+ pInt->pStreamHdr[i].pOpaqueData,
+ pInt->pStreamHdr[i].ulOpaqueDataLen);
+ if ((!pInt->pStreamHdr[i].pMimeType || pHdr->pMimeType) &&
+ (!pInt->pStreamHdr[i].pStreamName || pHdr->pStreamName) &&
+ (!pInt->pStreamHdr[i].pOpaqueData || pHdr->pOpaqueData)) {
+ /* Copy the properties array */
+ if (pInt->pStreamHdr[i].ulNumProperties &&
+ pInt->pStreamHdr[i].pProperty) {
+ /* Allocate space for the property array */
+ ulSize = pInt->pStreamHdr[i].ulNumProperties * sizeof(rm_property);
+ pHdr->pProperty = (rm_property*) rm_parseri_malloc(pInt, ulSize);
+ if (pHdr->pProperty) {
+ /* NULL out the array */
+ memset(pHdr->pProperty, 0, ulSize);
+ /* Copy each of the properties */
+ retVal = HXR_OK;
+ for (j = 0; j < pInt->pStreamHdr[i].ulNumProperties && retVal == HXR_OK; j++) {
+ retVal = rm_parseri_set_rm_property(pInt, &pHdr->pProperty[j],
+ pInt->pStreamHdr[i].pProperty[j].pName,
+ pInt->pStreamHdr[i].pProperty[j].ulType,
+ (void*) pInt->pStreamHdr[i].pProperty[j].pValue,
+ pInt->pStreamHdr[i].pProperty[j].ulValueLen);
+ }
+ if (retVal == HXR_OK) {
+ /* Assign the number of properties */
+ pHdr->ulNumProperties = pInt->pStreamHdr[i].ulNumProperties;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_update_seek_table(rm_parser_internal* pInt, UINT32 ulStreamNum,
+ UINT32 ulTime, UINT32 ulOffset, UINT32 ulFlags)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pStreamInfo && ulStreamNum < pInt->ulNumStreams) {
+ struct rm_seek_table* pTable = &pInt->pStreamInfo[ulStreamNum].seekTable;
+ if (pTable) {
+ /* Was this a keyframe packet? */
+ if (ulFlags & HX_KEYFRAME_FLAG) {
+ /* Do we have space left in the table? */
+ if (pTable->pEntry && pTable->ulNumEntries < pTable->ulMaxEntries) {
+ /*
+ * If this is the first entry; or if this
+ * time is at least ulTimeGranularity greater
+ * than the last time added, then make an entry.
+ */
+ if (!pTable->ulNumEntries ||
+ (ulTime > pTable->ulLastTime &&
+ ulTime - pTable->ulLastTime > pTable->ulTimeGranularity)) {
+ /* Update the last time */
+ pTable->ulLastTime = ulTime;
+ /* Update the time range this table covers */
+ if (ulTime > pTable->ulRangeTime) {
+ pTable->ulRangeTime = ulTime;
+ }
+ /* Make the new entry */
+ pTable->pEntry[pTable->ulNumEntries].ulTime = ulTime;
+ pTable->pEntry[pTable->ulNumEntries].ulOffset = ulOffset;
+ /* Increment the number of entries */
+ pTable->ulNumEntries++;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ } else {
+ /*
+ * This is not a keyframe, so we don't have to
+ * make an entry in the table, but we do need to
+ * update the time range that it covers.
+ */
+ if (ulTime > pTable->ulRangeTime) {
+ pTable->ulRangeTime = ulTime;
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_update_time_range(rm_parser_internal* pInt, UINT32 ulStreamNum,
+ UINT32 ulTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pStreamInfo && ulStreamNum < pInt->ulNumStreams) {
+ /* Get the seek table for this stream */
+ struct rm_seek_table* pTable = &pInt->pStreamInfo[ulStreamNum].seekTable;
+ if (pTable) {
+ /* Update the time range this table covers */
+ if (ulTime > pTable->ulRangeTime) {
+ pTable->ulRangeTime = ulTime;
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_search_all_seek_tables(rm_parser_internal* pInt, UINT32 ulSeekTime,
+ UINT32* pulFoundTime, UINT32* pulFoundOffset)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pulFoundTime && pulFoundOffset &&
+ pInt->ulNumStreams && pInt->pStreamInfo) {
+ /* Initialize local variables */
+ UINT32 ulMaxTime = 0;
+ UINT32 ulMaxOffset = 0;
+ UINT32 i = 0;
+ UINT32 pulFoundIndex;
+ HX_RESULT status = HXR_FAIL;
+ /* Search the streams */
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ /* Get the stream info struct */
+ struct rm_stream_info* pInfo = &pInt->pStreamInfo[i];
+ if (pInfo) {
+ status = rm_parseri_search_seek_table(&pInfo->seekTable,
+ ulSeekTime,
+ 0,
+ &pInfo->keyFramePacket.ulTimestamp,
+ &pInfo->keyFramePacket.ulFileOffset,
+ &pulFoundIndex);
+ if (status == HXR_OK) {
+ pInfo->keyFramePacket.bValid = TRUE;
+ if (pInfo->keyFramePacket.ulTimestamp > ulMaxTime) {
+ ulMaxTime = pInfo->keyFramePacket.ulTimestamp;
+ }
+ if (pInfo->keyFramePacket.ulFileOffset > ulMaxOffset) {
+ ulMaxOffset = pInfo->keyFramePacket.ulFileOffset;
+ }
+ }
+ /*
+ * If at least one stream succeeds, the overall search
+ * succeeds. Note that rm_parseri_search_seek_table() can
+ * return either HXR_AT_END or HXR_OK, both of which
+ * return HX_SUCCEEDED() == TRUE. That's why we have to
+ * specifically check for status == HXR_OK, as opposed
+ * to just HX_SUCCEEDED(status).
+ */
+ if (HX_FAILED(retVal) ||
+ (HX_SUCCEEDED(retVal) && status == HXR_OK)) {
+ retVal = status;
+ }
+ }
+ }
+ if (HX_SUCCEEDED(retVal)) {
+ *pulFoundTime = ulMaxTime;
+ *pulFoundOffset = ulMaxOffset;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_search_seek_tables(rm_parser_internal* pInt, INT32 lStreamNumber, UINT32 ulSeekTime, INT32 lDirection,
+ UINT32* pulFoundTime, UINT32* pulFoundOffset, UINT32* pulFoundIndex)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pulFoundTime && pulFoundOffset &&
+ pInt->ulNumStreams && pInt->pStreamInfo) {
+ /* Initialize local variables */
+ UINT32 ulMinTime = 0xffffffff;
+ UINT32 ulMinOffset = 0xffffffff;
+ UINT32 i = 0;
+ HX_RESULT status = HXR_FAIL;
+ struct rm_stream_info* pInfo = &pInt->pStreamInfo[lStreamNumber];
+ /* Search the streams */
+ {
+ /* Get the stream info struct */
+ if (pInfo) {
+ retVal = rm_parseri_search_seek_table(&pInfo->seekTable,
+ ulSeekTime,
+ lDirection,
+ &pInfo->keyFramePacket.ulTimestamp,
+ &pInfo->keyFramePacket.ulFileOffset,
+ pulFoundIndex);
+ if (retVal == HXR_OK) {
+ pInfo->keyFramePacket.bValid = TRUE;
+ }
+ }
+ }
+ if (retVal == HXR_OK) {
+ *pulFoundTime = pInfo->keyFramePacket.ulTimestamp;
+ *pulFoundOffset = pInfo->keyFramePacket.ulFileOffset;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_search_seek_table(struct rm_seek_table* pTable, UINT32 ulSeekTime, INT32 lDirection,
+ UINT32* pulFoundTime, UINT32* pulFoundOffset, UINT32 *pulFoundIndex)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pTable && pulFoundTime && pulFoundOffset && pTable->ulNumEntries) {
+ /* Estimate index to seek from */
+ UINT32 ulTableIdx = ulSeekTime / pTable->ulTimeGranularity;
+ /*
+ * If we've over-estimated, set the index at the
+ * last entry in the table.
+ */
+ if (ulTableIdx >= pTable->ulNumEntries) {
+ ulTableIdx = pTable->ulNumEntries - 1;
+ }
+ /* Scan forward in the table */
+ while (((ulTableIdx + 1) < (pTable->ulNumEntries - 1)) &&
+ (pTable->pEntry[ulTableIdx + 1].ulTime < ulSeekTime)) {
+ ulTableIdx++;
+ }
+ /* Scan backwards in the table */
+ while ((ulTableIdx > 0) &&
+ (pTable->pEntry[ulTableIdx].ulTime > ulSeekTime)) {
+ ulTableIdx--;
+ }
+ if (lDirection) {
+ if ((lDirection > 0) && (ulTableIdx < pTable->ulNumEntries - 1)) {
+ ulTableIdx++;
+ } else if ((lDirection < 0) && (ulTableIdx > 0)) {
+ ulTableIdx--;
+ }
+ }
+ /* Report results */
+ *pulFoundTime = pTable->pEntry[ulTableIdx].ulTime;
+ *pulFoundOffset = pTable->pEntry[ulTableIdx].ulOffset;
+ /* Set the return value */
+ retVal = (ulSeekTime > pTable->ulRangeTime ? HXR_AT_END : HXR_OK);
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_search_index_chunk(rm_parser_internal* pInt, UINT32 ulSeekTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->propHdr.index_offset && pInt->pStreamInfo &&
+ pInt->ulNumStreams) {
+ /* Initialize local variables */
+ struct rm_index_hdr hdr;
+ struct rm_index_rec rec;
+ UINT32 ulChunkID = 0;
+ UINT32 ulStreamNum = 0;
+ UINT32 i = 0;
+ UINT32 ulIndexOffset = pInt->propHdr.index_offset;
+ /* Mark all keyframe packets as invalid */
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ pInt->pStreamInfo[i].keyFramePacket.bValid = FALSE;
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Loop through all the index chunks */
+ while (HX_SUCCEEDED(retVal) &&
+ ulIndexOffset &&
+ !rm_parseri_is_all_keyframes_found(pInt)) {
+ /* Seek the file to the next index chunk */
+ rm_parseri_file_seek(pInt, ulIndexOffset, HX_SEEK_ORIGIN_SET);
+ /* Read the index header */
+ retVal = rm_parseri_read_next_header(pInt, &ulChunkID);
+ if (retVal == HXR_OK) {
+ /* Assume the worst */
+ retVal = HXR_FAIL;
+ /* Make sure this is an INDX header */
+ if (ulChunkID == RM_INDEX_OBJECT) {
+ /* Parse the index header */
+ retVal = rm_parseri_unpack_index_hdr(pInt, &hdr);
+ if (retVal == HXR_OK) {
+ /*
+ * Translate the stream number. If the
+ * stream number doesn't translate, then
+ * we will not consider it an error - we'll
+ * just go on to the next index chunk.
+ */
+ ulStreamNum = rm_parseri_translate_stream_number(pInt, hdr.stream_num);
+ if (ulStreamNum != RM_NO_STREAM_SET) {
+ /* Get the rm_keyframe_packet struct */
+ struct rm_keyframe_packet* pKey =
+ &pInt->pStreamInfo[ulStreamNum].keyFramePacket;
+ /* Read all the index records in this chunk */
+ for (i = 0; i < hdr.num_recs && retVal == HXR_OK; i++) {
+ retVal = rm_parseri_read_next_index_rec(pInt, &rec);
+ if (retVal == HXR_OK) {
+ /*
+ * Set this record into the on-the-fly
+ * seek table.
+ */
+ rm_parseri_update_seek_table(pInt,
+ ulStreamNum,
+ rec.timestamp,
+ rec.offset,
+ HX_KEYFRAME_FLAG);
+ /*
+ * Is the timestamp of the record
+ * greater than or equal to the seek time?
+ */
+ if (rec.timestamp >= ulSeekTime) {
+ /* Do we have a valid keyframe for this stream? */
+ if (!pKey->bValid) {
+ pKey->bValid = TRUE;
+ pKey->ulFileOffset = rec.offset;
+ pKey->ulTimestamp = rec.timestamp;
+ }
+ /*
+ * Now we can stop looking at index records
+ * for this stream
+ */
+ break;
+ } else {
+ /* Save the keyframe info */
+ pKey->bValid = TRUE;
+ pKey->ulFileOffset = rec.offset;
+ pKey->ulTimestamp = rec.timestamp;
+ }
+ }
+ }
+ }
+ /*
+ * Set the next index header. If there are
+ * no more index chunks, next_index_hdr will
+ * be zero.
+ */
+ ulIndexOffset = hdr.next_index_hdr;
+ }
+ }
+ }
+ }
+ /* Find the first keyframe */
+ if (HX_SUCCEEDED(retVal)) {
+ retVal = rm_parseri_find_first_keyframe(pInt);
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_build_seek_table(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ // not support seek without Interleaved Streams now
+ if (pInt->ulInterleavedStreamsFlag == 0) {
+ return HXR_FAIL;
+ }
+
+ if (pInt && pInt->propHdr.index_offset && pInt->pStreamInfo &&
+ pInt->ulNumStreams) {
+ /* Initialize local variables */
+ struct rm_index_hdr hdr;
+ struct rm_index_rec rec;
+ UINT32 ulChunkID = 0;
+ UINT32 ulStreamNum = 0;
+ UINT32 i = 0;
+ UINT32 ulIndexOffset = pInt->propHdr.index_offset;
+ /* Mark all keyframe packets as invalid */
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ pInt->pStreamInfo[i].keyFramePacket.bValid = FALSE;
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Loop through all the index chunks */
+ while (HX_SUCCEEDED(retVal) &&
+ ulIndexOffset &&
+ !rm_parseri_is_all_keyframes_found(pInt)) {
+ /* Seek the file to the next index chunk */
+ rm_parseri_file_seek(pInt, ulIndexOffset, HX_SEEK_ORIGIN_SET);
+ /* Read the index header */
+ retVal = rm_parseri_read_next_header(pInt, &ulChunkID);
+ if (retVal == HXR_OK) {
+ /* Assume the worst */
+ retVal = HXR_FAIL;
+ /* Make sure this is an INDX header */
+ if (ulChunkID == RM_INDEX_OBJECT) {
+ /* Parse the index header */
+ retVal = rm_parseri_unpack_index_hdr(pInt, &hdr);
+ if (retVal == HXR_OK) {
+ /*
+ * Translate the stream number. If the
+ * stream number doesn't translate, then
+ * we will not consider it an error - we'll
+ * just go on to the next index chunk.
+ */
+ ulStreamNum = rm_parseri_translate_stream_number(pInt, hdr.stream_num);
+ if (ulStreamNum != RM_NO_STREAM_SET) {
+ /* Get the rm_keyframe_packet struct */
+ struct rm_keyframe_packet* pKey =
+ &pInt->pStreamInfo[ulStreamNum].keyFramePacket;
+ /* Read all the index records in this chunk */
+ for (i = 0; i < hdr.num_recs && retVal == HXR_OK; i++) {
+ retVal = rm_parseri_read_next_index_rec(pInt, &rec);
+ if (retVal == HXR_OK) {
+ /*
+ * Set this record into the on-the-fly
+ * seek table.
+ */
+ rm_parseri_update_seek_table(pInt,
+ ulStreamNum,
+ rec.timestamp,
+ rec.offset,
+ HX_KEYFRAME_FLAG);
+ {
+ /* Save the keyframe info */
+ pKey->bValid = TRUE;
+ pKey->ulFileOffset = rec.offset;
+ pKey->ulTimestamp = rec.timestamp;
+ }
+ }
+ }
+ }
+ /*
+ * Set the next index header. If there are
+ * no more index chunks, next_index_hdr will
+ * be zero.
+ */
+ ulIndexOffset = hdr.next_index_hdr;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_seek(rm_parser_internal* pInt, UINT32 ulSeekTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->ulNumStreams && pInt->pStreamInfo) {
+ /* Initialize local variables */
+ UINT32 i = 0;
+ HX_RESULT status = HXR_OK;
+ UINT32 ulFoundTime = 0;
+ UINT32 ulDataOffset = 0;
+ /* Clear out stream state */
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ pInt->pStreamInfo[i].bStreamDone = FALSE;
+ pInt->pStreamInfo[i].ulLastTimeStamp = 0xFFFFFFFF;
+ pInt->pStreamInfo[i].keyFramePacket.bValid = FALSE;
+ }
+ /* First we try to search the on-the-fly seek table */
+ status = rm_parseri_search_all_seek_tables(pInt, ulSeekTime,
+ &ulFoundTime, &ulDataOffset);
+ if (status == HXR_OK) {
+ retVal = rm_parseri_find_first_packet_after_seek_time(pInt,
+ ulSeekTime,
+ ulDataOffset);
+ } else if (pInt->propHdr.index_offset && ulSeekTime) {
+ /*
+ * Try to find the offset via the index chunks
+ * at the end of the file
+ */
+ retVal = rm_parseri_search_index_chunk(pInt, ulSeekTime);
+ } else if (status == HXR_AT_END) {
+ /*
+ * The on-the-fly seek table returned HXR_AT_END,
+ * which means the seek time was past it's range,
+ * so it returned the last entry it had in the table.
+ * If we can't use the index table at the end of the
+ * file, then we'll use this - it's better than starting
+ * at the beginning of the data chunk.
+ */
+ retVal = rm_parseri_find_first_packet_after_seek_time(pInt,
+ ulSeekTime,
+ ulDataOffset);
+ } else {
+ /*
+ * Compute the offset of the first packet
+ * after the data chunk.
+ */
+ ulDataOffset = pInt->propHdr.data_offset +
+ RM_PARSER_DATA_CHUNK_HEADER_SIZE;
+ /* Seek from the beginning of the data chunk */
+ retVal = rm_parseri_find_first_packet_after_seek_time(pInt,
+ ulSeekTime,
+ ulDataOffset);
+ }
+ }
+
+ return retVal;
+}
+
+HXBOOL rm_parseri_is_all_keyframes_found(rm_parser_internal* pInt)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pInt && pInt->ulNumStreams && pInt->pStreamInfo) {
+ /* Init local variables */
+ UINT32 i = 0;
+ /* Assume we have found all of them */
+ bRet = TRUE;
+ /* Look through all streams */
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ if (!pInt->pStreamInfo[i].keyFramePacket.bValid) {
+ bRet = FALSE;
+ break;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+HXBOOL rm_parseri_is_a_keyframe_found(rm_parser_internal* pInt)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pInt && pInt->ulNumStreams && pInt->pStreamInfo) {
+ /* Init local variables */
+ UINT32 i = 0;
+ /* Look through all streams */
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ if (pInt->pStreamInfo[i].keyFramePacket.bValid) {
+ bRet = TRUE;
+ break;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+HX_RESULT rm_parseri_find_first_packet_after_seek_time(rm_parser_internal* pInt,
+ UINT32 ulSeekTime,
+ UINT32 ulInitialOffset)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ UINT32 ulStreamNum = 0;
+ UINT32 ulOffset = 0;
+ struct rm_pkt_hdr hdr;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Seek to the initial offset */
+ rm_parseri_file_seek(pInt, ulInitialOffset, HX_SEEK_ORIGIN_SET);
+ /*
+ * Read packet headers until we find one
+ * which is greater than or equal to the seek time.
+ */
+ while (HX_SUCCEEDED(retVal)) {
+ /* Read the next packet header */
+ retVal = rm_parseri_read_next_packet_header(pInt, &hdr);
+ if (HX_SUCCEEDED(retVal)) {
+ /* Compute the offset of this packet */
+ ulOffset = pInt->ulCurFileOffset - hdr.header_len;
+ /*
+ * Is the timestamp of this packet greater
+ * than or equal to the seek time?
+ */
+ if (hdr.timestamp >= ulSeekTime) {
+ /* We're finished. */
+ retVal = rm_parseri_find_first_keyframe(pInt);
+ break;
+ } else {
+ /* Assume the worst */
+ retVal = HXR_FAIL;
+ /* Get the stream num */
+ ulStreamNum = rm_parseri_translate_stream_number(pInt, hdr.stream_num);
+ if (ulStreamNum != RM_NO_STREAM_SET) {
+ /* Get the rm_keyframe_packet struct for this stream */
+ struct rm_keyframe_packet* pKey = &pInt->pStreamInfo[ulStreamNum].keyFramePacket;
+ if (pKey) {
+ if (hdr.flags & HX_KEYFRAME_FLAG) {
+ if (!pKey->bValid || hdr.timestamp > pKey->ulTimestamp) {
+ /* Save the keyframe info */
+ pKey->ulTimestamp = hdr.timestamp;
+ pKey->ulFileOffset = ulOffset;
+ pKey->bValid = TRUE;
+ /* Update the on-the-fly index table */
+ rm_parseri_update_seek_table(pInt,
+ ulStreamNum,
+ hdr.timestamp,
+ ulOffset,
+ hdr.flags);
+ }
+ } else {
+ rm_parseri_update_time_range(pInt,
+ ulStreamNum,
+ hdr.timestamp);
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ /*
+ * If we've succeeded and we're not done,
+ * then seek to the next packet header.
+ */
+ if (HX_SUCCEEDED(retVal)) {
+ rm_parseri_file_seek(pInt,
+ hdr.length - hdr.header_len,
+ HX_SEEK_ORIGIN_CUR);
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_parseri_find_first_keyframe(rm_parser_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->pStreamInfo && pInt->ulNumStreams) {
+ UINT32 ulLowOffset = 0;
+ UINT32 ulLowStream = 0;
+ UINT32 ulNumValid = 0;
+ UINT32 i = 0;
+ /*
+ * Mark the number of keyframes needed as
+ * the number of streams.
+ */
+ pInt->ulKeyframesNeeded = pInt->ulNumStreams;
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ pInt->pStreamInfo[i].bNeedKeyframe = TRUE;
+ }
+ /* Find the lowest offset of the valid keyframes */
+ for (i = 0; i < pInt->ulNumStreams; i++) {
+ if (pInt->pStreamInfo[i].bNeedKeyframe &&
+ pInt->pStreamInfo[i].keyFramePacket.bValid) {
+ /* Increment the number of valid keyframes */
+ ulNumValid++;
+ /* Find the lowest keyframe time and stream */
+ if (!ulLowOffset ||
+ pInt->pStreamInfo[i].keyFramePacket.ulFileOffset < ulLowOffset) {
+ ulLowOffset = pInt->pStreamInfo[i].keyFramePacket.ulFileOffset;
+ ulLowStream = i;
+ }
+ }
+ }
+ /* Did we find any valid keyframes? */
+ if (ulNumValid) {
+ /* Seek to the lowest offset */
+ rm_parseri_file_seek(pInt, ulLowOffset, HX_SEEK_ORIGIN_SET);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ } else {
+ /* Clear the number of keyframes needed */
+ pInt->ulKeyframesNeeded = 0;
+ }
+ }
+
+ return retVal;
+}
+
+void* rm_parseri_malloc(rm_parser_internal* pInt, UINT32 ulSize)
+{
+ void* pRet = HXNULL;
+ if (pInt && pInt->fpMalloc) {
+ pRet = pInt->fpMalloc(pInt->pUserMem, ulSize);
+ }
+ return pRet;
+}
+
+void rm_parseri_free(rm_parser_internal* pInt, void* pMem)
+{
+ if (pInt && pInt->fpFree) {
+ pInt->fpFree(pInt->pUserMem, pMem);
+ }
+}
+
+void rm_parseri_error(rm_parser_internal* pInt, HX_RESULT err, const char* pszMsg)
+{
+ if (pInt && pInt->fpError) {
+ pInt->fpError(pInt->pUserError, err, pszMsg);
+ }
+}
diff --git a/audio_codec/libraac/rm_parser_internal.h b/audio_codec/libraac/rm_parser_internal.h
new file mode 100644
index 0000000..4bf95a1
--- a/dev/null
+++ b/audio_codec/libraac/rm_parser_internal.h
@@ -0,0 +1,420 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_parser_internal.h,v 1.2.2.1 2005/05/04 18:21:36 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RM_PARSER_INTERNAL_H
+#define RM_PARSER_INTERNAL_H
+
+#include "../include/helix_types.h"
+#include "../include/helix_result.h"
+#include "../include/rm_memory.h"
+#include "../include/rm_error.h"
+#include "../include/rm_parse.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* Defines */
+#define RM_HEADER_OBJECT 0x2E524D46 /* '.RMF' */
+#define RM_PROPERTIES_OBJECT 0x50524F50 /* 'PROP' */
+#define RM_MEDIA_PROPERTIES_OBJECT 0x4D445052 /* 'MDPR' */
+#define RM_CONTENT_OBJECT 0x434F4E54 /* 'CONT' */
+#define RM_DATA_OBJECT 0x44415441 /* 'DATA' */
+#define RM_INDEX_OBJECT 0x494E4458 /* 'INDX' */
+#define RM_MULTIHEADER_OBJECT 0x4D4C5449 /* 'MLTI' */
+
+#define RM_NO_STREAM_SET 0xFFFFFFFF
+#define RM_INDEX_MIN_ENTRIES 32
+#define RM_INDEX_MAX_ENTRIES 2048
+#define RM_INDEX_MIN_TIME_GRANULARITY 50 /* in milliseconds */
+#define RM_INDEX_MAX_TIME_GRANULARITY 15000 /* in milliseconds */
+
+ /*
+ * We explicitly define the size for structs
+ * to be read. That's because we can't use sizeof()
+ * to determine how much to read since struct
+ * alignment will make that value different.
+ */
+#define RM_PARSER_GENERIC_HDR_SIZE 10
+#define RM_PARSER_INDEX_HEADER_SIZE 20
+#define RM_PARSER_INDEX_RECORD_SIZE 14
+#define RM_PARSER_PACKET_HEADER_SIZE 12
+#define RM_PARSER_DATA_CHUNK_HEADER_SIZE 18
+
+ /* generic header -- most headers start like this */
+ struct rm_generic_hdr {
+ UINT32 id; /* unique identifier for this header */
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ };
+
+ /* rm file header -- all real media files start with this header */
+ struct rm_file_hdr {
+ UINT32 id; /* unique identifier for this header */
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ UINT32 file_version; /* revision number for realmedia file */
+ UINT32 num_headers; /* num headers in file (including this one) */
+ };
+
+ /* rm properties header -- summarizes data for entire clip */
+ struct rm_properties_hdr {
+ UINT32 id; /* unique identifier for this header */
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ UINT32 max_bit_rate; /* maximum bit rate of clip */
+ UINT32 avg_bit_rate; /* average bit rate of clip */
+ UINT32 max_pkt_size; /* max length of packet in clip (bytes) */
+ UINT32 avg_pkt_size; /* averge length of packet in clip (bytes) */
+ UINT32 num_pkts; /* total packets in clip (all streams) */
+ UINT32 duration; /* duration of clip (milliseconds) */
+ UINT32 preroll; /* preroll time (milliseconds) */
+ UINT32 index_offset; /* offset to beginning of index data */
+ UINT32 data_offset; /* offset to beginning of packet data */
+ UINT16 num_streams; /* total number of streams in clip */
+ UINT32 flags; /* various and sundry */
+ };
+
+ /* rm content header -- title, author, copyright */
+ struct rm_content_hdr {
+ UINT32 id; /* unique identifier for this header */
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ UINT16 title_sz; /* length of title field */
+ char* title; /* title of clip */
+ UINT16 author_sz; /* length of author field */
+ char* author; /* author of clip */
+ UINT16 copyright_sz; /* length of copyright field */
+ char* copyright; /* copyright of clip */
+ UINT16 comment_sz; /* length of comment field */
+ char* comment; /* comment */
+ };
+
+ /* rm media properties header -- stream info, one for each stream */
+ struct rm_media_props_hdr {
+ UINT32 id; /* unique identifier for this header */
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ UINT16 stream_num; /* stream number */
+ UINT32 max_bit_rate; /* maximum bit rate of stream */
+ UINT32 avg_bit_rate; /* average bit rate of stream */
+ UINT32 max_pkt_size; /* max length of packet in stream (bytes) */
+ UINT32 avg_pkt_size; /* averge length of packet in stream (bytes) */
+ UINT32 start_time; /* start time of stream -- clip relative */
+ UINT32 preroll; /* preroll time (milliseconds) */
+ UINT32 duration; /* duration of stream (milliseconds) */
+ BYTE stream_name_sz; /* length of stream_name field */
+ char* stream_name; /* string name of stream */
+ BYTE mime_type_sz; /* length of mime_type field */
+ char* mime_type; /* MIME type of stream */
+ UINT32 type_spec_sz; /* length of type_spec field */
+ BYTE* type_spec; /* type specific data buffer */
+ UINT32 start_offset; /* for non-interleaved stream only */
+ };
+
+ /* rm name value header -- implements name/value pairs */
+ struct rm_name_value_map {
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ BYTE name_sz; /* length of name field */
+ char* name; /* name of property */
+ UINT32 type; /* type of property */
+ UINT16 value_sz; /* length of value field */
+ BYTE* value; /* value of property */
+ };
+
+ /* rm logical stream header -- used for surestream */
+ struct rm_logical_stream_hdr {
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ UINT16 num_physical_streams; /* number of actual streams */
+ UINT16* physical_stream_num; /* array of stream numbers */
+ UINT32* data_offsets; /* array of offsets to stream packets */
+ UINT16 num_rules; /* number of ASM rules */
+ UINT16* rule_stream_map; /* maps rules to streams */
+ UINT16 num_props; /* number of name value properties */
+ struct rm_name_value_map* props; /* array of name value properties */
+ };
+
+ /* rm meta information -- clip meta data */
+ struct rm_meta_data_hdr {
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ UINT16 num_props; /* number of name value properties */
+ struct rm_name_value_map* props; /* array of name value properties */
+ };
+
+ /* rm data header -- this occurs before the start of packet data */
+ struct rm_data_hdr {
+ UINT32 id; /* unique identifier for this header */
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ UINT32 num_pkts; /* total number of packets in segment */
+ UINT32 next_data_hdr; /* offset of next segment */
+ };
+
+ /* rm index header -- this occurs before the start of index data */
+ struct rm_index_hdr {
+ UINT32 id; /* unique identifier for this header */
+ UINT32 size; /* size of header in file */
+ UINT16 version; /* struct version */
+ UINT32 num_recs; /* number of index records */
+ UINT16 stream_num; /* stream number being indexed */
+ UINT32 next_index_hdr; /* offset of next header */
+ };
+
+ /* rm index record -- describes an index entry */
+ struct rm_index_rec {
+ UINT16 version; /* record version */
+ UINT32 timestamp; /* packet timestamp */
+ UINT32 offset; /* offset of packet in file */
+ UINT32 num_pkts; /* number of packets before this one in clip */
+ };
+
+ /* rm packet header */
+ struct rm_pkt_hdr_base {
+ UINT16 version; /* struct version */
+ UINT16 length; /* length of header */
+ };
+
+ struct rm_pkt_hdr {
+ UINT16 version; /* struct version */
+ UINT16 length; /* length of header */
+ UINT16 stream_num; /* stream number */
+ UINT32 timestamp; /* packet timestamp */
+ UINT16 flags; /* keyframe, etc. */
+ BYTE header_len;
+ };
+
+ struct rm_pkt_hdr1 {
+ UINT16 version; /* struct version */
+ UINT16 length; /* length of header */
+ UINT16 stream_num; /* stream number */
+ UINT32 timestamp; /* packet timestamp */
+ UINT16 asm_rule; /* for surestream */
+ BYTE asm_flags;
+ };
+
+ /*
+ * Internal struct which tracks stream info
+ */
+ struct rm_seek_table_entry {
+ UINT32 ulTime;
+ UINT32 ulOffset;
+ };
+
+ struct rm_seek_table {
+ struct rm_seek_table_entry* pEntry;
+ UINT32 ulMaxEntries;
+ UINT32 ulNumEntries;
+ UINT32 ulLastTime;
+ UINT32 ulRangeTime;
+ UINT32 ulTimeGranularity;
+ };
+
+ struct rm_keyframe_packet {
+ UINT32 ulTimestamp;
+ UINT32 ulFileOffset;
+ HXBOOL bValid;
+ };
+
+ struct rm_stream_info {
+ UINT32 ulLastTimeStamp;
+ UINT32 ulLastRule;
+ struct rm_keyframe_packet keyFramePacket;
+ struct rm_seek_table seekTable;
+ HX_BITFIELD bIsRealAudio : 1;
+ HX_BITFIELD bIsRealVideo : 1;
+ HX_BITFIELD bIsRealEvent : 1;
+ HX_BITFIELD bStreamDone : 1;
+ HX_BITFIELD bNeedKeyframe : 1;
+ HX_BITFIELD bSeenFirstPacketTimeStamp : 1;
+ };
+
+ /*
+ * Parser struct
+ */
+ typedef struct rm_parser_internal_struct {
+ rm_error_func_ptr fpError;
+ void* pUserError;
+ rm_malloc_func_ptr fpMalloc;
+ rm_free_func_ptr fpFree;
+ void* pUserMem;
+ rm_read_func_ptr fpRead;
+ rm_seek_func_ptr fpSeek;
+ void* pUserRead;
+ struct rm_file_hdr fileHdr;
+ struct rm_properties_hdr propHdr;
+ struct rm_content_hdr contHdr;
+ UINT32 ulNumStreams;
+ UINT32 ulNumMediaPropsHdrs;
+ UINT32 ulNumMediaPropsHdrsAlloc;
+ struct rm_media_props_hdr* pMediaPropsHdr;
+ UINT32 ulNumLogicalStreamHdrs;
+ struct rm_logical_stream_hdr* pLogicalStreamHdr;
+ struct rm_logical_stream_hdr* pLogicalFileInfo;
+ BYTE* pReadBuffer; /* Read buffer */
+ UINT32 ulReadBufferSize; /* Allocated size of the read buffer */
+ UINT32 ulNumBytesRead; /* Current number of bytes read into the buffer */
+ UINT32 ulCurFileOffset; /* Current read offset into the file */
+ UINT32 ulStreamNumMapSize;
+ UINT32* pulStreamNumMap;
+ UINT32 ulMaxDuration;
+ struct rm_stream_info* pStreamInfo;
+ struct rm_data_hdr* pDataHdr;
+ HXBOOL bIsRealDataType;
+ UINT32 ulMinFirstPacketTime;
+ rm_stream_header* pStreamHdr;
+ UINT32 ulKeyframesNeeded;
+ UINT32 ulInterleavedStreamsFlag;
+ UINT32 ulCurrentStream;
+ } rm_parser_internal;
+
+ /*
+ * Internal parser functions
+ */
+ HX_RESULT rm_parseri_unpack_generic_hdr(rm_parser_internal* pInt, struct rm_generic_hdr* h);
+ HX_RESULT rm_parseri_unpack_file_hdr(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_unpack_properties_hdr(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_unpack_content_hdr(rm_parser_internal* pInt);
+ void rm_parseri_cleanup_content_hdr(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_unpack_media_props_hdr(rm_parser_internal* pInt,
+ struct rm_media_props_hdr* h);
+ void rm_parseri_cleanup_media_props_hdr(rm_parser_internal* pInt,
+ struct rm_media_props_hdr* h);
+ void rm_parseri_cleanup_all_media_props_hdrs(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_unpack_name_value_map(rm_parser_internal* pInt,
+ struct rm_name_value_map* pMap,
+ BYTE** ppBuf, UINT32* pulLen);
+ void rm_parseri_cleanup_name_value_map(rm_parser_internal* pInt,
+ struct rm_name_value_map* h);
+ void rm_parseri_cleanup_all_name_value_maps(rm_parser_internal* pInt,
+ struct rm_logical_stream_hdr* h);
+ HX_RESULT rm_parseri_unpack_logical_stream_hdr(rm_parser_internal* pInt,
+ struct rm_media_props_hdr* mh,
+ struct rm_logical_stream_hdr* h);
+ UINT32 rm_parseri_get_num_logical_streams(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_unpack_all_logical_stream_hdrs(rm_parser_internal* pInt);
+ void rm_parseri_cleanup_logical_stream_hdr(rm_parser_internal* pInt,
+ struct rm_logical_stream_hdr* h);
+ void rm_parseri_cleanup_all_logical_stream_hdrs(rm_parser_internal* pInt);
+ HXBOOL rm_parseri_is_logical_fileinfo_present(rm_parser_internal* pInt, UINT32* pulIndx);
+ void rm_parseri_cleanup_logical_fileinfo_hdr(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_allocate_media_props_hdrs(rm_parser_internal* pInt);
+ void rm_parseri_cleanup_read_buffer(rm_parser_internal* pInt);
+ UINT32 rm_parseri_get_media_props_hdr_stream_num(rm_parser_internal* pInt);
+ HXBOOL rm_parseri_is_logical_stream_mime_type(const char* pszMimeType);
+ HXBOOL rm_parseri_is_logical_fileinfo_mime_type(const char* pszMimeType);
+ HX_RESULT rm_parseri_read_next_header(rm_parser_internal* pInt, UINT32* pulID);
+ HX_RESULT rm_parseri_setup_interleaved_streams(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_read_all_headers(rm_parser_internal* pInt);
+ UINT32 rm_parseri_get_num_file_properties(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_get_file_properties(rm_parser_internal* pInt,
+ rm_property* pProp, UINT32 ulNumProp);
+ HXBOOL rm_parseri_has_real_data_type(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_set_rm_property(rm_parser_internal* pInt, rm_property* pProp,
+ const char* pszName, UINT32 ulType,
+ void* pValue, UINT32 ulValueLen);
+ void rm_parseri_cleanup_rm_property(rm_parser_internal* pInt, rm_property* pProp);
+ void rm_parseri_cleanup_stream_num_map(rm_parser_internal* pInt);
+ void rm_parseri_cleanup_stream_info(rm_parser_internal* pInt, struct rm_stream_info* pInfo);
+ void rm_parseri_cleanup_stream_info_array(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_create_stream_structures(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_examine_initial_packets(rm_parser_internal* pInt, UINT32 StreamNum);
+ HX_RESULT rm_parseri_unpack_data_hdr(rm_parser_internal* pInt, UINT32 StreamNum);
+ HX_RESULT rm_parseri_unpack_pkt_hdr(rm_parser_internal* pInt,
+ struct rm_pkt_hdr* pPktHdr);
+ HX_RESULT rm_parseri_unpack_index_hdr(rm_parser_internal* pInt,
+ struct rm_index_hdr* hdr);
+ HX_RESULT rm_parseri_unpack_index_rec(rm_parser_internal* pInt,
+ struct rm_index_rec* rec);
+ HX_RESULT rm_parseri_read_next_index_rec(rm_parser_internal* pInt,
+ struct rm_index_rec* rec);
+ UINT32 rm_parseri_translate_stream_number(rm_parser_internal* pInt, UINT32 ulNum);
+ HX_RESULT rm_parseri_create_all_stream_headers(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_create_stream_header(rm_parser_internal* pInt, UINT32 i,
+ rm_stream_header* hdr);
+ void rm_parseri_cleanup_all_stream_headers(rm_parser_internal* pInt);
+ void rm_parseri_cleanup_stream_header(rm_parser_internal* pInt, rm_stream_header* hdr);
+ UINT32 rm_parseri_count_set_stream_header_props(rm_parser_internal* pInt, UINT32 i,
+ rm_stream_header* hdr,
+ rm_property* pProp, UINT32 ulNumProps);
+ char* rm_parseri_create_asm_rulebook(rm_parser_internal* pInt, HXBOOL bIsVideo,
+ HXBOOL bIsEvent, HXBOOL bHasOpaqueData,
+ UINT32 ulMaxBitRate, UINT32 ulAvgBitRate,
+ HXBOOL* pbHasPreDataProps);
+ HX_RESULT rm_parseri_read_next_packet(rm_parser_internal* pInt, rm_packet** ppPacket);
+ UINT32 rm_parseri_file_read(rm_parser_internal* pInt, UINT32 ulBytesToRead, UINT32 ulReadBufferOffset);
+ UINT32 rm_parseri_file_read_buffer(rm_parser_internal* pInt, BYTE* pBuf, UINT32 ulBytesToRead);
+ void rm_parseri_file_seek(rm_parser_internal* pInt, UINT32 ulOffset, UINT32 ulOrigin);
+ void rm_parseri_set_stream_size(rm_parser_internal* pInt, UINT32 stream_size);
+ HX_RESULT rm_parseri_copy_stream_header(rm_parser_internal* pInt, UINT32 i, rm_stream_header* pHdr);
+ HX_RESULT rm_parseri_update_seek_table(rm_parser_internal* pInt, UINT32 ulStreamNum,
+ UINT32 ulTime, UINT32 ulOffset, UINT32 ulFlags);
+ HX_RESULT rm_parseri_update_time_range(rm_parser_internal* pInt, UINT32 ulStreamNum,
+ UINT32 ulTime);
+ HX_RESULT rm_parseri_search_all_seek_tables(rm_parser_internal* pInt, UINT32 ulSeekTime,
+ UINT32* pulFoundTime, UINT32* pulFoundOffset);
+ HX_RESULT rm_parseri_search_seek_table(struct rm_seek_table* pTable, UINT32 ulSeekTime, INT32 lDirection,
+ UINT32* pulFoundTime, UINT32* pulFoundOffset, UINT32* pulFoundIndex);
+ HX_RESULT rm_parseri_search_index_chunk(rm_parser_internal* pInt, UINT32 ulSeekTime);
+ HX_RESULT rm_parseri_seek(rm_parser_internal* pInt, UINT32 ulSeekTime);
+ HXBOOL rm_parseri_is_all_keyframes_found(rm_parser_internal* pInt);
+ HXBOOL rm_parseri_is_a_keyframe_found(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_find_first_packet_after_seek_time(rm_parser_internal* pInt,
+ UINT32 ulSeekTime,
+ UINT32 ulInitialOffset);
+ HX_RESULT rm_parseri_find_first_keyframe(rm_parser_internal* pInt);
+ void* rm_parseri_malloc(rm_parser_internal* pInt, UINT32 ulSize);
+ void rm_parseri_free(rm_parser_internal* pInt, void* pMem);
+ void rm_parseri_error(rm_parser_internal* pInt, HX_RESULT err, const char* pszMsg);
+
+ HX_RESULT rm_parseri_build_seek_table(rm_parser_internal* pInt);
+ HX_RESULT rm_parseri_search_seek_tables(rm_parser_internal* pInt,
+ INT32 lStreamNumber,
+ UINT32 ulSeekTime,
+ INT32 lDirection,
+ UINT32* pulFoundTime,
+ UINT32* pulFoundOffset,
+ UINT32* pulFoundIndex);
+ UINT32 rm_parseri_get_stream_number(rm_parser_internal* pInt, UINT32 ulNum);
+ void rm_parseri_cleanup_all_data_headers(rm_parser_internal* pInt);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef RM_PARSER_INTERNAL_H */
diff --git a/audio_codec/libraac/rm_property.c b/audio_codec/libraac/rm_property.c
new file mode 100644
index 0000000..db0ab6f
--- a/dev/null
+++ b/audio_codec/libraac/rm_property.c
@@ -0,0 +1,105 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_property.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "../include/helix_types.h"
+#include "../include/rm_property.h"
+
+const char* rm_property_get_name(rm_property* prop)
+{
+ const char* pRet = HXNULL;
+
+ if (prop) {
+ pRet = (const char*) prop->pName;
+ }
+
+ return pRet;
+}
+
+UINT32 rm_property_get_type(rm_property* prop)
+{
+ UINT32 ulRet = 0;
+
+ if (prop) {
+ ulRet = prop->ulType;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_property_get_value_uint32(rm_property* prop)
+{
+ UINT32 ulRet = 0;
+
+ if (prop) {
+ ulRet = (UINT32) prop->pValue;
+ }
+
+ return ulRet;
+}
+
+const char* rm_property_get_value_cstring(rm_property* prop)
+{
+ const char* pRet = HXNULL;
+
+ if (prop) {
+ pRet = (const char*) prop->pValue;
+ }
+
+ return pRet;
+}
+
+UINT32 rm_property_get_value_buffer_length(rm_property* prop)
+{
+ UINT32 ulRet = 0;
+
+ if (prop) {
+ ulRet = prop->ulValueLen;
+ }
+
+ return ulRet;
+}
+
+BYTE* rm_property_get_value_buffer(rm_property* prop)
+{
+ BYTE* pRet = HXNULL;
+
+ if (prop) {
+ pRet = prop->pValue;
+ }
+
+ return pRet;
+}
diff --git a/audio_codec/libraac/rm_stream.c b/audio_codec/libraac/rm_stream.c
new file mode 100644
index 0000000..47c1ff0
--- a/dev/null
+++ b/audio_codec/libraac/rm_stream.c
@@ -0,0 +1,356 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rm_stream.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <string.h>
+#include "../include/helix_types.h"
+#include "../include/helix_mime_types.h"
+#include "../include/rm_property.h"
+#include "../include/rm_stream.h"
+
+UINT32 rm_stream_get_number(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulStreamNumber;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_max_bit_rate(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulMaxBitRate;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_avg_bit_rate(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulAvgBitRate;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_max_packet_size(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulMaxPacketSize;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_avg_packet_size(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulAvgPacketSize;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_start_time(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulStartTime;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_preroll(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulPreroll;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_duration(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulDuration;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_data_offset(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulStartOffset;
+ }
+
+ return ulRet;
+}
+
+UINT32 rm_stream_get_data_size(rm_stream_header* hdr)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr) {
+ ulRet = hdr->ulStreamSize;
+ }
+
+ return ulRet;
+}
+
+const char* rm_stream_get_name(rm_stream_header* hdr)
+{
+ const char* pRet = HXNULL;
+
+ if (hdr) {
+ pRet = (const char*) hdr->pStreamName;
+ }
+
+ return pRet;
+}
+
+const char* rm_stream_get_mime_type(rm_stream_header* hdr)
+{
+ const char* pRet = HXNULL;
+
+ if (hdr) {
+ pRet = (const char*) hdr->pMimeType;
+ }
+
+ return pRet;
+}
+
+UINT32 rm_stream_get_properties(rm_stream_header* hdr, rm_property** ppProp)
+{
+ UINT32 ulRet = 0;
+
+ if (hdr && ppProp) {
+ *ppProp = hdr->pProperty;
+ ulRet = hdr->ulNumProperties;
+ }
+
+ return ulRet;
+}
+
+HXBOOL rm_stream_is_realaudio(rm_stream_header* hdr)
+{
+ HXBOOL bRet = FALSE;
+
+ if (hdr) {
+ bRet = rm_stream_is_realaudio_mimetype((const char*) hdr->pMimeType);
+ }
+
+ return bRet;
+}
+
+HXBOOL rm_stream_is_realvideo(rm_stream_header* hdr)
+{
+ HXBOOL bRet = FALSE;
+
+ if (hdr) {
+ bRet = rm_stream_is_realvideo_mimetype((const char*) hdr->pMimeType);
+ }
+
+ return bRet;
+}
+
+HXBOOL rm_stream_is_realevent(rm_stream_header* hdr)
+{
+ HXBOOL bRet = FALSE;
+
+ if (hdr) {
+ bRet = rm_stream_is_realevent_mimetype((const char*) hdr->pMimeType);
+ }
+
+ return bRet;
+}
+
+HXBOOL rm_stream_is_realaudio_mimetype(const char* pszStr)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pszStr) {
+ if (!strcmp(pszStr, REALAUDIO_MIME_TYPE) ||
+ !strcmp(pszStr, REALAUDIO_MULTIRATE_MIME_TYPE) ||
+ !strcmp(pszStr, REALAUDIO_ENCRYPTED_MIME_TYPE)) {
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+HXBOOL rm_stream_is_realvideo_mimetype(const char* pszStr)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pszStr) {
+ if (!strcmp(pszStr, REALVIDEO_MIME_TYPE) ||
+ !strcmp(pszStr, REALVIDEO_MULTIRATE_MIME_TYPE) ||
+ !strcmp(pszStr, REALVIDEO_ENCRYPTED_MIME_TYPE)) {
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+HXBOOL rm_stream_is_realevent_mimetype(const char* pszStr)
+{
+ HXBOOL bRet = FALSE;
+
+ if (pszStr) {
+ if (!strcmp(pszStr, REALEVENT_MIME_TYPE) ||
+ !strcmp(pszStr, REALEVENT_ENCRYPTED_MIME_TYPE) ||
+ !strcmp(pszStr, REALIMAGEMAP_MIME_TYPE) ||
+ !strcmp(pszStr, REALIMAGEMAP_ENCRYPTED_MIME_TYPE) ||
+ !strcmp(pszStr, IMAGEMAP_MIME_TYPE) ||
+ !strcmp(pszStr, IMAGEMAP_ENCRYPTED_MIME_TYPE) ||
+ !strcmp(pszStr, SYNCMM_MIME_TYPE) ||
+ !strcmp(pszStr, SYNCMM_ENCRYPTED_MIME_TYPE)) {
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+HXBOOL rm_stream_is_real_mimetype(const char* pszStr)
+{
+ return rm_stream_is_realaudio_mimetype(pszStr) ||
+ rm_stream_is_realvideo_mimetype(pszStr) ||
+ rm_stream_is_realevent_mimetype(pszStr);
+}
+
+HX_RESULT rm_stream_get_property_int(rm_stream_header* hdr,
+ const char* pszStr,
+ UINT32* pulVal)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (hdr && pszStr && pulVal &&
+ hdr->pProperty && hdr->ulNumProperties) {
+ UINT32 i = 0;
+ for (i = 0; i < hdr->ulNumProperties; i++) {
+ rm_property* pProp = &hdr->pProperty[i];
+ if (pProp->ulType == RM_PROPERTY_TYPE_UINT32 &&
+ pProp->pName &&
+ !strcmp(pszStr, (const char*) pProp->pName)) {
+ /* Assign the out parameter */
+ *pulVal = (UINT32) pProp->pValue;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ break;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_stream_get_property_buf(rm_stream_header* hdr,
+ const char* pszStr,
+ BYTE** ppBuf,
+ UINT32* pulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (hdr && pszStr && ppBuf && pulLen &&
+ hdr->pProperty && hdr->ulNumProperties) {
+ UINT32 i = 0;
+ for (i = 0; i < hdr->ulNumProperties; i++) {
+ rm_property* pProp = &hdr->pProperty[i];
+ if (pProp->ulType == RM_PROPERTY_TYPE_BUFFER &&
+ pProp->pName &&
+ !strcmp(pszStr, (const char*) pProp->pName)) {
+ /* Assign the out parameters */
+ *ppBuf = pProp->pValue;
+ *pulLen = pProp->ulValueLen;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ break;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rm_stream_get_property_str(rm_stream_header* hdr,
+ const char* pszStr,
+ char** ppszStr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (hdr && pszStr && ppszStr &&
+ hdr->pProperty && hdr->ulNumProperties) {
+ UINT32 i = 0;
+ for (i = 0; i < hdr->ulNumProperties; i++) {
+ rm_property* pProp = &hdr->pProperty[i];
+ if (pProp->ulType == RM_PROPERTY_TYPE_CSTRING &&
+ pProp->pName &&
+ !strcmp(pszStr, (const char*) pProp->pName)) {
+ /* Assign the out parameter */
+ *ppszStr = (char*) pProp->pValue;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ break;
+ }
+ }
+ }
+
+ return retVal;
+}
diff --git a/audio_codec/libraac/rv_depack.c b/audio_codec/libraac/rv_depack.c
new file mode 100644
index 0000000..00a4374
--- a/dev/null
+++ b/audio_codec/libraac/rv_depack.c
@@ -0,0 +1,271 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_depack.c,v 1.1.1.1.2.1 2005/05/04 18:21:20 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <memory.h>
+#include "../include/helix_types.h"
+#include "../include/helix_result.h"
+#include "../include/rv_depack.h"
+#include "rv_depack_internal.h"
+#include "../include/rm_memory_default.h"
+#include "../include/rm_error_default.h"
+#include "../include/memory_utils.h"
+
+rv_depack* rv_depack_create(void* pAvail,
+ rv_frame_avail_func_ptr fpAvail,
+ void* pUserError,
+ rm_error_func_ptr fpError)
+{
+ return rv_depack_create2(pAvail,
+ fpAvail,
+ pUserError,
+ fpError,
+ HXNULL,
+ rm_memory_default_malloc,
+ rm_memory_default_free);
+}
+
+rv_depack* rv_depack_create2(void* pAvail,
+ rv_frame_avail_func_ptr fpAvail,
+ void* pUserError,
+ rm_error_func_ptr fpError,
+ void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree)
+{
+ rv_depack* pRet = HXNULL;
+
+ if (fpAvail && fpMalloc && fpFree) {
+ /* Allocate space for the rv_depack_internal struct
+ * by using the passed-in malloc function
+ */
+ rv_depack_internal* pInt =
+ (rv_depack_internal*) fpMalloc(pUserMem, sizeof(rv_depack_internal));
+ if (pInt) {
+ /* Zero out the struct */
+ memset((void*) pInt, 0, sizeof(rv_depack_internal));
+ /* Assign the frame callback members */
+ pInt->pAvail = pAvail;
+ pInt->fpAvail = fpAvail;
+ /*
+ * Assign the error members. If the caller did not
+ * provide an error callback, then use the default
+ * rm_error_default().
+ */
+ if (fpError) {
+ pInt->fpError = fpError;
+ pInt->pUserError = pUserError;
+ } else {
+ pInt->fpError = rm_error_default;
+ pInt->pUserError = HXNULL;
+ }
+ /* Assign the memory functions */
+ pInt->fpMalloc = fpMalloc;
+ pInt->fpFree = fpFree;
+ pInt->pUserMem = pUserMem;
+ /* Assign the return value */
+ pRet = (rv_depack*) pInt;
+ }
+ }
+
+ return pRet;
+}
+
+HX_RESULT rv_depack_init(rv_depack* pDepack, rm_stream_header* header)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pDepack && header) {
+ /* Get the internal struct */
+ rv_depack_internal* pInt = (rv_depack_internal*) pDepack;
+ /* Call the internal init */
+ retVal = rv_depacki_init(pInt, header);
+ }
+
+ return retVal;
+}
+
+UINT32 rv_depack_get_num_substreams(rv_depack* pDepack)
+{
+ UINT32 ulRet = 0;
+
+ if (pDepack) {
+ /* Get the internal struct */
+ rv_depack_internal* pInt = (rv_depack_internal*) pDepack;
+ /* Return the number of substreams */
+ ulRet = pInt->multiStreamHdr.ulNumSubStreams;
+ }
+
+ return ulRet;
+}
+
+UINT32 rv_depack_get_codec_4cc(rv_depack* pDepack)
+{
+ UINT32 ulRet = 0;
+
+ if (pDepack) {
+ /* Get the internal struct */
+ rv_depack_internal* pInt = (rv_depack_internal*) pDepack;
+ if (pInt->pSubStreamHdr &&
+ pInt->ulActiveSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Copy the subMOF tag */
+ ulRet = pInt->pSubStreamHdr[pInt->ulActiveSubStream].ulSubMOFTag;
+ }
+ }
+
+ return ulRet;
+}
+
+HX_RESULT rv_depack_get_codec_init_info(rv_depack* pDepack, rv_format_info** ppInfo)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pDepack && ppInfo) {
+ /* Get the internal struct */
+ rv_depack_internal* pInt = (rv_depack_internal*) pDepack;
+ if (pInt->pSubStreamHdr &&
+ pInt->ulActiveSubStream < pInt->multiStreamHdr.ulNumSubStreams) {
+ /* Clean up any existing format info */
+ rv_depacki_cleanup_format_info(pInt, *ppInfo);
+ /* Allocate memory for the format info */
+ *ppInfo = rv_depacki_malloc(pInt, sizeof(rv_format_info));
+ if (*ppInfo) {
+ /* NULL out the memory */
+ memset(*ppInfo, 0, sizeof(rv_format_info));
+ /* Make a deep copy of the format info */
+ retVal = rv_depacki_copy_format_info(pInt,
+ &pInt->pSubStreamHdr[pInt->ulActiveSubStream],
+ *ppInfo);
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rv_depack_destroy_codec_init_info(rv_depack* pDepack, rv_format_info** ppInfo)
+{
+ if (pDepack && ppInfo && *ppInfo) {
+ /* Get the internal struct */
+ rv_depack_internal* pInt = (rv_depack_internal*) pDepack;
+ /* Clean up the format info's internal allocs */
+ rv_depacki_cleanup_format_info(pInt, *ppInfo);
+ /* NULL it out */
+ memset(*ppInfo, 0, sizeof(rv_format_info));
+ /* Delete the memory associated with it */
+ rv_depacki_free(pInt, *ppInfo);
+ /* NULL the pointer out */
+ *ppInfo = HXNULL;
+ }
+}
+
+HX_RESULT rv_depack_add_packet(rv_depack* pDepack, rm_packet* packet)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pDepack && packet) {
+ /* Get the internal struct */
+ rv_depack_internal* pInt = (rv_depack_internal*) pDepack;
+ /* Call the internal function */
+ retVal = rv_depacki_add_packet(pInt, packet);
+ }
+
+ return retVal;
+}
+
+void rv_depack_destroy_frame(rv_depack* pDepack, rv_frame** ppFrame)
+{
+ if (pDepack && ppFrame && *ppFrame) {
+ /* Get the internal struct */
+ rv_depack_internal* pInt = (rv_depack_internal*) pDepack;
+ /* Call the internal function */
+ rv_depacki_cleanup_frame(pInt, ppFrame);
+ }
+}
+
+HX_RESULT rv_depack_seek(rv_depack* pDepack, UINT32 ulTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pDepack) {
+ /* Get the internal struct */
+ rv_depack_internal* pInt = (rv_depack_internal*) pDepack;
+ /* Call the internal function */
+ retVal = rv_depacki_seek(pInt, ulTime);
+ }
+
+ return retVal;
+}
+
+void rv_depack_destroy(rv_depack** ppDepack)
+{
+ if (ppDepack) {
+ rv_depack_internal* pInt = (rv_depack_internal*) * ppDepack;
+ if (pInt && pInt->fpFree) {
+ /* Save a pointer to fpFree and pUserMem */
+ rm_free_func_ptr fpFree = pInt->fpFree;
+ void* pUserMem = pInt->pUserMem;
+ /* Clean up the rule to flag map */
+ if (pInt->rule2Flag.pulMap) {
+ rv_depacki_free(pInt, pInt->rule2Flag.pulMap);
+ pInt->rule2Flag.pulMap = HXNULL;
+ pInt->rule2Flag.ulNumRules = 0;
+ }
+ /* Clean up the rule to header map */
+ if (pInt->multiStreamHdr.rule2SubStream.pulMap) {
+ rv_depacki_free(pInt, pInt->multiStreamHdr.rule2SubStream.pulMap);
+ pInt->multiStreamHdr.rule2SubStream.pulMap = HXNULL;
+ pInt->multiStreamHdr.rule2SubStream.ulNumRules = 0;
+ }
+ /* Clean up the format info array */
+ rv_depacki_cleanup_format_info_array(pInt);
+ /* Clean up ignore header array */
+ if (pInt->bIgnoreSubStream) {
+ rv_depacki_free(pInt, pInt->bIgnoreSubStream);
+ pInt->bIgnoreSubStream = HXNULL;
+ }
+ /* Clean up any current frame */
+ rv_depacki_cleanup_frame(pInt, &pInt->pCurFrame);
+ /* Null everything out */
+ memset(pInt, 0, sizeof(rv_depack_internal));
+ /* Free the rm_parser_internal struct memory */
+ fpFree(pUserMem, pInt);
+ /* NULL out the pointer */
+ *ppDepack = HXNULL;
+ }
+ }
+}
+
diff --git a/audio_codec/libraac/rv_depack_internal.c b/audio_codec/libraac/rv_depack_internal.c
new file mode 100644
index 0000000..d351c8d
--- a/dev/null
+++ b/audio_codec/libraac/rv_depack_internal.c
@@ -0,0 +1,1071 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_depack_internal.c,v 1.1.1.1.2.1 2005/05/04 18:21:20 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <stdio.h>
+#include <string.h>
+#include <memory.h>
+//#include "includes.h"
+#include "../include/helix_types.h"
+#include "../include/helix_result.h"
+#include "../include/pack_utils.h"
+#include "../include/string_utils.h"
+#include "../include/memory_utils.h"
+#include "../include/packet_defines.h"
+#include "../include/codec_defines.h"
+#include "../include/stream_hdr_structs.h"
+#include "../include/stream_hdr_utils.h"
+#include "rv_depack_internal.h"
+
+#define RM_MAX_UINT14 0x00003FFF
+#define RM_MAX_UINT30 0x3FFFFFFF
+#define MAX_INTERNAL_TIMESTAMP_DELTA 60000
+
+void* rv_depacki_malloc(rv_depack_internal* pInt, UINT32 ulSize)
+{
+ void* pRet = HXNULL;
+
+ if (pInt && pInt->fpMalloc) {
+ pRet = pInt->fpMalloc(pInt->pUserMem, ulSize);
+ }
+
+ return pRet;
+}
+
+void rv_depacki_free(rv_depack_internal* pInt, void* pMem)
+{
+ if (pInt && pInt->fpFree) {
+ pInt->fpFree(pInt->pUserMem, pMem);
+ }
+}
+
+HX_RESULT rv_depacki_init(rv_depack_internal* pInt, rm_stream_header* hdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && hdr) {
+ /* Initialize local variables */
+ UINT32 ulTmp = 0;
+ BYTE* pTmp = HXNULL;
+ UINT32 i = 0;
+ /* Check if we have a "HasRelativeTS" property - OK if we don't */
+ if (HX_SUCCEEDED(rm_stream_get_property_int(hdr, "HasRelativeTS", &ulTmp))) {
+ pInt->bHasRelativeTimeStamps = (ulTmp ? TRUE : FALSE);
+ }
+ /* Check if we have a "ZeroTimeOffset" property - OK if we don't */
+ if (HX_SUCCEEDED(rm_stream_get_property_int(hdr, "ZeroTimeOffset", &ulTmp))) {
+ pInt->ulZeroTimeOffset = ulTmp;
+ }
+ /* Check if we have a "RMFF 1.0 Flags" property */
+ retVal = rm_stream_get_property_buf(hdr, "RMFF 1.0 Flags", &pTmp, &ulTmp);
+ if (retVal == HXR_OK) {
+ /* Unpack the rule2Flag map */
+ rv_depacki_unpack_rule_map(pInt, &pInt->rule2Flag, &pTmp, &ulTmp);
+ /* Check if we have an "OpaqueData" property */
+ retVal = rm_stream_get_property_buf(hdr, "OpaqueData", &pTmp, &ulTmp);
+ if (retVal == HXR_OK) {
+ /* Unpack the opaque data */
+ retVal = rv_depacki_unpack_opaque_data(pInt, pTmp, ulTmp);
+ if (retVal == HXR_OK) {
+ /*
+ * Now that we've parsed all the headers, we need
+ * to see if there are any that need to be ignored.
+ * To do this, we parse the rules in the ASMRuleBook,
+ * and any rules that have "$OldPNMPlayer" as an expression,
+ * we will ignore.
+ */
+ retVal = rv_depacki_check_rule_book(pInt, hdr);
+ if (retVal == HXR_OK) {
+ /*
+ * Now select the first non-ignored substream. If
+ * we are not surestream, this of course will be zero.
+ */
+ pInt->ulActiveSubStream = 0;
+ if (pInt->bStreamSwitchable) {
+ for (i = 0; i < pInt->multiStreamHdr.ulNumSubStreams; i++) {
+ if (!pInt->bIgnoreSubStream[i]) {
+ pInt->ulActiveSubStream = i;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_unpack_rule_map(rv_depack_internal* pInt,
+ rm_rule_map* pMap,
+ BYTE** ppBuf,
+ UINT32* pulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ retVal = rm_unpack_rule_map(ppBuf, pulLen,
+ pInt->fpMalloc,
+ pInt->fpFree,
+ pInt->pUserMem,
+ pMap);
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_unpack_multistream_hdr(rv_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ retVal = rm_unpack_multistream_hdr(ppBuf, pulLen,
+ pInt->fpMalloc,
+ pInt->fpFree,
+ pInt->pUserMem,
+ &pInt->multiStreamHdr);
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_unpack_opaque_data(rv_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pBuf && ulLen >= 4) {
+ /* Initialize local variables */
+ UINT32 ulSize = 0;
+ UINT32 ulID = 0;
+ UINT32 i = 0;
+ /*
+ * If the first four bytes are MLTI, then we
+ * know the opaque data contains a multistream header
+ * followed by several normal headers. So first we
+ * need to check the first four bytes.
+ */
+ ulID = rm_unpack32(&pBuf, &ulLen);
+ /* Now back up 4 bytes */
+ pBuf -= 4;
+ ulLen += 4;
+ /* Is this a multistream header? */
+ if (ulID == RM_MULTIHEADER_OBJECT) {
+ /* Unpack the multistream header */
+ retVal = rv_depacki_unpack_multistream_hdr(pInt, &pBuf, &ulLen);
+ if (retVal == HXR_OK) {
+ pInt->bStreamSwitchable = TRUE;
+ }
+ } else {
+ /* Single-rate stream */
+ pInt->multiStreamHdr.ulNumSubStreams = 1;
+ /* Clear the stream switchable flag */
+ pInt->bStreamSwitchable = FALSE;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ /* Clean up any existing substream header array */
+ rv_depacki_cleanup_format_info_array(pInt);
+ /* Set the return value */
+ retVal = HXR_FAIL;
+ /* Allocate space for substream header array */
+ ulSize = pInt->multiStreamHdr.ulNumSubStreams * sizeof(rv_format_info);
+ pInt->pSubStreamHdr = (rv_format_info*) rv_depacki_malloc(pInt, ulSize);
+ if (pInt->pSubStreamHdr) {
+ /* NULL out the memory */
+ memset(pInt->pSubStreamHdr, 0, ulSize);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Loop through and unpack each substream header */
+ for (i = 0; i < pInt->multiStreamHdr.ulNumSubStreams && retVal == HXR_OK; i++) {
+ /* Is this a multiheader? */
+ if (pInt->bStreamSwitchable) {
+ /*
+ * If this is a multistream header, then there
+ * is a 4-byte length in front of every substream header
+ */
+ if (ulLen >= 4) {
+ ulSize = rm_unpack32(&pBuf, &ulLen);
+ } else {
+ retVal = HXR_FAIL;
+ }
+ }
+ /* Now unpack an substream header */
+ retVal = rv_depacki_unpack_format_info(pInt,
+ &pInt->pSubStreamHdr[i],
+ &pBuf, &ulLen);
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rv_depacki_cleanup_format_info(rv_depack_internal* pInt,
+ rv_format_info* pInfo)
+{
+ if (pInt && pInfo && pInfo->pOpaqueData) {
+ rv_depacki_free(pInt, pInfo->pOpaqueData);
+ pInfo->pOpaqueData = HXNULL;
+ pInfo->ulOpaqueDataSize = 0;
+ }
+}
+
+void rv_depacki_cleanup_format_info_array(rv_depack_internal* pInt)
+{
+ if (pInt && pInt->pSubStreamHdr) {
+ /* Clean up each individual rv_format_info */
+ UINT32 i = 0;
+ for (i = 0; i < pInt->multiStreamHdr.ulNumSubStreams; i++) {
+ rv_depacki_cleanup_format_info(pInt, &pInt->pSubStreamHdr[i]);
+ }
+ /* Clean up the array */
+ rv_depacki_free(pInt, pInt->pSubStreamHdr);
+ pInt->pSubStreamHdr = HXNULL;
+ }
+}
+
+HX_RESULT rv_depacki_unpack_format_info(rv_depack_internal* pInt,
+ rv_format_info* pInfo,
+ BYTE** ppBuf,
+ UINT32* pulLen)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInfo && ppBuf && *ppBuf && pulLen && *pulLen >= 26) {
+ /* Clean up any existing opaque data */
+ rv_depacki_cleanup_format_info(pInt, pInfo);
+ /* Unpack the format info struct */
+ pInfo->ulLength = rm_unpack32(ppBuf, pulLen);
+ pInfo->ulMOFTag = rm_unpack32(ppBuf, pulLen);
+ pInfo->ulSubMOFTag = rm_unpack32(ppBuf, pulLen);
+ pInfo->usWidth = rm_unpack16(ppBuf, pulLen);
+ pInfo->usHeight = rm_unpack16(ppBuf, pulLen);
+ pInfo->usBitCount = rm_unpack16(ppBuf, pulLen);
+ pInfo->usPadWidth = rm_unpack16(ppBuf, pulLen);
+ pInfo->usPadHeight = rm_unpack16(ppBuf, pulLen);
+ pInfo->ufFramesPerSecond = rm_unpack32(ppBuf, pulLen);
+ /* Fix up the subMOF tag */
+ if (pInfo->ulSubMOFTag == HX_RVTRVIDEO_ID) {
+ pInfo->ulSubMOFTag = HX_RV20VIDEO_ID;
+ } else if (pInfo->ulSubMOFTag == HX_RVTR_RV30_ID) {
+ pInfo->ulSubMOFTag = HX_RV30VIDEO_ID;
+ }
+ /* Compute the size of the opaque data */
+ pInfo->ulOpaqueDataSize = pInfo->ulLength - 26;
+ /* Make sure we have enough left in the parsing buffer */
+ if (*pulLen >= pInfo->ulOpaqueDataSize) {
+ /* Allocate a buffer of this size */
+ pInfo->pOpaqueData = (BYTE*) rv_depacki_malloc(pInt, pInfo->ulOpaqueDataSize);
+ if (pInfo->pOpaqueData) {
+ /* Copy the buffer */
+ memcpy(pInfo->pOpaqueData, *ppBuf, pInfo->ulOpaqueDataSize);
+ /* Advance the buffer */
+ *ppBuf += pInfo->ulOpaqueDataSize;
+ *pulLen -= pInfo->ulOpaqueDataSize;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_check_rule_book(rv_depack_internal* pInt, rm_stream_header* hdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && hdr) {
+ UINT32 ulSize = 0;
+ HXBOOL* pTmp = HXNULL;
+ char* pszRuleBook = HXNULL;
+ char* pStr = HXNULL;
+ char* pStrLimit = HXNULL;
+ UINT32 ulRule = 0;
+ UINT32 ulSubStream = 0;
+ const char* pszPNMStr = "$OldPNMPlayer";
+ UINT32 ulPNMStrLen = strlen(pszPNMStr);
+ UINT32 ulNumRules = pInt->multiStreamHdr.rule2SubStream.ulNumRules;
+ UINT32 ulNumSubStreams = pInt->multiStreamHdr.ulNumSubStreams;
+ /* Is this SureStream? */
+ if (pInt->bStreamSwitchable) {
+ /* Get the ASM Rule book */
+ retVal = rm_stream_get_property_str(hdr, "ASMRuleBook", &pszRuleBook);
+ if (retVal == HXR_OK) {
+ /* Allocate space for the ignore header flags */
+ ulSize = ulNumSubStreams * sizeof(HXBOOL);
+ pInt->bIgnoreSubStream = (HXBOOL*) rv_depacki_malloc(pInt, ulSize);
+ if (pInt->bIgnoreSubStream) {
+ /* NULL out the memory */
+ memset(pInt->bIgnoreSubStream, 0, ulSize);
+ /* Allocate space for temporary boolean array */
+ ulSize = ulNumRules * sizeof(HXBOOL);
+ pTmp = (HXBOOL*) rv_depacki_malloc(pInt, ulSize);
+ if (pTmp) {
+ /* NULL out the array */
+ memset(pTmp, 0, ulSize);
+ /* Parse the string */
+ pStr = pszRuleBook;
+ pStrLimit = pszRuleBook + strlen(pszRuleBook);
+ ulRule = 0;
+ while (pStr < pStrLimit && *pStr) {
+ while (pStr < pStrLimit && *pStr != ';') {
+ /* ignore quoted strings */
+ if (*pStr == '"') {
+ /* step past open quote */
+ pStr++;
+ /* ignore the string */
+ while (pStr < pStrLimit && *pStr != '"') {
+ pStr++;
+ }
+ /* step past end quote occurs at bottom of while !';' loop. */
+ }
+
+ if (pStr + ulPNMStrLen < pStrLimit && *pStr == '$') {
+ /* check to see if we have a $OldPNMPlayer variable */
+ if (!strncasecmp(pszPNMStr, pStr, ulPNMStrLen)) {
+ pStr += ulPNMStrLen;
+ pTmp[ulRule] = TRUE;
+ }
+ }
+ pStr++;
+ }
+ /* step past the ';' */
+ pStr++;
+ /* next rule */
+ ulRule++;
+ }
+ /*
+ * Now if pTmp[i] == TRUE, then we should ignore the
+ * substreams which correspond to rule i
+ */
+ for (ulRule = 0; ulRule < ulNumRules; ulRule++) {
+ ulSubStream = rv_depacki_rule_to_substream(pInt, ulRule);
+ if (ulSubStream < ulNumSubStreams) {
+ pInt->bIgnoreSubStream[ulSubStream] = pTmp[ulRule];
+ }
+ }
+ }
+ }
+ }
+ } else {
+ /* Not an error */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_copy_format_info(rv_depack_internal* pInt,
+ rv_format_info* pSrc,
+ rv_format_info* pDst)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pSrc && pDst) {
+ /* Clean up any existing format info */
+ rv_depacki_cleanup_format_info(pInt, pDst);
+ /* Copy the members */
+ pDst->ulLength = pSrc->ulLength;
+ pDst->ulMOFTag = pSrc->ulMOFTag;
+ pDst->ulSubMOFTag = pSrc->ulSubMOFTag;
+ pDst->usWidth = pSrc->usWidth;
+ pDst->usHeight = pSrc->usHeight;
+ pDst->usBitCount = pSrc->usBitCount;
+ pDst->usPadWidth = pSrc->usPadWidth;
+ pDst->usPadHeight = pSrc->usPadHeight;
+ pDst->ufFramesPerSecond = pSrc->ufFramesPerSecond;
+ pDst->ulOpaqueDataSize = pSrc->ulOpaqueDataSize;
+ /* Copy the opaque data buffer */
+ pDst->pOpaqueData = copy_buffer(pInt->pUserMem,
+ pInt->fpMalloc,
+ pSrc->pOpaqueData,
+ pSrc->ulOpaqueDataSize);
+ if (pDst->pOpaqueData) {
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_add_packet(rv_depack_internal* pInt,
+ rm_packet* pPacket)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pPacket) {
+ /* Init local variables */
+ BYTE* pBuf = pPacket->pData;
+ UINT32 ulLen = (UINT32) pPacket->usDataLen;
+ UINT32 ulSubStream = 0;
+ rv_frame_hdr hdr;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Make sure we are not ignoring this substream */
+ ulSubStream = rv_depacki_rule_to_substream(pInt, pPacket->ucASMRule);
+ if (!pInt->bStreamSwitchable ||
+ !pInt->bIgnoreSubStream[ulSubStream]) {
+ /* Loop through the packet buffer */
+ while (ulLen && retVal == HXR_OK) {
+ /* Parse the current point in the packet buffer */
+ retVal = rv_depacki_parse_frame_header(pInt, &pBuf, &ulLen, pPacket, &hdr);
+ if (retVal == HXR_OK) {
+ /* Switch based on frame header type */
+ switch (hdr.eType) {
+ case RVFrameTypePartial:
+ case RVFrameTypeLastPartial:
+ retVal = rv_depacki_handle_partial(pInt, &pBuf, &ulLen, pPacket, &hdr);
+ break;
+ case RVFrameTypeMultiple:
+ case RVFrameTypeWhole:
+ retVal = rv_depacki_handle_one_frame(pInt, &pBuf, &ulLen, pPacket, &hdr);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+UINT32 rv_depacki_rule_to_flags(rv_depack_internal* pInt, UINT32 ulRule)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt &&
+ pInt->rule2Flag.pulMap &&
+ ulRule < pInt->rule2Flag.ulNumRules) {
+ ulRet = pInt->rule2Flag.pulMap[ulRule];
+ }
+
+ return ulRet;
+}
+
+UINT32 rv_depacki_rule_to_substream(rv_depack_internal* pInt, UINT32 ulRule)
+{
+ UINT32 ulRet = 0;
+
+ if (pInt &&
+ pInt->multiStreamHdr.rule2SubStream.pulMap &&
+ ulRule < pInt->multiStreamHdr.rule2SubStream.ulNumRules) {
+ ulRet = pInt->multiStreamHdr.rule2SubStream.pulMap[ulRule];
+ }
+
+ return ulRet;
+}
+
+HX_RESULT rv_depacki_parse_frame_header(rv_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_packet* pPacket,
+ rv_frame_hdr* pFrameHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && ppBuf && pulLen && pFrameHdr && *pulLen >= 2 &&
+ *ppBuf >= pPacket->pData &&
+ *ppBuf < pPacket->pData + pPacket->usDataLen) {
+ /* Initialize local variables */
+ UINT32 ulTmp = 0;
+ HXBOOL bTmp = FALSE;
+ UINT32 ulOrigPacketTimeStamp = 0;
+ UINT32 ulClippedPacketTS = 0;
+ UINT32 ulDelta = 0;
+ BYTE* pBufAtStart = *ppBuf;
+ /* Set the offset of the header in the packet */
+ pFrameHdr->ulHeaderOffset = pBufAtStart - pPacket->pData;
+ /* Parse the RVFrameType */
+ pFrameHdr->eType = (RVFrameType)((pBufAtStart[0] & 0xC0) >> 6);
+ /* Switch based on frame type */
+ switch (pFrameHdr->eType) {
+ case RVFrameTypePartial:
+ case RVFrameTypeLastPartial:
+ /* Unpack the bit field */
+ ulTmp = rm_unpack16(ppBuf, pulLen);
+ pFrameHdr->ulNumPackets = ((ulTmp & 0x00003F80) >> 7);
+ pFrameHdr->ulPacketNum = (ulTmp & 0x0000007F);
+ /* Read the frame size */
+ retVal = rv_depacki_read_14_or_30(ppBuf, pulLen,
+ &pFrameHdr->bBrokenUpByUs,
+ &pFrameHdr->ulFrameSize);
+ if (retVal == HXR_OK) {
+ /* Read the partial size or offset */
+ ulTmp = 0;
+ retVal = rv_depacki_read_14_or_30(ppBuf, pulLen, &bTmp, &ulTmp);
+ if (retVal == HXR_OK) {
+ /* Make sure we have one byte */
+ if (*pulLen >= 1) {
+ /* Get the sequence number */
+ pFrameHdr->ulSeqNum = rm_unpack8(ppBuf, pulLen);
+ /* Assign the timestamp */
+ pFrameHdr->ulTimestamp = pPacket->ulTime;
+ /* Compute the header size */
+ pFrameHdr->ulHeaderSize = *ppBuf - pBufAtStart;
+ /* Assign the partial frame size and the partial frame offset. */
+ if (pFrameHdr->eType == RVFrameTypePartial) {
+ /*
+ * For partial frames the partial_size_or_offset
+ * member contains the offset into the frame. The size
+ * of the partial frame is just the amount of data
+ * in the packet minus the header size.
+ */
+ pFrameHdr->ulPartialFrameOffset = ulTmp;
+ pFrameHdr->ulPartialFrameSize = ((UINT32) pPacket->usDataLen) -
+ pFrameHdr->ulHeaderSize;
+ } else {
+ /*
+ * For last-partial frames, there could be other frame
+ * data after this, so the partial_size_or_offset field
+ * contains the partial frame size, not offset. We then
+ * compute the offset by subtracting the overall frame
+ * size from the partial frame size.
+ */
+ pFrameHdr->ulPartialFrameSize = ulTmp;
+ pFrameHdr->ulPartialFrameOffset = pFrameHdr->ulFrameSize - ulTmp;
+ }
+ } else {
+ retVal = HXR_FAIL;
+ }
+ }
+ }
+ break;
+ case RVFrameTypeWhole:
+ /* Skip the one-byte frame type */
+ rm_unpack8(ppBuf, pulLen);
+ /* Unpack the sequence number */
+ pFrameHdr->ulSeqNum = rm_unpack8(ppBuf, pulLen);
+ /* Compute the header size */
+ pFrameHdr->ulHeaderSize = *ppBuf - pBufAtStart;
+ /* Assign the frame header members */
+ pFrameHdr->ulNumPackets = 1;
+ pFrameHdr->ulPacketNum = 1;
+ pFrameHdr->ulFrameSize = ((UINT32) pPacket->usDataLen) -
+ pFrameHdr->ulHeaderSize;
+ pFrameHdr->ulTimestamp = pPacket->ulTime;
+ pFrameHdr->bBrokenUpByUs = FALSE;
+ pFrameHdr->ulPartialFrameOffset = 0;
+ pFrameHdr->ulPartialFrameSize = 0;
+ /* Clear return value */
+ retVal = HXR_OK;
+ break;
+ case RVFrameTypeMultiple:
+ /*
+ * For multiple frames, we still set ulNumPackets
+ * and ulPacketNum to 1, even though we know
+ * there are multiple packets.
+ */
+ pFrameHdr->ulNumPackets = 1;
+ pFrameHdr->ulPacketNum = 1;
+ /* Skip the frame type */
+ rm_unpack8(ppBuf, pulLen);
+ /* Unpack the frame size */
+ retVal = rv_depacki_read_14_or_30(ppBuf, pulLen, &bTmp,
+ &pFrameHdr->ulFrameSize);
+ if (retVal == HXR_OK) {
+ /* For multiple frames, there is no partial size or offset */
+ pFrameHdr->ulPartialFrameOffset = 0;
+ pFrameHdr->ulPartialFrameSize = 0;
+ /* Unpack the timestamp */
+ retVal = rv_depacki_read_14_or_30(ppBuf, pulLen, &bTmp,
+ &pFrameHdr->ulTimestamp);
+ if (retVal == HXR_OK) {
+ /* Does this stream have relative timestamps? */
+ if (pInt->bHasRelativeTimeStamps) {
+ /*
+ * Yes, we have relative timestamps so offset
+ * the timestamp in the frame header by the
+ * packet timestamp.
+ */
+ pFrameHdr->ulTimestamp += pPacket->ulTime;
+ } else {
+ /* No relative timestamps */
+ ulOrigPacketTimeStamp = pPacket->ulTime + pInt->ulZeroTimeOffset;
+ /*
+ * Because of a bug in the original Write14or30() which didn't mask
+ * the high bytes of the timestamp before |ing them with the flags,
+ * it's possible to read frame headers that are screwed up. If the
+ * application using this class sets the timestamp of the network packet
+ * before unpacking the header, we can determine if this header is
+ * screwed up and fix it.
+ */
+ /*
+ * If the time stamp returned is less than the packet timestamp
+ * something is screwed up. If the packet timestamp is > 14 bits,
+ * the frame timestamp is < the packet timestamp and the packet
+ * timestamp is < 14 bits then the Write14or30 bug described above
+ * may have occured. It's possible for rollover to occur and trigger
+ * this so we check for that too. If the bug occured, we want to read 30 bits.
+ */
+ if (ulOrigPacketTimeStamp > RM_MAX_UINT14 &&
+ ulOrigPacketTimeStamp > pFrameHdr->ulTimestamp &&
+ pFrameHdr->ulTimestamp < RM_MAX_UINT14 &&
+ /*
+ * check for rollover. If we assume ulOrigPacketTimeStamp is from before
+ * rollover and m_ulTimeStamp is from after, the left hand expression below
+ * should be a small number because m_ulPacketTimeSamp will be close to
+ * MAX_UINT30 and m_ulTimeStamp will be close to 0. I chose 60 seconds
+ * since two frames 60 seconds appart shouldn't be in the same packet
+ * due to latency considerations in the encoder. JEFFA 4/28/99
+ */
+ !(((RM_MAX_UINT30 - ulOrigPacketTimeStamp) + pFrameHdr->ulTimestamp) <= 60000UL)) {
+ /* We should have read 14 bits, so back up 2 bytes */
+ *ppBuf -= 2;
+ *pulLen += 2;
+ /* Now read 32 bits instead */
+ pFrameHdr->ulTimestamp = rm_unpack32(ppBuf, pulLen);
+ }
+
+ /* Clip the timestamp at 30 bits */
+ ulClippedPacketTS = (ulOrigPacketTimeStamp & RM_MAX_UINT30);
+ /*
+ * Much code in the system assumes full 32 bit typestamps; reconstruct
+ * them here. We assume child timestamps are no more than 2^30 - 1 away
+ */
+ ulDelta = (pFrameHdr->ulTimestamp >= ulClippedPacketTS ?
+ pFrameHdr->ulTimestamp - ulClippedPacketTS :
+ RM_MAX_UINT30 - ulClippedPacketTS + pFrameHdr->ulTimestamp);
+ pFrameHdr->ulTimestamp = ulOrigPacketTimeStamp + ulDelta;
+ /* If we have a zero time offset, we need to offset this timestamp */
+ pFrameHdr->ulTimestamp -= pInt->ulZeroTimeOffset;
+
+ /*
+ * Ensure that we have not caused the timestamp to fall behind
+ * the packet timestamp when we have subtracted zero time offset
+ */
+ if (pInt->ulZeroTimeOffset &&
+ (((INT32) pFrameHdr->ulTimestamp) - ((INT32) pPacket->ulTime) < 0)) {
+ pFrameHdr->ulTimestamp = pPacket->ulTime;
+ }
+
+ /*
+ * If older rmffplin is serving this slta stream and internal
+ * frame timestamp is much larger than pkt timestamp, then
+ * we are dealing with un-translated-for-slta-live internal
+ * frame timestamps (the above calculation w/ ulDelta made
+ * super-small timestamps into super-large ones). Here, we
+ * adjust and make the internal timestamp equal to the pkt timestamp
+ */
+ if (pFrameHdr->ulTimestamp - pPacket->ulTime > MAX_INTERNAL_TIMESTAMP_DELTA) {
+ pFrameHdr->ulTimestamp = pPacket->ulTime;
+ }
+ }
+ /* Read the sequence number */
+ pFrameHdr->ulSeqNum = rm_unpack8(ppBuf, pulLen);
+ }
+ }
+ break;
+ }
+ if (retVal == HXR_OK) {
+ /* Compute the number of bytes in the frame header we just parsed. */
+ pFrameHdr->ulHeaderSize = *ppBuf - pBufAtStart;
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_read_14_or_30(BYTE** ppBuf,
+ UINT32* pulLen,
+ HXBOOL* pbHiBit,
+ UINT32* pulValue)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (ppBuf && pulLen && pbHiBit && pulValue && *ppBuf && *pulLen >= 2) {
+ /* Init local variables */
+ UINT32 ulTmp = (*ppBuf)[0];
+ /* Assign the high bit */
+ *pbHiBit = ((ulTmp & 0x80) ? TRUE : FALSE);
+ /*
+ * Check the length bit. If it's 1, then
+ * this is a 14-bit value. If it's 0, then
+ * this is a 30-bit value.
+ */
+ if (ulTmp & 0x40) {
+ /*
+ * This is a 14-bit value, so unpack 16 bits.
+ * We don't need to check the buffer size, since
+ * we already checked for a minimum of 2 bytes above.
+ */
+ ulTmp = rm_unpack16(ppBuf, pulLen);
+ /* Mask out the upper two bits */
+ *pulValue = (ulTmp & 0x00003FFF);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ } else {
+ /* This is a 30-bit value, so check size */
+ if (*pulLen >= 4) {
+ /* Unpack 32 bits */
+ ulTmp = rm_unpack32(ppBuf, pulLen);
+ /* Mask out the upper 2 bits */
+ *pulValue = (ulTmp & 0x3FFFFFFF);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_handle_partial(rv_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_packet* pPacket,
+ rv_frame_hdr* pFrameHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && ppBuf && pulLen && pPacket && pFrameHdr && *ppBuf) {
+ /* Init local variables */
+ UINT32 i = 0;
+ UINT32 ulOffset = 0;
+ HXBOOL bAllThere = FALSE;
+ /* Clear the reutrn value */
+ retVal = HXR_OK;
+ /*
+ * If we have a current frame and its timestamp
+ * is different from the packet timestamp,
+ * then we will send it.
+ */
+ if (pInt->pCurFrame &&
+ pInt->pCurFrame->ulTimestamp != pPacket->ulTime) {
+ /* Send the current frame */
+ retVal = rv_depacki_send_current_frame(pInt);
+ }
+ /* Do we have a current frame? */
+ if (retVal == HXR_OK && !pInt->pCurFrame) {
+ /* We don't have a current frame, so create one */
+ retVal = rv_depacki_create_frame(pInt, pPacket, pFrameHdr,
+ &pInt->pCurFrame);
+ }
+ if (retVal == HXR_OK) {
+ /* Set the return value */
+ retVal = HXR_FAIL;
+ /* Sanity check */
+ ulOffset = pFrameHdr->ulPartialFrameOffset + pFrameHdr->ulPartialFrameSize;
+ if (ulOffset <= pInt->pCurFrame->ulDataLen &&
+ *pulLen >= pFrameHdr->ulPartialFrameSize &&
+ pFrameHdr->ulPacketNum - 1 < pInt->pCurFrame->ulNumSegments) {
+ /* Copy the data into the frame data buffer */
+ memcpy(pInt->pCurFrame->pData + pFrameHdr->ulPartialFrameOffset,
+ *ppBuf,
+ pFrameHdr->ulPartialFrameSize);
+ /* The segment indices in the frame header are 1-based */
+ i = pFrameHdr->ulPacketNum - 1;
+ /* Update the segment information */
+ pInt->pCurFrame->pSegment[i].bIsValid = TRUE;
+ pInt->pCurFrame->pSegment[i].ulOffset = pFrameHdr->ulPartialFrameOffset;
+ /*
+ * Set the offset for the segment after this one and all other
+ * segments until we find a valid one or we run out of segments.
+ * This allows a codec to know where missing data would go for
+ * single loss. For multiple loss in a row the offset is set
+ * to the same offset since the size of the missing segments
+ * isn't known.
+ */
+ for (i = pFrameHdr->ulPacketNum;
+ i < pInt->pCurFrame->ulNumSegments &&
+ !pInt->pCurFrame->pSegment[i].bIsValid;
+ i++) {
+ pInt->pCurFrame->pSegment[i].ulOffset = ulOffset;
+ }
+ /* Check to see if all segments are present */
+ bAllThere = TRUE;
+ for (i = 0; i < pInt->pCurFrame->ulNumSegments && bAllThere; i++) {
+ bAllThere = pInt->pCurFrame->pSegment[i].bIsValid;
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Are all segments present? */
+ if (bAllThere) {
+ /* We've got the entire packet, so send it */
+ retVal = rv_depacki_send_current_frame(pInt);
+ }
+ if (retVal == HXR_OK) {
+ /* Advance the buffer */
+ *ppBuf += pFrameHdr->ulPartialFrameSize;
+ *pulLen -= pFrameHdr->ulPartialFrameSize;
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_handle_one_frame(rv_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_packet* pPacket,
+ rv_frame_hdr* pFrameHdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && ppBuf && pulLen && pPacket && pFrameHdr && *ppBuf) {
+ /* If we have a current frame, send it */
+ retVal = rv_depacki_send_current_frame(pInt);
+ if (retVal == HXR_OK) {
+ /* Create a current frame */
+ retVal = rv_depacki_create_frame(pInt, pPacket, pFrameHdr,
+ &pInt->pCurFrame);
+ if (retVal == HXR_OK) {
+ /* Set the return value */
+ retVal = HXR_FAIL;
+ /* Sanity check on parsed values */
+ if (*pulLen >= pInt->pCurFrame->ulDataLen) {
+ /* Copy the data */
+ memcpy(pInt->pCurFrame->pData, *ppBuf,
+ pInt->pCurFrame->ulDataLen);
+ /* Set the one and only segment */
+ pInt->pCurFrame->pSegment[0].bIsValid = TRUE;
+ pInt->pCurFrame->pSegment[0].ulOffset = 0;
+ /* Send the frame we just created */
+ retVal = rv_depacki_send_current_frame(pInt);
+ if (retVal == HXR_OK) {
+ /* Advance the buffer */
+ *ppBuf += pFrameHdr->ulFrameSize;
+ *pulLen -= pFrameHdr->ulFrameSize;
+ }
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_send_current_frame(rv_depack_internal* pInt)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pInt->fpAvail) {
+ /* Init local variables */
+ HXBOOL bDoSend = TRUE;
+ UINT32 i = 0;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ /* Do we have a current frame? Not an error if we don't. */
+ if (pInt->pCurFrame) {
+ /* Was the packet broken up by us? */
+ if (pInt->bBrokenUpByUs) {
+ /*
+ * Make sure all the segments are there;
+ * otherwise, don't send it. After leaving
+ * the for loop below, bDoSend will only
+ * be TRUE if all the segments are valid.
+ */
+ for (i = 0; i < pInt->pCurFrame->ulNumSegments && bDoSend; i++) {
+ bDoSend = pInt->pCurFrame->pSegment[i].bIsValid;
+ }
+ /* Are we going to send this frame? */
+ if (bDoSend && pInt->pCurFrame->ulNumSegments) {
+ /* Collapse all the segment info into 1 segment */
+ pInt->pCurFrame->pSegment[0].bIsValid = TRUE;
+ pInt->pCurFrame->pSegment[0].ulOffset = 0;
+ /* Reset the number of segments to 1 */
+ pInt->pCurFrame->ulNumSegments = 1;
+ }
+ }
+ /* Are we going to send this frame? */
+ if (bDoSend) {
+ /* Call the frame available function pointer */
+ retVal = pInt->fpAvail(pInt->pAvail,
+ pInt->ulActiveSubStream,
+ pInt->pCurFrame);
+
+ } else {
+ /* Free the frame */
+ rv_depacki_cleanup_frame(pInt, &pInt->pCurFrame);
+ }
+ /* NULL out the pointer */
+ pInt->pCurFrame = HXNULL;
+ }
+ }
+
+ return retVal;
+}
+
+void rv_depacki_cleanup_frame(rv_depack_internal* pInt,
+ rv_frame** ppFrame)
+{
+ if (pInt && ppFrame && *ppFrame) {
+ /* Free the encoded frame buffer */
+ if ((*ppFrame)->pData) {
+ rv_depacki_free(pInt, (*ppFrame)->pData);
+ (*ppFrame)->pData = HXNULL;
+ }
+ /* Free the segment array */
+ if ((*ppFrame)->pSegment) {
+ rv_depacki_free(pInt, (*ppFrame)->pSegment);
+ (*ppFrame)->pSegment = HXNULL;
+ }
+ /* NULL out the frame */
+ memset(*ppFrame, 0, sizeof(rv_frame));
+ /* Delete the space for the frame struct itself */
+ rv_depacki_free(pInt, *ppFrame);
+ /* NULL out the pointer */
+ *ppFrame = HXNULL;
+ }
+}
+
+HX_RESULT rv_depacki_create_frame(rv_depack_internal* pInt,
+ rm_packet* pPacket,
+ rv_frame_hdr* pFrameHdr,
+ rv_frame** ppFrame)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt && pPacket && pFrameHdr && ppFrame &&
+ pFrameHdr->ulFrameSize && pFrameHdr->ulNumPackets) {
+ /* Init local variables */
+ rv_frame* pFrame = HXNULL;
+ UINT32 ulSize = 0;
+ UINT32 ulSeqNum = 0;
+ UINT32 ulFlags = 0;
+ /* Clean out any existing frame */
+ rv_depacki_cleanup_frame(pInt, ppFrame);
+ /* Allocate space rv_frame struct */
+ pFrame = rv_depacki_malloc(pInt, sizeof(rv_frame));
+ if (pFrame) {
+ /* NULL out the memory */
+ memset(pFrame, 0, sizeof(rv_frame));
+ /* Allocate enough space for the data */
+ pFrame->pData = rv_depacki_malloc(pInt, pFrameHdr->ulFrameSize);
+ if (pFrame->pData) {
+ /* NULL out the memory */
+ memset(pFrame->pData, 0, pFrameHdr->ulFrameSize);
+ /* Assign the data size */
+ pFrame->ulDataLen = pFrameHdr->ulFrameSize;
+ /* Allocate space for segment array */
+ ulSize = pFrameHdr->ulNumPackets * sizeof(rv_segment);
+ pFrame->pSegment = rv_depacki_malloc(pInt, ulSize);
+ if (pFrame->pSegment) {
+ /*
+ * NULL out the memory. This effectively sets
+ * all the bIsValid flags to FALSE and ulOffset
+ * values to zero.
+ */
+ memset(pFrame->pSegment, 0, ulSize);
+ /* Assign the rest of the members of the frame struct */
+ pFrame->ulNumSegments = pFrameHdr->ulNumPackets;
+ pFrame->ulTimestamp = pFrameHdr->ulTimestamp;
+ pFrame->bLastPacket = FALSE;
+ /* Look up the flags from the packet ASM rule */
+ ulFlags = rv_depacki_rule_to_flags(pInt, pPacket->ucASMRule);
+ /*
+ * If this is a packet with only multiple frames and the
+ * packet is a keyframe packet, then we only want the FIRST frame
+ * to be labelled as a keyframe. If this packet has a
+ * last-partial frame followed by multiple frames, then
+ * we don't want ANY of the multiple frames to be labelled
+ * as a keyframe. To implement this logic, we can do
+ * the following check: if this is a multiple frames header
+ * AND that header did not start at the beginning of the packet,
+ * then we need to clear the keyframe flag.
+ */
+ if (pFrameHdr->eType == RVFrameTypeMultiple &&
+ pFrameHdr->ulHeaderOffset) {
+ ulFlags &= ~HX_KEYFRAME_FLAG;
+ }
+ /* Assign the frame flags */
+ pFrame->usFlags = (UINT16) ulFlags;
+ /* Compute the output sequence number */
+ if (pInt->bCreatedFirstFrame) {
+ /*
+ * The sequence number in the RV frame is only
+ * one byte, so every 256 frames, it rolls over
+ * from 255 back to 0. Check to see if we've
+ * rolled over with this frame.
+ */
+ if (pFrameHdr->ulSeqNum < pInt->ulLastSeqNumIn) {
+ /* We rolled over */
+ pInt->ulLastSeqNumOut += pFrameHdr->ulSeqNum + 256 - pInt->ulLastSeqNumIn;
+ } else {
+ pInt->ulLastSeqNumOut += pFrameHdr->ulSeqNum - pInt->ulLastSeqNumIn;
+ }
+ /* Save the last input sequence number */
+ pInt->ulLastSeqNumIn = pFrameHdr->ulSeqNum;
+ } else {
+ /*
+ * Always start the output sequence number at 0, even
+ * if we lost a few packets and the actual input sequence
+ * number in the RV frame my not be 0.
+ */
+ pInt->ulLastSeqNumOut = 0;
+ pInt->ulLastSeqNumIn = pFrameHdr->ulSeqNum;
+ pInt->bCreatedFirstFrame = TRUE;
+ }
+ /* Assign the sequence number */
+ pFrame->usSequenceNum = (UINT16)(pInt->ulLastSeqNumOut & 0x0000FFFF);
+ /* Assign the broken-up-by-us flag */
+ pInt->bBrokenUpByUs = pFrameHdr->bBrokenUpByUs;
+ /* Assign the out parameter */
+ *ppFrame = pFrame;
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ }
+ }
+ }
+
+ return retVal;
+}
+
+HX_RESULT rv_depacki_seek(rv_depack_internal* pInt, UINT32 ulTime)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (pInt) {
+ /* Clean up any existing partial frame */
+ rv_depacki_cleanup_frame(pInt, &pInt->pCurFrame);
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+
+ return retVal;
+}
+
diff --git a/audio_codec/libraac/rv_depack_internal.h b/audio_codec/libraac/rv_depack_internal.h
new file mode 100644
index 0000000..2ed3d09
--- a/dev/null
+++ b/audio_codec/libraac/rv_depack_internal.h
@@ -0,0 +1,171 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: rv_depack_internal.h,v 1.1.1.1.2.1 2005/05/04 18:21:20 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef RV_DEPACK_INTERNAL_H
+#define RV_DEPACK_INTERNAL_H
+
+#include "../include/helix_types.h"
+#include "../include/helix_result.h"
+#include "../include/rm_memory.h"
+#include "../include/rm_error.h"
+#include "../include/rv_depack.h"
+#include "../include/stream_hdr_structs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* Frame type enum */
+ typedef enum
+ {
+ RVFrameTypePartial,
+ RVFrameTypeWhole,
+ RVFrameTypeLastPartial,
+ RVFrameTypeMultiple
+ }
+ RVFrameType;
+
+ /* Struct which holds frame header info */
+ typedef struct rv_frame_hdr_struct {
+ RVFrameType eType;
+ UINT32 ulPacketNum;
+ UINT32 ulNumPackets;
+ UINT32 ulFrameSize;
+ UINT32 ulPartialFrameSize;
+ UINT32 ulPartialFrameOffset;
+ UINT32 ulTimestamp;
+ UINT32 ulSeqNum;
+ UINT32 ulHeaderSize;
+ UINT32 ulHeaderOffset;
+ HXBOOL bBrokenUpByUs;
+ } rv_frame_hdr;
+
+ /*
+ * Internal rv_depack struct
+ */
+ typedef struct rv_depack_internal_struct {
+ void* pAvail;
+ rv_frame_avail_func_ptr fpAvail;
+ rm_error_func_ptr fpError;
+ void* pUserError;
+ rm_malloc_func_ptr fpMalloc;
+ rm_free_func_ptr fpFree;
+ void* pUserMem;
+ UINT32 ulZeroTimeOffset;
+ HX_BITFIELD bHasRelativeTimeStamps;
+ rm_rule_map rule2Flag;
+ rm_multistream_hdr multiStreamHdr;
+ rv_format_info* pSubStreamHdr;
+ HXBOOL* bIgnoreSubStream;
+ HXBOOL bStreamSwitchable;
+ UINT32 ulActiveSubStream;
+ rv_frame* pCurFrame;
+ HXBOOL bBrokenUpByUs;
+ HXBOOL bCreatedFirstFrame;
+ UINT32 ulLastSeqNumIn;
+ UINT32 ulLastSeqNumOut;
+ } rv_depack_internal;
+
+ /*
+ * Internal rv_depack functions
+ */
+ void* rv_depacki_malloc(rv_depack_internal* pInt, UINT32 ulSize);
+ void rv_depacki_free(rv_depack_internal* pInt, void* pMem);
+ HX_RESULT rv_depacki_init(rv_depack_internal* pInt, rm_stream_header* hdr);
+ HX_RESULT rv_depacki_unpack_rule_map(rv_depack_internal* pInt,
+ rm_rule_map* pMap,
+ BYTE** ppBuf,
+ UINT32* pulLen);
+ HX_RESULT rv_depacki_unpack_multistream_hdr(rv_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen);
+ HX_RESULT rv_depacki_unpack_opaque_data(rv_depack_internal* pInt,
+ BYTE* pBuf,
+ UINT32 ulLen);
+ void rv_depacki_cleanup_format_info(rv_depack_internal* pInt,
+ rv_format_info* pInfo);
+ void rv_depacki_cleanup_format_info_array(rv_depack_internal* pInt);
+ HX_RESULT rv_depacki_unpack_format_info(rv_depack_internal* pInt,
+ rv_format_info* pInfo,
+ BYTE** ppBuf,
+ UINT32* pulLen);
+ HX_RESULT rv_depacki_check_rule_book(rv_depack_internal* pInt,
+ rm_stream_header* hdr);
+ HX_RESULT rv_depacki_copy_format_info(rv_depack_internal* pInt,
+ rv_format_info* pSrc,
+ rv_format_info* pDst);
+ HX_RESULT rv_depacki_add_packet(rv_depack_internal* pInt,
+ rm_packet* pPacket);
+ UINT32 rv_depacki_rule_to_flags(rv_depack_internal* pInt, UINT32 ulRule);
+ UINT32 rv_depacki_rule_to_substream(rv_depack_internal* pInt, UINT32 ulRule);
+ HX_RESULT rv_depacki_parse_frame_header(rv_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_packet* pPacket,
+ rv_frame_hdr* pFrameHdr);
+ HX_RESULT rv_depacki_read_14_or_30(BYTE** ppBuf,
+ UINT32* pulLen,
+ HXBOOL* pbHiBit,
+ UINT32* pulValue);
+ HX_RESULT rv_depacki_handle_partial(rv_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_packet* pPacket,
+ rv_frame_hdr* pFrameHdr);
+ HX_RESULT rv_depacki_handle_one_frame(rv_depack_internal* pInt,
+ BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_packet* pPacket,
+ rv_frame_hdr* pFrameHdr);
+ HX_RESULT rv_depacki_send_current_frame(rv_depack_internal* pInt);
+ void rv_depacki_cleanup_frame(rv_depack_internal* pInt,
+ rv_frame** ppFrame);
+ HX_RESULT rv_depacki_create_frame(rv_depack_internal* pInt,
+ rm_packet* pPacket,
+ rv_frame_hdr* pFrameHdr,
+ rv_frame** ppFrame);
+ void rv_depacki_check_to_clear_keyframe_flag(BYTE* pBuf,
+ UINT32 ulLen,
+ rm_packet* pkt,
+ rv_frame_hdr* hdr);
+ HX_RESULT rv_depacki_seek(rv_depack_internal* pInt, UINT32 ulTime);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef RV_DEPACK_INTERNAL_H */
diff --git a/audio_codec/libraac/sbr.c b/audio_codec/libraac/sbr.c
new file mode 100644
index 0000000..4c9092e
--- a/dev/null
+++ b/audio_codec/libraac/sbr.c
@@ -0,0 +1,431 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbr.c,v 1.4 2008/01/15 21:20:31 ehyche Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbr.c - top level functions for SBR
+ **************************************************************************************/
+
+#if defined(REAL_FORMAT_SDK)
+#include "rm_memory_shim.h"
+#define malloc hx_realformatsdk_malloc
+#define free hx_realformatsdk_free
+#endif /* #if defined(REAL_FORMAT_SDK) */
+
+#include "sbr.h"
+//#include <core/dsp.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+
+/**************************************************************************************
+ * Function: InitSBRState
+ *
+ * Description: initialize PSInfoSBR struct at start of stream or after flush
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: PSInfoSBR struct with proper initial state
+ *
+ * Return: none
+ **************************************************************************************/
+static void InitSBRState(PSInfoSBR *psi)
+{
+ int i, ch;
+ unsigned char *c;
+
+ if (!psi) {
+ return;
+ }
+
+ /* clear SBR state structure */
+ c = (unsigned char *)psi;
+ for (i = 0; i < (int)sizeof(PSInfoSBR); i++) {
+ *c++ = 0;
+ }
+
+ /* initialize non-zero state variables */
+ for (ch = 0; ch < AAC_MAX_NCHANS; ch++) {
+ psi->sbrChan[ch].reset = 1;
+ psi->sbrChan[ch].laPrev = -1;
+ }
+}
+
+/**************************************************************************************
+ * Function: InitSBR
+ *
+ * Description: initialize SBR decoder
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: PSInfoSBR struct to hold SBR state information
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Note: memory allocation for SBR is only done here
+ **************************************************************************************/
+int InitSBR(AACDecInfo *aacDecInfo)
+{
+ PSInfoSBR *psi;
+
+ if (!aacDecInfo) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ /* allocate SBR state structure */
+ psi = (PSInfoSBR *)malloc(sizeof(PSInfoSBR));
+ if (!psi) {
+ return ERR_AAC_SBR_INIT;
+ }
+
+ InitSBRState(psi);
+
+ aacDecInfo->psInfoSBR = psi;
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: FreeSBR
+ *
+ * Description: free SBR decoder
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: none
+ *
+ * Return: none
+ *
+ * Note: memory deallocation for SBR is only done here
+ **************************************************************************************/
+void FreeSBR(AACDecInfo *aacDecInfo)
+{
+ if (aacDecInfo && aacDecInfo->psInfoSBR) {
+ free(aacDecInfo->psInfoSBR);
+ }
+
+ return;
+}
+
+/**************************************************************************************
+ * Function: DecodeSBRBitstream
+ *
+ * Description: decode sideband information for SBR
+ *
+ * Inputs: valid AACDecInfo struct
+ * fill buffer with SBR extension block
+ * number of bytes in fill buffer
+ * base output channel (range = [0, nChans-1])
+ *
+ * Outputs: initialized state structs (SBRHdr, SBRGrid, SBRFreq, SBRChan)
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: SBR payload should be in aacDecInfo->fillBuf
+ * returns with no error if fill buffer is not an SBR extension block,
+ * or if current block is not a fill block (e.g. for LFE upsampling)
+ **************************************************************************************/
+int DecodeSBRBitstream(AACDecInfo *aacDecInfo, int chBase)
+{
+ int headerFlag;
+ BitStreamInfo bsi;
+ PSInfoSBR *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoSBR) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoSBR *)(aacDecInfo->psInfoSBR);
+
+ if (aacDecInfo->currBlockID != AAC_ID_FIL || (aacDecInfo->fillExtType != EXT_SBR_DATA && aacDecInfo->fillExtType != EXT_SBR_DATA_CRC)) {
+ return ERR_AAC_NONE;
+ }
+
+ SetBitstreamPointer(&bsi, aacDecInfo->fillCount, aacDecInfo->fillBuf);
+ if (GetBits(&bsi, 4) != (unsigned int)aacDecInfo->fillExtType) {
+ return ERR_AAC_SBR_BITSTREAM;
+ }
+
+ if (aacDecInfo->fillExtType == EXT_SBR_DATA_CRC) {
+ psi->crcCheckWord = GetBits(&bsi, 10);
+ }
+
+ headerFlag = GetBits(&bsi, 1);
+ if (headerFlag) {
+ /* get sample rate index for output sample rate (2x base rate) */
+ psi->sampRateIdx = GetSampRateIdx(2 * aacDecInfo->sampRate);
+ if (psi->sampRateIdx < 0 || psi->sampRateIdx >= NUM_SAMPLE_RATES) {
+ return ERR_AAC_SBR_BITSTREAM;
+ } else if (psi->sampRateIdx >= NUM_SAMPLE_RATES_SBR) {
+ return ERR_AAC_SBR_SINGLERATE_UNSUPPORTED;
+ }
+
+ /* reset flag = 1 if header values changed */
+ if (UnpackSBRHeader(&bsi, &(psi->sbrHdr[chBase]))) {
+ psi->sbrChan[chBase].reset = 1;
+ }
+
+ /* first valid SBR header should always trigger CalcFreqTables(), since psi->reset was set in InitSBR() */
+ if (psi->sbrChan[chBase].reset) {
+ CalcFreqTables(&(psi->sbrHdr[chBase + 0]), &(psi->sbrFreq[chBase]), psi->sampRateIdx);
+ }
+
+ /* copy and reset state to right channel for CPE */
+ if (aacDecInfo->prevBlockID == AAC_ID_CPE) {
+ psi->sbrChan[chBase + 1].reset = psi->sbrChan[chBase + 0].reset;
+ }
+ }
+
+
+ /* if no header has been received, upsample only */
+ if (psi->sbrHdr[chBase].count == 0) {
+ return ERR_AAC_NONE;
+ }
+
+ if (aacDecInfo->prevBlockID == AAC_ID_SCE) {
+ UnpackSBRSingleChannel(&bsi, psi, chBase);
+ } else if (aacDecInfo->prevBlockID == AAC_ID_CPE) {
+ UnpackSBRChannelPair(&bsi, psi, chBase);
+ } else {
+ return ERR_AAC_SBR_BITSTREAM;
+ }
+
+ ByteAlignBitstream(&bsi);
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: DecodeSBRData
+ *
+ * Description: apply SBR to one frame of PCM data
+ *
+ * Inputs: 1024 samples of decoded 32-bit PCM, before SBR
+ * size of input PCM samples (must be 4 bytes)
+ * number of fraction bits in input PCM samples
+ * base output channel (range = [0, nChans-1])
+ * initialized state structs (SBRHdr, SBRGrid, SBRFreq, SBRChan)
+ *
+ * Outputs: 2048 samples of decoded 16-bit PCM, after SBR
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int DecodeSBRData(AACDecInfo *aacDecInfo, int chBase, short *outbuf)
+{
+ int k, l, ch, chBlock, qmfaBands, qmfsBands;
+ int upsampleOnly, gbIdx, gbMask;
+ int *inbuf;
+ short *outptr;
+ PSInfoSBR *psi;
+ SBRHeader *sbrHdr;
+ SBRGrid *sbrGrid;
+ SBRFreq *sbrFreq;
+ SBRChan *sbrChan;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoSBR) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoSBR *)(aacDecInfo->psInfoSBR);
+
+ /* same header and freq tables for both channels in CPE */
+ sbrHdr = &(psi->sbrHdr[chBase]);
+ sbrFreq = &(psi->sbrFreq[chBase]);
+
+ /* upsample only if we haven't received an SBR header yet or if we have an LFE block */
+ if (aacDecInfo->currBlockID == AAC_ID_LFE) {
+ chBlock = 1;
+ upsampleOnly = 1;
+ } else if (aacDecInfo->currBlockID == AAC_ID_FIL) {
+ if (aacDecInfo->prevBlockID == AAC_ID_SCE) {
+ chBlock = 1;
+ } else if (aacDecInfo->prevBlockID == AAC_ID_CPE) {
+ chBlock = 2;
+ } else {
+ return ERR_AAC_NONE;
+ }
+
+ upsampleOnly = (sbrHdr->count == 0 ? 1 : 0);
+ if (aacDecInfo->fillExtType != EXT_SBR_DATA && aacDecInfo->fillExtType != EXT_SBR_DATA_CRC) {
+ return ERR_AAC_NONE;
+ }
+ } else {
+ /* ignore non-SBR blocks */
+ return ERR_AAC_NONE;
+ }
+
+ if (upsampleOnly) {
+ sbrFreq->kStart = 32;
+ sbrFreq->numQMFBands = 0;
+ }
+
+ for (ch = 0; ch < chBlock; ch++) {
+ sbrGrid = &(psi->sbrGrid[chBase + ch]);
+ sbrChan = &(psi->sbrChan[chBase + ch]);
+
+ if (aacDecInfo->rawSampleBuf[ch] == 0 || aacDecInfo->rawSampleBytes != 4) {
+ return ERR_AAC_SBR_PCM_FORMAT;
+ }
+ inbuf = (int *)aacDecInfo->rawSampleBuf[ch];
+ outptr = outbuf + chBase + ch;
+
+ /* restore delay buffers (could use ring buffer or keep in temp buffer for nChans == 1) */
+ for (l = 0; l < HF_GEN; l++) {
+ for (k = 0; k < 64; k++) {
+ psi->XBuf[l][k][0] = psi->XBufDelay[chBase + ch][l][k][0];
+ psi->XBuf[l][k][1] = psi->XBufDelay[chBase + ch][l][k][1];
+ }
+ }
+
+ /* step 1 - analysis QMF */
+ qmfaBands = sbrFreq->kStart;
+ for (l = 0; l < 32; l++) {
+ gbMask = QMFAnalysis(inbuf + l * 32, psi->delayQMFA[chBase + ch], psi->XBuf[l + HF_GEN][0],
+ aacDecInfo->rawSampleFBits, &(psi->delayIdxQMFA[chBase + ch]), qmfaBands);
+
+ gbIdx = ((l + HF_GEN) >> 5) & 0x01;
+ sbrChan->gbMask[gbIdx] |= gbMask; /* gbIdx = (0 if i < 32), (1 if i >= 32) */
+ }
+
+ if (upsampleOnly) {
+ /* no SBR - just run synthesis QMF to upsample by 2x */
+ qmfsBands = 32;
+ for (l = 0; l < 32; l++) {
+ /* step 4 - synthesis QMF */
+ QMFSynthesis(psi->XBuf[l + HF_ADJ][0], psi->delayQMFS[chBase + ch], &(psi->delayIdxQMFS[chBase + ch]), qmfsBands, outptr, aacDecInfo->nChans);
+ outptr += 64 * aacDecInfo->nChans;
+ }
+ } else {
+ /* if previous frame had lower SBR starting freq than current, zero out the synthesized QMF
+ * bands so they aren't used as sources for patching
+ * after patch generation, restore from delay buffer
+ * can only happen after header reset
+ */
+ for (k = sbrFreq->kStartPrev; k < sbrFreq->kStart; k++) {
+ for (l = 0; l < sbrGrid->envTimeBorder[0] + HF_ADJ; l++) {
+ psi->XBuf[l][k][0] = 0;
+ psi->XBuf[l][k][1] = 0;
+ }
+ }
+
+ /* step 2 - HF generation */
+ GenerateHighFreq(psi, sbrGrid, sbrFreq, sbrChan, ch);
+
+ /* restore SBR bands that were cleared before patch generation (time slots 0, 1 no longer needed) */
+ for (k = sbrFreq->kStartPrev; k < sbrFreq->kStart; k++) {
+ for (l = HF_ADJ; l < sbrGrid->envTimeBorder[0] + HF_ADJ; l++) {
+ psi->XBuf[l][k][0] = psi->XBufDelay[chBase + ch][l][k][0];
+ psi->XBuf[l][k][1] = psi->XBufDelay[chBase + ch][l][k][1];
+ }
+ }
+
+ /* step 3 - HF adjustment */
+ AdjustHighFreq(psi, sbrHdr, sbrGrid, sbrFreq, sbrChan, ch);
+
+ /* step 4 - synthesis QMF */
+ qmfsBands = sbrFreq->kStartPrev + sbrFreq->numQMFBandsPrev;
+ for (l = 0; l < sbrGrid->envTimeBorder[0]; l++) {
+ /* if new envelope starts mid-frame, use old settings until start of first envelope in this frame */
+ QMFSynthesis(psi->XBuf[l + HF_ADJ][0], psi->delayQMFS[chBase + ch], &(psi->delayIdxQMFS[chBase + ch]), qmfsBands, outptr, aacDecInfo->nChans);
+ outptr += 64 * aacDecInfo->nChans;
+ }
+
+ qmfsBands = sbrFreq->kStart + sbrFreq->numQMFBands;
+ for (; l < 32; l++) {
+ /* use new settings for rest of frame (usually the entire frame, unless the first envelope starts mid-frame) */
+ QMFSynthesis(psi->XBuf[l + HF_ADJ][0], psi->delayQMFS[chBase + ch], &(psi->delayIdxQMFS[chBase + ch]), qmfsBands, outptr, aacDecInfo->nChans);
+ outptr += 64 * aacDecInfo->nChans;
+ }
+ }
+
+ /* save delay */
+ for (l = 0; l < HF_GEN; l++) {
+ for (k = 0; k < 64; k++) {
+ psi->XBufDelay[chBase + ch][l][k][0] = psi->XBuf[l + 32][k][0];
+ psi->XBufDelay[chBase + ch][l][k][1] = psi->XBuf[l + 32][k][1];
+ }
+ }
+ sbrChan->gbMask[0] = sbrChan->gbMask[1];
+ sbrChan->gbMask[1] = 0;
+
+ if (sbrHdr->count > 0) {
+ sbrChan->reset = 0;
+ }
+ }
+ sbrFreq->kStartPrev = sbrFreq->kStart;
+ sbrFreq->numQMFBandsPrev = sbrFreq->numQMFBands;
+
+ if (aacDecInfo->nChans > 0 && (chBase + ch) == aacDecInfo->nChans) {
+ psi->frameCount++;
+ }
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: FlushCodecSBR
+ *
+ * Description: flush internal SBR codec state (after seeking, for example)
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: updated state variables for SBR
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: SBR is heavily dependent on state from previous frames
+ * (e.g. delta coded scalefactors, previous envelope boundaries, etc.)
+ * On flush, we reset everything as if SBR had just been initialized
+ * for the first time. This triggers "upsample-only" mode until
+ * the first valid SBR header is received. Then SBR starts as usual.
+ **************************************************************************************/
+int FlushCodecSBR(AACDecInfo *aacDecInfo)
+{
+ PSInfoSBR *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoSBR) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoSBR *)(aacDecInfo->psInfoSBR);
+
+ InitSBRState(psi);
+
+ return 0;
+}
diff --git a/audio_codec/libraac/sbr.h b/audio_codec/libraac/sbr.h
new file mode 100644
index 0000000..0fe908c
--- a/dev/null
+++ b/audio_codec/libraac/sbr.h
@@ -0,0 +1,381 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbr.h,v 1.2 2005/05/20 18:05:41 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbr.h - definitions of platform-specific SBR data structures, functions, and tables
+ **************************************************************************************/
+
+#ifndef _SBR_H
+#define _SBR_H
+
+#include "aaccommon.h"
+#include "bitstream.h"
+
+#ifndef ASSERT
+#if defined(_WIN32) && defined(_M_IX86) && (defined (_DEBUG) || defined (REL_ENABLE_ASSERTS))
+#define ASSERT(x) if (!(x)) __asm int 3;
+#else
+#define ASSERT(x) /* do nothing */
+#endif
+#endif
+
+#ifndef MAX
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+#ifndef MIN
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+#define NUM_TIME_SLOTS 16
+#define SAMPLES_PER_SLOT 2 /* RATE in spec */
+#define NUM_SAMPLE_RATES_SBR 9 /* downsampled (single-rate) mode unsupported, so only use Fs_sbr >= 16 kHz */
+
+#define MAX_NUM_ENV 5
+#define MAX_NUM_NOISE_FLOORS 2
+#define MAX_NUM_NOISE_FLOOR_BANDS 5 /* max Nq, see 4.6.18.3.6 */
+#define MAX_NUM_PATCHES 5
+#define MAX_NUM_SMOOTH_COEFS 5
+
+#define HF_GEN 8
+#define HF_ADJ 2
+
+#define MAX_QMF_BANDS 48 /* max QMF subbands covered by SBR (4.6.18.3.6) */
+
+#define FBITS_IN_QMFA 14
+#define FBITS_LOST_QMFA (1 + 2 + 3 + 2 + 1) /* 1 from cTab, 2 in premul, 3 in FFT, 2 in postmul, 1 for implicit scaling by 2.0 */
+#define FBITS_OUT_QMFA (FBITS_IN_QMFA - FBITS_LOST_QMFA)
+
+#define MIN_GBITS_IN_QMFS 2
+#define FBITS_IN_QMFS FBITS_OUT_QMFA
+#define FBITS_LOST_DCT4_64 (2 + 3 + 2) /* 2 in premul, 3 in FFT, 2 in postmul */
+
+#define FBITS_OUT_DQ_ENV 29 /* dequantized env scalefactors are Q(29 - envDataDequantScale) */
+#define FBITS_OUT_DQ_NOISE 24 /* range of Q_orig = [2^-24, 2^6] */
+#define NOISE_FLOOR_OFFSET 6
+
+/* see comments in ApplyBoost() */
+#define FBITS_GLIM_BOOST 24
+#define FBITS_QLIM_BOOST 14
+
+#define MAX_HUFF_BITS 20
+#define NUM_QMF_DELAY_BUFS 10
+#define DELAY_SAMPS_QMFA (NUM_QMF_DELAY_BUFS * 32)
+#define DELAY_SAMPS_QMFS (NUM_QMF_DELAY_BUFS * 128)
+
+/* additional external symbols to name-mangle for static linking */
+#define FFT32C STATNAME(FFT32C)
+#define CalcFreqTables STATNAME(CalcFreqTables)
+#define AdjustHighFreq STATNAME(AdjustHighFreq)
+//#define GenerateHighFreq STATNAME(GenerateHighFreq)
+#define DecodeSBREnvelope STATNAME(DecodeSBREnvelope)
+#define DecodeSBRNoise STATNAME(DecodeSBRNoise)
+#define UncoupleSBREnvelope STATNAME(UncoupleSBREnvelope)
+#define UncoupleSBRNoise STATNAME(UncoupleSBRNoise)
+#define InvRNormalized STATNAME(InvRNormalized)
+#define RatioPowInv STATNAME(RatioPowInv)
+#define SqrtFix STATNAME(SqrtFix)
+#define QMFAnalysis STATNAME(QMFAnalysis)
+#define QMFSynthesis STATNAME(QMFSynthesis)
+#define GetSampRateIdx STATNAME(GetSampRateIdx)
+#define UnpackSBRHeader STATNAME(UnpackSBRHeader)
+#define UnpackSBRSingleChannel STATNAME(UnpackSBRSingleChannel)
+#define UnpackSBRChannelPair STATNAME(UnpackSBRChannelPair)
+
+/* asm functions */
+#define CVKernel1 STATNAME(CVKernel1)
+#define CVKernel2 STATNAME(CVKernel2)
+#define QMFAnalysisConv STATNAME(QMFAnalysisConv)
+#define QMFSynthesisConv STATNAME(QMFSynthesisConv)
+
+#define k0Tab STATNAME(k0Tab)
+#define k2Tab STATNAME(k2Tab)
+#define goalSBTab STATNAME(goalSBTab)
+#define huffTabSBR STATNAME(huffTabSBR)
+#define huffTabSBRInfo STATNAME(huffTabSBRInfo)
+#define log2Tab STATNAME(log2Tab)
+#define noiseTab STATNAME(noiseTab)
+#define cTabA STATNAME(cTabA)
+#define cTabS STATNAME(cTabS)
+
+/* do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) */
+#define CLIP_2N_SHIFT30(y, n) { \
+ int sign = (y) >> 31; \
+ if (sign != (y) >> (30 - (n))) { \
+ (y) = sign ^ (0x3fffffff); \
+ } else { \
+ (y) = (y) << (n); \
+ } \
+}
+
+#define CLIP_2N(y, n) { \
+ int sign = (y) >> 31; \
+ if (sign != ((y) >> (n))) { \
+ (y) = sign ^ ((1 << (n)) - 1); \
+ } \
+}
+
+enum {
+ SBR_GRID_FIXFIX = 0,
+ SBR_GRID_FIXVAR = 1,
+ SBR_GRID_VARFIX = 2,
+ SBR_GRID_VARVAR = 3
+};
+
+enum {
+ HuffTabSBR_tEnv15 = 0,
+ HuffTabSBR_fEnv15 = 1,
+ HuffTabSBR_tEnv15b = 2,
+ HuffTabSBR_fEnv15b = 3,
+ HuffTabSBR_tEnv30 = 4,
+ HuffTabSBR_fEnv30 = 5,
+ HuffTabSBR_tEnv30b = 6,
+ HuffTabSBR_fEnv30b = 7,
+ HuffTabSBR_tNoise30 = 8,
+ HuffTabSBR_fNoise30 = 5,
+ HuffTabSBR_tNoise30b = 9,
+ HuffTabSBR_fNoise30b = 7
+};
+
+typedef struct _HuffInfo {
+ int maxBits; /* number of bits in longest codeword */
+ unsigned char count[MAX_HUFF_BITS]; /* count[i] = number of codes with length i+1 bits */
+ int offset; /* offset into symbol table */
+} HuffInfo;
+
+/* need one SBRHeader per element (SCE/CPE), updated only on new header */
+typedef struct _SBRHeader {
+ int count;
+
+ unsigned char ampRes;
+ unsigned char startFreq;
+ unsigned char stopFreq;
+ unsigned char crossOverBand;
+ unsigned char resBitsHdr;
+ unsigned char hdrExtra1;
+ unsigned char hdrExtra2;
+
+ unsigned char freqScale;
+ unsigned char alterScale;
+ unsigned char noiseBands;
+
+ unsigned char limiterBands;
+ unsigned char limiterGains;
+ unsigned char interpFreq;
+ unsigned char smoothMode;
+} SBRHeader;
+
+/* need one SBRGrid per channel, updated every frame */
+typedef struct _SBRGrid {
+ unsigned char frameClass;
+ unsigned char ampResFrame;
+ unsigned char pointer;
+
+ unsigned char numEnv; /* L_E */
+ unsigned char envTimeBorder[MAX_NUM_ENV + 1]; /* t_E */
+ unsigned char freqRes[MAX_NUM_ENV]; /* r */
+
+ unsigned char numNoiseFloors; /* L_Q */
+ unsigned char noiseTimeBorder[MAX_NUM_NOISE_FLOORS + 1]; /* t_Q */
+
+ unsigned char numEnvPrev;
+ unsigned char numNoiseFloorsPrev;
+ unsigned char freqResPrev;
+} SBRGrid;
+
+/* need one SBRFreq per element (SCE/CPE/LFE), updated only on header reset */
+typedef struct _SBRFreq {
+ int kStart; /* k_x */
+ int nMaster;
+ int nHigh;
+ int nLow;
+ int nLimiter; /* N_l */
+ int numQMFBands; /* M */
+ int numNoiseFloorBands; /* Nq */
+
+ int kStartPrev;
+ int numQMFBandsPrev;
+
+ unsigned char freqMaster[MAX_QMF_BANDS + 1]; /* not necessary to save this after derived tables are generated */
+ unsigned char freqHigh[MAX_QMF_BANDS + 1];
+ unsigned char freqLow[MAX_QMF_BANDS / 2 + 1]; /* nLow = nHigh - (nHigh >> 1) */
+ unsigned char freqNoise[MAX_NUM_NOISE_FLOOR_BANDS + 1];
+ unsigned char freqLimiter[MAX_QMF_BANDS / 2 + MAX_NUM_PATCHES]; /* max (intermediate) size = nLow + numPatches - 1 */
+
+ unsigned char numPatches;
+ unsigned char patchNumSubbands[MAX_NUM_PATCHES + 1];
+ unsigned char patchStartSubband[MAX_NUM_PATCHES + 1];
+} SBRFreq;
+
+typedef struct _SBRChan {
+ int reset;
+ unsigned char deltaFlagEnv[MAX_NUM_ENV];
+ unsigned char deltaFlagNoise[MAX_NUM_NOISE_FLOORS];
+
+ signed char envDataQuant[MAX_NUM_ENV][MAX_QMF_BANDS]; /* range = [0, 127] */
+ signed char noiseDataQuant[MAX_NUM_NOISE_FLOORS][MAX_NUM_NOISE_FLOOR_BANDS];
+
+ unsigned char invfMode[2][MAX_NUM_NOISE_FLOOR_BANDS]; /* invfMode[0/1][band] = prev/curr */
+ int chirpFact[MAX_NUM_NOISE_FLOOR_BANDS]; /* bwArray */
+ unsigned char addHarmonicFlag[2]; /* addHarmonicFlag[0/1] = prev/curr */
+ unsigned char addHarmonic[2][64]; /* addHarmonic[0/1][band] = prev/curr */
+
+ int gbMask[2]; /* gbMask[0/1] = XBuf[0-31]/XBuf[32-39] */
+ signed char laPrev;
+
+ int noiseTabIndex;
+ int sinIndex;
+ int gainNoiseIndex;
+ int gTemp[MAX_NUM_SMOOTH_COEFS][MAX_QMF_BANDS];
+ int qTemp[MAX_NUM_SMOOTH_COEFS][MAX_QMF_BANDS];
+
+} SBRChan;
+
+typedef struct _PSInfoSBR {
+ /* save for entire file */
+ int frameCount;
+ int sampRateIdx;
+
+ /* state info that must be saved for each channel */
+ SBRHeader sbrHdr[AAC_MAX_NCHANS];
+ SBRGrid sbrGrid[AAC_MAX_NCHANS];
+ SBRFreq sbrFreq[AAC_MAX_NCHANS];
+ SBRChan sbrChan[AAC_MAX_NCHANS];
+
+ /* temp variables, no need to save between blocks */
+ unsigned char dataExtra;
+ unsigned char resBitsData;
+ unsigned char extendedDataPresent;
+ int extendedDataSize;
+
+ signed char envDataDequantScale[MAX_NCHANS_ELEM][MAX_NUM_ENV];
+ int envDataDequant[MAX_NCHANS_ELEM][MAX_NUM_ENV][MAX_QMF_BANDS];
+ int noiseDataDequant[MAX_NCHANS_ELEM][MAX_NUM_NOISE_FLOORS][MAX_NUM_NOISE_FLOOR_BANDS];
+
+ int eCurr[MAX_QMF_BANDS];
+ unsigned char eCurrExp[MAX_QMF_BANDS];
+ unsigned char eCurrExpMax;
+ signed char la;
+
+ int crcCheckWord;
+ int couplingFlag;
+ int envBand;
+ int eOMGainMax;
+ int gainMax;
+ int gainMaxFBits;
+ int noiseFloorBand;
+ int qp1Inv;
+ int qqp1Inv;
+ int sMapped;
+ int sBand;
+ int highBand;
+
+ int sumEOrigMapped;
+ int sumECurrGLim;
+ int sumSM;
+ int sumQM;
+ int gLimBoost[MAX_QMF_BANDS];
+ int qmLimBoost[MAX_QMF_BANDS];
+ int smBoost[MAX_QMF_BANDS];
+
+ int smBuf[MAX_QMF_BANDS];
+ int qmLimBuf[MAX_QMF_BANDS];
+ int gLimBuf[MAX_QMF_BANDS];
+ int gLimFbits[MAX_QMF_BANDS];
+
+ int gFiltLast[MAX_QMF_BANDS];
+ int qFiltLast[MAX_QMF_BANDS];
+
+ /* large buffers */
+ int delayIdxQMFA[AAC_MAX_NCHANS];
+ int delayQMFA[AAC_MAX_NCHANS][DELAY_SAMPS_QMFA];
+ int delayIdxQMFS[AAC_MAX_NCHANS];
+ int delayQMFS[AAC_MAX_NCHANS][DELAY_SAMPS_QMFS];
+ int XBufDelay[AAC_MAX_NCHANS][HF_GEN][64][2];
+ int XBuf[32 + 8][64][2];
+
+} PSInfoSBR;
+
+/* sbrfft.c */
+void FFT32C(int *x);
+
+/* sbrfreq.c */
+int CalcFreqTables(SBRHeader *sbrHdr, SBRFreq *sbrFreq, int sampRateIdx);
+
+/* sbrhfadj.c */
+void AdjustHighFreq(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch);
+
+/* sbrhfgen.c */
+void GenerateHighFreq(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch);
+
+/* sbrhuff.c */
+void DecodeSBREnvelope(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch);
+void DecodeSBRNoise(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch);
+void UncoupleSBREnvelope(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR);
+void UncoupleSBRNoise(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR);
+
+/* sbrmath.c */
+int InvRNormalized(int r);
+int RatioPowInv(int a, int b, int c);
+int SqrtFix(int x, int fBitsIn, int *fBitsOut);
+
+/* sbrqmf.c */
+int QMFAnalysis(int *inbuf, int *delay, int *XBuf, int fBitsIn, int *delayIdx, int qmfaBands);
+void QMFSynthesis(int *inbuf, int *delay, int *delayIdx, int qmfsBands, short *outbuf, int nChans);
+
+/* sbrside.c */
+int GetSampRateIdx(int sampRate);
+int UnpackSBRHeader(BitStreamInfo *bsi, SBRHeader *sbrHdr);
+void UnpackSBRSingleChannel(BitStreamInfo *bsi, PSInfoSBR *psi, int chOut);
+void UnpackSBRChannelPair(BitStreamInfo *bsi, PSInfoSBR *psi, int chOut);
+
+/* sbrtabs.c */
+extern const unsigned char k0Tab[NUM_SAMPLE_RATES_SBR][16];
+extern const unsigned char k2Tab[NUM_SAMPLE_RATES_SBR][14];
+extern const unsigned char goalSBTab[NUM_SAMPLE_RATES_SBR];
+extern const HuffInfo huffTabSBRInfo[10];
+extern const signed short huffTabSBR[604];
+extern const int log2Tab[65];
+extern const int noiseTab[512 * 2];
+extern const int cTabA[165];
+extern const int cTabS[640];
+
+#endif /* _SBR_H */
diff --git a/audio_codec/libraac/sbrcov.s b/audio_codec/libraac/sbrcov.s
new file mode 100755
index 0000000..0239712
--- a/dev/null
+++ b/audio_codec/libraac/sbrcov.s
@@ -0,0 +1,164 @@
+@ ***** BEGIN LICENSE BLOCK *****
+@ Source last modified: $Id: sbrcov.s,v 1.1 2005/04/08 21:59:46 jrecker Exp $
+@
+@ Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+@
+@ The contents of this file, and the files included with this file,
+@ are subject to the current version of the RealNetworks Public
+@ Source License (the "RPSL") available at
+@ http://www.helixcommunity.org/content/rpsl unless you have licensed
+@ the file under the current version of the RealNetworks Community
+@ Source License (the "RCSL") available at
+@ http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+@ will apply. You may also obtain the license terms directly from
+@ RealNetworks. You may not use this file except in compliance with
+@ the RPSL or, if you have a valid RCSL with RealNetworks applicable
+@ to this file, the RCSL. Please see the applicable RPSL or RCSL for
+@ the rights, obligations and limitations governing use of the
+@ contents of the file.
+@
+@ This file is part of the Helix DNA Technology. RealNetworks is the
+@ developer and/or licensor of the Original Code and owns the
+@ copyrights in the portions it created.
+@
+@ This file, and the files included with this file, is distributed
+@ and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+@ KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+@ ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+@ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+@ ENJOYMENT OR NON-INFRINGEMENT.
+@
+@ Technology Compatibility Kit Test Suite(s) Location:
+@ http://www.helixcommunity.org/content/tck
+@
+@ Contributor(s):
+@
+@ ***** END LICENSE BLOCK *****
+
+ .text
+ .code 32
+ .align
+
+@ void CVKernel1(int *XBuf, int *accBuf)
+@ see comments in sbrhfgen.c
+
+ .global raac_CVKernel1
+ .type raac_CVKernel1, %function
+raac_CVKernel1:
+
+ stmfd sp!, {r4-r11, r14}
+
+ ldr r3, [r0], #4*(1)
+ ldr r4, [r0], #4*(2*64-1)
+ ldr r5, [r0], #4*(1)
+ ldr r6, [r0], #4*(2*64-1)
+ rsb r14, r4, #0
+
+ smull r7, r8, r5, r3
+ smlal r7, r8, r6, r4
+ smull r9, r10, r3, r6
+ smlal r9, r10, r14, r5
+ smull r11, r12, r3, r3
+ smlal r11, r12, r4, r4
+
+ add r2, r1, #(4*6)
+ stmia r2, {r7-r12}
+
+ mov r7, #0
+ mov r8, #0
+ mov r9, #0
+ mov r10, #0
+ mov r11, #0
+ mov r12, #0
+
+ mov r2, #(16*2 + 6)
+CV1_Loop_Start:
+ mov r3, r5
+ ldr r5, [r0], #4*(1)
+ mov r4, r6
+ ldr r6, [r0], #4*(2*64-1)
+ rsb r14, r4, #0
+
+ smlal r7, r8, r5, r3
+ smlal r7, r8, r6, r4
+ smlal r9, r10, r3, r6
+ smlal r9, r10, r14, r5
+ smlal r11, r12, r3, r3
+ smlal r11, r12, r4, r4
+
+ subs r2, r2, #1
+ bne CV1_Loop_Start
+
+ stmia r1, {r7-r12}
+
+ ldr r0, [r1, #4*(6)]
+ ldr r2, [r1, #4*(7)]
+ rsb r3, r3, #0
+ adds r7, r0, r7
+ adc r8, r2, r8
+ smlal r7, r8, r5, r3
+ smlal r7, r8, r6, r14
+
+ ldr r0, [r1, #4*(8)]
+ ldr r2, [r1, #4*(9)]
+ adds r9, r0, r9
+ adc r10, r2, r10
+ smlal r9, r10, r3, r6
+ smlal r9, r10, r4, r5
+
+ ldr r0, [r1, #4*(10)]
+ ldr r2, [r1, #4*(11)]
+ adds r11, r0, r11
+ adc r12, r2, r12
+ rsb r0, r3, #0
+ smlal r11, r12, r3, r0
+ rsb r2, r4, #0
+ smlal r11, r12, r4, r2
+
+ add r1, r1, #(4*6)
+ stmia r1, {r7-r12}
+
+ ldmfd sp!, {r4-r11, pc}
+
+@ void CVKernel2(int *XBuf, int *accBuf)
+@ see comments in sbrhfgen.c
+
+ .global raac_CVKernel2
+ .type raac_CVKernel2, %function
+raac_CVKernel2:
+ stmfd sp!, {r4-r11, r14}
+
+ mov r7, #0
+ mov r8, #0
+ mov r9, #0
+ mov r10, #0
+
+ ldr r3, [r0], #4*(1)
+ ldr r4, [r0], #4*(2*64-1)
+ ldr r5, [r0], #4*(1)
+ ldr r6, [r0], #4*(2*64-1)
+
+ mov r2, #(16*2 + 6)
+CV2_Loop_Start:
+ ldr r11, [r0], #4*(1)
+ ldr r12, [r0], #4*(2*64-1)
+ rsb r14, r4, #0
+
+ smlal r7, r8, r11, r3
+ smlal r7, r8, r12, r4
+ smlal r9, r10, r3, r12
+ smlal r9, r10, r14, r11
+
+ mov r3, r5
+ mov r4, r6
+ mov r5, r11
+ mov r6, r12
+
+ subs r2, r2, #1
+ bne CV2_Loop_Start
+
+ stmia r1, {r7-r10}
+
+ ldmfd sp!, {r4-r11, pc}
+
+ .end
diff --git a/audio_codec/libraac/sbrfft.c b/audio_codec/libraac/sbrfft.c
new file mode 100644
index 0000000..2f74fc5
--- a/dev/null
+++ b/audio_codec/libraac/sbrfft.c
@@ -0,0 +1,368 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrfft.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * sbrfft.c - optimized FFT for SBR QMF filters
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+#define SQRT1_2 0x5a82799a
+
+/* swap RE{p0} with RE{p1} and IM{P0} with IM{P1} */
+#define swapcplx(p0,p1) \
+ t = p0; t1 = *(&(p0)+1); p0 = p1; *(&(p0)+1) = *(&(p1)+1); p1 = t; *(&(p1)+1) = t1
+
+/* nfft = 32, hard coded since small, fixed size FFT
+static const unsigned char bitrevtab32[9] = {
+ 0x01, 0x04, 0x03, 0x06, 0x00, 0x02, 0x05, 0x07, 0x00,
+};
+*/
+
+/* twiddle table for radix 4 pass, format = Q31 */
+static const int twidTabOdd32[8 * 6] = {
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x539eba45, 0xe7821d59,
+ 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59,
+ 0x539eba45, 0xc4df2862, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x22a2f4f8, 0xc4df2862,
+ 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862,
+ 0xac6145bb, 0x187de2a7, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52,
+};
+
+/**************************************************************************************
+ * Function: BitReverse32
+ *
+ * Description: Ken's fast in-place bit reverse
+ *
+ * Inputs: buffer of 32 complex samples
+ *
+ * Outputs: bit-reversed samples in same buffer
+ *
+ * Return: none
+**************************************************************************************/
+static void BitReverse32(int *inout)
+{
+ int t, t1;
+
+ swapcplx(inout[2], inout[32]);
+ swapcplx(inout[4], inout[16]);
+ swapcplx(inout[6], inout[48]);
+ swapcplx(inout[10], inout[40]);
+ swapcplx(inout[12], inout[24]);
+ swapcplx(inout[14], inout[56]);
+ swapcplx(inout[18], inout[36]);
+ swapcplx(inout[22], inout[52]);
+ swapcplx(inout[26], inout[44]);
+ swapcplx(inout[30], inout[60]);
+ swapcplx(inout[38], inout[50]);
+ swapcplx(inout[46], inout[58]);
+}
+
+/**************************************************************************************
+ * Function: R8FirstPass32
+ *
+ * Description: radix-8 trivial pass for decimation-in-time FFT (log2(N) = 5)
+ *
+ * Inputs: buffer of (bit-reversed) samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 3 guard bits, gains 1 integer bit
+ * guard bits out = guard bits in - 3 (if inputs are full scale)
+ * or guard bits in - 2 (if inputs bounded to +/- sqrt(2)/2)
+ * see scaling comments in fft.c for base AAC
+ * should compile with no stack spills on ARM (verify compiled output)
+ * current instruction count (per pass): 16 LDR, 16 STR, 4 SMULL, 61 ALU
+ **************************************************************************************/
+static void R8FirstPass32(int *r0)
+{
+ int r1, r2, r3, r4, r5, r6, r7;
+ int r8, r9, r10, r11, r12, r14;
+
+ /* number of passes = fft size / 8 = 32 / 8 = 4 */
+ r1 = (32 >> 3);
+ do {
+
+ r2 = r0[8];
+ r3 = r0[9];
+ r4 = r0[10];
+ r5 = r0[11];
+ r6 = r0[12];
+ r7 = r0[13];
+ r8 = r0[14];
+ r9 = r0[15];
+
+ r10 = r2 + r4;
+ r11 = r3 + r5;
+ r12 = r6 + r8;
+ r14 = r7 + r9;
+
+ r2 -= r4;
+ r3 -= r5;
+ r6 -= r8;
+ r7 -= r9;
+
+ r4 = r2 - r7;
+ r5 = r2 + r7;
+ r8 = r3 - r6;
+ r9 = r3 + r6;
+
+ r2 = r4 - r9;
+ r3 = r4 + r9;
+ r6 = r5 - r8;
+ r7 = r5 + r8;
+
+ r2 = MULSHIFT32(SQRT1_2, r2); /* can use r4, r5, r8, or r9 for constant and lo32 scratch reg */
+ r3 = MULSHIFT32(SQRT1_2, r3);
+ r6 = MULSHIFT32(SQRT1_2, r6);
+ r7 = MULSHIFT32(SQRT1_2, r7);
+
+ r4 = r10 + r12;
+ r5 = r10 - r12;
+ r8 = r11 + r14;
+ r9 = r11 - r14;
+
+ r10 = r0[0];
+ r11 = r0[2];
+ r12 = r0[4];
+ r14 = r0[6];
+
+ r10 += r11;
+ r12 += r14;
+
+ r4 >>= 1;
+ r10 += r12;
+ r4 += (r10 >> 1);
+ r0[ 0] = r4;
+ r4 -= (r10 >> 1);
+ r4 = (r10 >> 1) - r4;
+ r0[ 8] = r4;
+
+ r9 >>= 1;
+ r10 -= 2 * r12;
+ r4 = (r10 >> 1) + r9;
+ r0[ 4] = r4;
+ r4 = (r10 >> 1) - r9;
+ r0[12] = r4;
+ r10 += r12;
+
+ r10 -= 2 * r11;
+ r12 -= 2 * r14;
+
+ r4 = r0[1];
+ r9 = r0[3];
+ r11 = r0[5];
+ r14 = r0[7];
+
+ r4 += r9;
+ r11 += r14;
+
+ r8 >>= 1;
+ r4 += r11;
+ r8 += (r4 >> 1);
+ r0[ 1] = r8;
+ r8 -= (r4 >> 1);
+ r8 = (r4 >> 1) - r8;
+ r0[ 9] = r8;
+
+ r5 >>= 1;
+ r4 -= 2 * r11;
+ r8 = (r4 >> 1) - r5;
+ r0[ 5] = r8;
+ r8 = (r4 >> 1) + r5;
+ r0[13] = r8;
+ r4 += r11;
+
+ r4 -= 2 * r9;
+ r11 -= 2 * r14;
+
+ r9 = r10 - r11;
+ r10 += r11;
+ r14 = r4 + r12;
+ r4 -= r12;
+
+ r5 = (r10 >> 1) + r7;
+ r8 = (r4 >> 1) - r6;
+ r0[ 2] = r5;
+ r0[ 3] = r8;
+
+ r5 = (r9 >> 1) - r2;
+ r8 = (r14 >> 1) - r3;
+ r0[ 6] = r5;
+ r0[ 7] = r8;
+
+ r5 = (r10 >> 1) - r7;
+ r8 = (r4 >> 1) + r6;
+ r0[10] = r5;
+ r0[11] = r8;
+
+ r5 = (r9 >> 1) + r2;
+ r8 = (r14 >> 1) + r3;
+ r0[14] = r5;
+ r0[15] = r8;
+
+ r0 += 16;
+ r1--;
+ } while (r1 != 0);
+}
+
+/**************************************************************************************
+ * Function: R4Core32
+ *
+ * Description: radix-4 pass for 32-point decimation-in-time FFT
+ *
+ * Inputs: buffer of samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: gain 2 integer bits
+ * guard bits out = guard bits in - 1 (if inputs are full scale)
+ * see scaling comments in fft.c for base AAC
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ * should compile with no stack spills on ARM (verify compiled output)
+ * current instruction count (per pass): 16 LDR, 16 STR, 4 SMULL, 61 ALU
+ **************************************************************************************/
+static void R4Core32(int *r0)
+{
+ int r2, r3, r4, r5, r6, r7;
+ int r8, r9, r10, r12, r14;
+ int *r1;
+
+ r1 = (int *)twidTabOdd32;
+ r10 = 8;
+ do {
+ /* can use r14 for lo32 scratch register in all MULSHIFT32 */
+ r2 = r1[0];
+ r3 = r1[1];
+ r4 = r0[16];
+ r5 = r0[17];
+ r12 = r4 + r5;
+ r12 = MULSHIFT32(r3, r12);
+ r5 = MULSHIFT32(r2, r5) + r12;
+ r2 += 2 * r3;
+ r4 = MULSHIFT32(r2, r4) - r12;
+
+ r2 = r1[2];
+ r3 = r1[3];
+ r6 = r0[32];
+ r7 = r0[33];
+ r12 = r6 + r7;
+ r12 = MULSHIFT32(r3, r12);
+ r7 = MULSHIFT32(r2, r7) + r12;
+ r2 += 2 * r3;
+ r6 = MULSHIFT32(r2, r6) - r12;
+
+ r2 = r1[4];
+ r3 = r1[5];
+ r8 = r0[48];
+ r9 = r0[49];
+ r12 = r8 + r9;
+ r12 = MULSHIFT32(r3, r12);
+ r9 = MULSHIFT32(r2, r9) + r12;
+ r2 += 2 * r3;
+ r8 = MULSHIFT32(r2, r8) - r12;
+
+ r2 = r0[0];
+ r3 = r0[1];
+
+ r12 = r6 + r8;
+ r8 = r6 - r8;
+ r14 = r9 - r7;
+ r9 = r9 + r7;
+
+ r6 = (r2 >> 2) - r4;
+ r7 = (r3 >> 2) - r5;
+ r4 += (r2 >> 2);
+ r5 += (r3 >> 2);
+
+ r2 = r4 + r12;
+ r3 = r5 + r9;
+ r0[0] = r2;
+ r0[1] = r3;
+ r2 = r6 - r14;
+ r3 = r7 - r8;
+ r0[16] = r2;
+ r0[17] = r3;
+ r2 = r4 - r12;
+ r3 = r5 - r9;
+ r0[32] = r2;
+ r0[33] = r3;
+ r2 = r6 + r14;
+ r3 = r7 + r8;
+ r0[48] = r2;
+ r0[49] = r3;
+
+ r0 += 2;
+ r1 += 6;
+ r10--;
+ } while (r10 != 0);
+}
+
+/**************************************************************************************
+ * Function: FFT32C
+ *
+ * Description: Ken's very fast in-place radix-4 decimation-in-time FFT
+ *
+ * Inputs: buffer of 32 complex samples (before bit-reversal)
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 3 guard bits in, gains 3 integer bits
+ * guard bits out = guard bits in - 2
+ * (guard bit analysis includes assumptions about steps immediately
+ * before and after, i.e. PreMul and PostMul for DCT)
+ **************************************************************************************/
+void FFT32C(int *x)
+{
+ /* decimation in time */
+ BitReverse32(x);
+
+ /* 32-point complex FFT */
+ R8FirstPass32(x); /* gain 1 int bit, lose 2 GB (making assumptions about input) */
+ R4Core32(x); /* gain 2 int bits, lose 0 GB (making assumptions about input) */
+}
diff --git a/audio_codec/libraac/sbrfreq.c b/audio_codec/libraac/sbrfreq.c
new file mode 100644
index 0000000..e391046
--- a/dev/null
+++ b/audio_codec/libraac/sbrfreq.c
@@ -0,0 +1,667 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrfreq.c,v 1.2 2005/05/20 18:05:41 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrfreq.c - frequency band table calculation for SBR
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+/**************************************************************************************
+ * Function: BubbleSort
+ *
+ * Description: in-place sort of unsigned chars
+ *
+ * Inputs: buffer of elements to sort
+ * number of elements to sort
+ *
+ * Outputs: sorted buffer
+ *
+ * Return: none
+ **************************************************************************************/
+static void BubbleSort(unsigned char *v, int nItems)
+{
+ int i;
+ unsigned char t;
+
+ while (nItems >= 2) {
+ for (i = 0; i < nItems - 1; i++) {
+ if (v[i + 1] < v[i]) {
+ t = v[i + 1];
+ v[i + 1] = v[i];
+ v[i] = t;
+ }
+ }
+ nItems--;
+ }
+}
+
+/**************************************************************************************
+ * Function: VMin
+ *
+ * Description: find smallest element in a buffer of unsigned chars
+ *
+ * Inputs: buffer of elements to search
+ * number of elements to search
+ *
+ * Outputs: none
+ *
+ * Return: smallest element in buffer
+ **************************************************************************************/
+static unsigned char VMin(unsigned char *v, int nItems)
+{
+ int i;
+ unsigned char vMin;
+
+ vMin = v[0];
+ for (i = 1; i < nItems; i++) {
+ if (v[i] < vMin) {
+ vMin = v[i];
+ }
+ }
+ return vMin;
+}
+
+/**************************************************************************************
+ * Function: VMax
+ *
+ * Description: find largest element in a buffer of unsigned chars
+ *
+ * Inputs: buffer of elements to search
+ * number of elements to search
+ *
+ * Outputs: none
+ *
+ * Return: largest element in buffer
+ **************************************************************************************/
+static unsigned char VMax(unsigned char *v, int nItems)
+{
+ int i;
+ unsigned char vMax;
+
+ vMax = v[0];
+ for (i = 1; i < nItems; i++) {
+ if (v[i] > vMax) {
+ vMax = v[i];
+ }
+ }
+ return vMax;
+}
+
+/**************************************************************************************
+ * Function: CalcFreqMasterScaleZero
+ *
+ * Description: calculate master frequency table when freqScale == 0
+ * (4.6.18.3.2.1, figure 4.39)
+ *
+ * Inputs: alterScale flag
+ * index of first QMF subband in master freq table (k0)
+ * index of last QMF subband (k2)
+ *
+ * Outputs: master frequency table
+ *
+ * Return: number of bands in master frequency table
+ *
+ * Notes: assumes k2 - k0 <= 48 and k2 >= k0 (4.6.18.3.6)
+ **************************************************************************************/
+static int CalcFreqMasterScaleZero(unsigned char *freqMaster, int alterScale, int k0, int k2)
+{
+ int nMaster, k, nBands, k2Achieved, dk, vDk[64], k2Diff;
+
+ if (alterScale) {
+ dk = 2;
+ nBands = 2 * ((k2 - k0 + 2) >> 2);
+ } else {
+ dk = 1;
+ nBands = 2 * ((k2 - k0) >> 1);
+ }
+
+ if (nBands <= 0) {
+ return 0;
+ }
+
+ k2Achieved = k0 + nBands * dk;
+ k2Diff = k2 - k2Achieved;
+ for (k = 0; k < nBands; k++) {
+ vDk[k] = dk;
+ }
+
+ if (k2Diff > 0) {
+ k = nBands - 1;
+ while (k2Diff) {
+ vDk[k]++;
+ k--;
+ k2Diff--;
+ }
+ } else if (k2Diff < 0) {
+ k = 0;
+ while (k2Diff) {
+ vDk[k]--;
+ k++;
+ k2Diff++;
+ }
+ }
+
+ nMaster = nBands;
+ freqMaster[0] = k0;
+ for (k = 1; k <= nBands; k++) {
+ freqMaster[k] = freqMaster[k - 1] + vDk[k - 1];
+ }
+
+ return nMaster;
+}
+
+/* mBandTab[i] = temp1[i] / 2 */
+static const int mBandTab[3] = {6, 5, 4};
+
+/* invWarpTab[i] = 1.0 / temp2[i], Q30 (see 4.6.18.3.2.1) */
+static const int invWarpTab[2] = {0x40000000, 0x313b13b1};
+
+/**************************************************************************************
+ * Function: CalcFreqMasterScale
+ *
+ * Description: calculate master frequency table when freqScale > 0
+ * (4.6.18.3.2.1, figure 4.39)
+ *
+ * Inputs: alterScale flag
+ * freqScale flag
+ * index of first QMF subband in master freq table (k0)
+ * index of last QMF subband (k2)
+ *
+ * Outputs: master frequency table
+ *
+ * Return: number of bands in master frequency table
+ *
+ * Notes: assumes k2 - k0 <= 48 and k2 >= k0 (4.6.18.3.6)
+ **************************************************************************************/
+static int CalcFreqMaster(unsigned char *freqMaster, int freqScale, int alterScale, int k0, int k2)
+{
+ int bands, twoRegions, k, k1, t, vLast, vCurr, pCurr;
+ int invWarp, nBands0, nBands1, change;
+ unsigned char vDk1Min, vDk0Max;
+ unsigned char *vDelta;
+
+ if (freqScale < 1 || freqScale > 3) {
+ return -1;
+ }
+
+ bands = mBandTab[freqScale - 1];
+ invWarp = invWarpTab[alterScale];
+
+ /* tested for all k0 = [5, 64], k2 = [k0, 64] */
+ if (k2 * 10000 > 22449 * k0) {
+ twoRegions = 1;
+ k1 = 2 * k0;
+ } else {
+ twoRegions = 0;
+ k1 = k2;
+ }
+
+ /* tested for all k0 = [5, 64], k1 = [k0, 64], freqScale = [1,3] */
+ t = (log2Tab[k1] - log2Tab[k0]) >> 3; /* log2(k1/k0), Q28 to Q25 */
+ nBands0 = 2 * (((bands * t) + (1 << 24)) >> 25); /* multiply by bands/2, round to nearest int (mBandTab has factor of 1/2 rolled in) */
+
+ /* tested for all valid combinations of k0, k1, nBands (from sampRate, freqScale, alterScale)
+ * roundoff error can be a problem with fixpt (e.g. pCurr = 12.499999 instead of 12.50003)
+ * because successive multiplication always undershoots a little bit, but this
+ * doesn't occur in any of the ratios we encounter from the valid k0/k1 bands in the spec
+ */
+ t = RatioPowInv(k1, k0, nBands0);
+ pCurr = k0 << 24;
+ vLast = k0;
+ vDelta = freqMaster + 1; /* operate in-place */
+ for (k = 0; k < nBands0; k++) {
+ pCurr = MULSHIFT32(pCurr, t) << 8; /* keep in Q24 */
+ vCurr = (pCurr + (1 << 23)) >> 24;
+ vDelta[k] = (vCurr - vLast);
+ vLast = vCurr;
+ }
+
+ /* sort the deltas and find max delta for first region */
+ BubbleSort(vDelta, nBands0);
+ vDk0Max = VMax(vDelta, nBands0);
+
+ /* fill master frequency table with bands from first region */
+ freqMaster[0] = k0;
+ for (k = 1; k <= nBands0; k++) {
+ freqMaster[k] += freqMaster[k - 1];
+ }
+
+ /* if only one region, then the table is complete */
+ if (!twoRegions) {
+ return nBands0;
+ }
+
+ /* tested for all k1 = [10, 64], k2 = [k0, 64], freqScale = [1,3] */
+ t = (log2Tab[k2] - log2Tab[k1]) >> 3; /* log2(k1/k0), Q28 to Q25 */
+ t = MULSHIFT32(bands * t, invWarp) << 2; /* multiply by bands/2, divide by warp factor, keep Q25 */
+ nBands1 = 2 * ((t + (1 << 24)) >> 25); /* round to nearest int */
+
+ /* see comments above for calculations in first region */
+ t = RatioPowInv(k2, k1, nBands1);
+ pCurr = k1 << 24;
+ vLast = k1;
+ vDelta = freqMaster + nBands0 + 1; /* operate in-place */
+ for (k = 0; k < nBands1; k++) {
+ pCurr = MULSHIFT32(pCurr, t) << 8; /* keep in Q24 */
+ vCurr = (pCurr + (1 << 23)) >> 24;
+ vDelta[k] = (vCurr - vLast);
+ vLast = vCurr;
+ }
+
+ /* sort the deltas, adjusting first and last if the second region has smaller deltas than the first */
+ vDk1Min = VMin(vDelta, nBands1);
+ if (vDk1Min < vDk0Max) {
+ BubbleSort(vDelta, nBands1);
+ change = vDk0Max - vDelta[0];
+ if (change > ((vDelta[nBands1 - 1] - vDelta[0]) >> 1)) {
+ change = ((vDelta[nBands1 - 1] - vDelta[0]) >> 1);
+ }
+ vDelta[0] += change;
+ vDelta[nBands1 - 1] -= change;
+ }
+ BubbleSort(vDelta, nBands1);
+
+ /* fill master frequency table with bands from second region
+ * Note: freqMaster[nBands0] = k1
+ */
+ for (k = 1; k <= nBands1; k++) {
+ freqMaster[k + nBands0] += freqMaster[k + nBands0 - 1];
+ }
+
+ return (nBands0 + nBands1);
+}
+
+/**************************************************************************************
+ * Function: CalcFreqHigh
+ *
+ * Description: calculate high resolution frequency table (4.6.18.3.2.2)
+ *
+ * Inputs: master frequency table
+ * number of bands in master frequency table
+ * crossover band from header
+ *
+ * Outputs: high resolution frequency table
+ *
+ * Return: number of bands in high resolution frequency table
+ **************************************************************************************/
+static int CalcFreqHigh(unsigned char *freqHigh, unsigned char *freqMaster, int nMaster, int crossOverBand)
+{
+ int k, nHigh;
+
+ nHigh = nMaster - crossOverBand;
+
+ for (k = 0; k <= nHigh; k++) {
+ freqHigh[k] = freqMaster[k + crossOverBand];
+ }
+
+ return nHigh;
+}
+
+/**************************************************************************************
+ * Function: CalcFreqLow
+ *
+ * Description: calculate low resolution frequency table (4.6.18.3.2.2)
+ *
+ * Inputs: high resolution frequency table
+ * number of bands in high resolution frequency table
+ *
+ * Outputs: low resolution frequency table
+ *
+ * Return: number of bands in low resolution frequency table
+ **************************************************************************************/
+static int CalcFreqLow(unsigned char *freqLow, unsigned char *freqHigh, int nHigh)
+{
+ int k, nLow, oddFlag;
+
+ nLow = nHigh - (nHigh >> 1);
+ freqLow[0] = freqHigh[0];
+ oddFlag = nHigh & 0x01;
+
+ for (k = 1; k <= nLow; k++) {
+ freqLow[k] = freqHigh[2 * k - oddFlag];
+ }
+
+ return nLow;
+}
+
+/**************************************************************************************
+ * Function: CalcFreqNoise
+ *
+ * Description: calculate noise floor frequency table (4.6.18.3.2.2)
+ *
+ * Inputs: low resolution frequency table
+ * number of bands in low resolution frequency table
+ * index of starting QMF subband for SBR (kStart)
+ * index of last QMF subband (k2)
+ * number of noise bands
+ *
+ * Outputs: noise floor frequency table
+ *
+ * Return: number of bands in noise floor frequency table
+ **************************************************************************************/
+static int CalcFreqNoise(unsigned char *freqNoise, unsigned char *freqLow, int nLow, int kStart, int k2, int noiseBands)
+{
+ int i, iLast, k, nQ, lTop, lBottom;
+
+ lTop = log2Tab[k2];
+ lBottom = log2Tab[kStart];
+ nQ = noiseBands * ((lTop - lBottom) >> 2); /* Q28 to Q26, noiseBands = [0,3] */
+ nQ = (nQ + (1 << 25)) >> 26;
+ if (nQ < 1) {
+ nQ = 1;
+ }
+
+ ASSERT(nQ <= MAX_NUM_NOISE_FLOOR_BANDS); /* required from 4.6.18.3.6 */
+
+ iLast = 0;
+ freqNoise[0] = freqLow[0];
+ for (k = 1; k <= nQ; k++) {
+ i = iLast + (nLow - iLast) / (nQ + 1 - k); /* truncating division */
+ freqNoise[k] = freqLow[i];
+ iLast = i;
+ }
+
+ return nQ;
+}
+
+/**************************************************************************************
+ * Function: BuildPatches
+ *
+ * Description: build high frequency patches (4.6.18.6.3)
+ *
+ * Inputs: master frequency table
+ * number of bands in low resolution frequency table
+ * index of first QMF subband in master freq table (k0)
+ * index of starting QMF subband for SBR (kStart)
+ * number of QMF bands in high resolution frequency table
+ * sample rate index
+ *
+ * Outputs: starting subband for each patch
+ * number of subbands in each patch
+ *
+ * Return: number of patches
+ **************************************************************************************/
+static int BuildPatches(unsigned char *patchNumSubbands, unsigned char *patchStartSubband, unsigned char *freqMaster,
+ int nMaster, int k0, int kStart, int numQMFBands, int sampRateIdx)
+{
+ int i, j, k;
+ int msb, sb, usb, numPatches, goalSB, oddFlag;
+
+ msb = k0;
+ usb = kStart;
+ numPatches = 0;
+ goalSB = goalSBTab[sampRateIdx];
+
+ if (nMaster == 0) {
+ patchNumSubbands[0] = 0;
+ patchStartSubband[0] = 0;
+ return 0;
+ }
+
+ if (goalSB < kStart + numQMFBands) {
+ k = 0;
+ for (i = 0; freqMaster[i] < goalSB; i++) {
+ k = i + 1;
+ }
+ } else {
+ k = nMaster;
+ }
+
+ do {
+ j = k + 1;
+ do {
+ j--;
+ sb = freqMaster[j];
+ oddFlag = (sb - 2 + k0) & 0x01;
+ } while (sb > k0 - 1 + msb - oddFlag);
+
+ patchNumSubbands[numPatches] = MAX(sb - usb, 0);
+ patchStartSubband[numPatches] = k0 - oddFlag - patchNumSubbands[numPatches];
+
+ /* from MPEG reference code - slightly different from spec */
+ if ((patchNumSubbands[numPatches] < 3) && (numPatches > 0)) {
+ break;
+ }
+
+ if (patchNumSubbands[numPatches] > 0) {
+ usb = sb;
+ msb = sb;
+ numPatches++;
+ } else {
+ msb = kStart;
+ }
+
+ if (freqMaster[k] - sb < 3) {
+ k = nMaster;
+ }
+
+ } while (sb != (kStart + numQMFBands) && numPatches <= MAX_NUM_PATCHES);
+
+ return numPatches;
+}
+
+/**************************************************************************************
+ * Function: FindFreq
+ *
+ * Description: search buffer of unsigned chars for a specific value
+ *
+ * Inputs: buffer of elements to search
+ * number of elements to search
+ * value to search for
+ *
+ * Outputs: none
+ *
+ * Return: non-zero if the value is found anywhere in the buffer, zero otherwise
+ **************************************************************************************/
+static int FindFreq(unsigned char *freq, int nFreq, unsigned char val)
+{
+ int k;
+
+ for (k = 0; k < nFreq; k++) {
+ if (freq[k] == val) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: RemoveFreq
+ *
+ * Description: remove one element from a buffer of unsigned chars
+ *
+ * Inputs: buffer of elements
+ * number of elements
+ * index of element to remove
+ *
+ * Outputs: new buffer of length nFreq-1
+ *
+ * Return: none
+ **************************************************************************************/
+static void RemoveFreq(unsigned char *freq, int nFreq, int removeIdx)
+{
+ int k;
+
+ if (removeIdx >= nFreq) {
+ return;
+ }
+
+ for (k = removeIdx; k < nFreq - 1; k++) {
+ freq[k] = freq[k + 1];
+ }
+}
+
+/**************************************************************************************
+ * Function: CalcFreqLimiter
+ *
+ * Description: calculate limiter frequency table (4.6.18.3.2.3)
+ *
+ * Inputs: number of subbands in each patch
+ * low resolution frequency table
+ * number of bands in low resolution frequency table
+ * index of starting QMF subband for SBR (kStart)
+ * number of limiter bands
+ * number of patches
+ *
+ * Outputs: limiter frequency table
+ *
+ * Return: number of bands in limiter frequency table
+ **************************************************************************************/
+static int CalcFreqLimiter(unsigned char *freqLimiter, unsigned char *patchNumSubbands, unsigned char *freqLow,
+ int nLow, int kStart, int limiterBands, int numPatches)
+{
+ int k, bands, nLimiter, nOctaves;
+ int limBandsPerOctave[3] = {120, 200, 300}; /* [1.2, 2.0, 3.0] * 100 */
+ unsigned char patchBorders[MAX_NUM_PATCHES + 1];
+
+ /* simple case */
+ if (limiterBands == 0) {
+ freqLimiter[0] = freqLow[0] - kStart;
+ freqLimiter[1] = freqLow[nLow] - kStart;
+ return 1;
+ }
+
+ bands = limBandsPerOctave[limiterBands - 1];
+ patchBorders[0] = kStart;
+
+ /* from MPEG reference code - slightly different from spec (top border) */
+ for (k = 1; k < numPatches; k++) {
+ patchBorders[k] = patchBorders[k - 1] + patchNumSubbands[k - 1];
+ }
+ patchBorders[k] = freqLow[nLow];
+
+ for (k = 0; k <= nLow; k++) {
+ freqLimiter[k] = freqLow[k];
+ }
+
+ for (k = 1; k < numPatches; k++) {
+ freqLimiter[k + nLow] = patchBorders[k];
+ }
+
+ k = 1;
+ nLimiter = nLow + numPatches - 1;
+ BubbleSort(freqLimiter, nLimiter + 1);
+
+ while (k <= nLimiter) {
+ nOctaves = log2Tab[freqLimiter[k]] - log2Tab[freqLimiter[k - 1]]; /* Q28 */
+ nOctaves = (nOctaves >> 9) * bands; /* Q19, max bands = 300 < 2^9 */
+ if (nOctaves < (49 << 19)) { /* compare with 0.49*100, in Q19 */
+ if (freqLimiter[k] == freqLimiter[k - 1] || FindFreq(patchBorders, numPatches + 1, freqLimiter[k]) == 0) {
+ RemoveFreq(freqLimiter, nLimiter + 1, k);
+ nLimiter--;
+ } else if (FindFreq(patchBorders, numPatches + 1, freqLimiter[k - 1]) == 0) {
+ RemoveFreq(freqLimiter, nLimiter + 1, k - 1);
+ nLimiter--;
+ } else {
+ k++;
+ }
+ } else {
+ k++;
+ }
+ }
+
+ /* store limiter boundaries as offsets from kStart */
+ for (k = 0; k <= nLimiter; k++) {
+ freqLimiter[k] -= kStart;
+ }
+
+ return nLimiter;
+}
+
+/**************************************************************************************
+ * Function: CalcFreqTables
+ *
+ * Description: calulate master and derived frequency tables, and patches
+ *
+ * Inputs: initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRFreq struct for this SCE/CPE block
+ * sample rate index of output sample rate (after SBR)
+ *
+ * Outputs: master and derived frequency tables, and patches
+ *
+ * Return: non-zero if error, zero otherwise
+ **************************************************************************************/
+int CalcFreqTables(SBRHeader *sbrHdr, SBRFreq *sbrFreq, int sampRateIdx)
+{
+ int k0, k2;
+
+ k0 = k0Tab[sampRateIdx][sbrHdr->startFreq];
+
+ if (sbrHdr->stopFreq == 14) {
+ k2 = 2 * k0;
+ } else if (sbrHdr->stopFreq == 15) {
+ k2 = 3 * k0;
+ } else {
+ k2 = k2Tab[sampRateIdx][sbrHdr->stopFreq];
+ }
+ if (k2 > 64) {
+ k2 = 64;
+ }
+
+ /* calculate master frequency table */
+ if (sbrHdr->freqScale == 0) {
+ sbrFreq->nMaster = CalcFreqMasterScaleZero(sbrFreq->freqMaster, sbrHdr->alterScale, k0, k2);
+ } else {
+ sbrFreq->nMaster = CalcFreqMaster(sbrFreq->freqMaster, sbrHdr->freqScale, sbrHdr->alterScale, k0, k2);
+ }
+
+ /* calculate high frequency table and related parameters */
+ sbrFreq->nHigh = CalcFreqHigh(sbrFreq->freqHigh, sbrFreq->freqMaster, sbrFreq->nMaster, sbrHdr->crossOverBand);
+ sbrFreq->numQMFBands = sbrFreq->freqHigh[sbrFreq->nHigh] - sbrFreq->freqHigh[0];
+ sbrFreq->kStart = sbrFreq->freqHigh[0];
+
+ /* calculate low frequency table */
+ sbrFreq->nLow = CalcFreqLow(sbrFreq->freqLow, sbrFreq->freqHigh, sbrFreq->nHigh);
+
+ /* calculate noise floor frequency table */
+ sbrFreq->numNoiseFloorBands = CalcFreqNoise(sbrFreq->freqNoise, sbrFreq->freqLow, sbrFreq->nLow, sbrFreq->kStart, k2, sbrHdr->noiseBands);
+
+ /* calculate limiter table */
+ sbrFreq->numPatches = BuildPatches(sbrFreq->patchNumSubbands, sbrFreq->patchStartSubband, sbrFreq->freqMaster,
+ sbrFreq->nMaster, k0, sbrFreq->kStart, sbrFreq->numQMFBands, sampRateIdx);
+ sbrFreq->nLimiter = CalcFreqLimiter(sbrFreq->freqLimiter, sbrFreq->patchNumSubbands, sbrFreq->freqLow, sbrFreq->nLow, sbrFreq->kStart,
+ sbrHdr->limiterBands, sbrFreq->numPatches);
+
+ return 0;
+}
diff --git a/audio_codec/libraac/sbrhfadj.c b/audio_codec/libraac/sbrhfadj.c
new file mode 100644
index 0000000..f82e749
--- a/dev/null
+++ b/audio_codec/libraac/sbrhfadj.c
@@ -0,0 +1,877 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrhfadj.c,v 1.3 2005/05/24 16:01:55 albertofloyd Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrhfadj.c - high frequency adjustment for SBR
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+/* invBandTab[i] = 1.0 / (i + 1), Q31 */
+static const int invBandTab[64] = {
+ 0x7fffffff, 0x40000000, 0x2aaaaaab, 0x20000000, 0x1999999a, 0x15555555, 0x12492492, 0x10000000,
+ 0x0e38e38e, 0x0ccccccd, 0x0ba2e8ba, 0x0aaaaaab, 0x09d89d8a, 0x09249249, 0x08888889, 0x08000000,
+ 0x07878788, 0x071c71c7, 0x06bca1af, 0x06666666, 0x06186186, 0x05d1745d, 0x0590b216, 0x05555555,
+ 0x051eb852, 0x04ec4ec5, 0x04bda12f, 0x04924925, 0x0469ee58, 0x04444444, 0x04210842, 0x04000000,
+ 0x03e0f83e, 0x03c3c3c4, 0x03a83a84, 0x038e38e4, 0x03759f23, 0x035e50d8, 0x03483483, 0x03333333,
+ 0x031f3832, 0x030c30c3, 0x02fa0be8, 0x02e8ba2f, 0x02d82d83, 0x02c8590b, 0x02b93105, 0x02aaaaab,
+ 0x029cbc15, 0x028f5c29, 0x02828283, 0x02762762, 0x026a439f, 0x025ed098, 0x0253c825, 0x02492492,
+ 0x023ee090, 0x0234f72c, 0x022b63cc, 0x02222222, 0x02192e2a, 0x02108421, 0x02082082, 0x02000000,
+};
+
+/**************************************************************************************
+ * Function: EstimateEnvelope
+ *
+ * Description: estimate power of generated HF QMF bands in one time-domain envelope
+ * (4.6.18.7.3)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * index of current envelope
+ *
+ * Outputs: power of each QMF subband, stored as integer (Q0) * 2^N, N >= 0
+ *
+ * Return: none
+ **************************************************************************************/
+static void EstimateEnvelope(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, int env)
+{
+ int i, m, iStart, iEnd, xre, xim, nScale, expMax;
+ int p, n, mStart, mEnd, invFact, t;
+ int *XBuf;
+ U64 eCurr;
+ unsigned char *freqBandTab;
+
+ /* estimate current envelope */
+ iStart = sbrGrid->envTimeBorder[env] + HF_ADJ;
+ iEnd = sbrGrid->envTimeBorder[env + 1] + HF_ADJ;
+ if (sbrGrid->freqRes[env]) {
+ n = sbrFreq->nHigh;
+ freqBandTab = sbrFreq->freqHigh;
+ } else {
+ n = sbrFreq->nLow;
+ freqBandTab = sbrFreq->freqLow;
+ }
+
+ /* ADS should inline MADD64 (smlal) properly, but check to make sure */
+ expMax = 0;
+ if (sbrHdr->interpFreq) {
+ for (m = 0; m < sbrFreq->numQMFBands; m++) {
+ eCurr.w64 = 0;
+ XBuf = psi->XBuf[iStart][sbrFreq->kStart + m];
+ for (i = iStart; i < iEnd; i++) {
+ /* scale to int before calculating power (precision not critical, and avoids overflow) */
+ xre = (*XBuf) >> FBITS_OUT_QMFA;
+ XBuf += 1;
+ xim = (*XBuf) >> FBITS_OUT_QMFA;
+ XBuf += (2 * 64 - 1);
+ eCurr.w64 = MADD64(eCurr.w64, xre, xre);
+ eCurr.w64 = MADD64(eCurr.w64, xim, xim);
+ }
+
+ /* eCurr.w64 is now Q(64 - 2*FBITS_OUT_QMFA) (64-bit word)
+ * if energy is too big to fit in 32-bit word (> 2^31) scale down by power of 2
+ */
+ nScale = 0;
+ if (eCurr.r.hi32) {
+ nScale = (32 - CLZ(eCurr.r.hi32)) + 1;
+ t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */
+ t |= eCurr.r.hi32 << (32 - nScale);
+ } else if (eCurr.r.lo32 >> 31) {
+ nScale = 1;
+ t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */
+ } else {
+ t = (int)eCurr.r.lo32;
+ }
+
+ invFact = invBandTab[(iEnd - iStart) - 1];
+ psi->eCurr[m] = MULSHIFT32(t, invFact);
+ psi->eCurrExp[m] = nScale + 1; /* +1 for invFact = Q31 */
+ if (psi->eCurrExp[m] > expMax) {
+ expMax = psi->eCurrExp[m];
+ }
+ }
+ } else {
+ for (p = 0; p < n; p++) {
+ mStart = freqBandTab[p];
+ mEnd = freqBandTab[p + 1];
+ eCurr.w64 = 0;
+ for (i = iStart; i < iEnd; i++) {
+ XBuf = psi->XBuf[i][mStart];
+ for (m = mStart; m < mEnd; m++) {
+ xre = (*XBuf++) >> FBITS_OUT_QMFA;
+ xim = (*XBuf++) >> FBITS_OUT_QMFA;
+ eCurr.w64 = MADD64(eCurr.w64, xre, xre);
+ eCurr.w64 = MADD64(eCurr.w64, xim, xim);
+ }
+ }
+
+ nScale = 0;
+ if (eCurr.r.hi32) {
+ nScale = (32 - CLZ(eCurr.r.hi32)) + 1;
+ t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */
+ t |= eCurr.r.hi32 << (32 - nScale);
+ } else if (eCurr.r.lo32 >> 31) {
+ nScale = 1;
+ t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */
+ } else {
+ t = (int)eCurr.r.lo32;
+ }
+
+ invFact = invBandTab[(iEnd - iStart) - 1];
+ invFact = MULSHIFT32(invBandTab[(mEnd - mStart) - 1], invFact) << 1;
+ t = MULSHIFT32(t, invFact);
+
+ for (m = mStart; m < mEnd; m++) {
+ psi->eCurr[m - sbrFreq->kStart] = t;
+ psi->eCurrExp[m - sbrFreq->kStart] = nScale + 1; /* +1 for invFact = Q31 */
+ }
+ if (psi->eCurrExp[mStart - sbrFreq->kStart] > expMax) {
+ expMax = psi->eCurrExp[mStart - sbrFreq->kStart];
+ }
+ }
+ }
+ psi->eCurrExpMax = expMax;
+}
+
+/**************************************************************************************
+ * Function: GetSMapped
+ *
+ * Description: calculate SMapped (4.6.18.7.2)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current envelope
+ * index of current QMF band
+ * la flag for this envelope
+ *
+ * Outputs: none
+ *
+ * Return: 1 if a sinusoid is present in this band, 0 if not
+ **************************************************************************************/
+static int GetSMapped(SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int env, int band, int la)
+{
+ int bandStart, bandEnd, oddFlag, r;
+
+ if (sbrGrid->freqRes[env]) {
+ /* high resolution */
+ bandStart = band;
+ bandEnd = band + 1;
+ } else {
+ /* low resolution (see CalcFreqLow() for mapping) */
+ oddFlag = sbrFreq->nHigh & 0x01;
+ bandStart = (band > 0 ? 2 * band - oddFlag : 0); /* starting index for freqLow[band] */
+ bandEnd = 2 * (band + 1) - oddFlag; /* ending index for freqLow[band+1] */
+ }
+
+ /* sMapped = 1 if sIndexMapped == 1 for any frequency in this band */
+ for (band = bandStart; band < bandEnd; band++) {
+ if (sbrChan->addHarmonic[1][band]) {
+ r = ((sbrFreq->freqHigh[band + 1] + sbrFreq->freqHigh[band]) >> 1);
+ if (env >= la || sbrChan->addHarmonic[0][r] == 1) {
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+#define GBOOST_MAX 0x2830afd3 /* Q28, 1.584893192 squared */
+#define ACC_SCALE 6
+
+/* squared version of table in 4.6.18.7.5 */
+static const int limGainTab[4] = {0x20138ca7, 0x40000000, 0x7fb27dce, 0x80000000}; /* Q30 (0x80000000 = sentinel for GMAX) */
+
+/**************************************************************************************
+ * Function: CalcMaxGain
+ *
+ * Description: calculate max gain in one limiter band (4.6.18.7.5)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ * index of current envelope
+ * index of current limiter band
+ * number of fraction bits in dequantized envelope
+ * (max = Q(FBITS_OUT_DQ_ENV - 6) = Q23, can go negative)
+ *
+ * Outputs: updated gainMax, gainMaxFBits, and sumEOrigMapped in PSInfoSBR struct
+ *
+ * Return: none
+ **************************************************************************************/
+static void CalcMaxGain(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, int ch, int env, int lim, int fbitsDQ)
+{
+ int m, mStart, mEnd, q, z, r;
+ int sumEOrigMapped, sumECurr, gainMax, eOMGainMax, envBand;
+ unsigned char eCurrExpMax;
+ unsigned char *freqBandTab;
+
+ mStart = sbrFreq->freqLimiter[lim]; /* these are offsets from kStart */
+ mEnd = sbrFreq->freqLimiter[lim + 1];
+ freqBandTab = (sbrGrid->freqRes[env] ? sbrFreq->freqHigh : sbrFreq->freqLow);
+
+ /* calculate max gain to apply to signal in this limiter band */
+ sumECurr = 0;
+ sumEOrigMapped = 0;
+ eCurrExpMax = psi->eCurrExpMax;
+ eOMGainMax = psi->eOMGainMax;
+ envBand = psi->envBand;
+ for (m = mStart; m < mEnd; m++) {
+ /* map current QMF band to appropriate envelope band */
+ if (m == freqBandTab[envBand + 1] - sbrFreq->kStart) {
+ envBand++;
+ eOMGainMax = psi->envDataDequant[ch][env][envBand] >> ACC_SCALE; /* summing max 48 bands */
+ }
+ sumEOrigMapped += eOMGainMax;
+
+ /* easy test for overflow on ARM */
+ sumECurr += (psi->eCurr[m] >> (eCurrExpMax - psi->eCurrExp[m]));
+ if (sumECurr >> 30) {
+ sumECurr >>= 1;
+ eCurrExpMax++;
+ }
+ }
+ psi->eOMGainMax = eOMGainMax;
+ psi->envBand = envBand;
+
+ psi->gainMaxFBits = 30; /* Q30 tables */
+ if (sumECurr == 0) {
+ /* any non-zero numerator * 1/EPS_0 is > G_MAX */
+ gainMax = (sumEOrigMapped == 0 ? limGainTab[sbrHdr->limiterGains] : 0x80000000);
+ } else if (sumEOrigMapped == 0) {
+ /* 1/(any non-zero denominator) * EPS_0 * limGainTab[x] is appx. 0 */
+ gainMax = 0;
+ } else {
+ /* sumEOrigMapped = Q(fbitsDQ - ACC_SCALE), sumECurr = Q(-eCurrExpMax) */
+ gainMax = limGainTab[sbrHdr->limiterGains];
+ if (sbrHdr->limiterGains != 3) {
+ q = MULSHIFT32(sumEOrigMapped, gainMax); /* Q(fbitsDQ - ACC_SCALE - 2), gainMax = Q30 */
+ z = CLZ(sumECurr) - 1;
+ r = InvRNormalized(sumECurr << z); /* in = Q(z - eCurrExpMax), out = Q(29 + 31 - z + eCurrExpMax) */
+ gainMax = MULSHIFT32(q, r); /* Q(29 + 31 - z + eCurrExpMax + fbitsDQ - ACC_SCALE - 2 - 32) */
+ psi->gainMaxFBits = 26 - z + eCurrExpMax + fbitsDQ - ACC_SCALE;
+ }
+ }
+ psi->sumEOrigMapped = sumEOrigMapped;
+ psi->gainMax = gainMax;
+}
+
+/**************************************************************************************
+ * Function: CalcNoiseDivFactors
+ *
+ * Description: calculate 1/(1+Q) and Q/(1+Q) (4.6.18.7.4; 4.6.18.7.5)
+ *
+ * Inputs: dequantized noise floor scalefactor
+ *
+ * Outputs: 1/(1+Q) and Q/(1+Q), format = Q31
+ *
+ * Return: none
+ **************************************************************************************/
+static void CalcNoiseDivFactors(int q, int *qp1Inv, int *qqp1Inv)
+{
+ int z, qp1, t, s;
+
+ /* 1 + Q_orig */
+ qp1 = (q >> 1);
+ qp1 += (1 << (FBITS_OUT_DQ_NOISE - 1)); /* >> 1 to avoid overflow when adding 1.0 */
+ z = CLZ(qp1) - 1; /* z <= 31 - FBITS_OUT_DQ_NOISE */
+ qp1 <<= z; /* Q(FBITS_OUT_DQ_NOISE + z) = Q31 * 2^-(31 - (FBITS_OUT_DQ_NOISE + z)) */
+ t = InvRNormalized(qp1) << 1; /* Q30 * 2^(31 - (FBITS_OUT_DQ_NOISE + z)), guaranteed not to overflow */
+
+ /* normalize to Q31 */
+ s = (31 - (FBITS_OUT_DQ_NOISE - 1) - z - 1); /* clearly z >= 0, z <= (30 - (FBITS_OUT_DQ_NOISE - 1)) */
+ *qp1Inv = (t >> s); /* s = [0, 31 - FBITS_OUT_DQ_NOISE] */
+ *qqp1Inv = MULSHIFT32(t, q) << (32 - FBITS_OUT_DQ_NOISE - s);
+}
+
+/**************************************************************************************
+ * Function: CalcComponentGains
+ *
+ * Description: calculate gain of envelope, sinusoids, and noise in one limiter band
+ * (4.6.18.7.5)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ * index of current envelope
+ * index of current limiter band
+ * number of fraction bits in dequantized envelope
+ *
+ * Outputs: gains for envelope, sinusoids and noise
+ * number of fraction bits for envelope gain
+ * sum of the total gain for each component in this band
+ * other updated state variables
+ *
+ * Return: none
+ **************************************************************************************/
+static void CalcComponentGains(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch, int env, int lim, int fbitsDQ)
+{
+ int d, m, mStart, mEnd, q, qm, noiseFloor, sIndexMapped;
+ int shift, eCurr, maxFlag, gainMax, gainMaxFBits;
+ int gain, sm, z, r, fbitsGain, gainScale;
+ unsigned char *freqBandTab;
+
+ mStart = sbrFreq->freqLimiter[lim]; /* these are offsets from kStart */
+ mEnd = sbrFreq->freqLimiter[lim + 1];
+
+ gainMax = psi->gainMax;
+ gainMaxFBits = psi->gainMaxFBits;
+
+ d = (env == psi->la || env == sbrChan->laPrev ? 0 : 1);
+ freqBandTab = (sbrGrid->freqRes[env] ? sbrFreq->freqHigh : sbrFreq->freqLow);
+
+ /* figure out which noise floor this envelope is in (only 1 or 2 noise floors allowed) */
+ noiseFloor = 0;
+ if (sbrGrid->numNoiseFloors == 2 && sbrGrid->noiseTimeBorder[1] <= sbrGrid->envTimeBorder[env]) {
+ noiseFloor++;
+ }
+
+ psi->sumECurrGLim = 0;
+ psi->sumSM = 0;
+ psi->sumQM = 0;
+ /* calculate energy of noise to add in this limiter band */
+ for (m = mStart; m < mEnd; m++) {
+ if (m == sbrFreq->freqNoise[psi->noiseFloorBand + 1] - sbrFreq->kStart) {
+ /* map current QMF band to appropriate noise floor band (NOTE: freqLimiter[0] == freqLow[0] = freqHigh[0]) */
+ psi->noiseFloorBand++;
+ CalcNoiseDivFactors(psi->noiseDataDequant[ch][noiseFloor][psi->noiseFloorBand], &(psi->qp1Inv), &(psi->qqp1Inv));
+ }
+ if (m == sbrFreq->freqHigh[psi->highBand + 1] - sbrFreq->kStart) {
+ psi->highBand++;
+ }
+ if (m == freqBandTab[psi->sBand + 1] - sbrFreq->kStart) {
+ psi->sBand++;
+ psi->sMapped = GetSMapped(sbrGrid, sbrFreq, sbrChan, env, psi->sBand, psi->la);
+ }
+
+ /* get sIndexMapped for this QMF subband */
+ sIndexMapped = 0;
+ r = ((sbrFreq->freqHigh[psi->highBand + 1] + sbrFreq->freqHigh[psi->highBand]) >> 1);
+ if (m + sbrFreq->kStart == r) {
+ /* r = center frequency, deltaStep = (env >= la || sIndexMapped'(r, numEnv'-1) == 1) */
+ if (env >= psi->la || sbrChan->addHarmonic[0][r] == 1) {
+ sIndexMapped = sbrChan->addHarmonic[1][psi->highBand];
+ }
+ }
+
+ /* save sine flags from last envelope in this frame:
+ * addHarmonic[0][0...63] = saved sine present flag from previous frame, for each QMF subband
+ * addHarmonic[1][0...nHigh-1] = addHarmonic bit from current frame, for each high-res frequency band
+ * from MPEG reference code - slightly different from spec
+ * (sIndexMapped'(m,LE'-1) can still be 0 when numEnv == psi->la)
+ */
+ if (env == sbrGrid->numEnv - 1) {
+ if (m + sbrFreq->kStart == r) {
+ sbrChan->addHarmonic[0][m + sbrFreq->kStart] = sbrChan->addHarmonic[1][psi->highBand];
+ } else {
+ sbrChan->addHarmonic[0][m + sbrFreq->kStart] = 0;
+ }
+ }
+
+ gain = psi->envDataDequant[ch][env][psi->sBand];
+ qm = MULSHIFT32(gain, psi->qqp1Inv) << 1;
+ sm = (sIndexMapped ? MULSHIFT32(gain, psi->qp1Inv) << 1 : 0);
+
+ /* three cases: (sMapped == 0 && delta == 1), (sMapped == 0 && delta == 0), (sMapped == 1) */
+ if (d == 1 && psi->sMapped == 0) {
+ gain = MULSHIFT32(psi->qp1Inv, gain) << 1;
+ } else if (psi->sMapped != 0) {
+ gain = MULSHIFT32(psi->qqp1Inv, gain) << 1;
+ }
+
+ /* gain, qm, sm = Q(fbitsDQ), gainMax = Q(fbitsGainMax) */
+ eCurr = psi->eCurr[m];
+ if (eCurr) {
+ z = CLZ(eCurr) - 1;
+ r = InvRNormalized(eCurr << z); /* in = Q(z - eCurrExp), out = Q(29 + 31 - z + eCurrExp) */
+ gainScale = MULSHIFT32(gain, r); /* out = Q(29 + 31 - z + eCurrExp + fbitsDQ - 32) */
+ fbitsGain = 29 + 31 - z + psi->eCurrExp[m] + fbitsDQ - 32;
+ } else {
+ /* if eCurr == 0, then gain is unchanged (divide by EPS = 1) */
+ gainScale = gain;
+ fbitsGain = fbitsDQ;
+ }
+
+ /* see if gain for this band exceeds max gain */
+ maxFlag = 0;
+ if (gainMax != (int)0x80000000) {
+ if (fbitsGain >= gainMaxFBits) {
+ shift = MIN(fbitsGain - gainMaxFBits, 31);
+ maxFlag = ((gainScale >> shift) > gainMax ? 1 : 0);
+ } else {
+ shift = MIN(gainMaxFBits - fbitsGain, 31);
+ maxFlag = (gainScale > (gainMax >> shift) ? 1 : 0);
+ }
+ }
+
+ if (maxFlag) {
+ /* gainScale > gainMax, calculate ratio with 32/16 division */
+ q = 0;
+ r = gainScale; /* guaranteed > 0, else maxFlag could not have been set */
+ z = CLZ(r);
+ if (z < 16) {
+ q = 16 - z;
+ r >>= q; /* out = Q(fbitsGain - q) */
+ }
+
+ z = CLZ(gainMax) - 1;
+ r = (gainMax << z) / r; /* out = Q((fbitsGainMax + z) - (fbitsGain - q)) */
+ q = (gainMaxFBits + z) - (fbitsGain - q); /* r = Q(q) */
+ if (q > 30) {
+ r >>= MIN(q - 30, 31);
+ } else {
+ z = MIN(30 - q, 30);
+ CLIP_2N_SHIFT30(r, z); /* let r = Q30 since range = [0.0, 1.0) (clip to 0x3fffffff = 0.99999) */
+ }
+
+ qm = MULSHIFT32(qm, r) << 2;
+ gain = MULSHIFT32(gain, r) << 2;
+ psi->gLimBuf[m] = gainMax;
+ psi->gLimFbits[m] = gainMaxFBits;
+ } else {
+ psi->gLimBuf[m] = gainScale;
+ psi->gLimFbits[m] = fbitsGain;
+ }
+
+ /* sumSM, sumQM, sumECurrGLim = Q(fbitsDQ - ACC_SCALE) */
+ psi->smBuf[m] = sm;
+ psi->sumSM += (sm >> ACC_SCALE);
+
+ psi->qmLimBuf[m] = qm;
+ if (env != psi->la && env != sbrChan->laPrev && sm == 0) {
+ psi->sumQM += (qm >> ACC_SCALE);
+ }
+
+ /* eCurr * gain^2 same as gain^2, before division by eCurr
+ * (but note that gain != 0 even if eCurr == 0, since it's divided by eps)
+ */
+ if (eCurr) {
+ psi->sumECurrGLim += (gain >> ACC_SCALE);
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: ApplyBoost
+ *
+ * Description: calculate and apply boost factor for envelope, sinusoids, and noise
+ * in this limiter band (4.6.18.7.5)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRFreq struct for this SCE/CPE block
+ * index of current limiter band
+ * number of fraction bits in dequantized envelope
+ *
+ * Outputs: envelope gain, sinusoids and noise after scaling by gBoost
+ * format = Q(FBITS_GLIM_BOOST) for envelope gain,
+ * = Q(FBITS_QLIM_BOOST) for noise
+ * = Q(FBITS_OUT_QMFA) for sinusoids
+ *
+ * Return: none
+ *
+ * Notes: after scaling, each component has at least 1 GB
+ **************************************************************************************/
+static void ApplyBoost(PSInfoSBR *psi, SBRFreq *sbrFreq, int lim, int fbitsDQ)
+{
+ int m, mStart, mEnd, q, z, r;
+ int sumEOrigMapped, gBoost;
+
+ mStart = sbrFreq->freqLimiter[lim]; /* these are offsets from kStart */
+ mEnd = sbrFreq->freqLimiter[lim + 1];
+
+ sumEOrigMapped = psi->sumEOrigMapped >> 1;
+ r = (psi->sumECurrGLim >> 1) + (psi->sumSM >> 1) + (psi->sumQM >> 1); /* 1 GB fine (sm and qm are mutually exclusive in acc) */
+ if (r < (1 << (31 - 28))) {
+ /* any non-zero numerator * 1/EPS_0 is > GBOOST_MAX
+ * round very small r to zero to avoid scaling problems
+ */
+ gBoost = (sumEOrigMapped == 0 ? (1 << 28) : GBOOST_MAX);
+ z = 0;
+ } else if (sumEOrigMapped == 0) {
+ /* 1/(any non-zero denominator) * EPS_0 is appx. 0 */
+ gBoost = 0;
+ z = 0;
+ } else {
+ /* numerator (sumEOrigMapped) and denominator (r) have same Q format (before << z) */
+ z = CLZ(r) - 1; /* z = [0, 27] */
+ r = InvRNormalized(r << z);
+ gBoost = MULSHIFT32(sumEOrigMapped, r);
+ }
+
+ /* gBoost = Q(28 - z) */
+ if (gBoost > (GBOOST_MAX >> z)) {
+ gBoost = GBOOST_MAX;
+ z = 0;
+ }
+ gBoost <<= z; /* gBoost = Q28, minimum 1 GB */
+
+ /* convert gain, noise, sinusoids to fixed Q format, clipping if necessary
+ * (rare, usually only happens at very low bitrates, introduces slight
+ * distortion into final HF mapping, but should be inaudible)
+ */
+ for (m = mStart; m < mEnd; m++) {
+ /* let gLimBoost = Q24, since in practice the max values are usually 16 to 20
+ * unless limiterGains == 3 (limiter off) and eCurr ~= 0 (i.e. huge gain, but only
+ * because the envelope has 0 power anyway)
+ */
+ q = MULSHIFT32(psi->gLimBuf[m], gBoost) << 2; /* Q(gLimFbits) * Q(28) --> Q(gLimFbits[m]-2) */
+ r = SqrtFix(q, psi->gLimFbits[m] - 2, &z);
+ z -= FBITS_GLIM_BOOST;
+ if (z >= 0) {
+ psi->gLimBoost[m] = r >> MIN(z, 31);
+ } else {
+ z = MIN(30, -z);
+ CLIP_2N_SHIFT30(r, z);
+ psi->gLimBoost[m] = r;
+ }
+
+ q = MULSHIFT32(psi->qmLimBuf[m], gBoost) << 2; /* Q(fbitsDQ) * Q(28) --> Q(fbitsDQ-2) */
+ r = SqrtFix(q, fbitsDQ - 2, &z);
+ z -= FBITS_QLIM_BOOST; /* << by 14, since integer sqrt of x < 2^16, and we want to leave 1 GB */
+ if (z >= 0) {
+ psi->qmLimBoost[m] = r >> MIN(31, z);
+ } else {
+ z = MIN(30, -z);
+ CLIP_2N_SHIFT30(r, z);
+ psi->qmLimBoost[m] = r;
+ }
+
+ q = MULSHIFT32(psi->smBuf[m], gBoost) << 2; /* Q(fbitsDQ) * Q(28) --> Q(fbitsDQ-2) */
+ r = SqrtFix(q, fbitsDQ - 2, &z);
+ z -= FBITS_OUT_QMFA; /* justify for adding to signal (xBuf) later */
+ if (z >= 0) {
+ psi->smBoost[m] = r >> MIN(31, z);
+ } else {
+ z = MIN(30, -z);
+ CLIP_2N_SHIFT30(r, z);
+ psi->smBoost[m] = r;
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: CalcGain
+ *
+ * Description: calculate and apply proper gain to HF components in one envelope
+ * (4.6.18.7.5)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ * index of current envelope
+ *
+ * Outputs: envelope gain, sinusoids and noise after scaling
+ *
+ * Return: none
+ **************************************************************************************/
+static void CalcGain(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch, int env)
+{
+ int lim, fbitsDQ;
+
+ /* initialize to -1 so that mapping limiter bands to env/noise bands works right on first pass */
+ psi->envBand = -1;
+ psi->noiseFloorBand = -1;
+ psi->sBand = -1;
+ psi->highBand = -1;
+
+ fbitsDQ = (FBITS_OUT_DQ_ENV - psi->envDataDequantScale[ch][env]); /* Q(29 - optional scalefactor) */
+ for (lim = 0; lim < sbrFreq->nLimiter; lim++) {
+ /* the QMF bands are divided into lim regions (consecutive, non-overlapping) */
+ CalcMaxGain(psi, sbrHdr, sbrGrid, sbrFreq, ch, env, lim, fbitsDQ);
+ CalcComponentGains(psi, sbrGrid, sbrFreq, sbrChan, ch, env, lim, fbitsDQ);
+ ApplyBoost(psi, sbrFreq, lim, fbitsDQ);
+ }
+}
+
+/* hSmooth table from 4.7.18.7.6, format = Q31 */
+static const int hSmoothCoef[MAX_NUM_SMOOTH_COEFS] = {
+ 0x2aaaaaab, 0x2697a512, 0x1becfa68, 0x0ebdb043, 0x04130598,
+};
+
+/**************************************************************************************
+ * Function: MapHF
+ *
+ * Description: map HF components to proper QMF bands, with optional gain smoothing
+ * filter (4.6.18.7.6)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current envelope
+ * reset flag (can be non-zero for first envelope only)
+ *
+ * Outputs: complete reconstructed subband QMF samples for this envelope
+ *
+ * Return: none
+ *
+ * Notes: ensures that output has >= MIN_GBITS_IN_QMFS guard bits,
+ * so it's not necessary to check anything in the synth QMF
+ **************************************************************************************/
+static void MapHF(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int env, int hfReset)
+{
+ int noiseTabIndex, sinIndex, gainNoiseIndex, hSL;
+ int i, iStart, iEnd, m, idx, j, s, n, smre, smim;
+ int gFilt, qFilt, xre, xim, gbMask, gbIdx;
+ int *XBuf;
+
+ noiseTabIndex = sbrChan->noiseTabIndex;
+ sinIndex = sbrChan->sinIndex;
+ gainNoiseIndex = sbrChan->gainNoiseIndex; /* oldest entries in filter delay buffer */
+
+ if (hfReset) {
+ noiseTabIndex = 2; /* starts at 1, double since complex */
+ }
+ hSL = (sbrHdr->smoothMode ? 0 : 4);
+
+ if (hfReset) {
+ for (i = 0; i < hSL; i++) {
+ for (m = 0; m < sbrFreq->numQMFBands; m++) {
+ sbrChan->gTemp[gainNoiseIndex][m] = psi->gLimBoost[m];
+ sbrChan->qTemp[gainNoiseIndex][m] = psi->qmLimBoost[m];
+ }
+ gainNoiseIndex++;
+ if (gainNoiseIndex == MAX_NUM_SMOOTH_COEFS) {
+ gainNoiseIndex = 0;
+ }
+ }
+ ASSERT(env == 0); /* should only be reset when env == 0 */
+ }
+
+ iStart = sbrGrid->envTimeBorder[env];
+ iEnd = sbrGrid->envTimeBorder[env + 1];
+ for (i = iStart; i < iEnd; i++) {
+ /* save new values in temp buffers (delay)
+ * we only store MAX_NUM_SMOOTH_COEFS most recent values,
+ * so don't keep storing the same value over and over
+ */
+ if (i - iStart < MAX_NUM_SMOOTH_COEFS) {
+ for (m = 0; m < sbrFreq->numQMFBands; m++) {
+ sbrChan->gTemp[gainNoiseIndex][m] = psi->gLimBoost[m];
+ sbrChan->qTemp[gainNoiseIndex][m] = psi->qmLimBoost[m];
+ }
+ }
+
+ /* see 4.6.18.7.6 */
+ XBuf = psi->XBuf[i + HF_ADJ][sbrFreq->kStart];
+ gbMask = 0;
+ for (m = 0; m < sbrFreq->numQMFBands; m++) {
+ if (env == psi->la || env == sbrChan->laPrev) {
+ /* no smoothing filter for gain, and qFilt = 0 (only need to do once) */
+ if (i == iStart) {
+ psi->gFiltLast[m] = sbrChan->gTemp[gainNoiseIndex][m];
+ psi->qFiltLast[m] = 0;
+ }
+ } else if (hSL == 0) {
+ /* no smoothing filter for gain, (only need to do once) */
+ if (i == iStart) {
+ psi->gFiltLast[m] = sbrChan->gTemp[gainNoiseIndex][m];
+ psi->qFiltLast[m] = sbrChan->qTemp[gainNoiseIndex][m];
+ }
+ } else {
+ /* apply smoothing filter to gain and noise (after MAX_NUM_SMOOTH_COEFS, it's always the same) */
+ if (i - iStart < MAX_NUM_SMOOTH_COEFS) {
+ gFilt = 0;
+ qFilt = 0;
+ idx = gainNoiseIndex;
+ for (j = 0; j < MAX_NUM_SMOOTH_COEFS; j++) {
+ /* sum(abs(hSmoothCoef[j])) for all j < 1.0 */
+ gFilt += MULSHIFT32(sbrChan->gTemp[idx][m], hSmoothCoef[j]);
+ qFilt += MULSHIFT32(sbrChan->qTemp[idx][m], hSmoothCoef[j]);
+ idx--;
+ if (idx < 0) {
+ idx += MAX_NUM_SMOOTH_COEFS;
+ }
+ }
+ psi->gFiltLast[m] = gFilt << 1; /* restore to Q(FBITS_GLIM_BOOST) (gain of filter < 1.0, so no overflow) */
+ psi->qFiltLast[m] = qFilt << 1; /* restore to Q(FBITS_QLIM_BOOST) */
+ }
+ }
+
+ if (psi->smBoost[m] != 0) {
+ /* add scaled signal and sinusoid, don't add noise (qFilt = 0) */
+ smre = psi->smBoost[m];
+ smim = smre;
+
+ /* sinIndex: [0] xre += sm [1] xim += sm*s [2] xre -= sm [3] xim -= sm*s */
+ s = (sinIndex >> 1); /* if 2 or 3, flip sign to subtract sm */
+ s <<= 31;
+ smre ^= (s >> 31);
+ smre -= (s >> 31);
+ s ^= ((m + sbrFreq->kStart) << 31);
+ smim ^= (s >> 31);
+ smim -= (s >> 31);
+
+ /* if sinIndex == 0 or 2, smim = 0; if sinIndex == 1 or 3, smre = 0 */
+ s = sinIndex << 31;
+ smim &= (s >> 31);
+ s ^= 0x80000000;
+ smre &= (s >> 31);
+
+ noiseTabIndex += 2; /* noise filtered by 0, but still need to bump index */
+ } else {
+ /* add scaled signal and scaled noise */
+ qFilt = psi->qFiltLast[m];
+ n = noiseTab[noiseTabIndex++];
+ smre = MULSHIFT32(n, qFilt) >> (FBITS_QLIM_BOOST - 1 - FBITS_OUT_QMFA);
+
+ n = noiseTab[noiseTabIndex++];
+ smim = MULSHIFT32(n, qFilt) >> (FBITS_QLIM_BOOST - 1 - FBITS_OUT_QMFA);
+ }
+ noiseTabIndex &= 1023; /* 512 complex numbers */
+
+ gFilt = psi->gFiltLast[m];
+ xre = MULSHIFT32(gFilt, XBuf[0]);
+ xim = MULSHIFT32(gFilt, XBuf[1]);
+ CLIP_2N_SHIFT30(xre, 32 - FBITS_GLIM_BOOST);
+ CLIP_2N_SHIFT30(xim, 32 - FBITS_GLIM_BOOST);
+
+ xre += smre;
+ *XBuf++ = xre;
+ xim += smim;
+ *XBuf++ = xim;
+
+ gbMask |= FASTABS(xre);
+ gbMask |= FASTABS(xim);
+ }
+ /* update circular buffer index */
+ gainNoiseIndex++;
+ if (gainNoiseIndex == MAX_NUM_SMOOTH_COEFS) {
+ gainNoiseIndex = 0;
+ }
+
+ sinIndex++;
+ sinIndex &= 3;
+
+ /* ensure MIN_GBITS_IN_QMFS guard bits in output
+ * almost never occurs in practice, but checking here makes synth QMF logic very simple
+ */
+ if (gbMask >> (31 - MIN_GBITS_IN_QMFS)) {
+ XBuf = psi->XBuf[i + HF_ADJ][sbrFreq->kStart];
+ for (m = 0; m < sbrFreq->numQMFBands; m++) {
+ xre = XBuf[0];
+ xim = XBuf[1];
+ CLIP_2N(xre, (31 - MIN_GBITS_IN_QMFS));
+ CLIP_2N(xim, (31 - MIN_GBITS_IN_QMFS));
+ *XBuf++ = xre;
+ *XBuf++ = xim;
+ }
+ CLIP_2N(gbMask, (31 - MIN_GBITS_IN_QMFS));
+ }
+ gbIdx = ((i + HF_ADJ) >> 5) & 0x01;
+ sbrChan->gbMask[gbIdx] |= gbMask;
+ }
+ sbrChan->noiseTabIndex = noiseTabIndex;
+ sbrChan->sinIndex = sinIndex;
+ sbrChan->gainNoiseIndex = gainNoiseIndex;
+}
+
+/**************************************************************************************
+ * Function: AdjustHighFreq
+ *
+ * Description: adjust high frequencies and add noise and sinusoids (4.6.18.7)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ *
+ * Outputs: complete reconstructed subband QMF samples for this channel
+ *
+ * Return: none
+ **************************************************************************************/
+void AdjustHighFreq(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch)
+{
+ int i, env, hfReset;
+ unsigned char frameClass, pointer;
+
+ frameClass = sbrGrid->frameClass;
+ pointer = sbrGrid->pointer;
+
+ /* derive la from table 4.159 */
+ if ((frameClass == SBR_GRID_FIXVAR || frameClass == SBR_GRID_VARVAR) && pointer > 0) {
+ psi->la = sbrGrid->numEnv + 1 - pointer;
+ } else if (frameClass == SBR_GRID_VARFIX && pointer > 1) {
+ psi->la = pointer - 1;
+ } else {
+ psi->la = -1;
+ }
+
+ /* for each envelope, estimate gain and adjust SBR QMF bands */
+ hfReset = sbrChan->reset;
+ for (env = 0; env < sbrGrid->numEnv; env++) {
+ EstimateEnvelope(psi, sbrHdr, sbrGrid, sbrFreq, env);
+ CalcGain(psi, sbrHdr, sbrGrid, sbrFreq, sbrChan, ch, env);
+ MapHF(psi, sbrHdr, sbrGrid, sbrFreq, sbrChan, env, hfReset);
+ hfReset = 0; /* only set for first envelope after header reset */
+ }
+
+ /* set saved sine flags to 0 for QMF bands outside of current frequency range */
+ for (i = 0; i < sbrFreq->freqLimiter[0] + sbrFreq->kStart; i++) {
+ sbrChan->addHarmonic[0][i] = 0;
+ }
+ for (i = sbrFreq->freqLimiter[sbrFreq->nLimiter] + sbrFreq->kStart; i < 64; i++) {
+ sbrChan->addHarmonic[0][i] = 0;
+ }
+ sbrChan->addHarmonicFlag[0] = sbrChan->addHarmonicFlag[1];
+
+ /* save la for next frame */
+ if (psi->la == sbrGrid->numEnv) {
+ sbrChan->laPrev = 0;
+ } else {
+ sbrChan->laPrev = -1;
+ }
+}
diff --git a/audio_codec/libraac/sbrhfgen.c b/audio_codec/libraac/sbrhfgen.c
new file mode 100644
index 0000000..6be4d57
--- a/dev/null
+++ b/audio_codec/libraac/sbrhfgen.c
@@ -0,0 +1,646 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrhfgen.c,v 1.2 2005/05/19 20:45:20 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrhfgen.c - high frequency generation for SBR
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+#define FBITS_LPCOEFS 29 /* Q29 for range of (-4, 4) */
+#define MAG_16 (16 * (1 << (32 - (2*(32-FBITS_LPCOEFS))))) /* i.e. 16 in Q26 format */
+#define RELAX_COEF 0x7ffff79c /* 1.0 / (1.0 + 1e-6), Q31 */
+
+/* newBWTab[prev invfMode][curr invfMode], format = Q31 (table 4.158)
+ * sample file which uses all of these: al_sbr_sr_64_2_fsaac32.aac
+ */
+static const int newBWTab[4][4] = {
+ {0x00000000, 0x4ccccccd, 0x73333333, 0x7d70a3d7},
+ {0x4ccccccd, 0x60000000, 0x73333333, 0x7d70a3d7},
+ {0x00000000, 0x60000000, 0x73333333, 0x7d70a3d7},
+ {0x00000000, 0x60000000, 0x73333333, 0x7d70a3d7},
+};
+
+/**************************************************************************************
+ * Function: CVKernel1
+ *
+ * Description: kernel of covariance matrix calculation for p01, p11, p12, p22
+ *
+ * Inputs: buffer of low-freq samples, starting at time index = 0,
+ * freq index = patch subband
+ *
+ * Outputs: 64-bit accumulators for p01re, p01im, p12re, p12im, p11re, p22re
+ * stored in accBuf
+ *
+ * Return: none
+ *
+ * Notes: this is carefully written to be efficient on ARM
+ * use the assembly code version in sbrcov.s when building for ARM!
+ **************************************************************************************/
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+void CVKernel1(int *XBuf, int *accBuf)
+{
+ U64 p01re, p01im, p12re, p12im, p11re, p22re;
+ int n, x0re, x0im, x1re, x1im;
+
+ x0re = XBuf[0];
+ x0im = XBuf[1];
+ XBuf += (2 * 64);
+ x1re = XBuf[0];
+ x1im = XBuf[1];
+ XBuf += (2 * 64);
+
+ p01re.w64 = p01im.w64 = 0;
+ p12re.w64 = p12im.w64 = 0;
+ p11re.w64 = 0;
+ p22re.w64 = 0;
+
+ p12re.w64 = MADD64(p12re.w64, x1re, x0re);
+ p12re.w64 = MADD64(p12re.w64, x1im, x0im);
+ p12im.w64 = MADD64(p12im.w64, x0re, x1im);
+ p12im.w64 = MADD64(p12im.w64, -x0im, x1re);
+ p22re.w64 = MADD64(p22re.w64, x0re, x0re);
+ p22re.w64 = MADD64(p22re.w64, x0im, x0im);
+ for (n = (NUM_TIME_SLOTS * SAMPLES_PER_SLOT + 6); n != 0; n--) {
+ /* 4 input, 3*2 acc, 1 ptr, 1 loop counter = 12 registers (use same for x0im, -x0im) */
+ x0re = x1re;
+ x0im = x1im;
+ x1re = XBuf[0];
+ x1im = XBuf[1];
+
+ p01re.w64 = MADD64(p01re.w64, x1re, x0re);
+ p01re.w64 = MADD64(p01re.w64, x1im, x0im);
+ p01im.w64 = MADD64(p01im.w64, x0re, x1im);
+ p01im.w64 = MADD64(p01im.w64, -x0im, x1re);
+ p11re.w64 = MADD64(p11re.w64, x0re, x0re);
+ p11re.w64 = MADD64(p11re.w64, x0im, x0im);
+
+ XBuf += (2 * 64);
+ }
+ /* these can be derived by slight changes to account for boundary conditions */
+ p12re.w64 += p01re.w64;
+ p12re.w64 = MADD64(p12re.w64, x1re, -x0re);
+ p12re.w64 = MADD64(p12re.w64, x1im, -x0im);
+ p12im.w64 += p01im.w64;
+ p12im.w64 = MADD64(p12im.w64, x0re, -x1im);
+ p12im.w64 = MADD64(p12im.w64, x0im, x1re);
+ p22re.w64 += p11re.w64;
+ p22re.w64 = MADD64(p22re.w64, x0re, -x0re);
+ p22re.w64 = MADD64(p22re.w64, x0im, -x0im);
+
+ accBuf[0] = p01re.r.lo32;
+ accBuf[1] = p01re.r.hi32;
+ accBuf[2] = p01im.r.lo32;
+ accBuf[3] = p01im.r.hi32;
+ accBuf[4] = p11re.r.lo32;
+ accBuf[5] = p11re.r.hi32;
+ accBuf[6] = p12re.r.lo32;
+ accBuf[7] = p12re.r.hi32;
+ accBuf[8] = p12im.r.lo32;
+ accBuf[9] = p12im.r.hi32;
+ accBuf[10] = p22re.r.lo32;
+ accBuf[11] = p22re.r.hi32;
+}
+
+/**************************************************************************************
+ * Function: CalcCovariance1
+ *
+ * Description: calculate covariance matrix for p01, p12, p11, p22 (4.6.18.6.2)
+ *
+ * Inputs: buffer of low-freq samples, starting at time index 0,
+ * freq index = patch subband
+ *
+ * Outputs: complex covariance elements p01re, p01im, p12re, p12im, p11re, p22re
+ * (p11im = p22im = 0)
+ * format = integer (Q0) * 2^N, with scalefactor N >= 0
+ *
+ * Return: scalefactor N
+ *
+ * Notes: outputs are normalized to have 1 GB (sign in at least top 2 bits)
+ **************************************************************************************/
+static int CalcCovariance1(int *XBuf, int *p01reN, int *p01imN, int *p12reN, int *p12imN, int *p11reN, int *p22reN)
+{
+ int accBuf[2 * 6];
+ int n, z, s, loShift, hiShift, gbMask;
+ U64 p01re, p01im, p12re, p12im, p11re, p22re;
+
+ CVKernel1(XBuf, accBuf);
+ p01re.r.lo32 = accBuf[0];
+ p01re.r.hi32 = accBuf[1];
+ p01im.r.lo32 = accBuf[2];
+ p01im.r.hi32 = accBuf[3];
+ p11re.r.lo32 = accBuf[4];
+ p11re.r.hi32 = accBuf[5];
+ p12re.r.lo32 = accBuf[6];
+ p12re.r.hi32 = accBuf[7];
+ p12im.r.lo32 = accBuf[8];
+ p12im.r.hi32 = accBuf[9];
+ p22re.r.lo32 = accBuf[10];
+ p22re.r.hi32 = accBuf[11];
+
+ /* 64-bit accumulators now have 2*FBITS_OUT_QMFA fraction bits
+ * want to scale them down to integers (32-bit signed, Q0)
+ * with scale factor of 2^n, n >= 0
+ * leave 2 GB's for calculating determinant, so take top 30 non-zero bits
+ */
+ gbMask = ((p01re.r.hi32) ^(p01re.r.hi32 >> 31)) | ((p01im.r.hi32) ^(p01im.r.hi32 >> 31));
+ gbMask |= ((p12re.r.hi32) ^(p12re.r.hi32 >> 31)) | ((p12im.r.hi32) ^(p12im.r.hi32 >> 31));
+ gbMask |= ((p11re.r.hi32) ^(p11re.r.hi32 >> 31)) | ((p22re.r.hi32) ^(p22re.r.hi32 >> 31));
+ if (gbMask == 0) {
+ s = p01re.r.hi32 >> 31;
+ gbMask = (p01re.r.lo32 ^ s) - s;
+ s = p01im.r.hi32 >> 31;
+ gbMask |= (p01im.r.lo32 ^ s) - s;
+ s = p12re.r.hi32 >> 31;
+ gbMask |= (p12re.r.lo32 ^ s) - s;
+ s = p12im.r.hi32 >> 31;
+ gbMask |= (p12im.r.lo32 ^ s) - s;
+ s = p11re.r.hi32 >> 31;
+ gbMask |= (p11re.r.lo32 ^ s) - s;
+ s = p22re.r.hi32 >> 31;
+ gbMask |= (p22re.r.lo32 ^ s) - s;
+ z = 32 + CLZ(gbMask);
+ } else {
+ gbMask = FASTABS(p01re.r.hi32) | FASTABS(p01im.r.hi32);
+ gbMask |= FASTABS(p12re.r.hi32) | FASTABS(p12im.r.hi32);
+ gbMask |= FASTABS(p11re.r.hi32) | FASTABS(p22re.r.hi32);
+ z = CLZ(gbMask);
+ }
+
+ n = 64 - z; /* number of non-zero bits in bottom of 64-bit word */
+ if (n <= 30) {
+ loShift = (30 - n);
+ *p01reN = p01re.r.lo32 << loShift;
+ *p01imN = p01im.r.lo32 << loShift;
+ *p12reN = p12re.r.lo32 << loShift;
+ *p12imN = p12im.r.lo32 << loShift;
+ *p11reN = p11re.r.lo32 << loShift;
+ *p22reN = p22re.r.lo32 << loShift;
+ return -(loShift + 2 * FBITS_OUT_QMFA);
+ } else if (n < 32 + 30) {
+ loShift = (n - 30);
+ hiShift = 32 - loShift;
+ *p01reN = (p01re.r.hi32 << hiShift) | (p01re.r.lo32 >> loShift);
+ *p01imN = (p01im.r.hi32 << hiShift) | (p01im.r.lo32 >> loShift);
+ *p12reN = (p12re.r.hi32 << hiShift) | (p12re.r.lo32 >> loShift);
+ *p12imN = (p12im.r.hi32 << hiShift) | (p12im.r.lo32 >> loShift);
+ *p11reN = (p11re.r.hi32 << hiShift) | (p11re.r.lo32 >> loShift);
+ *p22reN = (p22re.r.hi32 << hiShift) | (p22re.r.lo32 >> loShift);
+ return (loShift - 2 * FBITS_OUT_QMFA);
+ } else {
+ hiShift = n - (32 + 30);
+ *p01reN = p01re.r.hi32 >> hiShift;
+ *p01imN = p01im.r.hi32 >> hiShift;
+ *p12reN = p12re.r.hi32 >> hiShift;
+ *p12imN = p12im.r.hi32 >> hiShift;
+ *p11reN = p11re.r.hi32 >> hiShift;
+ *p22reN = p22re.r.hi32 >> hiShift;
+ return (32 - 2 * FBITS_OUT_QMFA - hiShift);
+ }
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: CVKernel2
+ *
+ * Description: kernel of covariance matrix calculation for p02
+ *
+ * Inputs: buffer of low-freq samples, starting at time index = 0,
+ * freq index = patch subband
+ *
+ * Outputs: 64-bit accumulators for p02re, p02im stored in accBuf
+ *
+ * Return: none
+ *
+ * Notes: this is carefully written to be efficient on ARM
+ * use the assembly code version in sbrcov.s when building for ARM!
+ **************************************************************************************/
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+void CVKernel2(int *XBuf, int *accBuf)
+{
+ U64 p02re, p02im;
+ int n, x0re, x0im, x1re, x1im, x2re, x2im;
+
+ p02re.w64 = p02im.w64 = 0;
+
+ x0re = XBuf[0];
+ x0im = XBuf[1];
+ XBuf += (2 * 64);
+ x1re = XBuf[0];
+ x1im = XBuf[1];
+ XBuf += (2 * 64);
+
+ for (n = (NUM_TIME_SLOTS * SAMPLES_PER_SLOT + 6); n != 0; n--) {
+ /* 6 input, 2*2 acc, 1 ptr, 1 loop counter = 12 registers (use same for x0im, -x0im) */
+ x2re = XBuf[0];
+ x2im = XBuf[1];
+
+ p02re.w64 = MADD64(p02re.w64, x2re, x0re);
+ p02re.w64 = MADD64(p02re.w64, x2im, x0im);
+ p02im.w64 = MADD64(p02im.w64, x0re, x2im);
+ p02im.w64 = MADD64(p02im.w64, -x0im, x2re);
+
+ x0re = x1re;
+ x0im = x1im;
+ x1re = x2re;
+ x1im = x2im;
+ XBuf += (2 * 64);
+ }
+
+ accBuf[0] = p02re.r.lo32;
+ accBuf[1] = p02re.r.hi32;
+ accBuf[2] = p02im.r.lo32;
+ accBuf[3] = p02im.r.hi32;
+}
+
+/**************************************************************************************
+ * Function: CalcCovariance2
+ *
+ * Description: calculate covariance matrix for p02 (4.6.18.6.2)
+ *
+ * Inputs: buffer of low-freq samples, starting at time index = 0,
+ * freq index = patch subband
+ *
+ * Outputs: complex covariance element p02re, p02im
+ * format = integer (Q0) * 2^N, with scalefactor N >= 0
+ *
+ * Return: scalefactor N
+ *
+ * Notes: outputs are normalized to have 1 GB (sign in at least top 2 bits)
+ **************************************************************************************/
+static int CalcCovariance2(int *XBuf, int *p02reN, int *p02imN)
+{
+ U64 p02re, p02im;
+ int n, z, s, loShift, hiShift, gbMask;
+ int accBuf[2 * 2];
+
+ CVKernel2(XBuf, accBuf);
+ p02re.r.lo32 = accBuf[0];
+ p02re.r.hi32 = accBuf[1];
+ p02im.r.lo32 = accBuf[2];
+ p02im.r.hi32 = accBuf[3];
+
+ /* 64-bit accumulators now have 2*FBITS_OUT_QMFA fraction bits
+ * want to scale them down to integers (32-bit signed, Q0)
+ * with scale factor of 2^n, n >= 0
+ * leave 1 GB for calculating determinant, so take top 30 non-zero bits
+ */
+ gbMask = ((p02re.r.hi32) ^(p02re.r.hi32 >> 31)) | ((p02im.r.hi32) ^(p02im.r.hi32 >> 31));
+ if (gbMask == 0) {
+ s = p02re.r.hi32 >> 31;
+ gbMask = (p02re.r.lo32 ^ s) - s;
+ s = p02im.r.hi32 >> 31;
+ gbMask |= (p02im.r.lo32 ^ s) - s;
+ z = 32 + CLZ(gbMask);
+ } else {
+ gbMask = FASTABS(p02re.r.hi32) | FASTABS(p02im.r.hi32);
+ z = CLZ(gbMask);
+ }
+ n = 64 - z; /* number of non-zero bits in bottom of 64-bit word */
+
+ if (n <= 30) {
+ loShift = (30 - n);
+ *p02reN = p02re.r.lo32 << loShift;
+ *p02imN = p02im.r.lo32 << loShift;
+ return -(loShift + 2 * FBITS_OUT_QMFA);
+ } else if (n < 32 + 30) {
+ loShift = (n - 30);
+ hiShift = 32 - loShift;
+ *p02reN = (p02re.r.hi32 << hiShift) | (p02re.r.lo32 >> loShift);
+ *p02imN = (p02im.r.hi32 << hiShift) | (p02im.r.lo32 >> loShift);
+ return (loShift - 2 * FBITS_OUT_QMFA);
+ } else {
+ hiShift = n - (32 + 30);
+ *p02reN = p02re.r.hi32 >> hiShift;
+ *p02imN = p02im.r.hi32 >> hiShift;
+ return (32 - 2 * FBITS_OUT_QMFA - hiShift);
+ }
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: CalcLPCoefs
+ *
+ * Description: calculate linear prediction coefficients for one subband (4.6.18.6.2)
+ *
+ * Inputs: buffer of low-freq samples, starting at time index = 0,
+ * freq index = patch subband
+ * number of guard bits in input sample buffer
+ *
+ * Outputs: complex LP coefficients a0re, a0im, a1re, a1im, format = Q29
+ *
+ * Return: none
+ *
+ * Notes: output coefficients (a0re, a0im, a1re, a1im) clipped to range (-4, 4)
+ * if the comples coefficients have magnitude >= 4.0, they are all
+ * set to 0 (see spec)
+ **************************************************************************************/
+static void CalcLPCoefs(int *XBuf, int *a0re, int *a0im, int *a1re, int *a1im, int gb)
+{
+ int zFlag, n1, n2, nd, d, dInv, tre, tim;
+ int p01re, p01im, p02re, p02im, p12re, p12im, p11re, p22re;
+
+ /* pre-scale to avoid overflow - probably never happens in practice (see QMFA)
+ * max bit growth per accumulator = 38*2 = 76 mul-adds (X * X)
+ * using 64-bit MADD, so if X has n guard bits, X*X has 2n+1 guard bits
+ * gain 1 extra sign bit per multiply, so ensure ceil(log2(76/2) / 2) = 3 guard bits on inputs
+ */
+ if (gb < 3) {
+ nd = 3 - gb;
+ for (n1 = (NUM_TIME_SLOTS * SAMPLES_PER_SLOT + 6 + 2); n1 != 0; n1--) {
+ XBuf[0] >>= nd;
+ XBuf[1] >>= nd;
+ XBuf += (2 * 64);
+ }
+ XBuf -= (2 * 64 * (NUM_TIME_SLOTS * SAMPLES_PER_SLOT + 6 + 2));
+ }
+
+ /* calculate covariance elements */
+ n1 = CalcCovariance1(XBuf, &p01re, &p01im, &p12re, &p12im, &p11re, &p22re);
+ n2 = CalcCovariance2(XBuf, &p02re, &p02im);
+
+ /* normalize everything to larger power of 2 scalefactor, call it n1 */
+ if (n1 < n2) {
+ nd = MIN(n2 - n1, 31);
+ p01re >>= nd;
+ p01im >>= nd;
+ p12re >>= nd;
+ p12im >>= nd;
+ p11re >>= nd;
+ p22re >>= nd;
+ n1 = n2;
+ } else if (n1 > n2) {
+ nd = MIN(n1 - n2, 31);
+ p02re >>= nd;
+ p02im >>= nd;
+ }
+
+ /* calculate determinant of covariance matrix (at least 1 GB in pXX) */
+ d = MULSHIFT32(p12re, p12re) + MULSHIFT32(p12im, p12im);
+ d = MULSHIFT32(d, RELAX_COEF) << 1;
+ d = MULSHIFT32(p11re, p22re) - d;
+ ASSERT(d >= 0); /* should never be < 0 */
+
+ zFlag = 0;
+ *a0re = *a0im = 0;
+ *a1re = *a1im = 0;
+ if (d > 0) {
+ /* input = Q31 d = Q(-2*n1 - 32 + nd) = Q31 * 2^(31 + 2*n1 + 32 - nd)
+ * inverse = Q29 dInv = Q29 * 2^(-31 - 2*n1 - 32 + nd) = Q(29 + 31 + 2*n1 + 32 - nd)
+ *
+ * numerator has same Q format as d, since it's sum of normalized squares
+ * so num * inverse = Q(-2*n1 - 32) * Q(29 + 31 + 2*n1 + 32 - nd)
+ * = Q(29 + 31 - nd), drop low 32 in MULSHIFT32
+ * = Q(29 + 31 - 32 - nd) = Q(28 - nd)
+ */
+ nd = CLZ(d) - 1;
+ d <<= nd;
+ dInv = InvRNormalized(d);
+
+ /* 1 GB in pXX */
+ tre = MULSHIFT32(p01re, p12re) - MULSHIFT32(p01im, p12im) - MULSHIFT32(p02re, p11re);
+ tre = MULSHIFT32(tre, dInv);
+ tim = MULSHIFT32(p01re, p12im) + MULSHIFT32(p01im, p12re) - MULSHIFT32(p02im, p11re);
+ tim = MULSHIFT32(tim, dInv);
+
+ /* if d is extremely small, just set coefs to 0 (would have poor precision anyway) */
+ if (nd > 28 || (FASTABS(tre) >> (28 - nd)) >= 4 || (FASTABS(tim) >> (28 - nd)) >= 4) {
+ zFlag = 1;
+ } else {
+ *a1re = tre << (FBITS_LPCOEFS - 28 + nd); /* i.e. convert Q(28 - nd) to Q(29) */
+ *a1im = tim << (FBITS_LPCOEFS - 28 + nd);
+ }
+ }
+
+ if (p11re) {
+ /* input = Q31 p11re = Q(-n1 + nd) = Q31 * 2^(31 + n1 - nd)
+ * inverse = Q29 dInv = Q29 * 2^(-31 - n1 + nd) = Q(29 + 31 + n1 - nd)
+ *
+ * numerator is Q(-n1 - 3)
+ * so num * inverse = Q(-n1 - 3) * Q(29 + 31 + n1 - nd)
+ * = Q(29 + 31 - 3 - nd), drop low 32 in MULSHIFT32
+ * = Q(29 + 31 - 3 - 32 - nd) = Q(25 - nd)
+ */
+ nd = CLZ(p11re) - 1; /* assume positive */
+ p11re <<= nd;
+ dInv = InvRNormalized(p11re);
+
+ /* a1re, a1im = Q29, so scaled by (n1 + 3) */
+ tre = (p01re >> 3) + MULSHIFT32(p12re, *a1re) + MULSHIFT32(p12im, *a1im);
+ tre = -MULSHIFT32(tre, dInv);
+ tim = (p01im >> 3) - MULSHIFT32(p12im, *a1re) + MULSHIFT32(p12re, *a1im);
+ tim = -MULSHIFT32(tim, dInv);
+
+ if (nd > 25 || (FASTABS(tre) >> (25 - nd)) >= 4 || (FASTABS(tim) >> (25 - nd)) >= 4) {
+ zFlag = 1;
+ } else {
+ *a0re = tre << (FBITS_LPCOEFS - 25 + nd); /* i.e. convert Q(25 - nd) to Q(29) */
+ *a0im = tim << (FBITS_LPCOEFS - 25 + nd);
+ }
+ }
+
+ /* see 4.6.18.6.2 - if magnitude of a0 or a1 >= 4 then a0 = a1 = 0
+ * i.e. a0re < 4, a0im < 4, a1re < 4, a1im < 4
+ * Q29*Q29 = Q26
+ */
+ if (zFlag || MULSHIFT32(*a0re, *a0re) + MULSHIFT32(*a0im, *a0im) >= MAG_16 || MULSHIFT32(*a1re, *a1re) + MULSHIFT32(*a1im, *a1im) >= MAG_16) {
+ *a0re = *a0im = 0;
+ *a1re = *a1im = 0;
+ }
+
+ /* no need to clip - we never changed the XBuf data, just used it to calculate a0 and a1 */
+ if (gb < 3) {
+ nd = 3 - gb;
+ for (n1 = (NUM_TIME_SLOTS * SAMPLES_PER_SLOT + 6 + 2); n1 != 0; n1--) {
+ XBuf[0] <<= nd;
+ XBuf[1] <<= nd;
+ XBuf += (2 * 64);
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: GenerateHighFreq
+ *
+ * Description: generate high frequencies with SBR (4.6.18.6)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ *
+ * Outputs: new high frequency samples starting at frequency kStart
+ *
+ * Return: none
+ **************************************************************************************/
+void GenerateHighFreq(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch)
+{
+ int band, newBW, c, t, gb, gbMask, gbIdx;
+ int currPatch, p, x, k, g, i, iStart, iEnd, bw, bwsq;
+ int a0re, a0im, a1re, a1im;
+ int x1re, x1im, x2re, x2im;
+ int ACCre, ACCim;
+ int *XBufLo, *XBufHi;
+
+ /* calculate array of chirp factors */
+ for (band = 0; band < sbrFreq->numNoiseFloorBands; band++) {
+ c = sbrChan->chirpFact[band]; /* previous (bwArray') */
+ newBW = newBWTab[sbrChan->invfMode[0][band]][sbrChan->invfMode[1][band]];
+
+ /* weighted average of new and old (can't overflow - total gain = 1.0) */
+ if (newBW < c) {
+ t = MULSHIFT32(newBW, 0x60000000) + MULSHIFT32(0x20000000, c); /* new is smaller: 0.75*new + 0.25*old */
+ } else {
+ t = MULSHIFT32(newBW, 0x74000000) + MULSHIFT32(0x0c000000, c); /* new is larger: 0.90625*new + 0.09375*old */
+ }
+ t <<= 1;
+
+ if (t < 0x02000000) { /* below 0.015625, clip to 0 */
+ t = 0;
+ }
+ if (t > 0x7f800000) { /* clip to 0.99609375 */
+ t = 0x7f800000;
+ }
+
+ /* save curr as prev for next time */
+ sbrChan->chirpFact[band] = t;
+ sbrChan->invfMode[0][band] = sbrChan->invfMode[1][band];
+ }
+
+ iStart = sbrGrid->envTimeBorder[0] + HF_ADJ;
+ iEnd = sbrGrid->envTimeBorder[sbrGrid->numEnv] + HF_ADJ;
+
+ /* generate new high freqs from low freqs, patches, and chirp factors */
+ k = sbrFreq->kStart;
+ g = 0;
+ bw = sbrChan->chirpFact[g];
+ bwsq = MULSHIFT32(bw, bw) << 1;
+
+ gbMask = (sbrChan->gbMask[0] | sbrChan->gbMask[1]); /* older 32 | newer 8 */
+ gb = CLZ(gbMask) - 1;
+
+ for (currPatch = 0; currPatch < sbrFreq->numPatches; currPatch++) {
+ for (x = 0; x < sbrFreq->patchNumSubbands[currPatch]; x++) {
+ /* map k to corresponding noise floor band */
+ if (k >= sbrFreq->freqNoise[g + 1]) {
+ g++;
+ bw = sbrChan->chirpFact[g]; /* Q31 */
+ bwsq = MULSHIFT32(bw, bw) << 1; /* Q31 */
+ }
+
+ p = sbrFreq->patchStartSubband[currPatch] + x; /* low QMF band */
+ XBufHi = psi->XBuf[iStart][k];
+ if (bw) {
+ CalcLPCoefs(psi->XBuf[0][p], &a0re, &a0im, &a1re, &a1im, gb);
+
+ a0re = MULSHIFT32(bw, a0re); /* Q31 * Q29 = Q28 */
+ a0im = MULSHIFT32(bw, a0im);
+ a1re = MULSHIFT32(bwsq, a1re);
+ a1im = MULSHIFT32(bwsq, a1im);
+
+ XBufLo = psi->XBuf[iStart - 2][p];
+
+ x2re = XBufLo[0]; /* RE{XBuf[n-2]} */
+ x2im = XBufLo[1]; /* IM{XBuf[n-2]} */
+ XBufLo += (64 * 2);
+
+ x1re = XBufLo[0]; /* RE{XBuf[n-1]} */
+ x1im = XBufLo[1]; /* IM{XBuf[n-1]} */
+ XBufLo += (64 * 2);
+
+ for (i = iStart; i < iEnd; i++) {
+ /* a0re/im, a1re/im are Q28 with at least 1 GB,
+ * so the summing for AACre/im is fine (1 GB in, plus 1 from MULSHIFT32)
+ */
+ ACCre = MULSHIFT32(x2re, a1re) - MULSHIFT32(x2im, a1im);
+ ACCim = MULSHIFT32(x2re, a1im) + MULSHIFT32(x2im, a1re);
+ x2re = x1re;
+ x2im = x1im;
+
+ ACCre += MULSHIFT32(x1re, a0re) - MULSHIFT32(x1im, a0im);
+ ACCim += MULSHIFT32(x1re, a0im) + MULSHIFT32(x1im, a0re);
+ x1re = XBufLo[0]; /* RE{XBuf[n]} */
+ x1im = XBufLo[1]; /* IM{XBuf[n]} */
+ XBufLo += (64 * 2);
+
+ /* lost 4 fbits when scaling by a0re/im, a1re/im (Q28) */
+ CLIP_2N_SHIFT30(ACCre, 4);
+ ACCre += x1re;
+ CLIP_2N_SHIFT30(ACCim, 4);
+ ACCim += x1im;
+
+ XBufHi[0] = ACCre;
+ XBufHi[1] = ACCim;
+ XBufHi += (64 * 2);
+
+ /* update guard bit masks */
+ gbMask = FASTABS(ACCre);
+ gbMask |= FASTABS(ACCim);
+ gbIdx = (i >> 5) & 0x01; /* 0 if i < 32, 1 if i >= 32 */
+ sbrChan->gbMask[gbIdx] |= gbMask;
+ }
+ } else {
+ XBufLo = (int *)psi->XBuf[iStart][p];
+ for (i = iStart; i < iEnd; i++) {
+ XBufHi[0] = XBufLo[0];
+ XBufHi[1] = XBufLo[1];
+ XBufLo += (64 * 2);
+ XBufHi += (64 * 2);
+ }
+ }
+ k++; /* high QMF band */
+ }
+ }
+}
+
+
diff --git a/audio_codec/libraac/sbrhuff.c b/audio_codec/libraac/sbrhuff.c
new file mode 100644
index 0000000..07da660
--- a/dev/null
+++ b/audio_codec/libraac/sbrhuff.c
@@ -0,0 +1,492 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrhuff.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrhuff.c - functions for unpacking Huffman-coded envelope and noise data
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+/**************************************************************************************
+ * Function: DecodeHuffmanScalar
+ *
+ * Description: decode one Huffman symbol from bitstream
+ *
+ * Inputs: pointers to Huffman table and info struct
+ * left-aligned bit buffer with >= huffTabInfo->maxBits bits
+ *
+ * Outputs: decoded symbol in *val
+ *
+ * Return: number of bits in symbol
+ *
+ * Notes: assumes canonical Huffman codes:
+ * first CW always 0, we have "count" CW's of length "nBits" bits
+ * starting CW for codes of length nBits+1 =
+ * (startCW[nBits] + count[nBits]) << 1
+ * if there are no codes at nBits, then we just keep << 1 each time
+ * (since count[nBits] = 0)
+ **************************************************************************************/
+static int DecodeHuffmanScalar(const signed short *huffTab, const HuffInfo *huffTabInfo, unsigned int bitBuf, signed int *val)
+{
+ unsigned int count, start, shift, t;
+ const unsigned char *countPtr;
+ const signed short *map;
+
+ map = huffTab + huffTabInfo->offset;
+ countPtr = huffTabInfo->count;
+
+ start = 0;
+ count = 0;
+ shift = 32;
+ do {
+ start += count;
+ start <<= 1;
+ map += count;
+ count = *countPtr++;
+ shift--;
+ t = (bitBuf >> shift) - start;
+ } while (t >= count);
+
+ *val = (signed int)map[t];
+ return (countPtr - huffTabInfo->count);
+}
+
+/**************************************************************************************
+ * Function: DecodeOneSymbol
+ *
+ * Description: dequantize one Huffman symbol from bitstream,
+ * using table huffTabSBR[huffTabIndex]
+ *
+ * Inputs: BitStreamInfo struct pointing to start of next Huffman codeword
+ * index of Huffman table
+ *
+ * Outputs: bitstream advanced by number of bits in codeword
+ *
+ * Return: one decoded symbol
+ **************************************************************************************/
+static int DecodeOneSymbol(BitStreamInfo *bsi, int huffTabIndex)
+{
+ int nBits, val;
+ unsigned int bitBuf;
+ const HuffInfo *hi;
+
+ hi = &(huffTabSBRInfo[huffTabIndex]);
+
+ bitBuf = GetBitsNoAdvance(bsi, hi->maxBits) << (32 - hi->maxBits);
+ nBits = DecodeHuffmanScalar(huffTabSBR, hi, bitBuf, &val);
+ AdvanceBitstream(bsi, nBits);
+
+ return val;
+}
+
+/* [1.0, sqrt(2)], format = Q29 (one guard bit for decoupling) */
+static const int envDQTab[2] = {0x20000000, 0x2d413ccc};
+
+/**************************************************************************************
+ * Function: DequantizeEnvelope
+ *
+ * Description: dequantize envelope scalefactors
+ *
+ * Inputs: number of scalefactors to process
+ * amplitude resolution flag for this frame (0 or 1)
+ * quantized envelope scalefactors
+ *
+ * Outputs: dequantized envelope scalefactors
+ *
+ * Return: extra int bits in output (6 + expMax)
+ * in other words, output format = Q(FBITS_OUT_DQ_ENV - (6 + expMax))
+ *
+ * Notes: dequantized scalefactors have at least 2 GB
+ **************************************************************************************/
+static int DequantizeEnvelope(int nBands, int ampRes, signed char *envQuant, int *envDequant)
+{
+ int exp, expMax, i, scalei;
+
+ if (nBands <= 0) {
+ return 0;
+ }
+
+ /* scan for largest dequant value (do separately from envelope decoding to keep code cleaner) */
+ expMax = 0;
+ for (i = 0; i < nBands; i++) {
+ if (envQuant[i] > expMax) {
+ expMax = envQuant[i];
+ }
+ }
+
+ /* dequantized envelope gains
+ * envDequant = 64*2^(envQuant / alpha) = 2^(6 + envQuant / alpha)
+ * if ampRes == 0, alpha = 2 and range of envQuant = [0, 127]
+ * if ampRes == 1, alpha = 1 and range of envQuant = [0, 63]
+ * also if coupling is on, envDequant is scaled by something in range [0, 2]
+ * so range of envDequant = [2^6, 2^69] (no coupling), [2^6, 2^70] (with coupling)
+ *
+ * typical range (from observation) of envQuant/alpha = [0, 27] --> largest envQuant ~= 2^33
+ * output: Q(29 - (6 + expMax))
+ *
+ * reference: 14496-3:2001(E)/4.6.18.3.5 and 14496-4:200X/FPDAM8/5.6.5.1.2.1.5
+ */
+ if (ampRes) {
+ do {
+ exp = *envQuant++;
+ scalei = MIN(expMax - exp, 31);
+ *envDequant++ = envDQTab[0] >> scalei;
+ } while (--nBands);
+
+ return (6 + expMax);
+ } else {
+ expMax >>= 1;
+ do {
+ exp = *envQuant++;
+ scalei = MIN(expMax - (exp >> 1), 31);
+ *envDequant++ = envDQTab[exp & 0x01] >> scalei;
+ } while (--nBands);
+
+ return (6 + expMax);
+ }
+
+}
+
+/**************************************************************************************
+ * Function: DequantizeNoise
+ *
+ * Description: dequantize noise scalefactors
+ *
+ * Inputs: number of scalefactors to process
+ * quantized noise scalefactors
+ *
+ * Outputs: dequantized noise scalefactors, format = Q(FBITS_OUT_DQ_NOISE)
+ *
+ * Return: none
+ *
+ * Notes: dequantized scalefactors have at least 2 GB
+ **************************************************************************************/
+static void DequantizeNoise(int nBands, signed char *noiseQuant, int *noiseDequant)
+{
+ int exp, scalei;
+
+ if (nBands <= 0) {
+ return;
+ }
+
+ /* dequantize noise floor gains (4.6.18.3.5):
+ * noiseDequant = 2^(NOISE_FLOOR_OFFSET - noiseQuant)
+ *
+ * range of noiseQuant = [0, 30] (see 4.6.18.3.6), NOISE_FLOOR_OFFSET = 6
+ * so range of noiseDequant = [2^-24, 2^6]
+ */
+ do {
+ exp = *noiseQuant++;
+ scalei = NOISE_FLOOR_OFFSET - exp + FBITS_OUT_DQ_NOISE; /* 6 + 24 - exp, exp = [0,30] */
+
+ if (scalei < 0) {
+ *noiseDequant++ = 0;
+ } else if (scalei < 30) {
+ *noiseDequant++ = 1 << scalei;
+ } else {
+ *noiseDequant++ = 0x3fffffff; /* leave 2 GB */
+ }
+
+ } while (--nBands);
+}
+
+/**************************************************************************************
+ * Function: DecodeSBREnvelope
+ *
+ * Description: decode delta Huffman coded envelope scalefactors from bitstream
+ *
+ * Inputs: BitStreamInfo struct pointing to start of env data
+ * initialized PSInfoSBR struct
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ *
+ * Outputs: dequantized env scalefactors for left channel (before decoupling)
+ * dequantized env scalefactors for right channel (if coupling off)
+ * or raw decoded env scalefactors for right channel (if coupling on)
+ *
+ * Return: none
+ **************************************************************************************/
+void DecodeSBREnvelope(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch)
+{
+ int huffIndexTime, huffIndexFreq, env, envStartBits, band, nBands, sf, lastEnv;
+ int freqRes, freqResPrev, dShift, i;
+
+ if (psi->couplingFlag && ch) {
+ dShift = 1;
+ if (sbrGrid->ampResFrame) {
+ huffIndexTime = HuffTabSBR_tEnv30b;
+ huffIndexFreq = HuffTabSBR_fEnv30b;
+ envStartBits = 5;
+ } else {
+ huffIndexTime = HuffTabSBR_tEnv15b;
+ huffIndexFreq = HuffTabSBR_fEnv15b;
+ envStartBits = 6;
+ }
+ } else {
+ dShift = 0;
+ if (sbrGrid->ampResFrame) {
+ huffIndexTime = HuffTabSBR_tEnv30;
+ huffIndexFreq = HuffTabSBR_fEnv30;
+ envStartBits = 6;
+ } else {
+ huffIndexTime = HuffTabSBR_tEnv15;
+ huffIndexFreq = HuffTabSBR_fEnv15;
+ envStartBits = 7;
+ }
+ }
+
+ /* range of envDataQuant[] = [0, 127] (see comments in DequantizeEnvelope() for reference) */
+ for (env = 0; env < sbrGrid->numEnv; env++) {
+ nBands = (sbrGrid->freqRes[env] ? sbrFreq->nHigh : sbrFreq->nLow);
+ freqRes = (sbrGrid->freqRes[env]);
+ freqResPrev = (env == 0 ? sbrGrid->freqResPrev : sbrGrid->freqRes[env - 1]);
+ lastEnv = (env == 0 ? sbrGrid->numEnvPrev - 1 : env - 1);
+ if (lastEnv < 0) {
+ lastEnv = 0; /* first frame */
+ }
+
+ ASSERT(nBands <= MAX_QMF_BANDS);
+
+ if (sbrChan->deltaFlagEnv[env] == 0) {
+ /* delta coding in freq */
+ sf = GetBits(bsi, envStartBits) << dShift;
+ sbrChan->envDataQuant[env][0] = sf;
+ for (band = 1; band < nBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexFreq) << dShift;
+ sbrChan->envDataQuant[env][band] = sf + sbrChan->envDataQuant[env][band - 1];
+ }
+ } else if (freqRes == freqResPrev) {
+ /* delta coding in time - same freq resolution for both frames */
+ for (band = 0; band < nBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift;
+ sbrChan->envDataQuant[env][band] = sf + sbrChan->envDataQuant[lastEnv][band];
+ }
+ } else if (freqRes == 0 && freqResPrev == 1) {
+ /* delta coding in time - low freq resolution for new frame, high freq resolution for old frame */
+ for (band = 0; band < nBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift;
+ sbrChan->envDataQuant[env][band] = sf;
+ for (i = 0; i < sbrFreq->nHigh; i++) {
+ if (sbrFreq->freqHigh[i] == sbrFreq->freqLow[band]) {
+ sbrChan->envDataQuant[env][band] += sbrChan->envDataQuant[lastEnv][i];
+ break;
+ }
+ }
+ }
+ } else if (freqRes == 1 && freqResPrev == 0) {
+ /* delta coding in time - high freq resolution for new frame, low freq resolution for old frame */
+ for (band = 0; band < nBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift;
+ sbrChan->envDataQuant[env][band] = sf;
+ for (i = 0; i < sbrFreq->nLow; i++) {
+ if (sbrFreq->freqLow[i] <= sbrFreq->freqHigh[band] && sbrFreq->freqHigh[band] < sbrFreq->freqLow[i + 1]) {
+ sbrChan->envDataQuant[env][band] += sbrChan->envDataQuant[lastEnv][i];
+ break;
+ }
+ }
+ }
+ }
+
+ /* skip coupling channel */
+ if (ch != 1 || psi->couplingFlag != 1) {
+ psi->envDataDequantScale[ch][env] = DequantizeEnvelope(nBands, sbrGrid->ampResFrame, sbrChan->envDataQuant[env], psi->envDataDequant[ch][env]);
+ }
+ }
+ sbrGrid->numEnvPrev = sbrGrid->numEnv;
+ sbrGrid->freqResPrev = sbrGrid->freqRes[sbrGrid->numEnv - 1];
+}
+
+/**************************************************************************************
+ * Function: DecodeSBRNoise
+ *
+ * Description: decode delta Huffman coded noise scalefactors from bitstream
+ *
+ * Inputs: BitStreamInfo struct pointing to start of noise data
+ * initialized PSInfoSBR struct
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ *
+ * Outputs: dequantized noise scalefactors for left channel (before decoupling)
+ * dequantized noise scalefactors for right channel (if coupling off)
+ * or raw decoded noise scalefactors for right channel (if coupling on)
+ *
+ * Return: none
+ **************************************************************************************/
+void DecodeSBRNoise(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch)
+{
+ int huffIndexTime, huffIndexFreq, noiseFloor, band, dShift, sf, lastNoiseFloor;
+
+ if (psi->couplingFlag && ch) {
+ dShift = 1;
+ huffIndexTime = HuffTabSBR_tNoise30b;
+ huffIndexFreq = HuffTabSBR_fNoise30b;
+ } else {
+ dShift = 0;
+ huffIndexTime = HuffTabSBR_tNoise30;
+ huffIndexFreq = HuffTabSBR_fNoise30;
+ }
+
+ for (noiseFloor = 0; noiseFloor < sbrGrid->numNoiseFloors; noiseFloor++) {
+ lastNoiseFloor = (noiseFloor == 0 ? sbrGrid->numNoiseFloorsPrev - 1 : noiseFloor - 1);
+ if (lastNoiseFloor < 0) {
+ lastNoiseFloor = 0; /* first frame */
+ }
+
+ ASSERT(sbrFreq->numNoiseFloorBands <= MAX_QMF_BANDS);
+
+ if (sbrChan->deltaFlagNoise[noiseFloor] == 0) {
+ /* delta coding in freq */
+ sbrChan->noiseDataQuant[noiseFloor][0] = GetBits(bsi, 5) << dShift;
+ for (band = 1; band < sbrFreq->numNoiseFloorBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexFreq) << dShift;
+ sbrChan->noiseDataQuant[noiseFloor][band] = sf + sbrChan->noiseDataQuant[noiseFloor][band - 1];
+ }
+ } else {
+ /* delta coding in time */
+ for (band = 0; band < sbrFreq->numNoiseFloorBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift;
+ sbrChan->noiseDataQuant[noiseFloor][band] = sf + sbrChan->noiseDataQuant[lastNoiseFloor][band];
+ }
+ }
+
+ /* skip coupling channel */
+ if (ch != 1 || psi->couplingFlag != 1) {
+ DequantizeNoise(sbrFreq->numNoiseFloorBands, sbrChan->noiseDataQuant[noiseFloor], psi->noiseDataDequant[ch][noiseFloor]);
+ }
+ }
+ sbrGrid->numNoiseFloorsPrev = sbrGrid->numNoiseFloors;
+}
+
+/* dqTabCouple[i] = 2 / (1 + 2^(12 - i)), format = Q30 */
+static const int dqTabCouple[25] = {
+ 0x0007ff80, 0x000ffe00, 0x001ff802, 0x003fe010, 0x007f8080, 0x00fe03f8, 0x01f81f82, 0x03e0f83e,
+ 0x07878788, 0x0e38e38e, 0x1999999a, 0x2aaaaaab, 0x40000000, 0x55555555, 0x66666666, 0x71c71c72,
+ 0x78787878, 0x7c1f07c2, 0x7e07e07e, 0x7f01fc08, 0x7f807f80, 0x7fc01ff0, 0x7fe007fe, 0x7ff00200,
+ 0x7ff80080,
+};
+
+/**************************************************************************************
+ * Function: UncoupleSBREnvelope
+ *
+ * Description: scale dequantized envelope scalefactors according to channel
+ * coupling rules
+ *
+ * Inputs: initialized PSInfoSBR struct including
+ * dequantized envelope data for left channel
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for right channel including
+ * quantized envelope scalefactors
+ *
+ * Outputs: dequantized envelope data for left channel (after decoupling)
+ * dequantized envelope data for right channel (after decoupling)
+ *
+ * Return: none
+ **************************************************************************************/
+void UncoupleSBREnvelope(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR)
+{
+ int env, band, nBands, scalei, E_1;
+
+ scalei = (sbrGrid->ampResFrame ? 0 : 1);
+ for (env = 0; env < sbrGrid->numEnv; env++) {
+ nBands = (sbrGrid->freqRes[env] ? sbrFreq->nHigh : sbrFreq->nLow);
+ psi->envDataDequantScale[1][env] = psi->envDataDequantScale[0][env]; /* same scalefactor for L and R */
+ for (band = 0; band < nBands; band++) {
+ /* clip E_1 to [0, 24] (scalefactors approach 0 or 2) */
+ E_1 = sbrChanR->envDataQuant[env][band] >> scalei;
+ if (E_1 < 0) {
+ E_1 = 0;
+ }
+ if (E_1 > 24) {
+ E_1 = 24;
+ }
+
+ /* envDataDequant[0] has 1 GB, so << by 2 is okay */
+ psi->envDataDequant[1][env][band] = MULSHIFT32(psi->envDataDequant[0][env][band], dqTabCouple[24 - E_1]) << 2;
+ psi->envDataDequant[0][env][band] = MULSHIFT32(psi->envDataDequant[0][env][band], dqTabCouple[E_1]) << 2;
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: UncoupleSBRNoise
+ *
+ * Description: scale dequantized noise floor scalefactors according to channel
+ * coupling rules
+ *
+ * Inputs: initialized PSInfoSBR struct including
+ * dequantized noise data for left channel
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel including
+ * quantized noise scalefactors
+ *
+ * Outputs: dequantized noise data for left channel (after decoupling)
+ * dequantized noise data for right channel (after decoupling)
+ *
+ * Return: none
+ **************************************************************************************/
+void UncoupleSBRNoise(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR)
+{
+ int noiseFloor, band, Q_1;
+
+ for (noiseFloor = 0; noiseFloor < sbrGrid->numNoiseFloors; noiseFloor++) {
+ for (band = 0; band < sbrFreq->numNoiseFloorBands; band++) {
+ /* Q_1 should be in range [0, 24] according to 4.6.18.3.6, but check to make sure */
+ Q_1 = sbrChanR->noiseDataQuant[noiseFloor][band];
+ if (Q_1 < 0) {
+ Q_1 = 0;
+ }
+ if (Q_1 > 24) {
+ Q_1 = 24;
+ }
+
+ /* noiseDataDequant[0] has 1 GB, so << by 2 is okay */
+ psi->noiseDataDequant[1][noiseFloor][band] = MULSHIFT32(psi->noiseDataDequant[0][noiseFloor][band], dqTabCouple[24 - Q_1]) << 2;
+ psi->noiseDataDequant[0][noiseFloor][band] = MULSHIFT32(psi->noiseDataDequant[0][noiseFloor][band], dqTabCouple[Q_1]) << 2;
+ }
+ }
+}
diff --git a/audio_codec/libraac/sbrimdct.c b/audio_codec/libraac/sbrimdct.c
new file mode 100644
index 0000000..abec008
--- a/dev/null
+++ b/audio_codec/libraac/sbrimdct.c
@@ -0,0 +1,447 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrimdct.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrimdct.c - inverse MDCT without clipping or interleaving, for input to SBR
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+/**************************************************************************************
+ * Function: DecWindowOverlapNoClip
+ *
+ * Description: apply synthesis window, do overlap-add without clipping,
+ * for winSequence LONG-LONG
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 32-bit PCM, non-interleaved
+ *
+ * Return: none
+ *
+ * Notes: use this function when the decoded PCM is going to the SBR decoder
+ **************************************************************************************/
+void DecWindowOverlapNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev)
+{
+ int in, w0, w1, f0, f1;
+ int *buf1, *over1, *out1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ out1 = out0 + 1024 - 1;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ if (winTypeCurr == winTypePrev) {
+ /* cut window loads in half since current and overlap sections use same symmetric window */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ } else {
+ /* different windows for current and overlap parts - should still fit in registers on ARM w/o stack spill */
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapLongStart
+ *
+ * Description: apply synthesis window, do overlap-add, without clipping
+ * for winSequence LONG-START
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 32-bit PCM, non-interleaved
+ *
+ * Return: none
+ *
+ * Notes: use this function when the decoded PCM is going to the SBR decoder
+ **************************************************************************************/
+void DecWindowOverlapLongStartNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1, *out1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ out1 = out0 + 1024 - 1;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ i = 448; /* 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ in = *buf1--;
+
+ *over1-- = 0; /* Wn = 0 for n = (2047, 2046, ... 1600) */
+ *over0++ = in >> 1; /* Wn = 1 for n = (1024, 1025, ... 1471) */
+ } while (--i);
+
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+
+ /* do 64 more loops - 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ w0 = *wndCurr++; /* W[0], W[1], ... --> W[255], W[254], ... */
+ w1 = *wndCurr++; /* W[127], W[126], ... --> W[128], W[129], ... */
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in); /* Wn = short window for n = (1599, 1598, ... , 1536) */
+ *over0++ = MULSHIFT32(w1, in); /* Wn = short window for n = (1472, 1473, ... , 1535) */
+ } while (over0 < over1);
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapLongStop
+ *
+ * Description: apply synthesis window, do overlap-add, without clipping
+ * for winSequence LONG-STOP
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 32-bit PCM, non-interleaved
+ *
+ * Return: none
+ *
+ * Notes: use this function when the decoded PCM is going to the SBR decoder
+ **************************************************************************************/
+void DecWindowOverlapLongStopNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1, *out1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ out1 = out0 + 1024 - 1;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+
+ i = 448; /* 2 outputs, 2 overlaps per loop */
+ do {
+ /* Wn = 0 for n = (0, 1, ... 447) */
+ /* Wn = 1 for n = (576, 577, ... 1023) */
+ in = *buf0++;
+ f1 = in >> 1; /* scale since skipping multiply by Q31 */
+
+ in = *over0;
+ *out0++ = in;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (--i);
+
+ /* do 64 more loops - 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++; /* W[0], W[1], ...W[63] */
+ w1 = *wndPrev++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapShort
+ *
+ * Description: apply synthesis window, do overlap-add, without clipping
+ * for winSequence EIGHT-SHORT (does all 8 short blocks)
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 32-bit PCM, non-interleaved
+ *
+ * Return: none
+ *
+ * Notes: use this function when the decoded PCM is going to the SBR decoder
+ **************************************************************************************/
+void DecWindowOverlapShortNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1, *out1;
+ const int *wndPrev, *wndCurr;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+
+ /* pcm[0-447] = 0 + overlap[0-447] */
+ i = 448;
+ do {
+ f0 = *over0++;
+ f1 = *over0++;
+ *out0++ = f0;
+ *out0++ = f1;
+ i -= 2;
+ } while (i);
+
+ /* pcm[448-575] = Wp[0-127] * block0[0-127] + overlap[448-575] */
+ out1 = out0 + (128 - 1);
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ do {
+ w0 = *wndPrev++; /* W[0], W[1], ...W[63] */
+ w1 = *wndPrev++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ /* save over0/over1 for next short block, in the slots just vacated */
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+
+ /* pcm[576-703] = Wc[128-255] * block0[128-255] + Wc[0-127] * block1[0-127] + overlap[576-703]
+ * pcm[704-831] = Wc[128-255] * block1[128-255] + Wc[0-127] * block2[0-127] + overlap[704-831]
+ * pcm[832-959] = Wc[128-255] * block2[128-255] + Wc[0-127] * block3[0-127] + overlap[832-959]
+ */
+ for (i = 0; i < 3; i++) {
+ out0 += 64;
+ out1 = out0 + 128 - 1;
+ over0 += 64;
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *(over0 - 128); /* from last short block */
+ in += *(over0 + 0); /* from last full frame */
+ *out0++ = in - f0;
+
+ in = *(over1 - 128); /* from last short block */
+ in += *(over1 + 0); /* from last full frame */
+ *out1-- = in + f1;
+
+ /* save over0/over1 for next short block, in the slots just vacated */
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+
+ /* pcm[960-1023] = Wc[128-191] * block3[128-191] + Wc[0-63] * block4[0-63] + overlap[960-1023]
+ * over[0-63] = Wc[192-255] * block3[192-255] + Wc[64-127] * block4[64-127]
+ */
+ out0 += 64;
+ over0 -= 832; /* points at overlap[64] */
+ over1 = over0 + 128 - 1; /* points at overlap[191] */
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *(over0 + 768); /* from last short block */
+ in += *(over0 + 896); /* from last full frame */
+ *out0++ = in - f0;
+
+ in = *(over1 + 768); /* from last short block */
+ *(over1 - 128) = in + f1;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in); /* save in overlap[128-191] */
+ *over0++ = MULSHIFT32(w1, in); /* save in overlap[64-127] */
+ } while (over0 < over1);
+
+ /* over0 now points at overlap[128] */
+
+ /* over[64-191] = Wc[128-255] * block4[128-255] + Wc[0-127] * block5[0-127]
+ * over[192-319] = Wc[128-255] * block5[128-255] + Wc[0-127] * block6[0-127]
+ * over[320-447] = Wc[128-255] * block6[128-255] + Wc[0-127] * block7[0-127]
+ * over[448-576] = Wc[128-255] * block7[128-255]
+ */
+ for (i = 0; i < 3; i++) {
+ over0 += 64;
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ /* from last short block */
+ *(over0 - 128) -= f0;
+ *(over1 - 128) += f1;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+
+ /* over[576-1024] = 0 */
+ i = 448;
+ over0 += 64;
+ do {
+ *over0++ = 0;
+ *over0++ = 0;
+ *over0++ = 0;
+ *over0++ = 0;
+ i -= 4;
+ } while (i);
+}
diff --git a/audio_codec/libraac/sbrmath.c b/audio_codec/libraac/sbrmath.c
new file mode 100644
index 0000000..784f909
--- a/dev/null
+++ b/audio_codec/libraac/sbrmath.c
@@ -0,0 +1,198 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrmath.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrmath.c - fixed-point math functions for SBR
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+#define Q28_2 0x20000000 /* Q28: 2.0 */
+#define Q28_15 0x30000000 /* Q28: 1.5 */
+
+#define NUM_ITER_IRN 5
+
+/**************************************************************************************
+ * Function: InvRNormalized
+ *
+ * Description: use Newton's method to solve for x = 1/r
+ *
+ * Inputs: r = Q31, range = [0.5, 1) (normalize your inputs to this range)
+ *
+ * Outputs: none
+ *
+ * Return: x = Q29, range ~= [1.0, 2.0]
+ *
+ * Notes: guaranteed to converge and not overflow for any r in [0.5, 1)
+ *
+ * xn+1 = xn - f(xn)/f'(xn)
+ * f(x) = 1/r - x = 0 (find root)
+ * = 1/x - r
+ * f'(x) = -1/x^2
+ *
+ * so xn+1 = xn - (1/xn - r) / (-1/xn^2)
+ * = xn * (2 - r*xn)
+ *
+ * NUM_ITER_IRN = 2, maxDiff = 6.2500e-02 (precision of about 4 bits)
+ * NUM_ITER_IRN = 3, maxDiff = 3.9063e-03 (precision of about 8 bits)
+ * NUM_ITER_IRN = 4, maxDiff = 1.5288e-05 (precision of about 16 bits)
+ * NUM_ITER_IRN = 5, maxDiff = 3.0034e-08 (precision of about 24 bits)
+ **************************************************************************************/
+int InvRNormalized(int r)
+{
+ int i, xn, t;
+
+ /* r = [0.5, 1.0)
+ * 1/r = (1.0, 2.0]
+ * so use 1.5 as initial guess
+ */
+ xn = Q28_15;
+
+ /* xn = xn*(2.0 - r*xn) */
+ for (i = NUM_ITER_IRN; i != 0; i--) {
+ t = MULSHIFT32(r, xn); /* Q31*Q29 = Q28 */
+ t = Q28_2 - t; /* Q28 */
+ xn = MULSHIFT32(xn, t) << 4; /* Q29*Q28 << 4 = Q29 */
+ }
+
+ return xn;
+}
+
+#define NUM_TERMS_RPI 5
+#define LOG2_EXP_INV 0x58b90bfc /* 1/log2(e), Q31 */
+
+/* invTab[x] = 1/(x+1), format = Q30 */
+static const int invTab[NUM_TERMS_RPI] = {0x40000000, 0x20000000, 0x15555555, 0x10000000, 0x0ccccccd};
+
+/**************************************************************************************
+ * Function: RatioPowInv
+ *
+ * Description: use Taylor (MacLaurin) series expansion to calculate (a/b) ^ (1/c)
+ *
+ * Inputs: a = [1, 64], b = [1, 64], c = [1, 64], a >= b
+ *
+ * Outputs: none
+ *
+ * Return: y = Q24, range ~= [0.015625, 64]
+ **************************************************************************************/
+int RatioPowInv(int a, int b, int c)
+{
+ int lna, lnb, i, p, t, y;
+
+ if (a < 1 || b < 1 || c < 1 || a > 64 || b > 64 || c > 64 || a < b) {
+ return 0;
+ }
+
+ lna = MULSHIFT32(log2Tab[a], LOG2_EXP_INV) << 1; /* ln(a), Q28 */
+ lnb = MULSHIFT32(log2Tab[b], LOG2_EXP_INV) << 1; /* ln(b), Q28 */
+ p = (lna - lnb) / c; /* Q28 */
+
+ /* sum in Q24 */
+ y = (1 << 24);
+ t = p >> 4; /* t = p^1 * 1/1! (Q24)*/
+ y += t;
+
+ for (i = 2; i <= NUM_TERMS_RPI; i++) {
+ t = MULSHIFT32(invTab[i - 1], t) << 2;
+ t = MULSHIFT32(p, t) << 4; /* t = p^i * 1/i! (Q24) */
+ y += t;
+ }
+
+ return y;
+}
+
+/**************************************************************************************
+ * Function: SqrtFix
+ *
+ * Description: use binary search to calculate sqrt(q)
+ *
+ * Inputs: q = Q30
+ * number of fraction bits in input
+ *
+ * Outputs: number of fraction bits in output
+ *
+ * Return: lo = Q(fBitsOut)
+ *
+ * Notes: absolute precision varies depending on fBitsIn
+ * normalizes input to range [0x200000000, 0x7fffffff] and takes
+ * floor(sqrt(input)), and sets fBitsOut appropriately
+ **************************************************************************************/
+int SqrtFix(int q, int fBitsIn, int *fBitsOut)
+{
+ int z, lo, hi, mid;
+
+ if (q <= 0) {
+ *fBitsOut = fBitsIn;
+ return 0;
+ }
+
+ /* force even fBitsIn */
+ z = fBitsIn & 0x01;
+ q >>= z;
+ fBitsIn -= z;
+
+ /* for max precision, normalize to [0x20000000, 0x7fffffff] */
+ z = (CLZ(q) - 1);
+ z >>= 1;
+ q <<= (2 * z);
+
+ /* choose initial bounds */
+ lo = 1;
+ if (q >= 0x10000000) {
+ lo = 16384; /* (int)sqrt(0x10000000) */
+ }
+ hi = 46340; /* (int)sqrt(0x7fffffff) */
+
+ /* do binary search with 32x32->32 multiply test */
+ do {
+ mid = (lo + hi) >> 1;
+ if (mid * mid > q) {
+ hi = mid - 1;
+ } else {
+ lo = mid + 1;
+ }
+ } while (hi >= lo);
+ lo--;
+
+ *fBitsOut = ((fBitsIn + 2 * z) >> 1);
+ return lo;
+}
diff --git a/audio_codec/libraac/sbrqmf.c b/audio_codec/libraac/sbrqmf.c
new file mode 100644
index 0000000..9e8e790
--- a/dev/null
+++ b/audio_codec/libraac/sbrqmf.c
@@ -0,0 +1,643 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrqmf.c,v 1.2 2005/05/19 20:45:20 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrqmf.c - analysis and synthesis QMF filters for SBR
+ **************************************************************************************/
+#include "sbr.h"
+#include "assembly.h"
+#include <stdio.h>
+
+
+/* PreMultiply64() table
+ * format = Q30
+ * reordered for sequential access
+ *
+ * for (i = 0; i < 64/4; i++) {
+ * angle = (i + 0.25) * M_PI / nmdct;
+ * x = (cos(angle) + sin(angle));
+ * x = sin(angle);
+ *
+ * angle = (nmdct/2 - 1 - i + 0.25) * M_PI / nmdct;
+ * x = (cos(angle) + sin(angle));
+ * x = sin(angle);
+ * }
+ */
+static const int cos4sin4tab64[64] = {
+ 0x40c7d2bd, 0x00c90e90, 0x424ff28f, 0x3ff4e5e0, 0x43cdd89a, 0x03ecadcf, 0x454149fc, 0x3fc395f9,
+ 0x46aa0d6d, 0x070de172, 0x4807eb4b, 0x3f6af2e3, 0x495aada2, 0x0a2abb59, 0x4aa22036, 0x3eeb3347,
+ 0x4bde1089, 0x0d415013, 0x4d0e4de2, 0x3e44a5ef, 0x4e32a956, 0x104fb80e, 0x4f4af5d1, 0x3d77b192,
+ 0x50570819, 0x135410c3, 0x5156b6d9, 0x3c84d496, 0x5249daa2, 0x164c7ddd, 0x53304df6, 0x3b6ca4c4,
+ 0x5409ed4b, 0x19372a64, 0x54d69714, 0x3a2fcee8, 0x55962bc0, 0x1c1249d8, 0x56488dc5, 0x38cf1669,
+ 0x56eda1a0, 0x1edc1953, 0x57854ddd, 0x374b54ce, 0x580f7b19, 0x2192e09b, 0x588c1404, 0x35a5793c,
+ 0x58fb0568, 0x2434f332, 0x595c3e2a, 0x33de87de, 0x59afaf4c, 0x26c0b162, 0x59f54bee, 0x31f79948,
+ 0x5a2d0957, 0x29348937, 0x5a56deec, 0x2ff1d9c7, 0x5a72c63b, 0x2b8ef77d, 0x5a80baf6, 0x2dce88aa,
+};
+
+/* PostMultiply64() table
+ * format = Q30
+ * reordered for sequential access
+ *
+ * for (i = 0; i <= (32/2); i++) {
+ * angle = i * M_PI / 64;
+ * x = (cos(angle) + sin(angle));
+ * x = sin(angle);
+ * }
+ */
+static const int cos1sin1tab64[34] = {
+ 0x40000000, 0x00000000, 0x43103085, 0x0323ecbe, 0x45f704f7, 0x0645e9af, 0x48b2b335, 0x09640837,
+ 0x4b418bbe, 0x0c7c5c1e, 0x4da1fab5, 0x0f8cfcbe, 0x4fd288dc, 0x1294062f, 0x51d1dc80, 0x158f9a76,
+ 0x539eba45, 0x187de2a7, 0x553805f2, 0x1b5d100a, 0x569cc31b, 0x1e2b5d38, 0x57cc15bc, 0x20e70f32,
+ 0x58c542c5, 0x238e7673, 0x5987b08a, 0x261feffa, 0x5a12e720, 0x2899e64a, 0x5a6690ae, 0x2afad269,
+ 0x5a82799a, 0x2d413ccd,
+};
+
+/**************************************************************************************
+ * Function: PreMultiply64
+ *
+ * Description: pre-twiddle stage of 64-point DCT-IV
+ *
+ * Inputs: buffer of 64 samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: minimum 1 GB in, 2 GB out, gains 2 int bits
+ * gbOut = gbIn + 1
+ * output is limited to sqrt(2)/2 plus GB in full GB
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ **************************************************************************************/
+static void PreMultiply64(int *zbuf1)
+{
+ int i, ar1, ai1, ar2, ai2, z1, z2;
+ int t, cms2, cps2a, sin2a, cps2b, sin2b;
+ int *zbuf2;
+ const int *csptr;
+
+ zbuf2 = zbuf1 + 64 - 1;
+ csptr = cos4sin4tab64;
+
+ /* whole thing should fit in registers - verify that compiler does this */
+ for (i = 64 >> 2; i != 0; i--) {
+ /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */
+ cps2a = *csptr++;
+ sin2a = *csptr++;
+ cps2b = *csptr++;
+ sin2b = *csptr++;
+
+ ar1 = *(zbuf1 + 0);
+ ai2 = *(zbuf1 + 1);
+ ai1 = *(zbuf2 + 0);
+ ar2 = *(zbuf2 - 1);
+
+ /* gain 2 ints bit from MULSHIFT32 by Q30
+ * max per-sample gain (ignoring implicit scaling) = MAX(sin(angle)+cos(angle)) = 1.414
+ * i.e. gain 1 GB since worst case is sin(angle) = cos(angle) = 0.707 (Q30), gain 2 from
+ * extra sign bits, and eat one in adding
+ */
+ t = MULSHIFT32(sin2a, ar1 + ai1);
+ z2 = MULSHIFT32(cps2a, ai1) - t;
+ cms2 = cps2a - 2 * sin2a;
+ z1 = MULSHIFT32(cms2, ar1) + t;
+ *zbuf1++ = z1; /* cos*ar1 + sin*ai1 */
+ *zbuf1++ = z2; /* cos*ai1 - sin*ar1 */
+
+ t = MULSHIFT32(sin2b, ar2 + ai2);
+ z2 = MULSHIFT32(cps2b, ai2) - t;
+ cms2 = cps2b - 2 * sin2b;
+ z1 = MULSHIFT32(cms2, ar2) + t;
+ *zbuf2-- = z2; /* cos*ai2 - sin*ar2 */
+ *zbuf2-- = z1; /* cos*ar2 + sin*ai2 */
+ }
+}
+
+/**************************************************************************************
+ * Function: PostMultiply64
+ *
+ * Description: post-twiddle stage of 64-point type-IV DCT
+ *
+ * Inputs: buffer of 64 samples
+ * number of output samples to calculate
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: minimum 1 GB in, 2 GB out, gains 2 int bits
+ * gbOut = gbIn + 1
+ * output is limited to sqrt(2)/2 plus GB in full GB
+ * nSampsOut is rounded up to next multiple of 4, since we calculate
+ * 4 samples per loop
+ **************************************************************************************/
+static void PostMultiply64(int *fft1, int nSampsOut)
+{
+ int i, ar1, ai1, ar2, ai2;
+ int t, cms2, cps2, sin2;
+ int *fft2;
+ const int *csptr;
+
+ csptr = cos1sin1tab64;
+ fft2 = fft1 + 64 - 1;
+
+ /* load coeffs for first pass
+ * cps2 = (cos+sin)/2, sin2 = sin/2, cms2 = (cos-sin)/2
+ */
+ cps2 = *csptr++;
+ sin2 = *csptr++;
+ cms2 = cps2 - 2 * sin2;
+
+ for (i = (nSampsOut + 3) >> 2; i != 0; i--) {
+ ar1 = *(fft1 + 0);
+ ai1 = *(fft1 + 1);
+ ar2 = *(fft2 - 1);
+ ai2 = *(fft2 + 0);
+
+ /* gain 2 int bits (multiplying by Q30), max gain = sqrt(2) */
+ t = MULSHIFT32(sin2, ar1 + ai1);
+ *fft2-- = t - MULSHIFT32(cps2, ai1);
+ *fft1++ = t + MULSHIFT32(cms2, ar1);
+
+ cps2 = *csptr++;
+ sin2 = *csptr++;
+
+ ai2 = -ai2;
+ t = MULSHIFT32(sin2, ar2 + ai2);
+ *fft2-- = t - MULSHIFT32(cps2, ai2);
+ cms2 = cps2 - 2 * sin2;
+ *fft1++ = t + MULSHIFT32(cms2, ar2);
+ }
+}
+
+/**************************************************************************************
+ * Function: QMFAnalysisConv
+ *
+ * Description: convolution kernel for analysis QMF
+ *
+ * Inputs: pointer to coefficient table, reordered for sequential access
+ * delay buffer of size 32*10 = 320 real-valued PCM samples
+ * index for delay ring buffer (range = [0, 9])
+ *
+ * Outputs: 64 consecutive 32-bit samples
+ *
+ * Return: none
+ *
+ * Notes: this is carefully written to be efficient on ARM
+ * use the assembly code version in sbrqmfak.s when building for ARM!
+ **************************************************************************************/
+
+#ifdef __cplusplus
+extern "C"
+#endif
+void QMFAnalysisConv(int *cTab, int *delay, int dIdx, int *uBuf)
+{
+ int k, dOff;
+ int *cPtr0, *cPtr1;
+ U64 u64lo, u64hi;
+
+ dOff = dIdx * 32 + 31;
+ cPtr0 = cTab;
+ cPtr1 = cTab + 33 * 5 - 1;
+
+ /* special first pass since we need to flip sign to create cTab[384], cTab[512] */
+ u64lo.w64 = 0;
+ u64hi.w64 = 0;
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, -(*cPtr1--), delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, -(*cPtr1--), delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+
+ uBuf[0] = u64lo.r.hi32;
+ uBuf[32] = u64hi.r.hi32;
+ uBuf++;
+ dOff--;
+
+ /* max gain for any sample in uBuf, after scaling by cTab, ~= 0.99
+ * so we can just sum the uBuf values with no overflow problems
+ */
+ for (k = 1; k <= 31; k++) {
+ u64lo.w64 = 0;
+ u64hi.w64 = 0;
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+
+ uBuf[0] = u64lo.r.hi32;
+ uBuf[32] = u64hi.r.hi32;
+ uBuf++;
+ dOff--;
+ }
+}
+
+/**************************************************************************************
+ * Function: QMFAnalysis
+ *
+ * Description: 32-subband analysis QMF (4.6.18.4.1)
+ *
+ * Inputs: 32 consecutive samples of decoded 32-bit PCM, format = Q(fBitsIn)
+ * delay buffer of size 32*10 = 320 PCM samples
+ * number of fraction bits in input PCM
+ * index for delay ring buffer (range = [0, 9])
+ * number of subbands to calculate (range = [0, 32])
+ *
+ * Outputs: qmfaBands complex subband samples, format = Q(FBITS_OUT_QMFA)
+ * updated delay buffer
+ * updated delay index
+ *
+ * Return: guard bit mask
+ *
+ * Notes: output stored as RE{X0}, IM{X0}, RE{X1}, IM{X1}, ... RE{X31}, IM{X31}
+ * output stored in int buffer of size 64*2 = 128
+ * (zero-filled from XBuf[2*qmfaBands] to XBuf[127])
+ **************************************************************************************/
+int QMFAnalysis(int *inbuf, int *delay, int *XBuf, int fBitsIn, int *delayIdx, int qmfaBands)
+{
+ int n, y, shift, gbMask;
+ int *delayPtr, *uBuf, *tBuf;
+
+ /* use XBuf[128] as temp buffer for reordering */
+ uBuf = XBuf; /* first 64 samples */
+ tBuf = XBuf + 64; /* second 64 samples */
+
+ /* overwrite oldest PCM with new PCM
+ * delay[n] has 1 GB after shifting (either << or >>)
+ */
+ delayPtr = delay + (*delayIdx * 32);
+ if (fBitsIn > FBITS_IN_QMFA) {
+ shift = MIN(fBitsIn - FBITS_IN_QMFA, 31);
+ for (n = 32; n != 0; n--) {
+ y = (*inbuf) >> shift;
+ inbuf++;
+ *delayPtr++ = y;
+ }
+ } else {
+ shift = MIN(FBITS_IN_QMFA - fBitsIn, 30);
+ for (n = 32; n != 0; n--) {
+ y = *inbuf++;
+ CLIP_2N_SHIFT30(y, shift);
+ *delayPtr++ = y;
+ }
+ }
+
+ QMFAnalysisConv((int *)cTabA, delay, *delayIdx, uBuf);
+
+ /* uBuf has at least 2 GB right now (1 from clipping to Q(FBITS_IN_QMFA), one from
+ * the scaling by cTab (MULSHIFT32(*delayPtr--, *cPtr++), with net gain of < 1.0)
+ * TODO - fuse with QMFAnalysisConv to avoid separate reordering
+ */
+ tBuf[2 * 0 + 0] = uBuf[0];
+ tBuf[2 * 0 + 1] = uBuf[1];
+ for (n = 1; n < 31; n++) {
+ tBuf[2 * n + 0] = -uBuf[64 - n];
+ tBuf[2 * n + 1] = uBuf[n + 1];
+ }
+ tBuf[2 * 31 + 1] = uBuf[32];
+ tBuf[2 * 31 + 0] = -uBuf[33];
+
+ /* fast in-place DCT-IV - only need 2*qmfaBands output samples */
+ PreMultiply64(tBuf); /* 2 GB in, 3 GB out */
+ FFT32C(tBuf); /* 3 GB in, 1 GB out */
+ PostMultiply64(tBuf, qmfaBands * 2); /* 1 GB in, 2 GB out */
+
+ /* TODO - roll into PostMultiply (if enough registers) */
+ gbMask = 0;
+ for (n = 0; n < qmfaBands; n++) {
+ XBuf[2 * n + 0] = tBuf[ n + 0]; /* implicit scaling of 2 in our output Q format */
+ gbMask |= FASTABS(XBuf[2 * n + 0]);
+ XBuf[2 * n + 1] = -tBuf[63 - n];
+ gbMask |= FASTABS(XBuf[2 * n + 1]);
+ }
+
+ /* fill top section with zeros for HF generation */
+ for (; n < 64; n++) {
+ XBuf[2 * n + 0] = 0;
+ XBuf[2 * n + 1] = 0;
+ }
+
+ *delayIdx = (*delayIdx == NUM_QMF_DELAY_BUFS - 1 ? 0 : *delayIdx + 1);
+
+ /* minimum of 2 GB in output */
+ return gbMask;
+}
+
+/* lose FBITS_LOST_DCT4_64 in DCT4, gain 6 for implicit scaling by 1/64, lose 1 for cTab multiply (Q31) */
+#define FBITS_OUT_QMFS (FBITS_IN_QMFS - FBITS_LOST_DCT4_64 + 6 - 1)
+#define RND_VAL (1 << (FBITS_OUT_QMFS-1))
+
+/**************************************************************************************
+ * Function: QMFSynthesisConv
+ *
+ * Description: final convolution kernel for synthesis QMF
+ *
+ * Inputs: pointer to coefficient table, reordered for sequential access
+ * delay buffer of size 64*10 = 640 complex samples (1280 ints)
+ * index for delay ring buffer (range = [0, 9])
+ * number of QMF subbands to process (range = [0, 64])
+ * number of channels
+ *
+ * Outputs: 64 consecutive 16-bit PCM samples, interleaved by factor of nChans
+ *
+ * Return: none
+ *
+ * Notes: this is carefully written to be efficient on ARM
+ * use the assembly code version in sbrqmfsk.s when building for ARM!
+ **************************************************************************************/
+
+#ifdef __cplusplus
+extern "C"
+#endif
+void QMFSynthesisConv(int *cPtr, int *delay, int dIdx, short *outbuf, int nChans)
+{
+ int k, dOff0, dOff1;
+ U64 sum64;
+
+ dOff0 = (dIdx) * 128;
+ dOff1 = dOff0 - 1;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+
+ /* scaling note: total gain of coefs (cPtr[0]-cPtr[9] for any k) is < 2.0, so 1 GB in delay values is adequate */
+ for (k = 0; k <= 63; k++) {
+ sum64.w64 = 0;
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]);
+ dOff0 -= 256;
+ if (dOff0 < 0) {
+ dOff0 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]);
+ dOff1 -= 256;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]);
+ dOff0 -= 256;
+ if (dOff0 < 0) {
+ dOff0 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]);
+ dOff1 -= 256;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]);
+ dOff0 -= 256;
+ if (dOff0 < 0) {
+ dOff0 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]);
+ dOff1 -= 256;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]);
+ dOff0 -= 256;
+ if (dOff0 < 0) {
+ dOff0 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]);
+ dOff1 -= 256;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]);
+ dOff0 -= 256;
+ if (dOff0 < 0) {
+ dOff0 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]);
+ dOff1 -= 256;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+
+ dOff0++;
+ dOff1--;
+ *outbuf = CLIPTOSHORT((sum64.r.hi32 + RND_VAL) >> FBITS_OUT_QMFS);
+ outbuf += nChans;
+ }
+}
+
+/**************************************************************************************
+ * Function: QMFSynthesis
+ *
+ * Description: 64-subband synthesis QMF (4.6.18.4.2)
+ *
+ * Inputs: 64 consecutive complex subband QMF samples, format = Q(FBITS_IN_QMFS)
+ * delay buffer of size 64*10 = 640 complex samples (1280 ints)
+ * index for delay ring buffer (range = [0, 9])
+ * number of QMF subbands to process (range = [0, 64])
+ * number of channels
+ *
+ * Outputs: 64 consecutive 16-bit PCM samples, interleaved by factor of nChans
+ * updated delay buffer
+ * updated delay index
+ *
+ * Return: none
+ *
+ * Notes: assumes MIN_GBITS_IN_QMFS guard bits in input, either from
+ * QMFAnalysis (if upsampling only) or from MapHF (if SBR on)
+ **************************************************************************************/
+void QMFSynthesis(int *inbuf, int *delay, int *delayIdx, int qmfsBands, short *outbuf, int nChans)
+{
+ int n, a0, a1, b0, b1, dOff0, dOff1, dIdx;
+ int *tBufLo, *tBufHi;
+
+ dIdx = *delayIdx;
+ tBufLo = delay + dIdx * 128 + 0;
+ tBufHi = delay + dIdx * 128 + 127;
+
+ /* reorder inputs to DCT-IV, only use first qmfsBands (complex) samples
+ * TODO - fuse with PreMultiply64 to avoid separate reordering steps
+ */
+ for (n = 0; n < qmfsBands >> 1; n++) {
+ a0 = *inbuf++;
+ b0 = *inbuf++;
+ a1 = *inbuf++;
+ b1 = *inbuf++;
+ *tBufLo++ = a0;
+ *tBufLo++ = a1;
+ *tBufHi-- = b0;
+ *tBufHi-- = b1;
+ }
+ if (qmfsBands & 0x01) {
+ a0 = *inbuf++;
+ b0 = *inbuf++;
+ *tBufLo++ = a0;
+ *tBufHi-- = b0;
+ *tBufLo++ = 0;
+ *tBufHi-- = 0;
+ n++;
+ }
+ for (; n < 32; n++) {
+ *tBufLo++ = 0;
+ *tBufHi-- = 0;
+ *tBufLo++ = 0;
+ *tBufHi-- = 0;
+ }
+
+ tBufLo = delay + dIdx * 128 + 0;
+ tBufHi = delay + dIdx * 128 + 64;
+
+ /* 2 GB in, 3 GB out */
+ PreMultiply64(tBufLo);
+ PreMultiply64(tBufHi);
+
+ /* 3 GB in, 1 GB out */
+ FFT32C(tBufLo);
+ FFT32C(tBufHi);
+
+ /* 1 GB in, 2 GB out */
+ PostMultiply64(tBufLo, 64);
+ PostMultiply64(tBufHi, 64);
+
+ /* could fuse with PostMultiply64 to avoid separate pass */
+ dOff0 = dIdx * 128;
+ dOff1 = dIdx * 128 + 64;
+ for (n = 32; n != 0; n--) {
+ a0 = (*tBufLo++);
+ a1 = (*tBufLo++);
+ b0 = (*tBufHi++);
+ b1 = -(*tBufHi++);
+
+ delay[dOff0++] = (b0 - a0);
+ delay[dOff0++] = (b1 - a1);
+ delay[dOff1++] = (b0 + a0);
+ delay[dOff1++] = (b1 + a1);
+ }
+
+ QMFSynthesisConv((int *)cTabS, delay, dIdx, outbuf, nChans);
+
+ *delayIdx = (*delayIdx == NUM_QMF_DELAY_BUFS - 1 ? 0 : *delayIdx + 1);
+}
diff --git a/audio_codec/libraac/sbrqmfak.s b/audio_codec/libraac/sbrqmfak.s
new file mode 100755
index 0000000..ceb3e2b
--- a/dev/null
+++ b/audio_codec/libraac/sbrqmfak.s
@@ -0,0 +1,182 @@
+@ ***** BEGIN LICENSE BLOCK *****
+@ Source last modified: $Id: sbrqmfak.s,v 1.1 2005/04/08 21:59:46 jrecker Exp $
+@
+@ Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+@
+@ The contents of this file, and the files included with this file,
+@ are subject to the current version of the RealNetworks Public
+@ Source License (the "RPSL") available at
+@ http://www.helixcommunity.org/content/rpsl unless you have licensed
+@ the file under the current version of the RealNetworks Community
+@ Source License (the "RCSL") available at
+@ http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+@ will apply. You may also obtain the license terms directly from
+@ RealNetworks. You may not use this file except in compliance with
+@ the RPSL or, if you have a valid RCSL with RealNetworks applicable
+@ to this file, the RCSL. Please see the applicable RPSL or RCSL for
+@ the rights, obligations and limitations governing use of the
+@ contents of the file.
+@
+@ This file is part of the Helix DNA Technology. RealNetworks is the
+@ developer and/or licensor of the Original Code and owns the
+@ copyrights in the portions it created.
+@
+@ This file, and the files included with this file, is distributed
+@ and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+@ KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+@ ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+@ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+@ ENJOYMENT OR NON-INFRINGEMENT.
+@
+@ Technology Compatibility Kit Test Suite(s) Location:
+@ http://www.helixcommunity.org/content/tck
+@
+@ Contributor(s):
+@
+@ ***** END LICENSE BLOCK *****
+
+ .text
+ .code 32
+ .align
+
+@void QMFAnalysisConv(int *cTab, int *delay, int dIdx, int *uBuf)
+@ see comments in sbrqmf.c
+
+ .global raac_QMFAnalysisConv
+ .type raac_QMFAnalysisConv, %function
+raac_QMFAnalysisConv:
+ stmfd sp!, {r4-r11, r14}
+
+ mov r6, r2, lsl #5 @ dOff0 = 32*dIdx
+ add r6, r6, #31 @ dOff0 = 32*dIdx + 31
+ add r4, r0, #4*(164) @ cPtr1 = cPtr0 + 164
+
+ @ special first pass (flip sign for cTab[384], cTab[512])
+ ldr r11, [r0], #4
+ ldr r14, [r0], #4
+ ldr r12, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ ldr r2, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ smull r7, r8, r11, r12
+ smull r9, r10, r14, r2
+
+ ldr r11, [r0], #4
+ ldr r14, [r0], #4
+ ldr r12, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ ldr r2, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ smlal r7, r8, r11, r12
+ smlal r9, r10, r14, r2
+
+ ldr r11, [r0], #4
+ ldr r14, [r4], #-4
+ ldr r12, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ ldr r2, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ smlal r7, r8, r11, r12
+ smlal r9, r10, r14, r2
+
+ ldr r11, [r4], #-4
+ ldr r14, [r4], #-4
+ ldr r12, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ ldr r2, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ rsb r11, r11, #0
+ smlal r7, r8, r11, r12
+ smlal r9, r10, r14, r2
+
+ ldr r11, [r4], #-4
+ ldr r14, [r4], #-4
+ ldr r12, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ ldr r2, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ rsb r11, r11, #0
+ smlal r7, r8, r11, r12
+ smlal r9, r10, r14, r2
+
+ str r10, [r3, #4*32]
+ str r8, [r3], #4
+ sub r6, r6, #1
+ mov r5, #31
+
+SRC_Loop_Start:
+ ldr r11, [r0], #4
+ ldr r14, [r0], #4
+ ldr r12, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ ldr r2, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ smull r7, r8, r11, r12
+ smull r9, r10, r14, r2
+
+ ldr r11, [r0], #4
+ ldr r14, [r0], #4
+ ldr r12, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ ldr r2, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ smlal r7, r8, r11, r12
+ smlal r9, r10, r14, r2
+
+ ldr r11, [r0], #4
+ ldr r14, [r4], #-4
+ ldr r12, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ ldr r2, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ smlal r7, r8, r11, r12
+ smlal r9, r10, r14, r2
+
+ ldr r11, [r4], #-4
+ ldr r14, [r4], #-4
+ ldr r12, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ ldr r2, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ smlal r7, r8, r11, r12
+ smlal r9, r10, r14, r2
+
+ ldr r11, [r4], #-4
+ ldr r14, [r4], #-4
+ ldr r12, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ ldr r2, [r1, r6, lsl #2]
+ subs r6, r6, #32
+ addlt r6, r6, #320
+ smlal r7, r8, r11, r12
+ smlal r9, r10, r14, r2
+
+ str r10, [r3, #4*32]
+ str r8, [r3], #4
+ sub r6, r6, #1
+
+ subs r5, r5, #1
+ bne SRC_Loop_Start
+
+ ldmfd sp!, {r4-r11, pc}
+
+ .end
diff --git a/audio_codec/libraac/sbrqmfsk.s b/audio_codec/libraac/sbrqmfsk.s
new file mode 100755
index 0000000..ea93f7a
--- a/dev/null
+++ b/audio_codec/libraac/sbrqmfsk.s
@@ -0,0 +1,130 @@
+@ ***** BEGIN LICENSE BLOCK *****
+@ Source last modified: $Id: sbrqmfsk.s,v 1.1 2005/04/08 21:59:46 jrecker Exp $
+@
+@ Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+@
+@ The contents of this file, and the files included with this file,
+@ are subject to the current version of the RealNetworks Public
+@ Source License (the "RPSL") available at
+@ http://www.helixcommunity.org/content/rpsl unless you have licensed
+@ the file under the current version of the RealNetworks Community
+@ Source License (the "RCSL") available at
+@ http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+@ will apply. You may also obtain the license terms directly from
+@ RealNetworks. You may not use this file except in compliance with
+@ the RPSL or, if you have a valid RCSL with RealNetworks applicable
+@ to this file, the RCSL. Please see the applicable RPSL or RCSL for
+@ the rights, obligations and limitations governing use of the
+@ contents of the file.
+@
+@ This file is part of the Helix DNA Technology. RealNetworks is the
+@ developer and/or licensor of the Original Code and owns the
+@ copyrights in the portions it created.
+@
+@ This file, and the files included with this file, is distributed
+@ and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+@ KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+@ ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+@ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+@ ENJOYMENT OR NON-INFRINGEMENT.
+@
+@ Technology Compatibility Kit Test Suite(s) Location:
+@ http://www.helixcommunity.org/content/tck
+@
+@ Contributor(s):
+@
+@ ***** END LICENSE BLOCK *****
+
+ .text
+ .code 32
+ .align
+
+@ void QMFSynthesisConv(int *cPtr, int *delay, int dIdx, short *outbuf, int nChans);
+@ see comments in sbrqmf.c
+
+ .global raac_QMFSynthesisConv
+ .type raac_QMFSynthesisConv, %function
+raac_QMFSynthesisConv:
+ stmfd sp!, {r4-r11, r14}
+
+ ldr r9, [r13, #4*9] @ we saved 9 registers on stack
+ mov r5, r2, lsl #7 @ dOff0 = 128*dIdx
+ subs r6, r5, #1 @ dOff1 = dOff0 - 1
+ addlt r6, r6, #1280 @ if (dOff1 < 0) then dOff1 += 1280
+ mov r4, #64
+
+SRC_Loop_Start:
+ ldr r10, [r0], #4
+ ldr r12, [r0], #4
+ ldr r11, [r1, r5, lsl #2]
+ ldr r14, [r1, r6, lsl #2]
+ smull r7, r8, r10, r11
+ subs r5, r5, #256
+ addlt r5, r5, #1280
+ smlal r7, r8, r12, r14
+ subs r6, r6, #256
+ addlt r6, r6, #1280
+
+ ldr r10, [r0], #4
+ ldr r12, [r0], #4
+ ldr r11, [r1, r5, lsl #2]
+ ldr r14, [r1, r6, lsl #2]
+ smlal r7, r8, r10, r11
+ subs r5, r5, #256
+ addlt r5, r5, #1280
+ smlal r7, r8, r12, r14
+ subs r6, r6, #256
+ addlt r6, r6, #1280
+
+ ldr r10, [r0], #4
+ ldr r12, [r0], #4
+ ldr r11, [r1, r5, lsl #2]
+ ldr r14, [r1, r6, lsl #2]
+ smlal r7, r8, r10, r11
+ subs r5, r5, #256
+ addlt r5, r5, #1280
+ smlal r7, r8, r12, r14
+ subs r6, r6, #256
+ addlt r6, r6, #1280
+
+ ldr r10, [r0], #4
+ ldr r12, [r0], #4
+ ldr r11, [r1, r5, lsl #2]
+ ldr r14, [r1, r6, lsl #2]
+ smlal r7, r8, r10, r11
+ subs r5, r5, #256
+ addlt r5, r5, #1280
+ smlal r7, r8, r12, r14
+ subs r6, r6, #256
+ addlt r6, r6, #1280
+
+ ldr r10, [r0], #4
+ ldr r12, [r0], #4
+ ldr r11, [r1, r5, lsl #2]
+ ldr r14, [r1, r6, lsl #2]
+ smlal r7, r8, r10, r11
+ subs r5, r5, #256
+ addlt r5, r5, #1280
+ smlal r7, r8, r12, r14
+ subs r6, r6, #256
+ addlt r6, r6, #1280
+
+ add r5, r5, #1
+ sub r6, r6, #1
+
+ add r8, r8, #0x04
+ mov r8, r8, asr #3 @ FBITS_OUT_QMFS
+ mov r7, r8, asr #31
+ cmp r7, r8, asr #15
+ eorne r8, r7, #0x7f00 @ takes 2 instructions for immediate value of 0x7fffffff
+ eorne r8, r8, #0x00ff
+ strh r8, [r3, #0]
+ add r3, r3, r9, lsl #1
+
+ subs r4, r4, #1
+ bne SRC_Loop_Start
+
+ ldmfd sp!, {r4-r11, pc}
+
+ .end
+
diff --git a/audio_codec/libraac/sbrside.c b/audio_codec/libraac/sbrside.c
new file mode 100644
index 0000000..e2742f6
--- a/dev/null
+++ b/audio_codec/libraac/sbrside.c
@@ -0,0 +1,615 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrside.c,v 1.2 2005/05/24 16:01:55 albertofloyd Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrside.c - functions for unpacking side info from SBR bitstream
+ **************************************************************************************/
+
+#include "sbr.h"
+
+/**************************************************************************************
+ * Function: GetSampRateIdx
+ *
+ * Description: get index of given sample rate
+ *
+ * Inputs: sample rate (in Hz)
+ *
+ * Outputs: none
+ *
+ * Return: index of sample rate (table 1.15 in 14496-3:2001(E))
+ * -1 if sample rate not found in table
+ **************************************************************************************/
+int GetSampRateIdx(int sampRate)
+{
+ int idx;
+
+ for (idx = 0; idx < NUM_SAMPLE_RATES; idx++) {
+ if (sampRate == sampRateTab[idx]) {
+ return idx;
+ }
+ }
+
+ return -1;
+}
+
+/**************************************************************************************
+ * Function: UnpackSBRHeader
+ *
+ * Description: unpack SBR header (table 4.56)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of SBR header
+ *
+ * Outputs: initialized SBRHeader struct for this SCE/CPE block
+ *
+ * Return: non-zero if frame reset is triggered, zero otherwise
+ **************************************************************************************/
+int UnpackSBRHeader(BitStreamInfo *bsi, SBRHeader *sbrHdr)
+{
+ SBRHeader sbrHdrPrev;
+
+ /* save previous values so we know whether to reset decoder */
+ sbrHdrPrev.startFreq = sbrHdr->startFreq;
+ sbrHdrPrev.stopFreq = sbrHdr->stopFreq;
+ sbrHdrPrev.freqScale = sbrHdr->freqScale;
+ sbrHdrPrev.alterScale = sbrHdr->alterScale;
+ sbrHdrPrev.crossOverBand = sbrHdr->crossOverBand;
+ sbrHdrPrev.noiseBands = sbrHdr->noiseBands;
+
+ sbrHdr->ampRes = GetBits(bsi, 1);
+ sbrHdr->startFreq = GetBits(bsi, 4);
+ sbrHdr->stopFreq = GetBits(bsi, 4);
+ sbrHdr->crossOverBand = GetBits(bsi, 3);
+ sbrHdr->resBitsHdr = GetBits(bsi, 2);
+ sbrHdr->hdrExtra1 = GetBits(bsi, 1);
+ sbrHdr->hdrExtra2 = GetBits(bsi, 1);
+
+ if (sbrHdr->hdrExtra1) {
+ sbrHdr->freqScale = GetBits(bsi, 2);
+ sbrHdr->alterScale = GetBits(bsi, 1);
+ sbrHdr->noiseBands = GetBits(bsi, 2);
+ } else {
+ /* defaults */
+ sbrHdr->freqScale = 2;
+ sbrHdr->alterScale = 1;
+ sbrHdr->noiseBands = 2;
+ }
+
+ if (sbrHdr->hdrExtra2) {
+ sbrHdr->limiterBands = GetBits(bsi, 2);
+ sbrHdr->limiterGains = GetBits(bsi, 2);
+ sbrHdr->interpFreq = GetBits(bsi, 1);
+ sbrHdr->smoothMode = GetBits(bsi, 1);
+ } else {
+ /* defaults */
+ sbrHdr->limiterBands = 2;
+ sbrHdr->limiterGains = 2;
+ sbrHdr->interpFreq = 1;
+ sbrHdr->smoothMode = 1;
+ }
+ sbrHdr->count++;
+
+ /* if any of these have changed from previous frame, reset the SBR module */
+ if (sbrHdr->startFreq != sbrHdrPrev.startFreq || sbrHdr->stopFreq != sbrHdrPrev.stopFreq ||
+ sbrHdr->freqScale != sbrHdrPrev.freqScale || sbrHdr->alterScale != sbrHdrPrev.alterScale ||
+ sbrHdr->crossOverBand != sbrHdrPrev.crossOverBand || sbrHdr->noiseBands != sbrHdrPrev.noiseBands
+ ) {
+ return -1;
+ } else {
+ return 0;
+ }
+}
+
+/* cLog2[i] = ceil(log2(i)) (disregard i == 0) */
+static const unsigned char cLog2[9] = {0, 0, 1, 2, 2, 3, 3, 3, 3};
+
+/**************************************************************************************
+ * Function: UnpackSBRGrid
+ *
+ * Description: unpack SBR grid (table 4.62)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of SBR grid
+ * initialized SBRHeader struct for this SCE/CPE block
+ *
+ * Outputs: initialized SBRGrid struct for this channel
+ *
+ * Return: none
+ **************************************************************************************/
+static void UnpackSBRGrid(BitStreamInfo *bsi, SBRHeader *sbrHdr, SBRGrid *sbrGrid)
+{
+ int numEnvRaw, env, rel, pBits, border, middleBorder = 0;
+ unsigned char relBordLead[MAX_NUM_ENV], relBordTrail[MAX_NUM_ENV];
+ unsigned char relBorder0[3], relBorder1[3], relBorder[3];
+ unsigned char numRelBorder0, numRelBorder1, numRelBorder, numRelLead = 0, numRelTrail;
+ unsigned char absBordLead = 0, absBordTrail = 0, absBorder;
+
+ sbrGrid->ampResFrame = sbrHdr->ampRes;
+ sbrGrid->frameClass = GetBits(bsi, 2);
+ switch (sbrGrid->frameClass) {
+
+ case SBR_GRID_FIXFIX:
+ numEnvRaw = GetBits(bsi, 2);
+ sbrGrid->numEnv = (1 << numEnvRaw);
+ if (sbrGrid->numEnv == 1) {
+ sbrGrid->ampResFrame = 0;
+ }
+
+ ASSERT(sbrGrid->numEnv == 1 || sbrGrid->numEnv == 2 || sbrGrid->numEnv == 4);
+
+ sbrGrid->freqRes[0] = GetBits(bsi, 1);
+ for (env = 1; env < sbrGrid->numEnv; env++) {
+ sbrGrid->freqRes[env] = sbrGrid->freqRes[0];
+ }
+
+ absBordLead = 0;
+ absBordTrail = NUM_TIME_SLOTS;
+ numRelLead = sbrGrid->numEnv - 1;
+ numRelTrail = 0;
+
+ /* numEnv = 1, 2, or 4 */
+ if (sbrGrid->numEnv == 1) {
+ border = NUM_TIME_SLOTS / 1;
+ } else if (sbrGrid->numEnv == 2) {
+ border = NUM_TIME_SLOTS / 2;
+ } else {
+ border = NUM_TIME_SLOTS / 4;
+ }
+
+ for (rel = 0; rel < numRelLead; rel++) {
+ relBordLead[rel] = border;
+ }
+
+ middleBorder = (sbrGrid->numEnv >> 1);
+
+ break;
+
+ case SBR_GRID_FIXVAR:
+ absBorder = GetBits(bsi, 2) + NUM_TIME_SLOTS;
+ numRelBorder = GetBits(bsi, 2);
+ sbrGrid->numEnv = numRelBorder + 1;
+ for (rel = 0; rel < numRelBorder; rel++) {
+ relBorder[rel] = 2 * GetBits(bsi, 2) + 2;
+ }
+
+ pBits = cLog2[sbrGrid->numEnv + 1];
+ sbrGrid->pointer = GetBits(bsi, pBits);
+
+ for (env = sbrGrid->numEnv - 1; env >= 0; env--) {
+ sbrGrid->freqRes[env] = GetBits(bsi, 1);
+ }
+
+ absBordLead = 0;
+ absBordTrail = absBorder;
+ numRelLead = 0;
+ numRelTrail = numRelBorder;
+
+ for (rel = 0; rel < numRelTrail; rel++) {
+ relBordTrail[rel] = relBorder[rel];
+ }
+
+ if (sbrGrid->pointer > 1) {
+ middleBorder = sbrGrid->numEnv + 1 - sbrGrid->pointer;
+ } else {
+ middleBorder = sbrGrid->numEnv - 1;
+ }
+
+ break;
+
+ case SBR_GRID_VARFIX:
+ absBorder = GetBits(bsi, 2);
+ numRelBorder = GetBits(bsi, 2);
+ sbrGrid->numEnv = numRelBorder + 1;
+ for (rel = 0; rel < numRelBorder; rel++) {
+ relBorder[rel] = 2 * GetBits(bsi, 2) + 2;
+ }
+
+ pBits = cLog2[sbrGrid->numEnv + 1];
+ sbrGrid->pointer = GetBits(bsi, pBits);
+
+ for (env = 0; env < sbrGrid->numEnv; env++) {
+ sbrGrid->freqRes[env] = GetBits(bsi, 1);
+ }
+
+ absBordLead = absBorder;
+ absBordTrail = NUM_TIME_SLOTS;
+ numRelLead = numRelBorder;
+ numRelTrail = 0;
+
+ for (rel = 0; rel < numRelLead; rel++) {
+ relBordLead[rel] = relBorder[rel];
+ }
+
+ if (sbrGrid->pointer == 0) {
+ middleBorder = 1;
+ } else if (sbrGrid->pointer == 1) {
+ middleBorder = sbrGrid->numEnv - 1;
+ } else {
+ middleBorder = sbrGrid->pointer - 1;
+ }
+
+ break;
+
+ case SBR_GRID_VARVAR:
+ absBordLead = GetBits(bsi, 2); /* absBorder0 */
+ absBordTrail = GetBits(bsi, 2) + NUM_TIME_SLOTS; /* absBorder1 */
+ numRelBorder0 = GetBits(bsi, 2);
+ numRelBorder1 = GetBits(bsi, 2);
+
+ sbrGrid->numEnv = numRelBorder0 + numRelBorder1 + 1;
+ ASSERT(sbrGrid->numEnv <= 5);
+
+ for (rel = 0; rel < numRelBorder0; rel++) {
+ relBorder0[rel] = 2 * GetBits(bsi, 2) + 2;
+ }
+
+ for (rel = 0; rel < numRelBorder1; rel++) {
+ relBorder1[rel] = 2 * GetBits(bsi, 2) + 2;
+ }
+
+ pBits = cLog2[numRelBorder0 + numRelBorder1 + 2];
+ sbrGrid->pointer = GetBits(bsi, pBits);
+
+ for (env = 0; env < sbrGrid->numEnv; env++) {
+ sbrGrid->freqRes[env] = GetBits(bsi, 1);
+ }
+
+ numRelLead = numRelBorder0;
+ numRelTrail = numRelBorder1;
+
+ for (rel = 0; rel < numRelLead; rel++) {
+ relBordLead[rel] = relBorder0[rel];
+ }
+
+ for (rel = 0; rel < numRelTrail; rel++) {
+ relBordTrail[rel] = relBorder1[rel];
+ }
+
+ if (sbrGrid->pointer > 1) {
+ middleBorder = sbrGrid->numEnv + 1 - sbrGrid->pointer;
+ } else {
+ middleBorder = sbrGrid->numEnv - 1;
+ }
+
+ break;
+ }
+
+ /* build time border vector */
+ sbrGrid->envTimeBorder[0] = absBordLead * SAMPLES_PER_SLOT;
+
+ rel = 0;
+ border = absBordLead;
+ for (env = 1; env <= numRelLead; env++) {
+ border += relBordLead[rel++];
+ sbrGrid->envTimeBorder[env] = border * SAMPLES_PER_SLOT;
+ }
+
+ rel = 0;
+ border = absBordTrail;
+ for (env = sbrGrid->numEnv - 1; env > numRelLead; env--) {
+ border -= relBordTrail[rel++];
+ sbrGrid->envTimeBorder[env] = border * SAMPLES_PER_SLOT;
+ }
+
+ sbrGrid->envTimeBorder[sbrGrid->numEnv] = absBordTrail * SAMPLES_PER_SLOT;
+
+ if (sbrGrid->numEnv > 1) {
+ sbrGrid->numNoiseFloors = 2;
+ sbrGrid->noiseTimeBorder[0] = sbrGrid->envTimeBorder[0];
+ sbrGrid->noiseTimeBorder[1] = sbrGrid->envTimeBorder[middleBorder];
+ sbrGrid->noiseTimeBorder[2] = sbrGrid->envTimeBorder[sbrGrid->numEnv];
+ } else {
+ sbrGrid->numNoiseFloors = 1;
+ sbrGrid->noiseTimeBorder[0] = sbrGrid->envTimeBorder[0];
+ sbrGrid->noiseTimeBorder[1] = sbrGrid->envTimeBorder[1];
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackDeltaTimeFreq
+ *
+ * Description: unpack time/freq flags for delta coding of SBR envelopes (table 4.63)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of dt/df flags
+ * number of envelopes
+ * number of noise floors
+ *
+ * Outputs: delta flags for envelope and noise floors
+ *
+ * Return: none
+ **************************************************************************************/
+static void UnpackDeltaTimeFreq(BitStreamInfo *bsi, int numEnv, unsigned char *deltaFlagEnv,
+ int numNoiseFloors, unsigned char *deltaFlagNoise)
+{
+ int env, noiseFloor;
+
+ for (env = 0; env < numEnv; env++) {
+ deltaFlagEnv[env] = GetBits(bsi, 1);
+ }
+
+ for (noiseFloor = 0; noiseFloor < numNoiseFloors; noiseFloor++) {
+ deltaFlagNoise[noiseFloor] = GetBits(bsi, 1);
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackInverseFilterMode
+ *
+ * Description: unpack invf flags for chirp factor calculation (table 4.64)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of invf flags
+ * number of noise floor bands
+ *
+ * Outputs: invf flags for noise floor bands
+ *
+ * Return: none
+ **************************************************************************************/
+static void UnpackInverseFilterMode(BitStreamInfo *bsi, int numNoiseFloorBands, unsigned char *mode)
+{
+ int n;
+
+ for (n = 0; n < numNoiseFloorBands; n++) {
+ mode[n] = GetBits(bsi, 2);
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackSinusoids
+ *
+ * Description: unpack sinusoid (harmonic) flags for each SBR subband (table 4.67)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of sinusoid flags
+ * number of high resolution SBR subbands (nHigh)
+ *
+ * Outputs: sinusoid flags for each SBR subband, zero-filled above nHigh
+ *
+ * Return: none
+ **************************************************************************************/
+static void UnpackSinusoids(BitStreamInfo *bsi, int nHigh, int addHarmonicFlag, unsigned char *addHarmonic)
+{
+ int n;
+
+ n = 0;
+ if (addHarmonicFlag) {
+ for (; n < nHigh; n++) {
+ addHarmonic[n] = GetBits(bsi, 1);
+ }
+ }
+
+ /* zero out unused bands */
+ for (; n < MAX_QMF_BANDS; n++) {
+ addHarmonic[n] = 0;
+ }
+}
+
+/**************************************************************************************
+ * Function: CopyCouplingGrid
+ *
+ * Description: copy grid parameters from left to right for channel coupling
+ *
+ * Inputs: initialized SBRGrid struct for left channel
+ *
+ * Outputs: initialized SBRGrid struct for right channel
+ *
+ * Return: none
+ **************************************************************************************/
+static void CopyCouplingGrid(SBRGrid *sbrGridLeft, SBRGrid *sbrGridRight)
+{
+ int env, noiseFloor;
+
+ sbrGridRight->frameClass = sbrGridLeft->frameClass;
+ sbrGridRight->ampResFrame = sbrGridLeft->ampResFrame;
+ sbrGridRight->pointer = sbrGridLeft->pointer;
+
+ sbrGridRight->numEnv = sbrGridLeft->numEnv;
+ for (env = 0; env < sbrGridLeft->numEnv; env++) {
+ sbrGridRight->envTimeBorder[env] = sbrGridLeft->envTimeBorder[env];
+ sbrGridRight->freqRes[env] = sbrGridLeft->freqRes[env];
+ }
+ sbrGridRight->envTimeBorder[env] = sbrGridLeft->envTimeBorder[env]; /* borders are [0, numEnv] inclusive */
+
+ sbrGridRight->numNoiseFloors = sbrGridLeft->numNoiseFloors;
+ for (noiseFloor = 0; noiseFloor <= sbrGridLeft->numNoiseFloors; noiseFloor++) {
+ sbrGridRight->noiseTimeBorder[noiseFloor] = sbrGridLeft->noiseTimeBorder[noiseFloor];
+ }
+
+ /* numEnvPrev, numNoiseFloorsPrev, freqResPrev are updated in DecodeSBREnvelope() and DecodeSBRNoise() */
+}
+
+/**************************************************************************************
+ * Function: CopyCouplingInverseFilterMode
+ *
+ * Description: copy invf flags from left to right for channel coupling
+ *
+ * Inputs: invf flags for left channel
+ * number of noise floor bands
+ *
+ * Outputs: invf flags for right channel
+ *
+ * Return: none
+ **************************************************************************************/
+static void CopyCouplingInverseFilterMode(int numNoiseFloorBands, unsigned char *modeLeft, unsigned char *modeRight)
+{
+ int band;
+
+ for (band = 0; band < numNoiseFloorBands; band++) {
+ modeRight[band] = modeLeft[band];
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackSBRSingleChannel
+ *
+ * Description: unpack sideband info (grid, delta flags, invf flags, envelope and
+ * noise floor configuration, sinusoids) for a single channel
+ *
+ * Inputs: BitStreamInfo struct pointing to start of sideband info
+ * initialized PSInfoSBR struct (after parsing SBR header and building
+ * frequency tables)
+ * base output channel (range = [0, nChans-1])
+ *
+ * Outputs: updated PSInfoSBR struct (SBRGrid and SBRChan)
+ *
+ * Return: none
+ **************************************************************************************/
+void UnpackSBRSingleChannel(BitStreamInfo *bsi, PSInfoSBR *psi, int chBase)
+{
+ int bitsLeft;
+ SBRHeader *sbrHdr = &(psi->sbrHdr[chBase]);
+ SBRGrid *sbrGridL = &(psi->sbrGrid[chBase + 0]);
+ SBRFreq *sbrFreq = &(psi->sbrFreq[chBase]);
+ SBRChan *sbrChanL = &(psi->sbrChan[chBase + 0]);
+
+ psi->dataExtra = GetBits(bsi, 1);
+ if (psi->dataExtra) {
+ psi->resBitsData = GetBits(bsi, 4);
+ }
+
+ UnpackSBRGrid(bsi, sbrHdr, sbrGridL);
+ UnpackDeltaTimeFreq(bsi, sbrGridL->numEnv, sbrChanL->deltaFlagEnv, sbrGridL->numNoiseFloors, sbrChanL->deltaFlagNoise);
+ UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1]);
+
+ DecodeSBREnvelope(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ DecodeSBRNoise(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+
+ sbrChanL->addHarmonicFlag[1] = GetBits(bsi, 1);
+ UnpackSinusoids(bsi, sbrFreq->nHigh, sbrChanL->addHarmonicFlag[1], sbrChanL->addHarmonic[1]);
+
+ psi->extendedDataPresent = GetBits(bsi, 1);
+ if (psi->extendedDataPresent) {
+ psi->extendedDataSize = GetBits(bsi, 4);
+ if (psi->extendedDataSize == 15) {
+ psi->extendedDataSize += GetBits(bsi, 8);
+ }
+
+ bitsLeft = 8 * psi->extendedDataSize;
+
+ /* get ID, unpack extension info, do whatever is necessary with it... */
+ while (bitsLeft > 0) {
+ GetBits(bsi, 8);
+ bitsLeft -= 8;
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackSBRChannelPair
+ *
+ * Description: unpack sideband info (grid, delta flags, invf flags, envelope and
+ * noise floor configuration, sinusoids) for a channel pair
+ *
+ * Inputs: BitStreamInfo struct pointing to start of sideband info
+ * initialized PSInfoSBR struct (after parsing SBR header and building
+ * frequency tables)
+ * base output channel (range = [0, nChans-1])
+ *
+ * Outputs: updated PSInfoSBR struct (SBRGrid and SBRChan for both channels)
+ *
+ * Return: none
+ **************************************************************************************/
+void UnpackSBRChannelPair(BitStreamInfo *bsi, PSInfoSBR *psi, int chBase)
+{
+ int bitsLeft;
+ SBRHeader *sbrHdr = &(psi->sbrHdr[chBase]);
+ SBRGrid *sbrGridL = &(psi->sbrGrid[chBase + 0]), *sbrGridR = &(psi->sbrGrid[chBase + 1]);
+ SBRFreq *sbrFreq = &(psi->sbrFreq[chBase]);
+ SBRChan *sbrChanL = &(psi->sbrChan[chBase + 0]), *sbrChanR = &(psi->sbrChan[chBase + 1]);
+
+ psi->dataExtra = GetBits(bsi, 1);
+ if (psi->dataExtra) {
+ psi->resBitsData = GetBits(bsi, 4);
+ psi->resBitsData = GetBits(bsi, 4);
+ }
+
+ psi->couplingFlag = GetBits(bsi, 1);
+ if (psi->couplingFlag) {
+ UnpackSBRGrid(bsi, sbrHdr, sbrGridL);
+ CopyCouplingGrid(sbrGridL, sbrGridR);
+
+ UnpackDeltaTimeFreq(bsi, sbrGridL->numEnv, sbrChanL->deltaFlagEnv, sbrGridL->numNoiseFloors, sbrChanL->deltaFlagNoise);
+ UnpackDeltaTimeFreq(bsi, sbrGridR->numEnv, sbrChanR->deltaFlagEnv, sbrGridR->numNoiseFloors, sbrChanR->deltaFlagNoise);
+
+ UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1]);
+ CopyCouplingInverseFilterMode(sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1], sbrChanR->invfMode[1]);
+
+ DecodeSBREnvelope(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ DecodeSBRNoise(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ DecodeSBREnvelope(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1);
+ DecodeSBRNoise(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1);
+
+ /* pass RIGHT sbrChan struct */
+ UncoupleSBREnvelope(psi, sbrGridL, sbrFreq, sbrChanR);
+ UncoupleSBRNoise(psi, sbrGridL, sbrFreq, sbrChanR);
+
+ } else {
+ UnpackSBRGrid(bsi, sbrHdr, sbrGridL);
+ UnpackSBRGrid(bsi, sbrHdr, sbrGridR);
+ UnpackDeltaTimeFreq(bsi, sbrGridL->numEnv, sbrChanL->deltaFlagEnv, sbrGridL->numNoiseFloors, sbrChanL->deltaFlagNoise);
+ UnpackDeltaTimeFreq(bsi, sbrGridR->numEnv, sbrChanR->deltaFlagEnv, sbrGridR->numNoiseFloors, sbrChanR->deltaFlagNoise);
+ UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1]);
+ UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanR->invfMode[1]);
+
+ DecodeSBREnvelope(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ DecodeSBREnvelope(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1);
+ DecodeSBRNoise(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ DecodeSBRNoise(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1);
+ }
+
+ sbrChanL->addHarmonicFlag[1] = GetBits(bsi, 1);
+ UnpackSinusoids(bsi, sbrFreq->nHigh, sbrChanL->addHarmonicFlag[1], sbrChanL->addHarmonic[1]);
+
+ sbrChanR->addHarmonicFlag[1] = GetBits(bsi, 1);
+ UnpackSinusoids(bsi, sbrFreq->nHigh, sbrChanR->addHarmonicFlag[1], sbrChanR->addHarmonic[1]);
+
+ psi->extendedDataPresent = GetBits(bsi, 1);
+ if (psi->extendedDataPresent) {
+ psi->extendedDataSize = GetBits(bsi, 4);
+ if (psi->extendedDataSize == 15) {
+ psi->extendedDataSize += GetBits(bsi, 8);
+ }
+
+ bitsLeft = 8 * psi->extendedDataSize;
+
+ /* get ID, unpack extension info, do whatever is necessary with it... */
+ while (bitsLeft > 0) {
+ GetBits(bsi, 8);
+ bitsLeft -= 8;
+ }
+ }
+}
diff --git a/audio_codec/libraac/sbrtabs.c b/audio_codec/libraac/sbrtabs.c
new file mode 100644
index 0000000..d7ba798
--- a/dev/null
+++ b/audio_codec/libraac/sbrtabs.c
@@ -0,0 +1,400 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrtabs.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrtabs.c - platform-independent tables for SBR (global, read-only)
+ **************************************************************************************/
+
+#include "sbr.h"
+
+/* k0Tab[sampRateIdx][k] = k0 = startMin + offset(bs_start_freq) for given sample rate (4.6.18.3.2.1)
+ * downsampled (single-rate) SBR not currently supported
+ */
+const unsigned char k0Tab[NUM_SAMPLE_RATES_SBR][16] = {
+ { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 23, 27, 31 }, /* 96 kHz */
+ { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 23, 27, 31 }, /* 88 kHz */
+ { 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, 23, 26, 30 }, /* 64 kHz */
+ { 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 27, 31 }, /* 48 kHz */
+ { 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 23, 25, 28, 32 }, /* 44 kHz */
+ { 10, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 27, 29, 32 }, /* 32 kHz */
+ { 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 27, 29, 32 }, /* 24 kHz */
+ { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, 30 }, /* 22 kHz */
+ { 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }, /* 16 kHz */
+};
+
+/* k2Tab[sampRateIdx][k] = stopVector(bs_stop_freq) for given sample rate, bs_stop_freq = [0, 13] (4.6.18.3.2.1)
+ * generated with Matlab script calc_stopvec.m
+ * downsampled (single-rate) SBR not currently supported
+ */
+const unsigned char k2Tab[NUM_SAMPLE_RATES_SBR][14] = {
+ { 13, 15, 17, 19, 21, 24, 27, 31, 35, 39, 44, 50, 57, 64 }, /* 96 kHz */
+ { 15, 17, 19, 21, 23, 26, 29, 33, 37, 41, 46, 51, 57, 64 }, /* 88 kHz */
+ { 20, 22, 24, 26, 28, 31, 34, 37, 41, 45, 49, 54, 59, 64 }, /* 64 kHz */
+ { 21, 23, 25, 27, 29, 32, 35, 38, 41, 45, 49, 54, 59, 64 }, /* 48 kHz */
+ { 23, 25, 27, 29, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64 }, /* 44 kHz */
+ { 32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61, 64 }, /* 32 kHz */
+ { 32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61, 64 }, /* 24 kHz */
+ { 35, 36, 38, 40, 42, 44, 46, 48, 50, 52, 55, 58, 61, 64 }, /* 22 kHz */
+ { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 62, 64 }, /* 16 kHz */
+};
+
+/* NINT(2.048E6 / Fs) (figure 4.47)
+ * downsampled (single-rate) SBR not currently supported
+ */
+const unsigned char goalSBTab[NUM_SAMPLE_RATES_SBR] = {
+ 21, 23, 32, 43, 46, 64, 85, 93, 128
+};
+
+const HuffInfo huffTabSBRInfo[10] = {
+ {19, { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 2, 7, 4, 8, 72, 0}, 0},
+ {20, { 0, 2, 2, 2, 2, 2, 1, 3, 3, 2, 4, 4, 4, 3, 2, 5, 6, 13, 15, 46}, 121},
+ {17, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 0, 0, 1, 25, 10, 0, 0, 0}, 242},
+ {19, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 3, 1, 0, 1, 1, 2, 1, 29, 2, 0}, 291},
+ {19, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 2, 5, 1, 4, 2, 3, 34, 0}, 340},
+ {20, { 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 1, 2, 3, 4, 4, 7, 10, 16}, 403},
+ {14, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 13, 2, 0, 0, 0, 0, 0, 0}, 466},
+ {14, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 6, 8, 0, 0, 0, 0, 0, 0}, 491},
+ {14, { 1, 1, 1, 1, 1, 1, 0, 2, 0, 1, 1, 0, 51, 2, 0, 0, 0, 0, 0, 0}, 516},
+ { 8, { 1, 1, 1, 0, 1, 1, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 579},
+};
+
+/* Huffman tables from appendix 4.A.6.1, includes offset of -LAV[i] for table i */
+const signed short huffTabSBR[604] = {
+ /* SBR table sbr_tenv15 [121] (signed) */
+ 0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8,
+ -9, 8, -10, 9, -11, 10, -12, -13, 11, -14, 12, -15, -16, 13, -19, -18,
+ -17, 14, -24, -20, 16, -26, -21, 15, -23, -25, -22, -60, -59, -58, -57, -56,
+ -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40,
+ -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, 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,
+ /* SBR table sbr_fenv15 [121] (signed) */
+ 0, -1, 1, -2, -3, 2, -4, 3, -5, 4, -6, 5, -7, 6, -8, 7,
+ -9, 8, -10, 9, -11, 10, 11, -12, 12, -13, 13, 14, -14, -15, 15, 16,
+ 17, -16, -17, -18, -19, 18, 19, -20, -21, 20, 21, -24, -23, -22, -26, -28,
+ 22, 23, 25, -41, -25, 26, 27, -30, -27, 24, 28, 44, -51, -46, -44, -43,
+ -37, -33, -31, -29, 30, 37, 42, 47, 48, -60, -59, -58, -57, -56, -55, -54,
+ -53, -52, -50, -49, -48, -47, -45, -42, -40, -39, -38, -36, -35, -34, -32, 29,
+ 31, 32, 33, 34, 35, 36, 38, 39, 40, 41, 43, 45, 46, 49, 50, 51,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60,
+ /* SBR table sbr_tenv15b [49] (signed) */
+ 0, 1, -1, 2, -2, 3, -3, 4, -4, -5, 5, -6, 6, 7, -7, 8,
+ -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9,
+ -8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24,
+ /* SBR table sbr_fenv15b [49] (signed) */
+ 0, -1, 1, -2, 2, 3, -3, -4, 4, -5, 5, -6, 6, -7, 7, 8,
+ -9, -8, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11,
+ -10, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24,
+ /* SBR table sbr_tenv30 [63] (signed) */
+ 0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, -7, 6, -8, 7,
+ -9, -10, 8, 9, 10, -13, -11, -12, -14, 11, 12, -31, -30, -29, -28, -27,
+ -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ /* SBR table sbr_fenv30 [63] (signed) */
+ 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, -15, 14, 15, -14, 18,
+ -18, -24, -19, 16, 17, -22, -21, -16, 20, 21, 22, 25, -23, -20, 24, -31,
+ -30, -29, -28, -27, -26, -25, -17, 19, 23, 26, 27, 28, 29, 30, 31,
+ /* SBR table sbr_tenv30b [25] (signed) */
+ 0, 1, -1, -2, 2, 3, -3, -4, 4, -5, -12, -11, -10, -9, -8, -7,
+ -6, 5, 6, 7, 8, 9, 10, 11, 12,
+ /* SBR table sbr_fenv30b [25] (signed) */
+ 0, -1, 1, -2, 2, 3, -3, -4, 4, -5, 5, 6, -12, -11, -10, -9,
+ -8, -7, -6, 7, 8, 9, 10, 11, 12,
+ /* SBR table sbr_tnoise30 [63] (signed) */
+ 0, 1, -1, -2, 2, -3, 3, -4, 4, -5, 5, 11, -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, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ /* SBR table sbr_tnoise30b [25] (signed) */
+ 0, -1, 1, -2, 2, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, 3,
+ 4, 5, 6, 7, 8, 9, 10, 11, 12,
+};
+
+/* log2Tab[x] = floor(log2(x)), format = Q28 */
+const int log2Tab[65] = {
+ 0x00000000, 0x00000000, 0x10000000, 0x195c01a3, 0x20000000, 0x25269e12, 0x295c01a3, 0x2ceaecfe,
+ 0x30000000, 0x32b80347, 0x35269e12, 0x3759d4f8, 0x395c01a3, 0x3b350047, 0x3ceaecfe, 0x3e829fb6,
+ 0x40000000, 0x41663f6f, 0x42b80347, 0x43f782d7, 0x45269e12, 0x4646eea2, 0x4759d4f8, 0x48608280,
+ 0x495c01a3, 0x4a4d3c25, 0x4b350047, 0x4c1404ea, 0x4ceaecfe, 0x4dba4a47, 0x4e829fb6, 0x4f446359,
+ 0x50000000, 0x50b5d69b, 0x51663f6f, 0x52118b11, 0x52b80347, 0x5359ebc5, 0x53f782d7, 0x549101ea,
+ 0x55269e12, 0x55b88873, 0x5646eea2, 0x56d1fafd, 0x5759d4f8, 0x57dea15a, 0x58608280, 0x58df988f,
+ 0x595c01a3, 0x59d5d9fd, 0x5a4d3c25, 0x5ac24113, 0x5b350047, 0x5ba58feb, 0x5c1404ea, 0x5c80730b,
+ 0x5ceaecfe, 0x5d53847a, 0x5dba4a47, 0x5e1f4e51, 0x5e829fb6, 0x5ee44cd5, 0x5f446359, 0x5fa2f045,
+ 0x60000000
+};
+
+/* coefficient table 4.A.87, format = Q31
+ * reordered as:
+ * cTab[0], cTab[64], cTab[128], cTab[192], cTab[256],
+ * cTab[2], cTab[66], cTab[130], cTab[194], cTab[258],
+ * ...
+ * cTab[64], cTab[128], cTab[192], cTab[256], cTab[320]
+ *
+ * NOTE: cTab[1, 2, ... , 318, 319] = cTab[639, 638, ... 322, 321]
+ * except cTab[384] = -cTab[256], cTab[512] = -cTab[128]
+ */
+const int cTabA[165] = {
+ 0x00000000, 0x0055dba1, 0x01b2e41d, 0x09015651, 0x2e3a7532, 0xffed978a, 0x006090c4, 0x01fd3ba0, 0x08a24899, 0x311af3a4,
+ 0xfff0065d, 0x006b47fa, 0x024bf7a1, 0x082f552e, 0x33ff670e, 0xffef7b8b, 0x0075fded, 0x029e35b4, 0x07a8127d, 0x36e69691,
+ 0xffee1650, 0x00807994, 0x02f3e48d, 0x070bbf58, 0x39ce0477, 0xffecc31b, 0x008a7dd7, 0x034d01f0, 0x06593912, 0x3cb41219,
+ 0xffeb50b2, 0x009424c6, 0x03a966bb, 0x0590a67d, 0x3f962fb8, 0xffe9ca76, 0x009d10bf, 0x04083fec, 0x04b0adcb, 0x4272a385,
+ 0xffe88ba8, 0x00a520bb, 0x04694101, 0x03b8f8dc, 0x4547daea, 0xffe79e16, 0x00abe79e, 0x04cc2fcf, 0x02a99097, 0x4812f848,
+ 0xffe6d466, 0x00b1978d, 0x05303f87, 0x01816e06, 0x4ad237a2, 0xffe65416, 0x00b5c867, 0x05950122, 0x0040c496, 0x4d83976c,
+ 0xffe66dd0, 0x00b8394b, 0x05f9c051, 0xfee723c6, 0x5024d70e, 0xffe69423, 0x00b8c6b0, 0x065dd56a, 0xfd7475d8, 0x52b449de,
+ 0xffe75361, 0x00b73ab0, 0x06c0f0c0, 0xfbe8f5bd, 0x552f8ff7, 0xffe85b4b, 0x00b36acd, 0x0721bf22, 0xfa44a069, 0x579505f5,
+ 0xffea353a, 0x00acbd2f, 0x077fedb3, 0xf887507c, 0x59e2f69e, 0xffec8409, 0x00a3508f, 0x07da2b7f, 0xf6b1f3c3, 0x5c16d0ae,
+ 0xffef2395, 0x0096dcc2, 0x08303897, 0xf4c473c6, 0x5e2f6367, 0xfff294c3, 0x00872c63, 0x0880ffdd, 0xf2bf6ea4, 0x602b0c7f,
+ 0xfff681d6, 0x007400b8, 0x08cb4e23, 0xf0a3959f, 0x6207f220, 0xfffb42b0, 0x005d36df, 0x090ec1fc, 0xee71b2fe, 0x63c45243,
+ 0x00007134, 0x00426f36, 0x0949eaac, 0xec2a3f5f, 0x655f63f2, 0x0006b1cf, 0x0023b989, 0x097c1ee8, 0xe9cea84a, 0x66d76725,
+ 0x000d31b5, 0x0000e790, 0x09a3e163, 0xe75f8bb8, 0x682b39a4, 0x001471f8, 0xffda17f2, 0x09c0e59f, 0xe4de0cb0, 0x6959709d,
+ 0x001c3549, 0xffaea5d6, 0x09d19ca9, 0xe24b8f66, 0x6a619c5e, 0x0024dd50, 0xff7ee3f1, 0x09d5560b, 0xdfa93ab5, 0x6b42a864,
+ 0x002d8e42, 0xff4aabc8, 0x09caeb0f, 0xdcf898fb, 0x6bfbdd98, 0x003745f9, 0xff120d70, 0x09b18a1d, 0xda3b176a, 0x6c8c4c7a,
+ 0x004103f4, 0xfed4bec3, 0x09881dc5, 0xd7722f04, 0x6cf4073e, 0x004b6c46, 0xfe933dc0, 0x094d7ec2, 0xd49fd55f, 0x6d32730f,
+ 0x0055dba1, 0x01b2e41d, 0x09015651, 0x2e3a7532, 0x6d474e1d,
+};
+
+/* coefficient table 4.A.87, format = Q31
+ * reordered as cTab[0], cTab[64], cTab[128], ... cTab[576], cTab[1], cTab[65], cTab[129], ... cTab[639]
+ * keeping full table (not using symmetry) to allow sequential access in synth filter inner loop
+ * format = Q31
+ */
+const int cTabS[640] = {
+ 0x00000000, 0x0055dba1, 0x01b2e41d, 0x09015651, 0x2e3a7532, 0x6d474e1d, 0xd1c58ace, 0x09015651, 0xfe4d1be3, 0x0055dba1,
+ 0xffede50e, 0x005b5371, 0x01d78bfc, 0x08d3e41b, 0x2faa221c, 0x6d41d963, 0xd3337b3d, 0x09299ead, 0xfe70b8d1, 0x0050b177,
+ 0xffed978a, 0x006090c4, 0x01fd3ba0, 0x08a24899, 0x311af3a4, 0x6d32730f, 0xd49fd55f, 0x094d7ec2, 0xfe933dc0, 0x004b6c46,
+ 0xffefc9b9, 0x0065fde5, 0x02244a24, 0x086b1eeb, 0x328cc6f0, 0x6d18520e, 0xd60a46e5, 0x096d0e21, 0xfeb48d0d, 0x00465348,
+ 0xfff0065d, 0x006b47fa, 0x024bf7a1, 0x082f552e, 0x33ff670e, 0x6cf4073e, 0xd7722f04, 0x09881dc5, 0xfed4bec3, 0x004103f4,
+ 0xffeff6ca, 0x0070c8a5, 0x0274ba43, 0x07ee507c, 0x3572ec70, 0x6cc59bab, 0xd8d7f21f, 0x099ec3dc, 0xfef3f6ab, 0x003c1fa4,
+ 0xffef7b8b, 0x0075fded, 0x029e35b4, 0x07a8127d, 0x36e69691, 0x6c8c4c7a, 0xda3b176a, 0x09b18a1d, 0xff120d70, 0x003745f9,
+ 0xffeedfa4, 0x007b3875, 0x02c89901, 0x075ca90c, 0x385a49c4, 0x6c492217, 0xdb9b5b12, 0x09c018ce, 0xff2ef725, 0x00329ab6,
+ 0xffee1650, 0x00807994, 0x02f3e48d, 0x070bbf58, 0x39ce0477, 0x6bfbdd98, 0xdcf898fb, 0x09caeb0f, 0xff4aabc8, 0x002d8e42,
+ 0xffed651d, 0x0085c217, 0x03201116, 0x06b559c3, 0x3b415115, 0x6ba4629f, 0xde529086, 0x09d1fa23, 0xff6542d1, 0x00293718,
+ 0xffecc31b, 0x008a7dd7, 0x034d01f0, 0x06593912, 0x3cb41219, 0x6b42a864, 0xdfa93ab5, 0x09d5560b, 0xff7ee3f1, 0x0024dd50,
+ 0xffebe77b, 0x008f4bfc, 0x037ad438, 0x05f7fb90, 0x3e25b17e, 0x6ad73e8d, 0xe0fc421e, 0x09d52709, 0xff975c01, 0x002064f8,
+ 0xffeb50b2, 0x009424c6, 0x03a966bb, 0x0590a67d, 0x3f962fb8, 0x6a619c5e, 0xe24b8f66, 0x09d19ca9, 0xffaea5d6, 0x001c3549,
+ 0xffea9192, 0x0098b855, 0x03d8afe6, 0x05237f9d, 0x41058bc6, 0x69e29784, 0xe396a45d, 0x09cab9f2, 0xffc4e365, 0x0018703f,
+ 0xffe9ca76, 0x009d10bf, 0x04083fec, 0x04b0adcb, 0x4272a385, 0x6959709d, 0xe4de0cb0, 0x09c0e59f, 0xffda17f2, 0x001471f8,
+ 0xffe940f4, 0x00a1039c, 0x043889c6, 0x0437fb0a, 0x43de620a, 0x68c7269b, 0xe620c476, 0x09b3d77f, 0xffee183b, 0x0010bc63,
+ 0xffe88ba8, 0x00a520bb, 0x04694101, 0x03b8f8dc, 0x4547daea, 0x682b39a4, 0xe75f8bb8, 0x09a3e163, 0x0000e790, 0x000d31b5,
+ 0xffe83a07, 0x00a8739d, 0x049aa82f, 0x03343533, 0x46aea856, 0x6785c24d, 0xe89971b7, 0x099140a7, 0x00131c75, 0x0009aa3f,
+ 0xffe79e16, 0x00abe79e, 0x04cc2fcf, 0x02a99097, 0x4812f848, 0x66d76725, 0xe9cea84a, 0x097c1ee8, 0x0023b989, 0x0006b1cf,
+ 0xffe7746e, 0x00af374c, 0x04fe20be, 0x02186a91, 0x4973fef1, 0x661fd6b8, 0xeafee7f1, 0x0963ed46, 0x0033b927, 0x00039609,
+ 0xffe6d466, 0x00b1978d, 0x05303f87, 0x01816e06, 0x4ad237a2, 0x655f63f2, 0xec2a3f5f, 0x0949eaac, 0x00426f36, 0x00007134,
+ 0xffe6afee, 0x00b3d15c, 0x05626209, 0x00e42fa2, 0x4c2ca3df, 0x64964063, 0xed50a31d, 0x092d7970, 0x00504f41, 0xfffdfa25,
+ 0xffe65416, 0x00b5c867, 0x05950122, 0x0040c496, 0x4d83976c, 0x63c45243, 0xee71b2fe, 0x090ec1fc, 0x005d36df, 0xfffb42b0,
+ 0xffe681c6, 0x00b74c37, 0x05c76fed, 0xff96db90, 0x4ed62be3, 0x62ea6474, 0xef8d4d7b, 0x08edfeaa, 0x006928a0, 0xfff91fca,
+ 0xffe66dd0, 0x00b8394b, 0x05f9c051, 0xfee723c6, 0x5024d70e, 0x6207f220, 0xf0a3959f, 0x08cb4e23, 0x007400b8, 0xfff681d6,
+ 0xffe66fac, 0x00b8fe0d, 0x062bf5ec, 0xfe310657, 0x516eefb9, 0x611d58a3, 0xf1b461ab, 0x08a75da4, 0x007e0393, 0xfff48700,
+ 0xffe69423, 0x00b8c6b0, 0x065dd56a, 0xfd7475d8, 0x52b449de, 0x602b0c7f, 0xf2bf6ea4, 0x0880ffdd, 0x00872c63, 0xfff294c3,
+ 0xffe6fed4, 0x00b85f70, 0x068f8b44, 0xfcb1d740, 0x53f495aa, 0x5f30ff5f, 0xf3c4e887, 0x08594887, 0x008f87aa, 0xfff0e7ef,
+ 0xffe75361, 0x00b73ab0, 0x06c0f0c0, 0xfbe8f5bd, 0x552f8ff7, 0x5e2f6367, 0xf4c473c6, 0x08303897, 0x0096dcc2, 0xffef2395,
+ 0xffe80414, 0x00b58c8c, 0x06f1825d, 0xfb19b7bd, 0x56654bdd, 0x5d26be9b, 0xf5be0fa9, 0x08061671, 0x009da526, 0xffedc418,
+ 0xffe85b4b, 0x00b36acd, 0x0721bf22, 0xfa44a069, 0x579505f5, 0x5c16d0ae, 0xf6b1f3c3, 0x07da2b7f, 0x00a3508f, 0xffec8409,
+ 0xffe954d0, 0x00b06b68, 0x075112a2, 0xf96916f5, 0x58befacd, 0x5b001db8, 0xf79fa13a, 0x07ad8c26, 0x00a85e94, 0xffeb3849,
+ 0xffea353a, 0x00acbd2f, 0x077fedb3, 0xf887507c, 0x59e2f69e, 0x59e2f69e, 0xf887507c, 0x077fedb3, 0x00acbd2f, 0xffea353a,
+ 0xffeb3849, 0x00a85e94, 0x07ad8c26, 0xf79fa13a, 0x5b001db8, 0x58befacd, 0xf96916f5, 0x075112a2, 0x00b06b68, 0xffe954d0,
+ 0xffec8409, 0x00a3508f, 0x07da2b7f, 0xf6b1f3c3, 0x5c16d0ae, 0x579505f5, 0xfa44a069, 0x0721bf22, 0x00b36acd, 0xffe85b4b,
+ 0xffedc418, 0x009da526, 0x08061671, 0xf5be0fa9, 0x5d26be9b, 0x56654bdd, 0xfb19b7bd, 0x06f1825d, 0x00b58c8c, 0xffe80414,
+ 0xffef2395, 0x0096dcc2, 0x08303897, 0xf4c473c6, 0x5e2f6367, 0x552f8ff7, 0xfbe8f5bd, 0x06c0f0c0, 0x00b73ab0, 0xffe75361,
+ 0xfff0e7ef, 0x008f87aa, 0x08594887, 0xf3c4e887, 0x5f30ff5f, 0x53f495aa, 0xfcb1d740, 0x068f8b44, 0x00b85f70, 0xffe6fed4,
+ 0xfff294c3, 0x00872c63, 0x0880ffdd, 0xf2bf6ea4, 0x602b0c7f, 0x52b449de, 0xfd7475d8, 0x065dd56a, 0x00b8c6b0, 0xffe69423,
+ 0xfff48700, 0x007e0393, 0x08a75da4, 0xf1b461ab, 0x611d58a3, 0x516eefb9, 0xfe310657, 0x062bf5ec, 0x00b8fe0d, 0xffe66fac,
+ 0xfff681d6, 0x007400b8, 0x08cb4e23, 0xf0a3959f, 0x6207f220, 0x5024d70e, 0xfee723c6, 0x05f9c051, 0x00b8394b, 0xffe66dd0,
+ 0xfff91fca, 0x006928a0, 0x08edfeaa, 0xef8d4d7b, 0x62ea6474, 0x4ed62be3, 0xff96db90, 0x05c76fed, 0x00b74c37, 0xffe681c6,
+ 0xfffb42b0, 0x005d36df, 0x090ec1fc, 0xee71b2fe, 0x63c45243, 0x4d83976c, 0x0040c496, 0x05950122, 0x00b5c867, 0xffe65416,
+ 0xfffdfa25, 0x00504f41, 0x092d7970, 0xed50a31d, 0x64964063, 0x4c2ca3df, 0x00e42fa2, 0x05626209, 0x00b3d15c, 0xffe6afee,
+ 0x00007134, 0x00426f36, 0x0949eaac, 0xec2a3f5f, 0x655f63f2, 0x4ad237a2, 0x01816e06, 0x05303f87, 0x00b1978d, 0xffe6d466,
+ 0x00039609, 0x0033b927, 0x0963ed46, 0xeafee7f1, 0x661fd6b8, 0x4973fef1, 0x02186a91, 0x04fe20be, 0x00af374c, 0xffe7746e,
+ 0x0006b1cf, 0x0023b989, 0x097c1ee8, 0xe9cea84a, 0x66d76725, 0x4812f848, 0x02a99097, 0x04cc2fcf, 0x00abe79e, 0xffe79e16,
+ 0x0009aa3f, 0x00131c75, 0x099140a7, 0xe89971b7, 0x6785c24d, 0x46aea856, 0x03343533, 0x049aa82f, 0x00a8739d, 0xffe83a07,
+ 0x000d31b5, 0x0000e790, 0x09a3e163, 0xe75f8bb8, 0x682b39a4, 0x4547daea, 0x03b8f8dc, 0x04694101, 0x00a520bb, 0xffe88ba8,
+ 0x0010bc63, 0xffee183b, 0x09b3d77f, 0xe620c476, 0x68c7269b, 0x43de620a, 0x0437fb0a, 0x043889c6, 0x00a1039c, 0xffe940f4,
+ 0x001471f8, 0xffda17f2, 0x09c0e59f, 0xe4de0cb0, 0x6959709d, 0x4272a385, 0x04b0adcb, 0x04083fec, 0x009d10bf, 0xffe9ca76,
+ 0x0018703f, 0xffc4e365, 0x09cab9f2, 0xe396a45d, 0x69e29784, 0x41058bc6, 0x05237f9d, 0x03d8afe6, 0x0098b855, 0xffea9192,
+ 0x001c3549, 0xffaea5d6, 0x09d19ca9, 0xe24b8f66, 0x6a619c5e, 0x3f962fb8, 0x0590a67d, 0x03a966bb, 0x009424c6, 0xffeb50b2,
+ 0x002064f8, 0xff975c01, 0x09d52709, 0xe0fc421e, 0x6ad73e8d, 0x3e25b17e, 0x05f7fb90, 0x037ad438, 0x008f4bfc, 0xffebe77b,
+ 0x0024dd50, 0xff7ee3f1, 0x09d5560b, 0xdfa93ab5, 0x6b42a864, 0x3cb41219, 0x06593912, 0x034d01f0, 0x008a7dd7, 0xffecc31b,
+ 0x00293718, 0xff6542d1, 0x09d1fa23, 0xde529086, 0x6ba4629f, 0x3b415115, 0x06b559c3, 0x03201116, 0x0085c217, 0xffed651d,
+ 0x002d8e42, 0xff4aabc8, 0x09caeb0f, 0xdcf898fb, 0x6bfbdd98, 0x39ce0477, 0x070bbf58, 0x02f3e48d, 0x00807994, 0xffee1650,
+ 0x00329ab6, 0xff2ef725, 0x09c018ce, 0xdb9b5b12, 0x6c492217, 0x385a49c4, 0x075ca90c, 0x02c89901, 0x007b3875, 0xffeedfa4,
+ 0x003745f9, 0xff120d70, 0x09b18a1d, 0xda3b176a, 0x6c8c4c7a, 0x36e69691, 0x07a8127d, 0x029e35b4, 0x0075fded, 0xffef7b8b,
+ 0x003c1fa4, 0xfef3f6ab, 0x099ec3dc, 0xd8d7f21f, 0x6cc59bab, 0x3572ec70, 0x07ee507c, 0x0274ba43, 0x0070c8a5, 0xffeff6ca,
+ 0x004103f4, 0xfed4bec3, 0x09881dc5, 0xd7722f04, 0x6cf4073e, 0x33ff670e, 0x082f552e, 0x024bf7a1, 0x006b47fa, 0xfff0065d,
+ 0x00465348, 0xfeb48d0d, 0x096d0e21, 0xd60a46e5, 0x6d18520e, 0x328cc6f0, 0x086b1eeb, 0x02244a24, 0x0065fde5, 0xffefc9b9,
+ 0x004b6c46, 0xfe933dc0, 0x094d7ec2, 0xd49fd55f, 0x6d32730f, 0x311af3a4, 0x08a24899, 0x01fd3ba0, 0x006090c4, 0xffed978a,
+ 0x0050b177, 0xfe70b8d1, 0x09299ead, 0xd3337b3d, 0x6d41d963, 0x2faa221c, 0x08d3e41b, 0x01d78bfc, 0x005b5371, 0xffede50f,
+};
+
+/* noise table 4.A.88, format = Q31 */
+const int noiseTab[512 * 2] = {
+ 0x8010fd38, 0xb3dc7948, 0x7c4e2301, 0xa9904192, 0x121622a7, 0x86489625, 0xc3d53d25, 0xd0343fa9,
+ 0x674d6f70, 0x25f4e9fd, 0xce1a8c8b, 0x72a726c5, 0xfea6efc6, 0xaa4adb1a, 0x8b2dd628, 0xf14029e4,
+ 0x46321c1a, 0x604889a0, 0x33363b63, 0x815ed069, 0x802b4315, 0x8f2bf7f3, 0x85b86073, 0x745cfb46,
+ 0xc57886b3, 0xb76731f0, 0xa2a66772, 0x828ca631, 0x60cc145e, 0x1ad1010f, 0x090c83d4, 0x9bd7ba87,
+ 0x5f5aeea2, 0x8b4dbd99, 0x848e7b1e, 0x86bb9fa2, 0x26f18ae5, 0xc0b81194, 0x553407bf, 0x52c17953,
+ 0x755f468d, 0x166b04f8, 0xa5687981, 0x4343248b, 0xa6558d5e, 0xc5f6fab7, 0x80a4fb8c, 0x8cb53cb7,
+ 0x7da68a54, 0x9cd8df8a, 0xba05376c, 0xfcb58ee2, 0xfdd657a4, 0x005e35ca, 0x91c75c55, 0x367651e6,
+ 0x816abf85, 0x8f831c4f, 0x423f9c9c, 0x55aa919e, 0x80779834, 0xb59f4244, 0x800a095c, 0x7de9e0cc,
+ 0x46bda5cb, 0x4c184464, 0x2c438f71, 0x797216b5, 0x5035cee6, 0xa0c3a26e, 0x9d3f95fa, 0xd4a100c0,
+ 0x8ac30dac, 0x04b87397, 0x9e5ac516, 0x8b0b442e, 0x66210ad6, 0x88ba7598, 0x45b9bd33, 0xf0be5087,
+ 0x9261b85e, 0x364f6a31, 0x891c4b50, 0x23ad08ce, 0xf10366a6, 0x80414276, 0x1b562e06, 0x8be21591,
+ 0x9e798195, 0x7fb4045c, 0x7d9506cf, 0x854e691f, 0x9207f092, 0x7a94c9d5, 0x88911536, 0x3f45cc61,
+ 0x27059279, 0xa5b57109, 0x6d2bb67b, 0x3bdc5379, 0x74e662d8, 0x80348f8c, 0xf875e638, 0x5a8caea1,
+ 0x2459ae75, 0x2c54b939, 0x79ee3203, 0xb9bc8683, 0x9b6f630c, 0x9f45b351, 0x8563b2b9, 0xe5dbba41,
+ 0x697c7d0d, 0x7bb7c90e, 0xac900866, 0x8e6b5177, 0x8822dd37, 0x7fd5a91e, 0x7506da05, 0x82302aca,
+ 0xa5e4be04, 0x4b4288eb, 0x00b8bc9f, 0x4f1033e4, 0x7200d612, 0x43900c8c, 0xa815b900, 0x676ed1d4,
+ 0x5c5f23b2, 0xa758ee11, 0xaf73abfa, 0x11714ec0, 0x265239e0, 0xc50de679, 0x8a84e341, 0xa1438354,
+ 0x7f1a341f, 0x343ec96b, 0x696e71b0, 0xa13bde39, 0x81e75094, 0x80091111, 0x853a73bf, 0x80f9c1ee,
+ 0xe4980086, 0x886a8e28, 0xa7e89426, 0xdd93edd7, 0x7592100d, 0x0bfa8123, 0x850a26d4, 0x2e34f395,
+ 0x421b6c00, 0xa4a462e4, 0x4e3f5090, 0x3c189f4c, 0x3c971a56, 0xdd0376d2, 0x747a5367, 0x7bcbc9d7,
+ 0x3966be6a, 0x7efda616, 0x55445e15, 0x7ba2ab3f, 0x5fe684f2, 0x8cf42af9, 0x808c61c3, 0x4390c27b,
+ 0x7cac62ff, 0xea6cab22, 0x5d0902ad, 0xc27b7208, 0x7a27389d, 0x5820a357, 0xa29bbe59, 0x9df0f1fd,
+ 0x92bd67e5, 0x7195b587, 0x97cac65b, 0x8339807e, 0x8f72d832, 0x5fad8685, 0xa462d9d3, 0x81d46214,
+ 0x6ae93e1d, 0x6b23a5b9, 0xc2732874, 0x81795268, 0x7c568cb6, 0x668513ea, 0x428d024e, 0x66b78b3a,
+ 0xfee9ef03, 0x9ddcbb82, 0xa605f07e, 0x46dc55e0, 0x85415054, 0xc89ec271, 0x7c42edfb, 0x0befe59b,
+ 0x89b8f607, 0x6d732a1a, 0xa7081ebd, 0x7e403258, 0x21feeb7b, 0x5dd7a1e7, 0x23e3a31a, 0x129bc896,
+ 0xa11a6b54, 0x7f1e031c, 0xfdc1a4d1, 0x96402e53, 0xb9700f1a, 0x8168ecd6, 0x7d63d3cc, 0x87a70d65,
+ 0x81075a7a, 0x55c8caa7, 0xa95d00b5, 0x102b1652, 0x0bb30215, 0xe5b63237, 0xa446ca44, 0x82d4c333,
+ 0x67b2e094, 0x44c3d661, 0x33fd6036, 0xde1ea2a1, 0xa95e8e47, 0x78f66eb9, 0x6f2aef1e, 0xe8887247,
+ 0x80a3b70e, 0xfca0d9d3, 0x6bf0fd20, 0x0d5226de, 0xf4341c87, 0x5902df05, 0x7ff1a38d, 0xf02e5a5b,
+ 0x99f129af, 0x8ac63d01, 0x7b53f599, 0x7bb32532, 0x99ac59b0, 0x5255a80f, 0xf1320a41, 0x2497aa5c,
+ 0xcce60bd8, 0x787c634b, 0x7ed58c5b, 0x8a28eb3a, 0x24a5e647, 0x8b79a2c1, 0x955f5ce5, 0xa9d12bc4,
+ 0x7a1e20c6, 0x3eeda7ac, 0xf7be823a, 0x042924ce, 0x808b3f03, 0x364248da, 0xac2895e5, 0x69a8b5fa,
+ 0x97fe8b63, 0xbdeac9aa, 0x8073e0ad, 0x6c25dba7, 0x005e51d2, 0x52e74389, 0x59d3988c, 0xe5d1f39c,
+ 0x7b57dc91, 0x341adbe7, 0xa7d42b8d, 0x74e9f335, 0xd35bf7d8, 0x5b7c0a4b, 0x75bc0874, 0x552129bf,
+ 0x8144b70d, 0x6de93bbb, 0x5825f14b, 0x473ec5ca, 0x80a8f37c, 0xe6552d69, 0x7898360b, 0x806379b0,
+ 0xa9b59339, 0x3f6bf60c, 0xc367d731, 0x920ade99, 0x125592f7, 0x877e5ed1, 0xda895d95, 0x075f2ece,
+ 0x380e5f5e, 0x9b006b62, 0xd17a6dd2, 0x530a0e13, 0xf4cc9a14, 0x7d0a0ed4, 0x847c6e3f, 0xbaee4975,
+ 0x47131163, 0x64fb2cac, 0x5e2100a6, 0x7b756a42, 0xd87609f4, 0x98bfe48c, 0x0493745e, 0x836c5784,
+ 0x7e5ccb40, 0x3df6b476, 0x97700d28, 0x8bbd93fd, 0x56de9cdb, 0x680b4e65, 0xebc3d90e, 0x6d286793,
+ 0x6753712e, 0xe05c98a7, 0x3d2b6b85, 0xc4b18ddb, 0x7b59b869, 0x31435688, 0x811888e9, 0xe011ee7a,
+ 0x6a5844f9, 0x86ae35ea, 0xb4cbc10b, 0x01a6f5d6, 0x7a49ed64, 0x927caa49, 0x847ddaed, 0xae0d9bb6,
+ 0x836bdb04, 0x0fd810a6, 0x74fe126b, 0x4a346b5f, 0x80184d36, 0x5afd153c, 0x90cc8102, 0xe606d0e6,
+ 0xde69aa58, 0xa89f1222, 0xe06df715, 0x8fd16144, 0x0317c3e8, 0x22ce92fc, 0x690c3eca, 0x93166f02,
+ 0x71573414, 0x8d43cffb, 0xe8bd0bb6, 0xde86770f, 0x0bf99a41, 0x4633a661, 0xba064108, 0x7adafae3,
+ 0x2f6cde5d, 0xb350a52c, 0xa5ebfb0b, 0x74c57b46, 0xd3b603b5, 0x80b70892, 0xa7f7fa53, 0xd94b566c,
+ 0xdda3fd86, 0x6a635793, 0x3ed005ca, 0xc5f087d8, 0x31e3a746, 0x7a4278f9, 0x82def1f9, 0x06caa2b2,
+ 0xe9d2c349, 0x8940e7f7, 0x7feef8dd, 0x4a9b01f0, 0xacde69f8, 0x57ddc280, 0xf09e4ba4, 0xb6d9f729,
+ 0xb48c18f2, 0xd3654aa9, 0xca7a03c8, 0x14d57545, 0x7fda87a5, 0x0e411366, 0xb77d0df0, 0x8c2aa467,
+ 0x787f2590, 0x2d292db1, 0x9f12682c, 0x44ac364d, 0x1a4b31a6, 0x871f7ded, 0x7ff99167, 0x6630a1d5,
+ 0x25385eb9, 0x2d4dd549, 0xaf8a7004, 0x319ebe0f, 0x379ab730, 0x81dc56a4, 0x822d8523, 0x1ae8554c,
+ 0x18fa0786, 0x875f7de4, 0x85ca350f, 0x7de818dc, 0x7786a38f, 0xa5456355, 0x92e60f88, 0xf5526122,
+ 0x916039bc, 0xc561e2de, 0x31c42042, 0x7c82e290, 0x75d158b2, 0xb015bda1, 0x7220c750, 0x46565441,
+ 0xd0da1fdd, 0x7b777481, 0x782e73c6, 0x8cd72b7b, 0x7f1006aa, 0xfb30e51e, 0x87994818, 0x34e7c7db,
+ 0x7faae06b, 0xea74fbc0, 0xd20c7af4, 0xc44f396b, 0x06b4234e, 0xdf2e2a93, 0x2efb07c8, 0xce861911,
+ 0x7550ea05, 0xd8d90bbb, 0x58522eec, 0x746b3520, 0xce844ce9, 0x7f5cacc3, 0xda8f17e0, 0x2fedf9cb,
+ 0xb2f77ec4, 0x6f13f4c0, 0x834de085, 0x7b7ace4b, 0x713b16ac, 0x499c5ab0, 0x06a7961d, 0x1b39a48a,
+ 0xbb853e6e, 0x7c781cc1, 0xc0baebf5, 0x7dace394, 0x815ceebc, 0xcc7b27d4, 0x8274b181, 0xa2be40a2,
+ 0xdd01d5dc, 0x7fefeb14, 0x0813ec78, 0xba3077cc, 0xe5cf1e1c, 0xedcfacae, 0x54c43a9b, 0x5cd62a42,
+ 0x93806b55, 0x03095c5b, 0x8e076ae3, 0x71bfcd2a, 0x7ac1989b, 0x623bc71a, 0x5e15d4d2, 0xfb341dd1,
+ 0xd75dfbca, 0xd0da32be, 0xd4569063, 0x337869da, 0x3d30606a, 0xcd89cca2, 0x7dd2ae36, 0x028c03cd,
+ 0xd85e052c, 0xe8dc9ec5, 0x7ffd9241, 0xde5bf4c6, 0x88c4b235, 0x8228be2e, 0x7fe6ec64, 0x996abe6a,
+ 0xdeb0666d, 0x9eb86611, 0xd249b922, 0x18b3e26b, 0x80211168, 0x5f8bb99c, 0x6ecb0dd2, 0x4728ff8d,
+ 0x2ac325b8, 0x6e5169d2, 0x7ebbd68d, 0x05e41d17, 0xaaa19f28, 0x8ab238a6, 0x51f105be, 0x140809cc,
+ 0x7f7345d9, 0x3aae5a9d, 0xaecec6e4, 0x1afb3473, 0xf6229ed1, 0x8d55f467, 0x7e32003a, 0x70f30c14,
+ 0x6686f33f, 0xd0d45ed8, 0x644fab57, 0x3a3fbbd3, 0x0b255fc4, 0x679a1701, 0x90e17b6e, 0x325d537b,
+ 0xcd7b9b87, 0xaa7be2a2, 0x7d47c966, 0xa33dbce5, 0x8659c3bb, 0x72a41367, 0x15c446e0, 0x45fe8b0a,
+ 0x9d8ddf26, 0x84d47643, 0x7fabe0da, 0x36a70122, 0x7a28ebfe, 0x7c29b8b8, 0x7f760406, 0xbabe4672,
+ 0x23ea216e, 0x92bcc50a, 0x6d20dba2, 0xad5a7c7e, 0xbf3897f5, 0xabb793e1, 0x8391fc7e, 0xe270291c,
+ 0x7a248d58, 0x80f8fd15, 0x83ef19f3, 0x5e6ece7d, 0x278430c1, 0x35239f4d, 0xe09c073b, 0x50e78cb5,
+ 0xd4b811bd, 0xce834ee0, 0xf88aaa34, 0xf71da5a9, 0xe2b0a1d5, 0x7c3aef31, 0xe84eabca, 0x3ce25964,
+ 0xf29336d3, 0x8fa78b2c, 0xa3fc3415, 0x63e1313d, 0x7fbc74e0, 0x7340bc93, 0x49ae583b, 0x8b79de4b,
+ 0x25011ce9, 0x7b462279, 0x36007db0, 0x3da1599c, 0x77780772, 0xc845c9bb, 0x83ba68be, 0x6ee507d1,
+ 0x2f0159b8, 0x5392c4ed, 0x98336ff6, 0x0b3c7f11, 0xde697aac, 0x893fc8d0, 0x6b83f8f3, 0x47799a0d,
+ 0x801d9dfc, 0x8516a83e, 0x5f8d22ec, 0x0f8ba384, 0xa049dc4b, 0xdd920b05, 0x7a99bc9f, 0x9ad19344,
+ 0x7a345dba, 0xf501a13f, 0x3e58bf19, 0x7fffaf9a, 0x3b4e1511, 0x0e08b991, 0x9e157620, 0x7230a326,
+ 0x4977f9ff, 0x2d2bbae1, 0x607aa7fc, 0x7bc85d5f, 0xb441bbbe, 0x8d8fa5f2, 0x601cce26, 0xda1884f2,
+ 0x81c82d64, 0x200b709c, 0xcbd36abe, 0x8cbdddd3, 0x55ab61d3, 0x7e3ee993, 0x833f18aa, 0xffc1aaea,
+ 0x7362e16a, 0x7fb85db2, 0x904ee04c, 0x7f04dca6, 0x8ad7a046, 0xebe7d8f7, 0xfbc4c687, 0xd0609458,
+ 0x093ed977, 0x8e546085, 0x7f5b8236, 0x7c47e118, 0xa01f2641, 0x7ffb3e48, 0x05de7cda, 0x7fc281b9,
+ 0x8e0278fc, 0xd74e6d07, 0x94c24450, 0x7cf9e641, 0x2ad27871, 0x919fa815, 0x805fd205, 0x7758397f,
+ 0xe2c7e02c, 0x1828e194, 0x5613d6fe, 0xfb55359f, 0xf9699516, 0x8978ee26, 0x7feebad9, 0x77d71d82,
+ 0x55b28b60, 0x7e997600, 0x80821a6b, 0xc6d78af1, 0x691822ab, 0x7f6982a0, 0x7ef56f99, 0x5c307f40,
+ 0xac6f8b76, 0x42cc8ba4, 0x782c61d9, 0xa0224dd0, 0x7bd234d1, 0x74576e3b, 0xe38cfe9a, 0x491e66ef,
+ 0xc78291c5, 0x895bb87f, 0x924f7889, 0x71b89394, 0x757b779d, 0xc4a9c604, 0x5cdf7829, 0x8020e9df,
+ 0x805e8245, 0x4a82c398, 0x6360bd62, 0x78bb60fc, 0x09e0d014, 0x4b0ea180, 0xb841978b, 0x69a0e864,
+ 0x7df35977, 0x3284b0dd, 0x3cdc2efd, 0x57d31f5e, 0x541069cc, 0x1776e92e, 0x04309ea3, 0xa015eb2d,
+ 0xce7bfabc, 0x41b638f8, 0x8365932e, 0x846ab44c, 0xbbcc80cb, 0x8afa6cac, 0x7fc422ea, 0x4e403fc0,
+ 0xbfac9aee, 0x8e4c6709, 0x028e01fb, 0x6d160a9b, 0x7fe93004, 0x790f9cdc, 0x6a1f37a0, 0xf7e7ef30,
+ 0xb4ea0f04, 0x7bf4c8e6, 0xe981701f, 0xc258a9d3, 0x6acbbfba, 0xef5479c7, 0x079c8bd8, 0x1a410f56,
+ 0x6853b799, 0x86cd4f01, 0xc66e23b6, 0x34585565, 0x8d1fe00d, 0x7fcdba1a, 0x32c9717b, 0xa02f9f48,
+ 0xf64940db, 0x5ed7d8f1, 0x61b823b2, 0x356f8918, 0xa0a7151e, 0x793fc969, 0x530beaeb, 0x34e93270,
+ 0x4fc4ddb5, 0x88d58b6c, 0x36094774, 0xf620ac80, 0x03763a72, 0xf910c9a6, 0x6666fb2d, 0x752c8be8,
+ 0x9a6dfdd8, 0xd1a7117d, 0x51c1b1d4, 0x0a67773d, 0x43b32a79, 0x4cdcd085, 0x5f067d30, 0x05bfe92a,
+ 0x7ed7d203, 0xe71a3c85, 0x99127ce2, 0x8eb3cac4, 0xad4bbcea, 0x5c6a0fd0, 0x0eec04af, 0x94e95cd4,
+ 0x8654f921, 0x83eabb5d, 0xb058d7ca, 0x69f12d3c, 0x03d881b2, 0x80558ef7, 0x82938cb3, 0x2ec0e1d6,
+ 0x80044422, 0xd1e47051, 0x720fc6ff, 0x82b20316, 0x0d527b02, 0x63049a15, 0x7ad5b9ad, 0xd2a4641d,
+ 0x41144f86, 0x7b04917a, 0x15c4a2c0, 0x9da07916, 0x211df54a, 0x7fdd09af, 0xfe924f3f, 0x7e132cfe,
+ 0x9a1d18d6, 0x7c56508b, 0x80f0f0af, 0x8095ced6, 0x8037d0d7, 0x026719d1, 0xa55fec43, 0x2b1c7cb7,
+ 0xa5cd5ac1, 0x77639fad, 0x7fcd8b62, 0x81a18c27, 0xaee4912e, 0xeae9eebe, 0xeb3081de, 0x8532aada,
+ 0xc822362e, 0x86a649a9, 0x8031a71d, 0x7b319dc6, 0xea8022e6, 0x814bc5a9, 0x8f62f7a1, 0xa430ea17,
+ 0x388deafb, 0x883b5185, 0x776fe13c, 0x801c683f, 0x87c11b98, 0xb7cbc644, 0x8e9ad3e8, 0x3cf5a10c,
+ 0x7ff6a634, 0x949ef096, 0x9f84aa7c, 0x010af13f, 0x782d1de8, 0xf18e492a, 0x6cf63b01, 0x4301cd81,
+ 0x32d15c9e, 0x68ad8cef, 0xd09bd2d6, 0x908c5c15, 0xd1e36260, 0x2c5bfdd0, 0x88765a99, 0x93deba1e,
+ 0xac6ae342, 0xe865b84c, 0x0f4f2847, 0x7fdf0499, 0x78b1c9b3, 0x6a73261e, 0x601a96f6, 0xd2847933,
+ 0x489aa888, 0xe12e8093, 0x3bfa5a5f, 0xd96ba5f7, 0x7c8f4c8d, 0x80940c6f, 0xcef9dd1a, 0x7e1a055f,
+ 0x3483558b, 0x02b59cc4, 0x0c56333e, 0x05a5b813, 0x92d66287, 0x7516b679, 0x71bfe03f, 0x8056bf68,
+ 0xc24d0724, 0x8416bcf3, 0x234afbdb, 0x4b0d6f9c, 0xaba97333, 0x4b4f42b6, 0x7e8343ab, 0x7ffe2603,
+ 0xe590f73c, 0x45e10c76, 0xb07a6a78, 0xb35609d3, 0x1a027dfd, 0x90cb6e20, 0x82d3fe38, 0x7b409257,
+ 0x0e395afa, 0x1b802093, 0xcb0c6c59, 0x241e17e7, 0x1ee3ea0a, 0x41a82302, 0xab04350a, 0xf570beb7,
+ 0xbb444b9b, 0x83021459, 0x838d65dc, 0x1c439c84, 0x6fdcc454, 0xef9ef325, 0x18626c1c, 0x020d251f,
+ 0xc4aae786, 0x8614cb48, 0xf6f53ca6, 0x8710dbab, 0x89abec0d, 0xf29d41c1, 0x94b50336, 0xfdd49178,
+ 0x604658d1, 0x800e85be, 0xca1bb079, 0x7fa48eeb, 0xa3b7fafe, 0xd330436b, 0x64eb604c, 0x43a658ae,
+ 0x7caa1337, 0xddd445e6, 0x7efbf955, 0xb706ec71, 0x624a6b53, 0x9e0e231f, 0x97097248, 0xa1e1a17a,
+ 0x68dd2e44, 0x7f9d2e14, 0xddcc7074, 0x58324197, 0xc88fc426, 0x6d3640ae, 0x7ef83600, 0x759a0270,
+ 0x98b6d854, 0xd63c9b84, 0x372474a2, 0xe3f18cfd, 0x56ab0bdb, 0x85c9be7e, 0x47dfcfeb, 0xa5830d41,
+ 0x0ddd6283, 0xf4f480ad, 0x74c60e38, 0xab8943c3, 0xc1508fe7, 0x480cdc39, 0x8e097362, 0xa44793be,
+ 0x538b7e18, 0x545f5b41, 0x56529175, 0x9771a97e, 0xc2da7421, 0xea8265f2, 0x805d1163, 0x883c5d28,
+ 0x8ba94c48, 0x4f676e65, 0xf78735b3, 0xe1853671, 0x7f454f53, 0x18147f85, 0x7d09e15d, 0xdb4f3494,
+ 0x795c8973, 0x83310632, 0x85d8061c, 0x9a1a0ebf, 0xc125583c, 0x2a1b1a95, 0x7fd9103f, 0x71e98c72,
+ 0x40932ed7, 0x91ed227a, 0x3c5e560e, 0xe816dee9, 0xb0891b80, 0x600038ba, 0xc7d9a80d, 0x7fff5e09,
+ 0x7e3f4351, 0xbb6b4424, 0xb14448d4, 0x8d6bb7e1, 0xfb153626, 0xa68ad537, 0xd9782006, 0xf62f6991,
+ 0x359ba8c1, 0x02ccff0b, 0x91bf2256, 0x7ea71c4d, 0x560ce5df, 0xeeba289b, 0xa574c4e7, 0x9e04f6ee,
+ 0x7860a5ec, 0x0b8db4a2, 0x968ba3d7, 0x0b6c77df, 0xd6f3157d, 0x402eff1a, 0x49b820b3, 0x8152aebb,
+ 0xd180b0b6, 0x098604d4, 0x7ff92224, 0xede9c996, 0x89c58061, 0x829624c4, 0xc6e71ea7, 0xba94d915,
+ 0x389c3cf6, 0x5b4c5a06, 0x04b335e6, 0x516a8aab, 0x42c8d7d9, 0x92b12af6, 0x86c8549f, 0xfda98acf,
+ 0x819673b6, 0x69545dac, 0x6feaa230, 0x726e6d3f, 0x886ebdfe, 0x34f5730a, 0x7af63ba2, 0x77307bbf,
+ 0x7cd80630, 0x6e45efe0, 0x7f8ad7eb, 0x59d7df99, 0x86c70946, 0xda233629, 0x753f6cbf, 0x825eeb40,
+};
diff --git a/audio_codec/libraac/statname.h b/audio_codec/libraac/statname.h
new file mode 100644
index 0000000..127281c
--- a/dev/null
+++ b/audio_codec/libraac/statname.h
@@ -0,0 +1,115 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: statname.h,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * statname.h - name mangling macros for static linking
+ **************************************************************************************/
+
+#ifndef _STATNAME_H
+#define _STATNAME_H
+
+/* define STAT_PREFIX to a unique name for static linking
+ * all the C functions and global variables will be mangled by the preprocessor
+ * e.g. void DCT4(...) becomes void raac_DCT4(...)
+ */
+#define STAT_PREFIX raac
+
+#define STATCC1(x,y,z) STATCC2(x,y,z)
+#define STATCC2(x,y,z) x##y##z
+
+#ifdef STAT_PREFIX
+#define STATNAME(func) STATCC1(STAT_PREFIX, _, func)
+#else
+#define STATNAME(func) func
+#endif
+
+/* these symbols are common to all implementations */
+#define AllocateBuffers STATNAME(AllocateBuffers)
+#define FreeBuffers STATNAME(FreeBuffers)
+#define ClearBuffer STATNAME(ClearBuffer)
+
+#define SetRawBlockParams STATNAME(SetRawBlockParams)
+#define PrepareRawBlock STATNAME(PrepareRawBlock)
+#define FlushCodec STATNAME(FlushCodec)
+
+#define UnpackADTSHeader STATNAME(UnpackADTSHeader)
+#define GetADTSChannelMapping STATNAME(GetADTSChannelMapping)
+#define UnpackADIFHeader STATNAME(UnpackADIFHeader)
+#define DecodeNextElement STATNAME(DecodeNextElement)
+#define DecodeNoiselessData STATNAME(DecodeNoiselessData)
+#define Dequantize STATNAME(Dequantize)
+#define StereoProcess STATNAME(StereoProcess)
+#define DeinterleaveShortBlocks STATNAME(DeinterleaveShortBlocks)
+#define PNS STATNAME(PNS)
+#define TNSFilter STATNAME(TNSFilter)
+#define IMDCT STATNAME(IMDCT)
+
+#define InitSBR STATNAME(InitSBR)
+#define DecodeSBRBitstream STATNAME(DecodeSBRBitstream)
+#define DecodeSBRData STATNAME(DecodeSBRData)
+#define FreeSBR STATNAME(FreeSBR)
+#define FlushCodecSBR STATNAME(FlushCodecSBR)
+
+/* global ROM tables */
+#define sampRateTab STATNAME(sampRateTab)
+#define predSFBMax STATNAME(predSFBMax)
+#define channelMapTab STATNAME(channelMapTab)
+#define elementNumChans STATNAME(elementNumChans)
+#define sfBandTotalShort STATNAME(sfBandTotalShort)
+#define sfBandTotalLong STATNAME(sfBandTotalLong)
+#define sfBandTabShortOffset STATNAME(sfBandTabShortOffset)
+#define sfBandTabShort STATNAME(sfBandTabShort)
+#define sfBandTabLongOffset STATNAME(sfBandTabLongOffset)
+#define sfBandTabLong STATNAME(sfBandTabLong)
+#define tnsMaxBandsShortOffset STATNAME(tnsMaxBandsShortOffset)
+#define tnsMaxBandsShort STATNAME(tnsMaxBandsShort)
+#define tnsMaxOrderShort STATNAME(tnsMaxOrderShort)
+#define tnsMaxBandsLongOffset STATNAME(tnsMaxBandsLongOffset)
+#define tnsMaxBandsLong STATNAME(tnsMaxBandsLong)
+#define tnsMaxOrderLong STATNAME(tnsMaxOrderLong)
+
+/* in your implementation's top-level include file (e.g. real\coder.h) you should
+ * add new #define sym STATNAME(sym) lines for all the
+ * additional global functions or variables which your
+ * implementation uses
+ */
+
+#endif /* _STATNAME_H */
diff --git a/audio_codec/libraac/stproc.c b/audio_codec/libraac/stproc.c
new file mode 100644
index 0000000..54ef4e8
--- a/dev/null
+++ b/audio_codec/libraac/stproc.c
@@ -0,0 +1,252 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: stproc.c,v 1.3 2005/05/24 16:01:55 albertofloyd Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * stproc.c - mid-side and intensity stereo processing
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+/* pow14[0][i] = -pow(2, i/4.0)
+ * pow14[1][i] = +pow(2, i/4.0)
+ *
+ * i = [0,1,2,3]
+ * format = Q30
+ */
+static const int pow14[2][4] = {
+ { 0xc0000000, 0xb3e407d7, 0xa57d8666, 0x945d819b },
+ { 0x40000000, 0x4c1bf829, 0x5a82799a, 0x6ba27e65 }
+};
+
+/**************************************************************************************
+ * Function: StereoProcessGroup
+ *
+ * Description: apply mid-side and intensity stereo to group of transform coefficients
+ *
+ * Inputs: dequantized transform coefficients for both channels
+ * pointer to appropriate scalefactor band table
+ * mid-side mask enabled flag
+ * buffer with mid-side mask (one bit for each scalefactor band)
+ * bit offset into mid-side mask buffer
+ * max coded scalefactor band
+ * buffer of codebook indices for right channel
+ * buffer of scalefactors for right channel, range = [0, 256]
+ *
+ * Outputs: updated transform coefficients in Q(FBITS_OUT_DQ_OFF)
+ * updated minimum guard bit count for both channels
+ *
+ * Return: none
+ *
+ * Notes: assume no guard bits in input
+ * gains 0 int bits
+ **************************************************************************************/
+static void StereoProcessGroup(int *coefL, int *coefR, const short *sfbTab,
+ int msMaskPres, unsigned char *msMaskPtr, int msMaskOffset, int maxSFB,
+ unsigned char *cbRight, short *sfRight, int *gbCurrent)
+{
+ int sfb, width, cbIdx, sf, cl, cr, scalef, scalei;
+ int gbMaskL, gbMaskR;
+ unsigned char msMask;
+
+ msMask = (*msMaskPtr++) >> msMaskOffset;
+ gbMaskL = 0;
+ gbMaskR = 0;
+
+ for (sfb = 0; sfb < maxSFB; sfb++) {
+ width = sfbTab[sfb + 1] - sfbTab[sfb]; /* assume >= 0 (see sfBandTabLong/sfBandTabShort) */
+ cbIdx = cbRight[sfb];
+
+ if (cbIdx == 14 || cbIdx == 15) {
+ /* intensity stereo */
+ if (msMaskPres == 1 && (msMask & 0x01)) {
+ cbIdx ^= 0x01; /* invert_intensity(): 14 becomes 15, or 15 becomes 14 */
+ }
+ sf = -sfRight[sfb]; /* negative since we use identity 0.5^(x) = 2^(-x) (see spec) */
+ cbIdx &= 0x01; /* choose - or + scale factor */
+ scalef = pow14[cbIdx][sf & 0x03];
+ scalei = (sf >> 2) + 2; /* +2 to compensate for scalef = Q30 */
+
+ if (scalei > 0) {
+ if (scalei > 30) {
+ scalei = 30;
+ }
+ do {
+ cr = MULSHIFT32(*coefL++, scalef);
+ CLIP_2N(cr, 31 - scalei);
+ cr <<= scalei;
+ gbMaskR |= FASTABS(cr);
+ *coefR++ = cr;
+ } while (--width);
+ } else {
+ scalei = -scalei;
+ if (scalei > 31) {
+ scalei = 31;
+ }
+ do {
+ cr = MULSHIFT32(*coefL++, scalef) >> scalei;
+ gbMaskR |= FASTABS(cr);
+ *coefR++ = cr;
+ } while (--width);
+ }
+ } else if (cbIdx != 13 && ((msMaskPres == 1 && (msMask & 0x01)) || msMaskPres == 2)) {
+ /* mid-side stereo (assumes no GB in inputs) */
+ do {
+ cl = *coefL;
+ cr = *coefR;
+
+ if ((FASTABS(cl) | FASTABS(cr)) >> 30) {
+ /* avoid overflow (rare) */
+ cl >>= 1;
+ sf = cl + (cr >> 1);
+ CLIP_2N(sf, 30);
+ sf <<= 1;
+ cl = cl - (cr >> 1);
+ CLIP_2N(cl, 30);
+ cl <<= 1;
+ } else {
+ /* usual case */
+ sf = cl + cr;
+ cl -= cr;
+ }
+
+ *coefL++ = sf;
+ gbMaskL |= FASTABS(sf);
+ *coefR++ = cl;
+ gbMaskR |= FASTABS(cl);
+ } while (--width);
+
+ } else {
+ /* nothing to do */
+ coefL += width;
+ coefR += width;
+ }
+
+ /* get next mask bit (should be branchless on ARM) */
+ msMask >>= 1;
+ if (++msMaskOffset == 8) {
+ msMask = *msMaskPtr++;
+ msMaskOffset = 0;
+ }
+ }
+
+ cl = CLZ(gbMaskL) - 1;
+ if (gbCurrent[0] > cl) {
+ gbCurrent[0] = cl;
+ }
+
+ cr = CLZ(gbMaskR) - 1;
+ if (gbCurrent[1] > cr) {
+ gbCurrent[1] = cr;
+ }
+
+ return;
+}
+
+/**************************************************************************************
+ * Function: StereoProcess
+ *
+ * Description: apply mid-side and intensity stereo, if enabled
+ *
+ * Inputs: valid AACDecInfo struct (including dequantized transform coefficients)
+ *
+ * Outputs: updated transform coefficients in Q(FBITS_OUT_DQ_OFF)
+ * updated minimum guard bit count for both channels
+ *
+ * Return: 0 if successful, -1 if error
+ **************************************************************************************/
+int StereoProcess(AACDecInfo *aacDecInfo)
+{
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+ int gp, win, nSamps, msMaskOffset;
+ int *coefL, *coefR;
+ unsigned char *msMaskPtr;
+ const short *sfbTab;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ /* mid-side and intensity stereo require common_window == 1 (see MPEG4 spec, Correction 2, 2004) */
+ if (psi->commonWin != 1 || aacDecInfo->currBlockID != AAC_ID_CPE) {
+ return 0;
+ }
+
+ /* nothing to do */
+ if (!psi->msMaskPresent && !psi->intensityUsed[1]) {
+ return 0;
+ }
+
+ icsInfo = &(psi->icsInfo[0]);
+ if (icsInfo->winSequence == 2) {
+ sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_SHORT;
+ } else {
+ sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_LONG;
+ }
+ coefL = psi->coef[0];
+ coefR = psi->coef[1];
+
+ /* do fused mid-side/intensity processing for each block (one long or eight short) */
+ msMaskOffset = 0;
+ msMaskPtr = psi->msMaskBits;
+ for (gp = 0; gp < icsInfo->numWinGroup; gp++) {
+ for (win = 0; win < icsInfo->winGroupLen[gp]; win++) {
+ StereoProcessGroup(coefL, coefR, sfbTab, psi->msMaskPresent,
+ msMaskPtr, msMaskOffset, icsInfo->maxSFB, psi->sfbCodeBook[1] + gp * icsInfo->maxSFB,
+ psi->scaleFactors[1] + gp * icsInfo->maxSFB, psi->gbCurrent);
+ coefL += nSamps;
+ coefR += nSamps;
+ }
+ /* we use one bit per sfb, so there are maxSFB bits for each window group */
+ msMaskPtr += (msMaskOffset + icsInfo->maxSFB) >> 3;
+ msMaskOffset = (msMaskOffset + icsInfo->maxSFB) & 0x07;
+ }
+
+ ASSERT(coefL == psi->coef[0] + 1024);
+ ASSERT(coefR == psi->coef[1] + 1024);
+
+ return 0;
+}
diff --git a/audio_codec/libraac/stream_hdr_utils.c b/audio_codec/libraac/stream_hdr_utils.c
new file mode 100644
index 0000000..2ed7f7e
--- a/dev/null
+++ b/audio_codec/libraac/stream_hdr_utils.c
@@ -0,0 +1,136 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: stream_hdr_utils.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <memory.h>
+#include "../include/helix_types.h"
+#include "../include/helix_result.h"
+#include "../include/rm_memory.h"
+#include "../include/pack_utils.h"
+#include "../include/memory_utils.h"
+#include "../include/stream_hdr_structs.h"
+#include "../include/stream_hdr_utils.h"
+
+HX_RESULT rm_unpack_rule_map(BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree,
+ void* pUserMem,
+ rm_rule_map* pMap)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (ppBuf && pulLen && fpMalloc && fpFree && pMap &&
+ *ppBuf && *pulLen >= 2) {
+ /* Initialize local variables */
+ UINT32 ulSize = 0;
+ UINT32 i = 0;
+ /* Clean up any existing rule to flag map */
+ rm_cleanup_rule_map(fpFree, pUserMem, pMap);
+ /* Unpack the number of rules */
+ pMap->ulNumRules = rm_unpack16(ppBuf, pulLen);
+ if (pMap->ulNumRules && *pulLen >= pMap->ulNumRules * 2) {
+ /* Allocate the map array */
+ ulSize = pMap->ulNumRules * sizeof(UINT32);
+ pMap->pulMap = (UINT32*) fpMalloc(pUserMem, ulSize);
+ if (pMap->pulMap) {
+ /* Zero out the memory */
+ memset(pMap->pulMap, 0, ulSize);
+ /* Unpack each of the flags */
+ for (i = 0; i < pMap->ulNumRules; i++) {
+ pMap->pulMap[i] = rm_unpack16(ppBuf, pulLen);
+ }
+ /* Clear the return value */
+ retVal = HXR_OK;
+ }
+ } else {
+ /* No rules - not an error */
+ retVal = HXR_OK;
+ }
+ }
+
+ return retVal;
+}
+
+void rm_cleanup_rule_map(rm_free_func_ptr fpFree,
+ void* pUserMem,
+ rm_rule_map* pMap)
+{
+ if (fpFree && pMap && pMap->pulMap) {
+ fpFree(pUserMem, pMap->pulMap);
+ pMap->pulMap = HXNULL;
+ pMap->ulNumRules = 0;
+ }
+}
+
+HX_RESULT rm_unpack_multistream_hdr(BYTE** ppBuf,
+ UINT32* pulLen,
+ rm_malloc_func_ptr fpMalloc,
+ rm_free_func_ptr fpFree,
+ void* pUserMem,
+ rm_multistream_hdr* hdr)
+{
+ HX_RESULT retVal = HXR_FAIL;
+
+ if (ppBuf && pulLen && fpMalloc && fpFree && hdr &&
+ *ppBuf && *pulLen >= 4) {
+ /* Unpack the multistream members */
+ hdr->ulID = rm_unpack32(ppBuf, pulLen);
+ /* Unpack the rule to substream map */
+ retVal = rm_unpack_rule_map(ppBuf, pulLen,
+ fpMalloc, fpFree, pUserMem,
+ &hdr->rule2SubStream);
+ if (retVal == HXR_OK) {
+ if (*pulLen >= 2) {
+ /* Unpack the number of substreams */
+ hdr->ulNumSubStreams = rm_unpack16(ppBuf, pulLen);
+ } else {
+ retVal = HXR_FAIL;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+void rm_cleanup_multistream_hdr(rm_free_func_ptr fpFree,
+ void* pUserMem,
+ rm_multistream_hdr* hdr)
+{
+ if (hdr) {
+ rm_cleanup_rule_map(fpFree, pUserMem, &hdr->rule2SubStream);
+ }
+}
diff --git a/audio_codec/libraac/string_utils.c b/audio_codec/libraac/string_utils.c
new file mode 100644
index 0000000..9922539
--- a/dev/null
+++ b/audio_codec/libraac/string_utils.c
@@ -0,0 +1,87 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: string_utils.c,v 1.1.1.1.2.1 2005/05/04 18:21:24 hubbe Exp $
+ *
+ * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc.
+ * All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the Real Format Source Code
+ * Porting and Optimization License, available at
+ * https://helixcommunity.org/2005/license/realformatsource (unless
+ * RealNetworks otherwise expressly agrees in writing that you are
+ * subject to a different license). You may also obtain the license
+ * terms directly from RealNetworks. You may not use this file except
+ * in compliance with the Real Format Source Code Porting and
+ * Optimization License. There are no redistribution rights for the
+ * source code of this file. Please see the Real Format Source Code
+ * Porting and Optimization License for the rights, obligations and
+ * limitations governing use of the contents of the file.
+ *
+ * RealNetworks is the developer of the Original Code and owns the
+ * copyrights in the portions it created.
+ *
+ * This file, and the files included with this file, is distributed and
+ * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL
+ * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT
+ * OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * https://rarvcode-tck.helixcommunity.org
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <string.h>
+#include "../include/string_utils.h"
+#include "../include/memory_utils.h"
+
+char* copy_string(void* pUserMem,
+ rm_malloc_func_ptr fpMalloc,
+ const char* pszStr)
+{
+ char* pRet = HXNULL;
+
+ if (fpMalloc && pszStr) {
+ /* Allocate space for string */
+ pRet = (char*) fpMalloc(pUserMem, strlen(pszStr) + 1);
+ if (pRet) {
+ /* Copy the string */
+ strcpy(pRet, pszStr);
+ }
+ }
+
+ return pRet;
+}
+
+void free_string(void* pUserMem,
+ rm_free_func_ptr fpFree,
+ char** ppszStr)
+{
+ if (fpFree && ppszStr && *ppszStr) {
+ fpFree(pUserMem, *ppszStr);
+ *ppszStr = HXNULL;
+ }
+}
+
+#if defined(_WINDOWS)
+
+#if !defined(_WINCE)
+
+int strcasecmp(const char* pszStr1, const char* pszStr2)
+{
+ return _stricmp(pszStr1, pszStr2);
+}
+
+#endif /* #if !defined(_WINCE) */
+
+int strncasecmp(const char* pszStr1, const char* pszStr2, int len)
+{
+ return _strnicmp(pszStr1, pszStr2, (size_t) len);
+}
+
+#endif /* #if defined(_WINDOWS) */
+
diff --git a/audio_codec/libraac/tns.c b/audio_codec/libraac/tns.c
new file mode 100644
index 0000000..d3f430e
--- a/dev/null
+++ b/audio_codec/libraac/tns.c
@@ -0,0 +1,307 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: tns.c,v 1.2 2005/05/24 16:01:55 albertofloyd Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * tns.c - apply TNS to spectrum
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+#define FBITS_LPC_COEFS 20
+
+/* inverse quantization tables for TNS filter coefficients, format = Q31
+ * see bottom of file for table generation
+ * negative (vs. spec) since we use MADD for filter kernel
+ */
+static const int invQuant3[16] = {
+ 0x00000000, 0xc8767f65, 0x9becf22c, 0x83358feb, 0x83358feb, 0x9becf22c, 0xc8767f65, 0x00000000,
+ 0x2bc750e9, 0x5246dd49, 0x6ed9eba1, 0x7e0e2e32, 0x7e0e2e32, 0x6ed9eba1, 0x5246dd49, 0x2bc750e9,
+};
+
+static const int invQuant4[16] = {
+ 0x00000000, 0xe5632654, 0xcbf00dbe, 0xb4c373ee, 0xa0e0a15f, 0x9126145f, 0x8643c7b3, 0x80b381ac,
+ 0x7f7437ad, 0x7b1d1a49, 0x7294b5f2, 0x66256db2, 0x563ba8aa, 0x4362210e, 0x2e3d2abb, 0x17851aad,
+};
+
+/**************************************************************************************
+ * Function: DecodeLPCCoefs
+ *
+ * Description: decode LPC coefficients for TNS
+ *
+ * Inputs: order of TNS filter
+ * resolution of coefficients (3 or 4 bits)
+ * coefficients unpacked from bitstream
+ * scratch buffer (b) of size >= order
+ *
+ * Outputs: LPC coefficients in Q(FBITS_LPC_COEFS), in 'a'
+ *
+ * Return: none
+ *
+ * Notes: assumes no guard bits in input transform coefficients
+ * a[i] = Q(FBITS_LPC_COEFS), don't store a0 = 1.0
+ * (so a[0] = first delay tap, etc.)
+ * max abs(a[i]) < log2(order), so for max order = 20 a[i] < 4.4
+ * (up to 3 bits of gain) so a[i] has at least 31 - FBITS_LPC_COEFS - 3
+ * guard bits
+ * to ensure no intermediate overflow in all-pole filter, set
+ * FBITS_LPC_COEFS such that number of guard bits >= log2(max order)
+ **************************************************************************************/
+static void DecodeLPCCoefs(int order, int res, signed char *filtCoef, int *a, int *b)
+{
+ int i, m, t;
+ const int *invQuantTab;
+
+ if (res == 3) {
+ invQuantTab = invQuant3;
+ } else if (res == 4) {
+ invQuantTab = invQuant4;
+ } else {
+ return;
+ }
+
+ for (m = 0; m < order; m++) {
+ t = invQuantTab[filtCoef[m] & 0x0f]; /* t = Q31 */
+ for (i = 0; i < m; i++) {
+ b[i] = a[i] - (MULSHIFT32(t, a[m - i - 1]) << 1);
+ }
+ for (i = 0; i < m; i++) {
+ a[i] = b[i];
+ }
+ a[m] = t >> (31 - FBITS_LPC_COEFS);
+ }
+}
+
+/**************************************************************************************
+ * Function: FilterRegion
+ *
+ * Description: apply LPC filter to one region of coefficients
+ *
+ * Inputs: number of transform coefficients in this region
+ * direction flag (forward = 1, backward = -1)
+ * order of filter
+ * 'size' transform coefficients
+ * 'order' LPC coefficients in Q(FBITS_LPC_COEFS)
+ * scratch buffer for history (must be >= order samples long)
+ *
+ * Outputs: filtered transform coefficients
+ *
+ * Return: guard bit mask (OR of abs value of all filtered transform coefs)
+ *
+ * Notes: assumes no guard bits in input transform coefficients
+ * gains 0 int bits
+ * history buffer does not need to be preserved between regions
+ **************************************************************************************/
+static int FilterRegion(int size, int dir, int order, int *audioCoef, int *a, int *hist)
+{
+ int i, j, y, hi32, inc, gbMask;
+ U64 sum64;
+
+ /* init history to 0 every time */
+ for (i = 0; i < order; i++) {
+ hist[i] = 0;
+ }
+
+ sum64.w64 = 0; /* avoid warning */
+ gbMask = 0;
+ inc = (dir ? -1 : 1);
+ do {
+ /* sum64 = a0*y[n] = 1.0*y[n] */
+ y = *audioCoef;
+ sum64.r.hi32 = y >> (32 - FBITS_LPC_COEFS);
+ sum64.r.lo32 = y << FBITS_LPC_COEFS;
+
+ /* sum64 += (a1*y[n-1] + a2*y[n-2] + ... + a[order-1]*y[n-(order-1)]) */
+ for (j = order - 1; j > 0; j--) {
+ sum64.w64 = MADD64(sum64.w64, hist[j], a[j]);
+ hist[j] = hist[j - 1];
+ }
+ sum64.w64 = MADD64(sum64.w64, hist[0], a[0]);
+ y = (sum64.r.hi32 << (32 - FBITS_LPC_COEFS)) | (sum64.r.lo32 >> FBITS_LPC_COEFS);
+
+ /* clip output (rare) */
+ hi32 = sum64.r.hi32;
+ if ((hi32 >> 31) != (hi32 >> (FBITS_LPC_COEFS - 1))) {
+ y = (hi32 >> 31) ^ 0x7fffffff;
+ }
+
+ hist[0] = y;
+ *audioCoef = y;
+ audioCoef += inc;
+ gbMask |= FASTABS(y);
+ } while (--size);
+
+ return gbMask;
+}
+
+/**************************************************************************************
+ * Function: TNSFilter
+ *
+ * Description: apply temporal noise shaping, if enabled
+ *
+ * Inputs: valid AACDecInfo struct
+ * index of current channel
+ *
+ * Outputs: updated transform coefficients
+ * updated minimum guard bit count for this channel
+ *
+ * Return: 0 if successful, -1 if error
+ **************************************************************************************/
+int TNSFilter(AACDecInfo *aacDecInfo, int ch)
+{
+ int win, winLen, nWindows, nSFB, filt, bottom, top, order, maxOrder, dir;
+ int start, end, size, tnsMaxBand, numFilt, gbMask;
+ int *audioCoef;
+ unsigned char *filtLength, *filtOrder, *filtRes, *filtDir;
+ signed char *filtCoef;
+ const unsigned char *tnsMaxBandTab;
+ const short *sfbTab;
+ ICSInfo *icsInfo;
+ TNSInfo *ti;
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+ ti = &psi->tnsInfo[ch];
+
+ if (!ti->tnsDataPresent) {
+ return 0;
+ }
+
+ if (icsInfo->winSequence == 2) {
+ nWindows = NWINDOWS_SHORT;
+ winLen = NSAMPS_SHORT;
+ nSFB = sfBandTotalShort[psi->sampRateIdx];
+ maxOrder = tnsMaxOrderShort[aacDecInfo->profile];
+ sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx];
+ tnsMaxBandTab = tnsMaxBandsShort + tnsMaxBandsShortOffset[aacDecInfo->profile];
+ tnsMaxBand = tnsMaxBandTab[psi->sampRateIdx];
+ } else {
+ nWindows = NWINDOWS_LONG;
+ winLen = NSAMPS_LONG;
+ nSFB = sfBandTotalLong[psi->sampRateIdx];
+ maxOrder = tnsMaxOrderLong[aacDecInfo->profile];
+ sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx];
+ tnsMaxBandTab = tnsMaxBandsLong + tnsMaxBandsLongOffset[aacDecInfo->profile];
+ tnsMaxBand = tnsMaxBandTab[psi->sampRateIdx];
+ }
+
+ if (tnsMaxBand > icsInfo->maxSFB) {
+ tnsMaxBand = icsInfo->maxSFB;
+ }
+
+ filtRes = ti->coefRes;
+ filtLength = ti->length;
+ filtOrder = ti->order;
+ filtDir = ti->dir;
+ filtCoef = ti->coef;
+
+ gbMask = 0;
+ audioCoef = psi->coef[ch];
+ for (win = 0; win < nWindows; win++) {
+ bottom = nSFB;
+ numFilt = ti->numFilt[win];
+ for (filt = 0; filt < numFilt; filt++) {
+ top = bottom;
+ bottom = top - *filtLength++;
+ bottom = MAX(bottom, 0);
+ order = *filtOrder++;
+ order = MIN(order, maxOrder);
+
+ if (order) {
+ start = sfbTab[MIN(bottom, tnsMaxBand)];
+ end = sfbTab[MIN(top, tnsMaxBand)];
+ size = end - start;
+ if (size > 0) {
+ dir = *filtDir++;
+ if (dir) {
+ start = end - 1;
+ }
+
+ DecodeLPCCoefs(order, filtRes[win], filtCoef, psi->tnsLPCBuf, psi->tnsWorkBuf);
+ gbMask |= FilterRegion(size, dir, order, audioCoef + start, psi->tnsLPCBuf, psi->tnsWorkBuf);
+ }
+ filtCoef += order;
+ }
+ }
+ audioCoef += winLen;
+ }
+
+ /* update guard bit count if necessary */
+ size = CLZ(gbMask) - 1;
+ if (psi->gbCurrent[ch] > size) {
+ psi->gbCurrent[ch] = size;
+ }
+
+ return 0;
+}
+
+/* Code to generate invQuantXXX[] tables
+ * {
+ * int res, i, t;
+ * double powScale, iqfac, iqfac_m, d;
+ *
+ * powScale = pow(2.0, 31) * -1.0; / ** make coefficients negative for using MADD in kernel ** /
+ * for (res = 3; res <= 4; res++) {
+ * iqfac = ( ((1 << (res-1)) - 0.5) * (2.0 / M_PI) );
+ * iqfac_m = ( ((1 << (res-1)) + 0.5) * (2.0 / M_PI) );
+ * printf("static const int invQuant%d[16] = {\n", res);
+ * for (i = 0; i < 16; i++) {
+ * / ** extend bottom 4 bits into signed, 2's complement number ** /
+ * t = (i << 28) >> 28;
+ *
+ * if (t >= 0) d = sin(t / iqfac);
+ * else d = sin(t / iqfac_m);
+ *
+ * d *= powScale;
+ * printf("0x%08x, ", (int)(d > 0 ? d + 0.5 : d - 0.5));
+ * if ((i & 0x07) == 0x07)
+ * printf("\n");
+ * }
+ * printf("};\n\n");
+ * }
+ * }
+ */
+
diff --git a/audio_codec/libraac/trigtabs.c b/audio_codec/libraac/trigtabs.c
new file mode 100644
index 0000000..0a77b6f
--- a/dev/null
+++ b/audio_codec/libraac/trigtabs.c
@@ -0,0 +1,1000 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: trigtabs.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * trigtabs.c - tables of sin, cos, etc. for IMDCT
+ **************************************************************************************/
+
+#include "coder.h"
+
+const int cos4sin4tabOffset[NUM_IMDCT_SIZES] = {0, 128};
+
+/* PreMultiply() tables
+ * format = Q30 * 2^[-7, -10] for nmdct = [128, 1024]
+ * reordered for sequential access
+ *
+ * invM = -1.0 / nmdct;
+ * for (i = 0; i < nmdct/4; i++) {
+ * angle = (i + 0.25) * M_PI / nmdct;
+ * x = invM * (cos(angle) + sin(angle));
+ * x = invM * sin(angle);
+ *
+ * angle = (nmdct/2 - 1 - i + 0.25) * M_PI / nmdct;
+ * x = invM * (cos(angle) + sin(angle));
+ * x = invM * sin(angle);
+ * }
+ */
+const int cos4sin4tab[128 + 1024] = {
+ /* 128 - format = Q30 * 2^-7 */
+ 0xbf9bc731, 0xff9b783c, 0xbed5332c, 0xc002c697, 0xbe112251, 0xfe096c8d, 0xbd4f9c30, 0xc00f1c4a,
+ 0xbc90a83f, 0xfc77ae5e, 0xbbd44dd9, 0xc0254e27, 0xbb1a9443, 0xfae67ba2, 0xba6382a6, 0xc04558c0,
+ 0xb9af200f, 0xf9561237, 0xb8fd7373, 0xc06f3726, 0xb84e83ac, 0xf7c6afdc, 0xb7a25779, 0xc0a2e2e3,
+ 0xb6f8f57c, 0xf6389228, 0xb652643e, 0xc0e05401, 0xb5aeaa2a, 0xf4abf67e, 0xb50dcd90, 0xc1278104,
+ 0xb46fd4a4, 0xf3211a07, 0xb3d4c57c, 0xc1785ef4, 0xb33ca614, 0xf19839a6, 0xb2a77c49, 0xc1d2e158,
+ 0xb2154dda, 0xf01191f3, 0xb186206b, 0xc236fa3b, 0xb0f9f981, 0xee8d5f29, 0xb070de82, 0xc2a49a2e,
+ 0xafead4b9, 0xed0bdd25, 0xaf67e14f, 0xc31bb049, 0xaee80952, 0xeb8d475b, 0xae6b51ae, 0xc39c2a2f,
+ 0xadf1bf34, 0xea11d8c8, 0xad7b5692, 0xc425f410, 0xad081c5a, 0xe899cbf1, 0xac9814fd, 0xc4b8f8ad,
+ 0xac2b44cc, 0xe7255ad1, 0xabc1aff9, 0xc555215a, 0xab5b5a96, 0xe5b4bed8, 0xaaf84896, 0xc5fa5603,
+ 0xaa987dca, 0xe44830dd, 0xaa3bfde3, 0xc6a87d2d, 0xa9e2cc73, 0xe2dfe917, 0xa98cece9, 0xc75f7bfe,
+ 0xa93a6296, 0xe17c1f15, 0xa8eb30a7, 0xc81f363d, 0xa89f5a2b, 0xe01d09b4, 0xa856e20e, 0xc8e78e5b,
+ 0xa811cb1b, 0xdec2df18, 0xa7d017fc, 0xc9b86572, 0xa791cb39, 0xdd6dd4a2, 0xa756e73a, 0xca919b4e,
+ 0xa71f6e43, 0xdc1e1ee9, 0xa6eb6279, 0xcb730e70, 0xa6bac5dc, 0xdad3f1b1, 0xa68d9a4c, 0xcc5c9c14,
+ 0xa663e188, 0xd98f7fe6, 0xa63d9d2b, 0xcd4e2037, 0xa61aceaf, 0xd850fb8e, 0xa5fb776b, 0xce47759a,
+ 0xa5df9894, 0xd71895c9, 0xa5c7333e, 0xcf4875ca, 0xa5b2485a, 0xd5e67ec1, 0xa5a0d8b5, 0xd050f926,
+ 0xa592e4fd, 0xd4bae5ab, 0xa5886dba, 0xd160d6e5, 0xa5817354, 0xd395f8ba, 0xa57df60f, 0xd277e518,
+ /* 1024 - format = Q30 * 2^-10 */
+ 0xbff3703e, 0xfff36f02, 0xbfda5824, 0xc0000b1a, 0xbfc149ed, 0xffc12b16, 0xbfa845a0, 0xc0003c74,
+ 0xbf8f4b3e, 0xff8ee750, 0xbf765acc, 0xc0009547, 0xbf5d744e, 0xff5ca3d0, 0xbf4497c8, 0xc0011594,
+ 0xbf2bc53d, 0xff2a60b4, 0xbf12fcb2, 0xc001bd5c, 0xbefa3e2a, 0xfef81e1d, 0xbee189a8, 0xc0028c9c,
+ 0xbec8df32, 0xfec5dc28, 0xbeb03eca, 0xc0038356, 0xbe97a875, 0xfe939af5, 0xbe7f1c36, 0xc004a188,
+ 0xbe669a10, 0xfe615aa3, 0xbe4e2209, 0xc005e731, 0xbe35b423, 0xfe2f1b50, 0xbe1d5062, 0xc0075452,
+ 0xbe04f6cb, 0xfdfcdd1d, 0xbdeca760, 0xc008e8e8, 0xbdd46225, 0xfdcaa027, 0xbdbc2720, 0xc00aa4f3,
+ 0xbda3f652, 0xfd98648d, 0xbd8bcfbf, 0xc00c8872, 0xbd73b36d, 0xfd662a70, 0xbd5ba15d, 0xc00e9364,
+ 0xbd439995, 0xfd33f1ed, 0xbd2b9c17, 0xc010c5c7, 0xbd13a8e7, 0xfd01bb24, 0xbcfbc00a, 0xc0131f9b,
+ 0xbce3e182, 0xfccf8634, 0xbccc0d53, 0xc015a0dd, 0xbcb44382, 0xfc9d533b, 0xbc9c8411, 0xc018498c,
+ 0xbc84cf05, 0xfc6b2259, 0xbc6d2461, 0xc01b19a7, 0xbc558428, 0xfc38f3ac, 0xbc3dee5f, 0xc01e112b,
+ 0xbc266309, 0xfc06c754, 0xbc0ee22a, 0xc0213018, 0xbbf76bc4, 0xfbd49d70, 0xbbdfffdd, 0xc024766a,
+ 0xbbc89e77, 0xfba2761e, 0xbbb14796, 0xc027e421, 0xbb99fb3e, 0xfb70517d, 0xbb82b972, 0xc02b7939,
+ 0xbb6b8235, 0xfb3e2fac, 0xbb54558d, 0xc02f35b1, 0xbb3d337b, 0xfb0c10cb, 0xbb261c04, 0xc0331986,
+ 0xbb0f0f2b, 0xfad9f4f8, 0xbaf80cf4, 0xc03724b6, 0xbae11561, 0xfaa7dc52, 0xbaca2878, 0xc03b573f,
+ 0xbab3463b, 0xfa75c6f8, 0xba9c6eae, 0xc03fb11d, 0xba85a1d4, 0xfa43b508, 0xba6edfb1, 0xc044324f,
+ 0xba582849, 0xfa11a6a3, 0xba417b9e, 0xc048dad1, 0xba2ad9b5, 0xf9df9be6, 0xba144291, 0xc04daaa1,
+ 0xb9fdb635, 0xf9ad94f0, 0xb9e734a4, 0xc052a1bb, 0xb9d0bde4, 0xf97b91e1, 0xb9ba51f6, 0xc057c01d,
+ 0xb9a3f0de, 0xf94992d7, 0xb98d9aa0, 0xc05d05c3, 0xb9774f3f, 0xf91797f0, 0xb9610ebe, 0xc06272aa,
+ 0xb94ad922, 0xf8e5a14d, 0xb934ae6d, 0xc06806ce, 0xb91e8ea3, 0xf8b3af0c, 0xb90879c7, 0xc06dc22e,
+ 0xb8f26fdc, 0xf881c14b, 0xb8dc70e7, 0xc073a4c3, 0xb8c67cea, 0xf84fd829, 0xb8b093ea, 0xc079ae8c,
+ 0xb89ab5e8, 0xf81df3c5, 0xb884e2e9, 0xc07fdf85, 0xb86f1af0, 0xf7ec143e, 0xb8595e00, 0xc08637a9,
+ 0xb843ac1d, 0xf7ba39b3, 0xb82e0549, 0xc08cb6f5, 0xb818698a, 0xf7886442, 0xb802d8e0, 0xc0935d64,
+ 0xb7ed5351, 0xf756940a, 0xb7d7d8df, 0xc09a2af3, 0xb7c2698e, 0xf724c92a, 0xb7ad0561, 0xc0a11f9d,
+ 0xb797ac5b, 0xf6f303c0, 0xb7825e80, 0xc0a83b5e, 0xb76d1bd2, 0xf6c143ec, 0xb757e455, 0xc0af7e33,
+ 0xb742b80d, 0xf68f89cb, 0xb72d96fd, 0xc0b6e815, 0xb7188127, 0xf65dd57d, 0xb7037690, 0xc0be7901,
+ 0xb6ee773a, 0xf62c2721, 0xb6d98328, 0xc0c630f2, 0xb6c49a5e, 0xf5fa7ed4, 0xb6afbce0, 0xc0ce0fe3,
+ 0xb69aeab0, 0xf5c8dcb6, 0xb68623d1, 0xc0d615cf, 0xb6716847, 0xf59740e5, 0xb65cb815, 0xc0de42b2,
+ 0xb648133e, 0xf565ab80, 0xb63379c5, 0xc0e69686, 0xb61eebae, 0xf5341ca5, 0xb60a68fb, 0xc0ef1147,
+ 0xb5f5f1b1, 0xf5029473, 0xb5e185d1, 0xc0f7b2ee, 0xb5cd255f, 0xf4d11308, 0xb5b8d05f, 0xc1007b77,
+ 0xb5a486d2, 0xf49f9884, 0xb59048be, 0xc1096add, 0xb57c1624, 0xf46e2504, 0xb567ef08, 0xc1128119,
+ 0xb553d36c, 0xf43cb8a7, 0xb53fc355, 0xc11bbe26, 0xb52bbec4, 0xf40b538b, 0xb517c5be, 0xc12521ff,
+ 0xb503d845, 0xf3d9f5cf, 0xb4eff65c, 0xc12eac9d, 0xb4dc2007, 0xf3a89f92, 0xb4c85548, 0xc1385dfb,
+ 0xb4b49622, 0xf37750f2, 0xb4a0e299, 0xc1423613, 0xb48d3ab0, 0xf3460a0d, 0xb4799e69, 0xc14c34df,
+ 0xb4660dc8, 0xf314cb02, 0xb45288cf, 0xc1565a58, 0xb43f0f82, 0xf2e393ef, 0xb42ba1e4, 0xc160a678,
+ 0xb4183ff7, 0xf2b264f2, 0xb404e9bf, 0xc16b193a, 0xb3f19f3e, 0xf2813e2a, 0xb3de6078, 0xc175b296,
+ 0xb3cb2d70, 0xf2501fb5, 0xb3b80628, 0xc1807285, 0xb3a4eaa4, 0xf21f09b1, 0xb391dae6, 0xc18b5903,
+ 0xb37ed6f1, 0xf1edfc3d, 0xb36bdec9, 0xc1966606, 0xb358f26f, 0xf1bcf777, 0xb34611e8, 0xc1a1998a,
+ 0xb3333d36, 0xf18bfb7d, 0xb320745c, 0xc1acf386, 0xb30db75d, 0xf15b086d, 0xb2fb063b, 0xc1b873f5,
+ 0xb2e860fa, 0xf12a1e66, 0xb2d5c79d, 0xc1c41ace, 0xb2c33a26, 0xf0f93d86, 0xb2b0b898, 0xc1cfe80a,
+ 0xb29e42f6, 0xf0c865ea, 0xb28bd943, 0xc1dbdba3, 0xb2797b82, 0xf09797b2, 0xb26729b5, 0xc1e7f591,
+ 0xb254e3e0, 0xf066d2fa, 0xb242aa05, 0xc1f435cc, 0xb2307c27, 0xf03617e2, 0xb21e5a49, 0xc2009c4e,
+ 0xb20c446d, 0xf0056687, 0xb1fa3a97, 0xc20d290d, 0xb1e83cc9, 0xefd4bf08, 0xb1d64b06, 0xc219dc03,
+ 0xb1c46551, 0xefa42181, 0xb1b28bad, 0xc226b528, 0xb1a0be1b, 0xef738e12, 0xb18efca0, 0xc233b473,
+ 0xb17d473d, 0xef4304d8, 0xb16b9df6, 0xc240d9de, 0xb15a00cd, 0xef1285f2, 0xb1486fc5, 0xc24e255e,
+ 0xb136eae1, 0xeee2117c, 0xb1257223, 0xc25b96ee, 0xb114058e, 0xeeb1a796, 0xb102a524, 0xc2692e83,
+ 0xb0f150e9, 0xee81485c, 0xb0e008e0, 0xc276ec16, 0xb0cecd09, 0xee50f3ed, 0xb0bd9d6a, 0xc284cf9f,
+ 0xb0ac7a03, 0xee20aa67, 0xb09b62d8, 0xc292d914, 0xb08a57eb, 0xedf06be6, 0xb079593f, 0xc2a1086d,
+ 0xb06866d7, 0xedc0388a, 0xb05780b5, 0xc2af5da2, 0xb046a6db, 0xed901070, 0xb035d94e, 0xc2bdd8a9,
+ 0xb025180e, 0xed5ff3b5, 0xb014631e, 0xc2cc7979, 0xb003ba82, 0xed2fe277, 0xaff31e3b, 0xc2db400a,
+ 0xafe28e4d, 0xecffdcd4, 0xafd20ab9, 0xc2ea2c53, 0xafc19383, 0xeccfe2ea, 0xafb128ad, 0xc2f93e4a,
+ 0xafa0ca39, 0xec9ff4d6, 0xaf90782a, 0xc30875e5, 0xaf803283, 0xec7012b5, 0xaf6ff945, 0xc317d31c,
+ 0xaf5fcc74, 0xec403ca5, 0xaf4fac12, 0xc32755e5, 0xaf3f9822, 0xec1072c4, 0xaf2f90a5, 0xc336fe37,
+ 0xaf1f959f, 0xebe0b52f, 0xaf0fa712, 0xc346cc07, 0xaeffc500, 0xebb10404, 0xaeefef6c, 0xc356bf4d,
+ 0xaee02658, 0xeb815f60, 0xaed069c7, 0xc366d7fd, 0xaec0b9bb, 0xeb51c760, 0xaeb11636, 0xc377160f,
+ 0xaea17f3b, 0xeb223c22, 0xae91f4cd, 0xc3877978, 0xae8276ed, 0xeaf2bdc3, 0xae73059f, 0xc398022f,
+ 0xae63a0e3, 0xeac34c60, 0xae5448be, 0xc3a8b028, 0xae44fd31, 0xea93e817, 0xae35be3f, 0xc3b9835a,
+ 0xae268be9, 0xea649105, 0xae176633, 0xc3ca7bba, 0xae084d1f, 0xea354746, 0xadf940ae, 0xc3db993e,
+ 0xadea40e4, 0xea060af9, 0xaddb4dc2, 0xc3ecdbdc, 0xadcc674b, 0xe9d6dc3b, 0xadbd8d82, 0xc3fe4388,
+ 0xadaec067, 0xe9a7bb28, 0xad9fffff, 0xc40fd037, 0xad914c4b, 0xe978a7dd, 0xad82a54c, 0xc42181e0,
+ 0xad740b07, 0xe949a278, 0xad657d7c, 0xc4335877, 0xad56fcaf, 0xe91aab16, 0xad4888a0, 0xc44553f2,
+ 0xad3a2153, 0xe8ebc1d3, 0xad2bc6ca, 0xc4577444, 0xad1d7907, 0xe8bce6cd, 0xad0f380c, 0xc469b963,
+ 0xad0103db, 0xe88e1a20, 0xacf2dc77, 0xc47c2344, 0xace4c1e2, 0xe85f5be9, 0xacd6b41e, 0xc48eb1db,
+ 0xacc8b32c, 0xe830ac45, 0xacbabf10, 0xc4a1651c, 0xacacd7cb, 0xe8020b52, 0xac9efd60, 0xc4b43cfd,
+ 0xac912fd1, 0xe7d3792b, 0xac836f1f, 0xc4c73972, 0xac75bb4d, 0xe7a4f5ed, 0xac68145d, 0xc4da5a6f,
+ 0xac5a7a52, 0xe77681b6, 0xac4ced2c, 0xc4ed9fe7, 0xac3f6cef, 0xe7481ca1, 0xac31f99d, 0xc50109d0,
+ 0xac249336, 0xe719c6cb, 0xac1739bf, 0xc514981d, 0xac09ed38, 0xe6eb8052, 0xabfcada3, 0xc5284ac3,
+ 0xabef7b04, 0xe6bd4951, 0xabe2555b, 0xc53c21b4, 0xabd53caa, 0xe68f21e5, 0xabc830f5, 0xc5501ce5,
+ 0xabbb323c, 0xe6610a2a, 0xabae4082, 0xc5643c4a, 0xaba15bc9, 0xe633023e, 0xab948413, 0xc5787fd6,
+ 0xab87b962, 0xe6050a3b, 0xab7afbb7, 0xc58ce77c, 0xab6e4b15, 0xe5d72240, 0xab61a77d, 0xc5a17330,
+ 0xab5510f3, 0xe5a94a67, 0xab488776, 0xc5b622e6, 0xab3c0b0b, 0xe57b82cd, 0xab2f9bb1, 0xc5caf690,
+ 0xab23396c, 0xe54dcb8f, 0xab16e43d, 0xc5dfee22, 0xab0a9c27, 0xe52024c9, 0xaafe612a, 0xc5f5098f,
+ 0xaaf23349, 0xe4f28e96, 0xaae61286, 0xc60a48c9, 0xaad9fee3, 0xe4c50914, 0xaacdf861, 0xc61fabc4,
+ 0xaac1ff03, 0xe497945d, 0xaab612ca, 0xc6353273, 0xaaaa33b8, 0xe46a308f, 0xaa9e61cf, 0xc64adcc7,
+ 0xaa929d10, 0xe43cddc4, 0xaa86e57e, 0xc660aab5, 0xaa7b3b1b, 0xe40f9c1a, 0xaa6f9de7, 0xc6769c2e,
+ 0xaa640de6, 0xe3e26bac, 0xaa588b18, 0xc68cb124, 0xaa4d157f, 0xe3b54c95, 0xaa41ad1e, 0xc6a2e98b,
+ 0xaa3651f6, 0xe3883ef2, 0xaa2b0409, 0xc6b94554, 0xaa1fc358, 0xe35b42df, 0xaa148fe6, 0xc6cfc472,
+ 0xaa0969b3, 0xe32e5876, 0xa9fe50c2, 0xc6e666d7, 0xa9f34515, 0xe3017fd5, 0xa9e846ad, 0xc6fd2c75,
+ 0xa9dd558b, 0xe2d4b916, 0xa9d271b2, 0xc714153e, 0xa9c79b23, 0xe2a80456, 0xa9bcd1e0, 0xc72b2123,
+ 0xa9b215ea, 0xe27b61af, 0xa9a76744, 0xc7425016, 0xa99cc5ee, 0xe24ed13d, 0xa99231eb, 0xc759a20a,
+ 0xa987ab3c, 0xe222531c, 0xa97d31e3, 0xc77116f0, 0xa972c5e1, 0xe1f5e768, 0xa9686738, 0xc788aeb9,
+ 0xa95e15e9, 0xe1c98e3b, 0xa953d1f7, 0xc7a06957, 0xa9499b62, 0xe19d47b1, 0xa93f722c, 0xc7b846ba,
+ 0xa9355658, 0xe17113e5, 0xa92b47e5, 0xc7d046d6, 0xa92146d7, 0xe144f2f3, 0xa917532e, 0xc7e8699a,
+ 0xa90d6cec, 0xe118e4f6, 0xa9039413, 0xc800aef7, 0xa8f9c8a4, 0xe0ecea09, 0xa8f00aa0, 0xc81916df,
+ 0xa8e65a0a, 0xe0c10247, 0xa8dcb6e2, 0xc831a143, 0xa8d3212a, 0xe0952dcb, 0xa8c998e3, 0xc84a4e14,
+ 0xa8c01e10, 0xe0696cb0, 0xa8b6b0b1, 0xc8631d42, 0xa8ad50c8, 0xe03dbf11, 0xa8a3fe57, 0xc87c0ebd,
+ 0xa89ab95e, 0xe012250a, 0xa89181df, 0xc8952278, 0xa88857dc, 0xdfe69eb4, 0xa87f3b57, 0xc8ae5862,
+ 0xa8762c4f, 0xdfbb2c2c, 0xa86d2ac8, 0xc8c7b06b, 0xa86436c2, 0xdf8fcd8b, 0xa85b503e, 0xc8e12a84,
+ 0xa852773f, 0xdf6482ed, 0xa849abc4, 0xc8fac69e, 0xa840edd1, 0xdf394c6b, 0xa8383d66, 0xc91484a8,
+ 0xa82f9a84, 0xdf0e2a22, 0xa827052d, 0xc92e6492, 0xa81e7d62, 0xdee31c2b, 0xa8160324, 0xc948664d,
+ 0xa80d9675, 0xdeb822a1, 0xa8053756, 0xc96289c9, 0xa7fce5c9, 0xde8d3d9e, 0xa7f4a1ce, 0xc97ccef5,
+ 0xa7ec6b66, 0xde626d3e, 0xa7e44294, 0xc99735c2, 0xa7dc2759, 0xde37b199, 0xa7d419b4, 0xc9b1be1e,
+ 0xa7cc19a9, 0xde0d0acc, 0xa7c42738, 0xc9cc67fa, 0xa7bc4262, 0xdde278ef, 0xa7b46b29, 0xc9e73346,
+ 0xa7aca18e, 0xddb7fc1e, 0xa7a4e591, 0xca021fef, 0xa79d3735, 0xdd8d9472, 0xa795967a, 0xca1d2de7,
+ 0xa78e0361, 0xdd634206, 0xa7867dec, 0xca385d1d, 0xa77f061c, 0xdd3904f4, 0xa7779bf2, 0xca53ad7e,
+ 0xa7703f70, 0xdd0edd55, 0xa768f095, 0xca6f1efc, 0xa761af64, 0xdce4cb44, 0xa75a7bdd, 0xca8ab184,
+ 0xa7535602, 0xdcbacedb, 0xa74c3dd4, 0xcaa66506, 0xa7453353, 0xdc90e834, 0xa73e3681, 0xcac23971,
+ 0xa7374760, 0xdc671768, 0xa73065ef, 0xcade2eb3, 0xa7299231, 0xdc3d5c91, 0xa722cc25, 0xcafa44bc,
+ 0xa71c13ce, 0xdc13b7c9, 0xa715692c, 0xcb167b79, 0xa70ecc41, 0xdbea292b, 0xa7083d0d, 0xcb32d2da,
+ 0xa701bb91, 0xdbc0b0ce, 0xa6fb47ce, 0xcb4f4acd, 0xa6f4e1c6, 0xdb974ece, 0xa6ee8979, 0xcb6be341,
+ 0xa6e83ee8, 0xdb6e0342, 0xa6e20214, 0xcb889c23, 0xa6dbd2ff, 0xdb44ce46, 0xa6d5b1a9, 0xcba57563,
+ 0xa6cf9e13, 0xdb1baff2, 0xa6c9983e, 0xcbc26eee, 0xa6c3a02b, 0xdaf2a860, 0xa6bdb5da, 0xcbdf88b3,
+ 0xa6b7d94e, 0xdac9b7a9, 0xa6b20a86, 0xcbfcc29f, 0xa6ac4984, 0xdaa0dde7, 0xa6a69649, 0xcc1a1ca0,
+ 0xa6a0f0d5, 0xda781b31, 0xa69b5929, 0xcc3796a5, 0xa695cf46, 0xda4f6fa3, 0xa690532d, 0xcc55309b,
+ 0xa68ae4df, 0xda26db54, 0xa685845c, 0xcc72ea70, 0xa68031a6, 0xd9fe5e5e, 0xa67aecbd, 0xcc90c412,
+ 0xa675b5a3, 0xd9d5f8d9, 0xa6708c57, 0xccaebd6e, 0xa66b70db, 0xd9adaadf, 0xa6666330, 0xccccd671,
+ 0xa6616355, 0xd9857489, 0xa65c714d, 0xcceb0f0a, 0xa6578d18, 0xd95d55ef, 0xa652b6b6, 0xcd096725,
+ 0xa64dee28, 0xd9354f2a, 0xa6493370, 0xcd27deb0, 0xa644868d, 0xd90d6053, 0xa63fe781, 0xcd467599,
+ 0xa63b564c, 0xd8e58982, 0xa636d2ee, 0xcd652bcb, 0xa6325d6a, 0xd8bdcad0, 0xa62df5bf, 0xcd840134,
+ 0xa6299bed, 0xd8962456, 0xa6254ff7, 0xcda2f5c2, 0xa62111db, 0xd86e962b, 0xa61ce19c, 0xcdc20960,
+ 0xa618bf39, 0xd8472069, 0xa614aab3, 0xcde13bfd, 0xa610a40c, 0xd81fc328, 0xa60cab43, 0xce008d84,
+ 0xa608c058, 0xd7f87e7f, 0xa604e34e, 0xce1ffde2, 0xa6011424, 0xd7d15288, 0xa5fd52db, 0xce3f8d05,
+ 0xa5f99f73, 0xd7aa3f5a, 0xa5f5f9ed, 0xce5f3ad8, 0xa5f2624a, 0xd783450d, 0xa5eed88a, 0xce7f0748,
+ 0xa5eb5cae, 0xd75c63ba, 0xa5e7eeb6, 0xce9ef241, 0xa5e48ea3, 0xd7359b78, 0xa5e13c75, 0xcebefbb0,
+ 0xa5ddf82d, 0xd70eec60, 0xa5dac1cb, 0xcedf2380, 0xa5d79950, 0xd6e85689, 0xa5d47ebc, 0xceff699f,
+ 0xa5d17210, 0xd6c1da0b, 0xa5ce734d, 0xcf1fcdf8, 0xa5cb8272, 0xd69b76fe, 0xa5c89f80, 0xcf405077,
+ 0xa5c5ca77, 0xd6752d79, 0xa5c30359, 0xcf60f108, 0xa5c04a25, 0xd64efd94, 0xa5bd9edc, 0xcf81af97,
+ 0xa5bb017f, 0xd628e767, 0xa5b8720d, 0xcfa28c10, 0xa5b5f087, 0xd602eb0a, 0xa5b37cee, 0xcfc3865e,
+ 0xa5b11741, 0xd5dd0892, 0xa5aebf82, 0xcfe49e6d, 0xa5ac75b0, 0xd5b74019, 0xa5aa39cd, 0xd005d42a,
+ 0xa5a80bd7, 0xd59191b5, 0xa5a5ebd0, 0xd027277e, 0xa5a3d9b8, 0xd56bfd7d, 0xa5a1d590, 0xd0489856,
+ 0xa59fdf57, 0xd5468389, 0xa59df70e, 0xd06a269d, 0xa59c1cb5, 0xd52123f0, 0xa59a504c, 0xd08bd23f,
+ 0xa59891d4, 0xd4fbdec9, 0xa596e14e, 0xd0ad9b26, 0xa5953eb8, 0xd4d6b42b, 0xa593aa14, 0xd0cf813e,
+ 0xa5922362, 0xd4b1a42c, 0xa590aaa2, 0xd0f18472, 0xa58f3fd4, 0xd48caee4, 0xa58de2f8, 0xd113a4ad,
+ 0xa58c940f, 0xd467d469, 0xa58b5319, 0xd135e1d9, 0xa58a2016, 0xd44314d3, 0xa588fb06, 0xd1583be2,
+ 0xa587e3ea, 0xd41e7037, 0xa586dac1, 0xd17ab2b3, 0xa585df8c, 0xd3f9e6ad, 0xa584f24b, 0xd19d4636,
+ 0xa58412fe, 0xd3d5784a, 0xa58341a5, 0xd1bff656, 0xa5827e40, 0xd3b12526, 0xa581c8d0, 0xd1e2c2fd,
+ 0xa5812154, 0xd38ced57, 0xa58087cd, 0xd205ac17, 0xa57ffc3b, 0xd368d0f3, 0xa57f7e9d, 0xd228b18d,
+ 0xa57f0ef5, 0xd344d011, 0xa57ead41, 0xd24bd34a, 0xa57e5982, 0xd320eac6, 0xa57e13b8, 0xd26f1138,
+ 0xa57ddbe4, 0xd2fd2129, 0xa57db204, 0xd2926b41, 0xa57d961a, 0xd2d97350, 0xa57d8825, 0xd2b5e151,
+};
+
+/* PostMultiply() tables
+ * format = Q30
+ * reordered for sequential access
+ * decimate (skip by 16 instead of 2) for small transform (128)
+ *
+ * for (i = 0; i <= (512/2); i++) {
+ * angle = i * M_PI / 1024;
+ * x = (cos(angle) + sin(angle));
+ * x = sin(angle);
+ * }
+ */
+const int cos1sin1tab[514] = {
+ /* format = Q30 */
+ 0x40000000, 0x00000000, 0x40323034, 0x003243f1, 0x406438cf, 0x006487c4, 0x409619b2, 0x0096cb58,
+ 0x40c7d2bd, 0x00c90e90, 0x40f963d3, 0x00fb514b, 0x412accd4, 0x012d936c, 0x415c0da3, 0x015fd4d2,
+ 0x418d2621, 0x0192155f, 0x41be162f, 0x01c454f5, 0x41eeddaf, 0x01f69373, 0x421f7c84, 0x0228d0bb,
+ 0x424ff28f, 0x025b0caf, 0x42803fb2, 0x028d472e, 0x42b063d0, 0x02bf801a, 0x42e05ecb, 0x02f1b755,
+ 0x43103085, 0x0323ecbe, 0x433fd8e1, 0x03562038, 0x436f57c1, 0x038851a2, 0x439ead09, 0x03ba80df,
+ 0x43cdd89a, 0x03ecadcf, 0x43fcda59, 0x041ed854, 0x442bb227, 0x0451004d, 0x445a5fe8, 0x0483259d,
+ 0x4488e37f, 0x04b54825, 0x44b73ccf, 0x04e767c5, 0x44e56bbd, 0x0519845e, 0x4513702a, 0x054b9dd3,
+ 0x454149fc, 0x057db403, 0x456ef916, 0x05afc6d0, 0x459c7d5a, 0x05e1d61b, 0x45c9d6af, 0x0613e1c5,
+ 0x45f704f7, 0x0645e9af, 0x46240816, 0x0677edbb, 0x4650dff1, 0x06a9edc9, 0x467d8c6d, 0x06dbe9bb,
+ 0x46aa0d6d, 0x070de172, 0x46d662d6, 0x073fd4cf, 0x47028c8d, 0x0771c3b3, 0x472e8a76, 0x07a3adff,
+ 0x475a5c77, 0x07d59396, 0x47860275, 0x08077457, 0x47b17c54, 0x08395024, 0x47dcc9f9, 0x086b26de,
+ 0x4807eb4b, 0x089cf867, 0x4832e02d, 0x08cec4a0, 0x485da887, 0x09008b6a, 0x4888443d, 0x09324ca7,
+ 0x48b2b335, 0x09640837, 0x48dcf556, 0x0995bdfd, 0x49070a84, 0x09c76dd8, 0x4930f2a6, 0x09f917ac,
+ 0x495aada2, 0x0a2abb59, 0x49843b5f, 0x0a5c58c0, 0x49ad9bc2, 0x0a8defc3, 0x49d6ceb3, 0x0abf8043,
+ 0x49ffd417, 0x0af10a22, 0x4a28abd6, 0x0b228d42, 0x4a5155d6, 0x0b540982, 0x4a79d1ff, 0x0b857ec7,
+ 0x4aa22036, 0x0bb6ecef, 0x4aca4065, 0x0be853de, 0x4af23270, 0x0c19b374, 0x4b19f641, 0x0c4b0b94,
+ 0x4b418bbe, 0x0c7c5c1e, 0x4b68f2cf, 0x0cada4f5, 0x4b902b5c, 0x0cdee5f9, 0x4bb7354d, 0x0d101f0e,
+ 0x4bde1089, 0x0d415013, 0x4c04bcf8, 0x0d7278eb, 0x4c2b3a84, 0x0da39978, 0x4c518913, 0x0dd4b19a,
+ 0x4c77a88e, 0x0e05c135, 0x4c9d98de, 0x0e36c82a, 0x4cc359ec, 0x0e67c65a, 0x4ce8eb9f, 0x0e98bba7,
+ 0x4d0e4de2, 0x0ec9a7f3, 0x4d33809c, 0x0efa8b20, 0x4d5883b7, 0x0f2b650f, 0x4d7d571c, 0x0f5c35a3,
+ 0x4da1fab5, 0x0f8cfcbe, 0x4dc66e6a, 0x0fbdba40, 0x4deab226, 0x0fee6e0d, 0x4e0ec5d1, 0x101f1807,
+ 0x4e32a956, 0x104fb80e, 0x4e565c9f, 0x10804e06, 0x4e79df95, 0x10b0d9d0, 0x4e9d3222, 0x10e15b4e,
+ 0x4ec05432, 0x1111d263, 0x4ee345ad, 0x11423ef0, 0x4f06067f, 0x1172a0d7, 0x4f289692, 0x11a2f7fc,
+ 0x4f4af5d1, 0x11d3443f, 0x4f6d2427, 0x12038584, 0x4f8f217e, 0x1233bbac, 0x4fb0edc1, 0x1263e699,
+ 0x4fd288dc, 0x1294062f, 0x4ff3f2bb, 0x12c41a4f, 0x50152b47, 0x12f422db, 0x5036326e, 0x13241fb6,
+ 0x50570819, 0x135410c3, 0x5077ac37, 0x1383f5e3, 0x50981eb1, 0x13b3cefa, 0x50b85f74, 0x13e39be9,
+ 0x50d86e6d, 0x14135c94, 0x50f84b87, 0x144310dd, 0x5117f6ae, 0x1472b8a5, 0x51376fd0, 0x14a253d1,
+ 0x5156b6d9, 0x14d1e242, 0x5175cbb5, 0x150163dc, 0x5194ae52, 0x1530d881, 0x51b35e9b, 0x15604013,
+ 0x51d1dc80, 0x158f9a76, 0x51f027eb, 0x15bee78c, 0x520e40cc, 0x15ee2738, 0x522c270f, 0x161d595d,
+ 0x5249daa2, 0x164c7ddd, 0x52675b72, 0x167b949d, 0x5284a96e, 0x16aa9d7e, 0x52a1c482, 0x16d99864,
+ 0x52beac9f, 0x17088531, 0x52db61b0, 0x173763c9, 0x52f7e3a6, 0x1766340f, 0x5314326d, 0x1794f5e6,
+ 0x53304df6, 0x17c3a931, 0x534c362d, 0x17f24dd3, 0x5367eb03, 0x1820e3b0, 0x53836c66, 0x184f6aab,
+ 0x539eba45, 0x187de2a7, 0x53b9d48f, 0x18ac4b87, 0x53d4bb34, 0x18daa52f, 0x53ef6e23, 0x1908ef82,
+ 0x5409ed4b, 0x19372a64, 0x5424389d, 0x196555b8, 0x543e5007, 0x19937161, 0x5458337a, 0x19c17d44,
+ 0x5471e2e6, 0x19ef7944, 0x548b5e3b, 0x1a1d6544, 0x54a4a56a, 0x1a4b4128, 0x54bdb862, 0x1a790cd4,
+ 0x54d69714, 0x1aa6c82b, 0x54ef4171, 0x1ad47312, 0x5507b76a, 0x1b020d6c, 0x551ff8ef, 0x1b2f971e,
+ 0x553805f2, 0x1b5d100a, 0x554fde64, 0x1b8a7815, 0x55678236, 0x1bb7cf23, 0x557ef15a, 0x1be51518,
+ 0x55962bc0, 0x1c1249d8, 0x55ad315b, 0x1c3f6d47, 0x55c4021d, 0x1c6c7f4a, 0x55da9df7, 0x1c997fc4,
+ 0x55f104dc, 0x1cc66e99, 0x560736bd, 0x1cf34baf, 0x561d338d, 0x1d2016e9, 0x5632fb3f, 0x1d4cd02c,
+ 0x56488dc5, 0x1d79775c, 0x565deb11, 0x1da60c5d, 0x56731317, 0x1dd28f15, 0x568805c9, 0x1dfeff67,
+ 0x569cc31b, 0x1e2b5d38, 0x56b14b00, 0x1e57a86d, 0x56c59d6a, 0x1e83e0eb, 0x56d9ba4e, 0x1eb00696,
+ 0x56eda1a0, 0x1edc1953, 0x57015352, 0x1f081907, 0x5714cf59, 0x1f340596, 0x572815a8, 0x1f5fdee6,
+ 0x573b2635, 0x1f8ba4dc, 0x574e00f2, 0x1fb7575c, 0x5760a5d5, 0x1fe2f64c, 0x577314d2, 0x200e8190,
+ 0x57854ddd, 0x2039f90f, 0x579750ec, 0x20655cac, 0x57a91df2, 0x2090ac4d, 0x57bab4e6, 0x20bbe7d8,
+ 0x57cc15bc, 0x20e70f32, 0x57dd406a, 0x21122240, 0x57ee34e5, 0x213d20e8, 0x57fef323, 0x21680b0f,
+ 0x580f7b19, 0x2192e09b, 0x581fccbc, 0x21bda171, 0x582fe804, 0x21e84d76, 0x583fcce6, 0x2212e492,
+ 0x584f7b58, 0x223d66a8, 0x585ef351, 0x2267d3a0, 0x586e34c7, 0x22922b5e, 0x587d3fb0, 0x22bc6dca,
+ 0x588c1404, 0x22e69ac8, 0x589ab1b9, 0x2310b23e, 0x58a918c6, 0x233ab414, 0x58b74923, 0x2364a02e,
+ 0x58c542c5, 0x238e7673, 0x58d305a6, 0x23b836ca, 0x58e091bd, 0x23e1e117, 0x58ede700, 0x240b7543,
+ 0x58fb0568, 0x2434f332, 0x5907eced, 0x245e5acc, 0x59149d87, 0x2487abf7, 0x5921172e, 0x24b0e699,
+ 0x592d59da, 0x24da0a9a, 0x59396584, 0x250317df, 0x59453a24, 0x252c0e4f, 0x5950d7b3, 0x2554edd1,
+ 0x595c3e2a, 0x257db64c, 0x59676d82, 0x25a667a7, 0x597265b4, 0x25cf01c8, 0x597d26b8, 0x25f78497,
+ 0x5987b08a, 0x261feffa, 0x59920321, 0x264843d9, 0x599c1e78, 0x2670801a, 0x59a60288, 0x2698a4a6,
+ 0x59afaf4c, 0x26c0b162, 0x59b924bc, 0x26e8a637, 0x59c262d5, 0x2710830c, 0x59cb698f, 0x273847c8,
+ 0x59d438e5, 0x275ff452, 0x59dcd0d3, 0x27878893, 0x59e53151, 0x27af0472, 0x59ed5a5c, 0x27d667d5,
+ 0x59f54bee, 0x27fdb2a7, 0x59fd0603, 0x2824e4cc, 0x5a048895, 0x284bfe2f, 0x5a0bd3a1, 0x2872feb6,
+ 0x5a12e720, 0x2899e64a, 0x5a19c310, 0x28c0b4d2, 0x5a20676c, 0x28e76a37, 0x5a26d42f, 0x290e0661,
+ 0x5a2d0957, 0x29348937, 0x5a3306de, 0x295af2a3, 0x5a38ccc2, 0x2981428c, 0x5a3e5afe, 0x29a778db,
+ 0x5a43b190, 0x29cd9578, 0x5a48d074, 0x29f3984c, 0x5a4db7a6, 0x2a19813f, 0x5a526725, 0x2a3f503a,
+ 0x5a56deec, 0x2a650525, 0x5a5b1efa, 0x2a8a9fea, 0x5a5f274b, 0x2ab02071, 0x5a62f7dd, 0x2ad586a3,
+ 0x5a6690ae, 0x2afad269, 0x5a69f1bb, 0x2b2003ac, 0x5a6d1b03, 0x2b451a55, 0x5a700c84, 0x2b6a164d,
+ 0x5a72c63b, 0x2b8ef77d, 0x5a754827, 0x2bb3bdce, 0x5a779246, 0x2bd8692b, 0x5a79a498, 0x2bfcf97c,
+ 0x5a7b7f1a, 0x2c216eaa, 0x5a7d21cc, 0x2c45c8a0, 0x5a7e8cac, 0x2c6a0746, 0x5a7fbfbb, 0x2c8e2a87,
+ 0x5a80baf6, 0x2cb2324c, 0x5a817e5d, 0x2cd61e7f, 0x5a8209f1, 0x2cf9ef09, 0x5a825db0, 0x2d1da3d5,
+ 0x5a82799a, 0x2d413ccd,
+};
+
+const int sinWindowOffset[NUM_IMDCT_SIZES] = {0, 128};
+
+/* Synthesis window - SIN
+ * format = Q31 for nmdct = [128, 1024]
+ * reordered for sequential access
+ *
+ * for (i = 0; i < nmdct/2; i++) {
+ * angle = (i + 0.5) * M_PI / (2.0 * nmdct);
+ * x = sin(angle);
+ *
+ * angle = (nmdct - 1 - i + 0.5) * M_PI / (2.0 * nmdct);
+ * x = sin(angle);
+ * }
+ */
+const int sinWindow[128 + 1024] = {
+ /* 128 - format = Q31 * 2^0 */
+ 0x00c90f88, 0x7fff6216, 0x025b26d7, 0x7ffa72d1, 0x03ed26e6, 0x7ff09478, 0x057f0035, 0x7fe1c76b,
+ 0x0710a345, 0x7fce0c3e, 0x08a2009a, 0x7fb563b3, 0x0a3308bd, 0x7f97cebd, 0x0bc3ac35, 0x7f754e80,
+ 0x0d53db92, 0x7f4de451, 0x0ee38766, 0x7f2191b4, 0x1072a048, 0x7ef05860, 0x120116d5, 0x7eba3a39,
+ 0x138edbb1, 0x7e7f3957, 0x151bdf86, 0x7e3f57ff, 0x16a81305, 0x7dfa98a8, 0x183366e9, 0x7db0fdf8,
+ 0x19bdcbf3, 0x7d628ac6, 0x1b4732ef, 0x7d0f4218, 0x1ccf8cb3, 0x7cb72724, 0x1e56ca1e, 0x7c5a3d50,
+ 0x1fdcdc1b, 0x7bf88830, 0x2161b3a0, 0x7b920b89, 0x22e541af, 0x7b26cb4f, 0x24677758, 0x7ab6cba4,
+ 0x25e845b6, 0x7a4210d8, 0x27679df4, 0x79c89f6e, 0x28e5714b, 0x794a7c12, 0x2a61b101, 0x78c7aba2,
+ 0x2bdc4e6f, 0x78403329, 0x2d553afc, 0x77b417df, 0x2ecc681e, 0x77235f2d, 0x3041c761, 0x768e0ea6,
+ 0x31b54a5e, 0x75f42c0b, 0x3326e2c3, 0x7555bd4c, 0x34968250, 0x74b2c884, 0x36041ad9, 0x740b53fb,
+ 0x376f9e46, 0x735f6626, 0x38d8fe93, 0x72af05a7, 0x3a402dd2, 0x71fa3949, 0x3ba51e29, 0x71410805,
+ 0x3d07c1d6, 0x708378ff, 0x3e680b2c, 0x6fc19385, 0x3fc5ec98, 0x6efb5f12, 0x4121589b, 0x6e30e34a,
+ 0x427a41d0, 0x6d6227fa, 0x43d09aed, 0x6c8f351c, 0x452456bd, 0x6bb812d1, 0x46756828, 0x6adcc964,
+ 0x47c3c22f, 0x69fd614a, 0x490f57ee, 0x6919e320, 0x4a581c9e, 0x683257ab, 0x4b9e0390, 0x6746c7d8,
+ 0x4ce10034, 0x66573cbb, 0x4e210617, 0x6563bf92, 0x4f5e08e3, 0x646c59bf, 0x5097fc5e, 0x637114cc,
+ 0x51ced46e, 0x6271fa69, 0x53028518, 0x616f146c, 0x5433027d, 0x60686ccf, 0x556040e2, 0x5f5e0db3,
+ 0x568a34a9, 0x5e50015d, 0x57b0d256, 0x5d3e5237, 0x58d40e8c, 0x5c290acc, 0x59f3de12, 0x5b1035cf,
+ /* 1024 - format = Q31 * 2^0 */
+ 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,
+};
+
+const int kbdWindowOffset[NUM_IMDCT_SIZES] = {0, 128};
+
+/* Synthesis window - KBD
+ * format = Q31 for nmdct = [128, 1024]
+ * reordered for sequential access
+ *
+ * aacScaleFact = -sqrt(1.0 / (2.0 * nmdct));
+ * for (i = 0; i < nmdct/2; i++) {
+ * x = kbdWindowRef[i] * aacScaleFact;
+ * x = kbdWindowRef[nmdct - 1 - i] * aacScaleFact;
+ * }
+ * Note: see below for code to generate kbdWindowRef[]
+ */
+const int kbdWindow[128 + 1024] = {
+ /* 128 - format = Q31 * 2^0 */
+ 0x00016f63, 0x7ffffffe, 0x0003e382, 0x7ffffff1, 0x00078f64, 0x7fffffc7, 0x000cc323, 0x7fffff5d,
+ 0x0013d9ed, 0x7ffffe76, 0x001d3a9d, 0x7ffffcaa, 0x0029581f, 0x7ffff953, 0x0038b1bd, 0x7ffff372,
+ 0x004bd34d, 0x7fffe98b, 0x00635538, 0x7fffd975, 0x007fdc64, 0x7fffc024, 0x00a219f1, 0x7fff995b,
+ 0x00cacad0, 0x7fff5f5b, 0x00fab72d, 0x7fff0a75, 0x0132b1af, 0x7ffe9091, 0x01739689, 0x7ffde49e,
+ 0x01be4a63, 0x7ffcf5ef, 0x0213b910, 0x7ffbaf84, 0x0274d41e, 0x7ff9f73a, 0x02e2913a, 0x7ff7acf1,
+ 0x035de86c, 0x7ff4a99a, 0x03e7d233, 0x7ff0be3d, 0x0481457c, 0x7febb2f1, 0x052b357c, 0x7fe545d4,
+ 0x05e68f77, 0x7fdd2a02, 0x06b4386f, 0x7fd30695, 0x07950acb, 0x7fc675b4, 0x0889d3ef, 0x7fb703be,
+ 0x099351e0, 0x7fa42e89, 0x0ab230e0, 0x7f8d64d8, 0x0be70923, 0x7f7205f8, 0x0d325c93, 0x7f516195,
+ 0x0e9494ae, 0x7f2ab7d0, 0x100e0085, 0x7efd3997, 0x119ed2ef, 0x7ec8094a, 0x134720d8, 0x7e8a3ba7,
+ 0x1506dfdc, 0x7e42d906, 0x16dde50b, 0x7df0dee4, 0x18cbe3f7, 0x7d9341b4, 0x1ad06e07, 0x7d28ef02,
+ 0x1ceaf215, 0x7cb0cfcc, 0x1f1abc4f, 0x7c29cb20, 0x215ef677, 0x7b92c8eb, 0x23b6a867, 0x7aeab4ec,
+ 0x2620b8ec, 0x7a3081d0, 0x289beef5, 0x79632c5a, 0x2b26f30b, 0x7881be95, 0x2dc0511f, 0x778b5304,
+ 0x30667aa2, 0x767f17c0, 0x3317c8dd, 0x755c5178, 0x35d27f98, 0x74225e50, 0x3894cff3, 0x72d0b887,
+ 0x3b5cdb7b, 0x7166f8e7, 0x3e28b770, 0x6fe4d8e8, 0x40f6702a, 0x6e4a3491, 0x43c40caa, 0x6c970bfc,
+ 0x468f9231, 0x6acb8483, 0x495707f5, 0x68e7e994, 0x4c187ac7, 0x66ecad1c, 0x4ed200c5, 0x64da6797,
+ 0x5181bcea, 0x62b1d7b7, 0x5425e28e, 0x6073e1ae, 0x56bcb8c2, 0x5e218e16, 0x59449d76, 0x5bbc0875,
+ /* 1024 - format = Q31 * 2^0 */
+ 0x0009962f, 0x7fffffa4, 0x000e16fb, 0x7fffff39, 0x0011ea65, 0x7ffffebf, 0x0015750e, 0x7ffffe34,
+ 0x0018dc74, 0x7ffffd96, 0x001c332e, 0x7ffffce5, 0x001f83f5, 0x7ffffc1f, 0x0022d59a, 0x7ffffb43,
+ 0x00262cc2, 0x7ffffa4f, 0x00298cc4, 0x7ffff942, 0x002cf81f, 0x7ffff81a, 0x003070c4, 0x7ffff6d6,
+ 0x0033f840, 0x7ffff573, 0x00378fd9, 0x7ffff3f1, 0x003b38a1, 0x7ffff24d, 0x003ef381, 0x7ffff085,
+ 0x0042c147, 0x7fffee98, 0x0046a2a8, 0x7fffec83, 0x004a9847, 0x7fffea44, 0x004ea2b7, 0x7fffe7d8,
+ 0x0052c283, 0x7fffe53f, 0x0056f829, 0x7fffe274, 0x005b4422, 0x7fffdf76, 0x005fa6dd, 0x7fffdc43,
+ 0x006420c8, 0x7fffd8d6, 0x0068b249, 0x7fffd52f, 0x006d5bc4, 0x7fffd149, 0x00721d9a, 0x7fffcd22,
+ 0x0076f828, 0x7fffc8b6, 0x007bebca, 0x7fffc404, 0x0080f8d9, 0x7fffbf06, 0x00861fae, 0x7fffb9bb,
+ 0x008b609e, 0x7fffb41e, 0x0090bbff, 0x7fffae2c, 0x00963224, 0x7fffa7e1, 0x009bc362, 0x7fffa13a,
+ 0x00a17009, 0x7fff9a32, 0x00a7386c, 0x7fff92c5, 0x00ad1cdc, 0x7fff8af0, 0x00b31da8, 0x7fff82ad,
+ 0x00b93b21, 0x7fff79f9, 0x00bf7596, 0x7fff70cf, 0x00c5cd57, 0x7fff672a, 0x00cc42b1, 0x7fff5d05,
+ 0x00d2d5f3, 0x7fff525c, 0x00d9876c, 0x7fff4729, 0x00e05769, 0x7fff3b66, 0x00e74638, 0x7fff2f10,
+ 0x00ee5426, 0x7fff221f, 0x00f58182, 0x7fff148e, 0x00fcce97, 0x7fff0658, 0x01043bb3, 0x7ffef776,
+ 0x010bc923, 0x7ffee7e2, 0x01137733, 0x7ffed795, 0x011b4631, 0x7ffec68a, 0x01233669, 0x7ffeb4ba,
+ 0x012b4827, 0x7ffea21d, 0x01337bb8, 0x7ffe8eac, 0x013bd167, 0x7ffe7a61, 0x01444982, 0x7ffe6533,
+ 0x014ce454, 0x7ffe4f1c, 0x0155a229, 0x7ffe3813, 0x015e834d, 0x7ffe2011, 0x0167880c, 0x7ffe070d,
+ 0x0170b0b2, 0x7ffdecff, 0x0179fd8b, 0x7ffdd1df, 0x01836ee1, 0x7ffdb5a2, 0x018d0500, 0x7ffd9842,
+ 0x0196c035, 0x7ffd79b3, 0x01a0a0ca, 0x7ffd59ee, 0x01aaa70a, 0x7ffd38e8, 0x01b4d341, 0x7ffd1697,
+ 0x01bf25b9, 0x7ffcf2f2, 0x01c99ebd, 0x7ffccdee, 0x01d43e99, 0x7ffca780, 0x01df0597, 0x7ffc7f9e,
+ 0x01e9f401, 0x7ffc563d, 0x01f50a22, 0x7ffc2b51, 0x02004844, 0x7ffbfecf, 0x020baeb1, 0x7ffbd0ab,
+ 0x02173db4, 0x7ffba0da, 0x0222f596, 0x7ffb6f4f, 0x022ed6a1, 0x7ffb3bfd, 0x023ae11f, 0x7ffb06d8,
+ 0x02471558, 0x7ffacfd3, 0x02537397, 0x7ffa96e0, 0x025ffc25, 0x7ffa5bf2, 0x026caf4a, 0x7ffa1efc,
+ 0x02798d4f, 0x7ff9dfee, 0x0286967c, 0x7ff99ebb, 0x0293cb1b, 0x7ff95b55, 0x02a12b72, 0x7ff915ab,
+ 0x02aeb7cb, 0x7ff8cdaf, 0x02bc706d, 0x7ff88351, 0x02ca559f, 0x7ff83682, 0x02d867a9, 0x7ff7e731,
+ 0x02e6a6d2, 0x7ff7954e, 0x02f51361, 0x7ff740c8, 0x0303ad9c, 0x7ff6e98e, 0x031275ca, 0x7ff68f8f,
+ 0x03216c30, 0x7ff632ba, 0x03309116, 0x7ff5d2fb, 0x033fe4bf, 0x7ff57042, 0x034f6773, 0x7ff50a7a,
+ 0x035f1975, 0x7ff4a192, 0x036efb0a, 0x7ff43576, 0x037f0c78, 0x7ff3c612, 0x038f4e02, 0x7ff35353,
+ 0x039fbfeb, 0x7ff2dd24, 0x03b06279, 0x7ff26370, 0x03c135ed, 0x7ff1e623, 0x03d23a8b, 0x7ff16527,
+ 0x03e37095, 0x7ff0e067, 0x03f4d84e, 0x7ff057cc, 0x040671f7, 0x7fefcb40, 0x04183dd3, 0x7fef3aad,
+ 0x042a3c22, 0x7feea5fa, 0x043c6d25, 0x7fee0d11, 0x044ed11d, 0x7fed6fda, 0x04616849, 0x7fecce3d,
+ 0x047432eb, 0x7fec2821, 0x04873140, 0x7feb7d6c, 0x049a6388, 0x7feace07, 0x04adca01, 0x7fea19d6,
+ 0x04c164ea, 0x7fe960c0, 0x04d53481, 0x7fe8a2aa, 0x04e93902, 0x7fe7df79, 0x04fd72aa, 0x7fe71712,
+ 0x0511e1b6, 0x7fe6495a, 0x05268663, 0x7fe57634, 0x053b60eb, 0x7fe49d83, 0x05507189, 0x7fe3bf2b,
+ 0x0565b879, 0x7fe2db0f, 0x057b35f4, 0x7fe1f110, 0x0590ea35, 0x7fe10111, 0x05a6d574, 0x7fe00af3,
+ 0x05bcf7ea, 0x7fdf0e97, 0x05d351cf, 0x7fde0bdd, 0x05e9e35c, 0x7fdd02a6, 0x0600acc8, 0x7fdbf2d2,
+ 0x0617ae48, 0x7fdadc40, 0x062ee814, 0x7fd9becf, 0x06465a62, 0x7fd89a5e, 0x065e0565, 0x7fd76eca,
+ 0x0675e954, 0x7fd63bf1, 0x068e0662, 0x7fd501b0, 0x06a65cc3, 0x7fd3bfe4, 0x06beecaa, 0x7fd2766a,
+ 0x06d7b648, 0x7fd1251e, 0x06f0b9d1, 0x7fcfcbda, 0x0709f775, 0x7fce6a7a, 0x07236f65, 0x7fcd00d8,
+ 0x073d21d2, 0x7fcb8ecf, 0x07570eea, 0x7fca1439, 0x077136dd, 0x7fc890ed, 0x078b99da, 0x7fc704c7,
+ 0x07a6380d, 0x7fc56f9d, 0x07c111a4, 0x7fc3d147, 0x07dc26cc, 0x7fc2299e, 0x07f777b1, 0x7fc07878,
+ 0x0813047d, 0x7fbebdac, 0x082ecd5b, 0x7fbcf90f, 0x084ad276, 0x7fbb2a78, 0x086713f7, 0x7fb951bc,
+ 0x08839206, 0x7fb76eaf, 0x08a04ccb, 0x7fb58126, 0x08bd446e, 0x7fb388f4, 0x08da7915, 0x7fb185ee,
+ 0x08f7eae7, 0x7faf77e5, 0x09159a09, 0x7fad5ead, 0x0933869f, 0x7fab3a17, 0x0951b0cd, 0x7fa909f6,
+ 0x097018b7, 0x7fa6ce1a, 0x098ebe7f, 0x7fa48653, 0x09ada248, 0x7fa23273, 0x09ccc431, 0x7f9fd249,
+ 0x09ec245b, 0x7f9d65a4, 0x0a0bc2e7, 0x7f9aec53, 0x0a2b9ff3, 0x7f986625, 0x0a4bbb9e, 0x7f95d2e7,
+ 0x0a6c1604, 0x7f933267, 0x0a8caf43, 0x7f908472, 0x0aad8776, 0x7f8dc8d5, 0x0ace9eb9, 0x7f8aff5c,
+ 0x0aeff526, 0x7f8827d3, 0x0b118ad8, 0x7f854204, 0x0b335fe6, 0x7f824dbb, 0x0b557469, 0x7f7f4ac3,
+ 0x0b77c879, 0x7f7c38e4, 0x0b9a5c2b, 0x7f7917e9, 0x0bbd2f97, 0x7f75e79b, 0x0be042d0, 0x7f72a7c3,
+ 0x0c0395ec, 0x7f6f5828, 0x0c2728fd, 0x7f6bf892, 0x0c4afc16, 0x7f6888c9, 0x0c6f0f4a, 0x7f650894,
+ 0x0c9362a8, 0x7f6177b9, 0x0cb7f642, 0x7f5dd5ff, 0x0cdcca26, 0x7f5a232a, 0x0d01de63, 0x7f565f00,
+ 0x0d273307, 0x7f528947, 0x0d4cc81f, 0x7f4ea1c2, 0x0d729db7, 0x7f4aa835, 0x0d98b3da, 0x7f469c65,
+ 0x0dbf0a92, 0x7f427e13, 0x0de5a1e9, 0x7f3e4d04, 0x0e0c79e7, 0x7f3a08f9, 0x0e339295, 0x7f35b1b4,
+ 0x0e5aebfa, 0x7f3146f8, 0x0e82861a, 0x7f2cc884, 0x0eaa60fd, 0x7f28361b, 0x0ed27ca5, 0x7f238f7c,
+ 0x0efad917, 0x7f1ed467, 0x0f237656, 0x7f1a049d, 0x0f4c5462, 0x7f151fdc, 0x0f75733d, 0x7f1025e3,
+ 0x0f9ed2e6, 0x7f0b1672, 0x0fc8735e, 0x7f05f146, 0x0ff254a1, 0x7f00b61d, 0x101c76ae, 0x7efb64b4,
+ 0x1046d981, 0x7ef5fcca, 0x10717d15, 0x7ef07e19, 0x109c6165, 0x7eeae860, 0x10c7866a, 0x7ee53b5b,
+ 0x10f2ec1e, 0x7edf76c4, 0x111e9279, 0x7ed99a58, 0x114a7971, 0x7ed3a5d1, 0x1176a0fc, 0x7ecd98eb,
+ 0x11a30910, 0x7ec77360, 0x11cfb1a1, 0x7ec134eb, 0x11fc9aa2, 0x7ebadd44, 0x1229c406, 0x7eb46c27,
+ 0x12572dbf, 0x7eade14c, 0x1284d7bc, 0x7ea73c6c, 0x12b2c1ed, 0x7ea07d41, 0x12e0ec42, 0x7e99a382,
+ 0x130f56a8, 0x7e92aee7, 0x133e010b, 0x7e8b9f2a, 0x136ceb59, 0x7e847402, 0x139c157b, 0x7e7d2d25,
+ 0x13cb7f5d, 0x7e75ca4c, 0x13fb28e6, 0x7e6e4b2d, 0x142b1200, 0x7e66af7f, 0x145b3a92, 0x7e5ef6f8,
+ 0x148ba281, 0x7e572150, 0x14bc49b4, 0x7e4f2e3b, 0x14ed300f, 0x7e471d70, 0x151e5575, 0x7e3eeea5,
+ 0x154fb9c9, 0x7e36a18e, 0x15815ced, 0x7e2e35e2, 0x15b33ec1, 0x7e25ab56, 0x15e55f25, 0x7e1d019e,
+ 0x1617bdf9, 0x7e14386e, 0x164a5b19, 0x7e0b4f7d, 0x167d3662, 0x7e02467e, 0x16b04fb2, 0x7df91d25,
+ 0x16e3a6e2, 0x7defd327, 0x17173bce, 0x7de66837, 0x174b0e4d, 0x7ddcdc0a, 0x177f1e39, 0x7dd32e53,
+ 0x17b36b69, 0x7dc95ec6, 0x17e7f5b3, 0x7dbf6d17, 0x181cbcec, 0x7db558f9, 0x1851c0e9, 0x7dab221f,
+ 0x1887017d, 0x7da0c83c, 0x18bc7e7c, 0x7d964b05, 0x18f237b6, 0x7d8baa2b, 0x19282cfd, 0x7d80e563,
+ 0x195e5e20, 0x7d75fc5e, 0x1994caee, 0x7d6aeed0, 0x19cb7335, 0x7d5fbc6d, 0x1a0256c2, 0x7d5464e6,
+ 0x1a397561, 0x7d48e7ef, 0x1a70cede, 0x7d3d453b, 0x1aa86301, 0x7d317c7c, 0x1ae03195, 0x7d258d65,
+ 0x1b183a63, 0x7d1977aa, 0x1b507d30, 0x7d0d3afc, 0x1b88f9c5, 0x7d00d710, 0x1bc1afe6, 0x7cf44b97,
+ 0x1bfa9f58, 0x7ce79846, 0x1c33c7e0, 0x7cdabcce, 0x1c6d293f, 0x7ccdb8e4, 0x1ca6c337, 0x7cc08c39,
+ 0x1ce0958a, 0x7cb33682, 0x1d1a9ff8, 0x7ca5b772, 0x1d54e240, 0x7c980ebd, 0x1d8f5c21, 0x7c8a3c14,
+ 0x1dca0d56, 0x7c7c3f2e, 0x1e04f59f, 0x7c6e17bc, 0x1e4014b4, 0x7c5fc573, 0x1e7b6a53, 0x7c514807,
+ 0x1eb6f633, 0x7c429f2c, 0x1ef2b80f, 0x7c33ca96, 0x1f2eaf9e, 0x7c24c9fa, 0x1f6adc98, 0x7c159d0d,
+ 0x1fa73eb2, 0x7c064383, 0x1fe3d5a3, 0x7bf6bd11, 0x2020a11e, 0x7be7096c, 0x205da0d8, 0x7bd7284a,
+ 0x209ad483, 0x7bc71960, 0x20d83bd1, 0x7bb6dc65, 0x2115d674, 0x7ba6710d, 0x2153a41b, 0x7b95d710,
+ 0x2191a476, 0x7b850e24, 0x21cfd734, 0x7b7415ff, 0x220e3c02, 0x7b62ee59, 0x224cd28d, 0x7b5196e9,
+ 0x228b9a82, 0x7b400f67, 0x22ca938a, 0x7b2e578a, 0x2309bd52, 0x7b1c6f0b, 0x23491783, 0x7b0a55a1,
+ 0x2388a1c4, 0x7af80b07, 0x23c85bbf, 0x7ae58ef5, 0x2408451a, 0x7ad2e124, 0x24485d7c, 0x7ac0014e,
+ 0x2488a48a, 0x7aacef2e, 0x24c919e9, 0x7a99aa7e, 0x2509bd3d, 0x7a8632f8, 0x254a8e29, 0x7a728858,
+ 0x258b8c50, 0x7a5eaa5a, 0x25ccb753, 0x7a4a98b9, 0x260e0ed3, 0x7a365333, 0x264f9271, 0x7a21d983,
+ 0x269141cb, 0x7a0d2b68, 0x26d31c80, 0x79f8489e, 0x2715222f, 0x79e330e4, 0x27575273, 0x79cde3f8,
+ 0x2799acea, 0x79b8619a, 0x27dc3130, 0x79a2a989, 0x281ededf, 0x798cbb85, 0x2861b591, 0x7976974e,
+ 0x28a4b4e0, 0x79603ca5, 0x28e7dc65, 0x7949ab4c, 0x292b2bb8, 0x7932e304, 0x296ea270, 0x791be390,
+ 0x29b24024, 0x7904acb3, 0x29f6046b, 0x78ed3e30, 0x2a39eed8, 0x78d597cc, 0x2a7dff02, 0x78bdb94a,
+ 0x2ac2347c, 0x78a5a270, 0x2b068eda, 0x788d5304, 0x2b4b0dae, 0x7874cacb, 0x2b8fb08a, 0x785c098d,
+ 0x2bd47700, 0x78430f11, 0x2c1960a1, 0x7829db1f, 0x2c5e6cfd, 0x78106d7f, 0x2ca39ba3, 0x77f6c5fb,
+ 0x2ce8ec23, 0x77dce45c, 0x2d2e5e0b, 0x77c2c86e, 0x2d73f0e8, 0x77a871fa, 0x2db9a449, 0x778de0cd,
+ 0x2dff77b8, 0x777314b2, 0x2e456ac4, 0x77580d78, 0x2e8b7cf6, 0x773ccaeb, 0x2ed1addb, 0x77214cdb,
+ 0x2f17fcfb, 0x77059315, 0x2f5e69e2, 0x76e99d69, 0x2fa4f419, 0x76cd6ba9, 0x2feb9b27, 0x76b0fda4,
+ 0x30325e96, 0x7694532e, 0x30793dee, 0x76776c17, 0x30c038b5, 0x765a4834, 0x31074e72, 0x763ce759,
+ 0x314e7eab, 0x761f4959, 0x3195c8e6, 0x76016e0b, 0x31dd2ca9, 0x75e35545, 0x3224a979, 0x75c4fedc,
+ 0x326c3ed8, 0x75a66aab, 0x32b3ec4d, 0x75879887, 0x32fbb159, 0x7568884b, 0x33438d81, 0x754939d1,
+ 0x338b8045, 0x7529acf4, 0x33d3892a, 0x7509e18e, 0x341ba7b1, 0x74e9d77d, 0x3463db5a, 0x74c98e9e,
+ 0x34ac23a7, 0x74a906cd, 0x34f48019, 0x74883fec, 0x353cf02f, 0x746739d8, 0x3585736a, 0x7445f472,
+ 0x35ce0949, 0x74246f9c, 0x3616b14c, 0x7402ab37, 0x365f6af0, 0x73e0a727, 0x36a835b5, 0x73be6350,
+ 0x36f11118, 0x739bdf95, 0x3739fc98, 0x73791bdd, 0x3782f7b2, 0x7356180e, 0x37cc01e3, 0x7332d410,
+ 0x38151aa8, 0x730f4fc9, 0x385e417e, 0x72eb8b24, 0x38a775e1, 0x72c7860a, 0x38f0b74d, 0x72a34066,
+ 0x393a053e, 0x727eba24, 0x39835f30, 0x7259f331, 0x39ccc49e, 0x7234eb79, 0x3a163503, 0x720fa2eb,
+ 0x3a5fafda, 0x71ea1977, 0x3aa9349e, 0x71c44f0c, 0x3af2c2ca, 0x719e439d, 0x3b3c59d7, 0x7177f71a,
+ 0x3b85f940, 0x71516978, 0x3bcfa07e, 0x712a9aaa, 0x3c194f0d, 0x71038aa4, 0x3c630464, 0x70dc395e,
+ 0x3cacbfff, 0x70b4a6cd, 0x3cf68155, 0x708cd2e9, 0x3d4047e1, 0x7064bdab, 0x3d8a131c, 0x703c670d,
+ 0x3dd3e27e, 0x7013cf0a, 0x3e1db580, 0x6feaf59c, 0x3e678b9b, 0x6fc1dac1, 0x3eb16449, 0x6f987e76,
+ 0x3efb3f01, 0x6f6ee0b9, 0x3f451b3d, 0x6f45018b, 0x3f8ef874, 0x6f1ae0eb, 0x3fd8d620, 0x6ef07edb,
+ 0x4022b3b9, 0x6ec5db5d, 0x406c90b7, 0x6e9af675, 0x40b66c93, 0x6e6fd027, 0x410046c5, 0x6e446879,
+ 0x414a1ec6, 0x6e18bf71, 0x4193f40d, 0x6decd517, 0x41ddc615, 0x6dc0a972, 0x42279455, 0x6d943c8d,
+ 0x42715e45, 0x6d678e71, 0x42bb235f, 0x6d3a9f2a, 0x4304e31a, 0x6d0d6ec5, 0x434e9cf1, 0x6cdffd4f,
+ 0x4398505b, 0x6cb24ad6, 0x43e1fcd1, 0x6c84576b, 0x442ba1cd, 0x6c56231c, 0x44753ec7, 0x6c27adfd,
+ 0x44bed33a, 0x6bf8f81e, 0x45085e9d, 0x6bca0195, 0x4551e06b, 0x6b9aca75, 0x459b581e, 0x6b6b52d5,
+ 0x45e4c52f, 0x6b3b9ac9, 0x462e2717, 0x6b0ba26b, 0x46777d52, 0x6adb69d3, 0x46c0c75a, 0x6aaaf11b,
+ 0x470a04a9, 0x6a7a385c, 0x475334b9, 0x6a493fb3, 0x479c5707, 0x6a18073d, 0x47e56b0c, 0x69e68f17,
+ 0x482e7045, 0x69b4d761, 0x4877662c, 0x6982e039, 0x48c04c3f, 0x6950a9c0, 0x490921f8, 0x691e341a,
+ 0x4951e6d5, 0x68eb7f67, 0x499a9a51, 0x68b88bcd, 0x49e33beb, 0x68855970, 0x4a2bcb1f, 0x6851e875,
+ 0x4a74476b, 0x681e3905, 0x4abcb04c, 0x67ea4b47, 0x4b050541, 0x67b61f63, 0x4b4d45c9, 0x6781b585,
+ 0x4b957162, 0x674d0dd6, 0x4bdd878c, 0x67182883, 0x4c2587c6, 0x66e305b8, 0x4c6d7190, 0x66ada5a5,
+ 0x4cb5446a, 0x66780878, 0x4cfcffd5, 0x66422e60, 0x4d44a353, 0x660c1790, 0x4d8c2e64, 0x65d5c439,
+ 0x4dd3a08c, 0x659f348e, 0x4e1af94b, 0x656868c3, 0x4e623825, 0x6531610d, 0x4ea95c9d, 0x64fa1da3,
+ 0x4ef06637, 0x64c29ebb, 0x4f375477, 0x648ae48d, 0x4f7e26e1, 0x6452ef53, 0x4fc4dcfb, 0x641abf46,
+ 0x500b7649, 0x63e254a2, 0x5051f253, 0x63a9afa2, 0x5098509f, 0x6370d083, 0x50de90b3, 0x6337b784,
+ 0x5124b218, 0x62fe64e3, 0x516ab455, 0x62c4d8e0, 0x51b096f3, 0x628b13bc, 0x51f6597b, 0x625115b8,
+ 0x523bfb78, 0x6216df18, 0x52817c72, 0x61dc701f, 0x52c6dbf5, 0x61a1c912, 0x530c198d, 0x6166ea36,
+ 0x535134c5, 0x612bd3d2, 0x53962d2a, 0x60f0862d, 0x53db024a, 0x60b50190, 0x541fb3b1, 0x60794644,
+ 0x546440ef, 0x603d5494, 0x54a8a992, 0x60012cca, 0x54eced2b, 0x5fc4cf33, 0x55310b48, 0x5f883c1c,
+ 0x5575037c, 0x5f4b73d2, 0x55b8d558, 0x5f0e76a5, 0x55fc806f, 0x5ed144e5, 0x56400452, 0x5e93dee1,
+ 0x56836096, 0x5e5644ec, 0x56c694cf, 0x5e187757, 0x5709a092, 0x5dda7677, 0x574c8374, 0x5d9c429f,
+ 0x578f3d0d, 0x5d5ddc24, 0x57d1ccf2, 0x5d1f435d, 0x581432bd, 0x5ce078a0, 0x58566e04, 0x5ca17c45,
+ 0x58987e63, 0x5c624ea4, 0x58da6372, 0x5c22f016, 0x591c1ccc, 0x5be360f6, 0x595daa0d, 0x5ba3a19f,
+ 0x599f0ad1, 0x5b63b26c, 0x59e03eb6, 0x5b2393ba, 0x5a214558, 0x5ae345e7, 0x5a621e56, 0x5aa2c951,
+};
+
+
+
+/* bit reverse tables for FFT */
+
+const int bitrevtabOffset[NUM_IMDCT_SIZES] = {0, 17};
+
+const unsigned char bitrevtab[17 + 129] = {
+ /* nfft = 64 */
+ 0x01, 0x08, 0x02, 0x04, 0x03, 0x0c, 0x05, 0x0a, 0x07, 0x0e, 0x0b, 0x0d, 0x00, 0x06, 0x09, 0x0f,
+ 0x00,
+
+ /* nfft = 512 */
+ 0x01, 0x40, 0x02, 0x20, 0x03, 0x60, 0x04, 0x10, 0x05, 0x50, 0x06, 0x30, 0x07, 0x70, 0x09, 0x48,
+ 0x0a, 0x28, 0x0b, 0x68, 0x0c, 0x18, 0x0d, 0x58, 0x0e, 0x38, 0x0f, 0x78, 0x11, 0x44, 0x12, 0x24,
+ 0x13, 0x64, 0x15, 0x54, 0x16, 0x34, 0x17, 0x74, 0x19, 0x4c, 0x1a, 0x2c, 0x1b, 0x6c, 0x1d, 0x5c,
+ 0x1e, 0x3c, 0x1f, 0x7c, 0x21, 0x42, 0x23, 0x62, 0x25, 0x52, 0x26, 0x32, 0x27, 0x72, 0x29, 0x4a,
+ 0x2b, 0x6a, 0x2d, 0x5a, 0x2e, 0x3a, 0x2f, 0x7a, 0x31, 0x46, 0x33, 0x66, 0x35, 0x56, 0x37, 0x76,
+ 0x39, 0x4e, 0x3b, 0x6e, 0x3d, 0x5e, 0x3f, 0x7e, 0x43, 0x61, 0x45, 0x51, 0x47, 0x71, 0x4b, 0x69,
+ 0x4d, 0x59, 0x4f, 0x79, 0x53, 0x65, 0x57, 0x75, 0x5b, 0x6d, 0x5f, 0x7d, 0x67, 0x73, 0x6f, 0x7b,
+ 0x00, 0x08, 0x14, 0x1c, 0x22, 0x2a, 0x36, 0x3e, 0x41, 0x49, 0x55, 0x5d, 0x63, 0x6b, 0x77, 0x7f,
+ 0x00,
+
+};
+
+const unsigned char uniqueIDTab[8] = {0x5f, 0x4b, 0x43, 0x5f, 0x5f, 0x4a, 0x52, 0x5f};
+
+/* Twiddle tables for FFT
+ * format = Q30
+ *
+ * for (k = 4; k <= N/4; k <<= 1) {
+ * for (j = 0; j < k; j++) {
+ * double wr1, wi1, wr2, wi2, wr3, wi3;
+ *
+ * wr1 = cos(1.0 * M_PI * j / (2*k));
+ * wi1 = sin(1.0 * M_PI * j / (2*k));
+ * wr1 = (wr1 + wi1);
+ * wi1 = -wi1;
+ *
+ * wr2 = cos(2.0 * M_PI * j / (2*k));
+ * wi2 = sin(2.0 * M_PI * j / (2*k));
+ * wr2 = (wr2 + wi2);
+ * wi2 = -wi2;
+ *
+ * wr3 = cos(3.0 * M_PI * j / (2*k));
+ * wi3 = sin(3.0 * M_PI * j / (2*k));
+ * wr3 = (wr3 + wi3);
+ * wi3 = -wi3;
+ *
+ * if (k & 0xaaaaaaaa) {
+ * w_odd[iodd++] = (float)wr2;
+ * w_odd[iodd++] = (float)wi2;
+ * w_odd[iodd++] = (float)wr1;
+ * w_odd[iodd++] = (float)wi1;
+ * w_odd[iodd++] = (float)wr3;
+ * w_odd[iodd++] = (float)wi3;
+ * } else {
+ * w_even[ieven++] = (float)wr2;
+ * w_even[ieven++] = (float)wi2;
+ * w_even[ieven++] = (float)wr1;
+ * w_even[ieven++] = (float)wi1;
+ * w_even[ieven++] = (float)wr3;
+ * w_even[ieven++] = (float)wi3;
+ * }
+ * }
+ * }
+ */
+const int twidTabOdd[8 * 6 + 32 * 6 + 128 * 6] = {
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x539eba45, 0xe7821d59,
+ 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59,
+ 0x539eba45, 0xc4df2862, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x22a2f4f8, 0xc4df2862,
+ 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862,
+ 0xac6145bb, 0x187de2a7, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52,
+
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x45f704f7, 0xf9ba1651,
+ 0x43103085, 0xfcdc1342, 0x48b2b335, 0xf69bf7c9, 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651,
+ 0x4fd288dc, 0xed6bf9d1, 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9, 0x553805f2, 0xe4a2eff6,
+ 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x569cc31b, 0xe1d4a2c8,
+ 0x4da1fab5, 0xf0730342, 0x5a6690ae, 0xd5052d97, 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1,
+ 0x5a12e720, 0xce86ff2a, 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a, 0x57cc15bc, 0xc91af976,
+ 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a12e720, 0xce86ff2a,
+ 0x553805f2, 0xe4a2eff6, 0x4da1fab5, 0xc1eb0209, 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8,
+ 0x45f704f7, 0xc04ee4b8, 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce, 0x3cc85709, 0xc013bc39,
+ 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x4fd288dc, 0xc2c17d52,
+ 0x5987b08a, 0xd9e01006, 0x26b2a794, 0xc3bdbdf6, 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6,
+ 0x1a4608ab, 0xc78e9a1d, 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97, 0x0d47d096, 0xcc983f70,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x396b3199, 0xc04ee4b8,
+ 0x5a6690ae, 0xd09441bb, 0xf2b82f6a, 0xd9e01006, 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a,
+ 0xe5b9f755, 0xe1d4a2c8, 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70, 0xd94d586c, 0xea70658a,
+ 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x1a4608ab, 0xc78e9a1d,
+ 0x57cc15bc, 0xc91af976, 0xc337a8f7, 0xfcdc1342, 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d,
+ 0xba08fb09, 0x0645e9af, 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18, 0xb25e054b, 0x0f8cfcbe,
+ 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xf720e574, 0xd76619b6,
+ 0x51d1dc80, 0xc3bdbdf6, 0xa833ea44, 0x20e70f32, 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52,
+ 0xa5ed18e0, 0x2899e64a, 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209, 0xa5996f52, 0x2f6bbe45,
+ 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xd5558381, 0xed6bf9d1,
+ 0x48b2b335, 0xc0b15502, 0xaac7fa0e, 0x39daf5e8, 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8,
+ 0xb02d7724, 0x3d3e82ae, 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39, 0xb74d4ccb, 0x3f4eaafe,
+
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x418d2621, 0xfe6deaa1,
+ 0x40c7d2bd, 0xff36f170, 0x424ff28f, 0xfda4f351, 0x43103085, 0xfcdc1342, 0x418d2621, 0xfe6deaa1,
+ 0x4488e37f, 0xfb4ab7db, 0x4488e37f, 0xfb4ab7db, 0x424ff28f, 0xfda4f351, 0x46aa0d6d, 0xf8f21e8e,
+ 0x45f704f7, 0xf9ba1651, 0x43103085, 0xfcdc1342, 0x48b2b335, 0xf69bf7c9, 0x475a5c77, 0xf82a6c6a,
+ 0x43cdd89a, 0xfc135231, 0x4aa22036, 0xf4491311, 0x48b2b335, 0xf69bf7c9, 0x4488e37f, 0xfb4ab7db,
+ 0x4c77a88e, 0xf1fa3ecb, 0x49ffd417, 0xf50ef5de, 0x454149fc, 0xfa824bfd, 0x4e32a956, 0xefb047f2,
+ 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x4c77a88e, 0xf1fa3ecb,
+ 0x46aa0d6d, 0xf8f21e8e, 0x5156b6d9, 0xeb2e1dbe, 0x4da1fab5, 0xf0730342, 0x475a5c77, 0xf82a6c6a,
+ 0x52beac9f, 0xe8f77acf, 0x4ec05432, 0xeeee2d9d, 0x4807eb4b, 0xf7630799, 0x5409ed4b, 0xe6c8d59c,
+ 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9, 0x553805f2, 0xe4a2eff6, 0x50d86e6d, 0xebeca36c,
+ 0x495aada2, 0xf5d544a7, 0x56488dc5, 0xe28688a4, 0x51d1dc80, 0xea70658a, 0x49ffd417, 0xf50ef5de,
+ 0x573b2635, 0xe0745b24, 0x52beac9f, 0xe8f77acf, 0x4aa22036, 0xf4491311, 0x580f7b19, 0xde6d1f65,
+ 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5471e2e6, 0xe61086bc,
+ 0x4bde1089, 0xf2beafed, 0x595c3e2a, 0xda8249b4, 0x553805f2, 0xe4a2eff6, 0x4c77a88e, 0xf1fa3ecb,
+ 0x59d438e5, 0xd8a00bae, 0x55f104dc, 0xe3399167, 0x4d0e4de2, 0xf136580d, 0x5a2d0957, 0xd6cb76c9,
+ 0x569cc31b, 0xe1d4a2c8, 0x4da1fab5, 0xf0730342, 0x5a6690ae, 0xd5052d97, 0x573b2635, 0xe0745b24,
+ 0x4e32a956, 0xefb047f2, 0x5a80baf6, 0xd34dcdb4, 0x57cc15bc, 0xdf18f0ce, 0x4ec05432, 0xeeee2d9d,
+ 0x5a7b7f1a, 0xd1a5ef90, 0x584f7b58, 0xddc29958, 0x4f4af5d1, 0xee2cbbc1, 0x5a56deec, 0xd00e2639,
+ 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a, 0x592d59da, 0xdb25f566,
+ 0x50570819, 0xecabef3d, 0x59afaf4c, 0xcd110216, 0x5987b08a, 0xd9e01006, 0x50d86e6d, 0xebeca36c,
+ 0x592d59da, 0xcbacb0bf, 0x59d438e5, 0xd8a00bae, 0x5156b6d9, 0xeb2e1dbe, 0x588c1404, 0xca5a86c4,
+ 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a, 0x57cc15bc, 0xc91af976, 0x5a43b190, 0xd6326a88,
+ 0x5249daa2, 0xe9b38223, 0x56eda1a0, 0xc7ee77b3, 0x5a6690ae, 0xd5052d97, 0x52beac9f, 0xe8f77acf,
+ 0x55f104dc, 0xc6d569be, 0x5a7b7f1a, 0xd3de9156, 0x53304df6, 0xe83c56cf, 0x54d69714, 0xc5d03118,
+ 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a7b7f1a, 0xd1a5ef90,
+ 0x5409ed4b, 0xe6c8d59c, 0x5249daa2, 0xc402a33c, 0x5a6690ae, 0xd09441bb, 0x5471e2e6, 0xe61086bc,
+ 0x50d86e6d, 0xc33aee27, 0x5a43b190, 0xcf89e3e8, 0x54d69714, 0xe55937d5, 0x4f4af5d1, 0xc2884e6e,
+ 0x5a12e720, 0xce86ff2a, 0x553805f2, 0xe4a2eff6, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xcd8bbb6d,
+ 0x55962bc0, 0xe3edb628, 0x4bde1089, 0xc1633f8a, 0x5987b08a, 0xcc983f70, 0x55f104dc, 0xe3399167,
+ 0x49ffd417, 0xc0f1360b, 0x592d59da, 0xcbacb0bf, 0x56488dc5, 0xe28688a4, 0x4807eb4b, 0xc0950d1d,
+ 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x584f7b58, 0xc9edeb50,
+ 0x56eda1a0, 0xe123e6ad, 0x43cdd89a, 0xc01ed535, 0x57cc15bc, 0xc91af976, 0x573b2635, 0xe0745b24,
+ 0x418d2621, 0xc004ef3f, 0x573b2635, 0xc8507ea7, 0x57854ddd, 0xdfc606f1, 0x3f35b59d, 0xc0013bd3,
+ 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce, 0x3cc85709, 0xc013bc39, 0x55f104dc, 0xc6d569be,
+ 0x580f7b19, 0xde6d1f65, 0x3a45e1f7, 0xc03c6a07, 0x553805f2, 0xc6250a18, 0x584f7b58, 0xddc29958,
+ 0x37af354c, 0xc07b371e, 0x5471e2e6, 0xc57d965d, 0x588c1404, 0xdd196538, 0x350536f1, 0xc0d00db6,
+ 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x52beac9f, 0xc449d892,
+ 0x58fb0568, 0xdbcb0cce, 0x2f7afdfc, 0xc1bb5a11, 0x51d1dc80, 0xc3bdbdf6, 0x592d59da, 0xdb25f566,
+ 0x2c9caf6c, 0xc2517e31, 0x50d86e6d, 0xc33aee27, 0x595c3e2a, 0xda8249b4, 0x29aee694, 0xc2fd08a9,
+ 0x4fd288dc, 0xc2c17d52, 0x5987b08a, 0xd9e01006, 0x26b2a794, 0xc3bdbdf6, 0x4ec05432, 0xc2517e31,
+ 0x59afaf4c, 0xd93f4e9e, 0x23a8fb93, 0xc4935b3c, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xd8a00bae,
+ 0x2092f05f, 0xc57d965d, 0x4c77a88e, 0xc18e18a7, 0x59f54bee, 0xd8024d59, 0x1d719810, 0xc67c1e18,
+ 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d, 0x49ffd417, 0xc0f1360b,
+ 0x5a2d0957, 0xd6cb76c9, 0x17115bc0, 0xc8b4ab32, 0x48b2b335, 0xc0b15502, 0x5a43b190, 0xd6326a88,
+ 0x13d4ae08, 0xc9edeb50, 0x475a5c77, 0xc07b371e, 0x5a56deec, 0xd59afadb, 0x10911f04, 0xcb39edca,
+ 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97, 0x0d47d096, 0xcc983f70, 0x4488e37f, 0xc02c64a6,
+ 0x5a72c63b, 0xd4710883, 0x09f9e6a1, 0xce0866b8, 0x43103085, 0xc013bc39, 0x5a7b7f1a, 0xd3de9156,
+ 0x06a886a0, 0xcf89e3e8, 0x418d2621, 0xc004ef3f, 0x5a80baf6, 0xd34dcdb4, 0x0354d741, 0xd11c3142,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3e68fb62, 0xc004ef3f,
+ 0x5a80baf6, 0xd2317756, 0xfcab28bf, 0xd4710883, 0x3cc85709, 0xc013bc39, 0x5a7b7f1a, 0xd1a5ef90,
+ 0xf9577960, 0xd6326a88, 0x3b1e5335, 0xc02c64a6, 0x5a72c63b, 0xd11c3142, 0xf606195f, 0xd8024d59,
+ 0x396b3199, 0xc04ee4b8, 0x5a6690ae, 0xd09441bb, 0xf2b82f6a, 0xd9e01006, 0x37af354c, 0xc07b371e,
+ 0x5a56deec, 0xd00e2639, 0xef6ee0fc, 0xdbcb0cce, 0x35eaa2c7, 0xc0b15502, 0x5a43b190, 0xcf89e3e8,
+ 0xec2b51f8, 0xddc29958, 0x341dbfd3, 0xc0f1360b, 0x5a2d0957, 0xcf077fe1, 0xe8eea440, 0xdfc606f1,
+ 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x306c2624, 0xc18e18a7,
+ 0x59f54bee, 0xce0866b8, 0xe28e67f0, 0xe3edb628, 0x2e88013a, 0xc1eb0209, 0x59d438e5, 0xcd8bbb6d,
+ 0xdf6d0fa1, 0xe61086bc, 0x2c9caf6c, 0xc2517e31, 0x59afaf4c, 0xcd110216, 0xdc57046d, 0xe83c56cf,
+ 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70, 0xd94d586c, 0xea70658a, 0x28b1b544, 0xc33aee27,
+ 0x595c3e2a, 0xcc217822, 0xd651196c, 0xecabef3d, 0x26b2a794, 0xc3bdbdf6, 0x592d59da, 0xcbacb0bf,
+ 0xd3635094, 0xeeee2d9d, 0x24ada23d, 0xc449d892, 0x58fb0568, 0xcb39edca, 0xd0850204, 0xf136580d,
+ 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x2092f05f, 0xc57d965d,
+ 0x588c1404, 0xca5a86c4, 0xcafac90f, 0xf5d544a7, 0x1e7de5df, 0xc6250a18, 0x584f7b58, 0xc9edeb50,
+ 0xc850cab4, 0xf82a6c6a, 0x1c6427a9, 0xc6d569be, 0x580f7b19, 0xc9836582, 0xc5ba1e09, 0xfa824bfd,
+ 0x1a4608ab, 0xc78e9a1d, 0x57cc15bc, 0xc91af976, 0xc337a8f7, 0xfcdc1342, 0x1823dc7d, 0xc8507ea7,
+ 0x57854ddd, 0xc8b4ab32, 0xc0ca4a63, 0xff36f170, 0x15fdf758, 0xc91af976, 0x573b2635, 0xc8507ea7,
+ 0xbe72d9df, 0x0192155f, 0x13d4ae08, 0xc9edeb50, 0x56eda1a0, 0xc7ee77b3, 0xbc322766, 0x03ecadcf,
+ 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af, 0x0f7944a7, 0xcbacb0bf,
+ 0x56488dc5, 0xc730e997, 0xb7f814b5, 0x089cf867, 0x0d47d096, 0xcc983f70, 0x55f104dc, 0xc6d569be,
+ 0xb6002be9, 0x0af10a22, 0x0b145041, 0xcd8bbb6d, 0x55962bc0, 0xc67c1e18, 0xb421ef77, 0x0d415013,
+ 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18, 0xb25e054b, 0x0f8cfcbe, 0x06a886a0, 0xcf89e3e8,
+ 0x54d69714, 0xc5d03118, 0xb0b50a2f, 0x11d3443f, 0x0470ebdc, 0xd09441bb, 0x5471e2e6, 0xc57d965d,
+ 0xaf279193, 0x14135c94, 0x0238a1c6, 0xd1a5ef90, 0x5409ed4b, 0xc52d3d18, 0xadb6255e, 0x164c7ddd,
+ 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xfdc75e3a, 0xd3de9156,
+ 0x53304df6, 0xc4935b3c, 0xab2968ec, 0x1aa6c82b, 0xfb8f1424, 0xd5052d97, 0x52beac9f, 0xc449d892,
+ 0xaa0efb24, 0x1cc66e99, 0xf9577960, 0xd6326a88, 0x5249daa2, 0xc402a33c, 0xa9125e60, 0x1edc1953,
+ 0xf720e574, 0xd76619b6, 0x51d1dc80, 0xc3bdbdf6, 0xa833ea44, 0x20e70f32, 0xf4ebafbf, 0xd8a00bae,
+ 0x5156b6d9, 0xc37b2b6a, 0xa773ebfc, 0x22e69ac8, 0xf2b82f6a, 0xd9e01006, 0x50d86e6d, 0xc33aee27,
+ 0xa6d2a626, 0x24da0a9a, 0xf086bb59, 0xdb25f566, 0x50570819, 0xc2fd08a9, 0xa65050b4, 0x26c0b162,
+ 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xec2b51f8, 0xddc29958,
+ 0x4f4af5d1, 0xc2884e6e, 0xa5a92114, 0x2a650525, 0xea0208a8, 0xdf18f0ce, 0x4ec05432, 0xc2517e31,
+ 0xa58480e6, 0x2c216eaa, 0xe7dc2383, 0xe0745b24, 0x4e32a956, 0xc21d0eb8, 0xa57f450a, 0x2dce88aa,
+ 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209, 0xa5996f52, 0x2f6bbe45, 0xe39bd857, 0xe3399167,
+ 0x4d0e4de2, 0xc1bb5a11, 0xa5d2f6a9, 0x30f8801f, 0xe1821a21, 0xe4a2eff6, 0x4c77a88e, 0xc18e18a7,
+ 0xa62bc71b, 0x32744493, 0xdf6d0fa1, 0xe61086bc, 0x4bde1089, 0xc1633f8a, 0xa6a3c1d6, 0x33de87de,
+ 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xdb525dc3, 0xe8f77acf,
+ 0x4aa22036, 0xc114ccb9, 0xa7f084e7, 0x367c9a7e, 0xd94d586c, 0xea70658a, 0x49ffd417, 0xc0f1360b,
+ 0xa8c4d9cb, 0x37af8159, 0xd74e4abc, 0xebeca36c, 0x495aada2, 0xc0d00db6, 0xa9b7723b, 0x38cf1669,
+ 0xd5558381, 0xed6bf9d1, 0x48b2b335, 0xc0b15502, 0xaac7fa0e, 0x39daf5e8, 0xd3635094, 0xeeee2d9d,
+ 0x4807eb4b, 0xc0950d1d, 0xabf612b5, 0x3ad2c2e8, 0xd177fec6, 0xf0730342, 0x475a5c77, 0xc07b371e,
+ 0xad415361, 0x3bb6276e, 0xcf93d9dc, 0xf1fa3ecb, 0x46aa0d6d, 0xc063d405, 0xaea94927, 0x3c84d496,
+ 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae, 0xcbe2402d, 0xf50ef5de,
+ 0x454149fc, 0xc03c6a07, 0xb1cd56aa, 0x3de2f148, 0xca155d39, 0xf69bf7c9, 0x4488e37f, 0xc02c64a6,
+ 0xb3885772, 0x3e71e759, 0xc850cab4, 0xf82a6c6a, 0x43cdd89a, 0xc01ed535, 0xb55ddfca, 0x3eeb3347,
+ 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39, 0xb74d4ccb, 0x3f4eaafe, 0xc4e1accb, 0xfb4ab7db,
+ 0x424ff28f, 0xc00b1a20, 0xb955f293, 0x3f9c2bfb, 0xc337a8f7, 0xfcdc1342, 0x418d2621, 0xc004ef3f,
+ 0xbb771c81, 0x3fd39b5a, 0xc197049e, 0xfe6deaa1, 0x40c7d2bd, 0xc0013bd3, 0xbdb00d71, 0x3ff4e5e0,
+};
+
+const int twidTabEven[4 * 6 + 16 * 6 + 64 * 6] = {
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x5a82799a, 0xd2bec333,
+ 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333,
+ 0x00000000, 0xd2bec333, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7,
+
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x4b418bbe, 0xf383a3e2,
+ 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2,
+ 0x58c542c5, 0xdc71898d, 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a,
+ 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xcac933ae,
+ 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d,
+ 0x3248d382, 0xc13ad060, 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3248d382, 0xc13ad060,
+ 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae,
+ 0xcdb72c7e, 0xf383a3e2, 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af,
+ 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xee57aa21, 0xdc71898d,
+ 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060,
+ 0xa73abd3b, 0x3536cc52, 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae,
+
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x43103085, 0xfcdc1342,
+ 0x418d2621, 0xfe6deaa1, 0x4488e37f, 0xfb4ab7db, 0x45f704f7, 0xf9ba1651, 0x43103085, 0xfcdc1342,
+ 0x48b2b335, 0xf69bf7c9, 0x48b2b335, 0xf69bf7c9, 0x4488e37f, 0xfb4ab7db, 0x4c77a88e, 0xf1fa3ecb,
+ 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x4da1fab5, 0xf0730342,
+ 0x475a5c77, 0xf82a6c6a, 0x52beac9f, 0xe8f77acf, 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9,
+ 0x553805f2, 0xe4a2eff6, 0x51d1dc80, 0xea70658a, 0x49ffd417, 0xf50ef5de, 0x573b2635, 0xe0745b24,
+ 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x553805f2, 0xe4a2eff6,
+ 0x4c77a88e, 0xf1fa3ecb, 0x59d438e5, 0xd8a00bae, 0x569cc31b, 0xe1d4a2c8, 0x4da1fab5, 0xf0730342,
+ 0x5a6690ae, 0xd5052d97, 0x57cc15bc, 0xdf18f0ce, 0x4ec05432, 0xeeee2d9d, 0x5a7b7f1a, 0xd1a5ef90,
+ 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a, 0x5987b08a, 0xd9e01006,
+ 0x50d86e6d, 0xebeca36c, 0x592d59da, 0xcbacb0bf, 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a,
+ 0x57cc15bc, 0xc91af976, 0x5a6690ae, 0xd5052d97, 0x52beac9f, 0xe8f77acf, 0x55f104dc, 0xc6d569be,
+ 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a6690ae, 0xd09441bb,
+ 0x5471e2e6, 0xe61086bc, 0x50d86e6d, 0xc33aee27, 0x5a12e720, 0xce86ff2a, 0x553805f2, 0xe4a2eff6,
+ 0x4da1fab5, 0xc1eb0209, 0x5987b08a, 0xcc983f70, 0x55f104dc, 0xe3399167, 0x49ffd417, 0xc0f1360b,
+ 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x57cc15bc, 0xc91af976,
+ 0x573b2635, 0xe0745b24, 0x418d2621, 0xc004ef3f, 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce,
+ 0x3cc85709, 0xc013bc39, 0x553805f2, 0xc6250a18, 0x584f7b58, 0xddc29958, 0x37af354c, 0xc07b371e,
+ 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x51d1dc80, 0xc3bdbdf6,
+ 0x592d59da, 0xdb25f566, 0x2c9caf6c, 0xc2517e31, 0x4fd288dc, 0xc2c17d52, 0x5987b08a, 0xd9e01006,
+ 0x26b2a794, 0xc3bdbdf6, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xd8a00bae, 0x2092f05f, 0xc57d965d,
+ 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d, 0x48b2b335, 0xc0b15502,
+ 0x5a43b190, 0xd6326a88, 0x13d4ae08, 0xc9edeb50, 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97,
+ 0x0d47d096, 0xcc983f70, 0x43103085, 0xc013bc39, 0x5a7b7f1a, 0xd3de9156, 0x06a886a0, 0xcf89e3e8,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3cc85709, 0xc013bc39,
+ 0x5a7b7f1a, 0xd1a5ef90, 0xf9577960, 0xd6326a88, 0x396b3199, 0xc04ee4b8, 0x5a6690ae, 0xd09441bb,
+ 0xf2b82f6a, 0xd9e01006, 0x35eaa2c7, 0xc0b15502, 0x5a43b190, 0xcf89e3e8, 0xec2b51f8, 0xddc29958,
+ 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x2e88013a, 0xc1eb0209,
+ 0x59d438e5, 0xcd8bbb6d, 0xdf6d0fa1, 0xe61086bc, 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70,
+ 0xd94d586c, 0xea70658a, 0x26b2a794, 0xc3bdbdf6, 0x592d59da, 0xcbacb0bf, 0xd3635094, 0xeeee2d9d,
+ 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x1e7de5df, 0xc6250a18,
+ 0x584f7b58, 0xc9edeb50, 0xc850cab4, 0xf82a6c6a, 0x1a4608ab, 0xc78e9a1d, 0x57cc15bc, 0xc91af976,
+ 0xc337a8f7, 0xfcdc1342, 0x15fdf758, 0xc91af976, 0x573b2635, 0xc8507ea7, 0xbe72d9df, 0x0192155f,
+ 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af, 0x0d47d096, 0xcc983f70,
+ 0x55f104dc, 0xc6d569be, 0xb6002be9, 0x0af10a22, 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18,
+ 0xb25e054b, 0x0f8cfcbe, 0x0470ebdc, 0xd09441bb, 0x5471e2e6, 0xc57d965d, 0xaf279193, 0x14135c94,
+ 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xfb8f1424, 0xd5052d97,
+ 0x52beac9f, 0xc449d892, 0xaa0efb24, 0x1cc66e99, 0xf720e574, 0xd76619b6, 0x51d1dc80, 0xc3bdbdf6,
+ 0xa833ea44, 0x20e70f32, 0xf2b82f6a, 0xd9e01006, 0x50d86e6d, 0xc33aee27, 0xa6d2a626, 0x24da0a9a,
+ 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xea0208a8, 0xdf18f0ce,
+ 0x4ec05432, 0xc2517e31, 0xa58480e6, 0x2c216eaa, 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209,
+ 0xa5996f52, 0x2f6bbe45, 0xe1821a21, 0xe4a2eff6, 0x4c77a88e, 0xc18e18a7, 0xa62bc71b, 0x32744493,
+ 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xd94d586c, 0xea70658a,
+ 0x49ffd417, 0xc0f1360b, 0xa8c4d9cb, 0x37af8159, 0xd5558381, 0xed6bf9d1, 0x48b2b335, 0xc0b15502,
+ 0xaac7fa0e, 0x39daf5e8, 0xd177fec6, 0xf0730342, 0x475a5c77, 0xc07b371e, 0xad415361, 0x3bb6276e,
+ 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae, 0xca155d39, 0xf69bf7c9,
+ 0x4488e37f, 0xc02c64a6, 0xb3885772, 0x3e71e759, 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39,
+ 0xb74d4ccb, 0x3f4eaafe, 0xc337a8f7, 0xfcdc1342, 0x418d2621, 0xc004ef3f, 0xbb771c81, 0x3fd39b5a,
+};
+
+/* for reference, here's the code to generate the bitreverse tables
+ short blocks: nbits = 4 (nfft = 64)
+ long blocks: nbits = 7 (nfft = 512)
+
+static int bitrev(int n, int nbits)
+{
+ int r, i;
+
+ r = 0;
+ for (i = 0; i < nbits; i++) {
+ r <<= 1;
+ r |= (n & 1);
+ n >>= 1;
+ }
+
+ return r;
+}
+
+static void InitBitrevTable(unsigned char *out, int nbits)
+{
+ int i, t;
+
+ for (i = 0; i < (1<<nbits); i++) {
+ / *** do not register the same transposition twice *** /
+ t = bitrev(i,nbits);
+ if (i < t) {
+ *out++ = (unsigned char)i;
+ *out++ = (unsigned char)t;
+ }
+ }
+
+ / *** no need to write a sentinel (or rather, the first entry in the
+ * table for symetric codes will be 0, which serves as the sentinel)
+ *** /
+ for (i = 0; i < (1<<nbits); i++) {
+ t = bitrev(i,nbits);
+ if (i == t) / *** symmetric codes get special treatment *** /
+ *out++ = (unsigned char)t;
+ }
+ *out++ = 0; / *** second sentinel is 0, again *** /
+}
+
+*/
+
+/* code to generate KBD window:
+static double CalcI0(double x)
+{
+ int k;
+ double i0, iTmp, iLast, x2, xPow, kFact;
+
+ x2 = x / 2.0;
+ i0 = 0.0;
+ k = 0;
+ kFact = 1;
+ xPow = 1;
+ do {
+ iLast = i0;
+ iTmp = xPow / kFact;
+ i0 += (iTmp*iTmp);
+ k++;
+ kFact *= k;
+ xPow *= x2;
+ } while (fabs(i0 - iLast) > KBD_THRESH);
+
+ return i0;
+}
+
+static double CalcW(double nRef, double n, double a)
+{
+ double i0Base, i0Curr, nTemp;
+
+ i0Base = CalcI0(M_PI * a);
+
+ nTemp = (n - nRef/4) / (nRef/4);
+ i0Curr = CalcI0( M_PI * a * sqrt(1.0 - nTemp*nTemp) );
+
+ return i0Curr / i0Base;
+}
+
+void InitKBDWindow(int nmdct)
+{
+ int n, nRef;
+ double a, wBase, wCurr;
+
+ nRef = nmdct * 2;
+
+ / *** kbd window *** /
+ if (nmdct == 128)
+ a = 6.0;
+ else
+ a = 4.0;
+
+ wBase = 0;
+ for (n = 0; n <= nRef/2; n++)
+ wBase += CalcW(nRef, n, a);
+
+ / *** left *** /
+ wCurr = 0;
+ for (n = 0; n < nRef/2; n++) {
+ wCurr += CalcW(nRef, n, a);
+ kbdWindowRef[n] = sqrt(wCurr / wBase);
+ }
+
+ / ***
+ * symmetry:
+ * kbd_right(n) = kbd_ldef(N_REF - 1 - n), n = [N_REF/2, N_REF - 1]
+ *
+ * wCurr = 0;
+ * for (n = N_REF-1; n >= N_REF/2; n--) {
+ * wCurr += CalcW(N_REF-n-1, a);
+ * kbdWindowRef[n] = sqrt(wCurr / wBase);
+ * }
+ *
+ *** /
+ return;
+}
+*/
diff --git a/audio_codec/libraac/trigtabs_fltgen.c b/audio_codec/libraac/trigtabs_fltgen.c
new file mode 100644
index 0000000..b5ffa8e
--- a/dev/null
+++ b/audio_codec/libraac/trigtabs_fltgen.c
@@ -0,0 +1,357 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: trigtabs_fltgen.c,v 1.2 2006/12/05 03:36:53 ehyche Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * June 2005
+ *
+ * trigtabs_fltgen.c - low-ROM alternative to trigtabs.c
+ * generates large trig tables at runtime using floating-point
+ * math library
+ * MUST VERIFY that runtime-generated tables are bit-exact matches
+ * with ROM tables in trigtabs.c
+ **************************************************************************************/
+#ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT
+
+#include <math.h>
+#include "coder.h"
+
+/* read-only tables */
+const int cos4sin4tabOffset[NUM_IMDCT_SIZES] = {0, 128};
+const int sinWindowOffset[NUM_IMDCT_SIZES] = {0, 128};
+const int kbdWindowOffset[NUM_IMDCT_SIZES] = {0, 128};
+const int bitrevtabOffset[NUM_IMDCT_SIZES] = {0, 17};
+const unsigned char bitrevtab[17 + 129] = {
+ /* nfft = 64 */
+ 0x01, 0x08, 0x02, 0x04, 0x03, 0x0c, 0x05, 0x0a, 0x07, 0x0e, 0x0b, 0x0d, 0x00, 0x06, 0x09, 0x0f,
+ 0x00,
+
+ /* nfft = 512 */
+ 0x01, 0x40, 0x02, 0x20, 0x03, 0x60, 0x04, 0x10, 0x05, 0x50, 0x06, 0x30, 0x07, 0x70, 0x09, 0x48,
+ 0x0a, 0x28, 0x0b, 0x68, 0x0c, 0x18, 0x0d, 0x58, 0x0e, 0x38, 0x0f, 0x78, 0x11, 0x44, 0x12, 0x24,
+ 0x13, 0x64, 0x15, 0x54, 0x16, 0x34, 0x17, 0x74, 0x19, 0x4c, 0x1a, 0x2c, 0x1b, 0x6c, 0x1d, 0x5c,
+ 0x1e, 0x3c, 0x1f, 0x7c, 0x21, 0x42, 0x23, 0x62, 0x25, 0x52, 0x26, 0x32, 0x27, 0x72, 0x29, 0x4a,
+ 0x2b, 0x6a, 0x2d, 0x5a, 0x2e, 0x3a, 0x2f, 0x7a, 0x31, 0x46, 0x33, 0x66, 0x35, 0x56, 0x37, 0x76,
+ 0x39, 0x4e, 0x3b, 0x6e, 0x3d, 0x5e, 0x3f, 0x7e, 0x43, 0x61, 0x45, 0x51, 0x47, 0x71, 0x4b, 0x69,
+ 0x4d, 0x59, 0x4f, 0x79, 0x53, 0x65, 0x57, 0x75, 0x5b, 0x6d, 0x5f, 0x7d, 0x67, 0x73, 0x6f, 0x7b,
+ 0x00, 0x08, 0x14, 0x1c, 0x22, 0x2a, 0x36, 0x3e, 0x41, 0x49, 0x55, 0x5d, 0x63, 0x6b, 0x77, 0x7f,
+ 0x00,
+
+};
+
+/* tables generated at runtime */
+int cos4sin4tab[128 + 1024];
+int cos1sin1tab[514];
+int sinWindow[128 + 1024];
+int kbdWindow[128 + 1024];
+int twidTabEven[4 * 6 + 16 * 6 + 64 * 6];
+int twidTabOdd[8 * 6 + 32 * 6 + 128 * 6];
+
+#define M_PI 3.14159265358979323846
+#define M2_30 1073741824.0
+#define M2_31 2147483648.0
+
+#define MAX_DBL 2147483647.0
+#define MIN_DBL -2147483648.0
+
+static int NormAndRound(double x, double q, double n)
+{
+ if (x >= 0.0) {
+ x = (x * q * n + 0.5);
+ } else {
+ x = (x * q * n - 0.5);
+ }
+
+ /* clip */
+ if (x > MAX_DBL) {
+ x = MAX_DBL;
+ }
+ if (x < MIN_DBL) {
+ x = MIN_DBL;
+ }
+
+ return (int)x;
+}
+
+static void Init_cos4sin4tab(int *tPtr, int nmdct)
+{
+ int i;
+ double angle1, angle2, invM, x1, x2, x3, x4;
+
+ invM = -1.0 / (double)nmdct;
+ for (i = 0; i < nmdct / 4; i++) {
+ angle1 = (i + 0.25) * M_PI / nmdct;
+ angle2 = (nmdct / 2 - 1 - i + 0.25) * M_PI / nmdct;
+
+ x1 = invM * (cos(angle1) + sin(angle1));
+ x2 = invM * sin(angle1);
+ x3 = invM * (cos(angle2) + sin(angle2));
+ x4 = invM * sin(angle2);
+
+ tPtr[0] = NormAndRound(x1, M2_30, nmdct);
+ tPtr[1] = NormAndRound(x2, M2_30, nmdct);
+ tPtr[2] = NormAndRound(x3, M2_30, nmdct);
+ tPtr[3] = NormAndRound(x4, M2_30, nmdct);
+ tPtr += 4;
+ }
+}
+
+static void Init_cos1sin1tab(int *tPtr)
+{
+ int i;
+ double angle, x1, x2;
+
+ for (i = 0; i <= (512 / 2); i++) {
+ angle = i * M_PI / 1024;
+ x1 = (cos(angle) + sin(angle));
+ x2 = sin(angle);
+
+ tPtr[0] = NormAndRound(x1, M2_30, 1);
+ tPtr[1] = NormAndRound(x2, M2_30, 1);
+ tPtr += 2;
+ }
+}
+
+static void Init_sinWindow(int *tPtr, int nmdct)
+{
+ int i;
+ double angle1, angle2, x1, x2;
+
+ for (i = 0; i < nmdct / 2; i++) {
+ angle1 = (i + 0.5) * M_PI / (2.0 * nmdct);
+ angle2 = (nmdct - 1 - i + 0.5) * M_PI / (2.0 * nmdct);
+ x1 = sin(angle1);
+ x2 = sin(angle2);
+
+ tPtr[0] = NormAndRound(x1, M2_31, 1);
+ tPtr[1] = NormAndRound(x2, M2_31, 1);
+ tPtr += 2;
+ }
+}
+
+
+#define KBD_THRESH 1e-12
+
+static double CalcI0(double x)
+{
+ int k;
+ double i0, iTmp, iLast, x2, xPow, kFact;
+
+ x2 = x / 2.0;
+ i0 = 0.0;
+ k = 0;
+ kFact = 1;
+ xPow = 1;
+ do {
+ iLast = i0;
+ iTmp = xPow / kFact;
+ i0 += (iTmp * iTmp);
+ k++;
+ kFact *= k;
+ xPow *= x2;
+ } while (fabs(i0 - iLast) > KBD_THRESH);
+
+ return i0;
+}
+
+static double CalcW(double nRef, double n, double a)
+{
+ double i0Base, i0Curr, nTemp;
+
+ i0Base = CalcI0(M_PI * a);
+
+ nTemp = (n - nRef / 4) / (nRef / 4);
+ i0Curr = CalcI0(M_PI * a * sqrt(1.0 - nTemp * nTemp));
+
+ return i0Curr / i0Base;
+}
+
+static void Init_kbdWindow(int *tPtr, int nmdct)
+{
+ int n, nRef;
+ double a, wBase, wCurr, x1;
+
+ nRef = nmdct * 2;
+
+ /* kbd window */
+ if (nmdct == 128) {
+ a = 6.0;
+ } else {
+ a = 4.0;
+ }
+
+ wBase = 0;
+ for (n = 0; n <= nRef / 2; n++) {
+ wBase += CalcW(nRef, n, a);
+ }
+
+ /* left */
+ wCurr = 0;
+ for (n = 0; n < nmdct / 2; n++) {
+ wCurr += CalcW(nRef, n, a);
+ x1 = sqrt(wCurr / wBase);
+ tPtr[0] = NormAndRound(x1, M2_31, 1);
+ tPtr += 2;
+ }
+ tPtr--;
+
+ /* right */
+ for (n = nmdct / 2; n < nmdct; n++) {
+ wCurr += CalcW(nRef, n, a);
+ x1 = sqrt(wCurr / wBase);
+ tPtr[0] = NormAndRound(x1, M2_31, 1);
+ tPtr -= 2;
+ }
+
+ /* symmetry:
+ * kbd_right(n) = kbd_ldef(N_REF - 1 - n), n = [N_REF/2, N_REF - 1]
+ *
+ * wCurr = 0;
+ * for (n = N_REF-1; n >= N_REF/2; n--) {
+ * wCurr += CalcW(N_REF-n-1, a);
+ * kbdWindowRef[n] = sqrt(wCurr / wBase);
+ * }
+ *
+ */
+ return;
+}
+
+static void Init_twidTabs(int *tPtrEven, int *tPtrOdd, int nfft)
+{
+ int j, k;
+ double wr1, wi1, wr2, wi2, wr3, wi3;
+
+ for (k = 4; k <= nfft / 4; k <<= 1) {
+ for (j = 0; j < k; j++) {
+ wr1 = cos(1.0 * M_PI * j / (2 * k));
+ wi1 = sin(1.0 * M_PI * j / (2 * k));
+ wr1 = (wr1 + wi1);
+ wi1 = -wi1;
+
+ wr2 = cos(2.0 * M_PI * j / (2 * k));
+ wi2 = sin(2.0 * M_PI * j / (2 * k));
+ wr2 = (wr2 + wi2);
+ wi2 = -wi2;
+
+ wr3 = cos(3.0 * M_PI * j / (2 * k));
+ wi3 = sin(3.0 * M_PI * j / (2 * k));
+ wr3 = (wr3 + wi3);
+ wi3 = -wi3;
+
+ if (k & 0xaaaaaaaa) {
+ tPtrOdd[0] = NormAndRound(wr2, M2_30, 1);
+ tPtrOdd[1] = NormAndRound(wi2, M2_30, 1);
+ tPtrOdd[2] = NormAndRound(wr1, M2_30, 1);
+ tPtrOdd[3] = NormAndRound(wi1, M2_30, 1);
+ tPtrOdd[4] = NormAndRound(wr3, M2_30, 1);
+ tPtrOdd[5] = NormAndRound(wi3, M2_30, 1);
+ tPtrOdd += 6;
+ } else {
+ tPtrEven[0] = NormAndRound(wr2, M2_30, 1);
+ tPtrEven[1] = NormAndRound(wi2, M2_30, 1);
+ tPtrEven[2] = NormAndRound(wr1, M2_30, 1);
+ tPtrEven[3] = NormAndRound(wi1, M2_30, 1);
+ tPtrEven[4] = NormAndRound(wr3, M2_30, 1);
+ tPtrEven[5] = NormAndRound(wi3, M2_30, 1);
+ tPtrEven += 6;
+ }
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: AACInitTrigtabsFloat
+ *
+ * Description: generate AAC decoder tables using floating-point math library
+ *
+ * Inputs: none
+ *
+ * Outputs: initialized tables
+ *
+ * Return: 0 on success
+ *
+ * Notes: this function should ONLY be called when double-precision
+ * floating-point math is supported
+ * the generated tables must be bit-exact matches with read-only
+ * tables stored in trigtabs.c
+ * this initializes global tables in RAM, and is NOT thread-safe,
+ * so the caller must ensure that this function is not called
+ * from multiple threads
+ * this should be called exactly once, before the entrypoint function
+ * for the application or DLL is called
+ **************************************************************************************/
+int AACInitTrigtabsFloat(void)
+{
+ /* cos4sin4tab */
+ Init_cos4sin4tab(cos4sin4tab + cos4sin4tabOffset[0], 128);
+ Init_cos4sin4tab(cos4sin4tab + cos4sin4tabOffset[1], 1024);
+
+ /* cos1sin1tab */
+ Init_cos1sin1tab(cos1sin1tab);
+
+ /* sinWindow */
+ Init_sinWindow(sinWindow + sinWindowOffset[0], 128);
+ Init_sinWindow(sinWindow + sinWindowOffset[1], 1024);
+
+ /* kbdWindow */
+ Init_kbdWindow(kbdWindow + kbdWindowOffset[0], 128);
+ Init_kbdWindow(kbdWindow + kbdWindowOffset[1], 1024);
+
+ /* twidTabEven, twidTabOdd */
+ Init_twidTabs(twidTabEven, twidTabOdd, 512);
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: AACFreeTrigtabsFloat
+ *
+ * Description: free any memory allocated by AACInitTrigtabsFloat()
+ *
+ * Inputs: none
+ *
+ * Outputs: none
+ *
+ * Return: none
+ **************************************************************************************/
+void AACFreeTrigtabsFloat(void)
+{
+ return;
+}
+
+#endif /* HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT */
diff --git a/audio_codec/wfd_aac_decoder/Android.mk b/audio_codec/wfd_aac_decoder/Android.mk
new file mode 100755
index 0000000..9d0d183
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/Android.mk
@@ -0,0 +1,23 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libaac_helix
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+LOCAL_ARM_MODE := arm
+LOCAL_C_INCLUDES := $(LOCAL_PATH) \
+ $(LOCAL_PATH)/codebook
+LOCAL_CFLAGS += -DUSE_DEFAULT_STDLIB
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_SHARED_LIBRARIES += libutils libmedia libz libbinder libdl libcutils libc
+LOCAL_CFLAGS += -DUSE_DEFAULT_STDLIB
+LOCAL_MODULE := libaac_helix
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+LOCAL_ARM_MODE := arm
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := $(LOCAL_PATH) \
+ $(LOCAL_PATH)/codebook
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/audio_codec/wfd_aac_decoder/aaccommon.h b/audio_codec/wfd_aac_decoder/aaccommon.h
new file mode 100644
index 0000000..e349dce
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/aaccommon.h
@@ -0,0 +1,210 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aaccommon.h,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * aaccommon.h - implementation-independent API's, datatypes, and definitions
+ **************************************************************************************/
+
+#ifndef _AACCOMMON_H
+#define _AACCOMMON_H
+
+#include "aacdec.h"
+#include "statname.h"
+
+#include <android/log.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#define LOG_TAG "WFDAAC"
+#define audio_codec_print(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define printk audio_codec_print
+#define LOCAL /*inline*/
+
+/* 12-bit syncword */
+#define SYNCWORDH 0xff
+#define SYNCWORDL 0xf0
+
+#define SYNCWORD0 0x67
+#define SYNCWORD1 0x89
+
+#define MAX_NCHANS_ELEM 2// /* max number of channels in any single bitstream element (SCE,CPE,CCE,LFE) */
+
+#define ADTS_HEADER_BYTES 7
+#define NUM_SAMPLE_RATES 12
+#define NUM_DEF_CHAN_MAPS 8
+#define NUM_ELEMENTS 8
+#define MAX_NUM_PCE_ADIF 16
+
+#define MAX_WIN_GROUPS 8
+#define MAX_SFB_SHORT 15
+#define MAX_SF_BANDS (MAX_SFB_SHORT*MAX_WIN_GROUPS) /* worst case = 15 sfb's * 8 windows for short block */
+#define MAX_MS_MASK_BYTES ((MAX_SF_BANDS + 7) >> 3)
+#define MAX_PRED_SFB 41
+#define MAX_TNS_FILTERS 8
+#define MAX_TNS_COEFS 60
+#define MAX_TNS_ORDER 20
+#define MAX_PULSES 4
+#define MAX_GAIN_BANDS 3
+#define MAX_GAIN_WIN 8
+#define MAX_GAIN_ADJUST 7
+
+#define NSAMPS_LONG 1024
+#define NSAMPS_SHORT 128
+
+#define NUM_SYN_ID_BITS 3
+#define NUM_INST_TAG_BITS 4
+
+#define EXT_SBR_DATA 0x0d
+#define EXT_SBR_DATA_CRC 0x0e
+
+#define IS_ADIF(p) ((p)[0] == 'A' && (p)[1] == 'D' && (p)[2] == 'I' && (p)[3] == 'F')
+#define GET_ELE_ID(p) ((AACElementID)(*(p) >> (8-NUM_SYN_ID_BITS)))
+
+/* AAC file format */
+enum {
+ AAC_FF_Unknown = 0, /* should be 0 on init */
+
+ AAC_FF_ADTS = 1,
+ AAC_FF_ADIF = 2,
+ AAC_FF_RAW = 3
+
+};
+
+/* syntactic element type */
+enum {
+ AAC_ID_INVALID = -1,
+
+ AAC_ID_SCE = 0,
+ AAC_ID_CPE = 1,
+ AAC_ID_CCE = 2,
+ AAC_ID_LFE = 3,
+ AAC_ID_DSE = 4,
+ AAC_ID_PCE = 5,
+ AAC_ID_FIL = 6,
+ AAC_ID_END = 7
+};
+
+typedef struct _AACDecInfo {
+ /* pointers to platform-specific state information */
+ void *psInfoBase; /* baseline MPEG-4 LC decoding */
+ void *psInfoSBR; /* MPEG-4 SBR decoding */
+
+ /* raw decoded data, before rounding to 16-bit PCM (for postprocessing such as SBR) */
+ void *rawSampleBuf[AAC_MAX_NCHANS];
+ int rawSampleBytes;
+ int rawSampleFBits;
+
+ /* fill data (can be used for processing SBR or other extensions) */
+ unsigned char *fillBuf;
+ int fillCount;
+ int fillExtType;
+
+ /* block information */
+ int prevBlockID;
+ int currBlockID;
+ int currInstTag;
+ int sbDeinterleaveReqd[MAX_NCHANS_ELEM];
+ int adtsBlocksLeft;
+
+ /* user-accessible info */
+ int bitRate;
+ int nChans;
+ int sampRate;
+ int profile;
+ int format;
+ int sbrEnabled;
+ int tnsUsed;
+ int pnsUsed;
+ int frameCount;
+ int byteParsed;
+ int sampleDecoded;
+ unsigned audio_send_by_frame;
+ unsigned frame_length;
+} AACDecInfo;
+
+/* decoder functions which must be implemented for each platform */
+AACDecInfo *AllocateBuffers(void);
+void FreeBuffers(AACDecInfo *aacDecInfo);
+void ClearBuffer(void *buf, int nBytes);
+
+int UnpackADTSHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail);
+int GetADTSChannelMapping(AACDecInfo *aacDecInfo, unsigned char *buf, int bitOffset, int bitsAvail);
+int UnpackADIFHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail);
+int SetRawBlockParams(AACDecInfo *aacDecInfo, int copyLast, int nChans, int sampRate, int profile);
+int PrepareRawBlock(AACDecInfo *aacDecInfo);
+int FlushCodec(AACDecInfo *aacDecInfo);
+
+int DecodeNextElement(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail);
+int DecodeNoiselessData(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail, int ch);
+
+int Dequantize(AACDecInfo *aacDecInfo, int ch);
+int StereoProcess(AACDecInfo *aacDecInfo);
+int DeinterleaveShortBlocks(AACDecInfo *aacDecInfo, int ch);
+int PNS(AACDecInfo *aacDecInfo, int ch);
+int TNSFilter(AACDecInfo *aacDecInfo, int ch);
+int IMDCT(AACDecInfo *aacDecInfo, int ch, int chBase, short *outbuf);
+
+/* SBR specific functions */
+int InitSBR(AACDecInfo *aacDecInfo);
+void FreeSBR(AACDecInfo *aacDecInfo);
+int DecodeSBRBitstream(AACDecInfo *aacDecInfo, int chBase);
+int DecodeSBRData(AACDecInfo *aacDecInfo, int chBase, short *outbuf);
+int FlushCodecSBR(AACDecInfo *aacDecInfo);
+
+/* aactabs.c - global ROM tables */
+extern const int sampRateTab[NUM_SAMPLE_RATES];
+extern const int predSFBMax[NUM_SAMPLE_RATES];
+extern const int channelMapTab[NUM_DEF_CHAN_MAPS];
+extern const int elementNumChans[NUM_ELEMENTS];
+extern const unsigned char sfBandTotalShort[NUM_SAMPLE_RATES];
+extern const unsigned char sfBandTotalLong[NUM_SAMPLE_RATES];
+extern const int sfBandTabShortOffset[NUM_SAMPLE_RATES];
+extern const short sfBandTabShort[76];
+extern const int sfBandTabLongOffset[NUM_SAMPLE_RATES];
+extern const short sfBandTabLong[325];
+extern const int tnsMaxBandsShortOffset[AAC_NUM_PROFILES];
+extern const unsigned char tnsMaxBandsShort[2 * NUM_SAMPLE_RATES];
+extern const unsigned char tnsMaxOrderShort[AAC_NUM_PROFILES];
+extern const int tnsMaxBandsLongOffset[AAC_NUM_PROFILES];
+extern const unsigned char tnsMaxBandsLong[2 * NUM_SAMPLE_RATES];
+extern const unsigned char tnsMaxOrderLong[AAC_NUM_PROFILES];
+
+#endif /* _AACCOMMON_H */
diff --git a/audio_codec/wfd_aac_decoder/aacdec.c b/audio_codec/wfd_aac_decoder/aacdec.c
new file mode 100644
index 0000000..e8297a4
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/aacdec.c
@@ -0,0 +1,508 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aacdec.c,v 1.1 2005/02/26 01:47:31 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * aacdec.c - platform-independent top level decoder API
+ **************************************************************************************/
+#include "aaccommon.h"
+#include "bitstream.h"
+#include <stdio.h>
+#include "aacdec.h"
+
+#define HELIX_MAX_DECODE_CH_NUM (6)
+
+/**************************************************************************************
+ * Function: AACInitDecoder
+ *
+ * Description: allocate memory for platform-specific data
+ * clear all the user-accessible fields
+ * initialize SBR decoder if enabled
+ *
+ * Inputs: none
+ *
+ * Outputs: none
+ *
+ * Return: handle to AAC decoder instance, 0 if malloc fails
+ **************************************************************************************/
+HAACDecoder AACInitDecoder(void)
+{
+ AACDecInfo *aacDecInfo;
+
+ aacDecInfo = AllocateBuffers();
+ if (!aacDecInfo) {
+ return 0;
+ }
+
+#ifdef AAC_ENABLE_SBR
+ if (InitSBR(aacDecInfo)) {
+ AACFreeDecoder(aacDecInfo);
+ return 0;
+ }
+#endif
+
+ return (HAACDecoder)aacDecInfo;
+}
+
+/**************************************************************************************
+ * Function: AACFreeDecoder
+ *
+ * Description: free platform-specific data allocated by AACInitDecoder
+ * free SBR decoder if enabled
+ *
+ * Inputs: valid AAC decoder instance pointer (HAACDecoder)
+ *
+ * Outputs: none
+ *
+ * Return: none
+ **************************************************************************************/
+void AACFreeDecoder(HAACDecoder hAACDecoder)
+{
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+
+ if (!aacDecInfo) {
+ return;
+ }
+
+#ifdef AAC_ENABLE_SBR
+ FreeSBR(aacDecInfo);
+#endif
+ FreeBuffers(aacDecInfo);
+}
+
+/**************************************************************************************
+ * Function: AACFindSyncWord
+ *
+ * Description: locate the next byte-alinged sync word in the raw AAC stream
+ *
+ * Inputs: buffer to search for sync word
+ * max number of bytes to search in buffer
+ *
+ * Outputs: none
+ *
+ * Return: offset to first sync word (bytes from start of buf)
+ * -1 if sync not found after searching nBytes
+ **************************************************************************************/
+int AACFindSyncWord(unsigned char *buf, int nBytes)
+{
+ int i;
+
+ /* find byte-aligned syncword (12 bits = 0xFFF) */
+ for (i = 0; i < nBytes - 1; i++) {
+ if ((buf[i + 0] & SYNCWORDH) == SYNCWORDH && (buf[i + 1] & SYNCWORDL) == SYNCWORDL) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+/**************************************************************************************
+ * Function: AACGetLastFrameInfo
+ *
+ * Description: get info about last AAC frame decoded (number of samples decoded,
+ * sample rate, bit rate, etc.)
+ *
+ * Inputs: valid AAC decoder instance pointer (HAACDecoder)
+ * pointer to AACFrameInfo struct
+ *
+ * Outputs: filled-in AACFrameInfo struct
+ *
+ * Return: none
+ *
+ * Notes: call this right after calling AACDecode()
+ **************************************************************************************/
+void AACGetLastFrameInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo)
+{
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+
+ if (!aacDecInfo) {
+ aacFrameInfo->format = 0;
+ aacFrameInfo->bitRate = 0;
+ aacFrameInfo->nChans = 0;
+ aacFrameInfo->sampRateCore = 0;
+ aacFrameInfo->sampRateOut = 0;
+ aacFrameInfo->bitsPerSample = 0;
+ aacFrameInfo->outputSamps = 0;
+ aacFrameInfo->profile = 0;
+ aacFrameInfo->tnsUsed = 0;
+ aacFrameInfo->pnsUsed = 0;
+ } else {
+ aacFrameInfo->format = aacDecInfo->format;
+ aacFrameInfo->nChans = aacDecInfo->nChans;
+ aacFrameInfo->sampRateCore = aacDecInfo->sampRate;
+ aacFrameInfo->sampRateOut = aacDecInfo->sampRate * (aacDecInfo->sbrEnabled ? 2 : 1);
+ aacFrameInfo->bitsPerSample = 16;
+ aacFrameInfo->outputSamps = aacDecInfo->nChans * AAC_MAX_NSAMPS * (aacDecInfo->sbrEnabled ? 2 : 1);
+ aacFrameInfo->profile = aacDecInfo->profile;
+ aacFrameInfo->tnsUsed = aacDecInfo->tnsUsed;
+ aacFrameInfo->pnsUsed = aacDecInfo->pnsUsed;
+ }
+}
+
+void AACGetDecoderInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo)
+{
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+
+ if (aacDecInfo) {
+ aacFrameInfo->format = aacDecInfo->format;
+ aacFrameInfo->nChans = aacDecInfo->nChans;
+ aacFrameInfo->sampRateCore = aacDecInfo->sampRate;
+ aacFrameInfo->sampRateOut = aacDecInfo->sampRate * (aacDecInfo->sbrEnabled ? 2 : 1);
+ aacFrameInfo->bitsPerSample = 16;
+ aacFrameInfo->outputSamps = aacDecInfo->nChans * AAC_MAX_NSAMPS * (aacDecInfo->sbrEnabled ? 2 : 1);
+ aacFrameInfo->profile = aacDecInfo->profile;
+ aacFrameInfo->tnsUsed = aacDecInfo->tnsUsed;
+ aacFrameInfo->pnsUsed = aacDecInfo->pnsUsed;
+ aacFrameInfo->total_byte_parsed = aacDecInfo->byteParsed;
+ aacFrameInfo->total_sample_decoded = aacDecInfo->sampleDecoded;
+
+ if (aacDecInfo->bitRate) {
+ aacFrameInfo->bitRate = aacDecInfo->bitRate;
+ } else if (aacDecInfo->sampleDecoded > 0) {
+ aacFrameInfo->bitRate = (int)(((float)(aacDecInfo->byteParsed)) / ((float)aacDecInfo->sampleDecoded / (float)aacFrameInfo->sampRateOut)) << 3;
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: AACSetRawBlockParams
+ *
+ * Description: set internal state variables for decoding a stream of raw data blocks
+ *
+ * Inputs: valid AAC decoder instance pointer (HAACDecoder)
+ * flag indicating source of parameters
+ * AACFrameInfo struct, with the members nChans, sampRate, and profile
+ * optionally filled-in
+ *
+ * Outputs: updated codec state
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: if copyLast == 1, then the codec sets up its internal state (for
+ * decoding raw blocks) based on previously-decoded ADTS header info
+ * if copyLast == 0, then the codec uses the values passed in
+ * aacFrameInfo to configure its internal state (useful when the
+ * source is MP4 format, for example)
+ **************************************************************************************/
+int AACSetRawBlockParams(HAACDecoder hAACDecoder, int copyLast, AACFrameInfo *aacFrameInfo)
+{
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+
+ if (!aacDecInfo) {
+ return ERR_AAC_NULL_POINTER;
+ }
+
+ aacDecInfo->format = AAC_FF_RAW;
+ aacDecInfo->audio_send_by_frame = aacFrameInfo->audio_send_by_frame;
+ if (copyLast) {
+ return SetRawBlockParams(aacDecInfo, 1, 0, 0, 0);
+ } else {
+ return SetRawBlockParams(aacDecInfo, 0, aacFrameInfo->nChans, aacFrameInfo->sampRateCore, aacFrameInfo->profile);
+ }
+}
+
+/**************************************************************************************
+ * Function: AACFlushCodec
+ *
+ * Description: flush internal codec state (after seeking, for example)
+ *
+ * Inputs: valid AAC decoder instance pointer (HAACDecoder)
+ *
+ * Outputs: updated state variables in aacDecInfo
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int AACFlushCodec(HAACDecoder hAACDecoder)
+{
+ int ch;
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+
+ if (!aacDecInfo) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ /* reset common state variables which change per-frame
+ * don't touch state variables which are (usually) constant for entire clip
+ * (nChans, sampRate, profile, format, sbrEnabled)
+ */
+ aacDecInfo->prevBlockID = AAC_ID_INVALID;
+ aacDecInfo->currBlockID = AAC_ID_INVALID;
+ aacDecInfo->currInstTag = -1;
+ for (ch = 0; ch < MAX_NCHANS_ELEM; ch++) {
+ aacDecInfo->sbDeinterleaveReqd[ch] = 0;
+ }
+ aacDecInfo->adtsBlocksLeft = 0;
+ aacDecInfo->tnsUsed = 0;
+ aacDecInfo->pnsUsed = 0;
+
+ /* reset internal codec state (flush overlap buffers, etc.) */
+ FlushCodec(aacDecInfo);
+#ifdef AAC_ENABLE_SBR
+ FlushCodecSBR(aacDecInfo);
+#endif
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: AACDecode
+ *
+ * Description: decode AAC frame
+ *
+ * Inputs: valid AAC decoder instance pointer (HAACDecoder)
+ * double pointer to buffer of AAC data
+ * pointer to number of valid bytes remaining in inbuf
+ * pointer to outbuf, big enough to hold one frame of decoded PCM samples
+ * (outbuf must be double-sized if SBR enabled)
+ *
+ * Outputs: PCM data in outbuf, interleaved LRLRLR... if stereo
+ * number of output samples = 1024 per channel (2048 if SBR enabled)
+ * updated inbuf pointer
+ * updated bytesLeft
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: inbuf pointer and bytesLeft are not updated until whole frame is
+ * successfully decoded, so if ERR_AAC_INDATA_UNDERFLOW is returned
+ * just call AACDecode again with more data in inbuf
+ **************************************************************************************/
+int AACDecode(HAACDecoder hAACDecoder, unsigned char **inbuf, int *bytesLeft, short *outbuf)
+{
+ int err, offset, bitOffset, bitsAvail;
+ int ch, baseChan, baseChanSBR, elementChans;
+ unsigned char *inptr;
+ AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;
+#ifdef AAC_ENABLE_SBR
+ int elementChansSBR;
+#endif
+
+ if (!aacDecInfo) {
+ return ERR_AAC_NULL_POINTER;
+ }
+
+ /* make local copies (see "Notes" above) */
+ inptr = *inbuf;
+ bitOffset = 0;
+ bitsAvail = (*bytesLeft) << 3;
+
+ /* first time through figure out what the file format is */
+ if (aacDecInfo->format == AAC_FF_Unknown) {
+ if (bitsAvail < 32) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+
+ if (IS_ADIF(inptr)) {
+ /* unpack ADIF header */
+ aacDecInfo->format = AAC_FF_ADIF;
+ //printk("ADIF_DBG:ready step into UnpackADIFHeader()!\n");
+ err = UnpackADIFHeader(aacDecInfo, &inptr, &bitOffset, &bitsAvail);
+ if (err) {
+ return err;
+ }
+ } else {
+ /* assume ADTS by default */
+ aacDecInfo->format = AAC_FF_ADTS;
+ }
+ }
+ //printk("ADIF_DBG:aacDecInfo->format1=%d\n",aacDecInfo->format);
+
+ /* if ADTS, search for start of next frame */
+ if (aacDecInfo->format == AAC_FF_ADTS) {
+ /* can have 1-4 raw data blocks per ADTS frame (header only present for first one) */
+ if (/*aacDecInfo->adtsBlocksLeft == 0*/1) {
+ offset = AACFindSyncWord(inptr, bitsAvail >> 3);
+ if (AACDataSource == 1) {
+ if (offset < 0) { //not find sync word in current buffer
+ return ERR_AAC_INVALID_ADTS_SYNCWORD; //ERR_AAC_INDATA_UNDERFLOW;
+ }
+ inptr += offset;
+ bitsAvail -= (offset << 3);
+ }
+ err = UnpackADTSHeader(aacDecInfo, &inptr, &bitOffset, &bitsAvail);
+ if (err) {
+ return err;
+ }
+
+ if (aacDecInfo->nChans == -1) {
+ /* figure out implicit channel mapping if necessary */
+ err = GetADTSChannelMapping(aacDecInfo, inptr, bitOffset, bitsAvail);
+ if (err) {
+ return err;
+ }
+ }
+ }
+ aacDecInfo->adtsBlocksLeft--;
+ } else if (aacDecInfo->format == AAC_FF_RAW) {
+ err = PrepareRawBlock(aacDecInfo);
+ if (err) {
+ return err;
+ }
+ }
+
+ //printk("ADIF_DBG:aacDecInfo->nChans=%d aacDecInfo->sampRate=%d\n",aacDecInfo->nChans,aacDecInfo->sampRate);
+ /* check for valid number of channels */
+ if (aacDecInfo->nChans > AAC_MAX_NCHANS || aacDecInfo->nChans <= 0) {
+ printk("AAC ERR: ERR_AAC_NCHANS_TOO_HIGH\n");
+ return ERR_AAC_NCHANS_TOO_HIGH;
+ }
+
+ /* will be set later if active in this frame */
+ aacDecInfo->tnsUsed = 0;
+ aacDecInfo->pnsUsed = 0;
+
+ bitOffset = 0;
+ baseChan = 0;
+ baseChanSBR = 0;
+ do {
+ /* parse next syntactic element */
+ err = DecodeNextElement(aacDecInfo, &inptr, &bitOffset, &bitsAvail);
+ if (err) {
+ return err;
+ }
+
+ elementChans = elementNumChans[aacDecInfo->currBlockID];
+ if (baseChan + elementChans > AAC_MAX_NCHANS) {
+ return ERR_AAC_NCHANS_TOO_HIGH;
+ }
+
+ /* noiseless decoder and dequantizer */
+ for (ch = 0; ch < elementChans; ch++) {
+ err = DecodeNoiselessData(aacDecInfo, &inptr, &bitOffset, &bitsAvail, ch);
+ if (err) {
+ return err;
+ }
+
+ if (Dequantize(aacDecInfo, ch)) {
+ return ERR_AAC_DEQUANT;
+ }
+ }
+
+ /* mid-side and intensity stereo */
+ if (aacDecInfo->currBlockID == AAC_ID_CPE) {
+ if (StereoProcess(aacDecInfo)) {
+ return ERR_AAC_STEREO_PROCESS;
+ }
+ }
+
+ /* PNS, TNS, inverse transform */
+ for (ch = 0; ch < elementChans; ch++) {
+ if (PNS(aacDecInfo, ch)) {
+ return ERR_AAC_PNS;
+ }
+
+ if (aacDecInfo->sbDeinterleaveReqd[ch]) {
+ /* deinterleave short blocks, if required */
+ if (DeinterleaveShortBlocks(aacDecInfo, ch)) {
+ return ERR_AAC_SHORT_BLOCK_DEINT;
+ }
+ aacDecInfo->sbDeinterleaveReqd[ch] = 0;
+ }
+
+ if (TNSFilter(aacDecInfo, ch)) {
+ return ERR_AAC_TNS;
+ }
+
+ if (IMDCT(aacDecInfo, ch, baseChan + ch, outbuf)) {
+ return ERR_AAC_IMDCT;
+ }
+ }
+
+#ifdef AAC_ENABLE_SBR
+ if (aacDecInfo->sbrEnabled && (aacDecInfo->currBlockID == AAC_ID_FIL || aacDecInfo->currBlockID == AAC_ID_LFE)) {
+ if (aacDecInfo->currBlockID == AAC_ID_LFE) {
+ elementChansSBR = elementNumChans[AAC_ID_LFE];
+ } else if (aacDecInfo->currBlockID == AAC_ID_FIL && (aacDecInfo->prevBlockID == AAC_ID_SCE || aacDecInfo->prevBlockID == AAC_ID_CPE)) {
+ elementChansSBR = elementNumChans[aacDecInfo->prevBlockID];
+ } else {
+ elementChansSBR = 0;
+ }
+
+ if (baseChanSBR + elementChansSBR > AAC_MAX_NCHANS) {
+ return ERR_AAC_SBR_NCHANS_TOO_HIGH;
+ }
+
+ /* parse SBR extension data if present (contained in a fill element) */
+ if (DecodeSBRBitstream(aacDecInfo, baseChanSBR)) {
+ return ERR_AAC_SBR_BITSTREAM;
+ }
+
+ /* apply SBR */
+ if (DecodeSBRData(aacDecInfo, baseChanSBR, outbuf)) {
+ return ERR_AAC_SBR_DATA;
+ }
+
+ baseChanSBR += elementChansSBR;
+ }
+#endif
+
+ baseChan += elementChans;
+ } while (aacDecInfo->currBlockID != AAC_ID_END);
+
+ /* byte align after each raw_data_block */
+ if (bitOffset) {
+ inptr++;
+ bitsAvail -= (8 - bitOffset);
+ bitOffset = 0;
+ if (bitsAvail < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+
+ /* update pointers */
+ if (AACDataSource == 1) {
+ aacDecInfo->frameCount++;
+ aacDecInfo->byteParsed += inptr - *inbuf;
+ //printk(" decode one frame cost byte %d \n",inptr - *inbuf);
+ aacDecInfo->sampleDecoded += AAC_MAX_NSAMPS * (aacDecInfo->sbrEnabled ? 2 : 1);
+ *bytesLeft -= (inptr - *inbuf);
+ *inbuf = inptr;
+ } else {
+ aacDecInfo->frameCount++;
+ aacDecInfo->byteParsed = CalcBitsUsed(0, 0, 0) >> 3;
+ aacDecInfo->sampleDecoded += AAC_MAX_NSAMPS * (aacDecInfo->sbrEnabled ? 2 : 1);
+ *bytesLeft -= (CalcBitsUsed(0, 0, 0) >> 3);
+ // *inbuf = *inbuf+;
+ }
+
+
+
+ return ERR_AAC_NONE;
+}
+
diff --git a/audio_codec/wfd_aac_decoder/aacdec.h b/audio_codec/wfd_aac_decoder/aacdec.h
new file mode 100644
index 0000000..6d22a9e
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/aacdec.h
@@ -0,0 +1,206 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aacdec.h,v 1.8 2005/11/10 00:15:08 margotm Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * aacdec.h - public C API for AAC decoder
+ **************************************************************************************/
+
+#ifndef _AACDEC_H
+#define _AACDEC_H
+
+#define _ARC32
+
+#if defined(_WIN32) && !defined(_WIN32_WCE)
+#
+#elif defined(_WIN32) && defined(_WIN32_WCE) && defined(ARM)
+#
+#elif defined(_WIN32) && defined(WINCE_EMULATOR)
+#
+#elif defined (__arm) && defined (__ARMCC_VERSION)
+#
+#elif defined(_SYMBIAN) && defined(__WINS__)
+#
+#elif defined(__GNUC__) && defined(__arm__)
+#
+#elif defined(__GNUC__) && defined(__i386__)
+#
+#elif defined(__GNUC__) && defined(__amd64__)
+#
+#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__))
+#
+#elif defined(_OPENWAVE_SIMULATOR) || defined(_OPENWAVE_ARMULATOR)
+#
+#elif defined(_SOLARIS) && !defined(__GNUC__)
+#
+#elif defined(_ARC32)
+#define __inline _Inline
+#else
+#error No platform defined. See valid options in aacdec.h
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* according to spec (13818-7 section 8.2.2, 14496-3 section 4.5.3)
+ * max size of input buffer =
+ * 6144 bits = 768 bytes per SCE or CCE-I
+ * 12288 bits = 1536 bytes per CPE
+ * 0 bits = 0 bytes per CCE-D (uses bits from the SCE/CPE/CCE-I it is coupled to)
+ */
+#ifndef AAC_MAX_NCHANS /* if max channels isn't set in makefile, */
+#define AAC_MAX_NCHANS 6 /* set to default max number of channels */
+#endif
+#define AAC_MAX_NSAMPS 1024
+#define AAC_MAINBUF_SIZE (768 * AAC_MAX_NCHANS)
+
+#define AAC_NUM_PROFILES 3
+#define AAC_PROFILE_MP 0
+#define AAC_PROFILE_LC 1
+#define AAC_PROFILE_SSR 2
+
+#define AAC_INPUTBUF_SIZE (2 * 768 * 4) /* pick something big enough to hold a bunch of frames */
+
+ /* define these to enable decoder features */
+#ifndef __ARC600__
+#define HELIX_FEATURE_AUDIO_CODEC_AAC_SBR
+#endif /* __ARC600__ */
+#if defined(HELIX_FEATURE_AUDIO_CODEC_AAC_SBR)
+#define AAC_ENABLE_SBR
+#endif // HELIX_FEATURE_AUDIO_CODEC_AAC_SBR.
+#define AAC_ENABLE_MPEG4
+
+#ifdef AAC_ENABLE_SBR
+#define SBR_MUL 2
+#else
+#define SBR_MUL 1
+#endif
+
+ enum {
+ ERR_AAC_NONE = 0,
+ ERR_AAC_INDATA_UNDERFLOW = -1,
+ ERR_AAC_NULL_POINTER = -2,
+ ERR_AAC_INVALID_ADTS_HEADER = -3,
+ ERR_AAC_INVALID_ADIF_HEADER = -4,
+ ERR_AAC_INVALID_FRAME = -5,
+ ERR_AAC_MPEG4_UNSUPPORTED = -6,
+ ERR_AAC_CHANNEL_MAP = -7,
+ ERR_AAC_SYNTAX_ELEMENT = -8,
+
+ ERR_AAC_DEQUANT = -9,
+ ERR_AAC_STEREO_PROCESS = -10,
+ ERR_AAC_PNS = -11,
+ ERR_AAC_SHORT_BLOCK_DEINT = -12,
+ ERR_AAC_TNS = -13,
+ ERR_AAC_IMDCT = -14,
+ ERR_AAC_NCHANS_TOO_HIGH = -15,
+
+ ERR_AAC_SBR_INIT = -16,
+ ERR_AAC_SBR_BITSTREAM = -17,
+ ERR_AAC_SBR_DATA = -18,
+ ERR_AAC_SBR_PCM_FORMAT = -19,
+ ERR_AAC_SBR_NCHANS_TOO_HIGH = -20,
+ ERR_AAC_SBR_SINGLERATE_UNSUPPORTED = -21,
+
+ ERR_AAC_RAWBLOCK_PARAMS = -22,
+ ERR_AAC_COFF_EXCEED_RANGE = -23,
+ ERR_AAC_HUFFMAN_DECODING = -24,
+ ERR_AAC_SPEC_NOT_MATCH = -25,
+ ERR_AAC_INVALID_ADTS_SYNCWORD = -26,
+ ERR_AAC_SSR_GAIN_NOT_ADDED = -27,
+ ERR_AAC_EXIT_DECODE = -28,
+
+ ERR_UNKNOWN = -9999
+ };
+
+ typedef struct _AACIOBuf {
+ int bytesLeft;
+ unsigned char *readPtr;
+ unsigned char readBuf[AAC_INPUTBUF_SIZE];
+ short outBuf[AAC_MAX_NCHANS * AAC_MAX_NSAMPS * SBR_MUL];
+ } AACIOBuf;
+
+ typedef struct _AACFrameInfo { // should keep same as _audio_codec_config_aacdec_t in audio_codec_aac.h
+ int bitRate;
+ int nChans;
+ int sampRateCore;
+ int sampRateOut;
+ int bitsPerSample;
+ int outputSamps;
+ int profile;
+ int tnsUsed;
+ int pnsUsed;
+ int format;
+ unsigned total_byte_parsed;
+ unsigned total_sample_decoded;
+ unsigned audio_send_by_frame;
+ //#ifndef PRE_APOLLO
+ unsigned char *extra_data;
+ unsigned extradata_len;
+ //#endif
+ } AACFrameInfo;
+
+ typedef void *HAACDecoder;
+ typedef void *HAACIOBuf;
+
+ /* public C API */
+ HAACDecoder AACInitDecoder();
+ void AACFreeDecoder(HAACDecoder hAACDecoder);
+ int AACDecode(HAACDecoder hAACDecoder, unsigned char **inbuf, int *bytesLeft, short *outbuf);
+
+ int AACFindSyncWord(unsigned char *buf, int nBytes);
+ void AACGetLastFrameInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo);
+ void AACGetDecoderInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo);
+ int AACSetRawBlockParams(HAACDecoder hAACDecoder, int copyLast, AACFrameInfo *aacFrameInfo);
+ int AACFlushCodec(HAACDecoder hAACDecoder);
+
+#ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT
+ int AACInitTrigtabsFloat(void);
+ void AACFreeTrigtabsFloat(void);
+#endif
+
+ extern int AACDataSource;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _AACDEC_H */
diff --git a/audio_codec/wfd_aac_decoder/aactabs.c b/audio_codec/wfd_aac_decoder/aactabs.c
new file mode 100644
index 0000000..3cade7d
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/aactabs.c
@@ -0,0 +1,157 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: aactabs.c,v 1.1 2005/02/26 01:47:31 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * aactabs.c - platform-independent tables for AAC decoder (global, read-only)
+ **************************************************************************************/
+
+#include "aaccommon.h"
+
+/* sample rates (table 4.5.1) */
+const int sampRateTab[NUM_SAMPLE_RATES] = {
+ 96000, 88200, 64000, 48000, 44100, 32000,
+ 24000, 22050, 16000, 12000, 11025, 8000
+};
+
+/* max scalefactor band for prediction (main profile only) */
+const int predSFBMax[NUM_SAMPLE_RATES] = {
+ 33, 33, 38, 40, 40, 40, 41, 41, 37, 37, 37, 34
+};
+
+/* channel mapping (table 1.6.3.4) (-1 = unknown, so need to determine mapping based on rules in 8.5.1) */
+const int channelMapTab[NUM_DEF_CHAN_MAPS] = {
+ -1, 1, 2, 3, 4, 5, 6, 8
+};
+
+/* number of channels in each element (SCE, CPE, etc.)
+ * see AACElementID in aaccommon.h
+ */
+const int elementNumChans[NUM_ELEMENTS] = {
+ 1, 2, 0, 1, 0, 0, 0, 0
+};
+
+/* total number of scale factor bands in one window */
+const unsigned char sfBandTotalShort[NUM_SAMPLE_RATES] = {
+ 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15
+};
+
+const unsigned char sfBandTotalLong[NUM_SAMPLE_RATES] = {
+ 41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40
+};
+
+/* scale factor band tables */
+const int sfBandTabShortOffset[NUM_SAMPLE_RATES] = {0, 0, 0, 13, 13, 13, 28, 28, 44, 44, 44, 60};
+
+const short sfBandTabShort[76] = {
+ /* short block 64, 88, 96 kHz [13] (tables 4.5.24, 4.5.26) */
+ 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128,
+
+ /* short block 32, 44, 48 kHz [15] (table 4.5.15) */
+ 0, 4, 8, 12, 16, 20, 28, 36, 44, 56, 68, 80, 96, 112, 128,
+
+ /* short block 22, 24 kHz [16] (table 4.5.22) */
+ 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 64, 76, 92, 108, 128,
+
+ /* short block 11, 12, 16 kHz [16] (table 4.5.20) */
+ 0, 4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 60, 72, 88, 108, 128,
+
+ /* short block 8 kHz [16] (table 4.5.18) */
+ 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 128
+};
+
+const int sfBandTabLongOffset[NUM_SAMPLE_RATES] = {0, 0, 42, 90, 90, 140, 192, 192, 240, 240, 240, 284};
+
+const short sfBandTabLong[325] = {
+ /* long block 88, 96 kHz [42] (table 4.5.25) */
+ 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,
+
+ /* long block 64 kHz [48] (table 4.5.13) */
+ 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,
+
+ /* long block 44, 48 kHz [50] (table 4.5.14) */
+ 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,
+
+ /* long block 32 kHz [52] (table 4.5.16) */
+ 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,
+
+ /* long block 22, 24 kHz [48] (table 4.5.21) */
+ 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,
+
+ /* long block 11, 12, 16 kHz [44] (table 4.5.19) */
+ 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,
+
+ /* long block 8 kHz [41] (table 4.5.17) */
+ 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
+};
+
+
+/* TNS max bands (table 4.139) and max order (table 4.138) */
+const int tnsMaxBandsShortOffset[AAC_NUM_PROFILES] = {0, 0, 12};
+
+const unsigned char tnsMaxBandsShort[2 * NUM_SAMPLE_RATES] = {
+ 9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, /* short block, Main/LC */
+ 7, 7, 7, 6, 6, 6, 7, 7, 8, 8, 8, 7 /* short block, SSR */
+};
+
+const unsigned char tnsMaxOrderShort[AAC_NUM_PROFILES] = {7, 7, 7};
+
+const int tnsMaxBandsLongOffset[AAC_NUM_PROFILES] = {0, 0, 12};
+
+const unsigned char tnsMaxBandsLong[2 * NUM_SAMPLE_RATES] = {
+ 31, 31, 34, 40, 42, 51, 46, 46, 42, 42, 42, 39, /* long block, Main/LC */
+ 28, 28, 27, 26, 26, 26, 29, 29, 23, 23, 23, 19, /* long block, SSR */
+};
+
+const unsigned char tnsMaxOrderLong[AAC_NUM_PROFILES] = {20, 12, 12};
diff --git a/audio_codec/wfd_aac_decoder/assembly.h b/audio_codec/wfd_aac_decoder/assembly.h
new file mode 100644
index 0000000..43be7fc
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/assembly.h
@@ -0,0 +1,640 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: assembly.h,v 1.9 2007/02/28 07:10:21 gahluwalia Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * assembly.h - inline assembly language functions and prototypes
+ *
+ * MULSHIFT32(x, y) signed multiply of two 32-bit integers (x and y),
+ * returns top 32-bits of 64-bit result
+ * CLIPTOSHORT(x) convert 32-bit integer to 16-bit short,
+ * clipping to [-32768, 32767]
+ * FASTABS(x) branchless absolute value of signed integer x
+ * CLZ(x) count leading zeros on signed integer x
+ * MADD64(sum64, x, y) 64-bit multiply accumulate: sum64 += (x*y)
+ **************************************************************************************/
+
+#ifndef _ASSEMBLY_H
+#define _ASSEMBLY_H
+
+/* toolchain: MSFT Visual C++
+ * target architecture: x86
+ */
+#if 0//(defined (_WIN32) && !defined (_WIN32_WCE)) || (defined (__WINS__) && defined (_SYMBIAN)) || (defined (WINCE_EMULATOR)) || (defined (_OPENWAVE_SIMULATOR))
+
+#pragma warning( disable : 4035 ) /* complains about inline asm not returning a value */
+
+static __inline int MULSHIFT32(int x, int y)
+{
+ __asm {
+ mov eax, x
+ imul y
+ mov eax, edx
+ }
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+}
+
+#ifdef __CW32__
+typedef long long Word64;
+#else
+typedef __int64 Word64;
+#endif
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* x86 = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+/* returns 64-bit value in [edx:eax] */
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+#if (defined (_SYMBIAN_61_) || defined (_SYMBIAN_70_)) && defined (__WINS__) && !defined (__CW32__)
+ /* Workaround for the Symbian emulator because of non existing longlong.lib and
+ * hence __allmul not defined. */
+ __asm {
+ mov eax, x
+ imul y
+ add dword ptr sum64, eax
+ adc dword ptr sum64 + 4, edx
+ }
+#else
+ sum64 += (Word64)x * (Word64)y;
+#endif
+
+ return sum64;
+}
+
+/* toolchain: MSFT Embedded Visual C++
+ * target architecture: ARM v.4 and above (require 'M' type processor for 32x32->64 multiplier)
+ */
+#elif 1//defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)
+
+static short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search (function should be 17 ARM instructions total) */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+}
+
+/* implemented in asmfunc.s */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef long long Word64;
+
+ typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* ARM WinCE = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+ } U64;
+
+ /* manual name mangling for just this platform (must match labels in .s file) */
+//#define MULSHIFT32 raac_MULSHIFT32
+//#define MADD64 raac_MADD64
+static int MULSHIFT32(int x, int y)
+{
+ long c;
+ c = (long long)x * y;
+ return (int)c;
+}
+
+static Word64 MADD64(Word64 sum64, int x, int y)
+{
+ sum64 += (long long)x * y;
+ return sum64;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+/* toolchain: ARM ADS or RealView
+ * target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier)
+ */
+#elif (defined (__arm) && defined (__ARMCC_VERSION)) || (defined(HELIX_CONFIG_SYMBIAN_GENERATE_MMP) && !defined(__GCCE__))
+
+static __inline int MULSHIFT32(int x, int y)
+{
+ /* rules for smull RdLo, RdHi, Rm, Rs:
+ * RdHi != Rm
+ * RdLo != Rm
+ * RdHi != RdLo
+ */
+ int zlow;
+ __asm {
+ smull zlow, y, x, y
+ }
+
+ return y;
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search (function should be 17 ARM instructions total) */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+
+ /* ARM code would look like this, but do NOT use inline asm in ADS for this,
+ because you can't safely use the status register flags intermixed with C code
+
+ __asm {
+ mov numZeros, #1
+ tst x, 0xffff0000
+ addeq numZeros, numZeros, #16
+ moveq x, x, lsl #16
+ tst x, 0xff000000
+ addeq numZeros, numZeros, #8
+ moveq x, x, lsl #8
+ tst x, 0xf0000000
+ addeq numZeros, numZeros, #4
+ moveq x, x, lsl #4
+ tst x, 0xc0000000
+ addeq numZeros, numZeros, #2
+ moveq x, x, lsl #2
+ sub numZeros, numZeros, x, lsr #31
+ }
+ */
+ /* reference:
+ numZeros = 0;
+ while (!(x & 0x80000000)) {
+ numZeros++;
+ x <<= 1;
+ }
+ */
+}
+
+typedef __int64 Word64;
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* ARM ADS = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+ U64 u;
+ u.w64 = sum64;
+
+ __asm {
+ smlal u.r.lo32, u.r.hi32, x, y
+ }
+
+ return u.w64;
+}
+
+/* toolchain: ARM gcc
+ * target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier)
+ */
+#elif defined(__GNUC__) && defined(__arm__)
+
+static __inline__ int MULSHIFT32(int x, int y)
+{
+ int zlow;
+ __asm__ volatile("smull %0,%1,%2,%3" : "=&r"(zlow), "=r"(y) : "r"(x), "1"(y) : "cc");
+ return y;
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return (sizeof(int) * 8);
+ }
+
+ numZeros = 0;
+ while (!(x & 0x80000000)) {
+ numZeros++;
+ x <<= 1;
+ }
+
+ return numZeros;
+}
+
+typedef long long Word64;
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* ARM ADS = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+ U64 u;
+ u.w64 = sum64;
+
+ __asm__ volatile("smlal %0,%1,%2,%3" : "+&r"(u.r.lo32), "+&r"(u.r.hi32) : "r"(x), "r"(y) : "cc");
+
+ return u.w64;
+}
+
+/* toolchain: x86 gcc
+ * target architecture: x86
+ */
+#elif defined(__GNUC__) && (defined(__i386__) || defined(__amd64__)) || (defined (_SOLARIS) && !defined (__GNUC__) && defined(_SOLARISX86))
+
+typedef long long Word64;
+
+static __inline__ int MULSHIFT32(int x, int y)
+{
+ int z;
+
+ z = (Word64)x * (Word64)y >> 32;
+
+ return z;
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search (function should be 17 ARM instructions total) */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+}
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* x86 = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+ sum64 += (Word64)x * (Word64)y;
+
+ return sum64;
+}
+
+#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__)) || (defined (_SOLARIS) && !defined (__GNUC__) && !defined (_SOLARISX86))
+
+typedef long long Word64;
+
+static __inline__ int MULSHIFT32(int x, int y)
+{
+ int z;
+
+ z = (Word64)x * (Word64)y >> 32;
+
+ return z;
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search (function should be 17 ARM instructions total) */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+}
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* PowerPC = big endian */
+ signed int hi32;
+ unsigned int lo32;
+ } r;
+} U64;
+
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+ sum64 += (Word64)x * (Word64)y;
+
+ return sum64;
+}
+
+#else
+
+#error Unsupported platform in assembly.h
+
+#endif /* platforms */
+
+#endif /* _ASSEMBLY_H */
diff --git a/audio_codec/wfd_aac_decoder/assembly_mw.h b/audio_codec/wfd_aac_decoder/assembly_mw.h
new file mode 100644
index 0000000..335f4b0
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/assembly_mw.h
@@ -0,0 +1,743 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: assembly.h,v 1.7 2005/11/10 00:04:40 margotm Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * assembly.h - inline assembly language functions and prototypes
+ *
+ * MULSHIFT32(x, y) signed multiply of two 32-bit integers (x and y),
+ * returns top 32-bits of 64-bit result
+ * CLIPTOSHORT(x) convert 32-bit integer to 16-bit short,
+ * clipping to [-32768, 32767]
+ * FASTABS(x) branchless absolute value of signed integer x
+ * CLZ(x) count leading zeros on signed integer x
+ * MADD64(sum64, x, y) 64-bit multiply accumulate: sum64 += (x*y)
+ **************************************************************************************/
+
+#ifndef _ASSEMBLY_H
+#define _ASSEMBLY_H
+
+//#define _Inline inline
+#define _ARC32
+/* toolchain: MSFT Visual C++
+ * target architecture: x86
+ */
+#if (defined (_WIN32) && !defined (_WIN32_WCE)) || (defined (__WINS__) && defined (_SYMBIAN)) || (defined (WINCE_EMULATOR)) || (defined (_OPENWAVE_SIMULATOR))
+
+#pragma warning( disable : 4035 ) /* complains about inline asm not returning a value */
+
+static __inline int MULSHIFT32(int x, int y)
+{
+ __asm {
+ mov eax, x
+ imul y
+ mov eax, edx
+ }
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+}
+
+#ifdef __CW32__
+typedef long long Word64;
+#else
+typedef __int64 Word64;
+#endif
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* x86 = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+/* returns 64-bit value in [edx:eax] */
+static __inline Word64 madd64(Word64 sum64, int x, int y)
+{
+#if (defined (_SYMBIAN_61_) || defined (_SYMBIAN_70_)) && defined (__WINS__) && !defined (__CW32__)
+ /* Workaround for the Symbian emulator because of non existing longlong.lib and
+ * hence __allmul not defined. */
+ __asm {
+ mov eax, x
+ imul y
+ add dword ptr sum64, eax
+ adc dword ptr sum64 + 4, edx
+ }
+#else
+ sum64 += (Word64)x * (Word64)y;
+
+ /* equivalent to return (sum + ((__int64)x * y)); */
+#endif
+}
+
+#define SET_ZERO(x) x=0
+#define MADD64(sum64, x, y) sum64=madd64(sum64, x, y)
+#define ADD64(x64, y64) x64 += y64;
+
+/* toolchain: MSFT Embedded Visual C++
+ * target architecture: ARM v.4 and above (require 'M' type processor for 32x32->64 multiplier)
+ */
+#elif defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search (function should be 17 ARM instructions total) */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+}
+
+/* implemented in asmfunc.s */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef __int64 Word64;
+
+ typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* ARM WinCE = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+ } U64;
+
+ /* manual name mangling for just this platform (must match labels in .s file) */
+#define MULSHIFT32 raac_MULSHIFT32
+#define MADD64 raac_MADD64
+
+ int MULSHIFT32(int x, int y);
+ Word64 MADD64(Word64 sum64, int x, int y);
+
+#ifdef __cplusplus
+}
+#endif
+
+/* toolchain: ARM ADS or RealView
+ * target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier)
+ */
+#elif (defined (__arm) && defined (__ARMCC_VERSION)) || (defined(HELIX_CONFIG_SYMBIAN_GENERATE_MMP) && !defined(__GCCE__))
+
+static __inline int MULSHIFT32(int x, int y)
+{
+ /* rules for smull RdLo, RdHi, Rm, Rs:
+ * RdHi != Rm
+ * RdLo != Rm
+ * RdHi != RdLo
+ */
+ int zlow;
+ __asm {
+ smull zlow, y, x, y
+ }
+
+ return y;
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search (function should be 17 ARM instructions total) */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+
+ /* ARM code would look like this, but do NOT use inline asm in ADS for this,
+ because you can't safely use the status register flags intermixed with C code
+
+ __asm {
+ mov numZeros, #1
+ tst x, 0xffff0000
+ addeq numZeros, numZeros, #16
+ moveq x, x, lsl #16
+ tst x, 0xff000000
+ addeq numZeros, numZeros, #8
+ moveq x, x, lsl #8
+ tst x, 0xf0000000
+ addeq numZeros, numZeros, #4
+ moveq x, x, lsl #4
+ tst x, 0xc0000000
+ addeq numZeros, numZeros, #2
+ moveq x, x, lsl #2
+ sub numZeros, numZeros, x, lsr #31
+ }
+ */
+ /* reference:
+ numZeros = 0;
+ while (!(x & 0x80000000)) {
+ numZeros++;
+ x <<= 1;
+ }
+ */
+}
+
+typedef __int64 Word64;
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* ARM ADS = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+ U64 u;
+ u.w64 = sum64;
+
+ __asm {
+ smlal u.r.lo32, u.r.hi32, x, y
+ }
+
+ return u.w64;
+}
+
+/* toolchain: ARM gcc
+ * target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier)
+ */
+#elif defined(__GNUC__) && defined(__arm__)
+
+static __inline__ int MULSHIFT32(int x, int y)
+{
+ int zlow;
+ __asm__ volatile("smull %0,%1,%2,%3" : "=&r"(zlow), "=r"(y) : "r"(x), "1"(y) : "cc");
+ return y;
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return (sizeof(int) * 8);
+ }
+
+ numZeros = 0;
+ while (!(x & 0x80000000)) {
+ numZeros++;
+ x <<= 1;
+ }
+
+ return numZeros;
+}
+
+typedef long long Word64;
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* ARM ADS = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+ U64 u;
+ u.w64 = sum64;
+
+ __asm__ volatile("smlal %0,%1,%2,%3" : "+&r"(u.r.lo32), "+&r"(u.r.hi32) : "r"(x), "r"(y) : "cc");
+
+ return u.w64;
+}
+
+/* toolchain: x86 gcc
+ * target architecture: x86
+ */
+#elif defined(__GNUC__) && (defined(__i386__) || defined(__amd64__)) || (defined (_SOLARIS) && !defined (__GNUC__) && defined(_SOLARISX86))
+
+typedef long long Word64;
+
+static __inline__ int MULSHIFT32(int x, int y)
+{
+ int z;
+
+ z = (Word64)x * (Word64)y >> 32;
+
+ return z;
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search (function should be 17 ARM instructions total) */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+}
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* x86 = little endian */
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+ sum64 += (Word64)x * (Word64)y;
+
+ return sum64;
+}
+
+#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__)) || (defined (_SOLARIS) && !defined (__GNUC__) && !defined (_SOLARISX86))
+
+typedef long long Word64;
+
+static __inline__ int MULSHIFT32(int x, int y)
+{
+ int z;
+
+ z = (Word64)x * (Word64)y >> 32;
+
+ return z;
+}
+
+static __inline short CLIPTOSHORT(int x)
+{
+ int sign;
+
+ /* clip to [-32768, 32767] */
+ sign = x >> 31;
+ if (sign != (x >> 15)) {
+ x = sign ^((1 << 15) - 1);
+ }
+
+ return (short)x;
+}
+
+static __inline int FASTABS(int x)
+{
+ int sign;
+
+ sign = x >> (sizeof(int) * 8 - 1);
+ x ^= sign;
+ x -= sign;
+
+ return x;
+}
+
+static __inline int CLZ(int x)
+{
+ int numZeros;
+
+ if (!x) {
+ return 32;
+ }
+
+ /* count leading zeros with binary search (function should be 17 ARM instructions total) */
+ numZeros = 1;
+ if (!((unsigned int)x >> 16)) {
+ numZeros += 16;
+ x <<= 16;
+ }
+ if (!((unsigned int)x >> 24)) {
+ numZeros += 8;
+ x <<= 8;
+ }
+ if (!((unsigned int)x >> 28)) {
+ numZeros += 4;
+ x <<= 4;
+ }
+ if (!((unsigned int)x >> 30)) {
+ numZeros += 2;
+ x <<= 2;
+ }
+
+ numZeros -= ((unsigned int)x >> 31);
+
+ return numZeros;
+}
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ /* PowerPC = big endian */
+ signed int hi32;
+ unsigned int lo32;
+ } r;
+} U64;
+
+static __inline Word64 MADD64(Word64 sum64, int x, int y)
+{
+ sum64 += (Word64)x * (Word64)y;
+
+ return sum64;
+}
+
+#elif defined(_ARC32)
+
+_Asm _Inline int MULSHIFT32(int x, int y)
+{
+ % reg x, y
+ mullw 0, x, y
+ machlw % r0, x, y
+ % error
+}
+
+_Asm _Inline short CLIPTOSHORT(int x)
+{
+ % reg x
+ min % r0, x, 0x7fff
+ max % r0, % r0, -0x8000
+ % error
+}
+
+_Asm _Inline int FASTABS(int x)
+{
+ % reg x
+ abs % r0, x
+ % error
+}
+
+_Asm _Inline int CLZ(int x)
+{
+ /* assume x>0, if x<0 should return 0 */
+ % reg x;
+ norm % r0, x
+ add % r0, % r0, 1
+ % error
+}
+#endif
+typedef struct {
+ unsigned int lo32;
+ signed int hi32;
+} Word64;
+
+typedef union _U64 {
+ Word64 w64;
+ struct {
+ unsigned int lo32;
+ signed int hi32;
+ } r;
+} U64;
+
+_Asm _Inline unsigned add64_lo(unsigned int xlo, unsigned int ylo)
+{
+ % reg xlo, ylo;
+ add.f % r0, xlo, ylo
+ % error
+}
+
+_Asm _Inline int add64_hi(unsigned int xhi, unsigned int yhi)
+{
+ % reg xhi, yhi;
+ adc % r0, xhi, yhi
+ % error
+}
+
+_Asm _Inline unsigned madd64_lo(unsigned lo, int a, int b)
+{
+ % reg lo, a, b;
+ mpy % r0, a, b
+ add.f % r0, lo, % r0
+ % error
+}
+
+
+_Asm _Inline int madd64_hi(int hi, int a, int b)
+{
+ % reg hi, a, b;
+ mpyh % r0, a, b
+ adc % r0, hi, % r0
+ % error
+}
+
+
+
+_Asm _Inline void madd64(int a, int b)
+{
+ % reg a, b;
+ mulhlw 0, a, b
+ maclw 0, a, b
+ % error
+}
+
+_Asm _Inline int madd64hi(int hi)
+{
+ % reg hi
+ //mov %r0, %acc2
+ adc % r0, hi, % acc1
+ % error
+}
+
+_Asm _Inline int madd64lo(int lo)
+{
+ % reg lo
+ //mov %r0, %acc1
+ add.f % r0, lo, % acc2
+ % error
+}
+
+
+
+#define SET_ZERO(x) x.lo32 = x.hi32 = 0
+
+#define MADD64(w64, a, b) madd64(a, b); w64.lo32 = madd64lo(w64.lo32); w64.hi32 = madd64hi(w64.hi32);
+
+#define ADD64(x64, y64) x64.lo32 = add64_lo(x64.lo32,y64.lo32); x64.hi32 = add64_hi(x64.hi32,y64.hi32);
+
+#endif /* _ASSEMBLY_H */
diff --git a/audio_codec/wfd_aac_decoder/bitstream.c b/audio_codec/wfd_aac_decoder/bitstream.c
new file mode 100644
index 0000000..d92b2c8
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/bitstream.c
@@ -0,0 +1,261 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: bitstream.c,v 1.1.2.1.6.1 2005/10/19 00:18:49 gwright Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * bitstream.c - bitstream parsing functions
+ **************************************************************************************/
+
+#include "bitstream.h"
+
+/**************************************************************************************
+ * Function: SetBitstreamPointer
+ *
+ * Description: initialize bitstream reader
+ *
+ * Inputs: pointer to BitStreamInfo struct
+ * number of bytes in bitstream
+ * pointer to byte-aligned buffer of data to read from
+ *
+ * Outputs: initialized bitstream info struct
+ *
+ * Return: none
+ **************************************************************************************/
+void SetBitstreamPointer(BitStreamInfo *bsi, int nBytes, unsigned char *buf)
+{
+ /* init bitstream */
+ bsi->bytePtr = buf;
+ bsi->iCache = 0; /* 4-byte unsigned int */
+ bsi->cachedBits = 0; /* i.e. zero bits in cache */
+ bsi->nBytes = nBytes;
+}
+
+/**************************************************************************************
+ * Function: RefillBitstreamCache
+ *
+ * Description: read new data from bitstream buffer into 32-bit cache
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ *
+ * Outputs: updated bitstream info struct
+ *
+ * Return: none
+ *
+ * Notes: only call when iCache is completely drained (resets bitOffset to 0)
+ * always loads 4 new bytes except when bsi->nBytes < 4 (end of buffer)
+ * stores data as big-endian in cache, regardless of machine endian-ness
+ **************************************************************************************/
+static void RefillBitstreamCache(BitStreamInfo *bsi)
+{
+ int nBytes = bsi->nBytes;
+
+ /* optimize for common case, independent of machine endian-ness */
+ if (nBytes >= 4) {
+ bsi->iCache = (*bsi->bytePtr++) << 24;
+ bsi->iCache |= (*bsi->bytePtr++) << 16;
+ bsi->iCache |= (*bsi->bytePtr++) << 8;
+ bsi->iCache |= (*bsi->bytePtr++);
+ bsi->cachedBits = 32;
+ bsi->nBytes -= 4;
+ } else {
+ bsi->iCache = 0;
+ while (nBytes--) {
+ bsi->iCache |= (*bsi->bytePtr++);
+ bsi->iCache <<= 8;
+ }
+ bsi->iCache <<= ((3 - bsi->nBytes) * 8);
+ bsi->cachedBits = 8 * bsi->nBytes;
+ bsi->nBytes = 0;
+ }
+}
+
+/**************************************************************************************
+ * Function: GetBits
+ *
+ * Description: get bits from bitstream, advance bitstream pointer
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ * number of bits to get from bitstream
+ *
+ * Outputs: updated bitstream info struct
+ *
+ * Return: the next nBits bits of data from bitstream buffer
+ *
+ * Notes: nBits must be in range [0, 31], nBits outside this range masked by 0x1f
+ * for speed, does not indicate error if you overrun bit buffer
+ * if nBits == 0, returns 0
+ **************************************************************************************/
+unsigned int GetBits(BitStreamInfo *bsi, int nBits)
+{
+ unsigned int data, lowBits;
+
+ nBits &= 0x1f; /* nBits mod 32 to avoid unpredictable results like >> by negative amount */
+ data = bsi->iCache >> (31 - nBits); /* unsigned >> so zero-extend */
+ data >>= 1; /* do as >> 31, >> 1 so that nBits = 0 works okay (returns 0) */
+ bsi->iCache <<= nBits; /* left-justify cache */
+ bsi->cachedBits -= nBits; /* how many bits have we drawn from the cache so far */
+
+ /* if we cross an int boundary, refill the cache */
+ if (bsi->cachedBits < 0) {
+ lowBits = -bsi->cachedBits;
+ RefillBitstreamCache(bsi);
+ data |= bsi->iCache >> (32 - lowBits); /* get the low-order bits */
+
+ bsi->cachedBits -= lowBits; /* how many bits have we drawn from the cache so far */
+ bsi->iCache <<= lowBits; /* left-justify cache */
+ }
+
+ return data;
+}
+
+/**************************************************************************************
+ * Function: GetBitsNoAdvance
+ *
+ * Description: get bits from bitstream, do not advance bitstream pointer
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ * number of bits to get from bitstream
+ *
+ * Outputs: none (state of BitStreamInfo struct left unchanged)
+ *
+ * Return: the next nBits bits of data from bitstream buffer
+ *
+ * Notes: nBits must be in range [0, 31], nBits outside this range masked by 0x1f
+ * for speed, does not indicate error if you overrun bit buffer
+ * if nBits == 0, returns 0
+ **************************************************************************************/
+unsigned int GetBitsNoAdvance(BitStreamInfo *bsi, int nBits)
+{
+ unsigned char *buf;
+ unsigned int data, iCache;
+ signed int lowBits;
+
+ nBits &= 0x1f; /* nBits mod 32 to avoid unpredictable results like >> by negative amount */
+ data = bsi->iCache >> (31 - nBits); /* unsigned >> so zero-extend */
+ data >>= 1; /* do as >> 31, >> 1 so that nBits = 0 works okay (returns 0) */
+ lowBits = nBits - bsi->cachedBits; /* how many bits do we have left to read */
+
+ /* if we cross an int boundary, read next bytes in buffer */
+ if (lowBits > 0) {
+ iCache = 0;
+ buf = bsi->bytePtr;
+ while (lowBits > 0) {
+ iCache <<= 8;
+ if (buf < bsi->bytePtr + bsi->nBytes) {
+ iCache |= (unsigned int) * buf++;
+ }
+ lowBits -= 8;
+ }
+ lowBits = -lowBits;
+ data |= iCache >> lowBits;
+ }
+
+ return data;
+}
+
+/**************************************************************************************
+ * Function: AdvanceBitstream
+ *
+ * Description: move bitstream pointer ahead
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ * number of bits to advance bitstream
+ *
+ * Outputs: updated bitstream info struct
+ *
+ * Return: none
+ *
+ * Notes: generally used following GetBitsNoAdvance(bsi, maxBits)
+ **************************************************************************************/
+void AdvanceBitstream(BitStreamInfo *bsi, int nBits)
+{
+ nBits &= 0x1f;
+ if (nBits > bsi->cachedBits) {
+ nBits -= bsi->cachedBits;
+ RefillBitstreamCache(bsi);
+ }
+ bsi->iCache <<= nBits;
+ bsi->cachedBits -= nBits;
+}
+
+/**************************************************************************************
+ * Function: CalcBitsUsed
+ *
+ * Description: calculate how many bits have been read from bitstream
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ * pointer to start of bitstream buffer
+ * bit offset into first byte of startBuf (0-7)
+ *
+ * Outputs: none
+ *
+ * Return: number of bits read from bitstream, as offset from startBuf:startOffset
+ **************************************************************************************/
+int CalcBitsUsed(BitStreamInfo *bsi, unsigned char *startBuf, int startOffset)
+{
+ int bitsUsed;
+
+ bitsUsed = (bsi->bytePtr - startBuf) * 8;
+ bitsUsed -= bsi->cachedBits;
+ bitsUsed -= startOffset;
+
+ return bitsUsed;
+}
+
+/**************************************************************************************
+ * Function: ByteAlignBitstream
+ *
+ * Description: bump bitstream pointer to start of next byte
+ *
+ * Inputs: pointer to initialized BitStreamInfo struct
+ *
+ * Outputs: byte-aligned bitstream BitStreamInfo struct
+ *
+ * Return: none
+ *
+ * Notes: if bitstream is already byte-aligned, do nothing
+ **************************************************************************************/
+void ByteAlignBitstream(BitStreamInfo *bsi)
+{
+ int offset;
+
+ offset = bsi->cachedBits & 0x07;
+ AdvanceBitstream(bsi, offset);
+}
diff --git a/audio_codec/wfd_aac_decoder/bitstream.h b/audio_codec/wfd_aac_decoder/bitstream.h
new file mode 100644
index 0000000..5bfc54d
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/bitstream.h
@@ -0,0 +1,74 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: bitstream.h,v 1.1.2.1 2005/02/26 02:05:12 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * bitstream.h - definitions of bitstream handling functions
+ **************************************************************************************/
+
+#ifndef _BITSTREAM_H
+#define _BITSTREAM_H
+
+#include "aaccommon.h"
+
+/* additional external symbols to name-mangle for static linking */
+#define SetBitstreamPointer STATNAME(SetBitstreamPointer)
+#define GetBits STATNAME(GetBits)
+#define GetBitsNoAdvance STATNAME(GetBitsNoAdvance)
+#define AdvanceBitstream STATNAME(AdvanceBitstream)
+#define CalcBitsUsed STATNAME(CalcBitsUsed)
+#define ByteAlignBitstream STATNAME(ByteAlignBitstream)
+
+typedef struct _BitStreamInfo {
+ unsigned char *bytePtr;
+ unsigned int iCache;
+ int cachedBits;
+ int nBytes;
+} BitStreamInfo;
+
+/* bitstream.c */
+void SetBitstreamPointer(BitStreamInfo *bsi, int nBytes, unsigned char *buf);
+unsigned int GetBits(BitStreamInfo *bsi, int nBits);
+unsigned int GetBitsNoAdvance(BitStreamInfo *bsi, int nBits);
+void AdvanceBitstream(BitStreamInfo *bsi, int nBits);
+int CalcBitsUsed(BitStreamInfo *bsi, unsigned char *startBuf, int startOffset);
+void ByteAlignBitstream(BitStreamInfo *bsi);
+
+#endif /* _BITSTREAM_H */
diff --git a/audio_codec/wfd_aac_decoder/buffers.c b/audio_codec/wfd_aac_decoder/buffers.c
new file mode 100644
index 0000000..2428213
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/buffers.c
@@ -0,0 +1,140 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: buffers.c,v 1.1.2.1 2005/02/26 02:05:12 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * buffers.c - allocation and deallocation of internal AAC decoder buffers
+ **************************************************************************************/
+
+#ifdef USE_DEFAULT_STDLIB
+#include <stdlib.h>
+#else
+#include "hlxclib/stdlib.h"
+#endif
+
+#include "coder.h"
+
+/**************************************************************************************
+ * Function: ClearBuffer
+ *
+ * Description: fill buffer with 0's
+ *
+ * Inputs: pointer to buffer
+ * number of bytes to fill with 0
+ *
+ * Outputs: cleared buffer
+ *
+ * Return: none
+ *
+ * Notes: slow, platform-independent equivalent to memset(buf, 0, nBytes)
+ **************************************************************************************/
+void ClearBuffer(void *buf, int nBytes)
+{
+ int i;
+ unsigned char *cbuf = (unsigned char *)buf;
+
+ for (i = 0; i < nBytes; i++) {
+ cbuf[i] = 0;
+ }
+
+ return;
+}
+
+/**************************************************************************************
+ * Function: AllocateBuffers
+ *
+ * Description: allocate all the memory needed for the AAC decoder
+ *
+ * Inputs: none
+ *
+ * Outputs: none
+ *
+ * Return: pointer to AACDecInfo structure, cleared to all 0's (except for
+ * pointer to platform-specific data structure)
+ *
+ * Notes: if one or more mallocs fail, function frees any buffers already
+ * allocated before returning
+ **************************************************************************************/
+AACDecInfo *AllocateBuffers(void)
+{
+ AACDecInfo *aacDecInfo;
+
+ aacDecInfo = (AACDecInfo *)malloc(sizeof(AACDecInfo));
+ if (!aacDecInfo) {
+ return 0;
+ }
+ ClearBuffer(aacDecInfo, sizeof(AACDecInfo));
+
+ aacDecInfo->psInfoBase = malloc(sizeof(PSInfoBase));
+ if (!aacDecInfo->psInfoBase) {
+ FreeBuffers(aacDecInfo);
+ return 0;
+ }
+ ClearBuffer(aacDecInfo->psInfoBase, sizeof(PSInfoBase));
+
+ return aacDecInfo;
+}
+
+#ifndef SAFE_FREE
+#define SAFE_FREE(x) {if (x) free(x); (x) = 0;} /* helper macro */
+#endif
+
+/**************************************************************************************
+ * Function: FreeBuffers
+ *
+ * Description: frees all the memory used by the AAC decoder
+ *
+ * Inputs: pointer to initialized AACDecInfo structure
+ *
+ * Outputs: none
+ *
+ * Return: none
+ *
+ * Notes: safe to call even if some buffers were not allocated (uses SAFE_FREE)
+ **************************************************************************************/
+void FreeBuffers(AACDecInfo *aacDecInfo)
+{
+ if (!aacDecInfo) {
+ return;
+ }
+
+ SAFE_FREE(aacDecInfo->psInfoBase);
+ SAFE_FREE(aacDecInfo);
+}
diff --git a/audio_codec/wfd_aac_decoder/coder.h b/audio_codec/wfd_aac_decoder/coder.h
new file mode 100644
index 0000000..d57e5d7
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/coder.h
@@ -0,0 +1,369 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: coder.h,v 1.2 2005/06/27 21:06:00 gwright Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * coder.h - definitions of platform-specific data structures, functions, and tables
+ **************************************************************************************/
+
+#ifndef _CODER_H
+#define _CODER_H
+
+#include "aaccommon.h"
+#include "bitstream.h"
+
+#if 1//ndef ASSERT
+#if 0// defined(_WIN32) && defined(_M_IX86) && (defined (_DEBUG) || defined (REL_ENABLE_ASSERTS))
+#define ASSERT(x) if (!(x)) __asm int 3;
+#else
+#define ASSERT(x,errid) do{if(!(x)) {/*printk(" aac decoder error ,errid %d\n",(errid));*/return (errid);}}while(0)/* do nothing */
+#endif
+#endif
+
+#ifndef MAX
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+#ifndef MIN
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+#define NWINDOWS_LONG 1
+#define NWINDOWS_SHORT 8
+
+#define DATA_BUF_SIZE 510 /* max count = 255 + 255 */
+#define FILL_BUF_SIZE 269 /* max count = 15 + 255 - 1*/
+#define ADIF_COPYID_SIZE 9
+#define MAX_COMMENT_BYTES 255
+
+#define MAX_NUM_FCE 15
+#define MAX_NUM_SCE 15
+#define MAX_NUM_BCE 15
+#define MAX_NUM_LCE 3
+#define MAX_NUM_ADE 7
+#define MAX_NUM_CCE 15
+
+#define CHAN_ELEM_IS_CPE(x) (((x) & 0x10) >> 4) /* bit 4 = SCE/CPE flag */
+#define CHAN_ELEM_GET_TAG(x) (((x) & 0x0f) >> 0) /* bits 3-0 = instance tag */
+
+#define CHAN_ELEM_SET_CPE(x) (((x) & 0x01) << 4) /* bit 4 = SCE/CPE flag */
+#define CHAN_ELEM_SET_TAG(x) (((x) & 0x0f) << 0) /* bits 3-0 = instance tag */
+
+#define MAX_HUFF_BITS 20
+#define HUFFTAB_SPEC_OFFSET 1
+
+/* do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) */
+#define CLIP_2N_SHIFT(y, n) { \
+ int sign = (y) >> 31; \
+ if (sign != (y) >> (30 - (n))) { \
+ (y) = sign ^ (0x3fffffff); \
+ } else { \
+ (y) = (y) << (n); \
+ } \
+ }
+
+/* clip to [-2^n, 2^n-1], valid range of n = [1, 30] */
+#define CLIP_2N(val, n) { \
+ if ((val) >> 31 != (val) >> (n)) \
+ (val) = ((val) >> 31) ^ ((1 << (n)) - 1); \
+ }
+
+#define SF_DQ_OFFSET 15
+#define FBITS_OUT_DQ 20
+#define FBITS_OUT_DQ_OFF (FBITS_OUT_DQ - SF_DQ_OFFSET) /* number of fraction bits out of dequant, including 2^15 bias */
+
+#define FBITS_IN_IMDCT FBITS_OUT_DQ_OFF /* number of fraction bits into IMDCT */
+#define GBITS_IN_DCT4 4 /* min guard bits in for DCT4 */
+
+#define FBITS_LOST_DCT4 1 /* number of fraction bits lost (>> out) in DCT-IV */
+#define FBITS_LOST_WND 1 /* number of fraction bits lost (>> out) in synthesis window (neg = gain frac bits) */
+#define FBITS_LOST_IMDCT (FBITS_LOST_DCT4 + FBITS_LOST_WND)
+#define FBITS_OUT_IMDCT (FBITS_IN_IMDCT - FBITS_LOST_IMDCT)
+
+#define NUM_IMDCT_SIZES 2
+
+/* additional external symbols to name-mangle for static linking */
+#define DecodeProgramConfigElement STATNAME(DecodeProgramConfigElement)
+#define DecodeHuffmanScalar STATNAME(DecodeHuffmanScalar)
+#define DecodeSpectrumLong STATNAME(DecodeSpectrumLong)
+#define DecodeSpectrumShort STATNAME(DecodeSpectrumShort)
+#define DecodeICSInfo STATNAME(DecodeICSInfo)
+#define DCT4 STATNAME(DCT4)
+#define R4FFT STATNAME(R4FFT)
+
+#define DecWindowOverlapNoClip STATNAME(DecWindowOverlapNoClip)
+#define DecWindowOverlapLongStartNoClip STATNAME(DecWindowOverlapLongStartNoClip)
+#define DecWindowOverlapLongStopNoClip STATNAME(DecWindowOverlapLongStopNoClip)
+#define DecWindowOverlapShortNoClip STATNAME(DecWindowOverlapShortNoClip)
+
+#define huffTabSpecInfo STATNAME(huffTabSpecInfo)
+#define huffTabSpec STATNAME(huffTabSpec)
+#define huffTabScaleFactInfo STATNAME(huffTabScaleFactInfo)
+#define huffTabScaleFact STATNAME(huffTabScaleFact)
+#define cos4sin4tab STATNAME(cos4sin4tab)
+#define cos4sin4tabOffset STATNAME(cos4sin4tabOffset)
+#define cos1sin1tab STATNAME(cos1sin1tab)
+#define sinWindow STATNAME(sinWindow)
+#define sinWindowOffset STATNAME(sinWindowOffset)
+#define kbdWindow STATNAME(kbdWindow)
+#define kbdWindowOffset STATNAME(kbdWindowOffset)
+#define bitrevtab STATNAME(bitrevtab)
+#define bitrevtabOffset STATNAME(bitrevtabOffset)
+#define uniqueIDTab STATNAME(uniqueIDTab)
+#define twidTabEven STATNAME(twidTabEven)
+#define twidTabOdd STATNAME(twidTabOdd)
+
+typedef struct _HuffInfo {
+ int maxBits; /* number of bits in longest codeword */
+ unsigned char count[MAX_HUFF_BITS]; /* count[i] = number of codes with length i+1 bits */
+ int offset; /* offset into symbol table */
+} HuffInfo;
+
+typedef struct _PulseInfo {
+ unsigned char pulseDataPresent;
+ unsigned char numPulse;
+ unsigned char startSFB;
+ unsigned char offset[MAX_PULSES];
+ unsigned char amp[MAX_PULSES];
+} PulseInfo;
+
+typedef struct _TNSInfo {
+ unsigned char tnsDataPresent;
+ unsigned char numFilt[MAX_TNS_FILTERS]; /* max 1 filter each for 8 short windows, or 3 filters for 1 long window */
+ unsigned char coefRes[MAX_TNS_FILTERS];
+ unsigned char length[MAX_TNS_FILTERS];
+ unsigned char order[MAX_TNS_FILTERS];
+ unsigned char dir[MAX_TNS_FILTERS];
+ signed char coef[MAX_TNS_COEFS]; /* max 3 filters * 20 coefs for 1 long window, or 1 filter * 7 coefs for each of 8 short windows */
+} TNSInfo;
+
+typedef struct _GainControlInfo {
+ unsigned char gainControlDataPresent;
+ unsigned char maxBand;
+ unsigned char adjNum[MAX_GAIN_BANDS][MAX_GAIN_WIN];
+ unsigned char alevCode[MAX_GAIN_BANDS][MAX_GAIN_WIN][MAX_GAIN_ADJUST];
+ unsigned char alocCode[MAX_GAIN_BANDS][MAX_GAIN_WIN][MAX_GAIN_ADJUST];
+} GainControlInfo;
+
+typedef struct _ICSInfo {
+ unsigned char icsResBit;
+ unsigned char winSequence;
+ unsigned char winShape;
+ unsigned char maxSFB;
+ unsigned char sfGroup;
+ unsigned char predictorDataPresent;
+ unsigned char predictorReset;
+ unsigned char predictorResetGroupNum;
+ unsigned char predictionUsed[MAX_PRED_SFB];
+ unsigned char numWinGroup;
+ unsigned char winGroupLen[MAX_WIN_GROUPS];
+} ICSInfo;
+
+typedef struct _ADTSHeader {
+ /* fixed */
+ unsigned char id; /* MPEG bit - should be 1 */
+ unsigned char layer; /* MPEG layer - should be 0 */
+ unsigned char protectBit; /* 0 = CRC word follows, 1 = no CRC word */
+ unsigned char profile; /* 0 = main, 1 = LC, 2 = SSR, 3 = reserved */
+ unsigned char sampRateIdx; /* sample rate index range = [0, 11] */
+ unsigned char privateBit; /* ignore */
+ unsigned char channelConfig; /* 0 = implicit, >0 = use default table */
+ unsigned char origCopy; /* 0 = copy, 1 = original */
+ unsigned char home; /* ignore */
+
+ /* variable */
+ unsigned char copyBit; /* 1 bit of the 72-bit copyright ID (transmitted as 1 bit per frame) */
+ unsigned char copyStart; /* 1 = this bit starts the 72-bit ID, 0 = it does not */
+ int frameLength; /* length of frame */
+ int bufferFull; /* number of 32-bit words left in enc buffer, 0x7FF = VBR */
+ unsigned char numRawDataBlocks; /* number of raw data blocks in frame */
+
+ /* CRC */
+ int crcCheckWord; /* 16-bit CRC check word (present if protectBit == 0) */
+} ADTSHeader;
+
+typedef struct _ADIFHeader {
+ unsigned char copyBit; /* 0 = no copyright ID, 1 = 72-bit copyright ID follows immediately */
+ unsigned char origCopy; /* 0 = copy, 1 = original */
+ unsigned char home; /* ignore */
+ unsigned char bsType; /* bitstream type: 0 = CBR, 1 = VBR */
+ int bitRate; /* bitRate: CBR = bits/sec, VBR = peak bits/frame, 0 = unknown */
+ unsigned char numPCE; /* number of program config elements (max = 16) */
+ int bufferFull; /* bits left in bit reservoir */
+ unsigned char copyID[ADIF_COPYID_SIZE]; /* optional 72-bit copyright ID */
+} ADIFHeader;
+
+/* sizeof(ProgConfigElement) = 82 bytes (if KEEP_PCE_COMMENTS not defined) */
+typedef struct _ProgConfigElement {
+ unsigned char elemInstTag; /* element instance tag */
+ unsigned char profile; /* 0 = main, 1 = LC, 2 = SSR, 3 = reserved */
+ unsigned char sampRateIdx; /* sample rate index range = [0, 11] */
+ unsigned char numFCE; /* number of front channel elements (max = 15) */
+ unsigned char numSCE; /* number of side channel elements (max = 15) */
+ unsigned char numBCE; /* number of back channel elements (max = 15) */
+ unsigned char numLCE; /* number of LFE channel elements (max = 3) */
+ unsigned char numADE; /* number of associated data elements (max = 7) */
+ unsigned char numCCE; /* number of valid channel coupling elements (max = 15) */
+ unsigned char monoMixdown; /* mono mixdown: bit 4 = present flag, bits 3-0 = element number */
+ unsigned char stereoMixdown; /* stereo mixdown: bit 4 = present flag, bits 3-0 = element number */
+ unsigned char matrixMixdown; /* matrix mixdown: bit 4 = present flag, bit 3 = unused,
+ bits 2-1 = index, bit 0 = pseudo-surround enable */
+ unsigned char fce[MAX_NUM_FCE]; /* front element channel pair: bit 4 = SCE/CPE flag, bits 3-0 = inst tag */
+ unsigned char sce[MAX_NUM_SCE]; /* side element channel pair: bit 4 = SCE/CPE flag, bits 3-0 = inst tag */
+ unsigned char bce[MAX_NUM_BCE]; /* back element channel pair: bit 4 = SCE/CPE flag, bits 3-0 = inst tag */
+ unsigned char lce[MAX_NUM_LCE]; /* instance tag for LFE elements */
+ unsigned char ade[MAX_NUM_ADE]; /* instance tag for ADE elements */
+ unsigned char cce[MAX_NUM_BCE]; /* channel coupling elements: bit 4 = switching flag, bits 3-0 = inst tag */
+
+#ifdef KEEP_PCE_COMMENTS
+ /* make this optional - if not enabled, decoder will just skip comments */
+ unsigned char commentBytes;
+ unsigned char commentField[MAX_COMMENT_BYTES];
+#endif
+
+} ProgConfigElement;
+
+/* state info struct for baseline (MPEG-4 LC) decoding */
+typedef struct _PSInfoBase {
+ /* header information */
+ ADTSHeader fhADTS;
+ ADIFHeader fhADIF;
+ ProgConfigElement pce[MAX_NUM_PCE_ADIF];
+ int dataCount;
+ unsigned char dataBuf[DATA_BUF_SIZE];
+ int fillCount;
+ unsigned char fillBuf[FILL_BUF_SIZE];
+
+ /* state information which is the same throughout whole frame */
+ int nChans;
+ int useImpChanMap;
+ int sampRateIdx;
+
+ /* state information which can be overwritten by subsequent elements within frame */
+ ICSInfo icsInfo[MAX_NCHANS_ELEM];
+
+ int commonWin;
+ short scaleFactors[MAX_NCHANS_ELEM][MAX_SF_BANDS];
+ unsigned char sfbCodeBook[MAX_NCHANS_ELEM][MAX_SF_BANDS];
+
+ int msMaskPresent;
+ unsigned char msMaskBits[MAX_MS_MASK_BYTES];
+
+ int pnsUsed[MAX_NCHANS_ELEM];
+ int pnsLastVal;
+ int intensityUsed[MAX_NCHANS_ELEM];
+
+ PulseInfo pulseInfo[MAX_NCHANS_ELEM];
+
+ TNSInfo tnsInfo[MAX_NCHANS_ELEM];
+ int tnsLPCBuf[MAX_TNS_ORDER];
+ int tnsWorkBuf[MAX_TNS_ORDER];
+
+ GainControlInfo gainControlInfo[MAX_NCHANS_ELEM];
+
+ int gbCurrent[MAX_NCHANS_ELEM];
+ int coef[MAX_NCHANS_ELEM][AAC_MAX_NSAMPS];
+#ifdef AAC_ENABLE_SBR
+ int sbrWorkBuf[MAX_NCHANS_ELEM][AAC_MAX_NSAMPS];
+#endif
+ /* state information which must be saved for each element and used in next frame */
+ int overlap[AAC_MAX_NCHANS][AAC_MAX_NSAMPS];
+ int prevWinShape[AAC_MAX_NCHANS];
+
+} PSInfoBase;
+
+/* private implementation-specific functions */
+
+/* decelmnt.c */
+int DecodeProgramConfigElement(ProgConfigElement *pce, BitStreamInfo *bsi);
+
+/* huffman.c */
+int DecodeHuffmanScalar(const signed short *huffTab, const HuffInfo *huffTabInfo, unsigned int bitBuf, signed int *val);
+int DecodeSpectrumLong(PSInfoBase *psi, BitStreamInfo *bsi, int ch);
+int DecodeSpectrumShort(PSInfoBase *psi, BitStreamInfo *bsi, int ch);
+
+/* noiseless.c */
+void DecodeICSInfo(BitStreamInfo *bsi, ICSInfo *icsInfo, int sampRateIdx);
+
+/* dct4.c */
+void DCT4(int tabidx, int *coef, int gb);
+
+/* fft.c */
+void R4FFT(int tabidx, int *x);
+
+/* sbrimdct.c */
+void DecWindowOverlapNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev);
+void DecWindowOverlapLongStartNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev);
+void DecWindowOverlapLongStopNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev);
+void DecWindowOverlapShortNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev);
+
+/* hufftabs.c */
+extern const HuffInfo huffTabSpecInfo[11];
+extern const signed short huffTabSpec[1241];
+extern const HuffInfo huffTabScaleFactInfo;
+extern const signed short huffTabScaleFact[121];
+
+/* trigtabs.c */
+extern const int cos4sin4tabOffset[NUM_IMDCT_SIZES];
+extern const int sinWindowOffset[NUM_IMDCT_SIZES];
+extern const int kbdWindowOffset[NUM_IMDCT_SIZES];
+extern const unsigned char bitrevtab[17 + 129];
+extern const int bitrevtabOffset[NUM_IMDCT_SIZES];
+
+#ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT
+/* trigtabs_fltgen.c */
+extern int cos4sin4tab[128 + 1024];
+extern int cos1sin1tab[514];
+extern int sinWindow[128 + 1024];
+extern int kbdWindow[128 + 1024];
+extern int twidTabEven[4 * 6 + 16 * 6 + 64 * 6];
+extern int twidTabOdd[8 * 6 + 32 * 6 + 128 * 6];
+#else
+/* trigtabs.c */
+extern const int cos4sin4tab[128 + 1024];
+extern const int cos1sin1tab[514];
+extern const int sinWindow[128 + 1024];
+extern const int kbdWindow[128 + 1024];
+extern const int twidTabEven[4 * 6 + 16 * 6 + 64 * 6];
+extern const int twidTabOdd[8 * 6 + 32 * 6 + 128 * 6];
+#endif
+
+#endif /* _CODER_H */
+
diff --git a/audio_codec/wfd_aac_decoder/dct4.c b/audio_codec/wfd_aac_decoder/dct4.c
new file mode 100644
index 0000000..3182479
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/dct4.c
@@ -0,0 +1,337 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: dct4.c,v 1.1.2.1 2005/02/26 02:05:12 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * dct4.c - optimized DCT-IV
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+static const int nmdctTab[NUM_IMDCT_SIZES] = {128, 1024};
+static const int postSkip[NUM_IMDCT_SIZES] = {15, 1};
+
+/**************************************************************************************
+ * Function: PreMultiply
+ *
+ * Description: pre-twiddle stage of DCT4
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmdct samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: minimum 1 GB in, 2 GB out, gains 5 (short) or 8 (long) frac bits
+ * i.e. gains 2-7= -5 int bits (short) or 2-10 = -8 int bits (long)
+ * normalization by -1/N is rolled into tables here (see trigtabs.c)
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ **************************************************************************************/
+static void PreMultiply(int tabidx, int *zbuf1)
+{
+ int i, nmdct, ar1, ai1, ar2, ai2, z1, z2;
+ int t, cms2, cps2a, sin2a, cps2b, sin2b;
+ int *zbuf2;
+ const int *csptr;
+
+ nmdct = nmdctTab[tabidx];
+ zbuf2 = zbuf1 + nmdct - 1;
+ csptr = cos4sin4tab + cos4sin4tabOffset[tabidx];
+
+ /* whole thing should fit in registers - verify that compiler does this */
+ for (i = nmdct >> 2; i != 0; i--) {
+ /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */
+ cps2a = *csptr++;
+ sin2a = *csptr++;
+ cps2b = *csptr++;
+ sin2b = *csptr++;
+
+ ar1 = *(zbuf1 + 0);
+ ai2 = *(zbuf1 + 1);
+ ai1 = *(zbuf2 + 0);
+ ar2 = *(zbuf2 - 1);
+
+ /* gain 2 ints bit from MULSHIFT32 by Q30, but drop 7 or 10 int bits from table scaling of 1/M
+ * max per-sample gain (ignoring implicit scaling) = MAX(sin(angle)+cos(angle)) = 1.414
+ * i.e. gain 1 GB since worst case is sin(angle) = cos(angle) = 0.707 (Q30), gain 2 from
+ * extra sign bits, and eat one in adding
+ */
+ t = MULSHIFT32(sin2a, ar1 + ai1);
+ z2 = MULSHIFT32(cps2a, ai1) - t;
+ cms2 = cps2a - 2 * sin2a;
+ z1 = MULSHIFT32(cms2, ar1) + t;
+ *zbuf1++ = z1; /* cos*ar1 + sin*ai1 */
+ *zbuf1++ = z2; /* cos*ai1 - sin*ar1 */
+
+ t = MULSHIFT32(sin2b, ar2 + ai2);
+ z2 = MULSHIFT32(cps2b, ai2) - t;
+ cms2 = cps2b - 2 * sin2b;
+ z1 = MULSHIFT32(cms2, ar2) + t;
+ *zbuf2-- = z2; /* cos*ai2 - sin*ar2 */
+ *zbuf2-- = z1; /* cos*ar2 + sin*ai2 */
+ }
+}
+
+/**************************************************************************************
+ * Function: PostMultiply
+ *
+ * Description: post-twiddle stage of DCT4
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmdct samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: minimum 1 GB in, 2 GB out - gains 2 int bits
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ **************************************************************************************/
+static void PostMultiply(int tabidx, int *fft1)
+{
+ int i, nmdct, ar1, ai1, ar2, ai2, skipFactor;
+ int t, cms2, cps2, sin2;
+ int *fft2;
+ const int *csptr;
+
+ nmdct = nmdctTab[tabidx];
+ csptr = cos1sin1tab;
+ skipFactor = postSkip[tabidx];
+ fft2 = fft1 + nmdct - 1;
+
+ /* load coeffs for first pass
+ * cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin)
+ */
+ cps2 = *csptr++;
+ sin2 = *csptr;
+ csptr += skipFactor;
+ cms2 = cps2 - 2 * sin2;
+
+ for (i = nmdct >> 2; i != 0; i--) {
+ ar1 = *(fft1 + 0);
+ ai1 = *(fft1 + 1);
+ ar2 = *(fft2 - 1);
+ ai2 = *(fft2 + 0);
+
+ /* gain 2 ints bit from MULSHIFT32 by Q30
+ * max per-sample gain = MAX(sin(angle)+cos(angle)) = 1.414
+ * i.e. gain 1 GB since worst case is sin(angle) = cos(angle) = 0.707 (Q30), gain 2 from
+ * extra sign bits, and eat one in adding
+ */
+ t = MULSHIFT32(sin2, ar1 + ai1);
+ *fft2-- = t - MULSHIFT32(cps2, ai1); /* sin*ar1 - cos*ai1 */
+ *fft1++ = t + MULSHIFT32(cms2, ar1); /* cos*ar1 + sin*ai1 */
+ cps2 = *csptr++;
+ sin2 = *csptr;
+ csptr += skipFactor;
+
+ ai2 = -ai2;
+ t = MULSHIFT32(sin2, ar2 + ai2);
+ *fft2-- = t - MULSHIFT32(cps2, ai2); /* sin*ar1 - cos*ai1 */
+ cms2 = cps2 - 2 * sin2;
+ *fft1++ = t + MULSHIFT32(cms2, ar2); /* cos*ar1 + sin*ai1 */
+ }
+}
+
+/**************************************************************************************
+ * Function: PreMultiplyRescale
+ *
+ * Description: pre-twiddle stage of DCT4, with rescaling for extra guard bits
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmdct samples
+ * number of guard bits to add to input before processing
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: see notes on PreMultiply(), above
+ **************************************************************************************/
+static void PreMultiplyRescale(int tabidx, int *zbuf1, int es)
+{
+ int i, nmdct, ar1, ai1, ar2, ai2, z1, z2;
+ int t, cms2, cps2a, sin2a, cps2b, sin2b;
+ int *zbuf2;
+ const int *csptr;
+
+ nmdct = nmdctTab[tabidx];
+ zbuf2 = zbuf1 + nmdct - 1;
+ csptr = cos4sin4tab + cos4sin4tabOffset[tabidx];
+
+ /* whole thing should fit in registers - verify that compiler does this */
+ for (i = nmdct >> 2; i != 0; i--) {
+ /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */
+ cps2a = *csptr++;
+ sin2a = *csptr++;
+ cps2b = *csptr++;
+ sin2b = *csptr++;
+
+ ar1 = *(zbuf1 + 0) >> es;
+ ai1 = *(zbuf2 + 0) >> es;
+ ai2 = *(zbuf1 + 1) >> es;
+
+ t = MULSHIFT32(sin2a, ar1 + ai1);
+ z2 = MULSHIFT32(cps2a, ai1) - t;
+ cms2 = cps2a - 2 * sin2a;
+ z1 = MULSHIFT32(cms2, ar1) + t;
+ *zbuf1++ = z1;
+ *zbuf1++ = z2;
+
+ ar2 = *(zbuf2 - 1) >> es; /* do here to free up register used for es */
+
+ t = MULSHIFT32(sin2b, ar2 + ai2);
+ z2 = MULSHIFT32(cps2b, ai2) - t;
+ cms2 = cps2b - 2 * sin2b;
+ z1 = MULSHIFT32(cms2, ar2) + t;
+ *zbuf2-- = z2;
+ *zbuf2-- = z1;
+
+ }
+}
+
+/**************************************************************************************
+ * Function: PostMultiplyRescale
+ *
+ * Description: post-twiddle stage of DCT4, with rescaling for extra guard bits
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmdct samples
+ * number of guard bits to remove from output
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: clips output to [-2^30, 2^30 - 1], guaranteeing at least 1 guard bit
+ * see notes on PostMultiply(), above
+ **************************************************************************************/
+static void PostMultiplyRescale(int tabidx, int *fft1, int es)
+{
+ int i, nmdct, ar1, ai1, ar2, ai2, skipFactor, z;
+ int t, cs2, sin2;
+ int *fft2;
+ const int *csptr;
+
+ nmdct = nmdctTab[tabidx];
+ csptr = cos1sin1tab;
+ skipFactor = postSkip[tabidx];
+ fft2 = fft1 + nmdct - 1;
+
+ /* load coeffs for first pass
+ * cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin)
+ */
+ cs2 = *csptr++;
+ sin2 = *csptr;
+ csptr += skipFactor;
+
+ for (i = nmdct >> 2; i != 0; i--) {
+ ar1 = *(fft1 + 0);
+ ai1 = *(fft1 + 1);
+ ai2 = *(fft2 + 0);
+
+ t = MULSHIFT32(sin2, ar1 + ai1);
+ z = t - MULSHIFT32(cs2, ai1);
+ CLIP_2N_SHIFT(z, es);
+ *fft2-- = z;
+ cs2 -= 2 * sin2;
+ z = t + MULSHIFT32(cs2, ar1);
+ CLIP_2N_SHIFT(z, es);
+ *fft1++ = z;
+
+ cs2 = *csptr++;
+ sin2 = *csptr;
+ csptr += skipFactor;
+
+ ar2 = *fft2;
+ ai2 = -ai2;
+ t = MULSHIFT32(sin2, ar2 + ai2);
+ z = t - MULSHIFT32(cs2, ai2);
+ CLIP_2N_SHIFT(z, es);
+ *fft2-- = z;
+ cs2 -= 2 * sin2;
+ z = t + MULSHIFT32(cs2, ar2);
+ CLIP_2N_SHIFT(z, es);
+ *fft1++ = z;
+ cs2 += 2 * sin2;
+ }
+}
+
+/**************************************************************************************
+ * Function: DCT4
+ *
+ * Description: type-IV DCT
+ *
+ * Inputs: table index (for transform size)
+ * buffer of nmdct samples
+ * number of guard bits in the input buffer
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: operates in-place
+ * if number of guard bits in input is < GBITS_IN_DCT4, the input is
+ * scaled (>>) before the DCT4 and rescaled (<<, with clipping) after
+ * the DCT4 (rare)
+ * the output has FBITS_LOST_DCT4 fewer fraction bits than the input
+ * the output will always have at least 1 guard bit (GBITS_IN_DCT4 >= 4)
+ * int bits gained per stage (PreMul + FFT + PostMul)
+ * short blocks = (-5 + 4 + 2) = 1 total
+ * long blocks = (-8 + 7 + 2) = 1 total
+ **************************************************************************************/
+void DCT4(int tabidx, int *coef, int gb)
+{
+ int es;
+
+ /* fast in-place DCT-IV - adds guard bits if necessary */
+ if (gb < GBITS_IN_DCT4) {
+ es = GBITS_IN_DCT4 - gb;
+ PreMultiplyRescale(tabidx, coef, es);
+ R4FFT(tabidx, coef);
+ PostMultiplyRescale(tabidx, coef, es);
+ } else {
+ PreMultiply(tabidx, coef);
+ R4FFT(tabidx, coef);
+ PostMultiply(tabidx, coef);
+ }
+}
diff --git a/audio_codec/wfd_aac_decoder/decelmnt.c b/audio_codec/wfd_aac_decoder/decelmnt.c
new file mode 100644
index 0000000..4cd4ef8
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/decelmnt.c
@@ -0,0 +1,445 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: decelmnt.c,v 1.1.2.1 2005/02/26 02:05:12 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * decelmnt.c - syntactic element decoding
+ **************************************************************************************/
+
+#include "coder.h"
+
+/**************************************************************************************
+ * Function: DecodeSingleChannelElement
+ *
+ * Description: decode one SCE
+ *
+ * Inputs: BitStreamInfo struct pointing to start of SCE (14496-3, table 4.4.4)
+ *
+ * Outputs: updated element instance tag
+ *
+ * Return: 0 if successful, -1 if error
+ *
+ * Notes: doesn't decode individual channel stream (part of DecodeNoiselessData)
+ **************************************************************************************/
+static int DecodeSingleChannelElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
+{
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+
+ /* read instance tag */
+ aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS);
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeChannelPairElement
+ *
+ * Description: decode one CPE
+ *
+ * Inputs: BitStreamInfo struct pointing to start of CPE (14496-3, table 4.4.5)
+ *
+ * Outputs: updated element instance tag
+ * updated commonWin
+ * updated ICS info, if commonWin == 1
+ * updated mid-side stereo info, if commonWin == 1
+ *
+ * Return: 0 if successful, -1 if error
+ *
+ * Notes: doesn't decode individual channel stream (part of DecodeNoiselessData)
+ **************************************************************************************/
+static int DecodeChannelPairElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
+{
+ int sfb, gp, maskOffset;
+ unsigned char currBit, *maskPtr;
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = psi->icsInfo;
+
+ /* read instance tag */
+ aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS);
+
+ /* read common window flag and mid-side info (if present)
+ * store msMask bits in psi->msMaskBits[] as follows:
+ * long blocks - pack bits for each SFB in range [0, maxSFB) starting with lsb of msMaskBits[0]
+ * short blocks - pack bits for each SFB in range [0, maxSFB), for each group [0, 7]
+ * msMaskPresent = 0 means no M/S coding
+ * = 1 means psi->msMaskBits contains 1 bit per SFB to toggle M/S coding
+ * = 2 means all SFB's are M/S coded (so psi->msMaskBits is not needed)
+ */
+ psi->commonWin = GetBits(bsi, 1);
+ if (psi->commonWin) {
+ DecodeICSInfo(bsi, icsInfo, psi->sampRateIdx);
+ psi->msMaskPresent = GetBits(bsi, 2);
+ if (psi->msMaskPresent == 1) {
+ maskPtr = psi->msMaskBits;
+ *maskPtr = 0;
+ maskOffset = 0;
+ for (gp = 0; gp < icsInfo->numWinGroup; gp++) {
+ for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) {
+ currBit = (unsigned char)GetBits(bsi, 1);
+ *maskPtr |= currBit << maskOffset;
+ if (++maskOffset == 8) {
+ maskPtr++;
+ *maskPtr = 0;
+ maskOffset = 0;
+ }
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeLFEChannelElement
+ *
+ * Description: decode one LFE
+ *
+ * Inputs: BitStreamInfo struct pointing to start of LFE (14496-3, table 4.4.9)
+ *
+ * Outputs: updated element instance tag
+ *
+ * Return: 0 if successful, -1 if error
+ *
+ * Notes: doesn't decode individual channel stream (part of DecodeNoiselessData)
+ **************************************************************************************/
+static int DecodeLFEChannelElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
+{
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+
+ /* read instance tag */
+ aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS);
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeDataStreamElement
+ *
+ * Description: decode one DSE
+ *
+ * Inputs: BitStreamInfo struct pointing to start of DSE (14496-3, table 4.4.10)
+ *
+ * Outputs: updated element instance tag
+ * filled in data stream buffer
+ *
+ * Return: 0 if successful, -1 if error
+ **************************************************************************************/
+static int DecodeDataStreamElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
+{
+ unsigned int byteAlign, dataCount;
+ unsigned char *dataBuf;
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS);
+ byteAlign = GetBits(bsi, 1);
+ dataCount = GetBits(bsi, 8);
+ if (dataCount == 255) {
+ dataCount += GetBits(bsi, 8);
+ }
+
+ if (byteAlign) {
+ ByteAlignBitstream(bsi);
+ }
+
+ psi->dataCount = dataCount;
+ dataBuf = psi->dataBuf;
+ while (dataCount--) {
+ *dataBuf++ = GetBits(bsi, 8);
+ }
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeProgramConfigElement
+ *
+ * Description: decode one PCE
+ *
+ * Inputs: BitStreamInfo struct pointing to start of PCE (14496-3, table 4.4.2)
+ *
+ * Outputs: filled-in ProgConfigElement struct
+ * updated BitStreamInfo struct
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: #define KEEP_PCE_COMMENTS to save the comment field of the PCE
+ * (otherwise we just skip it in the bitstream, to save memory)
+ **************************************************************************************/
+int DecodeProgramConfigElement(ProgConfigElement *pce, BitStreamInfo *bsi)
+{
+ int i;
+
+ pce->elemInstTag = GetBits(bsi, 4);
+ pce->profile = GetBits(bsi, 2);
+ pce->sampRateIdx = GetBits(bsi, 4);
+ pce->numFCE = GetBits(bsi, 4);
+ pce->numSCE = GetBits(bsi, 4);
+ pce->numBCE = GetBits(bsi, 4);
+ pce->numLCE = GetBits(bsi, 2);
+ pce->numADE = GetBits(bsi, 3);
+ pce->numCCE = GetBits(bsi, 4);
+
+ pce->monoMixdown = GetBits(bsi, 1) << 4; /* present flag */
+ if (pce->monoMixdown) {
+ pce->monoMixdown |= GetBits(bsi, 4); /* element number */
+ }
+
+ pce->stereoMixdown = GetBits(bsi, 1) << 4; /* present flag */
+ if (pce->stereoMixdown) {
+ pce->stereoMixdown |= GetBits(bsi, 4); /* element number */
+ }
+
+ pce->matrixMixdown = GetBits(bsi, 1) << 4; /* present flag */
+ if (pce->matrixMixdown) {
+ pce->matrixMixdown |= GetBits(bsi, 2) << 1; /* index */
+ pce->matrixMixdown |= GetBits(bsi, 1); /* pseudo-surround enable */
+ }
+
+ for (i = 0; i < pce->numFCE; i++) {
+ pce->fce[i] = GetBits(bsi, 1) << 4; /* is_cpe flag */
+ pce->fce[i] |= GetBits(bsi, 4); /* tag select */
+ }
+
+ for (i = 0; i < pce->numSCE; i++) {
+ pce->sce[i] = GetBits(bsi, 1) << 4; /* is_cpe flag */
+ pce->sce[i] |= GetBits(bsi, 4); /* tag select */
+ }
+
+ for (i = 0; i < pce->numBCE; i++) {
+ pce->bce[i] = GetBits(bsi, 1) << 4; /* is_cpe flag */
+ pce->bce[i] |= GetBits(bsi, 4); /* tag select */
+ }
+
+ for (i = 0; i < pce->numLCE; i++) {
+ pce->lce[i] = GetBits(bsi, 4); /* tag select */
+ }
+
+ for (i = 0; i < pce->numADE; i++) {
+ pce->ade[i] = GetBits(bsi, 4); /* tag select */
+ }
+
+ for (i = 0; i < pce->numCCE; i++) {
+ pce->cce[i] = GetBits(bsi, 1) << 4; /* independent/dependent flag */
+ pce->cce[i] |= GetBits(bsi, 4); /* tag select */
+ }
+
+
+ ByteAlignBitstream(bsi);
+
+#ifdef KEEP_PCE_COMMENTS
+ pce->commentBytes = GetBits(bsi, 8);
+ for (i = 0; i < pce->commentBytes; i++) {
+ pce->commentField[i] = GetBits(bsi, 8);
+ }
+#else
+ /* eat comment bytes and throw away */
+ i = GetBits(bsi, 8);
+ while (i--) {
+ GetBits(bsi, 8);
+ }
+#endif
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeFillElement
+ *
+ * Description: decode one fill element
+ *
+ * Inputs: BitStreamInfo struct pointing to start of fill element
+ * (14496-3, table 4.4.11)
+ *
+ * Outputs: updated element instance tag
+ * unpacked extension payload
+ *
+ * Return: 0 if successful, -1 if error
+ **************************************************************************************/
+static int DecodeFillElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi)
+{
+ unsigned int fillCount;
+ unsigned char *fillBuf;
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ fillCount = GetBits(bsi, 4);
+ if (fillCount == 15) {
+ fillCount += (GetBits(bsi, 8) - 1);
+ }
+
+ psi->fillCount = fillCount;
+ fillBuf = psi->fillBuf;
+ while (fillCount--) {
+ *fillBuf++ = GetBits(bsi, 8);
+ }
+
+ aacDecInfo->currInstTag = -1; /* fill elements don't have instance tag */
+ aacDecInfo->fillExtType = 0;
+
+#ifdef AAC_ENABLE_SBR
+ /* check for SBR
+ * aacDecInfo->sbrEnabled is sticky (reset each raw_data_block), so for multichannel
+ * need to verify that all SCE/CPE/ICCE have valid SBR fill element following, and
+ * must upsample by 2 for LFE
+ */
+ if (psi->fillCount > 0) {
+ aacDecInfo->fillExtType = (int)((psi->fillBuf[0] >> 4) & 0x0f);
+ if (aacDecInfo->fillExtType == EXT_SBR_DATA || aacDecInfo->fillExtType == EXT_SBR_DATA_CRC) {
+ aacDecInfo->sbrEnabled = 1;
+ }
+ }
+#endif
+
+ aacDecInfo->fillBuf = psi->fillBuf;
+ aacDecInfo->fillCount = psi->fillCount;
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: DecodeNextElement
+ *
+ * Description: decode next syntactic element in AAC frame
+ *
+ * Inputs: valid AACDecInfo struct
+ * double pointer to buffer containing next element
+ * pointer to bit offset
+ * pointer to number of valid bits remaining in buf
+ *
+ * Outputs: type of element decoded (aacDecInfo->currBlockID)
+ * type of element decoded last time (aacDecInfo->prevBlockID)
+ * updated aacDecInfo state, depending on which element was decoded
+ * updated buffer pointer
+ * updated bit offset
+ * updated number of available bits
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int DecodeNextElement(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail)
+{
+ int err, bitsUsed;
+ PSInfoBase *psi;
+ BitStreamInfo bsi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ /* init bitstream reader */
+ SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf);
+ GetBits(&bsi, *bitOffset);
+
+ /* read element ID (save last ID for SBR purposes) */
+ aacDecInfo->prevBlockID = aacDecInfo->currBlockID;
+ aacDecInfo->currBlockID = GetBits(&bsi, NUM_SYN_ID_BITS);
+
+ /* set defaults (could be overwritten by DecodeXXXElement(), depending on currBlockID) */
+ psi->commonWin = 0;
+
+ err = 0;
+ switch (aacDecInfo->currBlockID) {
+ case AAC_ID_SCE:
+ err = DecodeSingleChannelElement(aacDecInfo, &bsi);
+ break;
+ case AAC_ID_CPE:
+ err = DecodeChannelPairElement(aacDecInfo, &bsi);
+ break;
+ case AAC_ID_CCE:
+ /* TODO - implement CCE decoding */
+ break;
+ case AAC_ID_LFE:
+ err = DecodeLFEChannelElement(aacDecInfo, &bsi);
+ break;
+ case AAC_ID_DSE:
+ err = DecodeDataStreamElement(aacDecInfo, &bsi);
+ break;
+ case AAC_ID_PCE:
+ err = DecodeProgramConfigElement(psi->pce + 0, &bsi);
+ break;
+ case AAC_ID_FIL:
+ err = DecodeFillElement(aacDecInfo, &bsi);
+ break;
+ case AAC_ID_END:
+ break;
+ }
+ if (err) {
+ return ERR_AAC_SYNTAX_ELEMENT;
+ }
+
+ /* update bitstream reader */
+ bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset);
+ *buf += (bitsUsed + *bitOffset) >> 3;
+ *bitOffset = (bitsUsed + *bitOffset) & 0x07;
+ *bitsAvail -= bitsUsed;
+
+ if (*bitsAvail < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+
+ return ERR_AAC_NONE;
+}
+
diff --git a/audio_codec/wfd_aac_decoder/dequant.c b/audio_codec/wfd_aac_decoder/dequant.c
new file mode 100644
index 0000000..43f4a5e
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/dequant.c
@@ -0,0 +1,379 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: dequant.c,v 1.2 2005/05/20 18:05:41 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * dequant.c - transform coefficient dequantization and short-block deinterleaving
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+#include <stdio.h>
+
+
+#define SF_OFFSET 100
+
+/* pow(2, i/4.0) for i = [0,1,2,3], format = Q30 */
+static const int pow14[4] = {
+ 0x40000000, 0x4c1bf829, 0x5a82799a, 0x6ba27e65
+};
+
+/* pow(2, i/4.0) * pow(j, 4.0/3.0) for i = [0,1,2,3], j = [0,1,2,...,15]
+ * format = Q28 for j = [0-3], Q25 for j = [4-15]
+ */
+static const int pow43_14[4][16] = {
+ {
+ 0x00000000, 0x10000000, 0x285145f3, 0x453a5cdb, /* Q28 */
+ 0x0cb2ff53, 0x111989d6, 0x15ce31c8, 0x1ac7f203, /* Q25 */
+ 0x20000000, 0x257106b9, 0x2b16b4a3, 0x30ed74b4, /* Q25 */
+ 0x36f23fa5, 0x3d227bd3, 0x437be656, 0x49fc823c, /* Q25 */
+ },
+ {
+ 0x00000000, 0x1306fe0a, 0x2ff221af, 0x52538f52,
+ 0x0f1a1bf4, 0x1455ccc2, 0x19ee62a8, 0x1fd92396,
+ 0x260dfc14, 0x2c8694d8, 0x333dcb29, 0x3a2f5c7a,
+ 0x4157aed5, 0x48b3aaa3, 0x50409f76, 0x57fc3010,
+ },
+ {
+ 0x00000000, 0x16a09e66, 0x39047c0f, 0x61e734aa,
+ 0x11f59ac4, 0x182ec633, 0x1ed66a45, 0x25dfc55a,
+ 0x2d413ccd, 0x34f3462d, 0x3cefc603, 0x4531ab69,
+ 0x4db4adf8, 0x56752054, 0x5f6fcfcd, 0x68a1eca1,
+ },
+ {
+ 0x00000000, 0x1ae89f99, 0x43ce3e4b, 0x746d57b2,
+ 0x155b8109, 0x1cc21cdc, 0x24ac1839, 0x2d0a479e,
+ 0x35d13f33, 0x3ef80748, 0x48775c93, 0x524938cd,
+ 0x5c68841d, 0x66d0df0a, 0x717e7bfe, 0x7c6e0305,
+ },
+};
+
+/* pow(j, 4.0 / 3.0) for j = [16,17,18,...,63], format = Q23 */
+static const int pow43[48] = {
+ 0x1428a2fa, 0x15db1bd6, 0x1796302c, 0x19598d85,
+ 0x1b24e8bb, 0x1cf7fcfa, 0x1ed28af2, 0x20b4582a,
+ 0x229d2e6e, 0x248cdb55, 0x26832fda, 0x28800000,
+ 0x2a832287, 0x2c8c70a8, 0x2e9bc5d8, 0x30b0ff99,
+ 0x32cbfd4a, 0x34eca001, 0x3712ca62, 0x393e6088,
+ 0x3b6f47e0, 0x3da56717, 0x3fe0a5fc, 0x4220ed72,
+ 0x44662758, 0x46b03e7c, 0x48ff1e87, 0x4b52b3f3,
+ 0x4daaebfd, 0x5007b497, 0x5268fc62, 0x54ceb29c,
+ 0x5738c721, 0x59a72a59, 0x5c19cd35, 0x5e90a129,
+ 0x610b9821, 0x638aa47f, 0x660db90f, 0x6894c90b,
+ 0x6b1fc80c, 0x6daeaa0d, 0x70416360, 0x72d7e8b0,
+ 0x75722ef9, 0x78102b85, 0x7ab1d3ec, 0x7d571e09,
+};
+
+/* sqrt(0.5), format = Q31 */
+#define SQRTHALF 0x5a82799a
+
+/* Minimax polynomial approximation to pow(x, 4/3), over the range
+ * poly43lo: x = [0.5, 0.7071]
+ * poly43hi: x = [0.7071, 1.0]
+ *
+ * Relative error < 1E-7
+ * Coefs are scaled by 4, 2, 1, 0.5, 0.25
+ */
+static const int poly43lo[5] = { 0x29a0bda9, 0xb02e4828, 0x5957aa1b, 0x236c498d, 0xff581859 };
+static const int poly43hi[5] = { 0x10852163, 0xd333f6a4, 0x46e9408b, 0x27c2cef0, 0xfef577b4 };
+
+/* pow2exp[i] = pow(2, i*4/3) exponent */
+static const int pow2exp[8] = { 14, 13, 11, 10, 9, 7, 6, 5 };
+
+/* pow2exp[i] = pow(2, i*4/3) fraction */
+static const int pow2frac[8] = {
+ 0x6597fa94, 0x50a28be6, 0x7fffffff, 0x6597fa94,
+ 0x50a28be6, 0x7fffffff, 0x6597fa94, 0x50a28be6
+};
+
+/**************************************************************************************
+ * Function: DequantBlock
+ *
+ * Description: dequantize one block of transform coefficients (in-place)
+ *
+ * Inputs: quantized transform coefficients, range = [0, 8191]
+ * number of samples to dequantize
+ * scalefactor for this block of data, range = [0, 256]
+ *
+ * Outputs: dequantized transform coefficients in Q(FBITS_OUT_DQ_OFF)
+ *
+ * Return: guard bit mask (OR of abs value of all dequantized coefs)
+ *
+ * Notes: applies dequant formula y = pow(x, 4.0/3.0) * pow(2, (scale - 100)/4.0)
+ * * pow(2, FBITS_OUT_DQ_OFF)
+ * clips outputs to Q(FBITS_OUT_DQ_OFF)
+ * output has no minimum number of guard bits
+ **************************************************************************************/
+static int DequantBlock(int *inbuf, int nSamps, int scale)
+{
+ int iSamp, scalef, scalei, x, y, gbMask, shift, tab4[4];
+ const int *tab16, *coef;
+
+ if (nSamps <= 0) {
+ return 0;
+ }
+
+ scale -= SF_OFFSET; /* new range = [-100, 156] */
+
+ /* with two's complement numbers, scalei/scalef factorization works for pos and neg values of scale:
+ * [+4...+7] >> 2 = +1, [ 0...+3] >> 2 = 0, [-4...-1] >> 2 = -1, [-8...-5] >> 2 = -2 ...
+ * (-1 & 0x3) = 3, (-2 & 0x3) = 2, (-3 & 0x3) = 1, (0 & 0x3) = 0
+ *
+ * Example: 2^(-5/4) = 2^(-1) * 2^(-1/4) = 2^-2 * 2^(3/4)
+ */
+ tab16 = pow43_14[scale & 0x3];
+ scalef = pow14[scale & 0x3];
+ scalei = (scale >> 2) + FBITS_OUT_DQ_OFF;
+
+ /* cache first 4 values:
+ * tab16[j] = Q28 for j = [0,3]
+ * tab4[x] = x^(4.0/3.0) * 2^(0.25*scale), Q(FBITS_OUT_DQ_OFF)
+ */
+ shift = 28 - scalei;
+ if (shift > 31) {
+ tab4[0] = tab4[1] = tab4[2] = tab4[3] = 0;
+ } else if (shift <= 0) {
+ shift = -shift;
+ if (shift > 31) {
+ shift = 31;
+ }
+ for (x = 0; x < 4; x++) {
+ y = tab16[x];
+ if (y > (0x7fffffff >> shift)) {
+ y = 0x7fffffff; /* clip (rare) */
+ } else {
+ y <<= shift;
+ }
+ tab4[x] = y;
+ }
+ } else {
+ tab4[0] = 0;
+ tab4[1] = tab16[1] >> shift;
+ tab4[2] = tab16[2] >> shift;
+ tab4[3] = tab16[3] >> shift;
+ }
+
+ gbMask = 0;
+ do {
+ iSamp = *inbuf;
+ x = FASTABS(iSamp);
+
+ if (x < 4) {
+ y = tab4[x];
+ } else {
+
+ if (x < 16) {
+ /* result: y = Q25 (tab16 = Q25) */
+ y = tab16[x];
+ shift = 25 - scalei;
+ } else if (x < 64) {
+ /* result: y = Q21 (pow43tab[j] = Q23, scalef = Q30) */
+ y = pow43[x - 16];
+ shift = 21 - scalei;
+ y = MULSHIFT32(y, scalef);
+ } else {
+ /* normalize to [0x40000000, 0x7fffffff]
+ * input x = [64, 8191] = [64, 2^13-1]
+ * ranges:
+ * shift = 7: 64 - 127
+ * shift = 6: 128 - 255
+ * shift = 5: 256 - 511
+ * shift = 4: 512 - 1023
+ * shift = 3: 1024 - 2047
+ * shift = 2: 2048 - 4095
+ * shift = 1: 4096 - 8191
+ */
+ x <<= 17;
+ shift = 0;
+ if (x < 0x08000000) {
+ x <<= 4, shift += 4;
+ }
+ if (x < 0x20000000) {
+ x <<= 2, shift += 2;
+ }
+ if (x < 0x40000000) {
+ x <<= 1, shift += 1;
+ }
+
+ coef = (x < SQRTHALF) ? poly43lo : poly43hi;
+
+ /* polynomial */
+ y = coef[0];
+ y = MULSHIFT32(y, x) + coef[1];
+ y = MULSHIFT32(y, x) + coef[2];
+ y = MULSHIFT32(y, x) + coef[3];
+ y = MULSHIFT32(y, x) + coef[4];
+ y = MULSHIFT32(y, pow2frac[shift]) << 3;
+
+ /* fractional scale
+ * result: y = Q21 (pow43tab[j] = Q23, scalef = Q30)
+ */
+ y = MULSHIFT32(y, scalef); /* now y is Q24 */
+ shift = 24 - scalei - pow2exp[shift];
+ }
+
+ /* integer scale */
+ if (shift <= 0) {
+ shift = -shift;
+ if (shift > 31) {
+ shift = 31;
+ }
+
+ if (y > (0x7fffffff >> shift)) {
+ y = 0x7fffffff; /* clip (rare) */
+ } else {
+ y <<= shift;
+ }
+ } else {
+ if (shift > 31) {
+ shift = 31;
+ }
+ y >>= shift;
+ }
+ }
+
+ /* sign and store (gbMask used to count GB's) */
+ gbMask |= y;
+
+ /* apply sign */
+ iSamp >>= 31;
+ y ^= iSamp;
+ y -= iSamp;
+
+ *inbuf++ = y;
+ } while (--nSamps);
+
+ return gbMask;
+}
+
+/**************************************************************************************
+ * Function: Dequantize
+ *
+ * Description: dequantize all transform coefficients for one channel
+ *
+ * Inputs: valid AACDecInfo struct (including unpacked, quantized coefficients)
+ * index of current channel
+ *
+ * Outputs: dequantized coefficients, including short-block deinterleaving
+ * flags indicating if intensity and/or PNS is active
+ * minimum guard bit count for dequantized coefficients
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int Dequantize(AACDecInfo *aacDecInfo, int ch)
+{
+ int gp, cb, sfb, win, width, nSamps, gbMask;
+ int *coef;
+ const short *sfbTab;
+ unsigned char *sfbCodeBook;
+ short *scaleFactors;
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ if (icsInfo->winSequence == 2) {
+ sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_SHORT;
+ } else {
+ sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_LONG;
+ }
+ coef = psi->coef[ch];
+ sfbCodeBook = psi->sfbCodeBook[ch];
+ scaleFactors = psi->scaleFactors[ch];
+
+ psi->intensityUsed[ch] = 0;
+ psi->pnsUsed[ch] = 0;
+ gbMask = 0;
+ for (gp = 0; gp < icsInfo->numWinGroup; gp++) {
+ for (win = 0; win < icsInfo->winGroupLen[gp]; win++) {
+ for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) {
+ /* dequantize one scalefactor band (not necessary if codebook is intensity or PNS)
+ * for zero codebook, still run dequantizer in case non-zero pulse data was added
+ */
+ cb = (int)(sfbCodeBook[sfb]);
+ width = sfbTab[sfb + 1] - sfbTab[sfb];
+ if (cb >= 0 && cb <= 11) {
+ gbMask |= DequantBlock(coef, width, scaleFactors[sfb]);
+ } else if (cb == 13) {
+ psi->pnsUsed[ch] = 1;
+ } else if (cb == 14 || cb == 15) {
+ psi->intensityUsed[ch] = 1; /* should only happen if ch == 1 */
+ }
+ coef += width;
+ }
+ coef += (nSamps - sfbTab[icsInfo->maxSFB]);
+ }
+ sfbCodeBook += icsInfo->maxSFB;
+ scaleFactors += icsInfo->maxSFB;
+ }
+ aacDecInfo->pnsUsed |= psi->pnsUsed[ch]; /* set flag if PNS used for any channel */
+
+ /* calculate number of guard bits in dequantized data */
+ psi->gbCurrent[ch] = CLZ(gbMask) - 1;
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: DeinterleaveShortBlocks
+ *
+ * Description: deinterleave transform coefficients in short blocks for one channel
+ *
+ * Inputs: valid AACDecInfo struct (including unpacked, quantized coefficients)
+ * index of current channel
+ *
+ * Outputs: deinterleaved coefficients (window groups into 8 separate windows)
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: only necessary if deinterleaving not part of Huffman decoding
+ **************************************************************************************/
+int DeinterleaveShortBlocks(AACDecInfo *aacDecInfo, int ch)
+{
+ /* not used for this implementation - short block deinterleaving performed during Huffman decoding */
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/wfd_aac_decoder/fft.c b/audio_codec/wfd_aac_decoder/fft.c
new file mode 100644
index 0000000..db17d27
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/fft.c
@@ -0,0 +1,391 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: fft.c,v 1.1.2.1 2005/02/26 02:05:12 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * fft.c - Ken's optimized radix-4 DIT FFT, optional radix-8 first pass for odd log2(N)
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+#define NUM_FFT_SIZES 2
+static const int nfftTab[NUM_FFT_SIZES] = {64, 512};
+static const int nfftlog2Tab[NUM_FFT_SIZES] = {6, 9};
+
+#define SQRT1_2 0x5a82799a /* sqrt(1/2) in Q31 */
+
+#define swapcplx(p0,p1) \
+ t = p0; t1 = *(&(p0)+1); p0 = p1; *(&(p0)+1) = *(&(p1)+1); p1 = t; *(&(p1)+1) = t1
+
+/**************************************************************************************
+ * Function: BitReverse
+ *
+ * Description: Ken's fast in-place bit reverse, using super-small table
+ *
+ * Inputs: buffer of samples
+ * table index (for transform size)
+ *
+ * Outputs: bit-reversed samples in same buffer
+ *
+ * Return: none
+ **************************************************************************************/
+static void BitReverse(int *inout, int tabidx)
+{
+ int *part0, *part1;
+ int a, b, t, t1;
+ const unsigned char* tab = bitrevtab + bitrevtabOffset[tabidx];
+ int nbits = nfftlog2Tab[tabidx];
+
+ part0 = inout;
+ part1 = inout + (1 << nbits);
+
+ while ((a = *tab++) != 0) {
+ b = *tab++;
+
+ swapcplx(part0[4 * a + 0], part0[4 * b + 0]); /* 0xxx0 <-> 0yyy0 */
+ swapcplx(part0[4 * a + 2], part1[4 * b + 0]); /* 0xxx1 <-> 1yyy0 */
+ swapcplx(part1[4 * a + 0], part0[4 * b + 2]); /* 1xxx0 <-> 0yyy1 */
+ swapcplx(part1[4 * a + 2], part1[4 * b + 2]); /* 1xxx1 <-> 1yyy1 */
+ }
+
+ do {
+ swapcplx(part0[4 * a + 2], part1[4 * a + 0]); /* 0xxx1 <-> 1xxx0 */
+ } while ((a = *tab++) != 0);
+}
+
+/**************************************************************************************
+ * Function: R4FirstPass
+ *
+ * Description: radix-4 trivial pass for decimation-in-time FFT
+ *
+ * Inputs: buffer of (bit-reversed) samples
+ * number of R4 butterflies per group (i.e. nfft / 4)
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 2 guard bits, gains no integer bits,
+ * guard bits out = guard bits in - 2
+ **************************************************************************************/
+static void R4FirstPass(int *x, int bg)
+{
+ int ar, ai, br, bi, cr, ci, dr, di;
+
+ for (; bg != 0; bg--) {
+
+ ar = x[0] + x[2];
+ br = x[0] - x[2];
+ ai = x[1] + x[3];
+ bi = x[1] - x[3];
+ cr = x[4] + x[6];
+ dr = x[4] - x[6];
+ ci = x[5] + x[7];
+ di = x[5] - x[7];
+
+ /* max per-sample gain = 4.0 (adding 4 inputs together) */
+ x[0] = ar + cr;
+ x[4] = ar - cr;
+ x[1] = ai + ci;
+ x[5] = ai - ci;
+ x[2] = br + di;
+ x[6] = br - di;
+ x[3] = bi - dr;
+ x[7] = bi + dr;
+
+ x += 8;
+ }
+}
+
+/**************************************************************************************
+ * Function: R8FirstPass
+ *
+ * Description: radix-8 trivial pass for decimation-in-time FFT
+ *
+ * Inputs: buffer of (bit-reversed) samples
+ * number of R8 butterflies per group (i.e. nfft / 8)
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 3 guard bits, gains 1 integer bit
+ * guard bits out = guard bits in - 3 (if inputs are full scale)
+ * or guard bits in - 2 (if inputs bounded to +/- sqrt(2)/2)
+ * see scaling comments in code
+ **************************************************************************************/
+static void R8FirstPass(int *x, int bg)
+{
+ int ar, ai, br, bi, cr, ci, dr, di;
+ int sr, si, tr, ti, ur, ui, vr, vi;
+ int wr, wi, xr, xi, yr, yi, zr, zi;
+
+ for (; bg != 0; bg--) {
+
+ ar = x[0] + x[2];
+ br = x[0] - x[2];
+ ai = x[1] + x[3];
+ bi = x[1] - x[3];
+ cr = x[4] + x[6];
+ dr = x[4] - x[6];
+ ci = x[5] + x[7];
+ di = x[5] - x[7];
+
+ sr = ar + cr;
+ ur = ar - cr;
+ si = ai + ci;
+ ui = ai - ci;
+ tr = br - di;
+ vr = br + di;
+ ti = bi + dr;
+ vi = bi - dr;
+
+ ar = x[ 8] + x[10];
+ br = x[ 8] - x[10];
+ ai = x[ 9] + x[11];
+ bi = x[ 9] - x[11];
+ cr = x[12] + x[14];
+ dr = x[12] - x[14];
+ ci = x[13] + x[15];
+ di = x[13] - x[15];
+
+ /* max gain of wr/wi/yr/yi vs input = 2
+ * (sum of 4 samples >> 1)
+ */
+ wr = (ar + cr) >> 1;
+ yr = (ar - cr) >> 1;
+ wi = (ai + ci) >> 1;
+ yi = (ai - ci) >> 1;
+
+ /* max gain of output vs input = 4
+ * (sum of 4 samples >> 1 + sum of 4 samples >> 1)
+ */
+ x[ 0] = (sr >> 1) + wr;
+ x[ 8] = (sr >> 1) - wr;
+ x[ 1] = (si >> 1) + wi;
+ x[ 9] = (si >> 1) - wi;
+ x[ 4] = (ur >> 1) + yi;
+ x[12] = (ur >> 1) - yi;
+ x[ 5] = (ui >> 1) - yr;
+ x[13] = (ui >> 1) + yr;
+
+ ar = br - di;
+ cr = br + di;
+ ai = bi + dr;
+ ci = bi - dr;
+
+ /* max gain of xr/xi/zr/zi vs input = 4*sqrt(2)/2 = 2*sqrt(2)
+ * (sum of 8 samples, multiply by sqrt(2)/2, implicit >> 1 from Q31)
+ */
+ xr = MULSHIFT32(SQRT1_2, ar - ai);
+ xi = MULSHIFT32(SQRT1_2, ar + ai);
+ zr = MULSHIFT32(SQRT1_2, cr - ci);
+ zi = MULSHIFT32(SQRT1_2, cr + ci);
+
+ /* max gain of output vs input = (2 + 2*sqrt(2) ~= 4.83)
+ * (sum of 4 samples >> 1, plus xr/xi/zr/zi with gain of 2*sqrt(2))
+ * in absolute terms, we have max gain of appx 9.656 (4 + 0.707*8)
+ * but we also gain 1 int bit (from MULSHIFT32 or from explicit >> 1)
+ */
+ x[ 6] = (tr >> 1) - xr;
+ x[14] = (tr >> 1) + xr;
+ x[ 7] = (ti >> 1) - xi;
+ x[15] = (ti >> 1) + xi;
+ x[ 2] = (vr >> 1) + zi;
+ x[10] = (vr >> 1) - zi;
+ x[ 3] = (vi >> 1) - zr;
+ x[11] = (vi >> 1) + zr;
+
+ x += 16;
+ }
+}
+
+/**************************************************************************************
+ * Function: R4Core
+ *
+ * Description: radix-4 pass for decimation-in-time FFT
+ *
+ * Inputs: buffer of samples
+ * number of R4 butterflies per group
+ * number of R4 groups per pass
+ * pointer to twiddle factors tables
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: gain 2 integer bits per pass (see scaling comments in code)
+ * min 1 GB in
+ * gbOut = gbIn - 1 (short block) or gbIn - 2 (long block)
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ **************************************************************************************/
+static void R4Core(int *x, int bg, int gp, int *wtab)
+{
+ int ar, ai, br, bi, cr, ci, dr, di, tr, ti;
+ int wd, ws, wi;
+ int i, j, step;
+ int *xptr, *wptr;
+
+ for (; bg != 0; gp <<= 2, bg >>= 2) {
+
+ step = 2 * gp;
+ xptr = x;
+
+ /* max per-sample gain, per group < 1 + 3*sqrt(2) ~= 5.25 if inputs x are full-scale
+ * do 3 groups for long block, 2 groups for short block (gain 2 int bits per group)
+ *
+ * very conservative scaling:
+ * group 1: max gain = 5.25, int bits gained = 2, gb used = 1 (2^3 = 8)
+ * group 2: max gain = 5.25^2 = 27.6, int bits gained = 4, gb used = 1 (2^5 = 32)
+ * group 3: max gain = 5.25^3 = 144.7, int bits gained = 6, gb used = 2 (2^8 = 256)
+ */
+ for (i = bg; i != 0; i--) {
+
+ wptr = wtab;
+
+ for (j = gp; j != 0; j--) {
+
+ ar = xptr[0];
+ ai = xptr[1];
+ xptr += step;
+
+ /* gain 2 int bits for br/bi, cr/ci, dr/di (MULSHIFT32 by Q30)
+ * gain 1 net GB
+ */
+ ws = wptr[0];
+ wi = wptr[1];
+ br = xptr[0];
+ bi = xptr[1];
+ wd = ws + 2 * wi;
+ tr = MULSHIFT32(wi, br + bi);
+ br = MULSHIFT32(wd, br) - tr; /* cos*br + sin*bi */
+ bi = MULSHIFT32(ws, bi) + tr; /* cos*bi - sin*br */
+ xptr += step;
+
+ ws = wptr[2];
+ wi = wptr[3];
+ cr = xptr[0];
+ ci = xptr[1];
+ wd = ws + 2 * wi;
+ tr = MULSHIFT32(wi, cr + ci);
+ cr = MULSHIFT32(wd, cr) - tr;
+ ci = MULSHIFT32(ws, ci) + tr;
+ xptr += step;
+
+ ws = wptr[4];
+ wi = wptr[5];
+ dr = xptr[0];
+ di = xptr[1];
+ wd = ws + 2 * wi;
+ tr = MULSHIFT32(wi, dr + di);
+ dr = MULSHIFT32(wd, dr) - tr;
+ di = MULSHIFT32(ws, di) + tr;
+ wptr += 6;
+
+ tr = ar;
+ ti = ai;
+ ar = (tr >> 2) - br;
+ ai = (ti >> 2) - bi;
+ br = (tr >> 2) + br;
+ bi = (ti >> 2) + bi;
+
+ tr = cr;
+ ti = ci;
+ cr = tr + dr;
+ ci = di - ti;
+ dr = tr - dr;
+ di = di + ti;
+
+ xptr[0] = ar + ci;
+ xptr[1] = ai + dr;
+ xptr -= step;
+ xptr[0] = br - cr;
+ xptr[1] = bi - di;
+ xptr -= step;
+ xptr[0] = ar - ci;
+ xptr[1] = ai - dr;
+ xptr -= step;
+ xptr[0] = br + cr;
+ xptr[1] = bi + di;
+ xptr += 2;
+ }
+ xptr += 3 * step;
+ }
+ wtab += 3 * step;
+ }
+}
+
+
+/**************************************************************************************
+ * Function: R4FFT
+ *
+ * Description: Ken's very fast in-place radix-4 decimation-in-time FFT
+ *
+ * Inputs: table index (for transform size)
+ * buffer of samples (non bit-reversed)
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 5 guard bits in for nfft <= 512
+ * gbOut = gbIn - 4 (assuming input is from PreMultiply)
+ * gains log2(nfft) - 2 int bits total
+ * so gain 7 int bits (LONG), 4 int bits (SHORT)
+ **************************************************************************************/
+void R4FFT(int tabidx, int *x)
+{
+ int order = nfftlog2Tab[tabidx];
+ int nfft = nfftTab[tabidx];
+
+ /* decimation in time */
+ BitReverse(x, tabidx);
+
+ if (order & 0x1) {
+ /* long block: order = 9, nfft = 512 */
+ R8FirstPass(x, nfft >> 3); /* gain 1 int bit, lose 2 GB */
+ R4Core(x, nfft >> 5, 8, (int *)twidTabOdd); /* gain 6 int bits, lose 2 GB */
+ } else {
+ /* short block: order = 6, nfft = 64 */
+ R4FirstPass(x, nfft >> 2); /* gain 0 int bits, lose 2 GB */
+ R4Core(x, nfft >> 4, 4, (int *)twidTabEven); /* gain 4 int bits, lose 1 GB */
+ }
+}
diff --git a/audio_codec/wfd_aac_decoder/filefmt.c b/audio_codec/wfd_aac_decoder/filefmt.c
new file mode 100644
index 0000000..9db47d4
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/filefmt.c
@@ -0,0 +1,539 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: filefmt.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * filefmt.c - ADIF and ADTS header decoding, raw block handling
+ **************************************************************************************/
+
+#include "coder.h"
+#include <stdio.h>
+
+/**************************************************************************************
+* Function: UnpackADTSHeader
+*
+* Description: parse the ADTS frame header and initialize decoder state
+*
+* Inputs: valid AACDecInfo struct
+* double pointer to buffer with complete ADTS frame header (byte aligned)
+* header size = 7 bytes, plus 2 if CRC
+*
+* Outputs: filled in ADTS struct
+* updated buffer pointer
+* updated bit offset
+* updated number of available bits
+*
+* Return: 0 if successful, error code (< 0) if error
+*
+* TODO: test CRC
+* verify that fixed fields don't change between frames
+**************************************************************************************/
+int UnpackADTSHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail)
+{
+ int bitsUsed;
+ PSInfoBase *psi;
+ BitStreamInfo bsi;
+ ADTSHeader *fhADTS;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ fhADTS = &(psi->fhADTS);
+
+ if (AACDataSource == 1) {
+ /* init bitstream reader */
+ SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf);
+ GetBits(&bsi, *bitOffset);
+
+ /* verify that first 12 bits of header are syncword */
+ if (GetBits(&bsi, 12) != 0x0fff) {
+ return ERR_AAC_INVALID_ADTS_HEADER;
+ }
+ }
+ /* fixed fields - should not change from frame to frame */
+ fhADTS->id = GetBits(&bsi, 1);
+ fhADTS->layer = GetBits(&bsi, 2);
+ fhADTS->protectBit = GetBits(&bsi, 1);
+ fhADTS->profile = GetBits(&bsi, 2);
+ fhADTS->sampRateIdx = GetBits(&bsi, 4);
+ fhADTS->privateBit = GetBits(&bsi, 1);
+ fhADTS->channelConfig = GetBits(&bsi, 3);
+ fhADTS->origCopy = GetBits(&bsi, 1);
+ fhADTS->home = GetBits(&bsi, 1);
+
+ /* variable fields - can change from frame to frame */
+ fhADTS->copyBit = GetBits(&bsi, 1);
+ fhADTS->copyStart = GetBits(&bsi, 1);
+ fhADTS->frameLength = GetBits(&bsi, 13);
+ fhADTS->bufferFull = GetBits(&bsi, 11);
+ fhADTS->numRawDataBlocks = GetBits(&bsi, 2) + 1;
+
+ /* note - MPEG4 spec, correction 1 changes how CRC is handled when protectBit == 0 and numRawDataBlocks > 1 */
+ if (fhADTS->protectBit == 0) {
+ fhADTS->crcCheckWord = GetBits(&bsi, 16);
+ }
+
+ /* byte align */
+ ByteAlignBitstream(&bsi); /* should always be aligned anyway */
+
+ /* check validity of header */
+ if (fhADTS->layer != 0 || fhADTS->profile != AAC_PROFILE_LC ||
+ fhADTS->sampRateIdx >= NUM_SAMPLE_RATES || fhADTS->channelConfig >= NUM_DEF_CHAN_MAPS) {
+ return ERR_AAC_INVALID_ADTS_HEADER;
+ }
+
+#ifndef AAC_ENABLE_MPEG4
+ if (fhADTS->id != 1) {
+ return ERR_AAC_MPEG4_UNSUPPORTED;
+ }
+#endif
+
+ /* update codec info */
+ psi->sampRateIdx = fhADTS->sampRateIdx;
+ if (!psi->useImpChanMap) {
+ psi->nChans = channelMapTab[fhADTS->channelConfig];
+ }
+
+ /* syntactic element fields will be read from bitstream for each element */
+ aacDecInfo->prevBlockID = AAC_ID_INVALID;
+ aacDecInfo->currBlockID = AAC_ID_INVALID;
+ aacDecInfo->currInstTag = -1;
+
+ /* fill in user-accessible data (TODO - calc bitrate, handle tricky channel config cases) */
+ aacDecInfo->bitRate = 0;
+ aacDecInfo->nChans = psi->nChans;
+ aacDecInfo->sampRate = sampRateTab[psi->sampRateIdx];
+ aacDecInfo->profile = fhADTS->profile;
+ aacDecInfo->sbrEnabled = 0;
+ aacDecInfo->adtsBlocksLeft = fhADTS->numRawDataBlocks;
+ aacDecInfo->frame_length = fhADTS->frameLength;
+ if (AACDataSource == 1) {
+ /* update bitstream reader */
+ bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset);
+ *buf += (bitsUsed + *bitOffset) >> 3;
+ *bitOffset = (bitsUsed + *bitOffset) & 0x07;
+ *bitsAvail -= bitsUsed ;
+ if (*bitsAvail < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: GetADTSChannelMapping
+ *
+ * Description: determine the number of channels from implicit mapping rules
+ *
+ * Inputs: valid AACDecInfo struct
+ * pointer to start of raw_data_block
+ * bit offset
+ * bits available
+ *
+ * Outputs: updated number of channels
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: calculates total number of channels using rules in 14496-3, 4.5.1.2.1
+ * does not attempt to deduce speaker geometry
+ **************************************************************************************/
+int GetADTSChannelMapping(AACDecInfo *aacDecInfo, unsigned char *buf, int bitOffset, int bitsAvail)
+{
+ int ch, nChans, elementChans, err;
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ nChans = 0;
+ do {
+ /* parse next syntactic element */
+ err = DecodeNextElement(aacDecInfo, &buf, &bitOffset, &bitsAvail);
+ if (err) {
+ return err;
+ }
+
+ elementChans = elementNumChans[aacDecInfo->currBlockID];
+ nChans += elementChans;
+
+ for (ch = 0; ch < elementChans; ch++) {
+ err = DecodeNoiselessData(aacDecInfo, &buf, &bitOffset, &bitsAvail, ch);
+ if (err) {
+ return err;
+ }
+ }
+ } while (aacDecInfo->currBlockID != AAC_ID_END);
+
+ if (nChans <= 0) {
+ return ERR_AAC_CHANNEL_MAP;
+ }
+
+ /* update number of channels in codec state and user-accessible info structs */
+ psi->nChans = nChans;
+ aacDecInfo->nChans = psi->nChans;
+ psi->useImpChanMap = 1;
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: GetNumChannelsADIF
+ *
+ * Description: get number of channels from program config elements in an ADIF file
+ *
+ * Inputs: array of filled-in program config element structures
+ * number of PCE's
+ *
+ * Outputs: none
+ *
+ * Return: total number of channels in file
+ * -1 if error (invalid number of PCE's or unsupported mode)
+ **************************************************************************************/
+static int GetNumChannelsADIF(ProgConfigElement *fhPCE, int nPCE)
+{
+ int i, j, nChans;
+
+ if (nPCE < 1 || nPCE > MAX_NUM_PCE_ADIF) {
+ return -1;
+ }
+
+ nChans = 0;
+ for (i = 0; i < nPCE; i++) {
+ /* for now: only support LC, no channel coupling */
+#if 0
+ if (fhPCE[i].profile != AAC_PROFILE_LC || fhPCE[i].numCCE > 0) {
+ return -1;
+ }
+#endif
+
+ /* add up number of channels in all channel elements (assume all single-channel) */
+ nChans += fhPCE[i].numFCE;
+ nChans += fhPCE[i].numSCE;
+ nChans += fhPCE[i].numBCE;
+ nChans += fhPCE[i].numLCE;
+
+ /* add one more for every element which is a channel pair */
+ for (j = 0; j < fhPCE[i].numFCE; j++) {
+ if (CHAN_ELEM_IS_CPE(fhPCE[i].fce[j])) {
+ nChans++;
+ }
+ }
+ for (j = 0; j < fhPCE[i].numSCE; j++) {
+ if (CHAN_ELEM_IS_CPE(fhPCE[i].sce[j])) {
+ nChans++;
+ }
+ }
+ for (j = 0; j < fhPCE[i].numBCE; j++) {
+ if (CHAN_ELEM_IS_CPE(fhPCE[i].bce[j])) {
+ nChans++;
+ }
+ }
+
+ }
+
+ return nChans;
+}
+
+/**************************************************************************************
+ * Function: GetSampleRateIdxADIF
+ *
+ * Description: get sampling rate index from program config elements in an ADIF file
+ *
+ * Inputs: array of filled-in program config element structures
+ * number of PCE's
+ *
+ * Outputs: none
+ *
+ * Return: sample rate of file
+ * -1 if error (invalid number of PCE's or sample rate mismatch)
+ **************************************************************************************/
+static int GetSampleRateIdxADIF(ProgConfigElement *fhPCE, int nPCE)
+{
+ int i, idx;
+
+ if (nPCE < 1 || nPCE > MAX_NUM_PCE_ADIF) {
+ return -1;
+ }
+
+ /* make sure all PCE's have the same sample rate */
+ idx = fhPCE[0].sampRateIdx;
+ for (i = 1; i < nPCE; i++) {
+ if (fhPCE[i].sampRateIdx != idx) {
+ return -1;
+ }
+ }
+
+ return idx;
+}
+
+/**************************************************************************************
+ * Function: UnpackADIFHeader
+ *
+ * Description: parse the ADIF file header and initialize decoder state
+ *
+ * Inputs: valid AACDecInfo struct
+ * double pointer to buffer with complete ADIF header
+ * (starting at 'A' in 'ADIF' tag)
+ * pointer to bit offset
+ * pointer to number of valid bits remaining in inbuf
+ *
+ * Outputs: filled-in ADIF struct
+ * updated buffer pointer
+ * updated bit offset
+ * updated number of available bits
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int UnpackADIFHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail)
+{
+ int i, bitsUsed;
+ PSInfoBase *psi;
+ BitStreamInfo bsi;
+ ADIFHeader *fhADIF;
+ ProgConfigElement *pce;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ if (AACDataSource == 1) {
+ /* init bitstream reader */
+ SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf);
+ GetBits(&bsi, *bitOffset);
+ }
+
+ /* unpack ADIF file header */
+ fhADIF = &(psi->fhADIF);
+ pce = psi->pce;
+
+ /* verify that first 32 bits of header are "ADIF" */
+ if (GetBits(&bsi, 8) != 'A' || GetBits(&bsi, 8) != 'D' || GetBits(&bsi, 8) != 'I' || GetBits(&bsi, 8) != 'F') {
+ return ERR_AAC_INVALID_ADIF_HEADER;
+ }
+
+ /* read ADIF header fields */
+ fhADIF->copyBit = GetBits(&bsi, 1);
+ if (fhADIF->copyBit) {
+ for (i = 0; i < ADIF_COPYID_SIZE; i++) {
+ fhADIF->copyID[i] = GetBits(&bsi, 8);
+ }
+ }
+ fhADIF->origCopy = GetBits(&bsi, 1);
+ fhADIF->home = GetBits(&bsi, 1);
+ fhADIF->bsType = GetBits(&bsi, 1);
+ fhADIF->bitRate = GetBits(&bsi, 23);
+ fhADIF->numPCE = GetBits(&bsi, 4) + 1; /* add 1 (so range = [1, 16]) */
+
+ //if (fhADIF->bsType == 0)
+ // fhADIF->bufferFull = GetBits(&bsi, 20);
+
+ /* parse all program config elements */
+ for (i = 0; i < fhADIF->numPCE; i++) {
+ if (fhADIF->bsType == 0) {
+ fhADIF->bufferFull = GetBits(&bsi, 20);
+ } else {
+ fhADIF->bufferFull = 0;
+ }
+ DecodeProgramConfigElement(pce + i, &bsi);
+
+ }
+
+ /* byte align */
+ ByteAlignBitstream(&bsi);
+
+ /* update codec info */
+ psi->nChans = GetNumChannelsADIF(pce, 1/*fhADIF->numPCE*/);
+ psi->sampRateIdx = GetSampleRateIdxADIF(pce, fhADIF->numPCE);
+
+ /* check validity of header */
+ if (psi->nChans < 0 || psi->sampRateIdx < 0 || psi->sampRateIdx >= NUM_SAMPLE_RATES) {
+ return ERR_AAC_INVALID_ADIF_HEADER;
+ }
+
+ /* syntactic element fields will be read from bitstream for each element */
+ aacDecInfo->prevBlockID = AAC_ID_INVALID;
+ aacDecInfo->currBlockID = AAC_ID_INVALID;
+ aacDecInfo->currInstTag = -1;
+
+ /* fill in user-accessible data */
+ aacDecInfo->bitRate = fhADIF->bitRate;
+ aacDecInfo->nChans = psi->nChans;
+ aacDecInfo->sampRate = sampRateTab[psi->sampRateIdx];
+ aacDecInfo->profile = pce[0].profile;
+ aacDecInfo->sbrEnabled = 0;
+
+ if (AACDataSource == 1) {
+ /* update bitstream reader */
+ bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset);
+ *buf += (bitsUsed + *bitOffset) >> 3;
+ *bitOffset = (bitsUsed + *bitOffset) & 0x07;
+ *bitsAvail -= bitsUsed ;
+ if (*bitsAvail < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: SetRawBlockParams
+ *
+ * Description: set internal state variables for decoding a stream of raw data blocks
+ *
+ * Inputs: valid AACDecInfo struct
+ * flag indicating source of parameters (from previous headers or passed
+ * explicitly by caller)
+ * number of channels
+ * sample rate
+ * profile ID
+ *
+ * Outputs: updated state variables in aacDecInfo
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: if copyLast == 1, then psi->nChans, psi->sampRateIdx, and
+ * aacDecInfo->profile are not changed (it's assumed that we already
+ * set them, such as by a previous call to UnpackADTSHeader())
+ * if copyLast == 0, then the parameters we passed in are used instead
+ **************************************************************************************/
+int SetRawBlockParams(AACDecInfo *aacDecInfo, int copyLast, int nChans, int sampRate, int profile)
+{
+ int idx;
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ if (!copyLast) {
+ aacDecInfo->profile = profile;
+ psi->nChans = nChans;
+ for (idx = 0; idx < NUM_SAMPLE_RATES; idx++) {
+ if (sampRate == sampRateTab[idx]) {
+ psi->sampRateIdx = idx;
+ break;
+ }
+ }
+ if (idx == NUM_SAMPLE_RATES) {
+ return ERR_AAC_INVALID_FRAME;
+ }
+ }
+ aacDecInfo->nChans = psi->nChans;
+ aacDecInfo->sampRate = sampRateTab[psi->sampRateIdx];
+
+ /* check validity of header */
+ if (psi->sampRateIdx >= NUM_SAMPLE_RATES || psi->sampRateIdx < 0 || aacDecInfo->profile != AAC_PROFILE_LC) {
+ return ERR_AAC_RAWBLOCK_PARAMS;
+ }
+
+ return ERR_AAC_NONE;
+}
+/**************************************************************************************
+ * Function: PrepareRawBlock
+ *
+ * Description: reset per-block state variables for raw blocks (no ADTS/ADIF headers)
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: updated state variables in aacDecInfo
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int PrepareRawBlock(AACDecInfo *aacDecInfo)
+{
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ /* syntactic element fields will be read from bitstream for each element */
+ aacDecInfo->prevBlockID = AAC_ID_INVALID;
+ aacDecInfo->currBlockID = AAC_ID_INVALID;
+ aacDecInfo->currInstTag = -1;
+
+ /* fill in user-accessible data */
+ aacDecInfo->bitRate = 0;
+ aacDecInfo->sbrEnabled = 0;
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: FlushCodec
+ *
+ * Description: flush internal codec state (after seeking, for example)
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: updated state variables in aacDecInfo
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: only need to clear data which is persistent between frames
+ * (such as overlap buffer)
+ **************************************************************************************/
+int FlushCodec(AACDecInfo *aacDecInfo)
+{
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ ClearBuffer(psi->overlap, AAC_MAX_NCHANS * AAC_MAX_NSAMPS * sizeof(int));
+ ClearBuffer(psi->prevWinShape, AAC_MAX_NCHANS * sizeof(int));
+
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/wfd_aac_decoder/helix_aac_decode.c b/audio_codec/wfd_aac_decoder/helix_aac_decode.c
new file mode 100644
index 0000000..ae32386
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/helix_aac_decode.c
@@ -0,0 +1,548 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <dlfcn.h>
+#include <sys/mman.h>
+#include <cutils/properties.h>
+
+
+
+#include "aaccommon.h"
+#include "aacdec.h"
+#include "../../amadec/adec-armdec-mgt.h"
+
+
+int AACDataSource = 1;
+static HAACDecoder hAACDecoder;
+static HAACIOBuf hAACIOBuf = NULL;
+
+static int mute_pcm_bytes;
+/* check the normal frame size */
+static unsigned last_frm_size;
+static unsigned cur_frm_size;
+static int lastFrameLen ;
+static int lastSampPerFrm ;
+
+#define FRAME_RECORD_NUM 20
+static unsigned error_count = 0;
+static unsigned mute_pcm_thread;
+static unsigned his_index;
+static unsigned frame_length_his[FRAME_RECORD_NUM];
+
+static unsigned stream_in_offset = 0;
+static unsigned enable_debug_print = 0;
+/* Channel definitions */
+#define FRONT_CENTER (0)
+#define FRONT_LEFT (1)
+#define FRONT_RIGHT (2)
+#define SIDE_LEFT (3)
+#define SIDE_RIGHT (4)
+#define BACK_LEFT (5)
+#define LFE_CHANNEL (6)
+
+
+
+
+
+#define ASTREAM_DEV "/dev/uio0"
+#define ASTREAM_ADDR "/sys/class/astream/astream-dev/uio0/maps/map0/addr"
+#define ASTREAM_SIZE "/sys/class/astream/astream-dev/uio0/maps/map0/size"
+#define ASTREAM_OFFSET "/sys/class/astream/astream-dev/uio0/maps/map0/offset"
+
+
+
+#define AIU_AIFIFO_CTRL 0x1580
+#define AIU_AIFIFO_STATUS 0x1581
+#define AIU_AIFIFO_GBIT 0x1582
+#define AIU_AIFIFO_CLB 0x1583
+#define AIU_MEM_AIFIFO_START_PTR 0x1584
+#define AIU_MEM_AIFIFO_CURR_PTR 0x1585
+#define AIU_MEM_AIFIFO_END_PTR 0x1586
+#define AIU_MEM_AIFIFO_BYTES_AVAIL 0x1587
+#define AIU_MEM_AIFIFO_CONTROL 0x1588
+#define AIU_MEM_AIFIFO_MAN_WP 0x1589
+#define AIU_MEM_AIFIFO_MAN_RP 0x158a
+#define AIU_MEM_AIFIFO_LEVEL 0x158b
+#define AIU_MEM_AIFIFO_BUF_CNTL 0x158c
+#define AIU_MEM_AIFIFO_BUF_WRAP_COUNT 0x158d
+#define AIU_MEM_AIFIFO2_BUF_WRAP_COUNT 0x158e
+#define AIU_MEM_AIFIFO_MEM_CTL 0x158f
+
+volatile unsigned* reg_base = 0;
+#define READ_MPEG_REG(reg) reg_base[reg-AIU_AIFIFO_CTRL]
+#define WRITE_MPEG_REG(reg, val) reg_base[reg-AIU_AIFIFO_CTRL]=val
+#define AIFIFO_READY (((READ_MPEG_REG(AIU_MEM_AIFIFO_CONTROL)&(1<<9))))
+#define min(x,y) ((x<y)?(x):(y))
+static int fd_uio = -1;
+static volatile void *memmap = MAP_FAILED;
+static int phys_size;
+static volatile int exit_flag = 0;
+static unsigned long amsysfs_get_sysfs_ulong(const char *path)
+{
+ int fd;
+ char bcmd[24] = "";
+ unsigned long num = 0;
+ if ((fd = open(path, O_RDONLY)) >= 0) {
+ read(fd, bcmd, sizeof(bcmd));
+ num = strtoul(bcmd, NULL, 0);
+ close(fd);
+ } else {
+ audio_codec_print("unable to open file %s,", path);
+ }
+ return num;
+}
+static unsigned long get_num_infile(char *file)
+{
+ return amsysfs_get_sysfs_ulong(file);
+}
+
+static int uio_init()
+{
+ int pagesize = getpagesize();
+ int phys_start;
+ int phys_offset;
+
+
+ fd_uio = open(ASTREAM_DEV, O_RDWR);
+ if (fd_uio < 0) {
+ audio_codec_print("error open UIO 0\n");
+ return -1;
+ }
+ phys_start = get_num_infile(ASTREAM_ADDR);
+ phys_size = get_num_infile(ASTREAM_SIZE);
+ phys_offset = get_num_infile(ASTREAM_OFFSET);
+
+ audio_codec_print("add=%08x, size=%08x, offset=%08x\n", phys_start, phys_size, phys_offset);
+
+ phys_size = (phys_size + pagesize - 1) & (~(pagesize - 1));
+ memmap = mmap(NULL, phys_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_uio, 0 * pagesize);
+
+ audio_codec_print("memmap = %x , pagesize = %x\n", memmap, pagesize);
+ if (memmap == MAP_FAILED) {
+ audio_codec_print("map /dev/uio0 failed\n");
+ return -1;
+ }
+
+ if (phys_offset == 0)
+ phys_offset = (AIU_AIFIFO_CTRL*4)&(pagesize-1);
+ reg_base = memmap + phys_offset;
+ return 0;
+}
+
+#define EXTRA_DATA_SIZE 128
+
+static inline void waiting_bits(int bits)
+{
+ int bytes;
+ bytes = READ_MPEG_REG(AIU_MEM_AIFIFO_BYTES_AVAIL);
+ while (bytes * 8 < bits && !exit_flag) {
+ usleep(1000);
+ bytes = READ_MPEG_REG(AIU_MEM_AIFIFO_BYTES_AVAIL);
+ }
+}
+
+int read_buffer(unsigned char *buffer, int size)
+{
+ int bytes;
+ int len;
+ unsigned char *p = buffer;
+ int tmp;
+ int space;
+ int i;
+ int wait_times = 0, fifo_ready_wait = 0;
+
+ int iii;
+
+ iii = READ_MPEG_REG(AIU_MEM_AIFIFO_LEVEL) - EXTRA_DATA_SIZE;
+ if ((size >= iii)) {
+ return 0;
+ }
+
+ // adec_print("read_buffer start while iii= %d!!\n", iii);
+ for (len = 0; len < size;) {
+ space = (size - len);
+ bytes = READ_MPEG_REG(AIU_MEM_AIFIFO_BYTES_AVAIL);
+ //adec_print("read_buffer start AIU_MEM_AIFIFO_BYTES_AVAIL bytes= %d!!\n", bytes);
+ wait_times = 0;
+ while (bytes == 0) {
+ waiting_bits((space > 128) ? 128 * 8 : (space * 8)); /*wait 32 bytes,if the space is less than 32 bytes,wait the space bits*/
+ bytes = READ_MPEG_REG(AIU_MEM_AIFIFO_BYTES_AVAIL);
+
+ audio_codec_print("read_buffer while AIU_MEM_AIFIFO_BYTES_AVAIL = %d!!\n", bytes);
+ wait_times++;
+ if (wait_times > 10) {
+ audio_codec_print("goto out!!\n");
+ goto out;
+ }
+ }
+ bytes = min(space, bytes);
+
+ //adec_print("read_buffer while bytes = %d!!\n", bytes);
+ for (i = 0; i < bytes; i++) {
+ while (!AIFIFO_READY) {
+ fifo_ready_wait++;
+ usleep(1000);
+ if (fifo_ready_wait > 100) {
+ audio_codec_print("FATAL err,AIFIFO is not ready,check!!\n");
+ return 0;
+ }
+ }
+ WRITE_MPEG_REG(AIU_AIFIFO_GBIT, 8);
+ tmp = READ_MPEG_REG(AIU_AIFIFO_GBIT);
+ //adec_print("read_buffer while tmp = %d!!\n", tmp);
+
+ *p++ = tmp & 0xff;
+ fifo_ready_wait = 0;
+
+ }
+ len += bytes;
+ }
+out:
+ stream_in_offset += len;
+ return len;
+}
+int get_audiobuf_level()
+{
+ int level = 0;
+ level = READ_MPEG_REG(AIU_MEM_AIFIFO_LEVEL) - EXTRA_DATA_SIZE;
+ if (level < 0) {
+ level = 0;
+ }
+ return level;
+}
+
+
+static unsigned get_frame_size()
+{
+ int i;
+ unsigned sum = 0;
+ unsigned valid_his_num = 0;
+ for (i = 0; i < FRAME_RECORD_NUM; i++) {
+ if (frame_length_his[i] > 0) {
+ valid_his_num ++;
+ sum += frame_length_his[i];
+ }
+ }
+
+ if (valid_his_num == 0) {
+ return 0;
+ }
+
+ return sum / valid_his_num;
+}
+
+unsigned get_audio_inbuf_latency(int bytesin)
+{
+ int frame_size = 0;
+ int latency_ms = 0;
+ frame_size = get_frame_size();
+ if (frame_size > 0) {
+ latency_ms = bytesin * 1024 / (frame_size * 48);
+ }
+ return latency_ms;
+}
+
+static HAACDecoder aac_init_decoder()
+{
+ return AACInitDecoder();
+}
+static HAACIOBuf aac_init_iobuf()
+{
+ return (HAACIOBuf)calloc(1, sizeof(AACIOBuf));
+}
+#define AUDIO_BUFFER_REMAINED 128
+static void aac_refill_buffer(HAACIOBuf hIOBuf)
+{
+ AACIOBuf *IOBuf = (AACIOBuf*)hIOBuf;
+ int bytes_expected;
+ int read_bytes;
+ int read_level_count = 0;
+ int buf_level = 0;
+ int retry_time = 0;
+
+start_read:
+ if (exit_flag) {
+ return ;
+ }
+ do {
+ buf_level = get_audiobuf_level();
+ if (buf_level <= 0) {
+ break;
+ }
+
+ if (IOBuf->bytesLeft > 0) {
+ while (IOBuf->bytesLeft > AAC_INPUTBUF_SIZE) {
+ ;
+ }
+ memcpy(IOBuf->readBuf, IOBuf->readPtr, IOBuf->bytesLeft);
+ }
+
+ while (IOBuf->bytesLeft < 0) {
+ printk("IOBuf->bytesLeft < 0\n", IOBuf->bytesLeft);
+ }
+
+ bytes_expected = AAC_INPUTBUF_SIZE - IOBuf->bytesLeft;
+
+ while (bytes_expected < 0) {
+ printk("bytes_expected = %d\n", bytes_expected);
+ }
+
+ if (bytes_expected > buf_level) {
+ bytes_expected = buf_level;
+ }
+
+ read_bytes = read_buffer(IOBuf->readBuf + IOBuf->bytesLeft, bytes_expected);
+
+ IOBuf->readPtr = IOBuf->readBuf;
+ IOBuf->bytesLeft += read_bytes;
+ } while (0);
+ if (IOBuf->bytesLeft < get_frame_size()) {
+ goto start_read;
+ }
+}
+
+static int aac_reset_decoder(HAACDecoder hAACDecoder, HAACIOBuf hIOBuf)
+{
+ AACIOBuf *IOBuf = (AACIOBuf*)hIOBuf;
+ IOBuf->readPtr = IOBuf->readBuf;
+ IOBuf->bytesLeft = 0;
+ return AACFlushCodec(hAACDecoder);
+}
+static int aac_decode_frame(HAACDecoder hAACDecoder, HAACIOBuf hIOBuf)
+{
+ int err;
+ AACIOBuf *IOBuf = (AACIOBuf*)hIOBuf;
+ if (AACDataSource == 1) {
+ if (IOBuf->bytesLeft < AAC_INPUTBUF_SIZE / 2) {
+ aac_refill_buffer(IOBuf);
+ }
+ }
+ if (exit_flag) {
+ return ERR_AAC_EXIT_DECODE;
+ }
+ /* decode one AAC frame */
+ err = AACDecode(hAACDecoder, &(IOBuf->readPtr), &(IOBuf->bytesLeft), (IOBuf->outBuf));
+ return err;
+}
+int audio_dec_init(audio_decoder_operations_t *adp)
+{
+ //printk("\n\n[%s]WFDAAC DEC BuildDate--%s BuildTime--%s", __FUNCTION__, __DATE__, __TIME__);
+ char value[PROPERTY_VALUE_MAX];
+ if (property_get("media.wfd.debug_dec", value, NULL) > 0) {
+ enable_debug_print = atoi(value);
+ }
+ int err = 0, ch = 0, i;
+ AACFrameInfo aacFrameInfo = {0};
+ audio_codec_print("helix_aac_decoder_init start \n");
+ err = uio_init();
+ if (err) {
+ return -1;
+ }
+ hAACDecoder = aac_init_decoder();
+ if (!hAACDecoder) {
+ printk("fatal error,helix aac decoder init failed\n");
+ return -1;
+ }
+ hAACIOBuf = aac_init_iobuf();
+ if (!hAACIOBuf) {
+ printk("fatal error,helix aac decoder init iobuf failed\n");
+
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ channel configuration mapping
+ ch nums position
+ 3 FC FL FR
+ 4 FC FL FR BC
+ 5 FC FL FR BL BR
+ 6 FC FL FR BL BR LFE
+
+*/
+#define FATAL_ERR_RESET_COUNT 2000
+int audio_dec_decode(audio_decoder_operations_t *adec_ops, char *buf, int *outlen, char *inbuf, int inlen)
+{
+ int err, i, sample_out = 0, ch;
+ short *pcmbuf = (short*)buf;
+ short *ouput = (short*)(((AACIOBuf*)hAACIOBuf)->outBuf);
+ int ch_num;
+ int sum;
+ unsigned ch_map_scale[6] = {2, 4, 4, 2, 2, 0}; //full scale == 8
+ AACFrameInfo aacFrameInfo = {0};
+
+ err = aac_decode_frame(hAACDecoder, hAACIOBuf);
+ if (!err) {
+ error_count = 0;
+ AACGetLastFrameInfo(hAACDecoder, &aacFrameInfo);
+
+
+ /* L = (l+c)/2;R = (r+c)/2 */
+ if (aacFrameInfo.nChans > 2) { //should do downmix to 2ch output.
+ ch_num = aacFrameInfo.nChans;
+ sample_out = aacFrameInfo.outputSamps / ch_num * 2 * 2; //ch_num*sample_num*16bit
+ if (ch_num == 3 || ch_num == 4) {
+ ch_map_scale[0] = 4; //50%
+ ch_map_scale[1] = 4;//50%
+ ch_map_scale[2] = 4;//50%
+ ch_map_scale[3] = 0;
+ ch_map_scale[4] = 0;
+ ch_map_scale[5] = 0;
+ }
+ for (i = 0; i < aacFrameInfo.outputSamps / ch_num; i++) {
+ sum = ((int)ouput[ch_num * i + FRONT_LEFT] * ch_map_scale[FRONT_LEFT] + (int)ouput[ch_num * i + FRONT_CENTER] * ch_map_scale[FRONT_CENTER] + (int)ouput[ch_num * i + BACK_LEFT] * ch_map_scale[BACK_LEFT]);
+ pcmbuf[i * 2] = sum >> 3;
+ sum = ((int)ouput[ch_num * i + FRONT_RIGHT] * ch_map_scale[FRONT_RIGHT] + (int)ouput[ch_num * i + FRONT_CENTER] * ch_map_scale[FRONT_CENTER] + (int)ouput[ch_num * i + BACK_LEFT] * ch_map_scale[BACK_LEFT]);
+ pcmbuf[2 * i + 1] = sum >> 3;
+ }
+ } else {
+ memcpy(pcmbuf, ouput, aacFrameInfo.outputSamps * 2);
+ sample_out = aacFrameInfo.outputSamps * 2; //ch_num*sample_num*16bit
+ }
+
+ AACGetDecoderInfo(hAACDecoder, &aacFrameInfo);
+ // fmt->total_byte_parsed = aacFrameInfo.total_byte_parsed;
+ // fmt->total_sample_decoded = aacFrameInfo.total_sample_decoded;
+ // fmt->format = aacFrameInfo.format;
+ // fmt->bps = aacFrameInfo.bitRate;
+
+ lastFrameLen = ((AACDecInfo*)hAACDecoder)->frame_length;
+ /* record the frame length into the history buffer */
+ for (i = 0; i < FRAME_RECORD_NUM - 1; i++) {
+ frame_length_his[i] = frame_length_his[i + 1];
+ }
+ frame_length_his[FRAME_RECORD_NUM - 1] = lastFrameLen;
+ unsigned abuf_level = get_audiobuf_level();
+ unsigned dec_cached = ((AACIOBuf*)hAACIOBuf)->bytesLeft;
+ unsigned in_latency_ms = get_audio_inbuf_latency(abuf_level + dec_cached);
+ if (enable_debug_print)
+ printk("sampRateCore %d,sampRateOut %d,last frame len %d,avarge frame size %d,decode out sample %d,buf level %d,decode cached %d,total level %d ;latency %d ms \n", \
+ aacFrameInfo.sampRateCore, aacFrameInfo.sampRateOut, \
+ lastFrameLen, get_frame_size(), sample_out, \
+ abuf_level, dec_cached, abuf_level + dec_cached, in_latency_ms);
+ memcpy(inbuf, &in_latency_ms, sizeof(in_latency_ms));
+ lastSampPerFrm = sample_out;
+ adec_ops->samplerate = aacFrameInfo.sampRateOut;
+ adec_ops->channels = aacFrameInfo.nChans > 2 ? 2 : aacFrameInfo.nChans;
+ } else if (err == ERR_AAC_INDATA_UNDERFLOW) {
+ aac_refill_buffer(hAACIOBuf);
+ }
+ /* why add this ????
+ else if (err==ERR_AAC_NCHANS_TOO_HIGH)
+ {
+ //maybe we meet zero frame
+ ((AACIOBuf*)hAACIOBuf)->bytesLeft =0;
+ sample_out =0;
+ }
+ */
+ else if (err == ERR_AAC_EXIT_DECODE) {
+ sample_out = 0;
+ } else {
+ int frame_length;
+ if (ERR_AAC_SSR_GAIN_NOT_ADDED != err) {
+ error_count++;
+ }
+ // error, disable output, reset decoder and flush io
+ if (/*!mute_frame_num*/(error_count % 20) == 1) { //only print the every 20 times error
+#if 0
+ printk("helix aac decoder error,err num :%d,try output 40 mute frames and skip err bitstream\n", err);
+ printk("frame_length = %d\n", get_frame_size());
+ printk("sames per frame: %d\n", lastSampPerFrm);
+#endif
+ }
+ if (error_count == FATAL_ERR_RESET_COUNT) { // send to player to reset the player
+ printk("decoder error count FATAL_ERR_RESET_COUNT %s\n", FATAL_ERR_RESET_COUNT);
+ // trans_err_code(DECODE_FATAL_ERR);
+ }
+ //aac_reset_decoder(hAACDecoder, hAACIOBuf);
+ // AACFlushCodec(hAACDecoder);
+ frame_length = get_frame_size() * 2 / 3/*((AACDecInfo*)hAACDecoder)->frame_length*/; //skip 2/3 of last frame size
+ if (AACDataSource) {
+ if (frame_length > 0) {
+ if (((AACIOBuf*)hAACIOBuf)->bytesLeft > frame_length) {
+ ((AACIOBuf*)hAACIOBuf)->bytesLeft -= frame_length;
+ ((AACIOBuf*)hAACIOBuf)->readPtr += frame_length;
+ // printk("skip1 %d bytes \n",frame_length);
+ } else {
+ // printk("skip2 %d bytes \n",((AACIOBuf*)hAACIOBuf)->bytesLeft);
+
+ ((AACIOBuf*)hAACIOBuf)->readPtr = ((AACIOBuf*)hAACIOBuf)->readBuf;
+ ((AACIOBuf*)hAACIOBuf)->bytesLeft = 0;
+
+ }
+ } else {
+ if (((AACIOBuf*)hAACIOBuf)->bytesLeft > 100) {
+ ((AACIOBuf*)hAACIOBuf)->bytesLeft -= 100;
+ ((AACIOBuf*)hAACIOBuf)->readPtr += 100;
+
+ // printk("skip3 %d bytes \n",100);
+ } else {
+ // printk("skip4 %d bytes \n",((AACIOBuf*)hAACIOBuf)->bytesLeft);
+
+ ((AACIOBuf*)hAACIOBuf)->readPtr = ((AACIOBuf*)hAACIOBuf)->readBuf;
+ ((AACIOBuf*)hAACIOBuf)->bytesLeft = 0;
+
+ }
+ }
+ }
+
+ sample_out = 0;//lastSampPerFrm/*fmt->channel_num*2*1024*/;
+ mute_pcm_bytes = mute_pcm_thread;
+ }
+ if (sample_out && mute_pcm_bytes > 0) {
+ memset(buf, 0, sample_out);
+ mute_pcm_bytes -= sample_out;
+ }
+ if (!err) {
+ mute_pcm_thread = 0;
+
+ }
+
+
+ *outlen = sample_out;
+ return stream_in_offset;
+}
+
+int audio_dec_release(audio_decoder_operations_t *adec_ops)
+{
+#if 0
+ if (hAACIOBuf) {
+ free(hAACIOBuf);
+ hAACIOBuf = NULL;
+ }
+ if (hAACDecoder) {
+ AACFreeDecoder(hAACDecoder);
+ hAACDecoder = NULL;
+ }
+#endif
+ if (fd_uio >= 0) {
+ close(fd_uio);
+ }
+ fd_uio = -1;
+ if (memmap != NULL && memmap != MAP_FAILED) {
+ munmap(memmap, phys_size);
+ }
+ printk("WFDAAC audio_dec_release done \n");
+ return 0;
+}
+int audio_dec_getinfo(audio_decoder_operations_t *adec_ops, void *pAudioInfo)
+{
+ return 0;
+}
+
+
+void audio_set_exit_flag()
+{
+ exit_flag = 1;
+ printk("adec decode exit flag set \n");
+}
+
+
+
+
diff --git a/audio_codec/wfd_aac_decoder/huffman.c b/audio_codec/wfd_aac_decoder/huffman.c
new file mode 100644
index 0000000..fdf310f
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/huffman.c
@@ -0,0 +1,450 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: huffman.c,v 1.2 2005/05/24 16:01:55 albertofloyd Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * huffman.c - Huffman decoding
+ **************************************************************************************/
+
+#include "coder.h"
+
+/**************************************************************************************
+ * Function: DecodeHuffmanScalar
+ *
+ * Description: decode one Huffman symbol from bitstream
+ *
+ * Inputs: pointers to Huffman table and info struct
+ * left-aligned bit buffer with >= huffTabInfo->maxBits bits
+ *
+ * Outputs: decoded symbol in *val
+ *
+ * Return: number of bits in symbol
+ *
+ * Notes: assumes canonical Huffman codes:
+ * first CW always 0, we have "count" CW's of length "nBits" bits
+ * starting CW for codes of length nBits+1 =
+ * (startCW[nBits] + count[nBits]) << 1
+ * if there are no codes at nBits, then we just keep << 1 each time
+ * (since count[nBits] = 0)
+ **************************************************************************************/
+int DecodeHuffmanScalar(const signed short *huffTab, const HuffInfo *huffTabInfo, unsigned int bitBuf, signed int *val)
+{
+ unsigned int count, start, shift, t;
+ const unsigned char *countPtr;
+ const signed short *map;
+
+ map = huffTab + huffTabInfo->offset;
+ countPtr = huffTabInfo->count;
+
+ start = 0;
+ count = 0;
+ shift = 32;
+ do {
+ start += count;
+ start <<= 1;
+ map += count;
+ count = *countPtr++;
+ shift--;
+ t = (bitBuf >> shift) - start;
+ } while (t >= count);
+
+ *val = (signed int)map[t];
+ return (countPtr - huffTabInfo->count);
+}
+
+#define APPLY_SIGN(v, s) {(v) ^= ((signed int)(s) >> 31); (v) -= ((signed int)(s) >> 31);}
+
+#define GET_QUAD_SIGNBITS(v) (((unsigned int)(v) << 17) >> 29) /* bits 14-12, unsigned */
+#define GET_QUAD_W(v) (((signed int)(v) << 20) >> 29) /* bits 11-9, sign-extend */
+#define GET_QUAD_X(v) (((signed int)(v) << 23) >> 29) /* bits 8-6, sign-extend */
+#define GET_QUAD_Y(v) (((signed int)(v) << 26) >> 29) /* bits 5-3, sign-extend */
+#define GET_QUAD_Z(v) (((signed int)(v) << 29) >> 29) /* bits 2-0, sign-extend */
+
+#define GET_PAIR_SIGNBITS(v) (((unsigned int)(v) << 20) >> 30) /* bits 11-10, unsigned */
+#define GET_PAIR_Y(v) (((signed int)(v) << 22) >> 27) /* bits 9-5, sign-extend */
+#define GET_PAIR_Z(v) (((signed int)(v) << 27) >> 27) /* bits 4-0, sign-extend */
+
+#define GET_ESC_SIGNBITS(v) (((unsigned int)(v) << 18) >> 30) /* bits 13-12, unsigned */
+#define GET_ESC_Y(v) (((signed int)(v) << 20) >> 26) /* bits 11-6, sign-extend */
+#define GET_ESC_Z(v) (((signed int)(v) << 26) >> 26) /* bits 5-0, sign-extend */
+
+/**************************************************************************************
+ * Function: UnpackZeros
+ *
+ * Description: fill a section of coefficients with zeros
+ *
+ * Inputs: number of coefficients
+ *
+ * Outputs: nVals zeros, starting at coef
+ *
+ * Return: none
+ *
+ * Notes: assumes nVals is always a multiple of 4 because all scalefactor bands
+ * are a multiple of 4 coefficients long
+ **************************************************************************************/
+static void UnpackZeros(int nVals, int *coef)
+{
+ while (nVals > 0) {
+ *coef++ = 0;
+ *coef++ = 0;
+ *coef++ = 0;
+ *coef++ = 0;
+ nVals -= 4;
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackQuads
+ *
+ * Description: decode a section of 4-way vector Huffman coded coefficients
+ *
+ * Inputs BitStreamInfo struct pointing to start of codewords for this section
+ * index of Huffman codebook
+ * number of coefficients
+ *
+ * Outputs: nVals coefficients, starting at coef
+ *
+ * Return: none
+ *
+ * Notes: assumes nVals is always a multiple of 4 because all scalefactor bands
+ * are a multiple of 4 coefficients long
+ **************************************************************************************/
+static void UnpackQuads(BitStreamInfo *bsi, int cb, int nVals, int *coef)
+{
+ int w, x, y, z, maxBits, nCodeBits, nSignBits, val;
+ unsigned int bitBuf;
+
+ maxBits = huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET].maxBits + 4;
+ while (nVals > 0) {
+ /* decode quad */
+ bitBuf = GetBitsNoAdvance(bsi, maxBits) << (32 - maxBits);
+ nCodeBits = DecodeHuffmanScalar(huffTabSpec, &huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET], bitBuf, &val);
+
+ w = GET_QUAD_W(val);
+ x = GET_QUAD_X(val);
+ y = GET_QUAD_Y(val);
+ z = GET_QUAD_Z(val);
+
+ bitBuf <<= nCodeBits;
+ nSignBits = (int)GET_QUAD_SIGNBITS(val);
+ AdvanceBitstream(bsi, nCodeBits + nSignBits);
+ if (nSignBits) {
+ if (w) {
+ APPLY_SIGN(w, bitBuf);
+ bitBuf <<= 1;
+ }
+ if (x) {
+ APPLY_SIGN(x, bitBuf);
+ bitBuf <<= 1;
+ }
+ if (y) {
+ APPLY_SIGN(y, bitBuf);
+ bitBuf <<= 1;
+ }
+ if (z) {
+ APPLY_SIGN(z, bitBuf);
+ bitBuf <<= 1;
+ }
+ }
+ *coef++ = w;
+ *coef++ = x;
+ *coef++ = y;
+ *coef++ = z;
+ nVals -= 4;
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackPairsNoEsc
+ *
+ * Description: decode a section of 2-way vector Huffman coded coefficients,
+ * using non-esc tables (5 through 10)
+ *
+ * Inputs BitStreamInfo struct pointing to start of codewords for this section
+ * index of Huffman codebook (must not be the escape codebook)
+ * number of coefficients
+ *
+ * Outputs: nVals coefficients, starting at coef
+ *
+ * Return: none
+ *
+ * Notes: assumes nVals is always a multiple of 2 because all scalefactor bands
+ * are a multiple of 4 coefficients long
+ **************************************************************************************/
+static void UnpackPairsNoEsc(BitStreamInfo *bsi, int cb, int nVals, int *coef)
+{
+ int y, z, maxBits, nCodeBits, nSignBits, val;
+ unsigned int bitBuf;
+
+ maxBits = huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET].maxBits + 2;
+ while (nVals > 0) {
+ /* decode pair */
+ bitBuf = GetBitsNoAdvance(bsi, maxBits) << (32 - maxBits);
+ nCodeBits = DecodeHuffmanScalar(huffTabSpec, &huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET], bitBuf, &val);
+
+ y = GET_PAIR_Y(val);
+ z = GET_PAIR_Z(val);
+
+ bitBuf <<= nCodeBits;
+ nSignBits = GET_PAIR_SIGNBITS(val);
+ AdvanceBitstream(bsi, nCodeBits + nSignBits);
+ if (nSignBits) {
+ if (y) {
+ APPLY_SIGN(y, bitBuf);
+ bitBuf <<= 1;
+ }
+ if (z) {
+ APPLY_SIGN(z, bitBuf);
+ bitBuf <<= 1;
+ }
+ }
+ *coef++ = y;
+ *coef++ = z;
+ nVals -= 2;
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackPairsEsc
+ *
+ * Description: decode a section of 2-way vector Huffman coded coefficients,
+ * using esc table (11)
+ *
+ * Inputs BitStreamInfo struct pointing to start of codewords for this section
+ * index of Huffman codebook (must be the escape codebook)
+ * number of coefficients
+ *
+ * Outputs: nVals coefficients, starting at coef
+ *
+ * Return: none
+ *
+ * Notes: assumes nVals is always a multiple of 2 because all scalefactor bands
+ * are a multiple of 4 coefficients long
+ **************************************************************************************/
+static void UnpackPairsEsc(BitStreamInfo *bsi, int cb, int nVals, int *coef)
+{
+ int y, z, maxBits, nCodeBits, nSignBits, n, val;
+ unsigned int bitBuf;
+
+ maxBits = huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET].maxBits + 2;
+ while (nVals > 0) {
+ /* decode pair with escape value */
+ bitBuf = GetBitsNoAdvance(bsi, maxBits) << (32 - maxBits);
+ nCodeBits = DecodeHuffmanScalar(huffTabSpec, &huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET], bitBuf, &val);
+
+ y = GET_ESC_Y(val);
+ z = GET_ESC_Z(val);
+
+ bitBuf <<= nCodeBits;
+ nSignBits = GET_ESC_SIGNBITS(val);
+ AdvanceBitstream(bsi, nCodeBits + nSignBits);
+
+ if (y == 16) {
+ n = 4;
+ while (GetBits(bsi, 1) == 1) {
+ n++;
+ }
+ y = (1 << n) + GetBits(bsi, n);
+ }
+ if (z == 16) {
+ n = 4;
+ while (GetBits(bsi, 1) == 1) {
+ n++;
+ }
+ z = (1 << n) + GetBits(bsi, n);
+ }
+
+ if (nSignBits) {
+ if (y) {
+ APPLY_SIGN(y, bitBuf);
+ bitBuf <<= 1;
+ }
+ if (z) {
+ APPLY_SIGN(z, bitBuf);
+ bitBuf <<= 1;
+ }
+ }
+
+ *coef++ = y;
+ *coef++ = z;
+ nVals -= 2;
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodeSpectrumLong
+ *
+ * Description: decode transform coefficients for frame with one long block
+ *
+ * Inputs: platform specific info struct
+ * BitStreamInfo struct pointing to start of spectral data
+ * (14496-3, table 4.4.29)
+ * index of current channel
+ *
+ * Outputs: decoded, quantized coefficients for this channel
+ *
+ * Return: none
+ *
+ * Notes: adds in pulse data if present
+ * fills coefficient buffer with zeros in any region not coded with
+ * codebook in range [1, 11] (including sfb's above sfbMax)
+ **************************************************************************************/
+int DecodeSpectrumLong(PSInfoBase *psi, BitStreamInfo *bsi, int ch)
+{
+ int i, sfb, cb, nVals, offset;
+ const short *sfbTab;
+ unsigned char *sfbCodeBook;
+ int *coef;
+ ICSInfo *icsInfo;
+ PulseInfo *pi;
+
+ coef = psi->coef[ch];
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ /* decode long block */
+ sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx];
+ sfbCodeBook = psi->sfbCodeBook[ch];
+ for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) {
+ cb = *sfbCodeBook++;
+ nVals = sfbTab[sfb + 1] - sfbTab[sfb];
+
+ if (cb == 0) {
+ UnpackZeros(nVals, coef);
+ } else if (cb <= 4) {
+ UnpackQuads(bsi, cb, nVals, coef);
+ } else if (cb <= 10) {
+ UnpackPairsNoEsc(bsi, cb, nVals, coef);
+ } else if (cb == 11) {
+ UnpackPairsEsc(bsi, cb, nVals, coef);
+ } else {
+ UnpackZeros(nVals, coef);
+ }
+
+ coef += nVals;
+ }
+
+ /* fill with zeros above maxSFB */
+ nVals = NSAMPS_LONG - sfbTab[sfb];
+ UnpackZeros(nVals, coef);
+
+ /* add pulse data, if present */
+ pi = &psi->pulseInfo[ch];
+ if (pi->pulseDataPresent) {
+ coef = psi->coef[ch];
+ offset = sfbTab[pi->startSFB];
+ for (i = 0; i < pi->numPulse; i++) {
+ offset += pi->offset[i];
+ if (coef[offset] > 0) {
+ coef[offset] += pi->amp[i];
+ } else {
+ coef[offset] -= pi->amp[i];
+ }
+ }
+ ASSERT(offset < NSAMPS_LONG, ERR_AAC_HUFFMAN_DECODING);
+ }
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: DecodeSpectrumShort
+ *
+ * Description: decode transform coefficients for frame with eight short blocks
+ *
+ * Inputs: platform specific info struct
+ * BitStreamInfo struct pointing to start of spectral data
+ * (14496-3, table 4.4.29)
+ * index of current channel
+ *
+ * Outputs: decoded, quantized coefficients for this channel
+ *
+ * Return: none
+ *
+ * Notes: fills coefficient buffer with zeros in any region not coded with
+ * codebook in range [1, 11] (including sfb's above sfbMax)
+ * deinterleaves window groups into 8 windows
+ **************************************************************************************/
+int DecodeSpectrumShort(PSInfoBase *psi, BitStreamInfo *bsi, int ch)
+{
+ int gp, cb, nVals = 0, win, offset, sfb;
+ const short *sfbTab;
+ unsigned char *sfbCodeBook;
+ int *coef;
+ ICSInfo *icsInfo;
+ coef = psi->coef[ch];
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ /* decode short blocks, deinterleaving in-place */
+ sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx];
+ sfbCodeBook = psi->sfbCodeBook[ch];
+ for (gp = 0; gp < icsInfo->numWinGroup; gp++) {
+ for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) {
+ nVals = sfbTab[sfb + 1] - sfbTab[sfb];
+ cb = *sfbCodeBook++;
+
+ for (win = 0; win < icsInfo->winGroupLen[gp]; win++) {
+ offset = win * NSAMPS_SHORT;
+ if (cb == 0) {
+ UnpackZeros(nVals, coef + offset);
+ } else if (cb <= 4) {
+ UnpackQuads(bsi, cb, nVals, coef + offset);
+ } else if (cb <= 10) {
+ UnpackPairsNoEsc(bsi, cb, nVals, coef + offset);
+ } else if (cb == 11) {
+ UnpackPairsEsc(bsi, cb, nVals, coef + offset);
+ } else {
+ UnpackZeros(nVals, coef + offset);
+ }
+ }
+ coef += nVals;
+ }
+
+ /* fill with zeros above maxSFB */
+ for (win = 0; win < icsInfo->winGroupLen[gp]; win++) {
+ offset = win * NSAMPS_SHORT;
+ nVals = NSAMPS_SHORT - sfbTab[sfb];
+ UnpackZeros(nVals, coef + offset);
+ }
+ coef += nVals;
+ coef += (icsInfo->winGroupLen[gp] - 1) * NSAMPS_SHORT;
+ }
+
+ ASSERT(coef == psi->coef[ch] + NSAMPS_LONG, ERR_AAC_COFF_EXCEED_RANGE);
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/wfd_aac_decoder/hufftabs.c b/audio_codec/wfd_aac_decoder/hufftabs.c
new file mode 100644
index 0000000..e153a61
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/hufftabs.c
@@ -0,0 +1,177 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: hufftabs.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * hufftabs.c - Huffman symbol tables
+ **************************************************************************************/
+
+#include "coder.h"
+
+const HuffInfo huffTabSpecInfo[11] = {
+ /* table 0 not used */
+ {11, { 1, 0, 0, 0, 8, 0, 24, 0, 24, 8, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0},
+ { 9, { 0, 0, 1, 1, 7, 24, 15, 19, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 81},
+ {16, { 1, 0, 0, 4, 2, 6, 3, 5, 15, 15, 8, 9, 3, 3, 5, 2, 0, 0, 0, 0}, 162},
+ {12, { 0, 0, 0, 10, 6, 0, 9, 21, 8, 14, 11, 2, 0, 0, 0, 0, 0, 0, 0, 0}, 243},
+ {13, { 1, 0, 0, 4, 4, 0, 4, 12, 12, 12, 18, 10, 4, 0, 0, 0, 0, 0, 0, 0}, 324},
+ {11, { 0, 0, 0, 9, 0, 16, 13, 8, 23, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 405},
+ {12, { 1, 0, 2, 1, 0, 4, 5, 10, 14, 15, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0}, 486},
+ {10, { 0, 0, 1, 5, 7, 10, 14, 15, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 550},
+ {15, { 1, 0, 2, 1, 0, 4, 3, 8, 11, 20, 31, 38, 32, 14, 4, 0, 0, 0, 0, 0}, 614},
+ {12, { 0, 0, 0, 3, 8, 14, 17, 25, 31, 41, 22, 8, 0, 0, 0, 0, 0, 0, 0, 0}, 783},
+ {12, { 0, 0, 0, 2, 6, 7, 16, 59, 55, 95, 43, 6, 0, 0, 0, 0, 0, 0, 0, 0}, 952},
+};
+
+const signed short huffTabSpec[1241] = {
+ /* spectrum table 1 [81] (signed) */
+ 0x0000, 0x0200, 0x0e00, 0x0007, 0x0040, 0x0001, 0x0038, 0x0008, 0x01c0, 0x03c0, 0x0e40, 0x0039, 0x0078, 0x01c8, 0x000f, 0x0240,
+ 0x003f, 0x0fc0, 0x01f8, 0x0238, 0x0047, 0x0e08, 0x0009, 0x0208, 0x01c1, 0x0048, 0x0041, 0x0e38, 0x0201, 0x0e07, 0x0207, 0x0e01,
+ 0x01c7, 0x0278, 0x0e78, 0x03c8, 0x004f, 0x0079, 0x01c9, 0x01cf, 0x03f8, 0x0239, 0x007f, 0x0e48, 0x0e0f, 0x0fc8, 0x01f9, 0x03c1,
+ 0x03c7, 0x0e47, 0x0ff8, 0x01ff, 0x0049, 0x020f, 0x0241, 0x0e41, 0x0248, 0x0fc1, 0x0e3f, 0x0247, 0x023f, 0x0e39, 0x0fc7, 0x0e09,
+ 0x0209, 0x03cf, 0x0e79, 0x0e4f, 0x03f9, 0x0249, 0x0fc9, 0x027f, 0x0fcf, 0x0fff, 0x0279, 0x03c9, 0x0e49, 0x0e7f, 0x0ff9, 0x03ff,
+ 0x024f,
+ /* spectrum table 2 [81] (signed) */
+ 0x0000, 0x0200, 0x0e00, 0x0001, 0x0038, 0x0007, 0x01c0, 0x0008, 0x0040, 0x01c8, 0x0e40, 0x0078, 0x000f, 0x0047, 0x0039, 0x0e07,
+ 0x03c0, 0x0238, 0x0fc0, 0x003f, 0x0208, 0x0201, 0x01c1, 0x0e08, 0x0041, 0x01f8, 0x0e01, 0x01c7, 0x0e38, 0x0240, 0x0048, 0x0009,
+ 0x0207, 0x0079, 0x0239, 0x0e78, 0x01cf, 0x03c8, 0x0247, 0x0209, 0x0e48, 0x01f9, 0x0248, 0x0e0f, 0x0ff8, 0x0e39, 0x03f8, 0x0278,
+ 0x03c1, 0x0e47, 0x0fc8, 0x0e09, 0x0fc1, 0x0fc7, 0x01ff, 0x020f, 0x023f, 0x007f, 0x0049, 0x0e41, 0x0e3f, 0x004f, 0x03c7, 0x01c9,
+ 0x0241, 0x03cf, 0x0e79, 0x03f9, 0x0fff, 0x0e4f, 0x0e49, 0x0249, 0x0fcf, 0x03c9, 0x0e7f, 0x0fc9, 0x027f, 0x03ff, 0x0ff9, 0x0279,
+ 0x024f,
+ /* spectrum table 3 [81] (unsigned) */
+ 0x0000, 0x1200, 0x1001, 0x1040, 0x1008, 0x2240, 0x2009, 0x2048, 0x2041, 0x2208, 0x3049, 0x2201, 0x3248, 0x4249, 0x3209, 0x3241,
+ 0x1400, 0x1002, 0x200a, 0x2440, 0x3288, 0x2011, 0x3051, 0x2280, 0x304a, 0x3448, 0x1010, 0x2088, 0x2050, 0x1080, 0x2042, 0x2408,
+ 0x4289, 0x3089, 0x3250, 0x4251, 0x3281, 0x2210, 0x3211, 0x2081, 0x4449, 0x424a, 0x3441, 0x320a, 0x2012, 0x3052, 0x3488, 0x3290,
+ 0x2202, 0x2401, 0x3091, 0x2480, 0x4291, 0x3242, 0x3409, 0x4252, 0x4489, 0x2090, 0x308a, 0x3212, 0x3481, 0x3450, 0x3490, 0x3092,
+ 0x4491, 0x4451, 0x428a, 0x4292, 0x2082, 0x2410, 0x3282, 0x3411, 0x444a, 0x3442, 0x4492, 0x448a, 0x4452, 0x340a, 0x2402, 0x3482,
+ 0x3412,
+ /* spectrum table 4 [81] (unsigned) */
+ 0x4249, 0x3049, 0x3241, 0x3248, 0x3209, 0x1200, 0x2240, 0x0000, 0x2009, 0x2208, 0x2201, 0x2048, 0x1001, 0x2041, 0x1008, 0x1040,
+ 0x4449, 0x4251, 0x4289, 0x424a, 0x3448, 0x3441, 0x3288, 0x3409, 0x3051, 0x304a, 0x3250, 0x3089, 0x320a, 0x3281, 0x3242, 0x3211,
+ 0x2440, 0x2408, 0x2280, 0x2401, 0x2042, 0x2088, 0x200a, 0x2050, 0x2081, 0x2202, 0x2011, 0x2210, 0x1400, 0x1002, 0x1080, 0x1010,
+ 0x4291, 0x4489, 0x4451, 0x4252, 0x428a, 0x444a, 0x3290, 0x3488, 0x3450, 0x3091, 0x3052, 0x3481, 0x308a, 0x3411, 0x3212, 0x4491,
+ 0x3282, 0x340a, 0x3442, 0x4292, 0x4452, 0x448a, 0x2090, 0x2480, 0x2012, 0x2410, 0x2082, 0x2402, 0x4492, 0x3092, 0x3490, 0x3482,
+ 0x3412,
+ /* spectrum table 5 [81] (signed) */
+ 0x0000, 0x03e0, 0x0020, 0x0001, 0x001f, 0x003f, 0x03e1, 0x03ff, 0x0021, 0x03c0, 0x0002, 0x0040, 0x001e, 0x03df, 0x0041, 0x03fe,
+ 0x0022, 0x03c1, 0x005f, 0x03e2, 0x003e, 0x03a0, 0x0060, 0x001d, 0x0003, 0x03bf, 0x0023, 0x0061, 0x03fd, 0x03a1, 0x007f, 0x003d,
+ 0x03e3, 0x03c2, 0x0042, 0x03de, 0x005e, 0x03be, 0x007e, 0x03c3, 0x005d, 0x0062, 0x0043, 0x03a2, 0x03dd, 0x001c, 0x0380, 0x0081,
+ 0x0080, 0x039f, 0x0004, 0x009f, 0x03fc, 0x0024, 0x03e4, 0x0381, 0x003c, 0x007d, 0x03bd, 0x03a3, 0x03c4, 0x039e, 0x0082, 0x005c,
+ 0x0044, 0x0063, 0x0382, 0x03dc, 0x009e, 0x007c, 0x039d, 0x0383, 0x0064, 0x03a4, 0x0083, 0x009d, 0x03bc, 0x009c, 0x0384, 0x0084,
+ 0x039c,
+ /* spectrum table 6 [81] (signed) */
+ 0x0000, 0x0020, 0x001f, 0x0001, 0x03e0, 0x0021, 0x03e1, 0x003f, 0x03ff, 0x005f, 0x0041, 0x03c1, 0x03df, 0x03c0, 0x03e2, 0x0040,
+ 0x003e, 0x0022, 0x001e, 0x03fe, 0x0002, 0x005e, 0x03c2, 0x03de, 0x0042, 0x03a1, 0x0061, 0x007f, 0x03e3, 0x03bf, 0x0023, 0x003d,
+ 0x03fd, 0x0060, 0x03a0, 0x001d, 0x0003, 0x0062, 0x03be, 0x03c3, 0x0043, 0x007e, 0x005d, 0x03dd, 0x03a2, 0x0063, 0x007d, 0x03bd,
+ 0x03a3, 0x003c, 0x03fc, 0x0081, 0x0381, 0x039f, 0x0024, 0x009f, 0x03e4, 0x001c, 0x0382, 0x039e, 0x0044, 0x03dc, 0x0380, 0x0082,
+ 0x009e, 0x03c4, 0x0080, 0x005c, 0x0004, 0x03bc, 0x03a4, 0x007c, 0x009d, 0x0064, 0x0083, 0x0383, 0x039d, 0x0084, 0x0384, 0x039c,
+ 0x009c,
+ /* spectrum table 7 [64] (unsigned) */
+ 0x0000, 0x0420, 0x0401, 0x0821, 0x0841, 0x0822, 0x0440, 0x0402, 0x0861, 0x0823, 0x0842, 0x0460, 0x0403, 0x0843, 0x0862, 0x0824,
+ 0x0881, 0x0825, 0x08a1, 0x0863, 0x0844, 0x0404, 0x0480, 0x0882, 0x0845, 0x08a2, 0x0405, 0x08c1, 0x04a0, 0x0826, 0x0883, 0x0865,
+ 0x0864, 0x08a3, 0x0846, 0x08c2, 0x0827, 0x0866, 0x0406, 0x04c0, 0x0884, 0x08e1, 0x0885, 0x08e2, 0x08a4, 0x08c3, 0x0847, 0x08e3,
+ 0x08c4, 0x08a5, 0x0886, 0x0867, 0x04e0, 0x0407, 0x08c5, 0x08a6, 0x08e4, 0x0887, 0x08a7, 0x08e5, 0x08e6, 0x08c6, 0x08c7, 0x08e7,
+ /* spectrum table 8 [64] (unsigned) */
+ 0x0821, 0x0841, 0x0420, 0x0822, 0x0401, 0x0842, 0x0000, 0x0440, 0x0402, 0x0861, 0x0823, 0x0862, 0x0843, 0x0863, 0x0881, 0x0824,
+ 0x0882, 0x0844, 0x0460, 0x0403, 0x0883, 0x0864, 0x08a2, 0x08a1, 0x0845, 0x0825, 0x08a3, 0x0865, 0x0884, 0x08a4, 0x0404, 0x0885,
+ 0x0480, 0x0846, 0x08c2, 0x08c1, 0x0826, 0x0866, 0x08c3, 0x08a5, 0x04a0, 0x08c4, 0x0405, 0x0886, 0x08e1, 0x08e2, 0x0847, 0x08c5,
+ 0x08e3, 0x0827, 0x08a6, 0x0867, 0x08c6, 0x08e4, 0x04c0, 0x0887, 0x0406, 0x08e5, 0x08e6, 0x08c7, 0x08a7, 0x04e0, 0x0407, 0x08e7,
+ /* spectrum table 9 [169] (unsigned) */
+ 0x0000, 0x0420, 0x0401, 0x0821, 0x0841, 0x0822, 0x0440, 0x0402, 0x0861, 0x0842, 0x0823, 0x0460, 0x0403, 0x0843, 0x0862, 0x0824,
+ 0x0881, 0x0844, 0x0825, 0x0882, 0x0863, 0x0404, 0x0480, 0x08a1, 0x0845, 0x0826, 0x0864, 0x08a2, 0x08c1, 0x0883, 0x0405, 0x0846,
+ 0x04a0, 0x0827, 0x0865, 0x0828, 0x0901, 0x0884, 0x08a3, 0x08c2, 0x08e1, 0x0406, 0x0902, 0x0848, 0x0866, 0x0847, 0x0885, 0x0921,
+ 0x0829, 0x08e2, 0x04c0, 0x08a4, 0x08c3, 0x0903, 0x0407, 0x0922, 0x0868, 0x0886, 0x0867, 0x0408, 0x0941, 0x08c4, 0x0849, 0x08a5,
+ 0x0500, 0x04e0, 0x08e3, 0x0942, 0x0923, 0x0904, 0x082a, 0x08e4, 0x08c5, 0x08a6, 0x0888, 0x0887, 0x0869, 0x0961, 0x08a8, 0x0520,
+ 0x0905, 0x0943, 0x084a, 0x0409, 0x0962, 0x0924, 0x08c6, 0x0981, 0x0889, 0x0906, 0x082b, 0x0925, 0x0944, 0x08a7, 0x08e5, 0x084b,
+ 0x082c, 0x0982, 0x0963, 0x086a, 0x08a9, 0x08c7, 0x0907, 0x0964, 0x040a, 0x08e6, 0x0983, 0x0540, 0x0945, 0x088a, 0x08c8, 0x084c,
+ 0x0926, 0x0927, 0x088b, 0x0560, 0x08c9, 0x086b, 0x08aa, 0x0908, 0x08e8, 0x0985, 0x086c, 0x0965, 0x08e7, 0x0984, 0x0966, 0x0946,
+ 0x088c, 0x08e9, 0x08ab, 0x040b, 0x0986, 0x08ca, 0x0580, 0x0947, 0x08ac, 0x08ea, 0x0928, 0x040c, 0x0967, 0x0909, 0x0929, 0x0948,
+ 0x08eb, 0x0987, 0x08cb, 0x090b, 0x0968, 0x08ec, 0x08cc, 0x090a, 0x0949, 0x090c, 0x092a, 0x092b, 0x092c, 0x094b, 0x0989, 0x094a,
+ 0x0969, 0x0988, 0x096a, 0x098a, 0x098b, 0x094c, 0x096b, 0x096c, 0x098c,
+ /* spectrum table 10 [169] (unsigned) */
+ 0x0821, 0x0822, 0x0841, 0x0842, 0x0420, 0x0401, 0x0823, 0x0862, 0x0861, 0x0843, 0x0863, 0x0440, 0x0402, 0x0844, 0x0882, 0x0824,
+ 0x0881, 0x0000, 0x0883, 0x0864, 0x0460, 0x0403, 0x0884, 0x0845, 0x08a2, 0x0825, 0x08a1, 0x08a3, 0x0865, 0x08a4, 0x0885, 0x08c2,
+ 0x0846, 0x08c3, 0x0480, 0x08c1, 0x0404, 0x0826, 0x0866, 0x08a5, 0x08c4, 0x0886, 0x08c5, 0x08e2, 0x0867, 0x0847, 0x08a6, 0x0902,
+ 0x08e3, 0x04a0, 0x08e1, 0x0405, 0x0901, 0x0827, 0x0903, 0x08e4, 0x0887, 0x0848, 0x08c6, 0x08e5, 0x0828, 0x0868, 0x0904, 0x0888,
+ 0x08a7, 0x0905, 0x08a8, 0x08e6, 0x08c7, 0x0922, 0x04c0, 0x08c8, 0x0923, 0x0869, 0x0921, 0x0849, 0x0406, 0x0906, 0x0924, 0x0889,
+ 0x0942, 0x0829, 0x08e7, 0x0907, 0x0925, 0x08e8, 0x0943, 0x08a9, 0x0944, 0x084a, 0x0941, 0x086a, 0x0926, 0x08c9, 0x0500, 0x088a,
+ 0x04e0, 0x0962, 0x08e9, 0x0963, 0x0946, 0x082a, 0x0961, 0x0927, 0x0407, 0x0908, 0x0945, 0x086b, 0x08aa, 0x0909, 0x0965, 0x0408,
+ 0x0964, 0x084b, 0x08ea, 0x08ca, 0x0947, 0x088b, 0x082b, 0x0982, 0x0928, 0x0983, 0x0966, 0x08ab, 0x0984, 0x0967, 0x0985, 0x086c,
+ 0x08cb, 0x0520, 0x0948, 0x0540, 0x0981, 0x0409, 0x088c, 0x0929, 0x0986, 0x084c, 0x090a, 0x092a, 0x082c, 0x0968, 0x0987, 0x08eb,
+ 0x08ac, 0x08cc, 0x0949, 0x090b, 0x0988, 0x040a, 0x08ec, 0x0560, 0x094a, 0x0969, 0x096a, 0x040b, 0x096b, 0x092b, 0x094b, 0x0580,
+ 0x090c, 0x0989, 0x094c, 0x092c, 0x096c, 0x098b, 0x040c, 0x098a, 0x098c,
+ /* spectrum table 11 [289] (unsigned) */
+ 0x0000, 0x2041, 0x2410, 0x1040, 0x1001, 0x2081, 0x2042, 0x2082, 0x2043, 0x20c1, 0x20c2, 0x1080, 0x2083, 0x1002, 0x20c3, 0x2101,
+ 0x2044, 0x2102, 0x2084, 0x2103, 0x20c4, 0x10c0, 0x1003, 0x2141, 0x2142, 0x2085, 0x2104, 0x2045, 0x2143, 0x20c5, 0x2144, 0x2105,
+ 0x2182, 0x2086, 0x2181, 0x2183, 0x20c6, 0x2046, 0x2110, 0x20d0, 0x2405, 0x2403, 0x2404, 0x2184, 0x2406, 0x1100, 0x2106, 0x1004,
+ 0x2090, 0x2145, 0x2150, 0x2407, 0x2402, 0x2408, 0x2087, 0x21c2, 0x20c7, 0x2185, 0x2146, 0x2190, 0x240a, 0x21c3, 0x21c1, 0x2409,
+ 0x21d0, 0x2050, 0x2047, 0x2107, 0x240b, 0x21c4, 0x240c, 0x2210, 0x2401, 0x2186, 0x2250, 0x2088, 0x2147, 0x2290, 0x240d, 0x2203,
+ 0x2202, 0x20c8, 0x1140, 0x240e, 0x22d0, 0x21c5, 0x2108, 0x2187, 0x21c6, 0x1005, 0x2204, 0x240f, 0x2310, 0x2048, 0x2201, 0x2390,
+ 0x2148, 0x2350, 0x20c9, 0x2205, 0x21c7, 0x2089, 0x2206, 0x2242, 0x2243, 0x23d0, 0x2109, 0x2188, 0x1180, 0x2244, 0x2149, 0x2207,
+ 0x21c8, 0x2049, 0x2283, 0x1006, 0x2282, 0x2241, 0x2245, 0x210a, 0x208a, 0x2246, 0x20ca, 0x2189, 0x2284, 0x2208, 0x2285, 0x2247,
+ 0x22c3, 0x204a, 0x11c0, 0x2286, 0x21c9, 0x20cb, 0x214a, 0x2281, 0x210b, 0x22c2, 0x2342, 0x218a, 0x2343, 0x208b, 0x1400, 0x214b,
+ 0x22c5, 0x22c4, 0x2248, 0x21ca, 0x2209, 0x1010, 0x210d, 0x1007, 0x20cd, 0x22c6, 0x2341, 0x2344, 0x2303, 0x208d, 0x2345, 0x220a,
+ 0x218b, 0x2288, 0x2287, 0x2382, 0x2304, 0x204b, 0x210c, 0x22c1, 0x20cc, 0x204d, 0x2302, 0x21cb, 0x20ce, 0x214c, 0x214d, 0x2384,
+ 0x210e, 0x22c7, 0x2383, 0x2305, 0x2346, 0x2306, 0x1200, 0x22c8, 0x208c, 0x2249, 0x2385, 0x218d, 0x228a, 0x23c2, 0x220b, 0x224a,
+ 0x2386, 0x2289, 0x214e, 0x22c9, 0x2381, 0x208e, 0x218c, 0x204c, 0x2348, 0x1008, 0x2347, 0x21cc, 0x2307, 0x21cd, 0x23c3, 0x2301,
+ 0x218e, 0x208f, 0x23c5, 0x23c4, 0x204e, 0x224b, 0x210f, 0x2387, 0x220d, 0x2349, 0x220c, 0x214f, 0x20cf, 0x228b, 0x22ca, 0x2308,
+ 0x23c6, 0x23c7, 0x220e, 0x23c1, 0x21ce, 0x1240, 0x1009, 0x224d, 0x224c, 0x2309, 0x2388, 0x228d, 0x2389, 0x230a, 0x218f, 0x21cf,
+ 0x224e, 0x23c8, 0x22cb, 0x22ce, 0x204f, 0x228c, 0x228e, 0x234b, 0x234a, 0x22cd, 0x22cc, 0x220f, 0x238b, 0x234c, 0x230d, 0x23c9,
+ 0x238a, 0x1280, 0x230b, 0x224f, 0x100a, 0x230c, 0x12c0, 0x230e, 0x228f, 0x234d, 0x100d, 0x238c, 0x23ca, 0x23cb, 0x22cf, 0x238d,
+ 0x1340, 0x100b, 0x234e, 0x23cc, 0x23cd, 0x230f, 0x1380, 0x238e, 0x234f, 0x1300, 0x238f, 0x100e, 0x100c, 0x23ce, 0x13c0, 0x100f,
+ 0x23cf,
+};
+
+const HuffInfo huffTabScaleFactInfo =
+{19, { 1, 0, 1, 3, 2, 4, 3, 5, 4, 6, 6, 6, 5, 8, 4, 7, 3, 7, 46, 0}, 0};
+
+/* note - includes offset of -60 (4.6.2.3 in spec) */
+const signed short huffTabScaleFact[121] = {
+ /* scale factor table [121] */
+ 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, 14, -14, 16, 15, 17,
+ 18, -15, -17, -16, 19, -18, -19, 20, -20, 21, -21, 22, -22, 23, -23, -25,
+ 25, -27, -24, -26, 24, -28, 27, 29, -30, -29, 26, -31, -34, -33, -32, -36,
+ 28, -35, -38, -37, 30, -39, -41, -57, -59, -58, -60, 38, 39, 40, 41, 42,
+ 57, 37, 31, 32, 33, 34, 35, 36, 44, 51, 52, 53, 54, 55, 56, 50,
+ 45, 46, 47, 48, 49, 58, -54, -52, -51, -50, -55, 43, 60, 59, -56, -53,
+ -45, -44, -42, -40, -43, -49, -48, -46, -47,
+};
+
diff --git a/audio_codec/wfd_aac_decoder/imdct.c b/audio_codec/wfd_aac_decoder/imdct.c
new file mode 100644
index 0000000..1a20f28
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/imdct.c
@@ -0,0 +1,596 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: imdct.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * imdct.c - inverse MDCT
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+#include "aacdec.h"
+
+#define RND_VAL (1 << (FBITS_OUT_IMDCT-1))
+
+#ifndef AAC_ENABLE_SBR
+
+/**************************************************************************************
+ * Function: DecWindowOverlap
+ *
+ * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM,
+ * for winSequence LONG-LONG
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * number of channels
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans
+ *
+ * Return: none
+ *
+ * Notes: this processes one channel at a time, but skips every other sample in
+ * the output buffer (pcm) for stereo interleaving
+ * this should fit in registers on ARM
+ *
+ * TODO: ARM5E version with saturating overlap/add (QADD)
+ * asm code with free pointer updates, better load scheduling
+ **************************************************************************************/
+static void DecWindowOverlap(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev)
+{
+ int in, w0, w1, f0, f1;
+ int *buf1, *over1;
+ short *pcm1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ pcm1 = pcm0 + (1024 - 1) * nChans;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ if (winTypeCurr == winTypePrev) {
+ /* cut window loads in half since current and overlap sections use same symmetric window */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ } else {
+ /* different windows for current and overlap parts - should still fit in registers on ARM w/o stack spill */
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapLongStart
+ *
+ * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM,
+ * for winSequence LONG-START
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * number of channels
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans
+ *
+ * Return: none
+ *
+ * Notes: this processes one channel at a time, but skips every other sample in
+ * the output buffer (pcm) for stereo interleaving
+ * this should fit in registers on ARM
+ *
+ * TODO: ARM5E version with saturating overlap/add (QADD)
+ * asm code with free pointer updates, better load scheduling
+ **************************************************************************************/
+static void DecWindowOverlapLongStart(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1;
+ short *pcm1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ pcm1 = pcm0 + (1024 - 1) * nChans;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ i = 448; /* 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ in = *buf1--;
+
+ *over1-- = 0; /* Wn = 0 for n = (2047, 2046, ... 1600) */
+ *over0++ = in >> 1; /* Wn = 1 for n = (1024, 1025, ... 1471) */
+ } while (--i);
+
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+
+ /* do 64 more loops - 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ w0 = *wndCurr++; /* W[0], W[1], ... --> W[255], W[254], ... */
+ w1 = *wndCurr++; /* W[127], W[126], ... --> W[128], W[129], ... */
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in); /* Wn = short window for n = (1599, 1598, ... , 1536) */
+ *over0++ = MULSHIFT32(w1, in); /* Wn = short window for n = (1472, 1473, ... , 1535) */
+ } while (over0 < over1);
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapLongStop
+ *
+ * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM,
+ * for winSequence LONG-STOP
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * number of channels
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans
+ *
+ * Return: none
+ *
+ * Notes: this processes one channel at a time, but skips every other sample in
+ * the output buffer (pcm) for stereo interleaving
+ * this should fit in registers on ARM
+ *
+ * TODO: ARM5E version with saturating overlap/add (QADD)
+ * asm code with free pointer updates, better load scheduling
+ **************************************************************************************/
+static void DecWindowOverlapLongStop(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1;
+ short *pcm1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ pcm1 = pcm0 + (1024 - 1) * nChans;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+
+ i = 448; /* 2 outputs, 2 overlaps per loop */
+ do {
+ /* Wn = 0 for n = (0, 1, ... 447) */
+ /* Wn = 1 for n = (576, 577, ... 1023) */
+ in = *buf0++;
+ f1 = in >> 1; /* scale since skipping multiply by Q31 */
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (--i);
+
+ /* do 64 more loops - 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++; /* W[0], W[1], ...W[63] */
+ w1 = *wndPrev++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapShort
+ *
+ * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM,
+ * for winSequence EIGHT-SHORT (does all 8 short blocks)
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * number of channels
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans
+ *
+ * Return: none
+ *
+ * Notes: this processes one channel at a time, but skips every other sample in
+ * the output buffer (pcm) for stereo interleaving
+ * this should fit in registers on ARM
+ *
+ * TODO: ARM5E version with saturating overlap/add (QADD)
+ * asm code with free pointer updates, better load scheduling
+ **************************************************************************************/
+static void DecWindowOverlapShort(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1;
+ short *pcm1;
+ const int *wndPrev, *wndCurr;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+
+ /* pcm[0-447] = 0 + overlap[0-447] */
+ i = 448;
+ do {
+ f0 = *over0++;
+ f1 = *over0++;
+ *pcm0 = CLIPTOSHORT((f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+ *pcm0 = CLIPTOSHORT((f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+ i -= 2;
+ } while (i);
+
+ /* pcm[448-575] = Wp[0-127] * block0[0-127] + overlap[448-575] */
+ pcm1 = pcm0 + (128 - 1) * nChans;
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ do {
+ w0 = *wndPrev++; /* W[0], W[1], ...W[63] */
+ w1 = *wndPrev++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *over1;
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ /* save over0/over1 for next short block, in the slots just vacated */
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+
+ /* pcm[576-703] = Wc[128-255] * block0[128-255] + Wc[0-127] * block1[0-127] + overlap[576-703]
+ * pcm[704-831] = Wc[128-255] * block1[128-255] + Wc[0-127] * block2[0-127] + overlap[704-831]
+ * pcm[832-959] = Wc[128-255] * block2[128-255] + Wc[0-127] * block3[0-127] + overlap[832-959]
+ */
+ for (i = 0; i < 3; i++) {
+ pcm0 += 64 * nChans;
+ pcm1 = pcm0 + (128 - 1) * nChans;
+ over0 += 64;
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *(over0 - 128); /* from last short block */
+ in += *(over0 + 0); /* from last full frame */
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *(over1 - 128); /* from last short block */
+ in += *(over1 + 0); /* from last full frame */
+ *pcm1 = CLIPTOSHORT((in + f1 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm1 -= nChans;
+
+ /* save over0/over1 for next short block, in the slots just vacated */
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+
+ /* pcm[960-1023] = Wc[128-191] * block3[128-191] + Wc[0-63] * block4[0-63] + overlap[960-1023]
+ * over[0-63] = Wc[192-255] * block3[192-255] + Wc[64-127] * block4[64-127]
+ */
+ pcm0 += 64 * nChans;
+ over0 -= 832; /* points at overlap[64] */
+ over1 = over0 + 128 - 1; /* points at overlap[191] */
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *(over0 + 768); /* from last short block */
+ in += *(over0 + 896); /* from last full frame */
+ *pcm0 = CLIPTOSHORT((in - f0 + RND_VAL) >> FBITS_OUT_IMDCT);
+ pcm0 += nChans;
+
+ in = *(over1 + 768); /* from last short block */
+ *(over1 - 128) = in + f1;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in); /* save in overlap[128-191] */
+ *over0++ = MULSHIFT32(w1, in); /* save in overlap[64-127] */
+ } while (over0 < over1);
+
+ /* over0 now points at overlap[128] */
+
+ /* over[64-191] = Wc[128-255] * block4[128-255] + Wc[0-127] * block5[0-127]
+ * over[192-319] = Wc[128-255] * block5[128-255] + Wc[0-127] * block6[0-127]
+ * over[320-447] = Wc[128-255] * block6[128-255] + Wc[0-127] * block7[0-127]
+ * over[448-576] = Wc[128-255] * block7[128-255]
+ */
+ for (i = 0; i < 3; i++) {
+ over0 += 64;
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ /* from last short block */
+ *(over0 - 128) -= f0;
+ *(over1 - 128) += f1;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+
+ /* over[576-1024] = 0 */
+ i = 448;
+ over0 += 64;
+ do {
+ *over0++ = 0;
+ *over0++ = 0;
+ *over0++ = 0;
+ *over0++ = 0;
+ i -= 4;
+ } while (i);
+}
+
+#endif /* !AAC_ENABLE_SBR */
+
+/**************************************************************************************
+ * Function: IMDCT
+ *
+ * Description: inverse transform and convert to 16-bit PCM
+ *
+ * Inputs: valid AACDecInfo struct
+ * index of current channel (0 for SCE/LFE, 0 or 1 for CPE)
+ * output channel (range = [0, nChans-1])
+ *
+ * Outputs: complete frame of decoded PCM, after inverse transform
+ *
+ * Return: 0 if successful, -1 if error
+ *
+ * Notes: If AAC_ENABLE_SBR is defined at compile time then window + overlap
+ * does NOT clip to 16-bit PCM and does NOT interleave channels
+ * If AAC_ENABLE_SBR is NOT defined at compile time, then window + overlap
+ * does clip to 16-bit PCM and interleaves channels
+ * If SBR is enabled at compile time, but we don't know whether it is
+ * actually used for this frame (e.g. the first frame of a stream),
+ * we need to produce both clipped 16-bit PCM in outbuf AND
+ * unclipped 32-bit PCM in the SBR input buffer. In this case we make
+ * a separate pass over the 32-bit PCM to produce 16-bit PCM output.
+ * This inflicts a slight performance hit when decoding non-SBR files.
+ **************************************************************************************/
+int IMDCT(AACDecInfo *aacDecInfo, int ch, int chOut, short *outbuf)
+{
+ int i;
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+ outbuf += chOut;
+
+ /* optimized type-IV DCT (operates inplace) */
+ if (icsInfo->winSequence == 2) {
+ /* 8 short blocks */
+ for (i = 0; i < 8; i++) {
+ DCT4(0, psi->coef[ch] + i * 128, psi->gbCurrent[ch]);
+ }
+ } else {
+ /* 1 long block */
+ DCT4(1, psi->coef[ch], psi->gbCurrent[ch]);
+ }
+
+#ifdef AAC_ENABLE_SBR
+ /* window, overlap-add, don't clip to short (send to SBR decoder)
+ * store the decoded 32-bit samples in top half (second AAC_MAX_NSAMPS samples) of coef buffer
+ */
+ if (icsInfo->winSequence == 0) {
+ DecWindowOverlapNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 1) {
+ DecWindowOverlapLongStartNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 2) {
+ DecWindowOverlapShortNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 3) {
+ DecWindowOverlapLongStopNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]);
+ }
+
+ if (!aacDecInfo->sbrEnabled) {
+ for (i = 0; i < AAC_MAX_NSAMPS; i++) {
+ *outbuf = CLIPTOSHORT((psi->sbrWorkBuf[ch][i] + RND_VAL) >> FBITS_OUT_IMDCT);
+ outbuf += aacDecInfo->nChans;
+ }
+ }
+
+ aacDecInfo->rawSampleBuf[ch] = psi->sbrWorkBuf[ch];
+ aacDecInfo->rawSampleBytes = sizeof(int);
+ aacDecInfo->rawSampleFBits = FBITS_OUT_IMDCT;
+#else
+ /* window, overlap-add, round to PCM - optimized for each window sequence */
+ if (icsInfo->winSequence == 0) {
+ DecWindowOverlap(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 1) {
+ DecWindowOverlapLongStart(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 2) {
+ DecWindowOverlapShort(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]);
+ } else if (icsInfo->winSequence == 3) {
+ DecWindowOverlapLongStop(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]);
+ }
+
+ aacDecInfo->rawSampleBuf[ch] = 0;
+ aacDecInfo->rawSampleBytes = 0;
+ aacDecInfo->rawSampleFBits = 0;
+#endif
+
+ psi->prevWinShape[chOut] = icsInfo->winShape;
+
+ return 0;
+}
diff --git a/audio_codec/wfd_aac_decoder/noiseless.c b/audio_codec/wfd_aac_decoder/noiseless.c
new file mode 100644
index 0000000..e519e9d
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/noiseless.c
@@ -0,0 +1,513 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: noiseless.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * noiseless.c - decode channel info, scalefactors, quantized coefficients,
+ * scalefactor band codebook, and TNS coefficients from bitstream
+ **************************************************************************************/
+
+#include "coder.h"
+#include <stdio.h>
+
+
+/**************************************************************************************
+ * Function: DecodeICSInfo
+ *
+ * Description: decode individual channel stream info
+ *
+ * Inputs: BitStreamInfo struct pointing to start of ICS info
+ * (14496-3, table 4.4.6)
+ * sample rate index
+ *
+ * Outputs: updated icsInfo struct
+ *
+ * Return: none
+ **************************************************************************************/
+void DecodeICSInfo(BitStreamInfo *bsi, ICSInfo *icsInfo, int sampRateIdx)
+{
+ int sfb, g, mask;
+
+ icsInfo->icsResBit = GetBits(bsi, 1);
+ icsInfo->winSequence = GetBits(bsi, 2);
+ icsInfo->winShape = GetBits(bsi, 1);
+ if (icsInfo->winSequence == 2) {
+ /* short block */
+ icsInfo->maxSFB = GetBits(bsi, 4);
+ icsInfo->sfGroup = GetBits(bsi, 7);
+ icsInfo->numWinGroup = 1;
+ icsInfo->winGroupLen[0] = 1;
+ mask = 0x40; /* start with bit 6 */
+ for (g = 0; g < 7; g++) {
+ if (icsInfo->sfGroup & mask) {
+ icsInfo->winGroupLen[icsInfo->numWinGroup - 1]++;
+ } else {
+ icsInfo->numWinGroup++;
+ icsInfo->winGroupLen[icsInfo->numWinGroup - 1] = 1;
+ }
+ mask >>= 1;
+ }
+ } else {
+ /* long block */
+ icsInfo->maxSFB = GetBits(bsi, 6);
+ icsInfo->predictorDataPresent = GetBits(bsi, 1);
+ if (icsInfo->predictorDataPresent) {
+ icsInfo->predictorReset = GetBits(bsi, 1);
+ if (icsInfo->predictorReset) {
+ icsInfo->predictorResetGroupNum = GetBits(bsi, 5);
+ }
+ for (sfb = 0; sfb < MIN(icsInfo->maxSFB, predSFBMax[sampRateIdx]); sfb++) {
+ icsInfo->predictionUsed[sfb] = GetBits(bsi, 1);
+ }
+ }
+ icsInfo->numWinGroup = 1;
+ icsInfo->winGroupLen[0] = 1;
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodeSectionData
+ *
+ * Description: decode section data (scale factor band groupings and
+ * associated Huffman codebooks)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of ICS info
+ * (14496-3, table 4.4.25)
+ * window sequence (short or long blocks)
+ * number of window groups (1 for long blocks, 1-8 for short blocks)
+ * max coded scalefactor band
+ *
+ * Outputs: index of Huffman codebook for each scalefactor band in each section
+ *
+ * Return: none
+ *
+ * Notes: sectCB, sectEnd, sfbCodeBook, ordered by window groups for short blocks
+ **************************************************************************************/
+static int DecodeSectionData(BitStreamInfo *bsi, int winSequence, int numWinGrp, int maxSFB, unsigned char *sfbCodeBook)
+{
+ int g, cb, sfb;
+ int sectLen, sectLenBits, sectLenIncr, sectEscapeVal;
+
+ sectLenBits = (winSequence == 2 ? 3 : 5);
+ sectEscapeVal = (1 << sectLenBits) - 1;
+
+ for (g = 0; g < numWinGrp; g++) {
+ sfb = 0;
+ while (sfb < maxSFB) {
+ cb = GetBits(bsi, 4); /* next section codebook */
+ sectLen = 0;
+ do {
+ sectLenIncr = GetBits(bsi, sectLenBits);
+ sectLen += sectLenIncr;
+ } while (sectLenIncr == sectEscapeVal);
+
+ sfb += sectLen;
+ while (sectLen--) {
+ *sfbCodeBook++ = (unsigned char)cb;
+ }
+ }
+ ASSERT(sfb == maxSFB, ERR_AAC_HUFFMAN_DECODING);
+ }
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: DecodeOneScaleFactor
+ *
+ * Description: decode one scalefactor using scalefactor Huffman codebook
+ *
+ * Inputs: BitStreamInfo struct pointing to start of next coded scalefactor
+ *
+ * Outputs: updated BitstreamInfo struct
+ *
+ * Return: one decoded scalefactor, including index_offset of -60
+ **************************************************************************************/
+static int DecodeOneScaleFactor(BitStreamInfo *bsi)
+{
+ int nBits, val;
+ unsigned int bitBuf;
+
+ /* decode next scalefactor from bitstream */
+ bitBuf = GetBitsNoAdvance(bsi, huffTabScaleFactInfo.maxBits) << (32 - huffTabScaleFactInfo.maxBits);
+ nBits = DecodeHuffmanScalar(huffTabScaleFact, &huffTabScaleFactInfo, bitBuf, &val);
+ AdvanceBitstream(bsi, nBits);
+
+ return val;
+}
+
+/**************************************************************************************
+ * Function: DecodeScaleFactors
+ *
+ * Description: decode scalefactors, PNS energy, and intensity stereo weights
+ *
+ * Inputs: BitStreamInfo struct pointing to start of ICS info
+ * (14496-3, table 4.4.26)
+ * number of window groups (1 for long blocks, 1-8 for short blocks)
+ * max coded scalefactor band
+ * global gain (starting value for differential scalefactor coding)
+ * index of Huffman codebook for each scalefactor band in each section
+ *
+ * Outputs: decoded scalefactor for each section
+ *
+ * Return: none
+ *
+ * Notes: sfbCodeBook, scaleFactors ordered by window groups for short blocks
+ * for section with codebook 13, scaleFactors buffer has decoded PNS
+ * energy instead of regular scalefactor
+ * for section with codebook 14 or 15, scaleFactors buffer has intensity
+ * stereo weight instead of regular scalefactor
+ **************************************************************************************/
+static void DecodeScaleFactors(BitStreamInfo *bsi, int numWinGrp, int maxSFB, int globalGain,
+ unsigned char *sfbCodeBook, short *scaleFactors)
+{
+ int g, sfbCB, nrg, npf, val, sf, is;
+
+ /* starting values for differential coding */
+ sf = globalGain;
+ is = 0;
+ nrg = globalGain - 90 - 256;
+ npf = 1;
+
+ for (g = 0; g < numWinGrp * maxSFB; g++) {
+ sfbCB = *sfbCodeBook++;
+
+ if (sfbCB == 14 || sfbCB == 15) {
+ /* intensity stereo - differential coding */
+ val = DecodeOneScaleFactor(bsi);
+ is += val;
+ *scaleFactors++ = (short)is;
+ } else if (sfbCB == 13) {
+ /* PNS - first energy is directly coded, rest are Huffman coded (npf = noise_pcm_flag) */
+ if (npf) {
+ val = GetBits(bsi, 9);
+ npf = 0;
+ } else {
+ val = DecodeOneScaleFactor(bsi);
+ }
+ nrg += val;
+ *scaleFactors++ = (short)nrg;
+ } else if (sfbCB >= 1 && sfbCB <= 11) {
+ /* regular (non-zero) region - differential coding */
+ val = DecodeOneScaleFactor(bsi);
+ sf += val;
+ *scaleFactors++ = (short)sf;
+ } else {
+ /* inactive scalefactor band if codebook 0 */
+ *scaleFactors++ = 0;
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodePulseInfo
+ *
+ * Description: decode pulse information
+ *
+ * Inputs: BitStreamInfo struct pointing to start of pulse info
+ * (14496-3, table 4.4.7)
+ *
+ * Outputs: updated PulseInfo struct
+ *
+ * Return: none
+ **************************************************************************************/
+static void DecodePulseInfo(BitStreamInfo *bsi, PulseInfo *pi)
+{
+ int i;
+
+ pi->numPulse = GetBits(bsi, 2) + 1; /* add 1 here */
+ pi->startSFB = GetBits(bsi, 6);
+ for (i = 0; i < pi->numPulse; i++) {
+ pi->offset[i] = GetBits(bsi, 5);
+ pi->amp[i] = GetBits(bsi, 4);
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodeTNSInfo
+ *
+ * Description: decode TNS filter information
+ *
+ * Inputs: BitStreamInfo struct pointing to start of TNS info
+ * (14496-3, table 4.4.27)
+ * window sequence (short or long blocks)
+ *
+ * Outputs: updated TNSInfo struct
+ * buffer of decoded (signed) TNS filter coefficients
+ *
+ * Return: none
+ **************************************************************************************/
+static void DecodeTNSInfo(BitStreamInfo *bsi, int winSequence, TNSInfo *ti, signed char *tnsCoef)
+{
+ int i, w, f, coefBits, compress;
+ signed char c, s, n;
+ signed char sgnMask[3] = { 0x02, 0x04, 0x08};
+ signed char negMask[3] = {~0x03, ~0x07, ~0x0f};
+ unsigned char *filtLength, *filtOrder, *filtDir;
+
+ filtLength = ti->length;
+ filtOrder = ti->order;
+ filtDir = ti->dir;
+
+ if (winSequence == 2) {
+ /* short blocks */
+ for (w = 0; w < NWINDOWS_SHORT; w++) {
+ ti->numFilt[w] = GetBits(bsi, 1);
+ if (ti->numFilt[w]) {
+ ti->coefRes[w] = GetBits(bsi, 1) + 3;
+ *filtLength = GetBits(bsi, 4);
+ *filtOrder = GetBits(bsi, 3);
+ if (*filtOrder) {
+ *filtDir++ = GetBits(bsi, 1);
+ compress = GetBits(bsi, 1);
+ coefBits = (int)ti->coefRes[w] - compress; /* 2, 3, or 4 */
+ s = sgnMask[coefBits - 2];
+ n = negMask[coefBits - 2];
+ for (i = 0; i < *filtOrder; i++) {
+ c = GetBits(bsi, coefBits);
+ if (c & s) {
+ c |= n;
+ }
+ *tnsCoef++ = c;
+ }
+ }
+ filtLength++;
+ filtOrder++;
+ }
+ }
+ } else {
+ /* long blocks */
+ ti->numFilt[0] = GetBits(bsi, 2);
+ if (ti->numFilt[0]) {
+ ti->coefRes[0] = GetBits(bsi, 1) + 3;
+ }
+ for (f = 0; f < ti->numFilt[0]; f++) {
+ *filtLength = GetBits(bsi, 6);
+ *filtOrder = GetBits(bsi, 5);
+ if (*filtOrder) {
+ *filtDir++ = GetBits(bsi, 1);
+ compress = GetBits(bsi, 1);
+ coefBits = (int)ti->coefRes[0] - compress; /* 2, 3, or 4 */
+ s = sgnMask[coefBits - 2];
+ n = negMask[coefBits - 2];
+ for (i = 0; i < *filtOrder; i++) {
+ c = GetBits(bsi, coefBits);
+ if (c & s) {
+ c |= n;
+ }
+ *tnsCoef++ = c;
+ }
+ }
+ filtLength++;
+ filtOrder++;
+ }
+ }
+}
+
+/* bitstream field lengths for gain control data:
+ * gainBits[winSequence][0] = maxWindow (how many gain windows there are)
+ * gainBits[winSequence][1] = locBitsZero (bits for alocCode if window == 0)
+ * gainBits[winSequence][2] = locBits (bits for alocCode if window != 0)
+ */
+static const unsigned char gainBits[4][3] = {
+ {1, 5, 5}, /* long */
+ {2, 4, 2}, /* start */
+ {8, 2, 2}, /* short */
+ {2, 4, 5}, /* stop */
+};
+
+/**************************************************************************************
+ * Function: DecodeGainControlInfo
+ *
+ * Description: decode gain control information (SSR profile only)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of gain control info
+ * (14496-3, table 4.4.12)
+ * window sequence (short or long blocks)
+ *
+ * Outputs: updated GainControlInfo struct
+ *
+ * Return: none
+ **************************************************************************************/
+static void DecodeGainControlInfo(BitStreamInfo *bsi, int winSequence, GainControlInfo *gi)
+{
+ int bd, wd, ad;
+ int locBits, locBitsZero, maxWin;
+
+ gi->maxBand = GetBits(bsi, 2);
+ maxWin = (int)gainBits[winSequence][0];
+ locBitsZero = (int)gainBits[winSequence][1];
+ locBits = (int)gainBits[winSequence][2];
+
+ for (bd = 1; bd <= gi->maxBand; bd++) {
+ for (wd = 0; wd < maxWin; wd++) {
+ gi->adjNum[bd][wd] = GetBits(bsi, 3);
+ for (ad = 0; ad < gi->adjNum[bd][wd]; ad++) {
+ gi->alevCode[bd][wd][ad] = GetBits(bsi, 4);
+ gi->alocCode[bd][wd][ad] = GetBits(bsi, (wd == 0 ? locBitsZero : locBits));
+ }
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: DecodeICS
+ *
+ * Description: decode individual channel stream
+ *
+ * Inputs: platform specific info struct
+ * BitStreamInfo struct pointing to start of individual channel stream
+ * (14496-3, table 4.4.24)
+ * index of current channel
+ *
+ * Outputs: updated section data, scale factor data, pulse data, TNS data,
+ * and gain control data
+ *
+ * Return: none
+ **************************************************************************************/
+static int DecodeICS(PSInfoBase *psi, BitStreamInfo *bsi, int ch)
+{
+ int globalGain;
+ ICSInfo *icsInfo;
+ PulseInfo *pi;
+ TNSInfo *ti;
+ GainControlInfo *gi;
+ int err = ERR_AAC_NONE;
+
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ globalGain = GetBits(bsi, 8);
+ if (!psi->commonWin) {
+ DecodeICSInfo(bsi, icsInfo, psi->sampRateIdx);
+ }
+
+ err = DecodeSectionData(bsi, icsInfo->winSequence, icsInfo->numWinGroup, icsInfo->maxSFB, psi->sfbCodeBook[ch]);
+ if (err) {
+ return err;
+ }
+ DecodeScaleFactors(bsi, icsInfo->numWinGroup, icsInfo->maxSFB, globalGain, psi->sfbCodeBook[ch], psi->scaleFactors[ch]);
+
+ pi = &psi->pulseInfo[ch];
+ pi->pulseDataPresent = GetBits(bsi, 1);
+ if (pi->pulseDataPresent) {
+ DecodePulseInfo(bsi, pi);
+ }
+
+ ti = &psi->tnsInfo[ch];
+ ti->tnsDataPresent = GetBits(bsi, 1);
+ if (ti->tnsDataPresent) {
+ DecodeTNSInfo(bsi, icsInfo->winSequence, ti, ti->coef);
+ }
+
+ gi = &psi->gainControlInfo[ch];
+ gi->gainControlDataPresent = GetBits(bsi, 1);
+ if (gi->gainControlDataPresent) {
+ /* disable SSR, as we can decode out this part */
+ return ERR_AAC_SSR_GAIN_NOT_ADDED;
+ DecodeGainControlInfo(bsi, icsInfo->winSequence, gi);
+ }
+ return err;
+}
+
+/**************************************************************************************
+ * Function: DecodeNoiselessData
+ *
+ * Description: decode noiseless data (side info and transform coefficients)
+ *
+ * Inputs: valid AACDecInfo struct
+ * double pointer to buffer pointing to start of individual channel stream
+ * (14496-3, table 4.4.24)
+ * pointer to bit offset
+ * pointer to number of valid bits remaining in buf
+ * index of current channel
+ *
+ * Outputs: updated global gain, section data, scale factor data, pulse data,
+ * TNS data, gain control data, and spectral data
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int DecodeNoiselessData(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail, int ch)
+{
+ int bitsUsed;
+ BitStreamInfo bsi;
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+ int err = 0;
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ if (AACDataSource == 1) {
+ SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf);
+ GetBits(&bsi, *bitOffset);
+ } else {
+ if (((*bitsAvail + 7) >> 3) < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+
+ err = DecodeICS(psi, &bsi, ch);
+ if (err) {
+ return err;
+ }
+ if (icsInfo->winSequence == 2) {
+ err = DecodeSpectrumShort(psi, &bsi, ch);
+ } else {
+ err = DecodeSpectrumLong(psi, &bsi, ch);
+ }
+ if (err) {
+ return err;
+ }
+ if (AACDataSource == 1) {
+ bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset);
+ *buf += ((bitsUsed + *bitOffset) >> 3);
+ *bitOffset = ((bitsUsed + *bitOffset) & 0x07);
+ *bitsAvail -= bitsUsed;
+ if (*bitsAvail < 0) {
+ return ERR_AAC_INDATA_UNDERFLOW;
+ }
+ }
+ aacDecInfo->sbDeinterleaveReqd[ch] = 0;
+ aacDecInfo->tnsUsed |= psi->tnsInfo[ch].tnsDataPresent; /* set flag if TNS used for any channel */
+
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/wfd_aac_decoder/pns.c b/audio_codec/wfd_aac_decoder/pns.c
new file mode 100644
index 0000000..2384593
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/pns.c
@@ -0,0 +1,371 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: pns.c,v 1.2 2005/03/10 17:01:56 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * pns.c - perceptual noise substitution
+ **************************************************************************************/
+
+#include "coder.h"
+#ifndef __MW__
+#include "assembly.h"
+#else
+#include "assembly_mw.h"
+#endif /* __MW__ */
+
+/**************************************************************************************
+ * Function: Get32BitVal
+ *
+ * Description: generate 32-bit unsigned random number
+ *
+ * Inputs: last number calculated (seed, first time through)
+ *
+ * Outputs: new number, saved in *last
+ *
+ * Return: 32-bit number, uniformly distributed between [0, 2^32)
+ *
+ * Notes: uses simple linear congruential generator
+ **************************************************************************************/
+static unsigned int Get32BitVal(unsigned int *last)
+{
+ unsigned int r = *last;
+
+ /* use same coefs as MPEG reference code (classic LCG)
+ * use unsigned multiply to force reliable wraparound behavior in C (mod 2^32)
+ */
+ r = (1664525U * r) + 1013904223U;
+ *last = r;
+
+ return r;
+}
+
+/* pow(2, i/4.0) for i = [0,1,2,3], format = Q30 */
+static const int pow14[4] = {
+ 0x40000000, 0x4c1bf829, 0x5a82799a, 0x6ba27e65
+};
+
+#define NUM_ITER_INVSQRT 4
+
+#define X0_COEF_2 0xc0000000 /* Q29: -2.0 */
+#define X0_OFF_2 0x60000000 /* Q29: 3.0 */
+#define Q26_3 0x0c000000 /* Q26: 3.0 */
+
+/**************************************************************************************
+ * Function: InvRootR
+ *
+ * Description: use Newton's method to solve for x = 1/sqrt(r)
+ *
+ * Inputs: r in Q30 format, range = [0.25, 1] (normalize inputs to this range)
+ *
+ * Outputs: none
+ *
+ * Return: x = Q29, range = (1, 2)
+ *
+ * Notes: guaranteed to converge and not overflow for any r in this range
+ *
+ * xn+1 = xn - f(xn)/f'(xn)
+ * f(x) = 1/sqrt(r) - x = 0 (find root)
+ * = 1/x^2 - r
+ * f'(x) = -2/x^3
+ *
+ * so xn+1 = xn/2 * (3 - r*xn^2)
+ *
+ * NUM_ITER_INVSQRT = 3, maxDiff = 1.3747e-02
+ * NUM_ITER_INVSQRT = 4, maxDiff = 3.9832e-04
+ **************************************************************************************/
+static int InvRootR(int r)
+{
+ int i, xn, t;
+
+ /* use linear equation for initial guess
+ * x0 = -2*r + 3 (so x0 always >= correct answer in range [0.25, 1))
+ * xn = Q29 (at every step)
+ */
+ xn = (MULSHIFT32(r, X0_COEF_2) << 2) + X0_OFF_2;
+
+ for (i = 0; i < NUM_ITER_INVSQRT; i++) {
+ t = MULSHIFT32(xn, xn); /* Q26 = Q29*Q29 */
+ t = Q26_3 - (MULSHIFT32(r, t) << 2); /* Q26 = Q26 - (Q31*Q26 << 1) */
+ xn = MULSHIFT32(xn, t) << (6 - 1); /* Q29 = (Q29*Q26 << 6), and -1 for division by 2 */
+ }
+
+ /* clip to range (1.0, 2.0)
+ * (because of rounding, this can converge to xn slightly > 2.0 when r is near 0.25)
+ */
+ if (xn >> 30) {
+ xn = (1 << 30) - 1;
+ }
+
+ return xn;
+}
+
+/**************************************************************************************
+ * Function: ScaleNoiseVector
+ *
+ * Description: apply scaling to vector of noise coefficients for one scalefactor band
+ *
+ * Inputs: unscaled coefficients
+ * number of coefficients in vector (one scalefactor band of coefs)
+ * scalefactor for this band (i.e. noise energy)
+ *
+ * Outputs: nVals coefficients in Q(FBITS_OUT_DQ_OFF)
+ *
+ * Return: guard bit mask (OR of abs value of all noise coefs)
+ **************************************************************************************/
+static int ScaleNoiseVector(int *coef, int nVals, int sf)
+{
+ int i, c, spec, energy, sq, scalef, scalei, invSqrtEnergy, z, gbMask;
+
+ energy = 0;
+ for (i = 0; i < nVals; i++) {
+ spec = coef[i];
+
+ /* max nVals = max SFB width = 96, so energy can gain < 2^7 bits in accumulation */
+ sq = (spec * spec) >> 8; /* spec*spec range = (-2^30, 2^30) */
+ energy += sq;
+ }
+
+ /* unless nVals == 1 (or the number generator is broken...), this should not happen */
+ if (energy == 0) {
+ return 0; /* coef[i] must = 0 for i = [0, nVals-1], so gbMask = 0 */
+ }
+
+ /* pow(2, sf/4) * pow(2, FBITS_OUT_DQ_OFF) */
+ scalef = pow14[sf & 0x3];
+ scalei = (sf >> 2) + FBITS_OUT_DQ_OFF;
+
+ /* energy has implied factor of 2^-8 since we shifted the accumulator
+ * normalize energy to range [0.25, 1.0), calculate 1/sqrt(1), and denormalize
+ * i.e. divide input by 2^(30-z) and convert to Q30
+ * output of 1/sqrt(i) now has extra factor of 2^((30-z)/2)
+ * for energy > 0, z is an even number between 0 and 28
+ * final scaling of invSqrtEnergy:
+ * 2^(15 - z/2) to compensate for implicit 2^(30-z) factor in input
+ * +4 to compensate for implicit 2^-8 factor in input
+ */
+ z = CLZ(energy) - 2; /* energy has at least 2 leading zeros (see acc loop) */
+ z &= 0xfffffffe; /* force even */
+ invSqrtEnergy = InvRootR(energy << z); /* energy << z must be in range [0x10000000, 0x40000000] */
+ scalei -= (15 - z / 2 + 4); /* nInt = 1/sqrt(energy) in Q29 */
+
+ /* normalize for final scaling */
+ z = CLZ(invSqrtEnergy) - 1;
+ invSqrtEnergy <<= z;
+ scalei -= (z - 3 - 2); /* -2 for scalef, z-3 for invSqrtEnergy */
+ scalef = MULSHIFT32(scalef, invSqrtEnergy); /* scalef (input) = Q30, invSqrtEnergy = Q29 * 2^z */
+ gbMask = 0;
+
+ if (scalei < 0) {
+ scalei = -scalei;
+ if (scalei > 31) {
+ scalei = 31;
+ }
+ for (i = 0; i < nVals; i++) {
+ c = MULSHIFT32(coef[i], scalef) >> scalei;
+ gbMask |= FASTABS(c);
+ coef[i] = c;
+ }
+ } else {
+ /* for scalei <= 16, no clipping possible (coef[i] is < 2^15 before scaling)
+ * for scalei > 16, just saturate exponent (rare)
+ * scalef is close to full-scale (since we normalized invSqrtEnergy)
+ * remember, we are just producing noise here
+ */
+ if (scalei > 16) {
+ scalei = 16;
+ }
+ for (i = 0; i < nVals; i++) {
+ c = MULSHIFT32(coef[i] << scalei, scalef);
+ coef[i] = c;
+ gbMask |= FASTABS(c);
+ }
+ }
+
+ return gbMask;
+}
+
+/**************************************************************************************
+ * Function: GenerateNoiseVector
+ *
+ * Description: create vector of noise coefficients for one scalefactor band
+ *
+ * Inputs: seed for number generator
+ * number of coefficients to generate
+ *
+ * Outputs: buffer of nVals coefficients, range = [-2^15, 2^15)
+ * updated seed for number generator
+ *
+ * Return: none
+ **************************************************************************************/
+static void GenerateNoiseVector(int *coef, int *last, int nVals)
+{
+ int i;
+
+ for (i = 0; i < nVals; i++) {
+ coef[i] = ((signed int)Get32BitVal((unsigned int *)last)) >> 16;
+ }
+}
+
+/**************************************************************************************
+ * Function: CopyNoiseVector
+ *
+ * Description: copy vector of noise coefficients for one scalefactor band from L to R
+ *
+ * Inputs: buffer of left coefficients
+ * number of coefficients to copy
+ *
+ * Outputs: buffer of right coefficients
+ *
+ * Return: none
+ **************************************************************************************/
+static void CopyNoiseVector(int *coefL, int *coefR, int nVals)
+{
+ int i;
+
+ for (i = 0; i < nVals; i++) {
+ coefR[i] = coefL[i];
+ }
+}
+
+/**************************************************************************************
+ * Function: PNS
+ *
+ * Description: apply perceptual noise substitution, if enabled (MPEG-4 only)
+ *
+ * Inputs: valid AACDecInfo struct
+ * index of current channel
+ *
+ * Outputs: shaped noise in scalefactor bands where PNS is active
+ * updated minimum guard bit count for this channel
+ *
+ * Return: 0 if successful, -1 if error
+ **************************************************************************************/
+int PNS(AACDecInfo *aacDecInfo, int ch)
+{
+ int gp, sfb, win, width, nSamps, gb, gbMask;
+ int *coef;
+ const short *sfbTab;
+ unsigned char *sfbCodeBook;
+ short *scaleFactors;
+ int msMaskOffset, checkCorr, genNew;
+ unsigned char msMask;
+ unsigned char *msMaskPtr;
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+
+ if (!psi->pnsUsed[ch]) {
+ return 0;
+ }
+
+ if (icsInfo->winSequence == 2) {
+ sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_SHORT;
+ } else {
+ sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_LONG;
+ }
+ coef = psi->coef[ch];
+ sfbCodeBook = psi->sfbCodeBook[ch];
+ scaleFactors = psi->scaleFactors[ch];
+ checkCorr = (aacDecInfo->currBlockID == AAC_ID_CPE && psi->commonWin == 1 ? 1 : 0);
+
+ gbMask = 0;
+ for (gp = 0; gp < icsInfo->numWinGroup; gp++) {
+ for (win = 0; win < icsInfo->winGroupLen[gp]; win++) {
+ msMaskPtr = psi->msMaskBits + ((gp * icsInfo->maxSFB) >> 3);
+ msMaskOffset = ((gp * icsInfo->maxSFB) & 0x07);
+ msMask = (*msMaskPtr++) >> msMaskOffset;
+
+ for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) {
+ width = sfbTab[sfb + 1] - sfbTab[sfb];
+ if (sfbCodeBook[sfb] == 13) {
+ if (ch == 0) {
+ /* generate new vector, copy into ch 1 if it's possible that the channels will be correlated
+ * if ch 1 has PNS enabled for this SFB but it's uncorrelated (i.e. ms_used == 0),
+ * the copied values will be overwritten when we process ch 1
+ */
+ GenerateNoiseVector(coef, &psi->pnsLastVal, width);
+ if (checkCorr && psi->sfbCodeBook[1][gp * icsInfo->maxSFB + sfb] == 13) {
+ CopyNoiseVector(coef, psi->coef[1] + (coef - psi->coef[0]), width);
+ }
+ } else {
+ /* generate new vector if no correlation between channels */
+ genNew = 1;
+ if (checkCorr && psi->sfbCodeBook[0][gp * icsInfo->maxSFB + sfb] == 13) {
+ if ((psi->msMaskPresent == 1 && (msMask & 0x01)) || psi->msMaskPresent == 2) {
+ genNew = 0;
+ }
+ }
+ if (genNew) {
+ GenerateNoiseVector(coef, &psi->pnsLastVal, width);
+ }
+ }
+ gbMask |= ScaleNoiseVector(coef, width, psi->scaleFactors[ch][gp * icsInfo->maxSFB + sfb]);
+ }
+ coef += width;
+
+ /* get next mask bit (should be branchless on ARM) */
+ msMask >>= 1;
+ if (++msMaskOffset == 8) {
+ msMask = *msMaskPtr++;
+ msMaskOffset = 0;
+ }
+ }
+ coef += (nSamps - sfbTab[icsInfo->maxSFB]);
+ }
+ sfbCodeBook += icsInfo->maxSFB;
+ scaleFactors += icsInfo->maxSFB;
+ }
+
+ /* update guard bit count if necessary */
+ gb = CLZ(gbMask) - 1;
+ if (psi->gbCurrent[ch] > gb) {
+ psi->gbCurrent[ch] = gb;
+ }
+
+ return 0;
+}
diff --git a/audio_codec/wfd_aac_decoder/sbr.c b/audio_codec/wfd_aac_decoder/sbr.c
new file mode 100644
index 0000000..7bb8bc3
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/sbr.c
@@ -0,0 +1,434 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbr.c,v 1.4 2008/01/15 21:20:31 ehyche Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbr.c - top level functions for SBR
+ **************************************************************************************/
+
+#if defined(REAL_FORMAT_SDK)
+#include "rm_memory_shim.h"
+#define malloc hx_realformatsdk_malloc
+#define free hx_realformatsdk_free
+#endif /* #if defined(REAL_FORMAT_SDK) */
+
+#include "sbr.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+/**************************************************************************************
+ * Function: InitSBRState
+ *
+ * Description: initialize PSInfoSBR struct at start of stream or after flush
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: PSInfoSBR struct with proper initial state
+ *
+ * Return: none
+ **************************************************************************************/
+static void InitSBRState(PSInfoSBR *psi)
+{
+ int i, ch;
+ unsigned char *c;
+
+ if (!psi) {
+ return;
+ }
+
+ /* clear SBR state structure */
+ c = (unsigned char *)psi;
+ for (i = 0; i < (int)sizeof(PSInfoSBR); i++) {
+ *c++ = 0;
+ }
+
+ /* initialize non-zero state variables */
+ for (ch = 0; ch < AAC_MAX_NCHANS; ch++) {
+ psi->sbrChan[ch].reset = 1;
+ psi->sbrChan[ch].laPrev = -1;
+ }
+}
+
+/**************************************************************************************
+ * Function: InitSBR
+ *
+ * Description: initialize SBR decoder
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: PSInfoSBR struct to hold SBR state information
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Note: memory allocation for SBR is only done here
+ **************************************************************************************/
+int InitSBR(AACDecInfo *aacDecInfo)
+{
+ PSInfoSBR *psi;
+
+ if (!aacDecInfo) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ /* allocate SBR state structure */
+ psi = (PSInfoSBR *)malloc(sizeof(PSInfoSBR));
+ if (!psi) {
+ return ERR_AAC_SBR_INIT;
+ }
+
+ InitSBRState(psi);
+
+ aacDecInfo->psInfoSBR = psi;
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: FreeSBR
+ *
+ * Description: free SBR decoder
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: none
+ *
+ * Return: none
+ *
+ * Note: memory deallocation for SBR is only done here
+ **************************************************************************************/
+void FreeSBR(AACDecInfo *aacDecInfo)
+{
+ if (aacDecInfo && aacDecInfo->psInfoSBR) {
+ free(aacDecInfo->psInfoSBR);
+ }
+
+ return;
+}
+
+/**************************************************************************************
+ * Function: DecodeSBRBitstream
+ *
+ * Description: decode sideband information for SBR
+ *
+ * Inputs: valid AACDecInfo struct
+ * fill buffer with SBR extension block
+ * number of bytes in fill buffer
+ * base output channel (range = [0, nChans-1])
+ *
+ * Outputs: initialized state structs (SBRHdr, SBRGrid, SBRFreq, SBRChan)
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: SBR payload should be in aacDecInfo->fillBuf
+ * returns with no error if fill buffer is not an SBR extension block,
+ * or if current block is not a fill block (e.g. for LFE upsampling)
+ **************************************************************************************/
+int DecodeSBRBitstream(AACDecInfo *aacDecInfo, int chBase)
+{
+ int headerFlag;
+ BitStreamInfo bsi;
+ PSInfoSBR *psi;
+ int err = ERR_AAC_NONE;
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoSBR) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoSBR *)(aacDecInfo->psInfoSBR);
+
+ if (aacDecInfo->currBlockID != AAC_ID_FIL || (aacDecInfo->fillExtType != EXT_SBR_DATA && aacDecInfo->fillExtType != EXT_SBR_DATA_CRC)) {
+ return ERR_AAC_NONE;
+ }
+
+ SetBitstreamPointer(&bsi, aacDecInfo->fillCount, aacDecInfo->fillBuf);
+ if (GetBits(&bsi, 4) != (unsigned int)aacDecInfo->fillExtType) {
+ return ERR_AAC_SBR_BITSTREAM;
+ }
+
+ if (aacDecInfo->fillExtType == EXT_SBR_DATA_CRC) {
+ psi->crcCheckWord = GetBits(&bsi, 10);
+ }
+
+ headerFlag = GetBits(&bsi, 1);
+ if (headerFlag) {
+ /* get sample rate index for output sample rate (2x base rate) */
+ psi->sampRateIdx = GetSampRateIdx(2 * aacDecInfo->sampRate);
+ if (psi->sampRateIdx < 0 || psi->sampRateIdx >= NUM_SAMPLE_RATES) {
+ return ERR_AAC_SBR_BITSTREAM;
+ } else if (psi->sampRateIdx >= NUM_SAMPLE_RATES_SBR) {
+ return ERR_AAC_SBR_SINGLERATE_UNSUPPORTED;
+ }
+
+ /* reset flag = 1 if header values changed */
+ if (UnpackSBRHeader(&bsi, &(psi->sbrHdr[chBase]))) {
+ psi->sbrChan[chBase].reset = 1;
+ }
+
+ /* first valid SBR header should always trigger CalcFreqTables(), since psi->reset was set in InitSBR() */
+ if (psi->sbrChan[chBase].reset) {
+ CalcFreqTables(&(psi->sbrHdr[chBase + 0]), &(psi->sbrFreq[chBase]), psi->sampRateIdx);
+ }
+
+ /* copy and reset state to right channel for CPE */
+ if (aacDecInfo->prevBlockID == AAC_ID_CPE) {
+ psi->sbrChan[chBase + 1].reset = psi->sbrChan[chBase + 0].reset;
+ }
+ }
+
+
+ /* if no header has been received, upsample only */
+ if (psi->sbrHdr[chBase].count == 0) {
+ return ERR_AAC_NONE;
+ }
+
+ if (aacDecInfo->prevBlockID == AAC_ID_SCE) {
+ err = UnpackSBRSingleChannel(&bsi, psi, chBase);
+ } else if (aacDecInfo->prevBlockID == AAC_ID_CPE) {
+ err = UnpackSBRChannelPair(&bsi, psi, chBase);
+ } else {
+ return ERR_AAC_SBR_BITSTREAM;
+ }
+ ByteAlignBitstream(&bsi);
+
+ return err;
+}
+
+/**************************************************************************************
+ * Function: DecodeSBRData
+ *
+ * Description: apply SBR to one frame of PCM data
+ *
+ * Inputs: 1024 samples of decoded 32-bit PCM, before SBR
+ * size of input PCM samples (must be 4 bytes)
+ * number of fraction bits in input PCM samples
+ * base output channel (range = [0, nChans-1])
+ * initialized state structs (SBRHdr, SBRGrid, SBRFreq, SBRChan)
+ *
+ * Outputs: 2048 samples of decoded 16-bit PCM, after SBR
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ **************************************************************************************/
+int DecodeSBRData(AACDecInfo *aacDecInfo, int chBase, short *outbuf)
+{
+ int k, l, ch, chBlock, qmfaBands, qmfsBands;
+ int upsampleOnly, gbIdx, gbMask;
+ int *inbuf;
+ short *outptr;
+ PSInfoSBR *psi;
+ SBRHeader *sbrHdr;
+ SBRGrid *sbrGrid;
+ SBRFreq *sbrFreq;
+ SBRChan *sbrChan;
+ int err = ERR_AAC_NONE;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoSBR) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoSBR *)(aacDecInfo->psInfoSBR);
+
+ /* same header and freq tables for both channels in CPE */
+ sbrHdr = &(psi->sbrHdr[chBase]);
+ sbrFreq = &(psi->sbrFreq[chBase]);
+
+ /* upsample only if we haven't received an SBR header yet or if we have an LFE block */
+ if (aacDecInfo->currBlockID == AAC_ID_LFE) {
+ chBlock = 1;
+ upsampleOnly = 1;
+ } else if (aacDecInfo->currBlockID == AAC_ID_FIL) {
+ if (aacDecInfo->prevBlockID == AAC_ID_SCE) {
+ chBlock = 1;
+ } else if (aacDecInfo->prevBlockID == AAC_ID_CPE) {
+ chBlock = 2;
+ } else {
+ return ERR_AAC_NONE;
+ }
+
+ upsampleOnly = (sbrHdr->count == 0 ? 1 : 0);
+ if (aacDecInfo->fillExtType != EXT_SBR_DATA && aacDecInfo->fillExtType != EXT_SBR_DATA_CRC) {
+ return ERR_AAC_NONE;
+ }
+ } else {
+ /* ignore non-SBR blocks */
+ return ERR_AAC_NONE;
+ }
+
+ if (upsampleOnly) {
+ sbrFreq->kStart = 32;
+ sbrFreq->numQMFBands = 0;
+ }
+
+ for (ch = 0; ch < chBlock; ch++) {
+ sbrGrid = &(psi->sbrGrid[chBase + ch]);
+ sbrChan = &(psi->sbrChan[chBase + ch]);
+
+ if (aacDecInfo->rawSampleBuf[ch] == 0 || aacDecInfo->rawSampleBytes != 4) {
+ return ERR_AAC_SBR_PCM_FORMAT;
+ }
+ inbuf = (int *)aacDecInfo->rawSampleBuf[ch];
+ outptr = outbuf + chBase + ch;
+
+ /* restore delay buffers (could use ring buffer or keep in temp buffer for nChans == 1) */
+ for (l = 0; l < HF_GEN; l++) {
+ for (k = 0; k < 64; k++) {
+ psi->XBuf[l][k][0] = psi->XBufDelay[chBase + ch][l][k][0];
+ psi->XBuf[l][k][1] = psi->XBufDelay[chBase + ch][l][k][1];
+ }
+ }
+
+ /* step 1 - analysis QMF */
+ qmfaBands = sbrFreq->kStart;
+ for (l = 0; l < 32; l++) {
+ gbMask = QMFAnalysis(inbuf + l * 32, psi->delayQMFA[chBase + ch], psi->XBuf[l + HF_GEN][0],
+ aacDecInfo->rawSampleFBits, &(psi->delayIdxQMFA[chBase + ch]), qmfaBands);
+
+ gbIdx = ((l + HF_GEN) >> 5) & 0x01;
+ sbrChan->gbMask[gbIdx] |= gbMask; /* gbIdx = (0 if i < 32), (1 if i >= 32) */
+ }
+
+ if (upsampleOnly) {
+ /* no SBR - just run synthesis QMF to upsample by 2x */
+ qmfsBands = 32;
+ for (l = 0; l < 32; l++) {
+ /* step 4 - synthesis QMF */
+ QMFSynthesis(psi->XBuf[l + HF_ADJ][0], psi->delayQMFS[chBase + ch], &(psi->delayIdxQMFS[chBase + ch]), qmfsBands, outptr, aacDecInfo->nChans);
+ outptr += 64 * aacDecInfo->nChans;
+ }
+ } else {
+ /* if previous frame had lower SBR starting freq than current, zero out the synthesized QMF
+ * bands so they aren't used as sources for patching
+ * after patch generation, restore from delay buffer
+ * can only happen after header reset
+ */
+ for (k = sbrFreq->kStartPrev; k < sbrFreq->kStart; k++) {
+ for (l = 0; l < sbrGrid->envTimeBorder[0] + HF_ADJ; l++) {
+ psi->XBuf[l][k][0] = 0;
+ psi->XBuf[l][k][1] = 0;
+ }
+ }
+
+ /* step 2 - HF generation */
+ err = GenerateHighFreq(psi, sbrGrid, sbrFreq, sbrChan, ch);
+ if (err) {
+ return err;
+ }
+
+ /* restore SBR bands that were cleared before patch generation (time slots 0, 1 no longer needed) */
+ for (k = sbrFreq->kStartPrev; k < sbrFreq->kStart; k++) {
+ for (l = HF_ADJ; l < sbrGrid->envTimeBorder[0] + HF_ADJ; l++) {
+ psi->XBuf[l][k][0] = psi->XBufDelay[chBase + ch][l][k][0];
+ psi->XBuf[l][k][1] = psi->XBufDelay[chBase + ch][l][k][1];
+ }
+ }
+
+ /* step 3 - HF adjustment */
+ err = AdjustHighFreq(psi, sbrHdr, sbrGrid, sbrFreq, sbrChan, ch);
+ if (err) {
+ return err;
+ }
+
+ /* step 4 - synthesis QMF */
+ qmfsBands = sbrFreq->kStartPrev + sbrFreq->numQMFBandsPrev;
+ for (l = 0; l < sbrGrid->envTimeBorder[0]; l++) {
+ /* if new envelope starts mid-frame, use old settings until start of first envelope in this frame */
+ QMFSynthesis(psi->XBuf[l + HF_ADJ][0], psi->delayQMFS[chBase + ch], &(psi->delayIdxQMFS[chBase + ch]), qmfsBands, outptr, aacDecInfo->nChans);
+ outptr += 64 * aacDecInfo->nChans;
+ }
+
+ qmfsBands = sbrFreq->kStart + sbrFreq->numQMFBands;
+ for (; l < 32; l++) {
+ /* use new settings for rest of frame (usually the entire frame, unless the first envelope starts mid-frame) */
+ QMFSynthesis(psi->XBuf[l + HF_ADJ][0], psi->delayQMFS[chBase + ch], &(psi->delayIdxQMFS[chBase + ch]), qmfsBands, outptr, aacDecInfo->nChans);
+ outptr += 64 * aacDecInfo->nChans;
+ }
+ }
+
+ /* save delay */
+ for (l = 0; l < HF_GEN; l++) {
+ for (k = 0; k < 64; k++) {
+ psi->XBufDelay[chBase + ch][l][k][0] = psi->XBuf[l + 32][k][0];
+ psi->XBufDelay[chBase + ch][l][k][1] = psi->XBuf[l + 32][k][1];
+ }
+ }
+ sbrChan->gbMask[0] = sbrChan->gbMask[1];
+ sbrChan->gbMask[1] = 0;
+
+ if (sbrHdr->count > 0) {
+ sbrChan->reset = 0;
+ }
+ }
+ sbrFreq->kStartPrev = sbrFreq->kStart;
+ sbrFreq->numQMFBandsPrev = sbrFreq->numQMFBands;
+
+ if (aacDecInfo->nChans > 0 && (chBase + ch) == aacDecInfo->nChans) {
+ psi->frameCount++;
+ }
+
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: FlushCodecSBR
+ *
+ * Description: flush internal SBR codec state (after seeking, for example)
+ *
+ * Inputs: valid AACDecInfo struct
+ *
+ * Outputs: updated state variables for SBR
+ *
+ * Return: 0 if successful, error code (< 0) if error
+ *
+ * Notes: SBR is heavily dependent on state from previous frames
+ * (e.g. delta coded scalefactors, previous envelope boundaries, etc.)
+ * On flush, we reset everything as if SBR had just been initialized
+ * for the first time. This triggers "upsample-only" mode until
+ * the first valid SBR header is received. Then SBR starts as usual.
+ **************************************************************************************/
+int FlushCodecSBR(AACDecInfo *aacDecInfo)
+{
+ PSInfoSBR *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoSBR) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoSBR *)(aacDecInfo->psInfoSBR);
+
+ InitSBRState(psi);
+
+ return 0;
+}
diff --git a/audio_codec/wfd_aac_decoder/sbr.h b/audio_codec/wfd_aac_decoder/sbr.h
new file mode 100644
index 0000000..7d01905
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/sbr.h
@@ -0,0 +1,380 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbr.h,v 1.2 2005/05/20 18:05:41 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbr.h - definitions of platform-specific SBR data structures, functions, and tables
+ **************************************************************************************/
+
+#ifndef _SBR_H
+#define _SBR_H
+
+#include "aaccommon.h"
+#include "bitstream.h"
+#ifndef ASSERT
+#if defined(_WIN32) && defined(_M_IX86) && (defined (_DEBUG) || defined (REL_ENABLE_ASSERTS))
+#define ASSERT(x) if (!(x)) __asm int 3;
+#else
+#define ASSERT(x,errid) do{if(!(x)) {printk(" aac decoder error ,errid %d\n",(errid));return (errid);}}while(0)/* do nothing */
+#endif
+#endif
+
+#ifndef MAX
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+#ifndef MIN
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+#define NUM_TIME_SLOTS 16
+#define SAMPLES_PER_SLOT 2 /* RATE in spec */
+#define NUM_SAMPLE_RATES_SBR 9 /* downsampled (single-rate) mode unsupported, so only use Fs_sbr >= 16 kHz */
+
+#define MAX_NUM_ENV 5
+#define MAX_NUM_NOISE_FLOORS 2
+#define MAX_NUM_NOISE_FLOOR_BANDS 5 /* max Nq, see 4.6.18.3.6 */
+#define MAX_NUM_PATCHES 5
+#define MAX_NUM_SMOOTH_COEFS 5
+
+#define HF_GEN 8
+#define HF_ADJ 2
+
+#define MAX_QMF_BANDS 48 /* max QMF subbands covered by SBR (4.6.18.3.6) */
+
+#define FBITS_IN_QMFA 14
+#define FBITS_LOST_QMFA (1 + 2 + 3 + 2 + 1) /* 1 from cTab, 2 in premul, 3 in FFT, 2 in postmul, 1 for implicit scaling by 2.0 */
+#define FBITS_OUT_QMFA (FBITS_IN_QMFA - FBITS_LOST_QMFA)
+
+#define MIN_GBITS_IN_QMFS 2
+#define FBITS_IN_QMFS FBITS_OUT_QMFA
+#define FBITS_LOST_DCT4_64 (2 + 3 + 2) /* 2 in premul, 3 in FFT, 2 in postmul */
+
+#define FBITS_OUT_DQ_ENV 29 /* dequantized env scalefactors are Q(29 - envDataDequantScale) */
+#define FBITS_OUT_DQ_NOISE 24 /* range of Q_orig = [2^-24, 2^6] */
+#define NOISE_FLOOR_OFFSET 6
+
+/* see comments in ApplyBoost() */
+#define FBITS_GLIM_BOOST 24
+#define FBITS_QLIM_BOOST 14
+
+#define MAX_HUFF_BITS 20
+#define NUM_QMF_DELAY_BUFS 10
+#define DELAY_SAMPS_QMFA (NUM_QMF_DELAY_BUFS * 32)
+#define DELAY_SAMPS_QMFS (NUM_QMF_DELAY_BUFS * 128)
+
+/* additional external symbols to name-mangle for static linking */
+#define FFT32C STATNAME(FFT32C)
+#define CalcFreqTables STATNAME(CalcFreqTables)
+#define AdjustHighFreq STATNAME(AdjustHighFreq)
+#define GenerateHighFreq STATNAME(GenerateHighFreq)
+#define DecodeSBREnvelope STATNAME(DecodeSBREnvelope)
+#define DecodeSBRNoise STATNAME(DecodeSBRNoise)
+#define UncoupleSBREnvelope STATNAME(UncoupleSBREnvelope)
+#define UncoupleSBRNoise STATNAME(UncoupleSBRNoise)
+#define InvRNormalized STATNAME(InvRNormalized)
+#define RatioPowInv STATNAME(RatioPowInv)
+#define SqrtFix STATNAME(SqrtFix)
+#define QMFAnalysis STATNAME(QMFAnalysis)
+#define QMFSynthesis STATNAME(QMFSynthesis)
+#define GetSampRateIdx STATNAME(GetSampRateIdx)
+#define UnpackSBRHeader STATNAME(UnpackSBRHeader)
+#define UnpackSBRSingleChannel STATNAME(UnpackSBRSingleChannel)
+#define UnpackSBRChannelPair STATNAME(UnpackSBRChannelPair)
+
+/* asm functions */
+#define CVKernel1 STATNAME(CVKernel1)
+#define CVKernel2 STATNAME(CVKernel2)
+#define QMFAnalysisConv STATNAME(QMFAnalysisConv)
+#define QMFSynthesisConv STATNAME(QMFSynthesisConv)
+
+#define k0Tab STATNAME(k0Tab)
+#define k2Tab STATNAME(k2Tab)
+#define goalSBTab STATNAME(goalSBTab)
+#define huffTabSBR STATNAME(huffTabSBR)
+#define huffTabSBRInfo STATNAME(huffTabSBRInfo)
+#define log2Tab STATNAME(log2Tab)
+#define noiseTab STATNAME(noiseTab)
+#define cTabA STATNAME(cTabA)
+#define cTabS STATNAME(cTabS)
+
+/* do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) */
+#define CLIP_2N_SHIFT30(y, n) { \
+ int sign = (y) >> 31; \
+ if (sign != (y) >> (30 - (n))) { \
+ (y) = sign ^ (0x3fffffff); \
+ } else { \
+ (y) = (y) << (n); \
+ } \
+}
+
+#define CLIP_2N(y, n) { \
+ int sign = (y) >> 31; \
+ if (sign != ((y) >> (n))) { \
+ (y) = sign ^ ((1 << (n)) - 1); \
+ } \
+}
+
+enum {
+ SBR_GRID_FIXFIX = 0,
+ SBR_GRID_FIXVAR = 1,
+ SBR_GRID_VARFIX = 2,
+ SBR_GRID_VARVAR = 3
+};
+
+enum {
+ HuffTabSBR_tEnv15 = 0,
+ HuffTabSBR_fEnv15 = 1,
+ HuffTabSBR_tEnv15b = 2,
+ HuffTabSBR_fEnv15b = 3,
+ HuffTabSBR_tEnv30 = 4,
+ HuffTabSBR_fEnv30 = 5,
+ HuffTabSBR_tEnv30b = 6,
+ HuffTabSBR_fEnv30b = 7,
+ HuffTabSBR_tNoise30 = 8,
+ HuffTabSBR_fNoise30 = 5,
+ HuffTabSBR_tNoise30b = 9,
+ HuffTabSBR_fNoise30b = 7
+};
+
+typedef struct _HuffInfo {
+ int maxBits; /* number of bits in longest codeword */
+ unsigned char count[MAX_HUFF_BITS]; /* count[i] = number of codes with length i+1 bits */
+ int offset; /* offset into symbol table */
+} HuffInfo;
+
+/* need one SBRHeader per element (SCE/CPE), updated only on new header */
+typedef struct _SBRHeader {
+ int count;
+
+ unsigned char ampRes;
+ unsigned char startFreq;
+ unsigned char stopFreq;
+ unsigned char crossOverBand;
+ unsigned char resBitsHdr;
+ unsigned char hdrExtra1;
+ unsigned char hdrExtra2;
+
+ unsigned char freqScale;
+ unsigned char alterScale;
+ unsigned char noiseBands;
+
+ unsigned char limiterBands;
+ unsigned char limiterGains;
+ unsigned char interpFreq;
+ unsigned char smoothMode;
+} SBRHeader;
+
+/* need one SBRGrid per channel, updated every frame */
+typedef struct _SBRGrid {
+ unsigned char frameClass;
+ unsigned char ampResFrame;
+ unsigned char pointer;
+
+ unsigned char numEnv; /* L_E */
+ unsigned char envTimeBorder[MAX_NUM_ENV + 1]; /* t_E */
+ unsigned char freqRes[MAX_NUM_ENV]; /* r */
+
+ unsigned char numNoiseFloors; /* L_Q */
+ unsigned char noiseTimeBorder[MAX_NUM_NOISE_FLOORS + 1]; /* t_Q */
+
+ unsigned char numEnvPrev;
+ unsigned char numNoiseFloorsPrev;
+ unsigned char freqResPrev;
+} SBRGrid;
+
+/* need one SBRFreq per element (SCE/CPE/LFE), updated only on header reset */
+typedef struct _SBRFreq {
+ int kStart; /* k_x */
+ int nMaster;
+ int nHigh;
+ int nLow;
+ int nLimiter; /* N_l */
+ int numQMFBands; /* M */
+ int numNoiseFloorBands; /* Nq */
+
+ int kStartPrev;
+ int numQMFBandsPrev;
+
+ unsigned char freqMaster[MAX_QMF_BANDS + 1]; /* not necessary to save this after derived tables are generated */
+ unsigned char freqHigh[MAX_QMF_BANDS + 1];
+ unsigned char freqLow[MAX_QMF_BANDS / 2 + 1]; /* nLow = nHigh - (nHigh >> 1) */
+ unsigned char freqNoise[MAX_NUM_NOISE_FLOOR_BANDS + 1];
+ unsigned char freqLimiter[MAX_QMF_BANDS / 2 + MAX_NUM_PATCHES]; /* max (intermediate) size = nLow + numPatches - 1 */
+
+ unsigned char numPatches;
+ unsigned char patchNumSubbands[MAX_NUM_PATCHES + 1];
+ unsigned char patchStartSubband[MAX_NUM_PATCHES + 1];
+} SBRFreq;
+
+typedef struct _SBRChan {
+ int reset;
+ unsigned char deltaFlagEnv[MAX_NUM_ENV];
+ unsigned char deltaFlagNoise[MAX_NUM_NOISE_FLOORS];
+
+ signed char envDataQuant[MAX_NUM_ENV][MAX_QMF_BANDS]; /* range = [0, 127] */
+ signed char noiseDataQuant[MAX_NUM_NOISE_FLOORS][MAX_NUM_NOISE_FLOOR_BANDS];
+
+ unsigned char invfMode[2][MAX_NUM_NOISE_FLOOR_BANDS]; /* invfMode[0/1][band] = prev/curr */
+ int chirpFact[MAX_NUM_NOISE_FLOOR_BANDS]; /* bwArray */
+ unsigned char addHarmonicFlag[2]; /* addHarmonicFlag[0/1] = prev/curr */
+ unsigned char addHarmonic[2][64]; /* addHarmonic[0/1][band] = prev/curr */
+
+ int gbMask[2]; /* gbMask[0/1] = XBuf[0-31]/XBuf[32-39] */
+ signed char laPrev;
+
+ int noiseTabIndex;
+ int sinIndex;
+ int gainNoiseIndex;
+ int gTemp[MAX_NUM_SMOOTH_COEFS][MAX_QMF_BANDS];
+ int qTemp[MAX_NUM_SMOOTH_COEFS][MAX_QMF_BANDS];
+
+} SBRChan;
+
+typedef struct _PSInfoSBR {
+ /* save for entire file */
+ int frameCount;
+ int sampRateIdx;
+
+ /* state info that must be saved for each channel */
+ SBRHeader sbrHdr[AAC_MAX_NCHANS];
+ SBRGrid sbrGrid[AAC_MAX_NCHANS];
+ SBRFreq sbrFreq[AAC_MAX_NCHANS];
+ SBRChan sbrChan[AAC_MAX_NCHANS];
+
+ /* temp variables, no need to save between blocks */
+ unsigned char dataExtra;
+ unsigned char resBitsData;
+ unsigned char extendedDataPresent;
+ int extendedDataSize;
+
+ signed char envDataDequantScale[MAX_NCHANS_ELEM][MAX_NUM_ENV];
+ int envDataDequant[MAX_NCHANS_ELEM][MAX_NUM_ENV][MAX_QMF_BANDS];
+ int noiseDataDequant[MAX_NCHANS_ELEM][MAX_NUM_NOISE_FLOORS][MAX_NUM_NOISE_FLOOR_BANDS];
+
+ int eCurr[MAX_QMF_BANDS];
+ unsigned char eCurrExp[MAX_QMF_BANDS];
+ unsigned char eCurrExpMax;
+ signed char la;
+
+ int crcCheckWord;
+ int couplingFlag;
+ int envBand;
+ int eOMGainMax;
+ int gainMax;
+ int gainMaxFBits;
+ int noiseFloorBand;
+ int qp1Inv;
+ int qqp1Inv;
+ int sMapped;
+ int sBand;
+ int highBand;
+
+ int sumEOrigMapped;
+ int sumECurrGLim;
+ int sumSM;
+ int sumQM;
+ int gLimBoost[MAX_QMF_BANDS];
+ int qmLimBoost[MAX_QMF_BANDS];
+ int smBoost[MAX_QMF_BANDS];
+
+ int smBuf[MAX_QMF_BANDS];
+ int qmLimBuf[MAX_QMF_BANDS];
+ int gLimBuf[MAX_QMF_BANDS];
+ int gLimFbits[MAX_QMF_BANDS];
+
+ int gFiltLast[MAX_QMF_BANDS];
+ int qFiltLast[MAX_QMF_BANDS];
+
+ /* large buffers */
+ int delayIdxQMFA[AAC_MAX_NCHANS];
+ int delayQMFA[AAC_MAX_NCHANS][DELAY_SAMPS_QMFA];
+ int delayIdxQMFS[AAC_MAX_NCHANS];
+ int delayQMFS[AAC_MAX_NCHANS][DELAY_SAMPS_QMFS];
+ int XBufDelay[AAC_MAX_NCHANS][HF_GEN][64][2];
+ int XBuf[32 + 8][64][2];
+
+} PSInfoSBR;
+
+/* sbrfft.c */
+void FFT32C(int *x);
+
+/* sbrfreq.c */
+int CalcFreqTables(SBRHeader *sbrHdr, SBRFreq *sbrFreq, int sampRateIdx);
+
+/* sbrhfadj.c */
+int AdjustHighFreq(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch);
+
+/* sbrhfgen.c */
+int GenerateHighFreq(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch);
+
+/* sbrhuff.c */
+int DecodeSBREnvelope(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch);
+int DecodeSBRNoise(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch);
+void UncoupleSBREnvelope(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR);
+void UncoupleSBRNoise(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR);
+
+/* sbrmath.c */
+int InvRNormalized(int r);
+int RatioPowInv(int a, int b, int c);
+int SqrtFix(int x, int fBitsIn, int *fBitsOut);
+
+/* sbrqmf.c */
+int QMFAnalysis(int *inbuf, int *delay, int *XBuf, int fBitsIn, int *delayIdx, int qmfaBands);
+void QMFSynthesis(int *inbuf, int *delay, int *delayIdx, int qmfsBands, short *outbuf, int nChans);
+
+/* sbrside.c */
+int GetSampRateIdx(int sampRate);
+int UnpackSBRHeader(BitStreamInfo *bsi, SBRHeader *sbrHdr);
+int UnpackSBRSingleChannel(BitStreamInfo *bsi, PSInfoSBR *psi, int chOut);
+int UnpackSBRChannelPair(BitStreamInfo *bsi, PSInfoSBR *psi, int chOut);
+
+/* sbrtabs.c */
+extern const unsigned char k0Tab[NUM_SAMPLE_RATES_SBR][16];
+extern const unsigned char k2Tab[NUM_SAMPLE_RATES_SBR][14];
+extern const unsigned char goalSBTab[NUM_SAMPLE_RATES_SBR];
+extern const HuffInfo huffTabSBRInfo[10];
+extern const signed short huffTabSBR[604];
+extern const int log2Tab[65];
+extern const int noiseTab[512 * 2];
+extern const int cTabA[165];
+extern const int cTabS[640];
+
+#endif /* _SBR_H */
diff --git a/audio_codec/wfd_aac_decoder/sbrfft.c b/audio_codec/wfd_aac_decoder/sbrfft.c
new file mode 100644
index 0000000..2f74fc5
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/sbrfft.c
@@ -0,0 +1,368 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrfft.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * sbrfft.c - optimized FFT for SBR QMF filters
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+#define SQRT1_2 0x5a82799a
+
+/* swap RE{p0} with RE{p1} and IM{P0} with IM{P1} */
+#define swapcplx(p0,p1) \
+ t = p0; t1 = *(&(p0)+1); p0 = p1; *(&(p0)+1) = *(&(p1)+1); p1 = t; *(&(p1)+1) = t1
+
+/* nfft = 32, hard coded since small, fixed size FFT
+static const unsigned char bitrevtab32[9] = {
+ 0x01, 0x04, 0x03, 0x06, 0x00, 0x02, 0x05, 0x07, 0x00,
+};
+*/
+
+/* twiddle table for radix 4 pass, format = Q31 */
+static const int twidTabOdd32[8 * 6] = {
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x539eba45, 0xe7821d59,
+ 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59,
+ 0x539eba45, 0xc4df2862, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x22a2f4f8, 0xc4df2862,
+ 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862,
+ 0xac6145bb, 0x187de2a7, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52,
+};
+
+/**************************************************************************************
+ * Function: BitReverse32
+ *
+ * Description: Ken's fast in-place bit reverse
+ *
+ * Inputs: buffer of 32 complex samples
+ *
+ * Outputs: bit-reversed samples in same buffer
+ *
+ * Return: none
+**************************************************************************************/
+static void BitReverse32(int *inout)
+{
+ int t, t1;
+
+ swapcplx(inout[2], inout[32]);
+ swapcplx(inout[4], inout[16]);
+ swapcplx(inout[6], inout[48]);
+ swapcplx(inout[10], inout[40]);
+ swapcplx(inout[12], inout[24]);
+ swapcplx(inout[14], inout[56]);
+ swapcplx(inout[18], inout[36]);
+ swapcplx(inout[22], inout[52]);
+ swapcplx(inout[26], inout[44]);
+ swapcplx(inout[30], inout[60]);
+ swapcplx(inout[38], inout[50]);
+ swapcplx(inout[46], inout[58]);
+}
+
+/**************************************************************************************
+ * Function: R8FirstPass32
+ *
+ * Description: radix-8 trivial pass for decimation-in-time FFT (log2(N) = 5)
+ *
+ * Inputs: buffer of (bit-reversed) samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 3 guard bits, gains 1 integer bit
+ * guard bits out = guard bits in - 3 (if inputs are full scale)
+ * or guard bits in - 2 (if inputs bounded to +/- sqrt(2)/2)
+ * see scaling comments in fft.c for base AAC
+ * should compile with no stack spills on ARM (verify compiled output)
+ * current instruction count (per pass): 16 LDR, 16 STR, 4 SMULL, 61 ALU
+ **************************************************************************************/
+static void R8FirstPass32(int *r0)
+{
+ int r1, r2, r3, r4, r5, r6, r7;
+ int r8, r9, r10, r11, r12, r14;
+
+ /* number of passes = fft size / 8 = 32 / 8 = 4 */
+ r1 = (32 >> 3);
+ do {
+
+ r2 = r0[8];
+ r3 = r0[9];
+ r4 = r0[10];
+ r5 = r0[11];
+ r6 = r0[12];
+ r7 = r0[13];
+ r8 = r0[14];
+ r9 = r0[15];
+
+ r10 = r2 + r4;
+ r11 = r3 + r5;
+ r12 = r6 + r8;
+ r14 = r7 + r9;
+
+ r2 -= r4;
+ r3 -= r5;
+ r6 -= r8;
+ r7 -= r9;
+
+ r4 = r2 - r7;
+ r5 = r2 + r7;
+ r8 = r3 - r6;
+ r9 = r3 + r6;
+
+ r2 = r4 - r9;
+ r3 = r4 + r9;
+ r6 = r5 - r8;
+ r7 = r5 + r8;
+
+ r2 = MULSHIFT32(SQRT1_2, r2); /* can use r4, r5, r8, or r9 for constant and lo32 scratch reg */
+ r3 = MULSHIFT32(SQRT1_2, r3);
+ r6 = MULSHIFT32(SQRT1_2, r6);
+ r7 = MULSHIFT32(SQRT1_2, r7);
+
+ r4 = r10 + r12;
+ r5 = r10 - r12;
+ r8 = r11 + r14;
+ r9 = r11 - r14;
+
+ r10 = r0[0];
+ r11 = r0[2];
+ r12 = r0[4];
+ r14 = r0[6];
+
+ r10 += r11;
+ r12 += r14;
+
+ r4 >>= 1;
+ r10 += r12;
+ r4 += (r10 >> 1);
+ r0[ 0] = r4;
+ r4 -= (r10 >> 1);
+ r4 = (r10 >> 1) - r4;
+ r0[ 8] = r4;
+
+ r9 >>= 1;
+ r10 -= 2 * r12;
+ r4 = (r10 >> 1) + r9;
+ r0[ 4] = r4;
+ r4 = (r10 >> 1) - r9;
+ r0[12] = r4;
+ r10 += r12;
+
+ r10 -= 2 * r11;
+ r12 -= 2 * r14;
+
+ r4 = r0[1];
+ r9 = r0[3];
+ r11 = r0[5];
+ r14 = r0[7];
+
+ r4 += r9;
+ r11 += r14;
+
+ r8 >>= 1;
+ r4 += r11;
+ r8 += (r4 >> 1);
+ r0[ 1] = r8;
+ r8 -= (r4 >> 1);
+ r8 = (r4 >> 1) - r8;
+ r0[ 9] = r8;
+
+ r5 >>= 1;
+ r4 -= 2 * r11;
+ r8 = (r4 >> 1) - r5;
+ r0[ 5] = r8;
+ r8 = (r4 >> 1) + r5;
+ r0[13] = r8;
+ r4 += r11;
+
+ r4 -= 2 * r9;
+ r11 -= 2 * r14;
+
+ r9 = r10 - r11;
+ r10 += r11;
+ r14 = r4 + r12;
+ r4 -= r12;
+
+ r5 = (r10 >> 1) + r7;
+ r8 = (r4 >> 1) - r6;
+ r0[ 2] = r5;
+ r0[ 3] = r8;
+
+ r5 = (r9 >> 1) - r2;
+ r8 = (r14 >> 1) - r3;
+ r0[ 6] = r5;
+ r0[ 7] = r8;
+
+ r5 = (r10 >> 1) - r7;
+ r8 = (r4 >> 1) + r6;
+ r0[10] = r5;
+ r0[11] = r8;
+
+ r5 = (r9 >> 1) + r2;
+ r8 = (r14 >> 1) + r3;
+ r0[14] = r5;
+ r0[15] = r8;
+
+ r0 += 16;
+ r1--;
+ } while (r1 != 0);
+}
+
+/**************************************************************************************
+ * Function: R4Core32
+ *
+ * Description: radix-4 pass for 32-point decimation-in-time FFT
+ *
+ * Inputs: buffer of samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: gain 2 integer bits
+ * guard bits out = guard bits in - 1 (if inputs are full scale)
+ * see scaling comments in fft.c for base AAC
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ * should compile with no stack spills on ARM (verify compiled output)
+ * current instruction count (per pass): 16 LDR, 16 STR, 4 SMULL, 61 ALU
+ **************************************************************************************/
+static void R4Core32(int *r0)
+{
+ int r2, r3, r4, r5, r6, r7;
+ int r8, r9, r10, r12, r14;
+ int *r1;
+
+ r1 = (int *)twidTabOdd32;
+ r10 = 8;
+ do {
+ /* can use r14 for lo32 scratch register in all MULSHIFT32 */
+ r2 = r1[0];
+ r3 = r1[1];
+ r4 = r0[16];
+ r5 = r0[17];
+ r12 = r4 + r5;
+ r12 = MULSHIFT32(r3, r12);
+ r5 = MULSHIFT32(r2, r5) + r12;
+ r2 += 2 * r3;
+ r4 = MULSHIFT32(r2, r4) - r12;
+
+ r2 = r1[2];
+ r3 = r1[3];
+ r6 = r0[32];
+ r7 = r0[33];
+ r12 = r6 + r7;
+ r12 = MULSHIFT32(r3, r12);
+ r7 = MULSHIFT32(r2, r7) + r12;
+ r2 += 2 * r3;
+ r6 = MULSHIFT32(r2, r6) - r12;
+
+ r2 = r1[4];
+ r3 = r1[5];
+ r8 = r0[48];
+ r9 = r0[49];
+ r12 = r8 + r9;
+ r12 = MULSHIFT32(r3, r12);
+ r9 = MULSHIFT32(r2, r9) + r12;
+ r2 += 2 * r3;
+ r8 = MULSHIFT32(r2, r8) - r12;
+
+ r2 = r0[0];
+ r3 = r0[1];
+
+ r12 = r6 + r8;
+ r8 = r6 - r8;
+ r14 = r9 - r7;
+ r9 = r9 + r7;
+
+ r6 = (r2 >> 2) - r4;
+ r7 = (r3 >> 2) - r5;
+ r4 += (r2 >> 2);
+ r5 += (r3 >> 2);
+
+ r2 = r4 + r12;
+ r3 = r5 + r9;
+ r0[0] = r2;
+ r0[1] = r3;
+ r2 = r6 - r14;
+ r3 = r7 - r8;
+ r0[16] = r2;
+ r0[17] = r3;
+ r2 = r4 - r12;
+ r3 = r5 - r9;
+ r0[32] = r2;
+ r0[33] = r3;
+ r2 = r6 + r14;
+ r3 = r7 + r8;
+ r0[48] = r2;
+ r0[49] = r3;
+
+ r0 += 2;
+ r1 += 6;
+ r10--;
+ } while (r10 != 0);
+}
+
+/**************************************************************************************
+ * Function: FFT32C
+ *
+ * Description: Ken's very fast in-place radix-4 decimation-in-time FFT
+ *
+ * Inputs: buffer of 32 complex samples (before bit-reversal)
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: assumes 3 guard bits in, gains 3 integer bits
+ * guard bits out = guard bits in - 2
+ * (guard bit analysis includes assumptions about steps immediately
+ * before and after, i.e. PreMul and PostMul for DCT)
+ **************************************************************************************/
+void FFT32C(int *x)
+{
+ /* decimation in time */
+ BitReverse32(x);
+
+ /* 32-point complex FFT */
+ R8FirstPass32(x); /* gain 1 int bit, lose 2 GB (making assumptions about input) */
+ R4Core32(x); /* gain 2 int bits, lose 0 GB (making assumptions about input) */
+}
diff --git a/audio_codec/wfd_aac_decoder/sbrfreq.c b/audio_codec/wfd_aac_decoder/sbrfreq.c
new file mode 100644
index 0000000..5d4b331
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/sbrfreq.c
@@ -0,0 +1,673 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrfreq.c,v 1.2 2005/05/20 18:05:41 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrfreq.c - frequency band table calculation for SBR
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+/**************************************************************************************
+ * Function: BubbleSort
+ *
+ * Description: in-place sort of unsigned chars
+ *
+ * Inputs: buffer of elements to sort
+ * number of elements to sort
+ *
+ * Outputs: sorted buffer
+ *
+ * Return: none
+ **************************************************************************************/
+static void BubbleSort(unsigned char *v, int nItems)
+{
+ int i;
+ unsigned char t;
+
+ while (nItems >= 2) {
+ for (i = 0; i < nItems - 1; i++) {
+ if (v[i + 1] < v[i]) {
+ t = v[i + 1];
+ v[i + 1] = v[i];
+ v[i] = t;
+ }
+ }
+ nItems--;
+ }
+}
+
+/**************************************************************************************
+ * Function: VMin
+ *
+ * Description: find smallest element in a buffer of unsigned chars
+ *
+ * Inputs: buffer of elements to search
+ * number of elements to search
+ *
+ * Outputs: none
+ *
+ * Return: smallest element in buffer
+ **************************************************************************************/
+static unsigned char VMin(unsigned char *v, int nItems)
+{
+ int i;
+ unsigned char vMin;
+
+ vMin = v[0];
+ for (i = 1; i < nItems; i++) {
+ if (v[i] < vMin) {
+ vMin = v[i];
+ }
+ }
+ return vMin;
+}
+
+/**************************************************************************************
+ * Function: VMax
+ *
+ * Description: find largest element in a buffer of unsigned chars
+ *
+ * Inputs: buffer of elements to search
+ * number of elements to search
+ *
+ * Outputs: none
+ *
+ * Return: largest element in buffer
+ **************************************************************************************/
+static unsigned char VMax(unsigned char *v, int nItems)
+{
+ int i;
+ unsigned char vMax;
+
+ vMax = v[0];
+ for (i = 1; i < nItems; i++) {
+ if (v[i] > vMax) {
+ vMax = v[i];
+ }
+ }
+ return vMax;
+}
+
+/**************************************************************************************
+ * Function: CalcFreqMasterScaleZero
+ *
+ * Description: calculate master frequency table when freqScale == 0
+ * (4.6.18.3.2.1, figure 4.39)
+ *
+ * Inputs: alterScale flag
+ * index of first QMF subband in master freq table (k0)
+ * index of last QMF subband (k2)
+ *
+ * Outputs: master frequency table
+ *
+ * Return: number of bands in master frequency table
+ *
+ * Notes: assumes k2 - k0 <= 48 and k2 >= k0 (4.6.18.3.6)
+ **************************************************************************************/
+static int CalcFreqMasterScaleZero(unsigned char *freqMaster, int alterScale, int k0, int k2)
+{
+ int nMaster, k, nBands, k2Achieved, dk, vDk[64], k2Diff;
+
+ if (alterScale) {
+ dk = 2;
+ nBands = 2 * ((k2 - k0 + 2) >> 2);
+ } else {
+ dk = 1;
+ nBands = 2 * ((k2 - k0) >> 1);
+ }
+
+ if (nBands <= 0) {
+ return 0;
+ }
+
+ k2Achieved = k0 + nBands * dk;
+ k2Diff = k2 - k2Achieved;
+ for (k = 0; k < nBands; k++) {
+ vDk[k] = dk;
+ }
+
+ if (k2Diff > 0) {
+ k = nBands - 1;
+ while (k2Diff) {
+ vDk[k]++;
+ k--;
+ k2Diff--;
+ }
+ } else if (k2Diff < 0) {
+ k = 0;
+ while (k2Diff) {
+ vDk[k]--;
+ k++;
+ k2Diff++;
+ }
+ }
+
+ nMaster = nBands;
+ freqMaster[0] = k0;
+ for (k = 1; k <= nBands; k++) {
+ freqMaster[k] = freqMaster[k - 1] + vDk[k - 1];
+ }
+
+ return nMaster;
+}
+
+/* mBandTab[i] = temp1[i] / 2 */
+static const int mBandTab[3] = {6, 5, 4};
+
+/* invWarpTab[i] = 1.0 / temp2[i], Q30 (see 4.6.18.3.2.1) */
+static const int invWarpTab[2] = {0x40000000, 0x313b13b1};
+
+/**************************************************************************************
+ * Function: CalcFreqMasterScale
+ *
+ * Description: calculate master frequency table when freqScale > 0
+ * (4.6.18.3.2.1, figure 4.39)
+ *
+ * Inputs: alterScale flag
+ * freqScale flag
+ * index of first QMF subband in master freq table (k0)
+ * index of last QMF subband (k2)
+ *
+ * Outputs: master frequency table
+ *
+ * Return: number of bands in master frequency table
+ *
+ * Notes: assumes k2 - k0 <= 48 and k2 >= k0 (4.6.18.3.6)
+ **************************************************************************************/
+static int CalcFreqMaster(unsigned char *freqMaster, int freqScale, int alterScale, int k0, int k2)
+{
+ int bands, twoRegions, k, k1, t, vLast, vCurr, pCurr;
+ int invWarp, nBands0, nBands1, change;
+ unsigned char vDk1Min, vDk0Max;
+ unsigned char *vDelta;
+
+ if (freqScale < 1 || freqScale > 3) {
+ return -1;
+ }
+
+ bands = mBandTab[freqScale - 1];
+ invWarp = invWarpTab[alterScale];
+
+ /* tested for all k0 = [5, 64], k2 = [k0, 64] */
+ if (k2 * 10000 > 22449 * k0) {
+ twoRegions = 1;
+ k1 = 2 * k0;
+ } else {
+ twoRegions = 0;
+ k1 = k2;
+ }
+
+ /* tested for all k0 = [5, 64], k1 = [k0, 64], freqScale = [1,3] */
+ t = (log2Tab[k1] - log2Tab[k0]) >> 3; /* log2(k1/k0), Q28 to Q25 */
+ nBands0 = 2 * (((bands * t) + (1 << 24)) >> 25); /* multiply by bands/2, round to nearest int (mBandTab has factor of 1/2 rolled in) */
+
+ /* tested for all valid combinations of k0, k1, nBands (from sampRate, freqScale, alterScale)
+ * roundoff error can be a problem with fixpt (e.g. pCurr = 12.499999 instead of 12.50003)
+ * because successive multiplication always undershoots a little bit, but this
+ * doesn't occur in any of the ratios we encounter from the valid k0/k1 bands in the spec
+ */
+ t = RatioPowInv(k1, k0, nBands0);
+ pCurr = k0 << 24;
+ vLast = k0;
+ vDelta = freqMaster + 1; /* operate in-place */
+ for (k = 0; k < nBands0; k++) {
+ pCurr = MULSHIFT32(pCurr, t) << 8; /* keep in Q24 */
+ vCurr = (pCurr + (1 << 23)) >> 24;
+ vDelta[k] = (vCurr - vLast);
+ vLast = vCurr;
+ }
+
+ /* sort the deltas and find max delta for first region */
+ BubbleSort(vDelta, nBands0);
+ vDk0Max = VMax(vDelta, nBands0);
+
+ /* fill master frequency table with bands from first region */
+ freqMaster[0] = k0;
+ for (k = 1; k <= nBands0; k++) {
+ freqMaster[k] += freqMaster[k - 1];
+ }
+
+ /* if only one region, then the table is complete */
+ if (!twoRegions) {
+ return nBands0;
+ }
+
+ /* tested for all k1 = [10, 64], k2 = [k0, 64], freqScale = [1,3] */
+ t = (log2Tab[k2] - log2Tab[k1]) >> 3; /* log2(k1/k0), Q28 to Q25 */
+ t = MULSHIFT32(bands * t, invWarp) << 2; /* multiply by bands/2, divide by warp factor, keep Q25 */
+ nBands1 = 2 * ((t + (1 << 24)) >> 25); /* round to nearest int */
+
+ /* see comments above for calculations in first region */
+ t = RatioPowInv(k2, k1, nBands1);
+ pCurr = k1 << 24;
+ vLast = k1;
+ vDelta = freqMaster + nBands0 + 1; /* operate in-place */
+ for (k = 0; k < nBands1; k++) {
+ pCurr = MULSHIFT32(pCurr, t) << 8; /* keep in Q24 */
+ vCurr = (pCurr + (1 << 23)) >> 24;
+ vDelta[k] = (vCurr - vLast);
+ vLast = vCurr;
+ }
+
+ /* sort the deltas, adjusting first and last if the second region has smaller deltas than the first */
+ vDk1Min = VMin(vDelta, nBands1);
+ if (vDk1Min < vDk0Max) {
+ BubbleSort(vDelta, nBands1);
+ change = vDk0Max - vDelta[0];
+ if (change > ((vDelta[nBands1 - 1] - vDelta[0]) >> 1)) {
+ change = ((vDelta[nBands1 - 1] - vDelta[0]) >> 1);
+ }
+ vDelta[0] += change;
+ vDelta[nBands1 - 1] -= change;
+ }
+ BubbleSort(vDelta, nBands1);
+
+ /* fill master frequency table with bands from second region
+ * Note: freqMaster[nBands0] = k1
+ */
+ for (k = 1; k <= nBands1; k++) {
+ freqMaster[k + nBands0] += freqMaster[k + nBands0 - 1];
+ }
+
+ return (nBands0 + nBands1);
+}
+
+/**************************************************************************************
+ * Function: CalcFreqHigh
+ *
+ * Description: calculate high resolution frequency table (4.6.18.3.2.2)
+ *
+ * Inputs: master frequency table
+ * number of bands in master frequency table
+ * crossover band from header
+ *
+ * Outputs: high resolution frequency table
+ *
+ * Return: number of bands in high resolution frequency table
+ **************************************************************************************/
+static int CalcFreqHigh(unsigned char *freqHigh, unsigned char *freqMaster, int nMaster, int crossOverBand)
+{
+ int k, nHigh;
+
+ nHigh = nMaster - crossOverBand;
+
+ for (k = 0; k <= nHigh; k++) {
+ freqHigh[k] = freqMaster[k + crossOverBand];
+ }
+
+ return nHigh;
+}
+
+/**************************************************************************************
+ * Function: CalcFreqLow
+ *
+ * Description: calculate low resolution frequency table (4.6.18.3.2.2)
+ *
+ * Inputs: high resolution frequency table
+ * number of bands in high resolution frequency table
+ *
+ * Outputs: low resolution frequency table
+ *
+ * Return: number of bands in low resolution frequency table
+ **************************************************************************************/
+static int CalcFreqLow(unsigned char *freqLow, unsigned char *freqHigh, int nHigh)
+{
+ int k, nLow, oddFlag;
+
+ nLow = nHigh - (nHigh >> 1);
+ freqLow[0] = freqHigh[0];
+ oddFlag = nHigh & 0x01;
+
+ for (k = 1; k <= nLow; k++) {
+ freqLow[k] = freqHigh[2 * k - oddFlag];
+ }
+
+ return nLow;
+}
+
+/**************************************************************************************
+ * Function: CalcFreqNoise
+ *
+ * Description: calculate noise floor frequency table (4.6.18.3.2.2)
+ *
+ * Inputs: low resolution frequency table
+ * number of bands in low resolution frequency table
+ * index of starting QMF subband for SBR (kStart)
+ * index of last QMF subband (k2)
+ * number of noise bands
+ *
+ * Outputs: noise floor frequency table
+ *
+ * Return: number of bands in noise floor frequency table
+ **************************************************************************************/
+static int CalcFreqNoise(unsigned char *freqNoise, unsigned char *freqLow, int nLow, int kStart, int k2, int noiseBands, int *err)
+{
+ int i, iLast, k, nQ, lTop, lBottom;
+
+ lTop = log2Tab[k2];
+ lBottom = log2Tab[kStart];
+ nQ = noiseBands * ((lTop - lBottom) >> 2); /* Q28 to Q26, noiseBands = [0,3] */
+ nQ = (nQ + (1 << 25)) >> 26;
+ if (nQ < 1) {
+ nQ = 1;
+ }
+
+ if (!(nQ <= MAX_NUM_NOISE_FLOOR_BANDS)) { /* required from 4.6.18.3.6 */
+ *err = ERR_AAC_SPEC_NOT_MATCH;
+ return ERR_AAC_SPEC_NOT_MATCH;
+ }
+
+ iLast = 0;
+ freqNoise[0] = freqLow[0];
+ for (k = 1; k <= nQ; k++) {
+ i = iLast + (nLow - iLast) / (nQ + 1 - k); /* truncating division */
+ freqNoise[k] = freqLow[i];
+ iLast = i;
+ }
+
+ return nQ;
+}
+
+/**************************************************************************************
+ * Function: BuildPatches
+ *
+ * Description: build high frequency patches (4.6.18.6.3)
+ *
+ * Inputs: master frequency table
+ * number of bands in low resolution frequency table
+ * index of first QMF subband in master freq table (k0)
+ * index of starting QMF subband for SBR (kStart)
+ * number of QMF bands in high resolution frequency table
+ * sample rate index
+ *
+ * Outputs: starting subband for each patch
+ * number of subbands in each patch
+ *
+ * Return: number of patches
+ **************************************************************************************/
+static int BuildPatches(unsigned char *patchNumSubbands, unsigned char *patchStartSubband, unsigned char *freqMaster,
+ int nMaster, int k0, int kStart, int numQMFBands, int sampRateIdx)
+{
+ int i, j, k;
+ int msb, sb, usb, numPatches, goalSB, oddFlag;
+
+ msb = k0;
+ usb = kStart;
+ numPatches = 0;
+ goalSB = goalSBTab[sampRateIdx];
+
+ if (nMaster == 0) {
+ patchNumSubbands[0] = 0;
+ patchStartSubband[0] = 0;
+ return 0;
+ }
+
+ if (goalSB < kStart + numQMFBands) {
+ k = 0;
+ for (i = 0; freqMaster[i] < goalSB; i++) {
+ k = i + 1;
+ }
+ } else {
+ k = nMaster;
+ }
+
+ do {
+ j = k + 1;
+ do {
+ j--;
+ sb = freqMaster[j];
+ oddFlag = (sb - 2 + k0) & 0x01;
+ } while (sb > k0 - 1 + msb - oddFlag);
+
+ patchNumSubbands[numPatches] = MAX(sb - usb, 0);
+ patchStartSubband[numPatches] = k0 - oddFlag - patchNumSubbands[numPatches];
+
+ /* from MPEG reference code - slightly different from spec */
+ if ((patchNumSubbands[numPatches] < 3) && (numPatches > 0)) {
+ break;
+ }
+
+ if (patchNumSubbands[numPatches] > 0) {
+ usb = sb;
+ msb = sb;
+ numPatches++;
+ } else {
+ msb = kStart;
+ }
+
+ if (freqMaster[k] - sb < 3) {
+ k = nMaster;
+ }
+
+ } while (sb != (kStart + numQMFBands) && numPatches <= MAX_NUM_PATCHES);
+
+ return numPatches;
+}
+
+/**************************************************************************************
+ * Function: FindFreq
+ *
+ * Description: search buffer of unsigned chars for a specific value
+ *
+ * Inputs: buffer of elements to search
+ * number of elements to search
+ * value to search for
+ *
+ * Outputs: none
+ *
+ * Return: non-zero if the value is found anywhere in the buffer, zero otherwise
+ **************************************************************************************/
+static int FindFreq(unsigned char *freq, int nFreq, unsigned char val)
+{
+ int k;
+
+ for (k = 0; k < nFreq; k++) {
+ if (freq[k] == val) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: RemoveFreq
+ *
+ * Description: remove one element from a buffer of unsigned chars
+ *
+ * Inputs: buffer of elements
+ * number of elements
+ * index of element to remove
+ *
+ * Outputs: new buffer of length nFreq-1
+ *
+ * Return: none
+ **************************************************************************************/
+static void RemoveFreq(unsigned char *freq, int nFreq, int removeIdx)
+{
+ int k;
+
+ if (removeIdx >= nFreq) {
+ return;
+ }
+
+ for (k = removeIdx; k < nFreq - 1; k++) {
+ freq[k] = freq[k + 1];
+ }
+}
+
+/**************************************************************************************
+ * Function: CalcFreqLimiter
+ *
+ * Description: calculate limiter frequency table (4.6.18.3.2.3)
+ *
+ * Inputs: number of subbands in each patch
+ * low resolution frequency table
+ * number of bands in low resolution frequency table
+ * index of starting QMF subband for SBR (kStart)
+ * number of limiter bands
+ * number of patches
+ *
+ * Outputs: limiter frequency table
+ *
+ * Return: number of bands in limiter frequency table
+ **************************************************************************************/
+static int CalcFreqLimiter(unsigned char *freqLimiter, unsigned char *patchNumSubbands, unsigned char *freqLow,
+ int nLow, int kStart, int limiterBands, int numPatches)
+{
+ int k, bands, nLimiter, nOctaves;
+ int limBandsPerOctave[3] = {120, 200, 300}; /* [1.2, 2.0, 3.0] * 100 */
+ unsigned char patchBorders[MAX_NUM_PATCHES + 1];
+
+ /* simple case */
+ if (limiterBands == 0) {
+ freqLimiter[0] = freqLow[0] - kStart;
+ freqLimiter[1] = freqLow[nLow] - kStart;
+ return 1;
+ }
+
+ bands = limBandsPerOctave[limiterBands - 1];
+ patchBorders[0] = kStart;
+
+ /* from MPEG reference code - slightly different from spec (top border) */
+ for (k = 1; k < numPatches; k++) {
+ patchBorders[k] = patchBorders[k - 1] + patchNumSubbands[k - 1];
+ }
+ patchBorders[k] = freqLow[nLow];
+
+ for (k = 0; k <= nLow; k++) {
+ freqLimiter[k] = freqLow[k];
+ }
+
+ for (k = 1; k < numPatches; k++) {
+ freqLimiter[k + nLow] = patchBorders[k];
+ }
+
+ k = 1;
+ nLimiter = nLow + numPatches - 1;
+ BubbleSort(freqLimiter, nLimiter + 1);
+
+ while (k <= nLimiter) {
+ nOctaves = log2Tab[freqLimiter[k]] - log2Tab[freqLimiter[k - 1]]; /* Q28 */
+ nOctaves = (nOctaves >> 9) * bands; /* Q19, max bands = 300 < 2^9 */
+ if (nOctaves < (49 << 19)) { /* compare with 0.49*100, in Q19 */
+ if (freqLimiter[k] == freqLimiter[k - 1] || FindFreq(patchBorders, numPatches + 1, freqLimiter[k]) == 0) {
+ RemoveFreq(freqLimiter, nLimiter + 1, k);
+ nLimiter--;
+ } else if (FindFreq(patchBorders, numPatches + 1, freqLimiter[k - 1]) == 0) {
+ RemoveFreq(freqLimiter, nLimiter + 1, k - 1);
+ nLimiter--;
+ } else {
+ k++;
+ }
+ } else {
+ k++;
+ }
+ }
+
+ /* store limiter boundaries as offsets from kStart */
+ for (k = 0; k <= nLimiter; k++) {
+ freqLimiter[k] -= kStart;
+ }
+
+ return nLimiter;
+}
+
+/**************************************************************************************
+ * Function: CalcFreqTables
+ *
+ * Description: calulate master and derived frequency tables, and patches
+ *
+ * Inputs: initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRFreq struct for this SCE/CPE block
+ * sample rate index of output sample rate (after SBR)
+ *
+ * Outputs: master and derived frequency tables, and patches
+ *
+ * Return: non-zero if error, zero otherwise
+ **************************************************************************************/
+int CalcFreqTables(SBRHeader *sbrHdr, SBRFreq *sbrFreq, int sampRateIdx)
+{
+ int k0, k2;
+ int err = ERR_AAC_NONE;
+ k0 = k0Tab[sampRateIdx][sbrHdr->startFreq];
+
+ if (sbrHdr->stopFreq == 14) {
+ k2 = 2 * k0;
+ } else if (sbrHdr->stopFreq == 15) {
+ k2 = 3 * k0;
+ } else {
+ k2 = k2Tab[sampRateIdx][sbrHdr->stopFreq];
+ }
+ if (k2 > 64) {
+ k2 = 64;
+ }
+
+ /* calculate master frequency table */
+ if (sbrHdr->freqScale == 0) {
+ sbrFreq->nMaster = CalcFreqMasterScaleZero(sbrFreq->freqMaster, sbrHdr->alterScale, k0, k2);
+ } else {
+ sbrFreq->nMaster = CalcFreqMaster(sbrFreq->freqMaster, sbrHdr->freqScale, sbrHdr->alterScale, k0, k2);
+ }
+
+ /* calculate high frequency table and related parameters */
+ sbrFreq->nHigh = CalcFreqHigh(sbrFreq->freqHigh, sbrFreq->freqMaster, sbrFreq->nMaster, sbrHdr->crossOverBand);
+ sbrFreq->numQMFBands = sbrFreq->freqHigh[sbrFreq->nHigh] - sbrFreq->freqHigh[0];
+ sbrFreq->kStart = sbrFreq->freqHigh[0];
+
+ /* calculate low frequency table */
+ sbrFreq->nLow = CalcFreqLow(sbrFreq->freqLow, sbrFreq->freqHigh, sbrFreq->nHigh);
+
+ /* calculate noise floor frequency table */
+ sbrFreq->numNoiseFloorBands = CalcFreqNoise(sbrFreq->freqNoise, sbrFreq->freqLow, sbrFreq->nLow, sbrFreq->kStart, k2, sbrHdr->noiseBands, &err);
+ if (err) {
+ return err;
+ }
+
+ /* calculate limiter table */
+ sbrFreq->numPatches = BuildPatches(sbrFreq->patchNumSubbands, sbrFreq->patchStartSubband, sbrFreq->freqMaster,
+ sbrFreq->nMaster, k0, sbrFreq->kStart, sbrFreq->numQMFBands, sampRateIdx);
+ sbrFreq->nLimiter = CalcFreqLimiter(sbrFreq->freqLimiter, sbrFreq->patchNumSubbands, sbrFreq->freqLow, sbrFreq->nLow, sbrFreq->kStart,
+ sbrHdr->limiterBands, sbrFreq->numPatches);
+
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/wfd_aac_decoder/sbrhfadj.c b/audio_codec/wfd_aac_decoder/sbrhfadj.c
new file mode 100644
index 0000000..d0a85ac
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/sbrhfadj.c
@@ -0,0 +1,882 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrhfadj.c,v 1.1.2.3 2005/05/24 20:34:40 albertofloyd Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrhfadj.c - high frequency adjustment for SBR
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+/* invBandTab[i] = 1.0 / (i + 1), Q31 */
+static const int invBandTab[64] = {
+ 0x7fffffff, 0x40000000, 0x2aaaaaab, 0x20000000, 0x1999999a, 0x15555555, 0x12492492, 0x10000000,
+ 0x0e38e38e, 0x0ccccccd, 0x0ba2e8ba, 0x0aaaaaab, 0x09d89d8a, 0x09249249, 0x08888889, 0x08000000,
+ 0x07878788, 0x071c71c7, 0x06bca1af, 0x06666666, 0x06186186, 0x05d1745d, 0x0590b216, 0x05555555,
+ 0x051eb852, 0x04ec4ec5, 0x04bda12f, 0x04924925, 0x0469ee58, 0x04444444, 0x04210842, 0x04000000,
+ 0x03e0f83e, 0x03c3c3c4, 0x03a83a84, 0x038e38e4, 0x03759f23, 0x035e50d8, 0x03483483, 0x03333333,
+ 0x031f3832, 0x030c30c3, 0x02fa0be8, 0x02e8ba2f, 0x02d82d83, 0x02c8590b, 0x02b93105, 0x02aaaaab,
+ 0x029cbc15, 0x028f5c29, 0x02828283, 0x02762762, 0x026a439f, 0x025ed098, 0x0253c825, 0x02492492,
+ 0x023ee090, 0x0234f72c, 0x022b63cc, 0x02222222, 0x02192e2a, 0x02108421, 0x02082082, 0x02000000,
+};
+
+/**************************************************************************************
+ * Function: EstimateEnvelope
+ *
+ * Description: estimate power of generated HF QMF bands in one time-domain envelope
+ * (4.6.18.7.3)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * index of current envelope
+ *
+ * Outputs: power of each QMF subband, stored as integer (Q0) * 2^N, N >= 0
+ *
+ * Return: none
+ **************************************************************************************/
+static void EstimateEnvelope(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, int env)
+{
+ int i, m, iStart, iEnd, xre, xim, nScale, expMax;
+ int p, n, mStart, mEnd, invFact, t;
+ int *XBuf;
+ U64 eCurr;
+ unsigned char *freqBandTab;
+
+ /* estimate current envelope */
+ iStart = sbrGrid->envTimeBorder[env] + HF_ADJ;
+ iEnd = sbrGrid->envTimeBorder[env + 1] + HF_ADJ;
+ if (sbrGrid->freqRes[env]) {
+ n = sbrFreq->nHigh;
+ freqBandTab = sbrFreq->freqHigh;
+ } else {
+ n = sbrFreq->nLow;
+ freqBandTab = sbrFreq->freqLow;
+ }
+
+ /* ADS should inline MADD64 (smlal) properly, but check to make sure */
+ expMax = 0;
+ if (sbrHdr->interpFreq) {
+ for (m = 0; m < sbrFreq->numQMFBands; m++) {
+ eCurr.w64 = 0;
+ XBuf = psi->XBuf[iStart][sbrFreq->kStart + m];
+ for (i = iStart; i < iEnd; i++) {
+ /* scale to int before calculating power (precision not critical, and avoids overflow) */
+ xre = (*XBuf) >> FBITS_OUT_QMFA;
+ XBuf += 1;
+ xim = (*XBuf) >> FBITS_OUT_QMFA;
+ XBuf += (2 * 64 - 1);
+ eCurr.w64 = MADD64(eCurr.w64, xre, xre);
+ eCurr.w64 = MADD64(eCurr.w64, xim, xim);
+ }
+
+ /* eCurr.w64 is now Q(64 - 2*FBITS_OUT_QMFA) (64-bit word)
+ * if energy is too big to fit in 32-bit word (> 2^31) scale down by power of 2
+ */
+ nScale = 0;
+ if (eCurr.r.hi32) {
+ nScale = (32 - CLZ(eCurr.r.hi32)) + 1;
+ t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */
+ t |= eCurr.r.hi32 << (32 - nScale);
+ } else if (eCurr.r.lo32 >> 31) {
+ nScale = 1;
+ t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */
+ } else {
+ t = (int)eCurr.r.lo32;
+ }
+
+ invFact = invBandTab[(iEnd - iStart) - 1];
+ psi->eCurr[m] = MULSHIFT32(t, invFact);
+ psi->eCurrExp[m] = nScale + 1; /* +1 for invFact = Q31 */
+ if (psi->eCurrExp[m] > expMax) {
+ expMax = psi->eCurrExp[m];
+ }
+ }
+ } else {
+ for (p = 0; p < n; p++) {
+ mStart = freqBandTab[p];
+ mEnd = freqBandTab[p + 1];
+ eCurr.w64 = 0;
+ for (i = iStart; i < iEnd; i++) {
+ XBuf = psi->XBuf[i][mStart];
+ for (m = mStart; m < mEnd; m++) {
+ xre = (*XBuf++) >> FBITS_OUT_QMFA;
+ xim = (*XBuf++) >> FBITS_OUT_QMFA;
+ eCurr.w64 = MADD64(eCurr.w64, xre, xre);
+ eCurr.w64 = MADD64(eCurr.w64, xim, xim);
+ }
+ }
+
+ nScale = 0;
+ if (eCurr.r.hi32) {
+ nScale = (32 - CLZ(eCurr.r.hi32)) + 1;
+ t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */
+ t |= eCurr.r.hi32 << (32 - nScale);
+ } else if (eCurr.r.lo32 >> 31) {
+ nScale = 1;
+ t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */
+ } else {
+ t = (int)eCurr.r.lo32;
+ }
+
+ invFact = invBandTab[(iEnd - iStart) - 1];
+ invFact = MULSHIFT32(invBandTab[(mEnd - mStart) - 1], invFact) << 1;
+ t = MULSHIFT32(t, invFact);
+
+ for (m = mStart; m < mEnd; m++) {
+ psi->eCurr[m - sbrFreq->kStart] = t;
+ psi->eCurrExp[m - sbrFreq->kStart] = nScale + 1; /* +1 for invFact = Q31 */
+ }
+ if (psi->eCurrExp[mStart - sbrFreq->kStart] > expMax) {
+ expMax = psi->eCurrExp[mStart - sbrFreq->kStart];
+ }
+ }
+ }
+ psi->eCurrExpMax = expMax;
+}
+
+/**************************************************************************************
+ * Function: GetSMapped
+ *
+ * Description: calculate SMapped (4.6.18.7.2)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current envelope
+ * index of current QMF band
+ * la flag for this envelope
+ *
+ * Outputs: none
+ *
+ * Return: 1 if a sinusoid is present in this band, 0 if not
+ **************************************************************************************/
+static int GetSMapped(SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int env, int band, int la)
+{
+ int bandStart, bandEnd, oddFlag, r;
+
+ if (sbrGrid->freqRes[env]) {
+ /* high resolution */
+ bandStart = band;
+ bandEnd = band + 1;
+ } else {
+ /* low resolution (see CalcFreqLow() for mapping) */
+ oddFlag = sbrFreq->nHigh & 0x01;
+ bandStart = (band > 0 ? 2 * band - oddFlag : 0); /* starting index for freqLow[band] */
+ bandEnd = 2 * (band + 1) - oddFlag; /* ending index for freqLow[band+1] */
+ }
+
+ /* sMapped = 1 if sIndexMapped == 1 for any frequency in this band */
+ for (band = bandStart; band < bandEnd; band++) {
+ if (sbrChan->addHarmonic[1][band]) {
+ r = ((sbrFreq->freqHigh[band + 1] + sbrFreq->freqHigh[band]) >> 1);
+ if (env >= la || sbrChan->addHarmonic[0][r] == 1) {
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+#define GBOOST_MAX 0x2830afd3 /* Q28, 1.584893192 squared */
+#define ACC_SCALE 6
+
+/* squared version of table in 4.6.18.7.5 */
+static const int limGainTab[4] = {0x20138ca7, 0x40000000, 0x7fb27dce, 0x80000000}; /* Q30 (0x80000000 = sentinel for GMAX) */
+
+/**************************************************************************************
+ * Function: CalcMaxGain
+ *
+ * Description: calculate max gain in one limiter band (4.6.18.7.5)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ * index of current envelope
+ * index of current limiter band
+ * number of fraction bits in dequantized envelope
+ * (max = Q(FBITS_OUT_DQ_ENV - 6) = Q23, can go negative)
+ *
+ * Outputs: updated gainMax, gainMaxFBits, and sumEOrigMapped in PSInfoSBR struct
+ *
+ * Return: none
+ **************************************************************************************/
+static void CalcMaxGain(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, int ch, int env, int lim, int fbitsDQ)
+{
+ int m, mStart, mEnd, q, z, r;
+ int sumEOrigMapped, sumECurr, gainMax, eOMGainMax, envBand;
+ unsigned char eCurrExpMax;
+ unsigned char *freqBandTab;
+
+ mStart = sbrFreq->freqLimiter[lim]; /* these are offsets from kStart */
+ mEnd = sbrFreq->freqLimiter[lim + 1];
+ freqBandTab = (sbrGrid->freqRes[env] ? sbrFreq->freqHigh : sbrFreq->freqLow);
+
+ /* calculate max gain to apply to signal in this limiter band */
+ sumECurr = 0;
+ sumEOrigMapped = 0;
+ eCurrExpMax = psi->eCurrExpMax;
+ eOMGainMax = psi->eOMGainMax;
+ envBand = psi->envBand;
+ for (m = mStart; m < mEnd; m++) {
+ /* map current QMF band to appropriate envelope band */
+ if (m == freqBandTab[envBand + 1] - sbrFreq->kStart) {
+ envBand++;
+ eOMGainMax = psi->envDataDequant[ch][env][envBand] >> ACC_SCALE; /* summing max 48 bands */
+ }
+ sumEOrigMapped += eOMGainMax;
+
+ /* easy test for overflow on ARM */
+ sumECurr += (psi->eCurr[m] >> (eCurrExpMax - psi->eCurrExp[m]));
+ if (sumECurr >> 30) {
+ sumECurr >>= 1;
+ eCurrExpMax++;
+ }
+ }
+ psi->eOMGainMax = eOMGainMax;
+ psi->envBand = envBand;
+
+ psi->gainMaxFBits = 30; /* Q30 tables */
+ if (sumECurr == 0) {
+ /* any non-zero numerator * 1/EPS_0 is > G_MAX */
+ gainMax = (sumEOrigMapped == 0 ? limGainTab[sbrHdr->limiterGains] : 0x80000000);
+ } else if (sumEOrigMapped == 0) {
+ /* 1/(any non-zero denominator) * EPS_0 * limGainTab[x] is appx. 0 */
+ gainMax = 0;
+ } else {
+ /* sumEOrigMapped = Q(fbitsDQ - ACC_SCALE), sumECurr = Q(-eCurrExpMax) */
+ gainMax = limGainTab[sbrHdr->limiterGains];
+ if (sbrHdr->limiterGains != 3) {
+ q = MULSHIFT32(sumEOrigMapped, gainMax); /* Q(fbitsDQ - ACC_SCALE - 2), gainMax = Q30 */
+ z = CLZ(sumECurr) - 1;
+ r = InvRNormalized(sumECurr << z); /* in = Q(z - eCurrExpMax), out = Q(29 + 31 - z + eCurrExpMax) */
+ gainMax = MULSHIFT32(q, r); /* Q(29 + 31 - z + eCurrExpMax + fbitsDQ - ACC_SCALE - 2 - 32) */
+ psi->gainMaxFBits = 26 - z + eCurrExpMax + fbitsDQ - ACC_SCALE;
+ }
+ }
+ psi->sumEOrigMapped = sumEOrigMapped;
+ psi->gainMax = gainMax;
+}
+
+/**************************************************************************************
+ * Function: CalcNoiseDivFactors
+ *
+ * Description: calculate 1/(1+Q) and Q/(1+Q) (4.6.18.7.4; 4.6.18.7.5)
+ *
+ * Inputs: dequantized noise floor scalefactor
+ *
+ * Outputs: 1/(1+Q) and Q/(1+Q), format = Q31
+ *
+ * Return: none
+ **************************************************************************************/
+static void CalcNoiseDivFactors(int q, int *qp1Inv, int *qqp1Inv)
+{
+ int z, qp1, t, s;
+
+ /* 1 + Q_orig */
+ qp1 = (q >> 1);
+ qp1 += (1 << (FBITS_OUT_DQ_NOISE - 1)); /* >> 1 to avoid overflow when adding 1.0 */
+ z = CLZ(qp1) - 1; /* z <= 31 - FBITS_OUT_DQ_NOISE */
+ qp1 <<= z; /* Q(FBITS_OUT_DQ_NOISE + z) = Q31 * 2^-(31 - (FBITS_OUT_DQ_NOISE + z)) */
+ t = InvRNormalized(qp1) << 1; /* Q30 * 2^(31 - (FBITS_OUT_DQ_NOISE + z)), guaranteed not to overflow */
+
+ /* normalize to Q31 */
+ s = (31 - (FBITS_OUT_DQ_NOISE - 1) - z - 1); /* clearly z >= 0, z <= (30 - (FBITS_OUT_DQ_NOISE - 1)) */
+ *qp1Inv = (t >> s); /* s = [0, 31 - FBITS_OUT_DQ_NOISE] */
+ *qqp1Inv = MULSHIFT32(t, q) << (32 - FBITS_OUT_DQ_NOISE - s);
+}
+
+/**************************************************************************************
+ * Function: CalcComponentGains
+ *
+ * Description: calculate gain of envelope, sinusoids, and noise in one limiter band
+ * (4.6.18.7.5)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ * index of current envelope
+ * index of current limiter band
+ * number of fraction bits in dequantized envelope
+ *
+ * Outputs: gains for envelope, sinusoids and noise
+ * number of fraction bits for envelope gain
+ * sum of the total gain for each component in this band
+ * other updated state variables
+ *
+ * Return: none
+ **************************************************************************************/
+static void CalcComponentGains(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch, int env, int lim, int fbitsDQ)
+{
+ int d, m, mStart, mEnd, q, qm, noiseFloor, sIndexMapped;
+ int shift, eCurr, maxFlag, gainMax, gainMaxFBits;
+ int gain, sm, z, r, fbitsGain, gainScale;
+ unsigned char *freqBandTab;
+
+ mStart = sbrFreq->freqLimiter[lim]; /* these are offsets from kStart */
+ mEnd = sbrFreq->freqLimiter[lim + 1];
+
+ gainMax = psi->gainMax;
+ gainMaxFBits = psi->gainMaxFBits;
+
+ d = (env == psi->la || env == sbrChan->laPrev ? 0 : 1);
+ freqBandTab = (sbrGrid->freqRes[env] ? sbrFreq->freqHigh : sbrFreq->freqLow);
+
+ /* figure out which noise floor this envelope is in (only 1 or 2 noise floors allowed) */
+ noiseFloor = 0;
+ if (sbrGrid->numNoiseFloors == 2 && sbrGrid->noiseTimeBorder[1] <= sbrGrid->envTimeBorder[env]) {
+ noiseFloor++;
+ }
+
+ psi->sumECurrGLim = 0;
+ psi->sumSM = 0;
+ psi->sumQM = 0;
+ /* calculate energy of noise to add in this limiter band */
+ for (m = mStart; m < mEnd; m++) {
+ if (m == sbrFreq->freqNoise[psi->noiseFloorBand + 1] - sbrFreq->kStart) {
+ /* map current QMF band to appropriate noise floor band (NOTE: freqLimiter[0] == freqLow[0] = freqHigh[0]) */
+ psi->noiseFloorBand++;
+ CalcNoiseDivFactors(psi->noiseDataDequant[ch][noiseFloor][psi->noiseFloorBand], &(psi->qp1Inv), &(psi->qqp1Inv));
+ }
+ if (m == sbrFreq->freqHigh[psi->highBand + 1] - sbrFreq->kStart) {
+ psi->highBand++;
+ }
+ if (m == freqBandTab[psi->sBand + 1] - sbrFreq->kStart) {
+ psi->sBand++;
+ psi->sMapped = GetSMapped(sbrGrid, sbrFreq, sbrChan, env, psi->sBand, psi->la);
+ }
+
+ /* get sIndexMapped for this QMF subband */
+ sIndexMapped = 0;
+ r = ((sbrFreq->freqHigh[psi->highBand + 1] + sbrFreq->freqHigh[psi->highBand]) >> 1);
+ if (m + sbrFreq->kStart == r) {
+ /* r = center frequency, deltaStep = (env >= la || sIndexMapped'(r, numEnv'-1) == 1) */
+ if (env >= psi->la || sbrChan->addHarmonic[0][r] == 1) {
+ sIndexMapped = sbrChan->addHarmonic[1][psi->highBand];
+ }
+ }
+
+ /* save sine flags from last envelope in this frame:
+ * addHarmonic[0][0...63] = saved sine present flag from previous frame, for each QMF subband
+ * addHarmonic[1][0...nHigh-1] = addHarmonic bit from current frame, for each high-res frequency band
+ * from MPEG reference code - slightly different from spec
+ * (sIndexMapped'(m,LE'-1) can still be 0 when numEnv == psi->la)
+ */
+ if (env == sbrGrid->numEnv - 1) {
+ if (m + sbrFreq->kStart == r) {
+ sbrChan->addHarmonic[0][m + sbrFreq->kStart] = sbrChan->addHarmonic[1][psi->highBand];
+ } else {
+ sbrChan->addHarmonic[0][m + sbrFreq->kStart] = 0;
+ }
+ }
+
+ gain = psi->envDataDequant[ch][env][psi->sBand];
+ qm = MULSHIFT32(gain, psi->qqp1Inv) << 1;
+ sm = (sIndexMapped ? MULSHIFT32(gain, psi->qp1Inv) << 1 : 0);
+
+ /* three cases: (sMapped == 0 && delta == 1), (sMapped == 0 && delta == 0), (sMapped == 1) */
+ if (d == 1 && psi->sMapped == 0) {
+ gain = MULSHIFT32(psi->qp1Inv, gain) << 1;
+ } else if (psi->sMapped != 0) {
+ gain = MULSHIFT32(psi->qqp1Inv, gain) << 1;
+ }
+
+ /* gain, qm, sm = Q(fbitsDQ), gainMax = Q(fbitsGainMax) */
+ eCurr = psi->eCurr[m];
+ if (eCurr) {
+ z = CLZ(eCurr) - 1;
+ r = InvRNormalized(eCurr << z); /* in = Q(z - eCurrExp), out = Q(29 + 31 - z + eCurrExp) */
+ gainScale = MULSHIFT32(gain, r); /* out = Q(29 + 31 - z + eCurrExp + fbitsDQ - 32) */
+ fbitsGain = 29 + 31 - z + psi->eCurrExp[m] + fbitsDQ - 32;
+ } else {
+ /* if eCurr == 0, then gain is unchanged (divide by EPS = 1) */
+ gainScale = gain;
+ fbitsGain = fbitsDQ;
+ }
+
+ /* see if gain for this band exceeds max gain */
+ maxFlag = 0;
+ if (gainMax != (int)0x80000000) {
+ if (fbitsGain >= gainMaxFBits) {
+ shift = MIN(fbitsGain - gainMaxFBits, 31);
+ maxFlag = ((gainScale >> shift) > gainMax ? 1 : 0);
+ } else {
+ shift = MIN(gainMaxFBits - fbitsGain, 31);
+ maxFlag = (gainScale > (gainMax >> shift) ? 1 : 0);
+ }
+ }
+
+ if (maxFlag) {
+ /* gainScale > gainMax, calculate ratio with 32/16 division */
+ q = 0;
+ r = gainScale; /* guaranteed > 0, else maxFlag could not have been set */
+ z = CLZ(r);
+ if (z < 16) {
+ q = 16 - z;
+ r >>= q; /* out = Q(fbitsGain - q) */
+ }
+
+ z = CLZ(gainMax) - 1;
+ r = (gainMax << z) / r; /* out = Q((fbitsGainMax + z) - (fbitsGain - q)) */
+ q = (gainMaxFBits + z) - (fbitsGain - q); /* r = Q(q) */
+ if (q > 30) {
+ r >>= MIN(q - 30, 31);
+ } else {
+ z = MIN(30 - q, 30);
+ CLIP_2N_SHIFT30(r, z); /* let r = Q30 since range = [0.0, 1.0) (clip to 0x3fffffff = 0.99999) */
+ }
+
+ qm = MULSHIFT32(qm, r) << 2;
+ gain = MULSHIFT32(gain, r) << 2;
+ psi->gLimBuf[m] = gainMax;
+ psi->gLimFbits[m] = gainMaxFBits;
+ } else {
+ psi->gLimBuf[m] = gainScale;
+ psi->gLimFbits[m] = fbitsGain;
+ }
+
+ /* sumSM, sumQM, sumECurrGLim = Q(fbitsDQ - ACC_SCALE) */
+ psi->smBuf[m] = sm;
+ psi->sumSM += (sm >> ACC_SCALE);
+
+ psi->qmLimBuf[m] = qm;
+ if (env != psi->la && env != sbrChan->laPrev && sm == 0) {
+ psi->sumQM += (qm >> ACC_SCALE);
+ }
+
+ /* eCurr * gain^2 same as gain^2, before division by eCurr
+ * (but note that gain != 0 even if eCurr == 0, since it's divided by eps)
+ */
+ if (eCurr) {
+ psi->sumECurrGLim += (gain >> ACC_SCALE);
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: ApplyBoost
+ *
+ * Description: calculate and apply boost factor for envelope, sinusoids, and noise
+ * in this limiter band (4.6.18.7.5)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRFreq struct for this SCE/CPE block
+ * index of current limiter band
+ * number of fraction bits in dequantized envelope
+ *
+ * Outputs: envelope gain, sinusoids and noise after scaling by gBoost
+ * format = Q(FBITS_GLIM_BOOST) for envelope gain,
+ * = Q(FBITS_QLIM_BOOST) for noise
+ * = Q(FBITS_OUT_QMFA) for sinusoids
+ *
+ * Return: none
+ *
+ * Notes: after scaling, each component has at least 1 GB
+ **************************************************************************************/
+static void ApplyBoost(PSInfoSBR *psi, SBRFreq *sbrFreq, int lim, int fbitsDQ)
+{
+ int m, mStart, mEnd, q, z, r;
+ int sumEOrigMapped, gBoost;
+
+ mStart = sbrFreq->freqLimiter[lim]; /* these are offsets from kStart */
+ mEnd = sbrFreq->freqLimiter[lim + 1];
+
+ sumEOrigMapped = psi->sumEOrigMapped >> 1;
+ r = (psi->sumECurrGLim >> 1) + (psi->sumSM >> 1) + (psi->sumQM >> 1); /* 1 GB fine (sm and qm are mutually exclusive in acc) */
+ if (r < (1 << (31 - 28))) {
+ /* any non-zero numerator * 1/EPS_0 is > GBOOST_MAX
+ * round very small r to zero to avoid scaling problems
+ */
+ gBoost = (sumEOrigMapped == 0 ? (1 << 28) : GBOOST_MAX);
+ z = 0;
+ } else if (sumEOrigMapped == 0) {
+ /* 1/(any non-zero denominator) * EPS_0 is appx. 0 */
+ gBoost = 0;
+ z = 0;
+ } else {
+ /* numerator (sumEOrigMapped) and denominator (r) have same Q format (before << z) */
+ z = CLZ(r) - 1; /* z = [0, 27] */
+ r = InvRNormalized(r << z);
+ gBoost = MULSHIFT32(sumEOrigMapped, r);
+ }
+
+ /* gBoost = Q(28 - z) */
+ if (gBoost > (GBOOST_MAX >> z)) {
+ gBoost = GBOOST_MAX;
+ z = 0;
+ }
+ gBoost <<= z; /* gBoost = Q28, minimum 1 GB */
+
+ /* convert gain, noise, sinusoids to fixed Q format, clipping if necessary
+ * (rare, usually only happens at very low bitrates, introduces slight
+ * distortion into final HF mapping, but should be inaudible)
+ */
+ for (m = mStart; m < mEnd; m++) {
+ /* let gLimBoost = Q24, since in practice the max values are usually 16 to 20
+ * unless limiterGains == 3 (limiter off) and eCurr ~= 0 (i.e. huge gain, but only
+ * because the envelope has 0 power anyway)
+ */
+ q = MULSHIFT32(psi->gLimBuf[m], gBoost) << 2; /* Q(gLimFbits) * Q(28) --> Q(gLimFbits[m]-2) */
+ r = SqrtFix(q, psi->gLimFbits[m] - 2, &z);
+ z -= FBITS_GLIM_BOOST;
+ if (z >= 0) {
+ psi->gLimBoost[m] = r >> MIN(z, 31);
+ } else {
+ z = MIN(30, -z);
+ CLIP_2N_SHIFT30(r, z);
+ psi->gLimBoost[m] = r;
+ }
+
+ q = MULSHIFT32(psi->qmLimBuf[m], gBoost) << 2; /* Q(fbitsDQ) * Q(28) --> Q(fbitsDQ-2) */
+ r = SqrtFix(q, fbitsDQ - 2, &z);
+ z -= FBITS_QLIM_BOOST; /* << by 14, since integer sqrt of x < 2^16, and we want to leave 1 GB */
+ if (z >= 0) {
+ psi->qmLimBoost[m] = r >> MIN(31, z);
+ } else {
+ z = MIN(30, -z);
+ CLIP_2N_SHIFT30(r, z);
+ psi->qmLimBoost[m] = r;
+ }
+
+ q = MULSHIFT32(psi->smBuf[m], gBoost) << 2; /* Q(fbitsDQ) * Q(28) --> Q(fbitsDQ-2) */
+ r = SqrtFix(q, fbitsDQ - 2, &z);
+ z -= FBITS_OUT_QMFA; /* justify for adding to signal (xBuf) later */
+ if (z >= 0) {
+ psi->smBoost[m] = r >> MIN(31, z);
+ } else {
+ z = MIN(30, -z);
+ CLIP_2N_SHIFT30(r, z);
+ psi->smBoost[m] = r;
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: CalcGain
+ *
+ * Description: calculate and apply proper gain to HF components in one envelope
+ * (4.6.18.7.5)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ * index of current envelope
+ *
+ * Outputs: envelope gain, sinusoids and noise after scaling
+ *
+ * Return: none
+ **************************************************************************************/
+static void CalcGain(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch, int env)
+{
+ int lim, fbitsDQ;
+
+ /* initialize to -1 so that mapping limiter bands to env/noise bands works right on first pass */
+ psi->envBand = -1;
+ psi->noiseFloorBand = -1;
+ psi->sBand = -1;
+ psi->highBand = -1;
+
+ fbitsDQ = (FBITS_OUT_DQ_ENV - psi->envDataDequantScale[ch][env]); /* Q(29 - optional scalefactor) */
+ for (lim = 0; lim < sbrFreq->nLimiter; lim++) {
+ /* the QMF bands are divided into lim regions (consecutive, non-overlapping) */
+ CalcMaxGain(psi, sbrHdr, sbrGrid, sbrFreq, ch, env, lim, fbitsDQ);
+ CalcComponentGains(psi, sbrGrid, sbrFreq, sbrChan, ch, env, lim, fbitsDQ);
+ ApplyBoost(psi, sbrFreq, lim, fbitsDQ);
+ }
+}
+
+/* hSmooth table from 4.7.18.7.6, format = Q31 */
+static const int hSmoothCoef[MAX_NUM_SMOOTH_COEFS] = {
+ 0x2aaaaaab, 0x2697a512, 0x1becfa68, 0x0ebdb043, 0x04130598,
+};
+
+/**************************************************************************************
+ * Function: MapHF
+ *
+ * Description: map HF components to proper QMF bands, with optional gain smoothing
+ * filter (4.6.18.7.6)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current envelope
+ * reset flag (can be non-zero for first envelope only)
+ *
+ * Outputs: complete reconstructed subband QMF samples for this envelope
+ *
+ * Return: none
+ *
+ * Notes: ensures that output has >= MIN_GBITS_IN_QMFS guard bits,
+ * so it's not necessary to check anything in the synth QMF
+ **************************************************************************************/
+static int MapHF(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int env, int hfReset)
+{
+ int noiseTabIndex, sinIndex, gainNoiseIndex, hSL;
+ int i, iStart, iEnd, m, idx, j, s, n, smre, smim;
+ int gFilt, qFilt, xre, xim, gbMask, gbIdx;
+ int *XBuf;
+
+ noiseTabIndex = sbrChan->noiseTabIndex;
+ sinIndex = sbrChan->sinIndex;
+ gainNoiseIndex = sbrChan->gainNoiseIndex; /* oldest entries in filter delay buffer */
+
+ if (hfReset) {
+ noiseTabIndex = 2; /* starts at 1, double since complex */
+ }
+ hSL = (sbrHdr->smoothMode ? 0 : 4);
+
+ if (hfReset) {
+ for (i = 0; i < hSL; i++) {
+ for (m = 0; m < sbrFreq->numQMFBands; m++) {
+ sbrChan->gTemp[gainNoiseIndex][m] = psi->gLimBoost[m];
+ sbrChan->qTemp[gainNoiseIndex][m] = psi->qmLimBoost[m];
+ }
+ gainNoiseIndex++;
+ if (gainNoiseIndex == MAX_NUM_SMOOTH_COEFS) {
+ gainNoiseIndex = 0;
+ }
+ }
+ ASSERT(env == 0, ERR_AAC_SBR_BITSTREAM); /* should only be reset when env == 0 */
+ }
+
+ iStart = sbrGrid->envTimeBorder[env];
+ iEnd = sbrGrid->envTimeBorder[env + 1];
+ for (i = iStart; i < iEnd; i++) {
+ /* save new values in temp buffers (delay)
+ * we only store MAX_NUM_SMOOTH_COEFS most recent values,
+ * so don't keep storing the same value over and over
+ */
+ if (i - iStart < MAX_NUM_SMOOTH_COEFS) {
+ for (m = 0; m < sbrFreq->numQMFBands; m++) {
+ sbrChan->gTemp[gainNoiseIndex][m] = psi->gLimBoost[m];
+ sbrChan->qTemp[gainNoiseIndex][m] = psi->qmLimBoost[m];
+ }
+ }
+
+ /* see 4.6.18.7.6 */
+ XBuf = psi->XBuf[i + HF_ADJ][sbrFreq->kStart];
+ gbMask = 0;
+ for (m = 0; m < sbrFreq->numQMFBands; m++) {
+ if (env == psi->la || env == sbrChan->laPrev) {
+ /* no smoothing filter for gain, and qFilt = 0 (only need to do once) */
+ if (i == iStart) {
+ psi->gFiltLast[m] = sbrChan->gTemp[gainNoiseIndex][m];
+ psi->qFiltLast[m] = 0;
+ }
+ } else if (hSL == 0) {
+ /* no smoothing filter for gain, (only need to do once) */
+ if (i == iStart) {
+ psi->gFiltLast[m] = sbrChan->gTemp[gainNoiseIndex][m];
+ psi->qFiltLast[m] = sbrChan->qTemp[gainNoiseIndex][m];
+ }
+ } else {
+ /* apply smoothing filter to gain and noise (after MAX_NUM_SMOOTH_COEFS, it's always the same) */
+ if (i - iStart < MAX_NUM_SMOOTH_COEFS) {
+ gFilt = 0;
+ qFilt = 0;
+ idx = gainNoiseIndex;
+ for (j = 0; j < MAX_NUM_SMOOTH_COEFS; j++) {
+ /* sum(abs(hSmoothCoef[j])) for all j < 1.0 */
+ gFilt += MULSHIFT32(sbrChan->gTemp[idx][m], hSmoothCoef[j]);
+ qFilt += MULSHIFT32(sbrChan->qTemp[idx][m], hSmoothCoef[j]);
+ idx--;
+ if (idx < 0) {
+ idx += MAX_NUM_SMOOTH_COEFS;
+ }
+ }
+ psi->gFiltLast[m] = gFilt << 1; /* restore to Q(FBITS_GLIM_BOOST) (gain of filter < 1.0, so no overflow) */
+ psi->qFiltLast[m] = qFilt << 1; /* restore to Q(FBITS_QLIM_BOOST) */
+ }
+ }
+
+ if (psi->smBoost[m] != 0) {
+ /* add scaled signal and sinusoid, don't add noise (qFilt = 0) */
+ smre = psi->smBoost[m];
+ smim = smre;
+
+ /* sinIndex: [0] xre += sm [1] xim += sm*s [2] xre -= sm [3] xim -= sm*s */
+ s = (sinIndex >> 1); /* if 2 or 3, flip sign to subtract sm */
+ s <<= 31;
+ smre ^= (s >> 31);
+ smre -= (s >> 31);
+ s ^= ((m + sbrFreq->kStart) << 31);
+ smim ^= (s >> 31);
+ smim -= (s >> 31);
+
+ /* if sinIndex == 0 or 2, smim = 0; if sinIndex == 1 or 3, smre = 0 */
+ s = sinIndex << 31;
+ smim &= (s >> 31);
+ s ^= 0x80000000;
+ smre &= (s >> 31);
+
+ noiseTabIndex += 2; /* noise filtered by 0, but still need to bump index */
+ } else {
+ /* add scaled signal and scaled noise */
+ qFilt = psi->qFiltLast[m];
+ n = noiseTab[noiseTabIndex++];
+ smre = MULSHIFT32(n, qFilt) >> (FBITS_QLIM_BOOST - 1 - FBITS_OUT_QMFA);
+
+ n = noiseTab[noiseTabIndex++];
+ smim = MULSHIFT32(n, qFilt) >> (FBITS_QLIM_BOOST - 1 - FBITS_OUT_QMFA);
+ }
+ noiseTabIndex &= 1023; /* 512 complex numbers */
+
+ gFilt = psi->gFiltLast[m];
+ xre = MULSHIFT32(gFilt, XBuf[0]);
+ xim = MULSHIFT32(gFilt, XBuf[1]);
+ CLIP_2N_SHIFT30(xre, 32 - FBITS_GLIM_BOOST);
+ CLIP_2N_SHIFT30(xim, 32 - FBITS_GLIM_BOOST);
+
+ xre += smre;
+ *XBuf++ = xre;
+ xim += smim;
+ *XBuf++ = xim;
+
+ gbMask |= FASTABS(xre);
+ gbMask |= FASTABS(xim);
+ }
+ /* update circular buffer index */
+ gainNoiseIndex++;
+ if (gainNoiseIndex == MAX_NUM_SMOOTH_COEFS) {
+ gainNoiseIndex = 0;
+ }
+
+ sinIndex++;
+ sinIndex &= 3;
+
+ /* ensure MIN_GBITS_IN_QMFS guard bits in output
+ * almost never occurs in practice, but checking here makes synth QMF logic very simple
+ */
+ if (gbMask >> (31 - MIN_GBITS_IN_QMFS)) {
+ XBuf = psi->XBuf[i + HF_ADJ][sbrFreq->kStart];
+ for (m = 0; m < sbrFreq->numQMFBands; m++) {
+ xre = XBuf[0];
+ xim = XBuf[1];
+ CLIP_2N(xre, (31 - MIN_GBITS_IN_QMFS));
+ CLIP_2N(xim, (31 - MIN_GBITS_IN_QMFS));
+ *XBuf++ = xre;
+ *XBuf++ = xim;
+ }
+ CLIP_2N(gbMask, (31 - MIN_GBITS_IN_QMFS));
+ }
+ gbIdx = ((i + HF_ADJ) >> 5) & 0x01;
+ sbrChan->gbMask[gbIdx] |= gbMask;
+ }
+ sbrChan->noiseTabIndex = noiseTabIndex;
+ sbrChan->sinIndex = sinIndex;
+ sbrChan->gainNoiseIndex = gainNoiseIndex;
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: AdjustHighFreq
+ *
+ * Description: adjust high frequencies and add noise and sinusoids (4.6.18.7)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRHeader struct for this SCE/CPE block
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ *
+ * Outputs: complete reconstructed subband QMF samples for this channel
+ *
+ * Return: none
+ **************************************************************************************/
+int AdjustHighFreq(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch)
+{
+ int i, env, hfReset;
+ unsigned char frameClass, pointer;
+ int err = ERR_AAC_NONE;
+ frameClass = sbrGrid->frameClass;
+ pointer = sbrGrid->pointer;
+
+ /* derive la from table 4.159 */
+ if ((frameClass == SBR_GRID_FIXVAR || frameClass == SBR_GRID_VARVAR) && pointer > 0) {
+ psi->la = sbrGrid->numEnv + 1 - pointer;
+ } else if (frameClass == SBR_GRID_VARFIX && pointer > 1) {
+ psi->la = pointer - 1;
+ } else {
+ psi->la = -1;
+ }
+
+ /* for each envelope, estimate gain and adjust SBR QMF bands */
+ hfReset = sbrChan->reset;
+ for (env = 0; env < sbrGrid->numEnv; env++) {
+ EstimateEnvelope(psi, sbrHdr, sbrGrid, sbrFreq, env);
+ CalcGain(psi, sbrHdr, sbrGrid, sbrFreq, sbrChan, ch, env);
+ err = MapHF(psi, sbrHdr, sbrGrid, sbrFreq, sbrChan, env, hfReset);
+ if (err) {
+ return err;
+ }
+ hfReset = 0; /* only set for first envelope after header reset */
+ }
+
+ /* set saved sine flags to 0 for QMF bands outside of current frequency range */
+ for (i = 0; i < sbrFreq->freqLimiter[0] + sbrFreq->kStart; i++) {
+ sbrChan->addHarmonic[0][i] = 0;
+ }
+ for (i = sbrFreq->freqLimiter[sbrFreq->nLimiter] + sbrFreq->kStart; i < 64; i++) {
+ sbrChan->addHarmonic[0][i] = 0;
+ }
+ sbrChan->addHarmonicFlag[0] = sbrChan->addHarmonicFlag[1];
+
+ /* save la for next frame */
+ if (psi->la == sbrGrid->numEnv) {
+ sbrChan->laPrev = 0;
+ } else {
+ sbrChan->laPrev = -1;
+ }
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/wfd_aac_decoder/sbrhfgen.c b/audio_codec/wfd_aac_decoder/sbrhfgen.c
new file mode 100644
index 0000000..0ab7dad
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/sbrhfgen.c
@@ -0,0 +1,655 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrhfgen.c,v 1.1.2.2 2005/05/19 21:00:01 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrhfgen.c - high frequency generation for SBR
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+#define FBITS_LPCOEFS 29 /* Q29 for range of (-4, 4) */
+#define MAG_16 (16 * (1 << (32 - (2*(32-FBITS_LPCOEFS))))) /* i.e. 16 in Q26 format */
+#define RELAX_COEF 0x7ffff79c /* 1.0 / (1.0 + 1e-6), Q31 */
+
+/* newBWTab[prev invfMode][curr invfMode], format = Q31 (table 4.158)
+ * sample file which uses all of these: al_sbr_sr_64_2_fsaac32.aac
+ */
+static const int newBWTab[4][4] = {
+ {0x00000000, 0x4ccccccd, 0x73333333, 0x7d70a3d7},
+ {0x4ccccccd, 0x60000000, 0x73333333, 0x7d70a3d7},
+ {0x00000000, 0x60000000, 0x73333333, 0x7d70a3d7},
+ {0x00000000, 0x60000000, 0x73333333, 0x7d70a3d7},
+};
+
+/**************************************************************************************
+ * Function: CVKernel1
+ *
+ * Description: kernel of covariance matrix calculation for p01, p11, p12, p22
+ *
+ * Inputs: buffer of low-freq samples, starting at time index = 0,
+ * freq index = patch subband
+ *
+ * Outputs: 64-bit accumulators for p01re, p01im, p12re, p12im, p11re, p22re
+ * stored in accBuf
+ *
+ * Return: none
+ *
+ * Notes: this is carefully written to be efficient on ARM
+ * use the assembly code version in sbrcov.s when building for ARM!
+ **************************************************************************************/
+#if 0// (defined (__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(__arm__))
+#ifdef __cplusplus
+extern "C"
+#endif
+void CVKernel1(int *XBuf, int *accBuf);
+#else
+void CVKernel1(int *XBuf, int *accBuf)
+{
+ U64 p01re, p01im, p12re, p12im, p11re, p22re;
+ int n, x0re, x0im, x1re, x1im;
+
+ x0re = XBuf[0];
+ x0im = XBuf[1];
+ XBuf += (2 * 64);
+ x1re = XBuf[0];
+ x1im = XBuf[1];
+ XBuf += (2 * 64);
+
+ p01re.w64 = p01im.w64 = 0;
+ p12re.w64 = p12im.w64 = 0;
+ p11re.w64 = 0;
+ p22re.w64 = 0;
+
+ p12re.w64 = MADD64(p12re.w64, x1re, x0re);
+ p12re.w64 = MADD64(p12re.w64, x1im, x0im);
+ p12im.w64 = MADD64(p12im.w64, x0re, x1im);
+ p12im.w64 = MADD64(p12im.w64, -x0im, x1re);
+ p22re.w64 = MADD64(p22re.w64, x0re, x0re);
+ p22re.w64 = MADD64(p22re.w64, x0im, x0im);
+ for (n = (NUM_TIME_SLOTS * SAMPLES_PER_SLOT + 6); n != 0; n--) {
+ /* 4 input, 3*2 acc, 1 ptr, 1 loop counter = 12 registers (use same for x0im, -x0im) */
+ x0re = x1re;
+ x0im = x1im;
+ x1re = XBuf[0];
+ x1im = XBuf[1];
+
+ p01re.w64 = MADD64(p01re.w64, x1re, x0re);
+ p01re.w64 = MADD64(p01re.w64, x1im, x0im);
+ p01im.w64 = MADD64(p01im.w64, x0re, x1im);
+ p01im.w64 = MADD64(p01im.w64, -x0im, x1re);
+ p11re.w64 = MADD64(p11re.w64, x0re, x0re);
+ p11re.w64 = MADD64(p11re.w64, x0im, x0im);
+
+ XBuf += (2 * 64);
+ }
+ /* these can be derived by slight changes to account for boundary conditions */
+ p12re.w64 += p01re.w64;
+ p12re.w64 = MADD64(p12re.w64, x1re, -x0re);
+ p12re.w64 = MADD64(p12re.w64, x1im, -x0im);
+ p12im.w64 += p01im.w64;
+ p12im.w64 = MADD64(p12im.w64, x0re, -x1im);
+ p12im.w64 = MADD64(p12im.w64, x0im, x1re);
+ p22re.w64 += p11re.w64;
+ p22re.w64 = MADD64(p22re.w64, x0re, -x0re);
+ p22re.w64 = MADD64(p22re.w64, x0im, -x0im);
+
+ accBuf[0] = p01re.r.lo32;
+ accBuf[1] = p01re.r.hi32;
+ accBuf[2] = p01im.r.lo32;
+ accBuf[3] = p01im.r.hi32;
+ accBuf[4] = p11re.r.lo32;
+ accBuf[5] = p11re.r.hi32;
+ accBuf[6] = p12re.r.lo32;
+ accBuf[7] = p12re.r.hi32;
+ accBuf[8] = p12im.r.lo32;
+ accBuf[9] = p12im.r.hi32;
+ accBuf[10] = p22re.r.lo32;
+ accBuf[11] = p22re.r.hi32;
+}
+#endif
+
+/**************************************************************************************
+ * Function: CalcCovariance1
+ *
+ * Description: calculate covariance matrix for p01, p12, p11, p22 (4.6.18.6.2)
+ *
+ * Inputs: buffer of low-freq samples, starting at time index 0,
+ * freq index = patch subband
+ *
+ * Outputs: complex covariance elements p01re, p01im, p12re, p12im, p11re, p22re
+ * (p11im = p22im = 0)
+ * format = integer (Q0) * 2^N, with scalefactor N >= 0
+ *
+ * Return: scalefactor N
+ *
+ * Notes: outputs are normalized to have 1 GB (sign in at least top 2 bits)
+ **************************************************************************************/
+static int CalcCovariance1(int *XBuf, int *p01reN, int *p01imN, int *p12reN, int *p12imN, int *p11reN, int *p22reN)
+{
+ int accBuf[2 * 6];
+ int n, z, s, loShift, hiShift, gbMask;
+ U64 p01re, p01im, p12re, p12im, p11re, p22re;
+
+ CVKernel1(XBuf, accBuf);
+ p01re.r.lo32 = accBuf[0];
+ p01re.r.hi32 = accBuf[1];
+ p01im.r.lo32 = accBuf[2];
+ p01im.r.hi32 = accBuf[3];
+ p11re.r.lo32 = accBuf[4];
+ p11re.r.hi32 = accBuf[5];
+ p12re.r.lo32 = accBuf[6];
+ p12re.r.hi32 = accBuf[7];
+ p12im.r.lo32 = accBuf[8];
+ p12im.r.hi32 = accBuf[9];
+ p22re.r.lo32 = accBuf[10];
+ p22re.r.hi32 = accBuf[11];
+
+ /* 64-bit accumulators now have 2*FBITS_OUT_QMFA fraction bits
+ * want to scale them down to integers (32-bit signed, Q0)
+ * with scale factor of 2^n, n >= 0
+ * leave 2 GB's for calculating determinant, so take top 30 non-zero bits
+ */
+ gbMask = ((p01re.r.hi32) ^(p01re.r.hi32 >> 31)) | ((p01im.r.hi32) ^(p01im.r.hi32 >> 31));
+ gbMask |= ((p12re.r.hi32) ^(p12re.r.hi32 >> 31)) | ((p12im.r.hi32) ^(p12im.r.hi32 >> 31));
+ gbMask |= ((p11re.r.hi32) ^(p11re.r.hi32 >> 31)) | ((p22re.r.hi32) ^(p22re.r.hi32 >> 31));
+ if (gbMask == 0) {
+ s = p01re.r.hi32 >> 31;
+ gbMask = (p01re.r.lo32 ^ s) - s;
+ s = p01im.r.hi32 >> 31;
+ gbMask |= (p01im.r.lo32 ^ s) - s;
+ s = p12re.r.hi32 >> 31;
+ gbMask |= (p12re.r.lo32 ^ s) - s;
+ s = p12im.r.hi32 >> 31;
+ gbMask |= (p12im.r.lo32 ^ s) - s;
+ s = p11re.r.hi32 >> 31;
+ gbMask |= (p11re.r.lo32 ^ s) - s;
+ s = p22re.r.hi32 >> 31;
+ gbMask |= (p22re.r.lo32 ^ s) - s;
+ z = 32 + CLZ(gbMask);
+ } else {
+ gbMask = FASTABS(p01re.r.hi32) | FASTABS(p01im.r.hi32);
+ gbMask |= FASTABS(p12re.r.hi32) | FASTABS(p12im.r.hi32);
+ gbMask |= FASTABS(p11re.r.hi32) | FASTABS(p22re.r.hi32);
+ z = CLZ(gbMask);
+ }
+
+ n = 64 - z; /* number of non-zero bits in bottom of 64-bit word */
+ if (n <= 30) {
+ loShift = (30 - n);
+ *p01reN = p01re.r.lo32 << loShift;
+ *p01imN = p01im.r.lo32 << loShift;
+ *p12reN = p12re.r.lo32 << loShift;
+ *p12imN = p12im.r.lo32 << loShift;
+ *p11reN = p11re.r.lo32 << loShift;
+ *p22reN = p22re.r.lo32 << loShift;
+ return -(loShift + 2 * FBITS_OUT_QMFA);
+ } else if (n < 32 + 30) {
+ loShift = (n - 30);
+ hiShift = 32 - loShift;
+ *p01reN = (p01re.r.hi32 << hiShift) | (p01re.r.lo32 >> loShift);
+ *p01imN = (p01im.r.hi32 << hiShift) | (p01im.r.lo32 >> loShift);
+ *p12reN = (p12re.r.hi32 << hiShift) | (p12re.r.lo32 >> loShift);
+ *p12imN = (p12im.r.hi32 << hiShift) | (p12im.r.lo32 >> loShift);
+ *p11reN = (p11re.r.hi32 << hiShift) | (p11re.r.lo32 >> loShift);
+ *p22reN = (p22re.r.hi32 << hiShift) | (p22re.r.lo32 >> loShift);
+ return (loShift - 2 * FBITS_OUT_QMFA);
+ } else {
+ hiShift = n - (32 + 30);
+ *p01reN = p01re.r.hi32 >> hiShift;
+ *p01imN = p01im.r.hi32 >> hiShift;
+ *p12reN = p12re.r.hi32 >> hiShift;
+ *p12imN = p12im.r.hi32 >> hiShift;
+ *p11reN = p11re.r.hi32 >> hiShift;
+ *p22reN = p22re.r.hi32 >> hiShift;
+ return (32 - 2 * FBITS_OUT_QMFA - hiShift);
+ }
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: CVKernel2
+ *
+ * Description: kernel of covariance matrix calculation for p02
+ *
+ * Inputs: buffer of low-freq samples, starting at time index = 0,
+ * freq index = patch subband
+ *
+ * Outputs: 64-bit accumulators for p02re, p02im stored in accBuf
+ *
+ * Return: none
+ *
+ * Notes: this is carefully written to be efficient on ARM
+ * use the assembly code version in sbrcov.s when building for ARM!
+ **************************************************************************************/
+#if 0// (defined (__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(__arm__))
+#ifdef __cplusplus
+extern "C"
+#endif
+void CVKernel2(int *XBuf, int *accBuf);
+#else
+void CVKernel2(int *XBuf, int *accBuf)
+{
+ U64 p02re, p02im;
+ int n, x0re, x0im, x1re, x1im, x2re, x2im;
+
+ p02re.w64 = p02im.w64 = 0;
+
+ x0re = XBuf[0];
+ x0im = XBuf[1];
+ XBuf += (2 * 64);
+ x1re = XBuf[0];
+ x1im = XBuf[1];
+ XBuf += (2 * 64);
+
+ for (n = (NUM_TIME_SLOTS * SAMPLES_PER_SLOT + 6); n != 0; n--) {
+ /* 6 input, 2*2 acc, 1 ptr, 1 loop counter = 12 registers (use same for x0im, -x0im) */
+ x2re = XBuf[0];
+ x2im = XBuf[1];
+
+ p02re.w64 = MADD64(p02re.w64, x2re, x0re);
+ p02re.w64 = MADD64(p02re.w64, x2im, x0im);
+ p02im.w64 = MADD64(p02im.w64, x0re, x2im);
+ p02im.w64 = MADD64(p02im.w64, -x0im, x2re);
+
+ x0re = x1re;
+ x0im = x1im;
+ x1re = x2re;
+ x1im = x2im;
+ XBuf += (2 * 64);
+ }
+
+ accBuf[0] = p02re.r.lo32;
+ accBuf[1] = p02re.r.hi32;
+ accBuf[2] = p02im.r.lo32;
+ accBuf[3] = p02im.r.hi32;
+}
+#endif
+
+/**************************************************************************************
+ * Function: CalcCovariance2
+ *
+ * Description: calculate covariance matrix for p02 (4.6.18.6.2)
+ *
+ * Inputs: buffer of low-freq samples, starting at time index = 0,
+ * freq index = patch subband
+ *
+ * Outputs: complex covariance element p02re, p02im
+ * format = integer (Q0) * 2^N, with scalefactor N >= 0
+ *
+ * Return: scalefactor N
+ *
+ * Notes: outputs are normalized to have 1 GB (sign in at least top 2 bits)
+ **************************************************************************************/
+static int CalcCovariance2(int *XBuf, int *p02reN, int *p02imN)
+{
+ U64 p02re, p02im;
+ int n, z, s, loShift, hiShift, gbMask;
+ int accBuf[2 * 2];
+
+ CVKernel2(XBuf, accBuf);
+ p02re.r.lo32 = accBuf[0];
+ p02re.r.hi32 = accBuf[1];
+ p02im.r.lo32 = accBuf[2];
+ p02im.r.hi32 = accBuf[3];
+
+ /* 64-bit accumulators now have 2*FBITS_OUT_QMFA fraction bits
+ * want to scale them down to integers (32-bit signed, Q0)
+ * with scale factor of 2^n, n >= 0
+ * leave 1 GB for calculating determinant, so take top 30 non-zero bits
+ */
+ gbMask = ((p02re.r.hi32) ^(p02re.r.hi32 >> 31)) | ((p02im.r.hi32) ^(p02im.r.hi32 >> 31));
+ if (gbMask == 0) {
+ s = p02re.r.hi32 >> 31;
+ gbMask = (p02re.r.lo32 ^ s) - s;
+ s = p02im.r.hi32 >> 31;
+ gbMask |= (p02im.r.lo32 ^ s) - s;
+ z = 32 + CLZ(gbMask);
+ } else {
+ gbMask = FASTABS(p02re.r.hi32) | FASTABS(p02im.r.hi32);
+ z = CLZ(gbMask);
+ }
+ n = 64 - z; /* number of non-zero bits in bottom of 64-bit word */
+
+ if (n <= 30) {
+ loShift = (30 - n);
+ *p02reN = p02re.r.lo32 << loShift;
+ *p02imN = p02im.r.lo32 << loShift;
+ return -(loShift + 2 * FBITS_OUT_QMFA);
+ } else if (n < 32 + 30) {
+ loShift = (n - 30);
+ hiShift = 32 - loShift;
+ *p02reN = (p02re.r.hi32 << hiShift) | (p02re.r.lo32 >> loShift);
+ *p02imN = (p02im.r.hi32 << hiShift) | (p02im.r.lo32 >> loShift);
+ return (loShift - 2 * FBITS_OUT_QMFA);
+ } else {
+ hiShift = n - (32 + 30);
+ *p02reN = p02re.r.hi32 >> hiShift;
+ *p02imN = p02im.r.hi32 >> hiShift;
+ return (32 - 2 * FBITS_OUT_QMFA - hiShift);
+ }
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: CalcLPCoefs
+ *
+ * Description: calculate linear prediction coefficients for one subband (4.6.18.6.2)
+ *
+ * Inputs: buffer of low-freq samples, starting at time index = 0,
+ * freq index = patch subband
+ * number of guard bits in input sample buffer
+ *
+ * Outputs: complex LP coefficients a0re, a0im, a1re, a1im, format = Q29
+ *
+ * Return: none
+ *
+ * Notes: output coefficients (a0re, a0im, a1re, a1im) clipped to range (-4, 4)
+ * if the comples coefficients have magnitude >= 4.0, they are all
+ * set to 0 (see spec)
+ **************************************************************************************/
+static int CalcLPCoefs(int *XBuf, int *a0re, int *a0im, int *a1re, int *a1im, int gb)
+{
+ int zFlag, n1, n2, nd, d, dInv, tre, tim;
+ int p01re, p01im, p02re, p02im, p12re, p12im, p11re, p22re;
+
+ /* pre-scale to avoid overflow - probably never happens in practice (see QMFA)
+ * max bit growth per accumulator = 38*2 = 76 mul-adds (X * X)
+ * using 64-bit MADD, so if X has n guard bits, X*X has 2n+1 guard bits
+ * gain 1 extra sign bit per multiply, so ensure ceil(log2(76/2) / 2) = 3 guard bits on inputs
+ */
+ if (gb < 3) {
+ nd = 3 - gb;
+ for (n1 = (NUM_TIME_SLOTS * SAMPLES_PER_SLOT + 6 + 2); n1 != 0; n1--) {
+ XBuf[0] >>= nd;
+ XBuf[1] >>= nd;
+ XBuf += (2 * 64);
+ }
+ XBuf -= (2 * 64 * (NUM_TIME_SLOTS * SAMPLES_PER_SLOT + 6 + 2));
+ }
+
+ /* calculate covariance elements */
+ n1 = CalcCovariance1(XBuf, &p01re, &p01im, &p12re, &p12im, &p11re, &p22re);
+ n2 = CalcCovariance2(XBuf, &p02re, &p02im);
+
+ /* normalize everything to larger power of 2 scalefactor, call it n1 */
+ if (n1 < n2) {
+ nd = MIN(n2 - n1, 31);
+ p01re >>= nd;
+ p01im >>= nd;
+ p12re >>= nd;
+ p12im >>= nd;
+ p11re >>= nd;
+ p22re >>= nd;
+ n1 = n2;
+ } else if (n1 > n2) {
+ nd = MIN(n1 - n2, 31);
+ p02re >>= nd;
+ p02im >>= nd;
+ }
+
+ /* calculate determinant of covariance matrix (at least 1 GB in pXX) */
+ d = MULSHIFT32(p12re, p12re) + MULSHIFT32(p12im, p12im);
+ d = MULSHIFT32(d, RELAX_COEF) << 1;
+ d = MULSHIFT32(p11re, p22re) - d;
+ //this assert always failed,no a fatal error when decoder sbr data ????.
+ //ASSERT(d >= 0,ERR_AAC_SBR_BITSTREAM); /* should never be < 0 */
+
+ zFlag = 0;
+ *a0re = *a0im = 0;
+ *a1re = *a1im = 0;
+ if (d > 0) {
+ /* input = Q31 d = Q(-2*n1 - 32 + nd) = Q31 * 2^(31 + 2*n1 + 32 - nd)
+ * inverse = Q29 dInv = Q29 * 2^(-31 - 2*n1 - 32 + nd) = Q(29 + 31 + 2*n1 + 32 - nd)
+ *
+ * numerator has same Q format as d, since it's sum of normalized squares
+ * so num * inverse = Q(-2*n1 - 32) * Q(29 + 31 + 2*n1 + 32 - nd)
+ * = Q(29 + 31 - nd), drop low 32 in MULSHIFT32
+ * = Q(29 + 31 - 32 - nd) = Q(28 - nd)
+ */
+ nd = CLZ(d) - 1;
+ d <<= nd;
+ dInv = InvRNormalized(d);
+
+ /* 1 GB in pXX */
+ tre = MULSHIFT32(p01re, p12re) - MULSHIFT32(p01im, p12im) - MULSHIFT32(p02re, p11re);
+ tre = MULSHIFT32(tre, dInv);
+ tim = MULSHIFT32(p01re, p12im) + MULSHIFT32(p01im, p12re) - MULSHIFT32(p02im, p11re);
+ tim = MULSHIFT32(tim, dInv);
+
+ /* if d is extremely small, just set coefs to 0 (would have poor precision anyway) */
+ if (nd > 28 || (FASTABS(tre) >> (28 - nd)) >= 4 || (FASTABS(tim) >> (28 - nd)) >= 4) {
+ zFlag = 1;
+ } else {
+ *a1re = tre << (FBITS_LPCOEFS - 28 + nd); /* i.e. convert Q(28 - nd) to Q(29) */
+ *a1im = tim << (FBITS_LPCOEFS - 28 + nd);
+ }
+ }
+
+ if (p11re) {
+ /* input = Q31 p11re = Q(-n1 + nd) = Q31 * 2^(31 + n1 - nd)
+ * inverse = Q29 dInv = Q29 * 2^(-31 - n1 + nd) = Q(29 + 31 + n1 - nd)
+ *
+ * numerator is Q(-n1 - 3)
+ * so num * inverse = Q(-n1 - 3) * Q(29 + 31 + n1 - nd)
+ * = Q(29 + 31 - 3 - nd), drop low 32 in MULSHIFT32
+ * = Q(29 + 31 - 3 - 32 - nd) = Q(25 - nd)
+ */
+ nd = CLZ(p11re) - 1; /* assume positive */
+ p11re <<= nd;
+ dInv = InvRNormalized(p11re);
+
+ /* a1re, a1im = Q29, so scaled by (n1 + 3) */
+ tre = (p01re >> 3) + MULSHIFT32(p12re, *a1re) + MULSHIFT32(p12im, *a1im);
+ tre = -MULSHIFT32(tre, dInv);
+ tim = (p01im >> 3) - MULSHIFT32(p12im, *a1re) + MULSHIFT32(p12re, *a1im);
+ tim = -MULSHIFT32(tim, dInv);
+
+ if (nd > 25 || (FASTABS(tre) >> (25 - nd)) >= 4 || (FASTABS(tim) >> (25 - nd)) >= 4) {
+ zFlag = 1;
+ } else {
+ *a0re = tre << (FBITS_LPCOEFS - 25 + nd); /* i.e. convert Q(25 - nd) to Q(29) */
+ *a0im = tim << (FBITS_LPCOEFS - 25 + nd);
+ }
+ }
+
+ /* see 4.6.18.6.2 - if magnitude of a0 or a1 >= 4 then a0 = a1 = 0
+ * i.e. a0re < 4, a0im < 4, a1re < 4, a1im < 4
+ * Q29*Q29 = Q26
+ */
+ if (zFlag || MULSHIFT32(*a0re, *a0re) + MULSHIFT32(*a0im, *a0im) >= MAG_16 || MULSHIFT32(*a1re, *a1re) + MULSHIFT32(*a1im, *a1im) >= MAG_16) {
+ *a0re = *a0im = 0;
+ *a1re = *a1im = 0;
+ }
+
+ /* no need to clip - we never changed the XBuf data, just used it to calculate a0 and a1 */
+ if (gb < 3) {
+ nd = 3 - gb;
+ for (n1 = (NUM_TIME_SLOTS * SAMPLES_PER_SLOT + 6 + 2); n1 != 0; n1--) {
+ XBuf[0] <<= nd;
+ XBuf[1] <<= nd;
+ XBuf += (2 * 64);
+ }
+ }
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: GenerateHighFreq
+ *
+ * Description: generate high frequencies with SBR (4.6.18.6)
+ *
+ * Inputs: initialized PSInfoSBR struct
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ *
+ * Outputs: new high frequency samples starting at frequency kStart
+ *
+ * Return: none
+ **************************************************************************************/
+int GenerateHighFreq(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch)
+{
+ int band, newBW, c, t, gb, gbMask, gbIdx;
+ int currPatch, p, x, k, g, i, iStart, iEnd, bw, bwsq;
+ int a0re, a0im, a1re, a1im;
+ int x1re, x1im, x2re, x2im;
+ int ACCre, ACCim;
+ int *XBufLo, *XBufHi;
+ int err = ERR_AAC_NONE;
+ /* calculate array of chirp factors */
+ for (band = 0; band < sbrFreq->numNoiseFloorBands; band++) {
+ c = sbrChan->chirpFact[band]; /* previous (bwArray') */
+ newBW = newBWTab[sbrChan->invfMode[0][band]][sbrChan->invfMode[1][band]];
+
+ /* weighted average of new and old (can't overflow - total gain = 1.0) */
+ if (newBW < c) {
+ t = MULSHIFT32(newBW, 0x60000000) + MULSHIFT32(0x20000000, c); /* new is smaller: 0.75*new + 0.25*old */
+ } else {
+ t = MULSHIFT32(newBW, 0x74000000) + MULSHIFT32(0x0c000000, c); /* new is larger: 0.90625*new + 0.09375*old */
+ }
+ t <<= 1;
+
+ if (t < 0x02000000) { /* below 0.015625, clip to 0 */
+ t = 0;
+ }
+ if (t > 0x7f800000) { /* clip to 0.99609375 */
+ t = 0x7f800000;
+ }
+
+ /* save curr as prev for next time */
+ sbrChan->chirpFact[band] = t;
+ sbrChan->invfMode[0][band] = sbrChan->invfMode[1][band];
+ }
+
+ iStart = sbrGrid->envTimeBorder[0] + HF_ADJ;
+ iEnd = sbrGrid->envTimeBorder[sbrGrid->numEnv] + HF_ADJ;
+
+ /* generate new high freqs from low freqs, patches, and chirp factors */
+ k = sbrFreq->kStart;
+ g = 0;
+ bw = sbrChan->chirpFact[g];
+ bwsq = MULSHIFT32(bw, bw) << 1;
+
+ gbMask = (sbrChan->gbMask[0] | sbrChan->gbMask[1]); /* older 32 | newer 8 */
+ gb = CLZ(gbMask) - 1;
+
+ for (currPatch = 0; currPatch < sbrFreq->numPatches; currPatch++) {
+ for (x = 0; x < sbrFreq->patchNumSubbands[currPatch]; x++) {
+ /* map k to corresponding noise floor band */
+ if (k >= sbrFreq->freqNoise[g + 1]) {
+ g++;
+ bw = sbrChan->chirpFact[g]; /* Q31 */
+ bwsq = MULSHIFT32(bw, bw) << 1; /* Q31 */
+ }
+
+ p = sbrFreq->patchStartSubband[currPatch] + x; /* low QMF band */
+ XBufHi = psi->XBuf[iStart][k];
+ if (bw) {
+ err = CalcLPCoefs(psi->XBuf[0][p], &a0re, &a0im, &a1re, &a1im, gb);
+ if (err) {
+ return err;
+ }
+ a0re = MULSHIFT32(bw, a0re); /* Q31 * Q29 = Q28 */
+ a0im = MULSHIFT32(bw, a0im);
+ a1re = MULSHIFT32(bwsq, a1re);
+ a1im = MULSHIFT32(bwsq, a1im);
+
+ XBufLo = psi->XBuf[iStart - 2][p];
+
+ x2re = XBufLo[0]; /* RE{XBuf[n-2]} */
+ x2im = XBufLo[1]; /* IM{XBuf[n-2]} */
+ XBufLo += (64 * 2);
+
+ x1re = XBufLo[0]; /* RE{XBuf[n-1]} */
+ x1im = XBufLo[1]; /* IM{XBuf[n-1]} */
+ XBufLo += (64 * 2);
+
+ for (i = iStart; i < iEnd; i++) {
+ /* a0re/im, a1re/im are Q28 with at least 1 GB,
+ * so the summing for AACre/im is fine (1 GB in, plus 1 from MULSHIFT32)
+ */
+ ACCre = MULSHIFT32(x2re, a1re) - MULSHIFT32(x2im, a1im);
+ ACCim = MULSHIFT32(x2re, a1im) + MULSHIFT32(x2im, a1re);
+ x2re = x1re;
+ x2im = x1im;
+
+ ACCre += MULSHIFT32(x1re, a0re) - MULSHIFT32(x1im, a0im);
+ ACCim += MULSHIFT32(x1re, a0im) + MULSHIFT32(x1im, a0re);
+ x1re = XBufLo[0]; /* RE{XBuf[n]} */
+ x1im = XBufLo[1]; /* IM{XBuf[n]} */
+ XBufLo += (64 * 2);
+
+ /* lost 4 fbits when scaling by a0re/im, a1re/im (Q28) */
+ CLIP_2N_SHIFT30(ACCre, 4);
+ ACCre += x1re;
+ CLIP_2N_SHIFT30(ACCim, 4);
+ ACCim += x1im;
+
+ XBufHi[0] = ACCre;
+ XBufHi[1] = ACCim;
+ XBufHi += (64 * 2);
+
+ /* update guard bit masks */
+ gbMask = FASTABS(ACCre);
+ gbMask |= FASTABS(ACCim);
+ gbIdx = (i >> 5) & 0x01; /* 0 if i < 32, 1 if i >= 32 */
+ sbrChan->gbMask[gbIdx] |= gbMask;
+ }
+ } else {
+ XBufLo = (int *)psi->XBuf[iStart][p];
+ for (i = iStart; i < iEnd; i++) {
+ XBufHi[0] = XBufLo[0];
+ XBufHi[1] = XBufLo[1];
+ XBufLo += (64 * 2);
+ XBufHi += (64 * 2);
+ }
+ }
+ k++; /* high QMF band */
+ }
+ }
+ return ERR_AAC_NONE;
+}
+
+
diff --git a/audio_codec/wfd_aac_decoder/sbrhuff.c b/audio_codec/wfd_aac_decoder/sbrhuff.c
new file mode 100644
index 0000000..35e759f
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/sbrhuff.c
@@ -0,0 +1,494 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrhuff.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrhuff.c - functions for unpacking Huffman-coded envelope and noise data
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+/**************************************************************************************
+ * Function: DecodeHuffmanScalar
+ *
+ * Description: decode one Huffman symbol from bitstream
+ *
+ * Inputs: pointers to Huffman table and info struct
+ * left-aligned bit buffer with >= huffTabInfo->maxBits bits
+ *
+ * Outputs: decoded symbol in *val
+ *
+ * Return: number of bits in symbol
+ *
+ * Notes: assumes canonical Huffman codes:
+ * first CW always 0, we have "count" CW's of length "nBits" bits
+ * starting CW for codes of length nBits+1 =
+ * (startCW[nBits] + count[nBits]) << 1
+ * if there are no codes at nBits, then we just keep << 1 each time
+ * (since count[nBits] = 0)
+ **************************************************************************************/
+static int DecodeHuffmanScalar(const signed short *huffTab, const HuffInfo *huffTabInfo, unsigned int bitBuf, signed int *val)
+{
+ unsigned int count, start, shift, t;
+ const unsigned char *countPtr;
+ const signed short *map;
+
+ map = huffTab + huffTabInfo->offset;
+ countPtr = huffTabInfo->count;
+
+ start = 0;
+ count = 0;
+ shift = 32;
+ do {
+ start += count;
+ start <<= 1;
+ map += count;
+ count = *countPtr++;
+ shift--;
+ t = (bitBuf >> shift) - start;
+ } while (t >= count);
+
+ *val = (signed int)map[t];
+ return (countPtr - huffTabInfo->count);
+}
+
+/**************************************************************************************
+ * Function: DecodeOneSymbol
+ *
+ * Description: dequantize one Huffman symbol from bitstream,
+ * using table huffTabSBR[huffTabIndex]
+ *
+ * Inputs: BitStreamInfo struct pointing to start of next Huffman codeword
+ * index of Huffman table
+ *
+ * Outputs: bitstream advanced by number of bits in codeword
+ *
+ * Return: one decoded symbol
+ **************************************************************************************/
+static int DecodeOneSymbol(BitStreamInfo *bsi, int huffTabIndex)
+{
+ int nBits, val;
+ unsigned int bitBuf;
+ const HuffInfo *hi;
+
+ hi = &(huffTabSBRInfo[huffTabIndex]);
+
+ bitBuf = GetBitsNoAdvance(bsi, hi->maxBits) << (32 - hi->maxBits);
+ nBits = DecodeHuffmanScalar(huffTabSBR, hi, bitBuf, &val);
+ AdvanceBitstream(bsi, nBits);
+
+ return val;
+}
+
+/* [1.0, sqrt(2)], format = Q29 (one guard bit for decoupling) */
+static const int envDQTab[2] = {0x20000000, 0x2d413ccc};
+
+/**************************************************************************************
+ * Function: DequantizeEnvelope
+ *
+ * Description: dequantize envelope scalefactors
+ *
+ * Inputs: number of scalefactors to process
+ * amplitude resolution flag for this frame (0 or 1)
+ * quantized envelope scalefactors
+ *
+ * Outputs: dequantized envelope scalefactors
+ *
+ * Return: extra int bits in output (6 + expMax)
+ * in other words, output format = Q(FBITS_OUT_DQ_ENV - (6 + expMax))
+ *
+ * Notes: dequantized scalefactors have at least 2 GB
+ **************************************************************************************/
+static int DequantizeEnvelope(int nBands, int ampRes, signed char *envQuant, int *envDequant)
+{
+ int exp, expMax, i, scalei;
+
+ if (nBands <= 0) {
+ return 0;
+ }
+
+ /* scan for largest dequant value (do separately from envelope decoding to keep code cleaner) */
+ expMax = 0;
+ for (i = 0; i < nBands; i++) {
+ if (envQuant[i] > expMax) {
+ expMax = envQuant[i];
+ }
+ }
+
+ /* dequantized envelope gains
+ * envDequant = 64*2^(envQuant / alpha) = 2^(6 + envQuant / alpha)
+ * if ampRes == 0, alpha = 2 and range of envQuant = [0, 127]
+ * if ampRes == 1, alpha = 1 and range of envQuant = [0, 63]
+ * also if coupling is on, envDequant is scaled by something in range [0, 2]
+ * so range of envDequant = [2^6, 2^69] (no coupling), [2^6, 2^70] (with coupling)
+ *
+ * typical range (from observation) of envQuant/alpha = [0, 27] --> largest envQuant ~= 2^33
+ * output: Q(29 - (6 + expMax))
+ *
+ * reference: 14496-3:2001(E)/4.6.18.3.5 and 14496-4:200X/FPDAM8/5.6.5.1.2.1.5
+ */
+ if (ampRes) {
+ do {
+ exp = *envQuant++;
+ scalei = MIN(expMax - exp, 31);
+ *envDequant++ = envDQTab[0] >> scalei;
+ } while (--nBands);
+
+ return (6 + expMax);
+ } else {
+ expMax >>= 1;
+ do {
+ exp = *envQuant++;
+ scalei = MIN(expMax - (exp >> 1), 31);
+ *envDequant++ = envDQTab[exp & 0x01] >> scalei;
+ } while (--nBands);
+
+ return (6 + expMax);
+ }
+
+}
+
+/**************************************************************************************
+ * Function: DequantizeNoise
+ *
+ * Description: dequantize noise scalefactors
+ *
+ * Inputs: number of scalefactors to process
+ * quantized noise scalefactors
+ *
+ * Outputs: dequantized noise scalefactors, format = Q(FBITS_OUT_DQ_NOISE)
+ *
+ * Return: none
+ *
+ * Notes: dequantized scalefactors have at least 2 GB
+ **************************************************************************************/
+static void DequantizeNoise(int nBands, signed char *noiseQuant, int *noiseDequant)
+{
+ int exp, scalei;
+
+ if (nBands <= 0) {
+ return;
+ }
+
+ /* dequantize noise floor gains (4.6.18.3.5):
+ * noiseDequant = 2^(NOISE_FLOOR_OFFSET - noiseQuant)
+ *
+ * range of noiseQuant = [0, 30] (see 4.6.18.3.6), NOISE_FLOOR_OFFSET = 6
+ * so range of noiseDequant = [2^-24, 2^6]
+ */
+ do {
+ exp = *noiseQuant++;
+ scalei = NOISE_FLOOR_OFFSET - exp + FBITS_OUT_DQ_NOISE; /* 6 + 24 - exp, exp = [0,30] */
+
+ if (scalei < 0) {
+ *noiseDequant++ = 0;
+ } else if (scalei < 30) {
+ *noiseDequant++ = 1 << scalei;
+ } else {
+ *noiseDequant++ = 0x3fffffff; /* leave 2 GB */
+ }
+
+ } while (--nBands);
+}
+
+/**************************************************************************************
+ * Function: DecodeSBREnvelope
+ *
+ * Description: decode delta Huffman coded envelope scalefactors from bitstream
+ *
+ * Inputs: BitStreamInfo struct pointing to start of env data
+ * initialized PSInfoSBR struct
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ *
+ * Outputs: dequantized env scalefactors for left channel (before decoupling)
+ * dequantized env scalefactors for right channel (if coupling off)
+ * or raw decoded env scalefactors for right channel (if coupling on)
+ *
+ * Return: none
+ **************************************************************************************/
+int DecodeSBREnvelope(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch)
+{
+ int huffIndexTime, huffIndexFreq, env, envStartBits, band, nBands, sf, lastEnv;
+ int freqRes, freqResPrev, dShift, i;
+
+ if (psi->couplingFlag && ch) {
+ dShift = 1;
+ if (sbrGrid->ampResFrame) {
+ huffIndexTime = HuffTabSBR_tEnv30b;
+ huffIndexFreq = HuffTabSBR_fEnv30b;
+ envStartBits = 5;
+ } else {
+ huffIndexTime = HuffTabSBR_tEnv15b;
+ huffIndexFreq = HuffTabSBR_fEnv15b;
+ envStartBits = 6;
+ }
+ } else {
+ dShift = 0;
+ if (sbrGrid->ampResFrame) {
+ huffIndexTime = HuffTabSBR_tEnv30;
+ huffIndexFreq = HuffTabSBR_fEnv30;
+ envStartBits = 6;
+ } else {
+ huffIndexTime = HuffTabSBR_tEnv15;
+ huffIndexFreq = HuffTabSBR_fEnv15;
+ envStartBits = 7;
+ }
+ }
+
+ /* range of envDataQuant[] = [0, 127] (see comments in DequantizeEnvelope() for reference) */
+ for (env = 0; env < sbrGrid->numEnv; env++) {
+ nBands = (sbrGrid->freqRes[env] ? sbrFreq->nHigh : sbrFreq->nLow);
+ freqRes = (sbrGrid->freqRes[env]);
+ freqResPrev = (env == 0 ? sbrGrid->freqResPrev : sbrGrid->freqRes[env - 1]);
+ lastEnv = (env == 0 ? sbrGrid->numEnvPrev - 1 : env - 1);
+ if (lastEnv < 0) {
+ lastEnv = 0; /* first frame */
+ }
+
+ ASSERT(nBands <= MAX_QMF_BANDS, ERR_AAC_SBR_BITSTREAM);
+
+ if (sbrChan->deltaFlagEnv[env] == 0) {
+ /* delta coding in freq */
+ sf = GetBits(bsi, envStartBits) << dShift;
+ sbrChan->envDataQuant[env][0] = sf;
+ for (band = 1; band < nBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexFreq) << dShift;
+ sbrChan->envDataQuant[env][band] = sf + sbrChan->envDataQuant[env][band - 1];
+ }
+ } else if (freqRes == freqResPrev) {
+ /* delta coding in time - same freq resolution for both frames */
+ for (band = 0; band < nBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift;
+ sbrChan->envDataQuant[env][band] = sf + sbrChan->envDataQuant[lastEnv][band];
+ }
+ } else if (freqRes == 0 && freqResPrev == 1) {
+ /* delta coding in time - low freq resolution for new frame, high freq resolution for old frame */
+ for (band = 0; band < nBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift;
+ sbrChan->envDataQuant[env][band] = sf;
+ for (i = 0; i < sbrFreq->nHigh; i++) {
+ if (sbrFreq->freqHigh[i] == sbrFreq->freqLow[band]) {
+ sbrChan->envDataQuant[env][band] += sbrChan->envDataQuant[lastEnv][i];
+ break;
+ }
+ }
+ }
+ } else if (freqRes == 1 && freqResPrev == 0) {
+ /* delta coding in time - high freq resolution for new frame, low freq resolution for old frame */
+ for (band = 0; band < nBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift;
+ sbrChan->envDataQuant[env][band] = sf;
+ for (i = 0; i < sbrFreq->nLow; i++) {
+ if (sbrFreq->freqLow[i] <= sbrFreq->freqHigh[band] && sbrFreq->freqHigh[band] < sbrFreq->freqLow[i + 1]) {
+ sbrChan->envDataQuant[env][band] += sbrChan->envDataQuant[lastEnv][i];
+ break;
+ }
+ }
+ }
+ }
+
+ /* skip coupling channel */
+ if (ch != 1 || psi->couplingFlag != 1) {
+ psi->envDataDequantScale[ch][env] = DequantizeEnvelope(nBands, sbrGrid->ampResFrame, sbrChan->envDataQuant[env], psi->envDataDequant[ch][env]);
+ }
+ }
+ sbrGrid->numEnvPrev = sbrGrid->numEnv;
+ sbrGrid->freqResPrev = sbrGrid->freqRes[sbrGrid->numEnv - 1];
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: DecodeSBRNoise
+ *
+ * Description: decode delta Huffman coded noise scalefactors from bitstream
+ *
+ * Inputs: BitStreamInfo struct pointing to start of noise data
+ * initialized PSInfoSBR struct
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel
+ * index of current channel (0 for SCE, 0 or 1 for CPE)
+ *
+ * Outputs: dequantized noise scalefactors for left channel (before decoupling)
+ * dequantized noise scalefactors for right channel (if coupling off)
+ * or raw decoded noise scalefactors for right channel (if coupling on)
+ *
+ * Return: none
+ **************************************************************************************/
+int DecodeSBRNoise(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch)
+{
+ int huffIndexTime, huffIndexFreq, noiseFloor, band, dShift, sf, lastNoiseFloor;
+
+ if (psi->couplingFlag && ch) {
+ dShift = 1;
+ huffIndexTime = HuffTabSBR_tNoise30b;
+ huffIndexFreq = HuffTabSBR_fNoise30b;
+ } else {
+ dShift = 0;
+ huffIndexTime = HuffTabSBR_tNoise30;
+ huffIndexFreq = HuffTabSBR_fNoise30;
+ }
+
+ for (noiseFloor = 0; noiseFloor < sbrGrid->numNoiseFloors; noiseFloor++) {
+ lastNoiseFloor = (noiseFloor == 0 ? sbrGrid->numNoiseFloorsPrev - 1 : noiseFloor - 1);
+ if (lastNoiseFloor < 0) {
+ lastNoiseFloor = 0; /* first frame */
+ }
+
+ ASSERT(sbrFreq->numNoiseFloorBands <= MAX_QMF_BANDS, ERR_AAC_SBR_BITSTREAM);
+
+ if (sbrChan->deltaFlagNoise[noiseFloor] == 0) {
+ /* delta coding in freq */
+ sbrChan->noiseDataQuant[noiseFloor][0] = GetBits(bsi, 5) << dShift;
+ for (band = 1; band < sbrFreq->numNoiseFloorBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexFreq) << dShift;
+ sbrChan->noiseDataQuant[noiseFloor][band] = sf + sbrChan->noiseDataQuant[noiseFloor][band - 1];
+ }
+ } else {
+ /* delta coding in time */
+ for (band = 0; band < sbrFreq->numNoiseFloorBands; band++) {
+ sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift;
+ sbrChan->noiseDataQuant[noiseFloor][band] = sf + sbrChan->noiseDataQuant[lastNoiseFloor][band];
+ }
+ }
+
+ /* skip coupling channel */
+ if (ch != 1 || psi->couplingFlag != 1) {
+ DequantizeNoise(sbrFreq->numNoiseFloorBands, sbrChan->noiseDataQuant[noiseFloor], psi->noiseDataDequant[ch][noiseFloor]);
+ }
+ }
+ sbrGrid->numNoiseFloorsPrev = sbrGrid->numNoiseFloors;
+ return ERR_AAC_NONE;
+}
+
+/* dqTabCouple[i] = 2 / (1 + 2^(12 - i)), format = Q30 */
+static const int dqTabCouple[25] = {
+ 0x0007ff80, 0x000ffe00, 0x001ff802, 0x003fe010, 0x007f8080, 0x00fe03f8, 0x01f81f82, 0x03e0f83e,
+ 0x07878788, 0x0e38e38e, 0x1999999a, 0x2aaaaaab, 0x40000000, 0x55555555, 0x66666666, 0x71c71c72,
+ 0x78787878, 0x7c1f07c2, 0x7e07e07e, 0x7f01fc08, 0x7f807f80, 0x7fc01ff0, 0x7fe007fe, 0x7ff00200,
+ 0x7ff80080,
+};
+
+/**************************************************************************************
+ * Function: UncoupleSBREnvelope
+ *
+ * Description: scale dequantized envelope scalefactors according to channel
+ * coupling rules
+ *
+ * Inputs: initialized PSInfoSBR struct including
+ * dequantized envelope data for left channel
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for right channel including
+ * quantized envelope scalefactors
+ *
+ * Outputs: dequantized envelope data for left channel (after decoupling)
+ * dequantized envelope data for right channel (after decoupling)
+ *
+ * Return: none
+ **************************************************************************************/
+void UncoupleSBREnvelope(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR)
+{
+ int env, band, nBands, scalei, E_1;
+
+ scalei = (sbrGrid->ampResFrame ? 0 : 1);
+ for (env = 0; env < sbrGrid->numEnv; env++) {
+ nBands = (sbrGrid->freqRes[env] ? sbrFreq->nHigh : sbrFreq->nLow);
+ psi->envDataDequantScale[1][env] = psi->envDataDequantScale[0][env]; /* same scalefactor for L and R */
+ for (band = 0; band < nBands; band++) {
+ /* clip E_1 to [0, 24] (scalefactors approach 0 or 2) */
+ E_1 = sbrChanR->envDataQuant[env][band] >> scalei;
+ if (E_1 < 0) {
+ E_1 = 0;
+ }
+ if (E_1 > 24) {
+ E_1 = 24;
+ }
+
+ /* envDataDequant[0] has 1 GB, so << by 2 is okay */
+ psi->envDataDequant[1][env][band] = MULSHIFT32(psi->envDataDequant[0][env][band], dqTabCouple[24 - E_1]) << 2;
+ psi->envDataDequant[0][env][band] = MULSHIFT32(psi->envDataDequant[0][env][band], dqTabCouple[E_1]) << 2;
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: UncoupleSBRNoise
+ *
+ * Description: scale dequantized noise floor scalefactors according to channel
+ * coupling rules
+ *
+ * Inputs: initialized PSInfoSBR struct including
+ * dequantized noise data for left channel
+ * initialized SBRGrid struct for this channel
+ * initialized SBRFreq struct for this SCE/CPE block
+ * initialized SBRChan struct for this channel including
+ * quantized noise scalefactors
+ *
+ * Outputs: dequantized noise data for left channel (after decoupling)
+ * dequantized noise data for right channel (after decoupling)
+ *
+ * Return: none
+ **************************************************************************************/
+void UncoupleSBRNoise(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR)
+{
+ int noiseFloor, band, Q_1;
+
+ for (noiseFloor = 0; noiseFloor < sbrGrid->numNoiseFloors; noiseFloor++) {
+ for (band = 0; band < sbrFreq->numNoiseFloorBands; band++) {
+ /* Q_1 should be in range [0, 24] according to 4.6.18.3.6, but check to make sure */
+ Q_1 = sbrChanR->noiseDataQuant[noiseFloor][band];
+ if (Q_1 < 0) {
+ Q_1 = 0;
+ }
+ if (Q_1 > 24) {
+ Q_1 = 24;
+ }
+
+ /* noiseDataDequant[0] has 1 GB, so << by 2 is okay */
+ psi->noiseDataDequant[1][noiseFloor][band] = MULSHIFT32(psi->noiseDataDequant[0][noiseFloor][band], dqTabCouple[24 - Q_1]) << 2;
+ psi->noiseDataDequant[0][noiseFloor][band] = MULSHIFT32(psi->noiseDataDequant[0][noiseFloor][band], dqTabCouple[Q_1]) << 2;
+ }
+ }
+}
diff --git a/audio_codec/wfd_aac_decoder/sbrimdct.c b/audio_codec/wfd_aac_decoder/sbrimdct.c
new file mode 100644
index 0000000..abec008
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/sbrimdct.c
@@ -0,0 +1,447 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrimdct.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrimdct.c - inverse MDCT without clipping or interleaving, for input to SBR
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+/**************************************************************************************
+ * Function: DecWindowOverlapNoClip
+ *
+ * Description: apply synthesis window, do overlap-add without clipping,
+ * for winSequence LONG-LONG
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 32-bit PCM, non-interleaved
+ *
+ * Return: none
+ *
+ * Notes: use this function when the decoded PCM is going to the SBR decoder
+ **************************************************************************************/
+void DecWindowOverlapNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev)
+{
+ int in, w0, w1, f0, f1;
+ int *buf1, *over1, *out1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ out1 = out0 + 1024 - 1;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ if (winTypeCurr == winTypePrev) {
+ /* cut window loads in half since current and overlap sections use same symmetric window */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ } else {
+ /* different windows for current and overlap parts - should still fit in registers on ARM w/o stack spill */
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapLongStart
+ *
+ * Description: apply synthesis window, do overlap-add, without clipping
+ * for winSequence LONG-START
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 32-bit PCM, non-interleaved
+ *
+ * Return: none
+ *
+ * Notes: use this function when the decoded PCM is going to the SBR decoder
+ **************************************************************************************/
+void DecWindowOverlapLongStartNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1, *out1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ out1 = out0 + 1024 - 1;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+ i = 448; /* 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ in = *buf1--;
+
+ *over1-- = 0; /* Wn = 0 for n = (2047, 2046, ... 1600) */
+ *over0++ = in >> 1; /* Wn = 1 for n = (1024, 1025, ... 1471) */
+ } while (--i);
+
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+
+ /* do 64 more loops - 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++;
+ w1 = *wndPrev++;
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ w0 = *wndCurr++; /* W[0], W[1], ... --> W[255], W[254], ... */
+ w1 = *wndCurr++; /* W[127], W[126], ... --> W[128], W[129], ... */
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in); /* Wn = short window for n = (1599, 1598, ... , 1536) */
+ *over0++ = MULSHIFT32(w1, in); /* Wn = short window for n = (1472, 1473, ... , 1535) */
+ } while (over0 < over1);
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapLongStop
+ *
+ * Description: apply synthesis window, do overlap-add, without clipping
+ * for winSequence LONG-STOP
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 32-bit PCM, non-interleaved
+ *
+ * Return: none
+ *
+ * Notes: use this function when the decoded PCM is going to the SBR decoder
+ **************************************************************************************/
+void DecWindowOverlapLongStopNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1, *out1;
+ const int *wndPrev, *wndCurr;
+
+ buf0 += (1024 >> 1);
+ buf1 = buf0 - 1;
+ out1 = out0 + 1024 - 1;
+ over1 = over0 + 1024 - 1;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]);
+
+ i = 448; /* 2 outputs, 2 overlaps per loop */
+ do {
+ /* Wn = 0 for n = (0, 1, ... 447) */
+ /* Wn = 1 for n = (576, 577, ... 1023) */
+ in = *buf0++;
+ f1 = in >> 1; /* scale since skipping multiply by Q31 */
+
+ in = *over0;
+ *out0++ = in;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (--i);
+
+ /* do 64 more loops - 2 outputs, 2 overlaps per loop */
+ do {
+ w0 = *wndPrev++; /* W[0], W[1], ...W[63] */
+ w1 = *wndPrev++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+}
+
+/**************************************************************************************
+ * Function: DecWindowOverlapShort
+ *
+ * Description: apply synthesis window, do overlap-add, without clipping
+ * for winSequence EIGHT-SHORT (does all 8 short blocks)
+ *
+ * Inputs: input buffer (output of type-IV DCT)
+ * overlap buffer (saved from last time)
+ * window type (sin or KBD) for input buffer
+ * window type (sin or KBD) for overlap buffer
+ *
+ * Outputs: one channel, one frame of 32-bit PCM, non-interleaved
+ *
+ * Return: none
+ *
+ * Notes: use this function when the decoded PCM is going to the SBR decoder
+ **************************************************************************************/
+void DecWindowOverlapShortNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev)
+{
+ int i, in, w0, w1, f0, f1;
+ int *buf1, *over1, *out1;
+ const int *wndPrev, *wndCurr;
+
+ wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+ wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]);
+
+ /* pcm[0-447] = 0 + overlap[0-447] */
+ i = 448;
+ do {
+ f0 = *over0++;
+ f1 = *over0++;
+ *out0++ = f0;
+ *out0++ = f1;
+ i -= 2;
+ } while (i);
+
+ /* pcm[448-575] = Wp[0-127] * block0[0-127] + overlap[448-575] */
+ out1 = out0 + (128 - 1);
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ do {
+ w0 = *wndPrev++; /* W[0], W[1], ...W[63] */
+ w1 = *wndPrev++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *over0;
+ *out0++ = in - f0;
+
+ in = *over1;
+ *out1-- = in + f1;
+
+ w0 = *wndCurr++;
+ w1 = *wndCurr++;
+ in = *buf1--;
+
+ /* save over0/over1 for next short block, in the slots just vacated */
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+
+ /* pcm[576-703] = Wc[128-255] * block0[128-255] + Wc[0-127] * block1[0-127] + overlap[576-703]
+ * pcm[704-831] = Wc[128-255] * block1[128-255] + Wc[0-127] * block2[0-127] + overlap[704-831]
+ * pcm[832-959] = Wc[128-255] * block2[128-255] + Wc[0-127] * block3[0-127] + overlap[832-959]
+ */
+ for (i = 0; i < 3; i++) {
+ out0 += 64;
+ out1 = out0 + 128 - 1;
+ over0 += 64;
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *(over0 - 128); /* from last short block */
+ in += *(over0 + 0); /* from last full frame */
+ *out0++ = in - f0;
+
+ in = *(over1 - 128); /* from last short block */
+ in += *(over1 + 0); /* from last full frame */
+ *out1-- = in + f1;
+
+ /* save over0/over1 for next short block, in the slots just vacated */
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+
+ /* pcm[960-1023] = Wc[128-191] * block3[128-191] + Wc[0-63] * block4[0-63] + overlap[960-1023]
+ * over[0-63] = Wc[192-255] * block3[192-255] + Wc[64-127] * block4[64-127]
+ */
+ out0 += 64;
+ over0 -= 832; /* points at overlap[64] */
+ over1 = over0 + 128 - 1; /* points at overlap[191] */
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ in = *(over0 + 768); /* from last short block */
+ in += *(over0 + 896); /* from last full frame */
+ *out0++ = in - f0;
+
+ in = *(over1 + 768); /* from last short block */
+ *(over1 - 128) = in + f1;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in); /* save in overlap[128-191] */
+ *over0++ = MULSHIFT32(w1, in); /* save in overlap[64-127] */
+ } while (over0 < over1);
+
+ /* over0 now points at overlap[128] */
+
+ /* over[64-191] = Wc[128-255] * block4[128-255] + Wc[0-127] * block5[0-127]
+ * over[192-319] = Wc[128-255] * block5[128-255] + Wc[0-127] * block6[0-127]
+ * over[320-447] = Wc[128-255] * block6[128-255] + Wc[0-127] * block7[0-127]
+ * over[448-576] = Wc[128-255] * block7[128-255]
+ */
+ for (i = 0; i < 3; i++) {
+ over0 += 64;
+ over1 = over0 + 128 - 1;
+ buf0 += 64;
+ buf1 = buf0 - 1;
+ wndCurr -= 128;
+ do {
+ w0 = *wndCurr++; /* W[0], W[1], ...W[63] */
+ w1 = *wndCurr++; /* W[127], W[126], ... W[64] */
+ in = *buf0++;
+
+ f0 = MULSHIFT32(w0, in);
+ f1 = MULSHIFT32(w1, in);
+
+ /* from last short block */
+ *(over0 - 128) -= f0;
+ *(over1 - 128) += f1;
+
+ in = *buf1--;
+ *over1-- = MULSHIFT32(w0, in);
+ *over0++ = MULSHIFT32(w1, in);
+ } while (over0 < over1);
+ }
+
+ /* over[576-1024] = 0 */
+ i = 448;
+ over0 += 64;
+ do {
+ *over0++ = 0;
+ *over0++ = 0;
+ *over0++ = 0;
+ *over0++ = 0;
+ i -= 4;
+ } while (i);
+}
diff --git a/audio_codec/wfd_aac_decoder/sbrmath.c b/audio_codec/wfd_aac_decoder/sbrmath.c
new file mode 100644
index 0000000..784f909
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/sbrmath.c
@@ -0,0 +1,198 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrmath.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrmath.c - fixed-point math functions for SBR
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+#define Q28_2 0x20000000 /* Q28: 2.0 */
+#define Q28_15 0x30000000 /* Q28: 1.5 */
+
+#define NUM_ITER_IRN 5
+
+/**************************************************************************************
+ * Function: InvRNormalized
+ *
+ * Description: use Newton's method to solve for x = 1/r
+ *
+ * Inputs: r = Q31, range = [0.5, 1) (normalize your inputs to this range)
+ *
+ * Outputs: none
+ *
+ * Return: x = Q29, range ~= [1.0, 2.0]
+ *
+ * Notes: guaranteed to converge and not overflow for any r in [0.5, 1)
+ *
+ * xn+1 = xn - f(xn)/f'(xn)
+ * f(x) = 1/r - x = 0 (find root)
+ * = 1/x - r
+ * f'(x) = -1/x^2
+ *
+ * so xn+1 = xn - (1/xn - r) / (-1/xn^2)
+ * = xn * (2 - r*xn)
+ *
+ * NUM_ITER_IRN = 2, maxDiff = 6.2500e-02 (precision of about 4 bits)
+ * NUM_ITER_IRN = 3, maxDiff = 3.9063e-03 (precision of about 8 bits)
+ * NUM_ITER_IRN = 4, maxDiff = 1.5288e-05 (precision of about 16 bits)
+ * NUM_ITER_IRN = 5, maxDiff = 3.0034e-08 (precision of about 24 bits)
+ **************************************************************************************/
+int InvRNormalized(int r)
+{
+ int i, xn, t;
+
+ /* r = [0.5, 1.0)
+ * 1/r = (1.0, 2.0]
+ * so use 1.5 as initial guess
+ */
+ xn = Q28_15;
+
+ /* xn = xn*(2.0 - r*xn) */
+ for (i = NUM_ITER_IRN; i != 0; i--) {
+ t = MULSHIFT32(r, xn); /* Q31*Q29 = Q28 */
+ t = Q28_2 - t; /* Q28 */
+ xn = MULSHIFT32(xn, t) << 4; /* Q29*Q28 << 4 = Q29 */
+ }
+
+ return xn;
+}
+
+#define NUM_TERMS_RPI 5
+#define LOG2_EXP_INV 0x58b90bfc /* 1/log2(e), Q31 */
+
+/* invTab[x] = 1/(x+1), format = Q30 */
+static const int invTab[NUM_TERMS_RPI] = {0x40000000, 0x20000000, 0x15555555, 0x10000000, 0x0ccccccd};
+
+/**************************************************************************************
+ * Function: RatioPowInv
+ *
+ * Description: use Taylor (MacLaurin) series expansion to calculate (a/b) ^ (1/c)
+ *
+ * Inputs: a = [1, 64], b = [1, 64], c = [1, 64], a >= b
+ *
+ * Outputs: none
+ *
+ * Return: y = Q24, range ~= [0.015625, 64]
+ **************************************************************************************/
+int RatioPowInv(int a, int b, int c)
+{
+ int lna, lnb, i, p, t, y;
+
+ if (a < 1 || b < 1 || c < 1 || a > 64 || b > 64 || c > 64 || a < b) {
+ return 0;
+ }
+
+ lna = MULSHIFT32(log2Tab[a], LOG2_EXP_INV) << 1; /* ln(a), Q28 */
+ lnb = MULSHIFT32(log2Tab[b], LOG2_EXP_INV) << 1; /* ln(b), Q28 */
+ p = (lna - lnb) / c; /* Q28 */
+
+ /* sum in Q24 */
+ y = (1 << 24);
+ t = p >> 4; /* t = p^1 * 1/1! (Q24)*/
+ y += t;
+
+ for (i = 2; i <= NUM_TERMS_RPI; i++) {
+ t = MULSHIFT32(invTab[i - 1], t) << 2;
+ t = MULSHIFT32(p, t) << 4; /* t = p^i * 1/i! (Q24) */
+ y += t;
+ }
+
+ return y;
+}
+
+/**************************************************************************************
+ * Function: SqrtFix
+ *
+ * Description: use binary search to calculate sqrt(q)
+ *
+ * Inputs: q = Q30
+ * number of fraction bits in input
+ *
+ * Outputs: number of fraction bits in output
+ *
+ * Return: lo = Q(fBitsOut)
+ *
+ * Notes: absolute precision varies depending on fBitsIn
+ * normalizes input to range [0x200000000, 0x7fffffff] and takes
+ * floor(sqrt(input)), and sets fBitsOut appropriately
+ **************************************************************************************/
+int SqrtFix(int q, int fBitsIn, int *fBitsOut)
+{
+ int z, lo, hi, mid;
+
+ if (q <= 0) {
+ *fBitsOut = fBitsIn;
+ return 0;
+ }
+
+ /* force even fBitsIn */
+ z = fBitsIn & 0x01;
+ q >>= z;
+ fBitsIn -= z;
+
+ /* for max precision, normalize to [0x20000000, 0x7fffffff] */
+ z = (CLZ(q) - 1);
+ z >>= 1;
+ q <<= (2 * z);
+
+ /* choose initial bounds */
+ lo = 1;
+ if (q >= 0x10000000) {
+ lo = 16384; /* (int)sqrt(0x10000000) */
+ }
+ hi = 46340; /* (int)sqrt(0x7fffffff) */
+
+ /* do binary search with 32x32->32 multiply test */
+ do {
+ mid = (lo + hi) >> 1;
+ if (mid * mid > q) {
+ hi = mid - 1;
+ } else {
+ lo = mid + 1;
+ }
+ } while (hi >= lo);
+ lo--;
+
+ *fBitsOut = ((fBitsIn + 2 * z) >> 1);
+ return lo;
+}
diff --git a/audio_codec/wfd_aac_decoder/sbrqmf.c b/audio_codec/wfd_aac_decoder/sbrqmf.c
new file mode 100644
index 0000000..6a9464a
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/sbrqmf.c
@@ -0,0 +1,648 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrqmf.c,v 1.1.2.2 2005/05/19 21:00:01 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrqmf.c - analysis and synthesis QMF filters for SBR
+ **************************************************************************************/
+
+#include "sbr.h"
+#include "assembly.h"
+
+/* PreMultiply64() table
+ * format = Q30
+ * reordered for sequential access
+ *
+ * for (i = 0; i < 64/4; i++) {
+ * angle = (i + 0.25) * M_PI / nmdct;
+ * x = (cos(angle) + sin(angle));
+ * x = sin(angle);
+ *
+ * angle = (nmdct/2 - 1 - i + 0.25) * M_PI / nmdct;
+ * x = (cos(angle) + sin(angle));
+ * x = sin(angle);
+ * }
+ */
+static const int cos4sin4tab64[64] = {
+ 0x40c7d2bd, 0x00c90e90, 0x424ff28f, 0x3ff4e5e0, 0x43cdd89a, 0x03ecadcf, 0x454149fc, 0x3fc395f9,
+ 0x46aa0d6d, 0x070de172, 0x4807eb4b, 0x3f6af2e3, 0x495aada2, 0x0a2abb59, 0x4aa22036, 0x3eeb3347,
+ 0x4bde1089, 0x0d415013, 0x4d0e4de2, 0x3e44a5ef, 0x4e32a956, 0x104fb80e, 0x4f4af5d1, 0x3d77b192,
+ 0x50570819, 0x135410c3, 0x5156b6d9, 0x3c84d496, 0x5249daa2, 0x164c7ddd, 0x53304df6, 0x3b6ca4c4,
+ 0x5409ed4b, 0x19372a64, 0x54d69714, 0x3a2fcee8, 0x55962bc0, 0x1c1249d8, 0x56488dc5, 0x38cf1669,
+ 0x56eda1a0, 0x1edc1953, 0x57854ddd, 0x374b54ce, 0x580f7b19, 0x2192e09b, 0x588c1404, 0x35a5793c,
+ 0x58fb0568, 0x2434f332, 0x595c3e2a, 0x33de87de, 0x59afaf4c, 0x26c0b162, 0x59f54bee, 0x31f79948,
+ 0x5a2d0957, 0x29348937, 0x5a56deec, 0x2ff1d9c7, 0x5a72c63b, 0x2b8ef77d, 0x5a80baf6, 0x2dce88aa,
+};
+
+/* PostMultiply64() table
+ * format = Q30
+ * reordered for sequential access
+ *
+ * for (i = 0; i <= (32/2); i++) {
+ * angle = i * M_PI / 64;
+ * x = (cos(angle) + sin(angle));
+ * x = sin(angle);
+ * }
+ */
+static const int cos1sin1tab64[34] = {
+ 0x40000000, 0x00000000, 0x43103085, 0x0323ecbe, 0x45f704f7, 0x0645e9af, 0x48b2b335, 0x09640837,
+ 0x4b418bbe, 0x0c7c5c1e, 0x4da1fab5, 0x0f8cfcbe, 0x4fd288dc, 0x1294062f, 0x51d1dc80, 0x158f9a76,
+ 0x539eba45, 0x187de2a7, 0x553805f2, 0x1b5d100a, 0x569cc31b, 0x1e2b5d38, 0x57cc15bc, 0x20e70f32,
+ 0x58c542c5, 0x238e7673, 0x5987b08a, 0x261feffa, 0x5a12e720, 0x2899e64a, 0x5a6690ae, 0x2afad269,
+ 0x5a82799a, 0x2d413ccd,
+};
+
+/**************************************************************************************
+ * Function: PreMultiply64
+ *
+ * Description: pre-twiddle stage of 64-point DCT-IV
+ *
+ * Inputs: buffer of 64 samples
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: minimum 1 GB in, 2 GB out, gains 2 int bits
+ * gbOut = gbIn + 1
+ * output is limited to sqrt(2)/2 plus GB in full GB
+ * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
+ **************************************************************************************/
+static void PreMultiply64(int *zbuf1)
+{
+ int i, ar1, ai1, ar2, ai2, z1, z2;
+ int t, cms2, cps2a, sin2a, cps2b, sin2b;
+ int *zbuf2;
+ const int *csptr;
+
+ zbuf2 = zbuf1 + 64 - 1;
+ csptr = cos4sin4tab64;
+
+ /* whole thing should fit in registers - verify that compiler does this */
+ for (i = 64 >> 2; i != 0; i--) {
+ /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */
+ cps2a = *csptr++;
+ sin2a = *csptr++;
+ cps2b = *csptr++;
+ sin2b = *csptr++;
+
+ ar1 = *(zbuf1 + 0);
+ ai2 = *(zbuf1 + 1);
+ ai1 = *(zbuf2 + 0);
+ ar2 = *(zbuf2 - 1);
+
+ /* gain 2 ints bit from MULSHIFT32 by Q30
+ * max per-sample gain (ignoring implicit scaling) = MAX(sin(angle)+cos(angle)) = 1.414
+ * i.e. gain 1 GB since worst case is sin(angle) = cos(angle) = 0.707 (Q30), gain 2 from
+ * extra sign bits, and eat one in adding
+ */
+ t = MULSHIFT32(sin2a, ar1 + ai1);
+ z2 = MULSHIFT32(cps2a, ai1) - t;
+ cms2 = cps2a - 2 * sin2a;
+ z1 = MULSHIFT32(cms2, ar1) + t;
+ *zbuf1++ = z1; /* cos*ar1 + sin*ai1 */
+ *zbuf1++ = z2; /* cos*ai1 - sin*ar1 */
+
+ t = MULSHIFT32(sin2b, ar2 + ai2);
+ z2 = MULSHIFT32(cps2b, ai2) - t;
+ cms2 = cps2b - 2 * sin2b;
+ z1 = MULSHIFT32(cms2, ar2) + t;
+ *zbuf2-- = z2; /* cos*ai2 - sin*ar2 */
+ *zbuf2-- = z1; /* cos*ar2 + sin*ai2 */
+ }
+}
+
+/**************************************************************************************
+ * Function: PostMultiply64
+ *
+ * Description: post-twiddle stage of 64-point type-IV DCT
+ *
+ * Inputs: buffer of 64 samples
+ * number of output samples to calculate
+ *
+ * Outputs: processed samples in same buffer
+ *
+ * Return: none
+ *
+ * Notes: minimum 1 GB in, 2 GB out, gains 2 int bits
+ * gbOut = gbIn + 1
+ * output is limited to sqrt(2)/2 plus GB in full GB
+ * nSampsOut is rounded up to next multiple of 4, since we calculate
+ * 4 samples per loop
+ **************************************************************************************/
+static void PostMultiply64(int *fft1, int nSampsOut)
+{
+ int i, ar1, ai1, ar2, ai2;
+ int t, cms2, cps2, sin2;
+ int *fft2;
+ const int *csptr;
+
+ csptr = cos1sin1tab64;
+ fft2 = fft1 + 64 - 1;
+
+ /* load coeffs for first pass
+ * cps2 = (cos+sin)/2, sin2 = sin/2, cms2 = (cos-sin)/2
+ */
+ cps2 = *csptr++;
+ sin2 = *csptr++;
+ cms2 = cps2 - 2 * sin2;
+
+ for (i = (nSampsOut + 3) >> 2; i != 0; i--) {
+ ar1 = *(fft1 + 0);
+ ai1 = *(fft1 + 1);
+ ar2 = *(fft2 - 1);
+ ai2 = *(fft2 + 0);
+
+ /* gain 2 int bits (multiplying by Q30), max gain = sqrt(2) */
+ t = MULSHIFT32(sin2, ar1 + ai1);
+ *fft2-- = t - MULSHIFT32(cps2, ai1);
+ *fft1++ = t + MULSHIFT32(cms2, ar1);
+
+ cps2 = *csptr++;
+ sin2 = *csptr++;
+
+ ai2 = -ai2;
+ t = MULSHIFT32(sin2, ar2 + ai2);
+ *fft2-- = t - MULSHIFT32(cps2, ai2);
+ cms2 = cps2 - 2 * sin2;
+ *fft1++ = t + MULSHIFT32(cms2, ar2);
+ }
+}
+
+/**************************************************************************************
+ * Function: QMFAnalysisConv
+ *
+ * Description: convolution kernel for analysis QMF
+ *
+ * Inputs: pointer to coefficient table, reordered for sequential access
+ * delay buffer of size 32*10 = 320 real-valued PCM samples
+ * index for delay ring buffer (range = [0, 9])
+ *
+ * Outputs: 64 consecutive 32-bit samples
+ *
+ * Return: none
+ *
+ * Notes: this is carefully written to be efficient on ARM
+ * use the assembly code version in sbrqmfak.s when building for ARM!
+ **************************************************************************************/
+#if 0// (defined (__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(__arm__))
+#ifdef __cplusplus
+extern "C"
+#endif
+void QMFAnalysisConv(int *cTab, int *delay, int dIdx, int *uBuf);
+#else
+void QMFAnalysisConv(int *cTab, int *delay, int dIdx, int *uBuf)
+{
+ int k, dOff;
+ int *cPtr0, *cPtr1;
+ U64 u64lo, u64hi;
+
+ dOff = dIdx * 32 + 31;
+ cPtr0 = cTab;
+ cPtr1 = cTab + 33 * 5 - 1;
+
+ /* special first pass since we need to flip sign to create cTab[384], cTab[512] */
+ u64lo.w64 = 0;
+ u64hi.w64 = 0;
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, -(*cPtr1--), delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, -(*cPtr1--), delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+
+ uBuf[0] = u64lo.r.hi32;
+ uBuf[32] = u64hi.r.hi32;
+ uBuf++;
+ dOff--;
+
+ /* max gain for any sample in uBuf, after scaling by cTab, ~= 0.99
+ * so we can just sum the uBuf values with no overflow problems
+ */
+ for (k = 1; k <= 31; k++) {
+ u64lo.w64 = 0;
+ u64hi.w64 = 0;
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64lo.w64 = MADD64(u64lo.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+ u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]);
+ dOff -= 32;
+ if (dOff < 0) {
+ dOff += 320;
+ }
+
+ uBuf[0] = u64lo.r.hi32;
+ uBuf[32] = u64hi.r.hi32;
+ uBuf++;
+ dOff--;
+ }
+}
+#endif
+
+/**************************************************************************************
+ * Function: QMFAnalysis
+ *
+ * Description: 32-subband analysis QMF (4.6.18.4.1)
+ *
+ * Inputs: 32 consecutive samples of decoded 32-bit PCM, format = Q(fBitsIn)
+ * delay buffer of size 32*10 = 320 PCM samples
+ * number of fraction bits in input PCM
+ * index for delay ring buffer (range = [0, 9])
+ * number of subbands to calculate (range = [0, 32])
+ *
+ * Outputs: qmfaBands complex subband samples, format = Q(FBITS_OUT_QMFA)
+ * updated delay buffer
+ * updated delay index
+ *
+ * Return: guard bit mask
+ *
+ * Notes: output stored as RE{X0}, IM{X0}, RE{X1}, IM{X1}, ... RE{X31}, IM{X31}
+ * output stored in int buffer of size 64*2 = 128
+ * (zero-filled from XBuf[2*qmfaBands] to XBuf[127])
+ **************************************************************************************/
+int QMFAnalysis(int *inbuf, int *delay, int *XBuf, int fBitsIn, int *delayIdx, int qmfaBands)
+{
+ int n, y, shift, gbMask;
+ int *delayPtr, *uBuf, *tBuf;
+
+ /* use XBuf[128] as temp buffer for reordering */
+ uBuf = XBuf; /* first 64 samples */
+ tBuf = XBuf + 64; /* second 64 samples */
+
+ /* overwrite oldest PCM with new PCM
+ * delay[n] has 1 GB after shifting (either << or >>)
+ */
+ delayPtr = delay + (*delayIdx * 32);
+ if (fBitsIn > FBITS_IN_QMFA) {
+ shift = MIN(fBitsIn - FBITS_IN_QMFA, 31);
+ for (n = 32; n != 0; n--) {
+ y = (*inbuf) >> shift;
+ inbuf++;
+ *delayPtr++ = y;
+ }
+ } else {
+ shift = MIN(FBITS_IN_QMFA - fBitsIn, 30);
+ for (n = 32; n != 0; n--) {
+ y = *inbuf++;
+ CLIP_2N_SHIFT30(y, shift);
+ *delayPtr++ = y;
+ }
+ }
+
+ QMFAnalysisConv((int *)cTabA, delay, *delayIdx, uBuf);
+
+ /* uBuf has at least 2 GB right now (1 from clipping to Q(FBITS_IN_QMFA), one from
+ * the scaling by cTab (MULSHIFT32(*delayPtr--, *cPtr++), with net gain of < 1.0)
+ * TODO - fuse with QMFAnalysisConv to avoid separate reordering
+ */
+ tBuf[2 * 0 + 0] = uBuf[0];
+ tBuf[2 * 0 + 1] = uBuf[1];
+ for (n = 1; n < 31; n++) {
+ tBuf[2 * n + 0] = -uBuf[64 - n];
+ tBuf[2 * n + 1] = uBuf[n + 1];
+ }
+ tBuf[2 * 31 + 1] = uBuf[32];
+ tBuf[2 * 31 + 0] = -uBuf[33];
+
+ /* fast in-place DCT-IV - only need 2*qmfaBands output samples */
+ PreMultiply64(tBuf); /* 2 GB in, 3 GB out */
+ FFT32C(tBuf); /* 3 GB in, 1 GB out */
+ PostMultiply64(tBuf, qmfaBands * 2); /* 1 GB in, 2 GB out */
+
+ /* TODO - roll into PostMultiply (if enough registers) */
+ gbMask = 0;
+ for (n = 0; n < qmfaBands; n++) {
+ XBuf[2 * n + 0] = tBuf[ n + 0]; /* implicit scaling of 2 in our output Q format */
+ gbMask |= FASTABS(XBuf[2 * n + 0]);
+ XBuf[2 * n + 1] = -tBuf[63 - n];
+ gbMask |= FASTABS(XBuf[2 * n + 1]);
+ }
+
+ /* fill top section with zeros for HF generation */
+ for (; n < 64; n++) {
+ XBuf[2 * n + 0] = 0;
+ XBuf[2 * n + 1] = 0;
+ }
+
+ *delayIdx = (*delayIdx == NUM_QMF_DELAY_BUFS - 1 ? 0 : *delayIdx + 1);
+
+ /* minimum of 2 GB in output */
+ return gbMask;
+}
+
+/* lose FBITS_LOST_DCT4_64 in DCT4, gain 6 for implicit scaling by 1/64, lose 1 for cTab multiply (Q31) */
+#define FBITS_OUT_QMFS (FBITS_IN_QMFS - FBITS_LOST_DCT4_64 + 6 - 1)
+#define RND_VAL (1 << (FBITS_OUT_QMFS-1))
+
+/**************************************************************************************
+ * Function: QMFSynthesisConv
+ *
+ * Description: final convolution kernel for synthesis QMF
+ *
+ * Inputs: pointer to coefficient table, reordered for sequential access
+ * delay buffer of size 64*10 = 640 complex samples (1280 ints)
+ * index for delay ring buffer (range = [0, 9])
+ * number of QMF subbands to process (range = [0, 64])
+ * number of channels
+ *
+ * Outputs: 64 consecutive 16-bit PCM samples, interleaved by factor of nChans
+ *
+ * Return: none
+ *
+ * Notes: this is carefully written to be efficient on ARM
+ * use the assembly code version in sbrqmfsk.s when building for ARM!
+ **************************************************************************************/
+#if 0// (defined (__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(__arm__))
+#ifdef __cplusplus
+extern "C"
+#endif
+void QMFSynthesisConv(int *cPtr, int *delay, int dIdx, short *outbuf, int nChans);
+#else
+void QMFSynthesisConv(int *cPtr, int *delay, int dIdx, short *outbuf, int nChans)
+{
+ int k, dOff0, dOff1;
+ U64 sum64;
+
+ dOff0 = (dIdx) * 128;
+ dOff1 = dOff0 - 1;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+
+ /* scaling note: total gain of coefs (cPtr[0]-cPtr[9] for any k) is < 2.0, so 1 GB in delay values is adequate */
+ for (k = 0; k <= 63; k++) {
+ sum64.w64 = 0;
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]);
+ dOff0 -= 256;
+ if (dOff0 < 0) {
+ dOff0 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]);
+ dOff1 -= 256;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]);
+ dOff0 -= 256;
+ if (dOff0 < 0) {
+ dOff0 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]);
+ dOff1 -= 256;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]);
+ dOff0 -= 256;
+ if (dOff0 < 0) {
+ dOff0 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]);
+ dOff1 -= 256;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]);
+ dOff0 -= 256;
+ if (dOff0 < 0) {
+ dOff0 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]);
+ dOff1 -= 256;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]);
+ dOff0 -= 256;
+ if (dOff0 < 0) {
+ dOff0 += 1280;
+ }
+ sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]);
+ dOff1 -= 256;
+ if (dOff1 < 0) {
+ dOff1 += 1280;
+ }
+
+ dOff0++;
+ dOff1--;
+ *outbuf = CLIPTOSHORT((sum64.r.hi32 + RND_VAL) >> FBITS_OUT_QMFS);
+ outbuf += nChans;
+ }
+}
+#endif
+
+/**************************************************************************************
+ * Function: QMFSynthesis
+ *
+ * Description: 64-subband synthesis QMF (4.6.18.4.2)
+ *
+ * Inputs: 64 consecutive complex subband QMF samples, format = Q(FBITS_IN_QMFS)
+ * delay buffer of size 64*10 = 640 complex samples (1280 ints)
+ * index for delay ring buffer (range = [0, 9])
+ * number of QMF subbands to process (range = [0, 64])
+ * number of channels
+ *
+ * Outputs: 64 consecutive 16-bit PCM samples, interleaved by factor of nChans
+ * updated delay buffer
+ * updated delay index
+ *
+ * Return: none
+ *
+ * Notes: assumes MIN_GBITS_IN_QMFS guard bits in input, either from
+ * QMFAnalysis (if upsampling only) or from MapHF (if SBR on)
+ **************************************************************************************/
+void QMFSynthesis(int *inbuf, int *delay, int *delayIdx, int qmfsBands, short *outbuf, int nChans)
+{
+ int n, a0, a1, b0, b1, dOff0, dOff1, dIdx;
+ int *tBufLo, *tBufHi;
+
+ dIdx = *delayIdx;
+ tBufLo = delay + dIdx * 128 + 0;
+ tBufHi = delay + dIdx * 128 + 127;
+
+ /* reorder inputs to DCT-IV, only use first qmfsBands (complex) samples
+ * TODO - fuse with PreMultiply64 to avoid separate reordering steps
+ */
+ for (n = 0; n < qmfsBands >> 1; n++) {
+ a0 = *inbuf++;
+ b0 = *inbuf++;
+ a1 = *inbuf++;
+ b1 = *inbuf++;
+ *tBufLo++ = a0;
+ *tBufLo++ = a1;
+ *tBufHi-- = b0;
+ *tBufHi-- = b1;
+ }
+ if (qmfsBands & 0x01) {
+ a0 = *inbuf++;
+ b0 = *inbuf++;
+ *tBufLo++ = a0;
+ *tBufHi-- = b0;
+ *tBufLo++ = 0;
+ *tBufHi-- = 0;
+ n++;
+ }
+ for (; n < 32; n++) {
+ *tBufLo++ = 0;
+ *tBufHi-- = 0;
+ *tBufLo++ = 0;
+ *tBufHi-- = 0;
+ }
+
+ tBufLo = delay + dIdx * 128 + 0;
+ tBufHi = delay + dIdx * 128 + 64;
+
+ /* 2 GB in, 3 GB out */
+ PreMultiply64(tBufLo);
+ PreMultiply64(tBufHi);
+
+ /* 3 GB in, 1 GB out */
+ FFT32C(tBufLo);
+ FFT32C(tBufHi);
+
+ /* 1 GB in, 2 GB out */
+ PostMultiply64(tBufLo, 64);
+ PostMultiply64(tBufHi, 64);
+
+ /* could fuse with PostMultiply64 to avoid separate pass */
+ dOff0 = dIdx * 128;
+ dOff1 = dIdx * 128 + 64;
+ for (n = 32; n != 0; n--) {
+ a0 = (*tBufLo++);
+ a1 = (*tBufLo++);
+ b0 = (*tBufHi++);
+ b1 = -(*tBufHi++);
+
+ delay[dOff0++] = (b0 - a0);
+ delay[dOff0++] = (b1 - a1);
+ delay[dOff1++] = (b0 + a0);
+ delay[dOff1++] = (b1 + a1);
+ }
+
+ QMFSynthesisConv((int *)cTabS, delay, dIdx, outbuf, nChans);
+
+ *delayIdx = (*delayIdx == NUM_QMF_DELAY_BUFS - 1 ? 0 : *delayIdx + 1);
+}
diff --git a/audio_codec/wfd_aac_decoder/sbrside.c b/audio_codec/wfd_aac_decoder/sbrside.c
new file mode 100644
index 0000000..070af98
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/sbrside.c
@@ -0,0 +1,634 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrside.c,v 1.2 2005/05/24 16:01:55 albertofloyd Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrside.c - functions for unpacking side info from SBR bitstream
+ **************************************************************************************/
+
+#include "sbr.h"
+
+/**************************************************************************************
+ * Function: GetSampRateIdx
+ *
+ * Description: get index of given sample rate
+ *
+ * Inputs: sample rate (in Hz)
+ *
+ * Outputs: none
+ *
+ * Return: index of sample rate (table 1.15 in 14496-3:2001(E))
+ * -1 if sample rate not found in table
+ **************************************************************************************/
+int GetSampRateIdx(int sampRate)
+{
+ int idx;
+
+ for (idx = 0; idx < NUM_SAMPLE_RATES; idx++) {
+ if (sampRate == sampRateTab[idx]) {
+ return idx;
+ }
+ }
+
+ return -1;
+}
+
+/**************************************************************************************
+ * Function: UnpackSBRHeader
+ *
+ * Description: unpack SBR header (table 4.56)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of SBR header
+ *
+ * Outputs: initialized SBRHeader struct for this SCE/CPE block
+ *
+ * Return: non-zero if frame reset is triggered, zero otherwise
+ **************************************************************************************/
+int UnpackSBRHeader(BitStreamInfo *bsi, SBRHeader *sbrHdr)
+{
+ SBRHeader sbrHdrPrev;
+
+ /* save previous values so we know whether to reset decoder */
+ sbrHdrPrev.startFreq = sbrHdr->startFreq;
+ sbrHdrPrev.stopFreq = sbrHdr->stopFreq;
+ sbrHdrPrev.freqScale = sbrHdr->freqScale;
+ sbrHdrPrev.alterScale = sbrHdr->alterScale;
+ sbrHdrPrev.crossOverBand = sbrHdr->crossOverBand;
+ sbrHdrPrev.noiseBands = sbrHdr->noiseBands;
+
+ sbrHdr->ampRes = GetBits(bsi, 1);
+ sbrHdr->startFreq = GetBits(bsi, 4);
+ sbrHdr->stopFreq = GetBits(bsi, 4);
+ sbrHdr->crossOverBand = GetBits(bsi, 3);
+ sbrHdr->resBitsHdr = GetBits(bsi, 2);
+ sbrHdr->hdrExtra1 = GetBits(bsi, 1);
+ sbrHdr->hdrExtra2 = GetBits(bsi, 1);
+
+ if (sbrHdr->hdrExtra1) {
+ sbrHdr->freqScale = GetBits(bsi, 2);
+ sbrHdr->alterScale = GetBits(bsi, 1);
+ sbrHdr->noiseBands = GetBits(bsi, 2);
+ } else {
+ /* defaults */
+ sbrHdr->freqScale = 2;
+ sbrHdr->alterScale = 1;
+ sbrHdr->noiseBands = 2;
+ }
+
+ if (sbrHdr->hdrExtra2) {
+ sbrHdr->limiterBands = GetBits(bsi, 2);
+ sbrHdr->limiterGains = GetBits(bsi, 2);
+ sbrHdr->interpFreq = GetBits(bsi, 1);
+ sbrHdr->smoothMode = GetBits(bsi, 1);
+ } else {
+ /* defaults */
+ sbrHdr->limiterBands = 2;
+ sbrHdr->limiterGains = 2;
+ sbrHdr->interpFreq = 1;
+ sbrHdr->smoothMode = 1;
+ }
+ sbrHdr->count++;
+
+ /* if any of these have changed from previous frame, reset the SBR module */
+ if (sbrHdr->startFreq != sbrHdrPrev.startFreq || sbrHdr->stopFreq != sbrHdrPrev.stopFreq ||
+ sbrHdr->freqScale != sbrHdrPrev.freqScale || sbrHdr->alterScale != sbrHdrPrev.alterScale ||
+ sbrHdr->crossOverBand != sbrHdrPrev.crossOverBand || sbrHdr->noiseBands != sbrHdrPrev.noiseBands
+ ) {
+ return -1;
+ } else {
+ return 0;
+ }
+}
+
+/* cLog2[i] = ceil(log2(i)) (disregard i == 0) */
+static const unsigned char cLog2[9] = {0, 0, 1, 2, 2, 3, 3, 3, 3};
+
+/**************************************************************************************
+ * Function: UnpackSBRGrid
+ *
+ * Description: unpack SBR grid (table 4.62)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of SBR grid
+ * initialized SBRHeader struct for this SCE/CPE block
+ *
+ * Outputs: initialized SBRGrid struct for this channel
+ *
+ * Return: none
+ **************************************************************************************/
+static int UnpackSBRGrid(BitStreamInfo *bsi, SBRHeader *sbrHdr, SBRGrid *sbrGrid)
+{
+ int numEnvRaw, env, rel, pBits, border, middleBorder = 0;
+ unsigned char relBordLead[MAX_NUM_ENV], relBordTrail[MAX_NUM_ENV];
+ unsigned char relBorder0[3], relBorder1[3], relBorder[3];
+ unsigned char numRelBorder0, numRelBorder1, numRelBorder, numRelLead = 0, numRelTrail;
+ unsigned char absBordLead = 0, absBordTrail = 0, absBorder;
+
+ sbrGrid->ampResFrame = sbrHdr->ampRes;
+ sbrGrid->frameClass = GetBits(bsi, 2);
+ switch (sbrGrid->frameClass) {
+
+ case SBR_GRID_FIXFIX:
+ numEnvRaw = GetBits(bsi, 2);
+ sbrGrid->numEnv = (1 << numEnvRaw);
+ if (sbrGrid->numEnv == 1) {
+ sbrGrid->ampResFrame = 0;
+ }
+
+ ASSERT(sbrGrid->numEnv == 1 || sbrGrid->numEnv == 2 || sbrGrid->numEnv == 4, ERR_AAC_SBR_BITSTREAM);
+
+ sbrGrid->freqRes[0] = GetBits(bsi, 1);
+ for (env = 1; env < sbrGrid->numEnv; env++) {
+ sbrGrid->freqRes[env] = sbrGrid->freqRes[0];
+ }
+
+ absBordLead = 0;
+ absBordTrail = NUM_TIME_SLOTS;
+ numRelLead = sbrGrid->numEnv - 1;
+ numRelTrail = 0;
+
+ /* numEnv = 1, 2, or 4 */
+ if (sbrGrid->numEnv == 1) {
+ border = NUM_TIME_SLOTS / 1;
+ } else if (sbrGrid->numEnv == 2) {
+ border = NUM_TIME_SLOTS / 2;
+ } else {
+ border = NUM_TIME_SLOTS / 4;
+ }
+
+ for (rel = 0; rel < numRelLead; rel++) {
+ relBordLead[rel] = border;
+ }
+
+ middleBorder = (sbrGrid->numEnv >> 1);
+
+ break;
+
+ case SBR_GRID_FIXVAR:
+ absBorder = GetBits(bsi, 2) + NUM_TIME_SLOTS;
+ numRelBorder = GetBits(bsi, 2);
+ sbrGrid->numEnv = numRelBorder + 1;
+ for (rel = 0; rel < numRelBorder; rel++) {
+ relBorder[rel] = 2 * GetBits(bsi, 2) + 2;
+ }
+
+ pBits = cLog2[sbrGrid->numEnv + 1];
+ sbrGrid->pointer = GetBits(bsi, pBits);
+
+ for (env = sbrGrid->numEnv - 1; env >= 0; env--) {
+ sbrGrid->freqRes[env] = GetBits(bsi, 1);
+ }
+
+ absBordLead = 0;
+ absBordTrail = absBorder;
+ numRelLead = 0;
+ numRelTrail = numRelBorder;
+
+ for (rel = 0; rel < numRelTrail; rel++) {
+ relBordTrail[rel] = relBorder[rel];
+ }
+
+ if (sbrGrid->pointer > 1) {
+ middleBorder = sbrGrid->numEnv + 1 - sbrGrid->pointer;
+ } else {
+ middleBorder = sbrGrid->numEnv - 1;
+ }
+
+ break;
+
+ case SBR_GRID_VARFIX:
+ absBorder = GetBits(bsi, 2);
+ numRelBorder = GetBits(bsi, 2);
+ sbrGrid->numEnv = numRelBorder + 1;
+ for (rel = 0; rel < numRelBorder; rel++) {
+ relBorder[rel] = 2 * GetBits(bsi, 2) + 2;
+ }
+
+ pBits = cLog2[sbrGrid->numEnv + 1];
+ sbrGrid->pointer = GetBits(bsi, pBits);
+
+ for (env = 0; env < sbrGrid->numEnv; env++) {
+ sbrGrid->freqRes[env] = GetBits(bsi, 1);
+ }
+
+ absBordLead = absBorder;
+ absBordTrail = NUM_TIME_SLOTS;
+ numRelLead = numRelBorder;
+ numRelTrail = 0;
+
+ for (rel = 0; rel < numRelLead; rel++) {
+ relBordLead[rel] = relBorder[rel];
+ }
+
+ if (sbrGrid->pointer == 0) {
+ middleBorder = 1;
+ } else if (sbrGrid->pointer == 1) {
+ middleBorder = sbrGrid->numEnv - 1;
+ } else {
+ middleBorder = sbrGrid->pointer - 1;
+ }
+
+ break;
+
+ case SBR_GRID_VARVAR:
+ absBordLead = GetBits(bsi, 2); /* absBorder0 */
+ absBordTrail = GetBits(bsi, 2) + NUM_TIME_SLOTS; /* absBorder1 */
+ numRelBorder0 = GetBits(bsi, 2);
+ numRelBorder1 = GetBits(bsi, 2);
+
+ sbrGrid->numEnv = numRelBorder0 + numRelBorder1 + 1;
+ ASSERT(sbrGrid->numEnv <= 5, ERR_AAC_SBR_BITSTREAM);
+
+ for (rel = 0; rel < numRelBorder0; rel++) {
+ relBorder0[rel] = 2 * GetBits(bsi, 2) + 2;
+ }
+
+ for (rel = 0; rel < numRelBorder1; rel++) {
+ relBorder1[rel] = 2 * GetBits(bsi, 2) + 2;
+ }
+
+ pBits = cLog2[numRelBorder0 + numRelBorder1 + 2];
+ sbrGrid->pointer = GetBits(bsi, pBits);
+
+ for (env = 0; env < sbrGrid->numEnv; env++) {
+ sbrGrid->freqRes[env] = GetBits(bsi, 1);
+ }
+
+ numRelLead = numRelBorder0;
+ numRelTrail = numRelBorder1;
+
+ for (rel = 0; rel < numRelLead; rel++) {
+ relBordLead[rel] = relBorder0[rel];
+ }
+
+ for (rel = 0; rel < numRelTrail; rel++) {
+ relBordTrail[rel] = relBorder1[rel];
+ }
+
+ if (sbrGrid->pointer > 1) {
+ middleBorder = sbrGrid->numEnv + 1 - sbrGrid->pointer;
+ } else {
+ middleBorder = sbrGrid->numEnv - 1;
+ }
+
+ break;
+ }
+
+ /* build time border vector */
+ sbrGrid->envTimeBorder[0] = absBordLead * SAMPLES_PER_SLOT;
+
+ rel = 0;
+ border = absBordLead;
+ for (env = 1; env <= numRelLead; env++) {
+ border += relBordLead[rel++];
+ sbrGrid->envTimeBorder[env] = border * SAMPLES_PER_SLOT;
+ }
+
+ rel = 0;
+ border = absBordTrail;
+ for (env = sbrGrid->numEnv - 1; env > numRelLead; env--) {
+ border -= relBordTrail[rel++];
+ sbrGrid->envTimeBorder[env] = border * SAMPLES_PER_SLOT;
+ }
+
+ sbrGrid->envTimeBorder[sbrGrid->numEnv] = absBordTrail * SAMPLES_PER_SLOT;
+
+ if (sbrGrid->numEnv > 1) {
+ sbrGrid->numNoiseFloors = 2;
+ sbrGrid->noiseTimeBorder[0] = sbrGrid->envTimeBorder[0];
+ sbrGrid->noiseTimeBorder[1] = sbrGrid->envTimeBorder[middleBorder];
+ sbrGrid->noiseTimeBorder[2] = sbrGrid->envTimeBorder[sbrGrid->numEnv];
+ } else {
+ sbrGrid->numNoiseFloors = 1;
+ sbrGrid->noiseTimeBorder[0] = sbrGrid->envTimeBorder[0];
+ sbrGrid->noiseTimeBorder[1] = sbrGrid->envTimeBorder[1];
+ }
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: UnpackDeltaTimeFreq
+ *
+ * Description: unpack time/freq flags for delta coding of SBR envelopes (table 4.63)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of dt/df flags
+ * number of envelopes
+ * number of noise floors
+ *
+ * Outputs: delta flags for envelope and noise floors
+ *
+ * Return: none
+ **************************************************************************************/
+static void UnpackDeltaTimeFreq(BitStreamInfo *bsi, int numEnv, unsigned char *deltaFlagEnv,
+ int numNoiseFloors, unsigned char *deltaFlagNoise)
+{
+ int env, noiseFloor;
+
+ for (env = 0; env < numEnv; env++) {
+ deltaFlagEnv[env] = GetBits(bsi, 1);
+ }
+
+ for (noiseFloor = 0; noiseFloor < numNoiseFloors; noiseFloor++) {
+ deltaFlagNoise[noiseFloor] = GetBits(bsi, 1);
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackInverseFilterMode
+ *
+ * Description: unpack invf flags for chirp factor calculation (table 4.64)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of invf flags
+ * number of noise floor bands
+ *
+ * Outputs: invf flags for noise floor bands
+ *
+ * Return: none
+ **************************************************************************************/
+static void UnpackInverseFilterMode(BitStreamInfo *bsi, int numNoiseFloorBands, unsigned char *mode)
+{
+ int n;
+
+ for (n = 0; n < numNoiseFloorBands; n++) {
+ mode[n] = GetBits(bsi, 2);
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackSinusoids
+ *
+ * Description: unpack sinusoid (harmonic) flags for each SBR subband (table 4.67)
+ *
+ * Inputs: BitStreamInfo struct pointing to start of sinusoid flags
+ * number of high resolution SBR subbands (nHigh)
+ *
+ * Outputs: sinusoid flags for each SBR subband, zero-filled above nHigh
+ *
+ * Return: none
+ **************************************************************************************/
+static void UnpackSinusoids(BitStreamInfo *bsi, int nHigh, int addHarmonicFlag, unsigned char *addHarmonic)
+{
+ int n;
+
+ n = 0;
+ if (addHarmonicFlag) {
+ for (; n < nHigh; n++) {
+ addHarmonic[n] = GetBits(bsi, 1);
+ }
+ }
+
+ /* zero out unused bands */
+ for (; n < MAX_QMF_BANDS; n++) {
+ addHarmonic[n] = 0;
+ }
+}
+
+/**************************************************************************************
+ * Function: CopyCouplingGrid
+ *
+ * Description: copy grid parameters from left to right for channel coupling
+ *
+ * Inputs: initialized SBRGrid struct for left channel
+ *
+ * Outputs: initialized SBRGrid struct for right channel
+ *
+ * Return: none
+ **************************************************************************************/
+static void CopyCouplingGrid(SBRGrid *sbrGridLeft, SBRGrid *sbrGridRight)
+{
+ int env, noiseFloor;
+
+ sbrGridRight->frameClass = sbrGridLeft->frameClass;
+ sbrGridRight->ampResFrame = sbrGridLeft->ampResFrame;
+ sbrGridRight->pointer = sbrGridLeft->pointer;
+
+ sbrGridRight->numEnv = sbrGridLeft->numEnv;
+ for (env = 0; env < sbrGridLeft->numEnv; env++) {
+ sbrGridRight->envTimeBorder[env] = sbrGridLeft->envTimeBorder[env];
+ sbrGridRight->freqRes[env] = sbrGridLeft->freqRes[env];
+ }
+ sbrGridRight->envTimeBorder[env] = sbrGridLeft->envTimeBorder[env]; /* borders are [0, numEnv] inclusive */
+
+ sbrGridRight->numNoiseFloors = sbrGridLeft->numNoiseFloors;
+ for (noiseFloor = 0; noiseFloor <= sbrGridLeft->numNoiseFloors; noiseFloor++) {
+ sbrGridRight->noiseTimeBorder[noiseFloor] = sbrGridLeft->noiseTimeBorder[noiseFloor];
+ }
+
+ /* numEnvPrev, numNoiseFloorsPrev, freqResPrev are updated in DecodeSBREnvelope() and DecodeSBRNoise() */
+}
+
+/**************************************************************************************
+ * Function: CopyCouplingInverseFilterMode
+ *
+ * Description: copy invf flags from left to right for channel coupling
+ *
+ * Inputs: invf flags for left channel
+ * number of noise floor bands
+ *
+ * Outputs: invf flags for right channel
+ *
+ * Return: none
+ **************************************************************************************/
+static void CopyCouplingInverseFilterMode(int numNoiseFloorBands, unsigned char *modeLeft, unsigned char *modeRight)
+{
+ int band;
+
+ for (band = 0; band < numNoiseFloorBands; band++) {
+ modeRight[band] = modeLeft[band];
+ }
+}
+
+/**************************************************************************************
+ * Function: UnpackSBRSingleChannel
+ *
+ * Description: unpack sideband info (grid, delta flags, invf flags, envelope and
+ * noise floor configuration, sinusoids) for a single channel
+ *
+ * Inputs: BitStreamInfo struct pointing to start of sideband info
+ * initialized PSInfoSBR struct (after parsing SBR header and building
+ * frequency tables)
+ * base output channel (range = [0, nChans-1])
+ *
+ * Outputs: updated PSInfoSBR struct (SBRGrid and SBRChan)
+ *
+ * Return: none
+ **************************************************************************************/
+int UnpackSBRSingleChannel(BitStreamInfo *bsi, PSInfoSBR *psi, int chBase)
+{
+ int bitsLeft;
+ int err = ERR_AAC_NONE;
+ SBRHeader *sbrHdr = &(psi->sbrHdr[chBase]);
+ SBRGrid *sbrGridL = &(psi->sbrGrid[chBase + 0]);
+ SBRFreq *sbrFreq = &(psi->sbrFreq[chBase]);
+ SBRChan *sbrChanL = &(psi->sbrChan[chBase + 0]);
+
+ psi->dataExtra = GetBits(bsi, 1);
+ if (psi->dataExtra) {
+ psi->resBitsData = GetBits(bsi, 4);
+ }
+
+ err = UnpackSBRGrid(bsi, sbrHdr, sbrGridL);
+ if (err) {
+ return err;
+ }
+ UnpackDeltaTimeFreq(bsi, sbrGridL->numEnv, sbrChanL->deltaFlagEnv, sbrGridL->numNoiseFloors, sbrChanL->deltaFlagNoise);
+ UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1]);
+
+ err = DecodeSBREnvelope(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ if (err) {
+ return err;
+ }
+ err = DecodeSBRNoise(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ if (err) {
+ return err;
+ }
+
+ sbrChanL->addHarmonicFlag[1] = GetBits(bsi, 1);
+ UnpackSinusoids(bsi, sbrFreq->nHigh, sbrChanL->addHarmonicFlag[1], sbrChanL->addHarmonic[1]);
+
+ psi->extendedDataPresent = GetBits(bsi, 1);
+ if (psi->extendedDataPresent) {
+ psi->extendedDataSize = GetBits(bsi, 4);
+ if (psi->extendedDataSize == 15) {
+ psi->extendedDataSize += GetBits(bsi, 8);
+ }
+
+ bitsLeft = 8 * psi->extendedDataSize;
+
+ /* get ID, unpack extension info, do whatever is necessary with it... */
+ while (bitsLeft > 0) {
+ GetBits(bsi, 8);
+ bitsLeft -= 8;
+ }
+ }
+ return ERR_AAC_NONE;
+}
+
+/**************************************************************************************
+ * Function: UnpackSBRChannelPair
+ *
+ * Description: unpack sideband info (grid, delta flags, invf flags, envelope and
+ * noise floor configuration, sinusoids) for a channel pair
+ *
+ * Inputs: BitStreamInfo struct pointing to start of sideband info
+ * initialized PSInfoSBR struct (after parsing SBR header and building
+ * frequency tables)
+ * base output channel (range = [0, nChans-1])
+ *
+ * Outputs: updated PSInfoSBR struct (SBRGrid and SBRChan for both channels)
+ *
+ * Return: none
+ **************************************************************************************/
+int UnpackSBRChannelPair(BitStreamInfo *bsi, PSInfoSBR *psi, int chBase)
+{
+ int bitsLeft, err = ERR_AAC_NONE;
+ SBRHeader *sbrHdr = &(psi->sbrHdr[chBase]);
+ SBRGrid *sbrGridL = &(psi->sbrGrid[chBase + 0]), *sbrGridR = &(psi->sbrGrid[chBase + 1]);
+ SBRFreq *sbrFreq = &(psi->sbrFreq[chBase]);
+ SBRChan *sbrChanL = &(psi->sbrChan[chBase + 0]), *sbrChanR = &(psi->sbrChan[chBase + 1]);
+
+ psi->dataExtra = GetBits(bsi, 1);
+ if (psi->dataExtra) {
+ psi->resBitsData = GetBits(bsi, 4);
+ psi->resBitsData = GetBits(bsi, 4);
+ }
+
+ psi->couplingFlag = GetBits(bsi, 1);
+ if (psi->couplingFlag) {
+ err = UnpackSBRGrid(bsi, sbrHdr, sbrGridL);
+ if (err) {
+ return err;
+ }
+ CopyCouplingGrid(sbrGridL, sbrGridR);
+
+ UnpackDeltaTimeFreq(bsi, sbrGridL->numEnv, sbrChanL->deltaFlagEnv, sbrGridL->numNoiseFloors, sbrChanL->deltaFlagNoise);
+ UnpackDeltaTimeFreq(bsi, sbrGridR->numEnv, sbrChanR->deltaFlagEnv, sbrGridR->numNoiseFloors, sbrChanR->deltaFlagNoise);
+
+ UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1]);
+ CopyCouplingInverseFilterMode(sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1], sbrChanR->invfMode[1]);
+
+ err = DecodeSBREnvelope(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ if (err) {
+ return err;
+ }
+ DecodeSBRNoise(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ DecodeSBREnvelope(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1);
+ DecodeSBRNoise(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1);
+
+ /* pass RIGHT sbrChan struct */
+ UncoupleSBREnvelope(psi, sbrGridL, sbrFreq, sbrChanR);
+ UncoupleSBRNoise(psi, sbrGridL, sbrFreq, sbrChanR);
+
+ } else {
+ UnpackSBRGrid(bsi, sbrHdr, sbrGridL);
+ UnpackSBRGrid(bsi, sbrHdr, sbrGridR);
+ UnpackDeltaTimeFreq(bsi, sbrGridL->numEnv, sbrChanL->deltaFlagEnv, sbrGridL->numNoiseFloors, sbrChanL->deltaFlagNoise);
+ UnpackDeltaTimeFreq(bsi, sbrGridR->numEnv, sbrChanR->deltaFlagEnv, sbrGridR->numNoiseFloors, sbrChanR->deltaFlagNoise);
+ UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1]);
+ UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanR->invfMode[1]);
+
+ DecodeSBREnvelope(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ DecodeSBREnvelope(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1);
+ DecodeSBRNoise(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0);
+ DecodeSBRNoise(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1);
+ }
+
+ sbrChanL->addHarmonicFlag[1] = GetBits(bsi, 1);
+ UnpackSinusoids(bsi, sbrFreq->nHigh, sbrChanL->addHarmonicFlag[1], sbrChanL->addHarmonic[1]);
+
+ sbrChanR->addHarmonicFlag[1] = GetBits(bsi, 1);
+ UnpackSinusoids(bsi, sbrFreq->nHigh, sbrChanR->addHarmonicFlag[1], sbrChanR->addHarmonic[1]);
+
+ psi->extendedDataPresent = GetBits(bsi, 1);
+ if (psi->extendedDataPresent) {
+ psi->extendedDataSize = GetBits(bsi, 4);
+ if (psi->extendedDataSize == 15) {
+ psi->extendedDataSize += GetBits(bsi, 8);
+ }
+
+ bitsLeft = 8 * psi->extendedDataSize;
+
+ /* get ID, unpack extension info, do whatever is necessary with it... */
+ while (bitsLeft > 0) {
+ GetBits(bsi, 8);
+ bitsLeft -= 8;
+ }
+ }
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/wfd_aac_decoder/sbrtabs.c b/audio_codec/wfd_aac_decoder/sbrtabs.c
new file mode 100644
index 0000000..d7ba798
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/sbrtabs.c
@@ -0,0 +1,400 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: sbrtabs.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * sbrtabs.c - platform-independent tables for SBR (global, read-only)
+ **************************************************************************************/
+
+#include "sbr.h"
+
+/* k0Tab[sampRateIdx][k] = k0 = startMin + offset(bs_start_freq) for given sample rate (4.6.18.3.2.1)
+ * downsampled (single-rate) SBR not currently supported
+ */
+const unsigned char k0Tab[NUM_SAMPLE_RATES_SBR][16] = {
+ { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 23, 27, 31 }, /* 96 kHz */
+ { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 23, 27, 31 }, /* 88 kHz */
+ { 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, 23, 26, 30 }, /* 64 kHz */
+ { 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 27, 31 }, /* 48 kHz */
+ { 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 23, 25, 28, 32 }, /* 44 kHz */
+ { 10, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 27, 29, 32 }, /* 32 kHz */
+ { 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 27, 29, 32 }, /* 24 kHz */
+ { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, 30 }, /* 22 kHz */
+ { 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }, /* 16 kHz */
+};
+
+/* k2Tab[sampRateIdx][k] = stopVector(bs_stop_freq) for given sample rate, bs_stop_freq = [0, 13] (4.6.18.3.2.1)
+ * generated with Matlab script calc_stopvec.m
+ * downsampled (single-rate) SBR not currently supported
+ */
+const unsigned char k2Tab[NUM_SAMPLE_RATES_SBR][14] = {
+ { 13, 15, 17, 19, 21, 24, 27, 31, 35, 39, 44, 50, 57, 64 }, /* 96 kHz */
+ { 15, 17, 19, 21, 23, 26, 29, 33, 37, 41, 46, 51, 57, 64 }, /* 88 kHz */
+ { 20, 22, 24, 26, 28, 31, 34, 37, 41, 45, 49, 54, 59, 64 }, /* 64 kHz */
+ { 21, 23, 25, 27, 29, 32, 35, 38, 41, 45, 49, 54, 59, 64 }, /* 48 kHz */
+ { 23, 25, 27, 29, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64 }, /* 44 kHz */
+ { 32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61, 64 }, /* 32 kHz */
+ { 32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61, 64 }, /* 24 kHz */
+ { 35, 36, 38, 40, 42, 44, 46, 48, 50, 52, 55, 58, 61, 64 }, /* 22 kHz */
+ { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 62, 64 }, /* 16 kHz */
+};
+
+/* NINT(2.048E6 / Fs) (figure 4.47)
+ * downsampled (single-rate) SBR not currently supported
+ */
+const unsigned char goalSBTab[NUM_SAMPLE_RATES_SBR] = {
+ 21, 23, 32, 43, 46, 64, 85, 93, 128
+};
+
+const HuffInfo huffTabSBRInfo[10] = {
+ {19, { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 2, 7, 4, 8, 72, 0}, 0},
+ {20, { 0, 2, 2, 2, 2, 2, 1, 3, 3, 2, 4, 4, 4, 3, 2, 5, 6, 13, 15, 46}, 121},
+ {17, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 0, 0, 1, 25, 10, 0, 0, 0}, 242},
+ {19, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 3, 1, 0, 1, 1, 2, 1, 29, 2, 0}, 291},
+ {19, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 2, 5, 1, 4, 2, 3, 34, 0}, 340},
+ {20, { 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 1, 2, 3, 4, 4, 7, 10, 16}, 403},
+ {14, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 13, 2, 0, 0, 0, 0, 0, 0}, 466},
+ {14, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 6, 8, 0, 0, 0, 0, 0, 0}, 491},
+ {14, { 1, 1, 1, 1, 1, 1, 0, 2, 0, 1, 1, 0, 51, 2, 0, 0, 0, 0, 0, 0}, 516},
+ { 8, { 1, 1, 1, 0, 1, 1, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 579},
+};
+
+/* Huffman tables from appendix 4.A.6.1, includes offset of -LAV[i] for table i */
+const signed short huffTabSBR[604] = {
+ /* SBR table sbr_tenv15 [121] (signed) */
+ 0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8,
+ -9, 8, -10, 9, -11, 10, -12, -13, 11, -14, 12, -15, -16, 13, -19, -18,
+ -17, 14, -24, -20, 16, -26, -21, 15, -23, -25, -22, -60, -59, -58, -57, -56,
+ -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40,
+ -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, 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,
+ /* SBR table sbr_fenv15 [121] (signed) */
+ 0, -1, 1, -2, -3, 2, -4, 3, -5, 4, -6, 5, -7, 6, -8, 7,
+ -9, 8, -10, 9, -11, 10, 11, -12, 12, -13, 13, 14, -14, -15, 15, 16,
+ 17, -16, -17, -18, -19, 18, 19, -20, -21, 20, 21, -24, -23, -22, -26, -28,
+ 22, 23, 25, -41, -25, 26, 27, -30, -27, 24, 28, 44, -51, -46, -44, -43,
+ -37, -33, -31, -29, 30, 37, 42, 47, 48, -60, -59, -58, -57, -56, -55, -54,
+ -53, -52, -50, -49, -48, -47, -45, -42, -40, -39, -38, -36, -35, -34, -32, 29,
+ 31, 32, 33, 34, 35, 36, 38, 39, 40, 41, 43, 45, 46, 49, 50, 51,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60,
+ /* SBR table sbr_tenv15b [49] (signed) */
+ 0, 1, -1, 2, -2, 3, -3, 4, -4, -5, 5, -6, 6, 7, -7, 8,
+ -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9,
+ -8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24,
+ /* SBR table sbr_fenv15b [49] (signed) */
+ 0, -1, 1, -2, 2, 3, -3, -4, 4, -5, 5, -6, 6, -7, 7, 8,
+ -9, -8, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11,
+ -10, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24,
+ /* SBR table sbr_tenv30 [63] (signed) */
+ 0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, -7, 6, -8, 7,
+ -9, -10, 8, 9, 10, -13, -11, -12, -14, 11, 12, -31, -30, -29, -28, -27,
+ -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ /* SBR table sbr_fenv30 [63] (signed) */
+ 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, -15, 14, 15, -14, 18,
+ -18, -24, -19, 16, 17, -22, -21, -16, 20, 21, 22, 25, -23, -20, 24, -31,
+ -30, -29, -28, -27, -26, -25, -17, 19, 23, 26, 27, 28, 29, 30, 31,
+ /* SBR table sbr_tenv30b [25] (signed) */
+ 0, 1, -1, -2, 2, 3, -3, -4, 4, -5, -12, -11, -10, -9, -8, -7,
+ -6, 5, 6, 7, 8, 9, 10, 11, 12,
+ /* SBR table sbr_fenv30b [25] (signed) */
+ 0, -1, 1, -2, 2, 3, -3, -4, 4, -5, 5, 6, -12, -11, -10, -9,
+ -8, -7, -6, 7, 8, 9, 10, 11, 12,
+ /* SBR table sbr_tnoise30 [63] (signed) */
+ 0, 1, -1, -2, 2, -3, 3, -4, 4, -5, 5, 11, -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, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ /* SBR table sbr_tnoise30b [25] (signed) */
+ 0, -1, 1, -2, 2, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, 3,
+ 4, 5, 6, 7, 8, 9, 10, 11, 12,
+};
+
+/* log2Tab[x] = floor(log2(x)), format = Q28 */
+const int log2Tab[65] = {
+ 0x00000000, 0x00000000, 0x10000000, 0x195c01a3, 0x20000000, 0x25269e12, 0x295c01a3, 0x2ceaecfe,
+ 0x30000000, 0x32b80347, 0x35269e12, 0x3759d4f8, 0x395c01a3, 0x3b350047, 0x3ceaecfe, 0x3e829fb6,
+ 0x40000000, 0x41663f6f, 0x42b80347, 0x43f782d7, 0x45269e12, 0x4646eea2, 0x4759d4f8, 0x48608280,
+ 0x495c01a3, 0x4a4d3c25, 0x4b350047, 0x4c1404ea, 0x4ceaecfe, 0x4dba4a47, 0x4e829fb6, 0x4f446359,
+ 0x50000000, 0x50b5d69b, 0x51663f6f, 0x52118b11, 0x52b80347, 0x5359ebc5, 0x53f782d7, 0x549101ea,
+ 0x55269e12, 0x55b88873, 0x5646eea2, 0x56d1fafd, 0x5759d4f8, 0x57dea15a, 0x58608280, 0x58df988f,
+ 0x595c01a3, 0x59d5d9fd, 0x5a4d3c25, 0x5ac24113, 0x5b350047, 0x5ba58feb, 0x5c1404ea, 0x5c80730b,
+ 0x5ceaecfe, 0x5d53847a, 0x5dba4a47, 0x5e1f4e51, 0x5e829fb6, 0x5ee44cd5, 0x5f446359, 0x5fa2f045,
+ 0x60000000
+};
+
+/* coefficient table 4.A.87, format = Q31
+ * reordered as:
+ * cTab[0], cTab[64], cTab[128], cTab[192], cTab[256],
+ * cTab[2], cTab[66], cTab[130], cTab[194], cTab[258],
+ * ...
+ * cTab[64], cTab[128], cTab[192], cTab[256], cTab[320]
+ *
+ * NOTE: cTab[1, 2, ... , 318, 319] = cTab[639, 638, ... 322, 321]
+ * except cTab[384] = -cTab[256], cTab[512] = -cTab[128]
+ */
+const int cTabA[165] = {
+ 0x00000000, 0x0055dba1, 0x01b2e41d, 0x09015651, 0x2e3a7532, 0xffed978a, 0x006090c4, 0x01fd3ba0, 0x08a24899, 0x311af3a4,
+ 0xfff0065d, 0x006b47fa, 0x024bf7a1, 0x082f552e, 0x33ff670e, 0xffef7b8b, 0x0075fded, 0x029e35b4, 0x07a8127d, 0x36e69691,
+ 0xffee1650, 0x00807994, 0x02f3e48d, 0x070bbf58, 0x39ce0477, 0xffecc31b, 0x008a7dd7, 0x034d01f0, 0x06593912, 0x3cb41219,
+ 0xffeb50b2, 0x009424c6, 0x03a966bb, 0x0590a67d, 0x3f962fb8, 0xffe9ca76, 0x009d10bf, 0x04083fec, 0x04b0adcb, 0x4272a385,
+ 0xffe88ba8, 0x00a520bb, 0x04694101, 0x03b8f8dc, 0x4547daea, 0xffe79e16, 0x00abe79e, 0x04cc2fcf, 0x02a99097, 0x4812f848,
+ 0xffe6d466, 0x00b1978d, 0x05303f87, 0x01816e06, 0x4ad237a2, 0xffe65416, 0x00b5c867, 0x05950122, 0x0040c496, 0x4d83976c,
+ 0xffe66dd0, 0x00b8394b, 0x05f9c051, 0xfee723c6, 0x5024d70e, 0xffe69423, 0x00b8c6b0, 0x065dd56a, 0xfd7475d8, 0x52b449de,
+ 0xffe75361, 0x00b73ab0, 0x06c0f0c0, 0xfbe8f5bd, 0x552f8ff7, 0xffe85b4b, 0x00b36acd, 0x0721bf22, 0xfa44a069, 0x579505f5,
+ 0xffea353a, 0x00acbd2f, 0x077fedb3, 0xf887507c, 0x59e2f69e, 0xffec8409, 0x00a3508f, 0x07da2b7f, 0xf6b1f3c3, 0x5c16d0ae,
+ 0xffef2395, 0x0096dcc2, 0x08303897, 0xf4c473c6, 0x5e2f6367, 0xfff294c3, 0x00872c63, 0x0880ffdd, 0xf2bf6ea4, 0x602b0c7f,
+ 0xfff681d6, 0x007400b8, 0x08cb4e23, 0xf0a3959f, 0x6207f220, 0xfffb42b0, 0x005d36df, 0x090ec1fc, 0xee71b2fe, 0x63c45243,
+ 0x00007134, 0x00426f36, 0x0949eaac, 0xec2a3f5f, 0x655f63f2, 0x0006b1cf, 0x0023b989, 0x097c1ee8, 0xe9cea84a, 0x66d76725,
+ 0x000d31b5, 0x0000e790, 0x09a3e163, 0xe75f8bb8, 0x682b39a4, 0x001471f8, 0xffda17f2, 0x09c0e59f, 0xe4de0cb0, 0x6959709d,
+ 0x001c3549, 0xffaea5d6, 0x09d19ca9, 0xe24b8f66, 0x6a619c5e, 0x0024dd50, 0xff7ee3f1, 0x09d5560b, 0xdfa93ab5, 0x6b42a864,
+ 0x002d8e42, 0xff4aabc8, 0x09caeb0f, 0xdcf898fb, 0x6bfbdd98, 0x003745f9, 0xff120d70, 0x09b18a1d, 0xda3b176a, 0x6c8c4c7a,
+ 0x004103f4, 0xfed4bec3, 0x09881dc5, 0xd7722f04, 0x6cf4073e, 0x004b6c46, 0xfe933dc0, 0x094d7ec2, 0xd49fd55f, 0x6d32730f,
+ 0x0055dba1, 0x01b2e41d, 0x09015651, 0x2e3a7532, 0x6d474e1d,
+};
+
+/* coefficient table 4.A.87, format = Q31
+ * reordered as cTab[0], cTab[64], cTab[128], ... cTab[576], cTab[1], cTab[65], cTab[129], ... cTab[639]
+ * keeping full table (not using symmetry) to allow sequential access in synth filter inner loop
+ * format = Q31
+ */
+const int cTabS[640] = {
+ 0x00000000, 0x0055dba1, 0x01b2e41d, 0x09015651, 0x2e3a7532, 0x6d474e1d, 0xd1c58ace, 0x09015651, 0xfe4d1be3, 0x0055dba1,
+ 0xffede50e, 0x005b5371, 0x01d78bfc, 0x08d3e41b, 0x2faa221c, 0x6d41d963, 0xd3337b3d, 0x09299ead, 0xfe70b8d1, 0x0050b177,
+ 0xffed978a, 0x006090c4, 0x01fd3ba0, 0x08a24899, 0x311af3a4, 0x6d32730f, 0xd49fd55f, 0x094d7ec2, 0xfe933dc0, 0x004b6c46,
+ 0xffefc9b9, 0x0065fde5, 0x02244a24, 0x086b1eeb, 0x328cc6f0, 0x6d18520e, 0xd60a46e5, 0x096d0e21, 0xfeb48d0d, 0x00465348,
+ 0xfff0065d, 0x006b47fa, 0x024bf7a1, 0x082f552e, 0x33ff670e, 0x6cf4073e, 0xd7722f04, 0x09881dc5, 0xfed4bec3, 0x004103f4,
+ 0xffeff6ca, 0x0070c8a5, 0x0274ba43, 0x07ee507c, 0x3572ec70, 0x6cc59bab, 0xd8d7f21f, 0x099ec3dc, 0xfef3f6ab, 0x003c1fa4,
+ 0xffef7b8b, 0x0075fded, 0x029e35b4, 0x07a8127d, 0x36e69691, 0x6c8c4c7a, 0xda3b176a, 0x09b18a1d, 0xff120d70, 0x003745f9,
+ 0xffeedfa4, 0x007b3875, 0x02c89901, 0x075ca90c, 0x385a49c4, 0x6c492217, 0xdb9b5b12, 0x09c018ce, 0xff2ef725, 0x00329ab6,
+ 0xffee1650, 0x00807994, 0x02f3e48d, 0x070bbf58, 0x39ce0477, 0x6bfbdd98, 0xdcf898fb, 0x09caeb0f, 0xff4aabc8, 0x002d8e42,
+ 0xffed651d, 0x0085c217, 0x03201116, 0x06b559c3, 0x3b415115, 0x6ba4629f, 0xde529086, 0x09d1fa23, 0xff6542d1, 0x00293718,
+ 0xffecc31b, 0x008a7dd7, 0x034d01f0, 0x06593912, 0x3cb41219, 0x6b42a864, 0xdfa93ab5, 0x09d5560b, 0xff7ee3f1, 0x0024dd50,
+ 0xffebe77b, 0x008f4bfc, 0x037ad438, 0x05f7fb90, 0x3e25b17e, 0x6ad73e8d, 0xe0fc421e, 0x09d52709, 0xff975c01, 0x002064f8,
+ 0xffeb50b2, 0x009424c6, 0x03a966bb, 0x0590a67d, 0x3f962fb8, 0x6a619c5e, 0xe24b8f66, 0x09d19ca9, 0xffaea5d6, 0x001c3549,
+ 0xffea9192, 0x0098b855, 0x03d8afe6, 0x05237f9d, 0x41058bc6, 0x69e29784, 0xe396a45d, 0x09cab9f2, 0xffc4e365, 0x0018703f,
+ 0xffe9ca76, 0x009d10bf, 0x04083fec, 0x04b0adcb, 0x4272a385, 0x6959709d, 0xe4de0cb0, 0x09c0e59f, 0xffda17f2, 0x001471f8,
+ 0xffe940f4, 0x00a1039c, 0x043889c6, 0x0437fb0a, 0x43de620a, 0x68c7269b, 0xe620c476, 0x09b3d77f, 0xffee183b, 0x0010bc63,
+ 0xffe88ba8, 0x00a520bb, 0x04694101, 0x03b8f8dc, 0x4547daea, 0x682b39a4, 0xe75f8bb8, 0x09a3e163, 0x0000e790, 0x000d31b5,
+ 0xffe83a07, 0x00a8739d, 0x049aa82f, 0x03343533, 0x46aea856, 0x6785c24d, 0xe89971b7, 0x099140a7, 0x00131c75, 0x0009aa3f,
+ 0xffe79e16, 0x00abe79e, 0x04cc2fcf, 0x02a99097, 0x4812f848, 0x66d76725, 0xe9cea84a, 0x097c1ee8, 0x0023b989, 0x0006b1cf,
+ 0xffe7746e, 0x00af374c, 0x04fe20be, 0x02186a91, 0x4973fef1, 0x661fd6b8, 0xeafee7f1, 0x0963ed46, 0x0033b927, 0x00039609,
+ 0xffe6d466, 0x00b1978d, 0x05303f87, 0x01816e06, 0x4ad237a2, 0x655f63f2, 0xec2a3f5f, 0x0949eaac, 0x00426f36, 0x00007134,
+ 0xffe6afee, 0x00b3d15c, 0x05626209, 0x00e42fa2, 0x4c2ca3df, 0x64964063, 0xed50a31d, 0x092d7970, 0x00504f41, 0xfffdfa25,
+ 0xffe65416, 0x00b5c867, 0x05950122, 0x0040c496, 0x4d83976c, 0x63c45243, 0xee71b2fe, 0x090ec1fc, 0x005d36df, 0xfffb42b0,
+ 0xffe681c6, 0x00b74c37, 0x05c76fed, 0xff96db90, 0x4ed62be3, 0x62ea6474, 0xef8d4d7b, 0x08edfeaa, 0x006928a0, 0xfff91fca,
+ 0xffe66dd0, 0x00b8394b, 0x05f9c051, 0xfee723c6, 0x5024d70e, 0x6207f220, 0xf0a3959f, 0x08cb4e23, 0x007400b8, 0xfff681d6,
+ 0xffe66fac, 0x00b8fe0d, 0x062bf5ec, 0xfe310657, 0x516eefb9, 0x611d58a3, 0xf1b461ab, 0x08a75da4, 0x007e0393, 0xfff48700,
+ 0xffe69423, 0x00b8c6b0, 0x065dd56a, 0xfd7475d8, 0x52b449de, 0x602b0c7f, 0xf2bf6ea4, 0x0880ffdd, 0x00872c63, 0xfff294c3,
+ 0xffe6fed4, 0x00b85f70, 0x068f8b44, 0xfcb1d740, 0x53f495aa, 0x5f30ff5f, 0xf3c4e887, 0x08594887, 0x008f87aa, 0xfff0e7ef,
+ 0xffe75361, 0x00b73ab0, 0x06c0f0c0, 0xfbe8f5bd, 0x552f8ff7, 0x5e2f6367, 0xf4c473c6, 0x08303897, 0x0096dcc2, 0xffef2395,
+ 0xffe80414, 0x00b58c8c, 0x06f1825d, 0xfb19b7bd, 0x56654bdd, 0x5d26be9b, 0xf5be0fa9, 0x08061671, 0x009da526, 0xffedc418,
+ 0xffe85b4b, 0x00b36acd, 0x0721bf22, 0xfa44a069, 0x579505f5, 0x5c16d0ae, 0xf6b1f3c3, 0x07da2b7f, 0x00a3508f, 0xffec8409,
+ 0xffe954d0, 0x00b06b68, 0x075112a2, 0xf96916f5, 0x58befacd, 0x5b001db8, 0xf79fa13a, 0x07ad8c26, 0x00a85e94, 0xffeb3849,
+ 0xffea353a, 0x00acbd2f, 0x077fedb3, 0xf887507c, 0x59e2f69e, 0x59e2f69e, 0xf887507c, 0x077fedb3, 0x00acbd2f, 0xffea353a,
+ 0xffeb3849, 0x00a85e94, 0x07ad8c26, 0xf79fa13a, 0x5b001db8, 0x58befacd, 0xf96916f5, 0x075112a2, 0x00b06b68, 0xffe954d0,
+ 0xffec8409, 0x00a3508f, 0x07da2b7f, 0xf6b1f3c3, 0x5c16d0ae, 0x579505f5, 0xfa44a069, 0x0721bf22, 0x00b36acd, 0xffe85b4b,
+ 0xffedc418, 0x009da526, 0x08061671, 0xf5be0fa9, 0x5d26be9b, 0x56654bdd, 0xfb19b7bd, 0x06f1825d, 0x00b58c8c, 0xffe80414,
+ 0xffef2395, 0x0096dcc2, 0x08303897, 0xf4c473c6, 0x5e2f6367, 0x552f8ff7, 0xfbe8f5bd, 0x06c0f0c0, 0x00b73ab0, 0xffe75361,
+ 0xfff0e7ef, 0x008f87aa, 0x08594887, 0xf3c4e887, 0x5f30ff5f, 0x53f495aa, 0xfcb1d740, 0x068f8b44, 0x00b85f70, 0xffe6fed4,
+ 0xfff294c3, 0x00872c63, 0x0880ffdd, 0xf2bf6ea4, 0x602b0c7f, 0x52b449de, 0xfd7475d8, 0x065dd56a, 0x00b8c6b0, 0xffe69423,
+ 0xfff48700, 0x007e0393, 0x08a75da4, 0xf1b461ab, 0x611d58a3, 0x516eefb9, 0xfe310657, 0x062bf5ec, 0x00b8fe0d, 0xffe66fac,
+ 0xfff681d6, 0x007400b8, 0x08cb4e23, 0xf0a3959f, 0x6207f220, 0x5024d70e, 0xfee723c6, 0x05f9c051, 0x00b8394b, 0xffe66dd0,
+ 0xfff91fca, 0x006928a0, 0x08edfeaa, 0xef8d4d7b, 0x62ea6474, 0x4ed62be3, 0xff96db90, 0x05c76fed, 0x00b74c37, 0xffe681c6,
+ 0xfffb42b0, 0x005d36df, 0x090ec1fc, 0xee71b2fe, 0x63c45243, 0x4d83976c, 0x0040c496, 0x05950122, 0x00b5c867, 0xffe65416,
+ 0xfffdfa25, 0x00504f41, 0x092d7970, 0xed50a31d, 0x64964063, 0x4c2ca3df, 0x00e42fa2, 0x05626209, 0x00b3d15c, 0xffe6afee,
+ 0x00007134, 0x00426f36, 0x0949eaac, 0xec2a3f5f, 0x655f63f2, 0x4ad237a2, 0x01816e06, 0x05303f87, 0x00b1978d, 0xffe6d466,
+ 0x00039609, 0x0033b927, 0x0963ed46, 0xeafee7f1, 0x661fd6b8, 0x4973fef1, 0x02186a91, 0x04fe20be, 0x00af374c, 0xffe7746e,
+ 0x0006b1cf, 0x0023b989, 0x097c1ee8, 0xe9cea84a, 0x66d76725, 0x4812f848, 0x02a99097, 0x04cc2fcf, 0x00abe79e, 0xffe79e16,
+ 0x0009aa3f, 0x00131c75, 0x099140a7, 0xe89971b7, 0x6785c24d, 0x46aea856, 0x03343533, 0x049aa82f, 0x00a8739d, 0xffe83a07,
+ 0x000d31b5, 0x0000e790, 0x09a3e163, 0xe75f8bb8, 0x682b39a4, 0x4547daea, 0x03b8f8dc, 0x04694101, 0x00a520bb, 0xffe88ba8,
+ 0x0010bc63, 0xffee183b, 0x09b3d77f, 0xe620c476, 0x68c7269b, 0x43de620a, 0x0437fb0a, 0x043889c6, 0x00a1039c, 0xffe940f4,
+ 0x001471f8, 0xffda17f2, 0x09c0e59f, 0xe4de0cb0, 0x6959709d, 0x4272a385, 0x04b0adcb, 0x04083fec, 0x009d10bf, 0xffe9ca76,
+ 0x0018703f, 0xffc4e365, 0x09cab9f2, 0xe396a45d, 0x69e29784, 0x41058bc6, 0x05237f9d, 0x03d8afe6, 0x0098b855, 0xffea9192,
+ 0x001c3549, 0xffaea5d6, 0x09d19ca9, 0xe24b8f66, 0x6a619c5e, 0x3f962fb8, 0x0590a67d, 0x03a966bb, 0x009424c6, 0xffeb50b2,
+ 0x002064f8, 0xff975c01, 0x09d52709, 0xe0fc421e, 0x6ad73e8d, 0x3e25b17e, 0x05f7fb90, 0x037ad438, 0x008f4bfc, 0xffebe77b,
+ 0x0024dd50, 0xff7ee3f1, 0x09d5560b, 0xdfa93ab5, 0x6b42a864, 0x3cb41219, 0x06593912, 0x034d01f0, 0x008a7dd7, 0xffecc31b,
+ 0x00293718, 0xff6542d1, 0x09d1fa23, 0xde529086, 0x6ba4629f, 0x3b415115, 0x06b559c3, 0x03201116, 0x0085c217, 0xffed651d,
+ 0x002d8e42, 0xff4aabc8, 0x09caeb0f, 0xdcf898fb, 0x6bfbdd98, 0x39ce0477, 0x070bbf58, 0x02f3e48d, 0x00807994, 0xffee1650,
+ 0x00329ab6, 0xff2ef725, 0x09c018ce, 0xdb9b5b12, 0x6c492217, 0x385a49c4, 0x075ca90c, 0x02c89901, 0x007b3875, 0xffeedfa4,
+ 0x003745f9, 0xff120d70, 0x09b18a1d, 0xda3b176a, 0x6c8c4c7a, 0x36e69691, 0x07a8127d, 0x029e35b4, 0x0075fded, 0xffef7b8b,
+ 0x003c1fa4, 0xfef3f6ab, 0x099ec3dc, 0xd8d7f21f, 0x6cc59bab, 0x3572ec70, 0x07ee507c, 0x0274ba43, 0x0070c8a5, 0xffeff6ca,
+ 0x004103f4, 0xfed4bec3, 0x09881dc5, 0xd7722f04, 0x6cf4073e, 0x33ff670e, 0x082f552e, 0x024bf7a1, 0x006b47fa, 0xfff0065d,
+ 0x00465348, 0xfeb48d0d, 0x096d0e21, 0xd60a46e5, 0x6d18520e, 0x328cc6f0, 0x086b1eeb, 0x02244a24, 0x0065fde5, 0xffefc9b9,
+ 0x004b6c46, 0xfe933dc0, 0x094d7ec2, 0xd49fd55f, 0x6d32730f, 0x311af3a4, 0x08a24899, 0x01fd3ba0, 0x006090c4, 0xffed978a,
+ 0x0050b177, 0xfe70b8d1, 0x09299ead, 0xd3337b3d, 0x6d41d963, 0x2faa221c, 0x08d3e41b, 0x01d78bfc, 0x005b5371, 0xffede50f,
+};
+
+/* noise table 4.A.88, format = Q31 */
+const int noiseTab[512 * 2] = {
+ 0x8010fd38, 0xb3dc7948, 0x7c4e2301, 0xa9904192, 0x121622a7, 0x86489625, 0xc3d53d25, 0xd0343fa9,
+ 0x674d6f70, 0x25f4e9fd, 0xce1a8c8b, 0x72a726c5, 0xfea6efc6, 0xaa4adb1a, 0x8b2dd628, 0xf14029e4,
+ 0x46321c1a, 0x604889a0, 0x33363b63, 0x815ed069, 0x802b4315, 0x8f2bf7f3, 0x85b86073, 0x745cfb46,
+ 0xc57886b3, 0xb76731f0, 0xa2a66772, 0x828ca631, 0x60cc145e, 0x1ad1010f, 0x090c83d4, 0x9bd7ba87,
+ 0x5f5aeea2, 0x8b4dbd99, 0x848e7b1e, 0x86bb9fa2, 0x26f18ae5, 0xc0b81194, 0x553407bf, 0x52c17953,
+ 0x755f468d, 0x166b04f8, 0xa5687981, 0x4343248b, 0xa6558d5e, 0xc5f6fab7, 0x80a4fb8c, 0x8cb53cb7,
+ 0x7da68a54, 0x9cd8df8a, 0xba05376c, 0xfcb58ee2, 0xfdd657a4, 0x005e35ca, 0x91c75c55, 0x367651e6,
+ 0x816abf85, 0x8f831c4f, 0x423f9c9c, 0x55aa919e, 0x80779834, 0xb59f4244, 0x800a095c, 0x7de9e0cc,
+ 0x46bda5cb, 0x4c184464, 0x2c438f71, 0x797216b5, 0x5035cee6, 0xa0c3a26e, 0x9d3f95fa, 0xd4a100c0,
+ 0x8ac30dac, 0x04b87397, 0x9e5ac516, 0x8b0b442e, 0x66210ad6, 0x88ba7598, 0x45b9bd33, 0xf0be5087,
+ 0x9261b85e, 0x364f6a31, 0x891c4b50, 0x23ad08ce, 0xf10366a6, 0x80414276, 0x1b562e06, 0x8be21591,
+ 0x9e798195, 0x7fb4045c, 0x7d9506cf, 0x854e691f, 0x9207f092, 0x7a94c9d5, 0x88911536, 0x3f45cc61,
+ 0x27059279, 0xa5b57109, 0x6d2bb67b, 0x3bdc5379, 0x74e662d8, 0x80348f8c, 0xf875e638, 0x5a8caea1,
+ 0x2459ae75, 0x2c54b939, 0x79ee3203, 0xb9bc8683, 0x9b6f630c, 0x9f45b351, 0x8563b2b9, 0xe5dbba41,
+ 0x697c7d0d, 0x7bb7c90e, 0xac900866, 0x8e6b5177, 0x8822dd37, 0x7fd5a91e, 0x7506da05, 0x82302aca,
+ 0xa5e4be04, 0x4b4288eb, 0x00b8bc9f, 0x4f1033e4, 0x7200d612, 0x43900c8c, 0xa815b900, 0x676ed1d4,
+ 0x5c5f23b2, 0xa758ee11, 0xaf73abfa, 0x11714ec0, 0x265239e0, 0xc50de679, 0x8a84e341, 0xa1438354,
+ 0x7f1a341f, 0x343ec96b, 0x696e71b0, 0xa13bde39, 0x81e75094, 0x80091111, 0x853a73bf, 0x80f9c1ee,
+ 0xe4980086, 0x886a8e28, 0xa7e89426, 0xdd93edd7, 0x7592100d, 0x0bfa8123, 0x850a26d4, 0x2e34f395,
+ 0x421b6c00, 0xa4a462e4, 0x4e3f5090, 0x3c189f4c, 0x3c971a56, 0xdd0376d2, 0x747a5367, 0x7bcbc9d7,
+ 0x3966be6a, 0x7efda616, 0x55445e15, 0x7ba2ab3f, 0x5fe684f2, 0x8cf42af9, 0x808c61c3, 0x4390c27b,
+ 0x7cac62ff, 0xea6cab22, 0x5d0902ad, 0xc27b7208, 0x7a27389d, 0x5820a357, 0xa29bbe59, 0x9df0f1fd,
+ 0x92bd67e5, 0x7195b587, 0x97cac65b, 0x8339807e, 0x8f72d832, 0x5fad8685, 0xa462d9d3, 0x81d46214,
+ 0x6ae93e1d, 0x6b23a5b9, 0xc2732874, 0x81795268, 0x7c568cb6, 0x668513ea, 0x428d024e, 0x66b78b3a,
+ 0xfee9ef03, 0x9ddcbb82, 0xa605f07e, 0x46dc55e0, 0x85415054, 0xc89ec271, 0x7c42edfb, 0x0befe59b,
+ 0x89b8f607, 0x6d732a1a, 0xa7081ebd, 0x7e403258, 0x21feeb7b, 0x5dd7a1e7, 0x23e3a31a, 0x129bc896,
+ 0xa11a6b54, 0x7f1e031c, 0xfdc1a4d1, 0x96402e53, 0xb9700f1a, 0x8168ecd6, 0x7d63d3cc, 0x87a70d65,
+ 0x81075a7a, 0x55c8caa7, 0xa95d00b5, 0x102b1652, 0x0bb30215, 0xe5b63237, 0xa446ca44, 0x82d4c333,
+ 0x67b2e094, 0x44c3d661, 0x33fd6036, 0xde1ea2a1, 0xa95e8e47, 0x78f66eb9, 0x6f2aef1e, 0xe8887247,
+ 0x80a3b70e, 0xfca0d9d3, 0x6bf0fd20, 0x0d5226de, 0xf4341c87, 0x5902df05, 0x7ff1a38d, 0xf02e5a5b,
+ 0x99f129af, 0x8ac63d01, 0x7b53f599, 0x7bb32532, 0x99ac59b0, 0x5255a80f, 0xf1320a41, 0x2497aa5c,
+ 0xcce60bd8, 0x787c634b, 0x7ed58c5b, 0x8a28eb3a, 0x24a5e647, 0x8b79a2c1, 0x955f5ce5, 0xa9d12bc4,
+ 0x7a1e20c6, 0x3eeda7ac, 0xf7be823a, 0x042924ce, 0x808b3f03, 0x364248da, 0xac2895e5, 0x69a8b5fa,
+ 0x97fe8b63, 0xbdeac9aa, 0x8073e0ad, 0x6c25dba7, 0x005e51d2, 0x52e74389, 0x59d3988c, 0xe5d1f39c,
+ 0x7b57dc91, 0x341adbe7, 0xa7d42b8d, 0x74e9f335, 0xd35bf7d8, 0x5b7c0a4b, 0x75bc0874, 0x552129bf,
+ 0x8144b70d, 0x6de93bbb, 0x5825f14b, 0x473ec5ca, 0x80a8f37c, 0xe6552d69, 0x7898360b, 0x806379b0,
+ 0xa9b59339, 0x3f6bf60c, 0xc367d731, 0x920ade99, 0x125592f7, 0x877e5ed1, 0xda895d95, 0x075f2ece,
+ 0x380e5f5e, 0x9b006b62, 0xd17a6dd2, 0x530a0e13, 0xf4cc9a14, 0x7d0a0ed4, 0x847c6e3f, 0xbaee4975,
+ 0x47131163, 0x64fb2cac, 0x5e2100a6, 0x7b756a42, 0xd87609f4, 0x98bfe48c, 0x0493745e, 0x836c5784,
+ 0x7e5ccb40, 0x3df6b476, 0x97700d28, 0x8bbd93fd, 0x56de9cdb, 0x680b4e65, 0xebc3d90e, 0x6d286793,
+ 0x6753712e, 0xe05c98a7, 0x3d2b6b85, 0xc4b18ddb, 0x7b59b869, 0x31435688, 0x811888e9, 0xe011ee7a,
+ 0x6a5844f9, 0x86ae35ea, 0xb4cbc10b, 0x01a6f5d6, 0x7a49ed64, 0x927caa49, 0x847ddaed, 0xae0d9bb6,
+ 0x836bdb04, 0x0fd810a6, 0x74fe126b, 0x4a346b5f, 0x80184d36, 0x5afd153c, 0x90cc8102, 0xe606d0e6,
+ 0xde69aa58, 0xa89f1222, 0xe06df715, 0x8fd16144, 0x0317c3e8, 0x22ce92fc, 0x690c3eca, 0x93166f02,
+ 0x71573414, 0x8d43cffb, 0xe8bd0bb6, 0xde86770f, 0x0bf99a41, 0x4633a661, 0xba064108, 0x7adafae3,
+ 0x2f6cde5d, 0xb350a52c, 0xa5ebfb0b, 0x74c57b46, 0xd3b603b5, 0x80b70892, 0xa7f7fa53, 0xd94b566c,
+ 0xdda3fd86, 0x6a635793, 0x3ed005ca, 0xc5f087d8, 0x31e3a746, 0x7a4278f9, 0x82def1f9, 0x06caa2b2,
+ 0xe9d2c349, 0x8940e7f7, 0x7feef8dd, 0x4a9b01f0, 0xacde69f8, 0x57ddc280, 0xf09e4ba4, 0xb6d9f729,
+ 0xb48c18f2, 0xd3654aa9, 0xca7a03c8, 0x14d57545, 0x7fda87a5, 0x0e411366, 0xb77d0df0, 0x8c2aa467,
+ 0x787f2590, 0x2d292db1, 0x9f12682c, 0x44ac364d, 0x1a4b31a6, 0x871f7ded, 0x7ff99167, 0x6630a1d5,
+ 0x25385eb9, 0x2d4dd549, 0xaf8a7004, 0x319ebe0f, 0x379ab730, 0x81dc56a4, 0x822d8523, 0x1ae8554c,
+ 0x18fa0786, 0x875f7de4, 0x85ca350f, 0x7de818dc, 0x7786a38f, 0xa5456355, 0x92e60f88, 0xf5526122,
+ 0x916039bc, 0xc561e2de, 0x31c42042, 0x7c82e290, 0x75d158b2, 0xb015bda1, 0x7220c750, 0x46565441,
+ 0xd0da1fdd, 0x7b777481, 0x782e73c6, 0x8cd72b7b, 0x7f1006aa, 0xfb30e51e, 0x87994818, 0x34e7c7db,
+ 0x7faae06b, 0xea74fbc0, 0xd20c7af4, 0xc44f396b, 0x06b4234e, 0xdf2e2a93, 0x2efb07c8, 0xce861911,
+ 0x7550ea05, 0xd8d90bbb, 0x58522eec, 0x746b3520, 0xce844ce9, 0x7f5cacc3, 0xda8f17e0, 0x2fedf9cb,
+ 0xb2f77ec4, 0x6f13f4c0, 0x834de085, 0x7b7ace4b, 0x713b16ac, 0x499c5ab0, 0x06a7961d, 0x1b39a48a,
+ 0xbb853e6e, 0x7c781cc1, 0xc0baebf5, 0x7dace394, 0x815ceebc, 0xcc7b27d4, 0x8274b181, 0xa2be40a2,
+ 0xdd01d5dc, 0x7fefeb14, 0x0813ec78, 0xba3077cc, 0xe5cf1e1c, 0xedcfacae, 0x54c43a9b, 0x5cd62a42,
+ 0x93806b55, 0x03095c5b, 0x8e076ae3, 0x71bfcd2a, 0x7ac1989b, 0x623bc71a, 0x5e15d4d2, 0xfb341dd1,
+ 0xd75dfbca, 0xd0da32be, 0xd4569063, 0x337869da, 0x3d30606a, 0xcd89cca2, 0x7dd2ae36, 0x028c03cd,
+ 0xd85e052c, 0xe8dc9ec5, 0x7ffd9241, 0xde5bf4c6, 0x88c4b235, 0x8228be2e, 0x7fe6ec64, 0x996abe6a,
+ 0xdeb0666d, 0x9eb86611, 0xd249b922, 0x18b3e26b, 0x80211168, 0x5f8bb99c, 0x6ecb0dd2, 0x4728ff8d,
+ 0x2ac325b8, 0x6e5169d2, 0x7ebbd68d, 0x05e41d17, 0xaaa19f28, 0x8ab238a6, 0x51f105be, 0x140809cc,
+ 0x7f7345d9, 0x3aae5a9d, 0xaecec6e4, 0x1afb3473, 0xf6229ed1, 0x8d55f467, 0x7e32003a, 0x70f30c14,
+ 0x6686f33f, 0xd0d45ed8, 0x644fab57, 0x3a3fbbd3, 0x0b255fc4, 0x679a1701, 0x90e17b6e, 0x325d537b,
+ 0xcd7b9b87, 0xaa7be2a2, 0x7d47c966, 0xa33dbce5, 0x8659c3bb, 0x72a41367, 0x15c446e0, 0x45fe8b0a,
+ 0x9d8ddf26, 0x84d47643, 0x7fabe0da, 0x36a70122, 0x7a28ebfe, 0x7c29b8b8, 0x7f760406, 0xbabe4672,
+ 0x23ea216e, 0x92bcc50a, 0x6d20dba2, 0xad5a7c7e, 0xbf3897f5, 0xabb793e1, 0x8391fc7e, 0xe270291c,
+ 0x7a248d58, 0x80f8fd15, 0x83ef19f3, 0x5e6ece7d, 0x278430c1, 0x35239f4d, 0xe09c073b, 0x50e78cb5,
+ 0xd4b811bd, 0xce834ee0, 0xf88aaa34, 0xf71da5a9, 0xe2b0a1d5, 0x7c3aef31, 0xe84eabca, 0x3ce25964,
+ 0xf29336d3, 0x8fa78b2c, 0xa3fc3415, 0x63e1313d, 0x7fbc74e0, 0x7340bc93, 0x49ae583b, 0x8b79de4b,
+ 0x25011ce9, 0x7b462279, 0x36007db0, 0x3da1599c, 0x77780772, 0xc845c9bb, 0x83ba68be, 0x6ee507d1,
+ 0x2f0159b8, 0x5392c4ed, 0x98336ff6, 0x0b3c7f11, 0xde697aac, 0x893fc8d0, 0x6b83f8f3, 0x47799a0d,
+ 0x801d9dfc, 0x8516a83e, 0x5f8d22ec, 0x0f8ba384, 0xa049dc4b, 0xdd920b05, 0x7a99bc9f, 0x9ad19344,
+ 0x7a345dba, 0xf501a13f, 0x3e58bf19, 0x7fffaf9a, 0x3b4e1511, 0x0e08b991, 0x9e157620, 0x7230a326,
+ 0x4977f9ff, 0x2d2bbae1, 0x607aa7fc, 0x7bc85d5f, 0xb441bbbe, 0x8d8fa5f2, 0x601cce26, 0xda1884f2,
+ 0x81c82d64, 0x200b709c, 0xcbd36abe, 0x8cbdddd3, 0x55ab61d3, 0x7e3ee993, 0x833f18aa, 0xffc1aaea,
+ 0x7362e16a, 0x7fb85db2, 0x904ee04c, 0x7f04dca6, 0x8ad7a046, 0xebe7d8f7, 0xfbc4c687, 0xd0609458,
+ 0x093ed977, 0x8e546085, 0x7f5b8236, 0x7c47e118, 0xa01f2641, 0x7ffb3e48, 0x05de7cda, 0x7fc281b9,
+ 0x8e0278fc, 0xd74e6d07, 0x94c24450, 0x7cf9e641, 0x2ad27871, 0x919fa815, 0x805fd205, 0x7758397f,
+ 0xe2c7e02c, 0x1828e194, 0x5613d6fe, 0xfb55359f, 0xf9699516, 0x8978ee26, 0x7feebad9, 0x77d71d82,
+ 0x55b28b60, 0x7e997600, 0x80821a6b, 0xc6d78af1, 0x691822ab, 0x7f6982a0, 0x7ef56f99, 0x5c307f40,
+ 0xac6f8b76, 0x42cc8ba4, 0x782c61d9, 0xa0224dd0, 0x7bd234d1, 0x74576e3b, 0xe38cfe9a, 0x491e66ef,
+ 0xc78291c5, 0x895bb87f, 0x924f7889, 0x71b89394, 0x757b779d, 0xc4a9c604, 0x5cdf7829, 0x8020e9df,
+ 0x805e8245, 0x4a82c398, 0x6360bd62, 0x78bb60fc, 0x09e0d014, 0x4b0ea180, 0xb841978b, 0x69a0e864,
+ 0x7df35977, 0x3284b0dd, 0x3cdc2efd, 0x57d31f5e, 0x541069cc, 0x1776e92e, 0x04309ea3, 0xa015eb2d,
+ 0xce7bfabc, 0x41b638f8, 0x8365932e, 0x846ab44c, 0xbbcc80cb, 0x8afa6cac, 0x7fc422ea, 0x4e403fc0,
+ 0xbfac9aee, 0x8e4c6709, 0x028e01fb, 0x6d160a9b, 0x7fe93004, 0x790f9cdc, 0x6a1f37a0, 0xf7e7ef30,
+ 0xb4ea0f04, 0x7bf4c8e6, 0xe981701f, 0xc258a9d3, 0x6acbbfba, 0xef5479c7, 0x079c8bd8, 0x1a410f56,
+ 0x6853b799, 0x86cd4f01, 0xc66e23b6, 0x34585565, 0x8d1fe00d, 0x7fcdba1a, 0x32c9717b, 0xa02f9f48,
+ 0xf64940db, 0x5ed7d8f1, 0x61b823b2, 0x356f8918, 0xa0a7151e, 0x793fc969, 0x530beaeb, 0x34e93270,
+ 0x4fc4ddb5, 0x88d58b6c, 0x36094774, 0xf620ac80, 0x03763a72, 0xf910c9a6, 0x6666fb2d, 0x752c8be8,
+ 0x9a6dfdd8, 0xd1a7117d, 0x51c1b1d4, 0x0a67773d, 0x43b32a79, 0x4cdcd085, 0x5f067d30, 0x05bfe92a,
+ 0x7ed7d203, 0xe71a3c85, 0x99127ce2, 0x8eb3cac4, 0xad4bbcea, 0x5c6a0fd0, 0x0eec04af, 0x94e95cd4,
+ 0x8654f921, 0x83eabb5d, 0xb058d7ca, 0x69f12d3c, 0x03d881b2, 0x80558ef7, 0x82938cb3, 0x2ec0e1d6,
+ 0x80044422, 0xd1e47051, 0x720fc6ff, 0x82b20316, 0x0d527b02, 0x63049a15, 0x7ad5b9ad, 0xd2a4641d,
+ 0x41144f86, 0x7b04917a, 0x15c4a2c0, 0x9da07916, 0x211df54a, 0x7fdd09af, 0xfe924f3f, 0x7e132cfe,
+ 0x9a1d18d6, 0x7c56508b, 0x80f0f0af, 0x8095ced6, 0x8037d0d7, 0x026719d1, 0xa55fec43, 0x2b1c7cb7,
+ 0xa5cd5ac1, 0x77639fad, 0x7fcd8b62, 0x81a18c27, 0xaee4912e, 0xeae9eebe, 0xeb3081de, 0x8532aada,
+ 0xc822362e, 0x86a649a9, 0x8031a71d, 0x7b319dc6, 0xea8022e6, 0x814bc5a9, 0x8f62f7a1, 0xa430ea17,
+ 0x388deafb, 0x883b5185, 0x776fe13c, 0x801c683f, 0x87c11b98, 0xb7cbc644, 0x8e9ad3e8, 0x3cf5a10c,
+ 0x7ff6a634, 0x949ef096, 0x9f84aa7c, 0x010af13f, 0x782d1de8, 0xf18e492a, 0x6cf63b01, 0x4301cd81,
+ 0x32d15c9e, 0x68ad8cef, 0xd09bd2d6, 0x908c5c15, 0xd1e36260, 0x2c5bfdd0, 0x88765a99, 0x93deba1e,
+ 0xac6ae342, 0xe865b84c, 0x0f4f2847, 0x7fdf0499, 0x78b1c9b3, 0x6a73261e, 0x601a96f6, 0xd2847933,
+ 0x489aa888, 0xe12e8093, 0x3bfa5a5f, 0xd96ba5f7, 0x7c8f4c8d, 0x80940c6f, 0xcef9dd1a, 0x7e1a055f,
+ 0x3483558b, 0x02b59cc4, 0x0c56333e, 0x05a5b813, 0x92d66287, 0x7516b679, 0x71bfe03f, 0x8056bf68,
+ 0xc24d0724, 0x8416bcf3, 0x234afbdb, 0x4b0d6f9c, 0xaba97333, 0x4b4f42b6, 0x7e8343ab, 0x7ffe2603,
+ 0xe590f73c, 0x45e10c76, 0xb07a6a78, 0xb35609d3, 0x1a027dfd, 0x90cb6e20, 0x82d3fe38, 0x7b409257,
+ 0x0e395afa, 0x1b802093, 0xcb0c6c59, 0x241e17e7, 0x1ee3ea0a, 0x41a82302, 0xab04350a, 0xf570beb7,
+ 0xbb444b9b, 0x83021459, 0x838d65dc, 0x1c439c84, 0x6fdcc454, 0xef9ef325, 0x18626c1c, 0x020d251f,
+ 0xc4aae786, 0x8614cb48, 0xf6f53ca6, 0x8710dbab, 0x89abec0d, 0xf29d41c1, 0x94b50336, 0xfdd49178,
+ 0x604658d1, 0x800e85be, 0xca1bb079, 0x7fa48eeb, 0xa3b7fafe, 0xd330436b, 0x64eb604c, 0x43a658ae,
+ 0x7caa1337, 0xddd445e6, 0x7efbf955, 0xb706ec71, 0x624a6b53, 0x9e0e231f, 0x97097248, 0xa1e1a17a,
+ 0x68dd2e44, 0x7f9d2e14, 0xddcc7074, 0x58324197, 0xc88fc426, 0x6d3640ae, 0x7ef83600, 0x759a0270,
+ 0x98b6d854, 0xd63c9b84, 0x372474a2, 0xe3f18cfd, 0x56ab0bdb, 0x85c9be7e, 0x47dfcfeb, 0xa5830d41,
+ 0x0ddd6283, 0xf4f480ad, 0x74c60e38, 0xab8943c3, 0xc1508fe7, 0x480cdc39, 0x8e097362, 0xa44793be,
+ 0x538b7e18, 0x545f5b41, 0x56529175, 0x9771a97e, 0xc2da7421, 0xea8265f2, 0x805d1163, 0x883c5d28,
+ 0x8ba94c48, 0x4f676e65, 0xf78735b3, 0xe1853671, 0x7f454f53, 0x18147f85, 0x7d09e15d, 0xdb4f3494,
+ 0x795c8973, 0x83310632, 0x85d8061c, 0x9a1a0ebf, 0xc125583c, 0x2a1b1a95, 0x7fd9103f, 0x71e98c72,
+ 0x40932ed7, 0x91ed227a, 0x3c5e560e, 0xe816dee9, 0xb0891b80, 0x600038ba, 0xc7d9a80d, 0x7fff5e09,
+ 0x7e3f4351, 0xbb6b4424, 0xb14448d4, 0x8d6bb7e1, 0xfb153626, 0xa68ad537, 0xd9782006, 0xf62f6991,
+ 0x359ba8c1, 0x02ccff0b, 0x91bf2256, 0x7ea71c4d, 0x560ce5df, 0xeeba289b, 0xa574c4e7, 0x9e04f6ee,
+ 0x7860a5ec, 0x0b8db4a2, 0x968ba3d7, 0x0b6c77df, 0xd6f3157d, 0x402eff1a, 0x49b820b3, 0x8152aebb,
+ 0xd180b0b6, 0x098604d4, 0x7ff92224, 0xede9c996, 0x89c58061, 0x829624c4, 0xc6e71ea7, 0xba94d915,
+ 0x389c3cf6, 0x5b4c5a06, 0x04b335e6, 0x516a8aab, 0x42c8d7d9, 0x92b12af6, 0x86c8549f, 0xfda98acf,
+ 0x819673b6, 0x69545dac, 0x6feaa230, 0x726e6d3f, 0x886ebdfe, 0x34f5730a, 0x7af63ba2, 0x77307bbf,
+ 0x7cd80630, 0x6e45efe0, 0x7f8ad7eb, 0x59d7df99, 0x86c70946, 0xda233629, 0x753f6cbf, 0x825eeb40,
+};
diff --git a/audio_codec/wfd_aac_decoder/statname.h b/audio_codec/wfd_aac_decoder/statname.h
new file mode 100644
index 0000000..127281c
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/statname.h
@@ -0,0 +1,115 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: statname.h,v 1.1 2005/02/26 01:47:34 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * statname.h - name mangling macros for static linking
+ **************************************************************************************/
+
+#ifndef _STATNAME_H
+#define _STATNAME_H
+
+/* define STAT_PREFIX to a unique name for static linking
+ * all the C functions and global variables will be mangled by the preprocessor
+ * e.g. void DCT4(...) becomes void raac_DCT4(...)
+ */
+#define STAT_PREFIX raac
+
+#define STATCC1(x,y,z) STATCC2(x,y,z)
+#define STATCC2(x,y,z) x##y##z
+
+#ifdef STAT_PREFIX
+#define STATNAME(func) STATCC1(STAT_PREFIX, _, func)
+#else
+#define STATNAME(func) func
+#endif
+
+/* these symbols are common to all implementations */
+#define AllocateBuffers STATNAME(AllocateBuffers)
+#define FreeBuffers STATNAME(FreeBuffers)
+#define ClearBuffer STATNAME(ClearBuffer)
+
+#define SetRawBlockParams STATNAME(SetRawBlockParams)
+#define PrepareRawBlock STATNAME(PrepareRawBlock)
+#define FlushCodec STATNAME(FlushCodec)
+
+#define UnpackADTSHeader STATNAME(UnpackADTSHeader)
+#define GetADTSChannelMapping STATNAME(GetADTSChannelMapping)
+#define UnpackADIFHeader STATNAME(UnpackADIFHeader)
+#define DecodeNextElement STATNAME(DecodeNextElement)
+#define DecodeNoiselessData STATNAME(DecodeNoiselessData)
+#define Dequantize STATNAME(Dequantize)
+#define StereoProcess STATNAME(StereoProcess)
+#define DeinterleaveShortBlocks STATNAME(DeinterleaveShortBlocks)
+#define PNS STATNAME(PNS)
+#define TNSFilter STATNAME(TNSFilter)
+#define IMDCT STATNAME(IMDCT)
+
+#define InitSBR STATNAME(InitSBR)
+#define DecodeSBRBitstream STATNAME(DecodeSBRBitstream)
+#define DecodeSBRData STATNAME(DecodeSBRData)
+#define FreeSBR STATNAME(FreeSBR)
+#define FlushCodecSBR STATNAME(FlushCodecSBR)
+
+/* global ROM tables */
+#define sampRateTab STATNAME(sampRateTab)
+#define predSFBMax STATNAME(predSFBMax)
+#define channelMapTab STATNAME(channelMapTab)
+#define elementNumChans STATNAME(elementNumChans)
+#define sfBandTotalShort STATNAME(sfBandTotalShort)
+#define sfBandTotalLong STATNAME(sfBandTotalLong)
+#define sfBandTabShortOffset STATNAME(sfBandTabShortOffset)
+#define sfBandTabShort STATNAME(sfBandTabShort)
+#define sfBandTabLongOffset STATNAME(sfBandTabLongOffset)
+#define sfBandTabLong STATNAME(sfBandTabLong)
+#define tnsMaxBandsShortOffset STATNAME(tnsMaxBandsShortOffset)
+#define tnsMaxBandsShort STATNAME(tnsMaxBandsShort)
+#define tnsMaxOrderShort STATNAME(tnsMaxOrderShort)
+#define tnsMaxBandsLongOffset STATNAME(tnsMaxBandsLongOffset)
+#define tnsMaxBandsLong STATNAME(tnsMaxBandsLong)
+#define tnsMaxOrderLong STATNAME(tnsMaxOrderLong)
+
+/* in your implementation's top-level include file (e.g. real\coder.h) you should
+ * add new #define sym STATNAME(sym) lines for all the
+ * additional global functions or variables which your
+ * implementation uses
+ */
+
+#endif /* _STATNAME_H */
diff --git a/audio_codec/wfd_aac_decoder/stproc.c b/audio_codec/wfd_aac_decoder/stproc.c
new file mode 100644
index 0000000..852fefa
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/stproc.c
@@ -0,0 +1,251 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: stproc.c,v 1.3 2005/05/24 16:01:55 albertofloyd Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * stproc.c - mid-side and intensity stereo processing
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+/* pow14[0][i] = -pow(2, i/4.0)
+ * pow14[1][i] = +pow(2, i/4.0)
+ *
+ * i = [0,1,2,3]
+ * format = Q30
+ */
+static const int pow14[2][4] = {
+ { 0xc0000000, 0xb3e407d7, 0xa57d8666, 0x945d819b },
+ { 0x40000000, 0x4c1bf829, 0x5a82799a, 0x6ba27e65 }
+};
+
+/**************************************************************************************
+ * Function: StereoProcessGroup
+ *
+ * Description: apply mid-side and intensity stereo to group of transform coefficients
+ *
+ * Inputs: dequantized transform coefficients for both channels
+ * pointer to appropriate scalefactor band table
+ * mid-side mask enabled flag
+ * buffer with mid-side mask (one bit for each scalefactor band)
+ * bit offset into mid-side mask buffer
+ * max coded scalefactor band
+ * buffer of codebook indices for right channel
+ * buffer of scalefactors for right channel, range = [0, 256]
+ *
+ * Outputs: updated transform coefficients in Q(FBITS_OUT_DQ_OFF)
+ * updated minimum guard bit count for both channels
+ *
+ * Return: none
+ *
+ * Notes: assume no guard bits in input
+ * gains 0 int bits
+ **************************************************************************************/
+static void StereoProcessGroup(int *coefL, int *coefR, const short *sfbTab,
+ int msMaskPres, unsigned char *msMaskPtr, int msMaskOffset, int maxSFB,
+ unsigned char *cbRight, short *sfRight, int *gbCurrent)
+{
+ int sfb, width, cbIdx, sf, cl, cr, scalef, scalei;
+ int gbMaskL, gbMaskR;
+ unsigned char msMask;
+
+ msMask = (*msMaskPtr++) >> msMaskOffset;
+ gbMaskL = 0;
+ gbMaskR = 0;
+
+ for (sfb = 0; sfb < maxSFB; sfb++) {
+ width = sfbTab[sfb + 1] - sfbTab[sfb]; /* assume >= 0 (see sfBandTabLong/sfBandTabShort) */
+ cbIdx = cbRight[sfb];
+
+ if (cbIdx == 14 || cbIdx == 15) {
+ /* intensity stereo */
+ if (msMaskPres == 1 && (msMask & 0x01)) {
+ cbIdx ^= 0x01; /* invert_intensity(): 14 becomes 15, or 15 becomes 14 */
+ }
+ sf = -sfRight[sfb]; /* negative since we use identity 0.5^(x) = 2^(-x) (see spec) */
+ cbIdx &= 0x01; /* choose - or + scale factor */
+ scalef = pow14[cbIdx][sf & 0x03];
+ scalei = (sf >> 2) + 2; /* +2 to compensate for scalef = Q30 */
+
+ if (scalei > 0) {
+ if (scalei > 30) {
+ scalei = 30;
+ }
+ do {
+ cr = MULSHIFT32(*coefL++, scalef);
+ CLIP_2N(cr, 31 - scalei);
+ cr <<= scalei;
+ gbMaskR |= FASTABS(cr);
+ *coefR++ = cr;
+ } while (--width > 0);
+ } else {
+ scalei = -scalei;
+ if (scalei > 31) {
+ scalei = 31;
+ }
+ do {
+ cr = MULSHIFT32(*coefL++, scalef) >> scalei;
+ gbMaskR |= FASTABS(cr);
+ *coefR++ = cr;
+ } while (--width > 0);
+ }
+ } else if (cbIdx != 13 && ((msMaskPres == 1 && (msMask & 0x01)) || msMaskPres == 2)) {
+ /* mid-side stereo (assumes no GB in inputs) */
+ do {
+ cl = *coefL;
+ cr = *coefR;
+
+ if ((FASTABS(cl) | FASTABS(cr)) >> 30) {
+ /* avoid overflow (rare) */
+ cl >>= 1;
+ sf = cl + (cr >> 1);
+ CLIP_2N(sf, 30);
+ sf <<= 1;
+ cl = cl - (cr >> 1);
+ CLIP_2N(cl, 30);
+ cl <<= 1;
+ } else {
+ /* usual case */
+ sf = cl + cr;
+ cl -= cr;
+ }
+
+ *coefL++ = sf;
+ gbMaskL |= FASTABS(sf);
+ *coefR++ = cl;
+ gbMaskR |= FASTABS(cl);
+ } while (--width > 0);
+
+ } else {
+ /* nothing to do */
+ coefL += width;
+ coefR += width;
+ }
+
+ /* get next mask bit (should be branchless on ARM) */
+ msMask >>= 1;
+ if (++msMaskOffset == 8) {
+ msMask = *msMaskPtr++;
+ msMaskOffset = 0;
+ }
+ }
+
+ cl = CLZ(gbMaskL) - 1;
+ if (gbCurrent[0] > cl) {
+ gbCurrent[0] = cl;
+ }
+
+ cr = CLZ(gbMaskR) - 1;
+ if (gbCurrent[1] > cr) {
+ gbCurrent[1] = cr;
+ }
+
+ return;
+}
+
+/**************************************************************************************
+ * Function: StereoProcess
+ *
+ * Description: apply mid-side and intensity stereo, if enabled
+ *
+ * Inputs: valid AACDecInfo struct (including dequantized transform coefficients)
+ *
+ * Outputs: updated transform coefficients in Q(FBITS_OUT_DQ_OFF)
+ * updated minimum guard bit count for both channels
+ *
+ * Return: 0 if successful, -1 if error
+ **************************************************************************************/
+int StereoProcess(AACDecInfo *aacDecInfo)
+{
+ PSInfoBase *psi;
+ ICSInfo *icsInfo;
+ int gp, win, nSamps, msMaskOffset;
+ int *coefL, *coefR;
+ unsigned char *msMaskPtr;
+ const short *sfbTab;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return ERR_AAC_NULL_POINTER;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+
+ /* mid-side and intensity stereo require common_window == 1 (see MPEG4 spec, Correction 2, 2004) */
+ if (psi->commonWin != 1 || aacDecInfo->currBlockID != AAC_ID_CPE) {
+ return ERR_AAC_NONE;
+ }
+
+ /* nothing to do */
+ if (!psi->msMaskPresent && !psi->intensityUsed[1]) {
+ return ERR_AAC_NONE;
+ }
+
+ icsInfo = &(psi->icsInfo[0]);
+ if (icsInfo->winSequence == 2) {
+ sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_SHORT;
+ } else {
+ sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx];
+ nSamps = NSAMPS_LONG;
+ }
+ coefL = psi->coef[0];
+ coefR = psi->coef[1];
+
+ /* do fused mid-side/intensity processing for each block (one long or eight short) */
+ msMaskOffset = 0;
+ msMaskPtr = psi->msMaskBits;
+ for (gp = 0; gp < icsInfo->numWinGroup; gp++) {
+ for (win = 0; win < icsInfo->winGroupLen[gp]; win++) {
+ StereoProcessGroup(coefL, coefR, sfbTab, psi->msMaskPresent,
+ msMaskPtr, msMaskOffset, icsInfo->maxSFB, psi->sfbCodeBook[1] + gp * icsInfo->maxSFB,
+ psi->scaleFactors[1] + gp * icsInfo->maxSFB, psi->gbCurrent);
+ coefL += nSamps;
+ coefR += nSamps;
+ }
+ /* we use one bit per sfb, so there are maxSFB bits for each window group */
+ msMaskPtr += (msMaskOffset + icsInfo->maxSFB) >> 3;
+ msMaskOffset = (msMaskOffset + icsInfo->maxSFB) & 0x07;
+ }
+
+ ASSERT(coefL == psi->coef[0] + 1024, ERR_AAC_COFF_EXCEED_RANGE);
+ ASSERT(coefR == psi->coef[1] + 1024, ERR_AAC_COFF_EXCEED_RANGE);
+ return ERR_AAC_NONE;
+}
diff --git a/audio_codec/wfd_aac_decoder/tns.c b/audio_codec/wfd_aac_decoder/tns.c
new file mode 100644
index 0000000..7607502
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/tns.c
@@ -0,0 +1,307 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: tns.c,v 1.1.2.2 2005/05/24 20:34:40 albertofloyd Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com)
+ * February 2005
+ *
+ * tns.c - apply TNS to spectrum
+ **************************************************************************************/
+
+#include "coder.h"
+#include "assembly.h"
+
+#define FBITS_LPC_COEFS 20
+
+/* inverse quantization tables for TNS filter coefficients, format = Q31
+ * see bottom of file for table generation
+ * negative (vs. spec) since we use MADD for filter kernel
+ */
+static const int invQuant3[16] = {
+ 0x00000000, 0xc8767f65, 0x9becf22c, 0x83358feb, 0x83358feb, 0x9becf22c, 0xc8767f65, 0x00000000,
+ 0x2bc750e9, 0x5246dd49, 0x6ed9eba1, 0x7e0e2e32, 0x7e0e2e32, 0x6ed9eba1, 0x5246dd49, 0x2bc750e9,
+};
+
+static const int invQuant4[16] = {
+ 0x00000000, 0xe5632654, 0xcbf00dbe, 0xb4c373ee, 0xa0e0a15f, 0x9126145f, 0x8643c7b3, 0x80b381ac,
+ 0x7f7437ad, 0x7b1d1a49, 0x7294b5f2, 0x66256db2, 0x563ba8aa, 0x4362210e, 0x2e3d2abb, 0x17851aad,
+};
+
+/**************************************************************************************
+ * Function: DecodeLPCCoefs
+ *
+ * Description: decode LPC coefficients for TNS
+ *
+ * Inputs: order of TNS filter
+ * resolution of coefficients (3 or 4 bits)
+ * coefficients unpacked from bitstream
+ * scratch buffer (b) of size >= order
+ *
+ * Outputs: LPC coefficients in Q(FBITS_LPC_COEFS), in 'a'
+ *
+ * Return: none
+ *
+ * Notes: assumes no guard bits in input transform coefficients
+ * a[i] = Q(FBITS_LPC_COEFS), don't store a0 = 1.0
+ * (so a[0] = first delay tap, etc.)
+ * max abs(a[i]) < log2(order), so for max order = 20 a[i] < 4.4
+ * (up to 3 bits of gain) so a[i] has at least 31 - FBITS_LPC_COEFS - 3
+ * guard bits
+ * to ensure no intermediate overflow in all-pole filter, set
+ * FBITS_LPC_COEFS such that number of guard bits >= log2(max order)
+ **************************************************************************************/
+static void DecodeLPCCoefs(int order, int res, signed char *filtCoef, int *a, int *b)
+{
+ int i, m, t;
+ const int *invQuantTab;
+
+ if (res == 3) {
+ invQuantTab = invQuant3;
+ } else if (res == 4) {
+ invQuantTab = invQuant4;
+ } else {
+ return;
+ }
+
+ for (m = 0; m < order; m++) {
+ t = invQuantTab[filtCoef[m] & 0x0f]; /* t = Q31 */
+ for (i = 0; i < m; i++) {
+ b[i] = a[i] - (MULSHIFT32(t, a[m - i - 1]) << 1);
+ }
+ for (i = 0; i < m; i++) {
+ a[i] = b[i];
+ }
+ a[m] = t >> (31 - FBITS_LPC_COEFS);
+ }
+}
+
+/**************************************************************************************
+ * Function: FilterRegion
+ *
+ * Description: apply LPC filter to one region of coefficients
+ *
+ * Inputs: number of transform coefficients in this region
+ * direction flag (forward = 1, backward = -1)
+ * order of filter
+ * 'size' transform coefficients
+ * 'order' LPC coefficients in Q(FBITS_LPC_COEFS)
+ * scratch buffer for history (must be >= order samples long)
+ *
+ * Outputs: filtered transform coefficients
+ *
+ * Return: guard bit mask (OR of abs value of all filtered transform coefs)
+ *
+ * Notes: assumes no guard bits in input transform coefficients
+ * gains 0 int bits
+ * history buffer does not need to be preserved between regions
+ **************************************************************************************/
+static int FilterRegion(int size, int dir, int order, int *audioCoef, int *a, int *hist)
+{
+ int i, j, y, hi32, inc, gbMask;
+ U64 sum64;
+
+ /* init history to 0 every time */
+ for (i = 0; i < order; i++) {
+ hist[i] = 0;
+ }
+
+ sum64.w64 = 0; /* avoid warning */
+ gbMask = 0;
+ inc = (dir ? -1 : 1);
+ do {
+ /* sum64 = a0*y[n] = 1.0*y[n] */
+ y = *audioCoef;
+ sum64.r.hi32 = y >> (32 - FBITS_LPC_COEFS);
+ sum64.r.lo32 = y << FBITS_LPC_COEFS;
+
+ /* sum64 += (a1*y[n-1] + a2*y[n-2] + ... + a[order-1]*y[n-(order-1)]) */
+ for (j = order - 1; j > 0; j--) {
+ sum64.w64 = MADD64(sum64.w64, hist[j], a[j]);
+ hist[j] = hist[j - 1];
+ }
+ sum64.w64 = MADD64(sum64.w64, hist[0], a[0]);
+ y = (sum64.r.hi32 << (32 - FBITS_LPC_COEFS)) | (sum64.r.lo32 >> FBITS_LPC_COEFS);
+
+ /* clip output (rare) */
+ hi32 = sum64.r.hi32;
+ if ((hi32 >> 31) != (hi32 >> (FBITS_LPC_COEFS - 1))) {
+ y = (hi32 >> 31) ^ 0x7fffffff;
+ }
+
+ hist[0] = y;
+ *audioCoef = y;
+ audioCoef += inc;
+ gbMask |= FASTABS(y);
+ } while (--size);
+
+ return gbMask;
+}
+
+/**************************************************************************************
+ * Function: TNSFilter
+ *
+ * Description: apply temporal noise shaping, if enabled
+ *
+ * Inputs: valid AACDecInfo struct
+ * index of current channel
+ *
+ * Outputs: updated transform coefficients
+ * updated minimum guard bit count for this channel
+ *
+ * Return: 0 if successful, -1 if error
+ **************************************************************************************/
+int TNSFilter(AACDecInfo *aacDecInfo, int ch)
+{
+ int win, winLen, nWindows, nSFB, filt, bottom, top, order, maxOrder, dir;
+ int start, end, size, tnsMaxBand, numFilt, gbMask;
+ int *audioCoef;
+ unsigned char *filtLength, *filtOrder, *filtRes, *filtDir;
+ signed char *filtCoef;
+ const unsigned char *tnsMaxBandTab;
+ const short *sfbTab;
+ ICSInfo *icsInfo;
+ TNSInfo *ti;
+ PSInfoBase *psi;
+
+ /* validate pointers */
+ if (!aacDecInfo || !aacDecInfo->psInfoBase) {
+ return -1;
+ }
+ psi = (PSInfoBase *)(aacDecInfo->psInfoBase);
+ icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]);
+ ti = &psi->tnsInfo[ch];
+
+ if (!ti->tnsDataPresent) {
+ return 0;
+ }
+
+ if (icsInfo->winSequence == 2) {
+ nWindows = NWINDOWS_SHORT;
+ winLen = NSAMPS_SHORT;
+ nSFB = sfBandTotalShort[psi->sampRateIdx];
+ maxOrder = tnsMaxOrderShort[aacDecInfo->profile];
+ sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx];
+ tnsMaxBandTab = tnsMaxBandsShort + tnsMaxBandsShortOffset[aacDecInfo->profile];
+ tnsMaxBand = tnsMaxBandTab[psi->sampRateIdx];
+ } else {
+ nWindows = NWINDOWS_LONG;
+ winLen = NSAMPS_LONG;
+ nSFB = sfBandTotalLong[psi->sampRateIdx];
+ maxOrder = tnsMaxOrderLong[aacDecInfo->profile];
+ sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx];
+ tnsMaxBandTab = tnsMaxBandsLong + tnsMaxBandsLongOffset[aacDecInfo->profile];
+ tnsMaxBand = tnsMaxBandTab[psi->sampRateIdx];
+ }
+
+ if (tnsMaxBand > icsInfo->maxSFB) {
+ tnsMaxBand = icsInfo->maxSFB;
+ }
+
+ filtRes = ti->coefRes;
+ filtLength = ti->length;
+ filtOrder = ti->order;
+ filtDir = ti->dir;
+ filtCoef = ti->coef;
+
+ gbMask = 0;
+ audioCoef = psi->coef[ch];
+ for (win = 0; win < nWindows; win++) {
+ bottom = nSFB;
+ numFilt = ti->numFilt[win];
+ for (filt = 0; filt < numFilt; filt++) {
+ top = bottom;
+ bottom = top - *filtLength++;
+ bottom = MAX(bottom, 0);
+ order = *filtOrder++;
+ order = MIN(order, maxOrder);
+
+ if (order) {
+ start = sfbTab[MIN(bottom, tnsMaxBand)];
+ end = sfbTab[MIN(top, tnsMaxBand)];
+ size = end - start;
+ if (size > 0) {
+ dir = *filtDir++;
+ if (dir) {
+ start = end - 1;
+ }
+
+ DecodeLPCCoefs(order, filtRes[win], filtCoef, psi->tnsLPCBuf, psi->tnsWorkBuf);
+ gbMask |= FilterRegion(size, dir, order, audioCoef + start, psi->tnsLPCBuf, psi->tnsWorkBuf);
+ }
+ filtCoef += order;
+ }
+ }
+ audioCoef += winLen;
+ }
+
+ /* update guard bit count if necessary */
+ size = CLZ(gbMask) - 1;
+ if (psi->gbCurrent[ch] > size) {
+ psi->gbCurrent[ch] = size;
+ }
+
+ return 0;
+}
+
+/* Code to generate invQuantXXX[] tables
+ * {
+ * int res, i, t;
+ * double powScale, iqfac, iqfac_m, d;
+ *
+ * powScale = pow(2.0, 31) * -1.0; / ** make coefficients negative for using MADD in kernel ** /
+ * for (res = 3; res <= 4; res++) {
+ * iqfac = ( ((1 << (res-1)) - 0.5) * (2.0 / M_PI) );
+ * iqfac_m = ( ((1 << (res-1)) + 0.5) * (2.0 / M_PI) );
+ * printf("static const int invQuant%d[16] = {\n", res);
+ * for (i = 0; i < 16; i++) {
+ * / ** extend bottom 4 bits into signed, 2's complement number ** /
+ * t = (i << 28) >> 28;
+ *
+ * if (t >= 0) d = sin(t / iqfac);
+ * else d = sin(t / iqfac_m);
+ *
+ * d *= powScale;
+ * printf("0x%08x, ", (int)(d > 0 ? d + 0.5 : d - 0.5));
+ * if ((i & 0x07) == 0x07)
+ * printf("\n");
+ * }
+ * printf("};\n\n");
+ * }
+ * }
+ */
+
diff --git a/audio_codec/wfd_aac_decoder/trigtabs.c b/audio_codec/wfd_aac_decoder/trigtabs.c
new file mode 100644
index 0000000..0a77b6f
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/trigtabs.c
@@ -0,0 +1,1000 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: trigtabs.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * February 2005
+ *
+ * trigtabs.c - tables of sin, cos, etc. for IMDCT
+ **************************************************************************************/
+
+#include "coder.h"
+
+const int cos4sin4tabOffset[NUM_IMDCT_SIZES] = {0, 128};
+
+/* PreMultiply() tables
+ * format = Q30 * 2^[-7, -10] for nmdct = [128, 1024]
+ * reordered for sequential access
+ *
+ * invM = -1.0 / nmdct;
+ * for (i = 0; i < nmdct/4; i++) {
+ * angle = (i + 0.25) * M_PI / nmdct;
+ * x = invM * (cos(angle) + sin(angle));
+ * x = invM * sin(angle);
+ *
+ * angle = (nmdct/2 - 1 - i + 0.25) * M_PI / nmdct;
+ * x = invM * (cos(angle) + sin(angle));
+ * x = invM * sin(angle);
+ * }
+ */
+const int cos4sin4tab[128 + 1024] = {
+ /* 128 - format = Q30 * 2^-7 */
+ 0xbf9bc731, 0xff9b783c, 0xbed5332c, 0xc002c697, 0xbe112251, 0xfe096c8d, 0xbd4f9c30, 0xc00f1c4a,
+ 0xbc90a83f, 0xfc77ae5e, 0xbbd44dd9, 0xc0254e27, 0xbb1a9443, 0xfae67ba2, 0xba6382a6, 0xc04558c0,
+ 0xb9af200f, 0xf9561237, 0xb8fd7373, 0xc06f3726, 0xb84e83ac, 0xf7c6afdc, 0xb7a25779, 0xc0a2e2e3,
+ 0xb6f8f57c, 0xf6389228, 0xb652643e, 0xc0e05401, 0xb5aeaa2a, 0xf4abf67e, 0xb50dcd90, 0xc1278104,
+ 0xb46fd4a4, 0xf3211a07, 0xb3d4c57c, 0xc1785ef4, 0xb33ca614, 0xf19839a6, 0xb2a77c49, 0xc1d2e158,
+ 0xb2154dda, 0xf01191f3, 0xb186206b, 0xc236fa3b, 0xb0f9f981, 0xee8d5f29, 0xb070de82, 0xc2a49a2e,
+ 0xafead4b9, 0xed0bdd25, 0xaf67e14f, 0xc31bb049, 0xaee80952, 0xeb8d475b, 0xae6b51ae, 0xc39c2a2f,
+ 0xadf1bf34, 0xea11d8c8, 0xad7b5692, 0xc425f410, 0xad081c5a, 0xe899cbf1, 0xac9814fd, 0xc4b8f8ad,
+ 0xac2b44cc, 0xe7255ad1, 0xabc1aff9, 0xc555215a, 0xab5b5a96, 0xe5b4bed8, 0xaaf84896, 0xc5fa5603,
+ 0xaa987dca, 0xe44830dd, 0xaa3bfde3, 0xc6a87d2d, 0xa9e2cc73, 0xe2dfe917, 0xa98cece9, 0xc75f7bfe,
+ 0xa93a6296, 0xe17c1f15, 0xa8eb30a7, 0xc81f363d, 0xa89f5a2b, 0xe01d09b4, 0xa856e20e, 0xc8e78e5b,
+ 0xa811cb1b, 0xdec2df18, 0xa7d017fc, 0xc9b86572, 0xa791cb39, 0xdd6dd4a2, 0xa756e73a, 0xca919b4e,
+ 0xa71f6e43, 0xdc1e1ee9, 0xa6eb6279, 0xcb730e70, 0xa6bac5dc, 0xdad3f1b1, 0xa68d9a4c, 0xcc5c9c14,
+ 0xa663e188, 0xd98f7fe6, 0xa63d9d2b, 0xcd4e2037, 0xa61aceaf, 0xd850fb8e, 0xa5fb776b, 0xce47759a,
+ 0xa5df9894, 0xd71895c9, 0xa5c7333e, 0xcf4875ca, 0xa5b2485a, 0xd5e67ec1, 0xa5a0d8b5, 0xd050f926,
+ 0xa592e4fd, 0xd4bae5ab, 0xa5886dba, 0xd160d6e5, 0xa5817354, 0xd395f8ba, 0xa57df60f, 0xd277e518,
+ /* 1024 - format = Q30 * 2^-10 */
+ 0xbff3703e, 0xfff36f02, 0xbfda5824, 0xc0000b1a, 0xbfc149ed, 0xffc12b16, 0xbfa845a0, 0xc0003c74,
+ 0xbf8f4b3e, 0xff8ee750, 0xbf765acc, 0xc0009547, 0xbf5d744e, 0xff5ca3d0, 0xbf4497c8, 0xc0011594,
+ 0xbf2bc53d, 0xff2a60b4, 0xbf12fcb2, 0xc001bd5c, 0xbefa3e2a, 0xfef81e1d, 0xbee189a8, 0xc0028c9c,
+ 0xbec8df32, 0xfec5dc28, 0xbeb03eca, 0xc0038356, 0xbe97a875, 0xfe939af5, 0xbe7f1c36, 0xc004a188,
+ 0xbe669a10, 0xfe615aa3, 0xbe4e2209, 0xc005e731, 0xbe35b423, 0xfe2f1b50, 0xbe1d5062, 0xc0075452,
+ 0xbe04f6cb, 0xfdfcdd1d, 0xbdeca760, 0xc008e8e8, 0xbdd46225, 0xfdcaa027, 0xbdbc2720, 0xc00aa4f3,
+ 0xbda3f652, 0xfd98648d, 0xbd8bcfbf, 0xc00c8872, 0xbd73b36d, 0xfd662a70, 0xbd5ba15d, 0xc00e9364,
+ 0xbd439995, 0xfd33f1ed, 0xbd2b9c17, 0xc010c5c7, 0xbd13a8e7, 0xfd01bb24, 0xbcfbc00a, 0xc0131f9b,
+ 0xbce3e182, 0xfccf8634, 0xbccc0d53, 0xc015a0dd, 0xbcb44382, 0xfc9d533b, 0xbc9c8411, 0xc018498c,
+ 0xbc84cf05, 0xfc6b2259, 0xbc6d2461, 0xc01b19a7, 0xbc558428, 0xfc38f3ac, 0xbc3dee5f, 0xc01e112b,
+ 0xbc266309, 0xfc06c754, 0xbc0ee22a, 0xc0213018, 0xbbf76bc4, 0xfbd49d70, 0xbbdfffdd, 0xc024766a,
+ 0xbbc89e77, 0xfba2761e, 0xbbb14796, 0xc027e421, 0xbb99fb3e, 0xfb70517d, 0xbb82b972, 0xc02b7939,
+ 0xbb6b8235, 0xfb3e2fac, 0xbb54558d, 0xc02f35b1, 0xbb3d337b, 0xfb0c10cb, 0xbb261c04, 0xc0331986,
+ 0xbb0f0f2b, 0xfad9f4f8, 0xbaf80cf4, 0xc03724b6, 0xbae11561, 0xfaa7dc52, 0xbaca2878, 0xc03b573f,
+ 0xbab3463b, 0xfa75c6f8, 0xba9c6eae, 0xc03fb11d, 0xba85a1d4, 0xfa43b508, 0xba6edfb1, 0xc044324f,
+ 0xba582849, 0xfa11a6a3, 0xba417b9e, 0xc048dad1, 0xba2ad9b5, 0xf9df9be6, 0xba144291, 0xc04daaa1,
+ 0xb9fdb635, 0xf9ad94f0, 0xb9e734a4, 0xc052a1bb, 0xb9d0bde4, 0xf97b91e1, 0xb9ba51f6, 0xc057c01d,
+ 0xb9a3f0de, 0xf94992d7, 0xb98d9aa0, 0xc05d05c3, 0xb9774f3f, 0xf91797f0, 0xb9610ebe, 0xc06272aa,
+ 0xb94ad922, 0xf8e5a14d, 0xb934ae6d, 0xc06806ce, 0xb91e8ea3, 0xf8b3af0c, 0xb90879c7, 0xc06dc22e,
+ 0xb8f26fdc, 0xf881c14b, 0xb8dc70e7, 0xc073a4c3, 0xb8c67cea, 0xf84fd829, 0xb8b093ea, 0xc079ae8c,
+ 0xb89ab5e8, 0xf81df3c5, 0xb884e2e9, 0xc07fdf85, 0xb86f1af0, 0xf7ec143e, 0xb8595e00, 0xc08637a9,
+ 0xb843ac1d, 0xf7ba39b3, 0xb82e0549, 0xc08cb6f5, 0xb818698a, 0xf7886442, 0xb802d8e0, 0xc0935d64,
+ 0xb7ed5351, 0xf756940a, 0xb7d7d8df, 0xc09a2af3, 0xb7c2698e, 0xf724c92a, 0xb7ad0561, 0xc0a11f9d,
+ 0xb797ac5b, 0xf6f303c0, 0xb7825e80, 0xc0a83b5e, 0xb76d1bd2, 0xf6c143ec, 0xb757e455, 0xc0af7e33,
+ 0xb742b80d, 0xf68f89cb, 0xb72d96fd, 0xc0b6e815, 0xb7188127, 0xf65dd57d, 0xb7037690, 0xc0be7901,
+ 0xb6ee773a, 0xf62c2721, 0xb6d98328, 0xc0c630f2, 0xb6c49a5e, 0xf5fa7ed4, 0xb6afbce0, 0xc0ce0fe3,
+ 0xb69aeab0, 0xf5c8dcb6, 0xb68623d1, 0xc0d615cf, 0xb6716847, 0xf59740e5, 0xb65cb815, 0xc0de42b2,
+ 0xb648133e, 0xf565ab80, 0xb63379c5, 0xc0e69686, 0xb61eebae, 0xf5341ca5, 0xb60a68fb, 0xc0ef1147,
+ 0xb5f5f1b1, 0xf5029473, 0xb5e185d1, 0xc0f7b2ee, 0xb5cd255f, 0xf4d11308, 0xb5b8d05f, 0xc1007b77,
+ 0xb5a486d2, 0xf49f9884, 0xb59048be, 0xc1096add, 0xb57c1624, 0xf46e2504, 0xb567ef08, 0xc1128119,
+ 0xb553d36c, 0xf43cb8a7, 0xb53fc355, 0xc11bbe26, 0xb52bbec4, 0xf40b538b, 0xb517c5be, 0xc12521ff,
+ 0xb503d845, 0xf3d9f5cf, 0xb4eff65c, 0xc12eac9d, 0xb4dc2007, 0xf3a89f92, 0xb4c85548, 0xc1385dfb,
+ 0xb4b49622, 0xf37750f2, 0xb4a0e299, 0xc1423613, 0xb48d3ab0, 0xf3460a0d, 0xb4799e69, 0xc14c34df,
+ 0xb4660dc8, 0xf314cb02, 0xb45288cf, 0xc1565a58, 0xb43f0f82, 0xf2e393ef, 0xb42ba1e4, 0xc160a678,
+ 0xb4183ff7, 0xf2b264f2, 0xb404e9bf, 0xc16b193a, 0xb3f19f3e, 0xf2813e2a, 0xb3de6078, 0xc175b296,
+ 0xb3cb2d70, 0xf2501fb5, 0xb3b80628, 0xc1807285, 0xb3a4eaa4, 0xf21f09b1, 0xb391dae6, 0xc18b5903,
+ 0xb37ed6f1, 0xf1edfc3d, 0xb36bdec9, 0xc1966606, 0xb358f26f, 0xf1bcf777, 0xb34611e8, 0xc1a1998a,
+ 0xb3333d36, 0xf18bfb7d, 0xb320745c, 0xc1acf386, 0xb30db75d, 0xf15b086d, 0xb2fb063b, 0xc1b873f5,
+ 0xb2e860fa, 0xf12a1e66, 0xb2d5c79d, 0xc1c41ace, 0xb2c33a26, 0xf0f93d86, 0xb2b0b898, 0xc1cfe80a,
+ 0xb29e42f6, 0xf0c865ea, 0xb28bd943, 0xc1dbdba3, 0xb2797b82, 0xf09797b2, 0xb26729b5, 0xc1e7f591,
+ 0xb254e3e0, 0xf066d2fa, 0xb242aa05, 0xc1f435cc, 0xb2307c27, 0xf03617e2, 0xb21e5a49, 0xc2009c4e,
+ 0xb20c446d, 0xf0056687, 0xb1fa3a97, 0xc20d290d, 0xb1e83cc9, 0xefd4bf08, 0xb1d64b06, 0xc219dc03,
+ 0xb1c46551, 0xefa42181, 0xb1b28bad, 0xc226b528, 0xb1a0be1b, 0xef738e12, 0xb18efca0, 0xc233b473,
+ 0xb17d473d, 0xef4304d8, 0xb16b9df6, 0xc240d9de, 0xb15a00cd, 0xef1285f2, 0xb1486fc5, 0xc24e255e,
+ 0xb136eae1, 0xeee2117c, 0xb1257223, 0xc25b96ee, 0xb114058e, 0xeeb1a796, 0xb102a524, 0xc2692e83,
+ 0xb0f150e9, 0xee81485c, 0xb0e008e0, 0xc276ec16, 0xb0cecd09, 0xee50f3ed, 0xb0bd9d6a, 0xc284cf9f,
+ 0xb0ac7a03, 0xee20aa67, 0xb09b62d8, 0xc292d914, 0xb08a57eb, 0xedf06be6, 0xb079593f, 0xc2a1086d,
+ 0xb06866d7, 0xedc0388a, 0xb05780b5, 0xc2af5da2, 0xb046a6db, 0xed901070, 0xb035d94e, 0xc2bdd8a9,
+ 0xb025180e, 0xed5ff3b5, 0xb014631e, 0xc2cc7979, 0xb003ba82, 0xed2fe277, 0xaff31e3b, 0xc2db400a,
+ 0xafe28e4d, 0xecffdcd4, 0xafd20ab9, 0xc2ea2c53, 0xafc19383, 0xeccfe2ea, 0xafb128ad, 0xc2f93e4a,
+ 0xafa0ca39, 0xec9ff4d6, 0xaf90782a, 0xc30875e5, 0xaf803283, 0xec7012b5, 0xaf6ff945, 0xc317d31c,
+ 0xaf5fcc74, 0xec403ca5, 0xaf4fac12, 0xc32755e5, 0xaf3f9822, 0xec1072c4, 0xaf2f90a5, 0xc336fe37,
+ 0xaf1f959f, 0xebe0b52f, 0xaf0fa712, 0xc346cc07, 0xaeffc500, 0xebb10404, 0xaeefef6c, 0xc356bf4d,
+ 0xaee02658, 0xeb815f60, 0xaed069c7, 0xc366d7fd, 0xaec0b9bb, 0xeb51c760, 0xaeb11636, 0xc377160f,
+ 0xaea17f3b, 0xeb223c22, 0xae91f4cd, 0xc3877978, 0xae8276ed, 0xeaf2bdc3, 0xae73059f, 0xc398022f,
+ 0xae63a0e3, 0xeac34c60, 0xae5448be, 0xc3a8b028, 0xae44fd31, 0xea93e817, 0xae35be3f, 0xc3b9835a,
+ 0xae268be9, 0xea649105, 0xae176633, 0xc3ca7bba, 0xae084d1f, 0xea354746, 0xadf940ae, 0xc3db993e,
+ 0xadea40e4, 0xea060af9, 0xaddb4dc2, 0xc3ecdbdc, 0xadcc674b, 0xe9d6dc3b, 0xadbd8d82, 0xc3fe4388,
+ 0xadaec067, 0xe9a7bb28, 0xad9fffff, 0xc40fd037, 0xad914c4b, 0xe978a7dd, 0xad82a54c, 0xc42181e0,
+ 0xad740b07, 0xe949a278, 0xad657d7c, 0xc4335877, 0xad56fcaf, 0xe91aab16, 0xad4888a0, 0xc44553f2,
+ 0xad3a2153, 0xe8ebc1d3, 0xad2bc6ca, 0xc4577444, 0xad1d7907, 0xe8bce6cd, 0xad0f380c, 0xc469b963,
+ 0xad0103db, 0xe88e1a20, 0xacf2dc77, 0xc47c2344, 0xace4c1e2, 0xe85f5be9, 0xacd6b41e, 0xc48eb1db,
+ 0xacc8b32c, 0xe830ac45, 0xacbabf10, 0xc4a1651c, 0xacacd7cb, 0xe8020b52, 0xac9efd60, 0xc4b43cfd,
+ 0xac912fd1, 0xe7d3792b, 0xac836f1f, 0xc4c73972, 0xac75bb4d, 0xe7a4f5ed, 0xac68145d, 0xc4da5a6f,
+ 0xac5a7a52, 0xe77681b6, 0xac4ced2c, 0xc4ed9fe7, 0xac3f6cef, 0xe7481ca1, 0xac31f99d, 0xc50109d0,
+ 0xac249336, 0xe719c6cb, 0xac1739bf, 0xc514981d, 0xac09ed38, 0xe6eb8052, 0xabfcada3, 0xc5284ac3,
+ 0xabef7b04, 0xe6bd4951, 0xabe2555b, 0xc53c21b4, 0xabd53caa, 0xe68f21e5, 0xabc830f5, 0xc5501ce5,
+ 0xabbb323c, 0xe6610a2a, 0xabae4082, 0xc5643c4a, 0xaba15bc9, 0xe633023e, 0xab948413, 0xc5787fd6,
+ 0xab87b962, 0xe6050a3b, 0xab7afbb7, 0xc58ce77c, 0xab6e4b15, 0xe5d72240, 0xab61a77d, 0xc5a17330,
+ 0xab5510f3, 0xe5a94a67, 0xab488776, 0xc5b622e6, 0xab3c0b0b, 0xe57b82cd, 0xab2f9bb1, 0xc5caf690,
+ 0xab23396c, 0xe54dcb8f, 0xab16e43d, 0xc5dfee22, 0xab0a9c27, 0xe52024c9, 0xaafe612a, 0xc5f5098f,
+ 0xaaf23349, 0xe4f28e96, 0xaae61286, 0xc60a48c9, 0xaad9fee3, 0xe4c50914, 0xaacdf861, 0xc61fabc4,
+ 0xaac1ff03, 0xe497945d, 0xaab612ca, 0xc6353273, 0xaaaa33b8, 0xe46a308f, 0xaa9e61cf, 0xc64adcc7,
+ 0xaa929d10, 0xe43cddc4, 0xaa86e57e, 0xc660aab5, 0xaa7b3b1b, 0xe40f9c1a, 0xaa6f9de7, 0xc6769c2e,
+ 0xaa640de6, 0xe3e26bac, 0xaa588b18, 0xc68cb124, 0xaa4d157f, 0xe3b54c95, 0xaa41ad1e, 0xc6a2e98b,
+ 0xaa3651f6, 0xe3883ef2, 0xaa2b0409, 0xc6b94554, 0xaa1fc358, 0xe35b42df, 0xaa148fe6, 0xc6cfc472,
+ 0xaa0969b3, 0xe32e5876, 0xa9fe50c2, 0xc6e666d7, 0xa9f34515, 0xe3017fd5, 0xa9e846ad, 0xc6fd2c75,
+ 0xa9dd558b, 0xe2d4b916, 0xa9d271b2, 0xc714153e, 0xa9c79b23, 0xe2a80456, 0xa9bcd1e0, 0xc72b2123,
+ 0xa9b215ea, 0xe27b61af, 0xa9a76744, 0xc7425016, 0xa99cc5ee, 0xe24ed13d, 0xa99231eb, 0xc759a20a,
+ 0xa987ab3c, 0xe222531c, 0xa97d31e3, 0xc77116f0, 0xa972c5e1, 0xe1f5e768, 0xa9686738, 0xc788aeb9,
+ 0xa95e15e9, 0xe1c98e3b, 0xa953d1f7, 0xc7a06957, 0xa9499b62, 0xe19d47b1, 0xa93f722c, 0xc7b846ba,
+ 0xa9355658, 0xe17113e5, 0xa92b47e5, 0xc7d046d6, 0xa92146d7, 0xe144f2f3, 0xa917532e, 0xc7e8699a,
+ 0xa90d6cec, 0xe118e4f6, 0xa9039413, 0xc800aef7, 0xa8f9c8a4, 0xe0ecea09, 0xa8f00aa0, 0xc81916df,
+ 0xa8e65a0a, 0xe0c10247, 0xa8dcb6e2, 0xc831a143, 0xa8d3212a, 0xe0952dcb, 0xa8c998e3, 0xc84a4e14,
+ 0xa8c01e10, 0xe0696cb0, 0xa8b6b0b1, 0xc8631d42, 0xa8ad50c8, 0xe03dbf11, 0xa8a3fe57, 0xc87c0ebd,
+ 0xa89ab95e, 0xe012250a, 0xa89181df, 0xc8952278, 0xa88857dc, 0xdfe69eb4, 0xa87f3b57, 0xc8ae5862,
+ 0xa8762c4f, 0xdfbb2c2c, 0xa86d2ac8, 0xc8c7b06b, 0xa86436c2, 0xdf8fcd8b, 0xa85b503e, 0xc8e12a84,
+ 0xa852773f, 0xdf6482ed, 0xa849abc4, 0xc8fac69e, 0xa840edd1, 0xdf394c6b, 0xa8383d66, 0xc91484a8,
+ 0xa82f9a84, 0xdf0e2a22, 0xa827052d, 0xc92e6492, 0xa81e7d62, 0xdee31c2b, 0xa8160324, 0xc948664d,
+ 0xa80d9675, 0xdeb822a1, 0xa8053756, 0xc96289c9, 0xa7fce5c9, 0xde8d3d9e, 0xa7f4a1ce, 0xc97ccef5,
+ 0xa7ec6b66, 0xde626d3e, 0xa7e44294, 0xc99735c2, 0xa7dc2759, 0xde37b199, 0xa7d419b4, 0xc9b1be1e,
+ 0xa7cc19a9, 0xde0d0acc, 0xa7c42738, 0xc9cc67fa, 0xa7bc4262, 0xdde278ef, 0xa7b46b29, 0xc9e73346,
+ 0xa7aca18e, 0xddb7fc1e, 0xa7a4e591, 0xca021fef, 0xa79d3735, 0xdd8d9472, 0xa795967a, 0xca1d2de7,
+ 0xa78e0361, 0xdd634206, 0xa7867dec, 0xca385d1d, 0xa77f061c, 0xdd3904f4, 0xa7779bf2, 0xca53ad7e,
+ 0xa7703f70, 0xdd0edd55, 0xa768f095, 0xca6f1efc, 0xa761af64, 0xdce4cb44, 0xa75a7bdd, 0xca8ab184,
+ 0xa7535602, 0xdcbacedb, 0xa74c3dd4, 0xcaa66506, 0xa7453353, 0xdc90e834, 0xa73e3681, 0xcac23971,
+ 0xa7374760, 0xdc671768, 0xa73065ef, 0xcade2eb3, 0xa7299231, 0xdc3d5c91, 0xa722cc25, 0xcafa44bc,
+ 0xa71c13ce, 0xdc13b7c9, 0xa715692c, 0xcb167b79, 0xa70ecc41, 0xdbea292b, 0xa7083d0d, 0xcb32d2da,
+ 0xa701bb91, 0xdbc0b0ce, 0xa6fb47ce, 0xcb4f4acd, 0xa6f4e1c6, 0xdb974ece, 0xa6ee8979, 0xcb6be341,
+ 0xa6e83ee8, 0xdb6e0342, 0xa6e20214, 0xcb889c23, 0xa6dbd2ff, 0xdb44ce46, 0xa6d5b1a9, 0xcba57563,
+ 0xa6cf9e13, 0xdb1baff2, 0xa6c9983e, 0xcbc26eee, 0xa6c3a02b, 0xdaf2a860, 0xa6bdb5da, 0xcbdf88b3,
+ 0xa6b7d94e, 0xdac9b7a9, 0xa6b20a86, 0xcbfcc29f, 0xa6ac4984, 0xdaa0dde7, 0xa6a69649, 0xcc1a1ca0,
+ 0xa6a0f0d5, 0xda781b31, 0xa69b5929, 0xcc3796a5, 0xa695cf46, 0xda4f6fa3, 0xa690532d, 0xcc55309b,
+ 0xa68ae4df, 0xda26db54, 0xa685845c, 0xcc72ea70, 0xa68031a6, 0xd9fe5e5e, 0xa67aecbd, 0xcc90c412,
+ 0xa675b5a3, 0xd9d5f8d9, 0xa6708c57, 0xccaebd6e, 0xa66b70db, 0xd9adaadf, 0xa6666330, 0xccccd671,
+ 0xa6616355, 0xd9857489, 0xa65c714d, 0xcceb0f0a, 0xa6578d18, 0xd95d55ef, 0xa652b6b6, 0xcd096725,
+ 0xa64dee28, 0xd9354f2a, 0xa6493370, 0xcd27deb0, 0xa644868d, 0xd90d6053, 0xa63fe781, 0xcd467599,
+ 0xa63b564c, 0xd8e58982, 0xa636d2ee, 0xcd652bcb, 0xa6325d6a, 0xd8bdcad0, 0xa62df5bf, 0xcd840134,
+ 0xa6299bed, 0xd8962456, 0xa6254ff7, 0xcda2f5c2, 0xa62111db, 0xd86e962b, 0xa61ce19c, 0xcdc20960,
+ 0xa618bf39, 0xd8472069, 0xa614aab3, 0xcde13bfd, 0xa610a40c, 0xd81fc328, 0xa60cab43, 0xce008d84,
+ 0xa608c058, 0xd7f87e7f, 0xa604e34e, 0xce1ffde2, 0xa6011424, 0xd7d15288, 0xa5fd52db, 0xce3f8d05,
+ 0xa5f99f73, 0xd7aa3f5a, 0xa5f5f9ed, 0xce5f3ad8, 0xa5f2624a, 0xd783450d, 0xa5eed88a, 0xce7f0748,
+ 0xa5eb5cae, 0xd75c63ba, 0xa5e7eeb6, 0xce9ef241, 0xa5e48ea3, 0xd7359b78, 0xa5e13c75, 0xcebefbb0,
+ 0xa5ddf82d, 0xd70eec60, 0xa5dac1cb, 0xcedf2380, 0xa5d79950, 0xd6e85689, 0xa5d47ebc, 0xceff699f,
+ 0xa5d17210, 0xd6c1da0b, 0xa5ce734d, 0xcf1fcdf8, 0xa5cb8272, 0xd69b76fe, 0xa5c89f80, 0xcf405077,
+ 0xa5c5ca77, 0xd6752d79, 0xa5c30359, 0xcf60f108, 0xa5c04a25, 0xd64efd94, 0xa5bd9edc, 0xcf81af97,
+ 0xa5bb017f, 0xd628e767, 0xa5b8720d, 0xcfa28c10, 0xa5b5f087, 0xd602eb0a, 0xa5b37cee, 0xcfc3865e,
+ 0xa5b11741, 0xd5dd0892, 0xa5aebf82, 0xcfe49e6d, 0xa5ac75b0, 0xd5b74019, 0xa5aa39cd, 0xd005d42a,
+ 0xa5a80bd7, 0xd59191b5, 0xa5a5ebd0, 0xd027277e, 0xa5a3d9b8, 0xd56bfd7d, 0xa5a1d590, 0xd0489856,
+ 0xa59fdf57, 0xd5468389, 0xa59df70e, 0xd06a269d, 0xa59c1cb5, 0xd52123f0, 0xa59a504c, 0xd08bd23f,
+ 0xa59891d4, 0xd4fbdec9, 0xa596e14e, 0xd0ad9b26, 0xa5953eb8, 0xd4d6b42b, 0xa593aa14, 0xd0cf813e,
+ 0xa5922362, 0xd4b1a42c, 0xa590aaa2, 0xd0f18472, 0xa58f3fd4, 0xd48caee4, 0xa58de2f8, 0xd113a4ad,
+ 0xa58c940f, 0xd467d469, 0xa58b5319, 0xd135e1d9, 0xa58a2016, 0xd44314d3, 0xa588fb06, 0xd1583be2,
+ 0xa587e3ea, 0xd41e7037, 0xa586dac1, 0xd17ab2b3, 0xa585df8c, 0xd3f9e6ad, 0xa584f24b, 0xd19d4636,
+ 0xa58412fe, 0xd3d5784a, 0xa58341a5, 0xd1bff656, 0xa5827e40, 0xd3b12526, 0xa581c8d0, 0xd1e2c2fd,
+ 0xa5812154, 0xd38ced57, 0xa58087cd, 0xd205ac17, 0xa57ffc3b, 0xd368d0f3, 0xa57f7e9d, 0xd228b18d,
+ 0xa57f0ef5, 0xd344d011, 0xa57ead41, 0xd24bd34a, 0xa57e5982, 0xd320eac6, 0xa57e13b8, 0xd26f1138,
+ 0xa57ddbe4, 0xd2fd2129, 0xa57db204, 0xd2926b41, 0xa57d961a, 0xd2d97350, 0xa57d8825, 0xd2b5e151,
+};
+
+/* PostMultiply() tables
+ * format = Q30
+ * reordered for sequential access
+ * decimate (skip by 16 instead of 2) for small transform (128)
+ *
+ * for (i = 0; i <= (512/2); i++) {
+ * angle = i * M_PI / 1024;
+ * x = (cos(angle) + sin(angle));
+ * x = sin(angle);
+ * }
+ */
+const int cos1sin1tab[514] = {
+ /* format = Q30 */
+ 0x40000000, 0x00000000, 0x40323034, 0x003243f1, 0x406438cf, 0x006487c4, 0x409619b2, 0x0096cb58,
+ 0x40c7d2bd, 0x00c90e90, 0x40f963d3, 0x00fb514b, 0x412accd4, 0x012d936c, 0x415c0da3, 0x015fd4d2,
+ 0x418d2621, 0x0192155f, 0x41be162f, 0x01c454f5, 0x41eeddaf, 0x01f69373, 0x421f7c84, 0x0228d0bb,
+ 0x424ff28f, 0x025b0caf, 0x42803fb2, 0x028d472e, 0x42b063d0, 0x02bf801a, 0x42e05ecb, 0x02f1b755,
+ 0x43103085, 0x0323ecbe, 0x433fd8e1, 0x03562038, 0x436f57c1, 0x038851a2, 0x439ead09, 0x03ba80df,
+ 0x43cdd89a, 0x03ecadcf, 0x43fcda59, 0x041ed854, 0x442bb227, 0x0451004d, 0x445a5fe8, 0x0483259d,
+ 0x4488e37f, 0x04b54825, 0x44b73ccf, 0x04e767c5, 0x44e56bbd, 0x0519845e, 0x4513702a, 0x054b9dd3,
+ 0x454149fc, 0x057db403, 0x456ef916, 0x05afc6d0, 0x459c7d5a, 0x05e1d61b, 0x45c9d6af, 0x0613e1c5,
+ 0x45f704f7, 0x0645e9af, 0x46240816, 0x0677edbb, 0x4650dff1, 0x06a9edc9, 0x467d8c6d, 0x06dbe9bb,
+ 0x46aa0d6d, 0x070de172, 0x46d662d6, 0x073fd4cf, 0x47028c8d, 0x0771c3b3, 0x472e8a76, 0x07a3adff,
+ 0x475a5c77, 0x07d59396, 0x47860275, 0x08077457, 0x47b17c54, 0x08395024, 0x47dcc9f9, 0x086b26de,
+ 0x4807eb4b, 0x089cf867, 0x4832e02d, 0x08cec4a0, 0x485da887, 0x09008b6a, 0x4888443d, 0x09324ca7,
+ 0x48b2b335, 0x09640837, 0x48dcf556, 0x0995bdfd, 0x49070a84, 0x09c76dd8, 0x4930f2a6, 0x09f917ac,
+ 0x495aada2, 0x0a2abb59, 0x49843b5f, 0x0a5c58c0, 0x49ad9bc2, 0x0a8defc3, 0x49d6ceb3, 0x0abf8043,
+ 0x49ffd417, 0x0af10a22, 0x4a28abd6, 0x0b228d42, 0x4a5155d6, 0x0b540982, 0x4a79d1ff, 0x0b857ec7,
+ 0x4aa22036, 0x0bb6ecef, 0x4aca4065, 0x0be853de, 0x4af23270, 0x0c19b374, 0x4b19f641, 0x0c4b0b94,
+ 0x4b418bbe, 0x0c7c5c1e, 0x4b68f2cf, 0x0cada4f5, 0x4b902b5c, 0x0cdee5f9, 0x4bb7354d, 0x0d101f0e,
+ 0x4bde1089, 0x0d415013, 0x4c04bcf8, 0x0d7278eb, 0x4c2b3a84, 0x0da39978, 0x4c518913, 0x0dd4b19a,
+ 0x4c77a88e, 0x0e05c135, 0x4c9d98de, 0x0e36c82a, 0x4cc359ec, 0x0e67c65a, 0x4ce8eb9f, 0x0e98bba7,
+ 0x4d0e4de2, 0x0ec9a7f3, 0x4d33809c, 0x0efa8b20, 0x4d5883b7, 0x0f2b650f, 0x4d7d571c, 0x0f5c35a3,
+ 0x4da1fab5, 0x0f8cfcbe, 0x4dc66e6a, 0x0fbdba40, 0x4deab226, 0x0fee6e0d, 0x4e0ec5d1, 0x101f1807,
+ 0x4e32a956, 0x104fb80e, 0x4e565c9f, 0x10804e06, 0x4e79df95, 0x10b0d9d0, 0x4e9d3222, 0x10e15b4e,
+ 0x4ec05432, 0x1111d263, 0x4ee345ad, 0x11423ef0, 0x4f06067f, 0x1172a0d7, 0x4f289692, 0x11a2f7fc,
+ 0x4f4af5d1, 0x11d3443f, 0x4f6d2427, 0x12038584, 0x4f8f217e, 0x1233bbac, 0x4fb0edc1, 0x1263e699,
+ 0x4fd288dc, 0x1294062f, 0x4ff3f2bb, 0x12c41a4f, 0x50152b47, 0x12f422db, 0x5036326e, 0x13241fb6,
+ 0x50570819, 0x135410c3, 0x5077ac37, 0x1383f5e3, 0x50981eb1, 0x13b3cefa, 0x50b85f74, 0x13e39be9,
+ 0x50d86e6d, 0x14135c94, 0x50f84b87, 0x144310dd, 0x5117f6ae, 0x1472b8a5, 0x51376fd0, 0x14a253d1,
+ 0x5156b6d9, 0x14d1e242, 0x5175cbb5, 0x150163dc, 0x5194ae52, 0x1530d881, 0x51b35e9b, 0x15604013,
+ 0x51d1dc80, 0x158f9a76, 0x51f027eb, 0x15bee78c, 0x520e40cc, 0x15ee2738, 0x522c270f, 0x161d595d,
+ 0x5249daa2, 0x164c7ddd, 0x52675b72, 0x167b949d, 0x5284a96e, 0x16aa9d7e, 0x52a1c482, 0x16d99864,
+ 0x52beac9f, 0x17088531, 0x52db61b0, 0x173763c9, 0x52f7e3a6, 0x1766340f, 0x5314326d, 0x1794f5e6,
+ 0x53304df6, 0x17c3a931, 0x534c362d, 0x17f24dd3, 0x5367eb03, 0x1820e3b0, 0x53836c66, 0x184f6aab,
+ 0x539eba45, 0x187de2a7, 0x53b9d48f, 0x18ac4b87, 0x53d4bb34, 0x18daa52f, 0x53ef6e23, 0x1908ef82,
+ 0x5409ed4b, 0x19372a64, 0x5424389d, 0x196555b8, 0x543e5007, 0x19937161, 0x5458337a, 0x19c17d44,
+ 0x5471e2e6, 0x19ef7944, 0x548b5e3b, 0x1a1d6544, 0x54a4a56a, 0x1a4b4128, 0x54bdb862, 0x1a790cd4,
+ 0x54d69714, 0x1aa6c82b, 0x54ef4171, 0x1ad47312, 0x5507b76a, 0x1b020d6c, 0x551ff8ef, 0x1b2f971e,
+ 0x553805f2, 0x1b5d100a, 0x554fde64, 0x1b8a7815, 0x55678236, 0x1bb7cf23, 0x557ef15a, 0x1be51518,
+ 0x55962bc0, 0x1c1249d8, 0x55ad315b, 0x1c3f6d47, 0x55c4021d, 0x1c6c7f4a, 0x55da9df7, 0x1c997fc4,
+ 0x55f104dc, 0x1cc66e99, 0x560736bd, 0x1cf34baf, 0x561d338d, 0x1d2016e9, 0x5632fb3f, 0x1d4cd02c,
+ 0x56488dc5, 0x1d79775c, 0x565deb11, 0x1da60c5d, 0x56731317, 0x1dd28f15, 0x568805c9, 0x1dfeff67,
+ 0x569cc31b, 0x1e2b5d38, 0x56b14b00, 0x1e57a86d, 0x56c59d6a, 0x1e83e0eb, 0x56d9ba4e, 0x1eb00696,
+ 0x56eda1a0, 0x1edc1953, 0x57015352, 0x1f081907, 0x5714cf59, 0x1f340596, 0x572815a8, 0x1f5fdee6,
+ 0x573b2635, 0x1f8ba4dc, 0x574e00f2, 0x1fb7575c, 0x5760a5d5, 0x1fe2f64c, 0x577314d2, 0x200e8190,
+ 0x57854ddd, 0x2039f90f, 0x579750ec, 0x20655cac, 0x57a91df2, 0x2090ac4d, 0x57bab4e6, 0x20bbe7d8,
+ 0x57cc15bc, 0x20e70f32, 0x57dd406a, 0x21122240, 0x57ee34e5, 0x213d20e8, 0x57fef323, 0x21680b0f,
+ 0x580f7b19, 0x2192e09b, 0x581fccbc, 0x21bda171, 0x582fe804, 0x21e84d76, 0x583fcce6, 0x2212e492,
+ 0x584f7b58, 0x223d66a8, 0x585ef351, 0x2267d3a0, 0x586e34c7, 0x22922b5e, 0x587d3fb0, 0x22bc6dca,
+ 0x588c1404, 0x22e69ac8, 0x589ab1b9, 0x2310b23e, 0x58a918c6, 0x233ab414, 0x58b74923, 0x2364a02e,
+ 0x58c542c5, 0x238e7673, 0x58d305a6, 0x23b836ca, 0x58e091bd, 0x23e1e117, 0x58ede700, 0x240b7543,
+ 0x58fb0568, 0x2434f332, 0x5907eced, 0x245e5acc, 0x59149d87, 0x2487abf7, 0x5921172e, 0x24b0e699,
+ 0x592d59da, 0x24da0a9a, 0x59396584, 0x250317df, 0x59453a24, 0x252c0e4f, 0x5950d7b3, 0x2554edd1,
+ 0x595c3e2a, 0x257db64c, 0x59676d82, 0x25a667a7, 0x597265b4, 0x25cf01c8, 0x597d26b8, 0x25f78497,
+ 0x5987b08a, 0x261feffa, 0x59920321, 0x264843d9, 0x599c1e78, 0x2670801a, 0x59a60288, 0x2698a4a6,
+ 0x59afaf4c, 0x26c0b162, 0x59b924bc, 0x26e8a637, 0x59c262d5, 0x2710830c, 0x59cb698f, 0x273847c8,
+ 0x59d438e5, 0x275ff452, 0x59dcd0d3, 0x27878893, 0x59e53151, 0x27af0472, 0x59ed5a5c, 0x27d667d5,
+ 0x59f54bee, 0x27fdb2a7, 0x59fd0603, 0x2824e4cc, 0x5a048895, 0x284bfe2f, 0x5a0bd3a1, 0x2872feb6,
+ 0x5a12e720, 0x2899e64a, 0x5a19c310, 0x28c0b4d2, 0x5a20676c, 0x28e76a37, 0x5a26d42f, 0x290e0661,
+ 0x5a2d0957, 0x29348937, 0x5a3306de, 0x295af2a3, 0x5a38ccc2, 0x2981428c, 0x5a3e5afe, 0x29a778db,
+ 0x5a43b190, 0x29cd9578, 0x5a48d074, 0x29f3984c, 0x5a4db7a6, 0x2a19813f, 0x5a526725, 0x2a3f503a,
+ 0x5a56deec, 0x2a650525, 0x5a5b1efa, 0x2a8a9fea, 0x5a5f274b, 0x2ab02071, 0x5a62f7dd, 0x2ad586a3,
+ 0x5a6690ae, 0x2afad269, 0x5a69f1bb, 0x2b2003ac, 0x5a6d1b03, 0x2b451a55, 0x5a700c84, 0x2b6a164d,
+ 0x5a72c63b, 0x2b8ef77d, 0x5a754827, 0x2bb3bdce, 0x5a779246, 0x2bd8692b, 0x5a79a498, 0x2bfcf97c,
+ 0x5a7b7f1a, 0x2c216eaa, 0x5a7d21cc, 0x2c45c8a0, 0x5a7e8cac, 0x2c6a0746, 0x5a7fbfbb, 0x2c8e2a87,
+ 0x5a80baf6, 0x2cb2324c, 0x5a817e5d, 0x2cd61e7f, 0x5a8209f1, 0x2cf9ef09, 0x5a825db0, 0x2d1da3d5,
+ 0x5a82799a, 0x2d413ccd,
+};
+
+const int sinWindowOffset[NUM_IMDCT_SIZES] = {0, 128};
+
+/* Synthesis window - SIN
+ * format = Q31 for nmdct = [128, 1024]
+ * reordered for sequential access
+ *
+ * for (i = 0; i < nmdct/2; i++) {
+ * angle = (i + 0.5) * M_PI / (2.0 * nmdct);
+ * x = sin(angle);
+ *
+ * angle = (nmdct - 1 - i + 0.5) * M_PI / (2.0 * nmdct);
+ * x = sin(angle);
+ * }
+ */
+const int sinWindow[128 + 1024] = {
+ /* 128 - format = Q31 * 2^0 */
+ 0x00c90f88, 0x7fff6216, 0x025b26d7, 0x7ffa72d1, 0x03ed26e6, 0x7ff09478, 0x057f0035, 0x7fe1c76b,
+ 0x0710a345, 0x7fce0c3e, 0x08a2009a, 0x7fb563b3, 0x0a3308bd, 0x7f97cebd, 0x0bc3ac35, 0x7f754e80,
+ 0x0d53db92, 0x7f4de451, 0x0ee38766, 0x7f2191b4, 0x1072a048, 0x7ef05860, 0x120116d5, 0x7eba3a39,
+ 0x138edbb1, 0x7e7f3957, 0x151bdf86, 0x7e3f57ff, 0x16a81305, 0x7dfa98a8, 0x183366e9, 0x7db0fdf8,
+ 0x19bdcbf3, 0x7d628ac6, 0x1b4732ef, 0x7d0f4218, 0x1ccf8cb3, 0x7cb72724, 0x1e56ca1e, 0x7c5a3d50,
+ 0x1fdcdc1b, 0x7bf88830, 0x2161b3a0, 0x7b920b89, 0x22e541af, 0x7b26cb4f, 0x24677758, 0x7ab6cba4,
+ 0x25e845b6, 0x7a4210d8, 0x27679df4, 0x79c89f6e, 0x28e5714b, 0x794a7c12, 0x2a61b101, 0x78c7aba2,
+ 0x2bdc4e6f, 0x78403329, 0x2d553afc, 0x77b417df, 0x2ecc681e, 0x77235f2d, 0x3041c761, 0x768e0ea6,
+ 0x31b54a5e, 0x75f42c0b, 0x3326e2c3, 0x7555bd4c, 0x34968250, 0x74b2c884, 0x36041ad9, 0x740b53fb,
+ 0x376f9e46, 0x735f6626, 0x38d8fe93, 0x72af05a7, 0x3a402dd2, 0x71fa3949, 0x3ba51e29, 0x71410805,
+ 0x3d07c1d6, 0x708378ff, 0x3e680b2c, 0x6fc19385, 0x3fc5ec98, 0x6efb5f12, 0x4121589b, 0x6e30e34a,
+ 0x427a41d0, 0x6d6227fa, 0x43d09aed, 0x6c8f351c, 0x452456bd, 0x6bb812d1, 0x46756828, 0x6adcc964,
+ 0x47c3c22f, 0x69fd614a, 0x490f57ee, 0x6919e320, 0x4a581c9e, 0x683257ab, 0x4b9e0390, 0x6746c7d8,
+ 0x4ce10034, 0x66573cbb, 0x4e210617, 0x6563bf92, 0x4f5e08e3, 0x646c59bf, 0x5097fc5e, 0x637114cc,
+ 0x51ced46e, 0x6271fa69, 0x53028518, 0x616f146c, 0x5433027d, 0x60686ccf, 0x556040e2, 0x5f5e0db3,
+ 0x568a34a9, 0x5e50015d, 0x57b0d256, 0x5d3e5237, 0x58d40e8c, 0x5c290acc, 0x59f3de12, 0x5b1035cf,
+ /* 1024 - format = Q31 * 2^0 */
+ 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,
+};
+
+const int kbdWindowOffset[NUM_IMDCT_SIZES] = {0, 128};
+
+/* Synthesis window - KBD
+ * format = Q31 for nmdct = [128, 1024]
+ * reordered for sequential access
+ *
+ * aacScaleFact = -sqrt(1.0 / (2.0 * nmdct));
+ * for (i = 0; i < nmdct/2; i++) {
+ * x = kbdWindowRef[i] * aacScaleFact;
+ * x = kbdWindowRef[nmdct - 1 - i] * aacScaleFact;
+ * }
+ * Note: see below for code to generate kbdWindowRef[]
+ */
+const int kbdWindow[128 + 1024] = {
+ /* 128 - format = Q31 * 2^0 */
+ 0x00016f63, 0x7ffffffe, 0x0003e382, 0x7ffffff1, 0x00078f64, 0x7fffffc7, 0x000cc323, 0x7fffff5d,
+ 0x0013d9ed, 0x7ffffe76, 0x001d3a9d, 0x7ffffcaa, 0x0029581f, 0x7ffff953, 0x0038b1bd, 0x7ffff372,
+ 0x004bd34d, 0x7fffe98b, 0x00635538, 0x7fffd975, 0x007fdc64, 0x7fffc024, 0x00a219f1, 0x7fff995b,
+ 0x00cacad0, 0x7fff5f5b, 0x00fab72d, 0x7fff0a75, 0x0132b1af, 0x7ffe9091, 0x01739689, 0x7ffde49e,
+ 0x01be4a63, 0x7ffcf5ef, 0x0213b910, 0x7ffbaf84, 0x0274d41e, 0x7ff9f73a, 0x02e2913a, 0x7ff7acf1,
+ 0x035de86c, 0x7ff4a99a, 0x03e7d233, 0x7ff0be3d, 0x0481457c, 0x7febb2f1, 0x052b357c, 0x7fe545d4,
+ 0x05e68f77, 0x7fdd2a02, 0x06b4386f, 0x7fd30695, 0x07950acb, 0x7fc675b4, 0x0889d3ef, 0x7fb703be,
+ 0x099351e0, 0x7fa42e89, 0x0ab230e0, 0x7f8d64d8, 0x0be70923, 0x7f7205f8, 0x0d325c93, 0x7f516195,
+ 0x0e9494ae, 0x7f2ab7d0, 0x100e0085, 0x7efd3997, 0x119ed2ef, 0x7ec8094a, 0x134720d8, 0x7e8a3ba7,
+ 0x1506dfdc, 0x7e42d906, 0x16dde50b, 0x7df0dee4, 0x18cbe3f7, 0x7d9341b4, 0x1ad06e07, 0x7d28ef02,
+ 0x1ceaf215, 0x7cb0cfcc, 0x1f1abc4f, 0x7c29cb20, 0x215ef677, 0x7b92c8eb, 0x23b6a867, 0x7aeab4ec,
+ 0x2620b8ec, 0x7a3081d0, 0x289beef5, 0x79632c5a, 0x2b26f30b, 0x7881be95, 0x2dc0511f, 0x778b5304,
+ 0x30667aa2, 0x767f17c0, 0x3317c8dd, 0x755c5178, 0x35d27f98, 0x74225e50, 0x3894cff3, 0x72d0b887,
+ 0x3b5cdb7b, 0x7166f8e7, 0x3e28b770, 0x6fe4d8e8, 0x40f6702a, 0x6e4a3491, 0x43c40caa, 0x6c970bfc,
+ 0x468f9231, 0x6acb8483, 0x495707f5, 0x68e7e994, 0x4c187ac7, 0x66ecad1c, 0x4ed200c5, 0x64da6797,
+ 0x5181bcea, 0x62b1d7b7, 0x5425e28e, 0x6073e1ae, 0x56bcb8c2, 0x5e218e16, 0x59449d76, 0x5bbc0875,
+ /* 1024 - format = Q31 * 2^0 */
+ 0x0009962f, 0x7fffffa4, 0x000e16fb, 0x7fffff39, 0x0011ea65, 0x7ffffebf, 0x0015750e, 0x7ffffe34,
+ 0x0018dc74, 0x7ffffd96, 0x001c332e, 0x7ffffce5, 0x001f83f5, 0x7ffffc1f, 0x0022d59a, 0x7ffffb43,
+ 0x00262cc2, 0x7ffffa4f, 0x00298cc4, 0x7ffff942, 0x002cf81f, 0x7ffff81a, 0x003070c4, 0x7ffff6d6,
+ 0x0033f840, 0x7ffff573, 0x00378fd9, 0x7ffff3f1, 0x003b38a1, 0x7ffff24d, 0x003ef381, 0x7ffff085,
+ 0x0042c147, 0x7fffee98, 0x0046a2a8, 0x7fffec83, 0x004a9847, 0x7fffea44, 0x004ea2b7, 0x7fffe7d8,
+ 0x0052c283, 0x7fffe53f, 0x0056f829, 0x7fffe274, 0x005b4422, 0x7fffdf76, 0x005fa6dd, 0x7fffdc43,
+ 0x006420c8, 0x7fffd8d6, 0x0068b249, 0x7fffd52f, 0x006d5bc4, 0x7fffd149, 0x00721d9a, 0x7fffcd22,
+ 0x0076f828, 0x7fffc8b6, 0x007bebca, 0x7fffc404, 0x0080f8d9, 0x7fffbf06, 0x00861fae, 0x7fffb9bb,
+ 0x008b609e, 0x7fffb41e, 0x0090bbff, 0x7fffae2c, 0x00963224, 0x7fffa7e1, 0x009bc362, 0x7fffa13a,
+ 0x00a17009, 0x7fff9a32, 0x00a7386c, 0x7fff92c5, 0x00ad1cdc, 0x7fff8af0, 0x00b31da8, 0x7fff82ad,
+ 0x00b93b21, 0x7fff79f9, 0x00bf7596, 0x7fff70cf, 0x00c5cd57, 0x7fff672a, 0x00cc42b1, 0x7fff5d05,
+ 0x00d2d5f3, 0x7fff525c, 0x00d9876c, 0x7fff4729, 0x00e05769, 0x7fff3b66, 0x00e74638, 0x7fff2f10,
+ 0x00ee5426, 0x7fff221f, 0x00f58182, 0x7fff148e, 0x00fcce97, 0x7fff0658, 0x01043bb3, 0x7ffef776,
+ 0x010bc923, 0x7ffee7e2, 0x01137733, 0x7ffed795, 0x011b4631, 0x7ffec68a, 0x01233669, 0x7ffeb4ba,
+ 0x012b4827, 0x7ffea21d, 0x01337bb8, 0x7ffe8eac, 0x013bd167, 0x7ffe7a61, 0x01444982, 0x7ffe6533,
+ 0x014ce454, 0x7ffe4f1c, 0x0155a229, 0x7ffe3813, 0x015e834d, 0x7ffe2011, 0x0167880c, 0x7ffe070d,
+ 0x0170b0b2, 0x7ffdecff, 0x0179fd8b, 0x7ffdd1df, 0x01836ee1, 0x7ffdb5a2, 0x018d0500, 0x7ffd9842,
+ 0x0196c035, 0x7ffd79b3, 0x01a0a0ca, 0x7ffd59ee, 0x01aaa70a, 0x7ffd38e8, 0x01b4d341, 0x7ffd1697,
+ 0x01bf25b9, 0x7ffcf2f2, 0x01c99ebd, 0x7ffccdee, 0x01d43e99, 0x7ffca780, 0x01df0597, 0x7ffc7f9e,
+ 0x01e9f401, 0x7ffc563d, 0x01f50a22, 0x7ffc2b51, 0x02004844, 0x7ffbfecf, 0x020baeb1, 0x7ffbd0ab,
+ 0x02173db4, 0x7ffba0da, 0x0222f596, 0x7ffb6f4f, 0x022ed6a1, 0x7ffb3bfd, 0x023ae11f, 0x7ffb06d8,
+ 0x02471558, 0x7ffacfd3, 0x02537397, 0x7ffa96e0, 0x025ffc25, 0x7ffa5bf2, 0x026caf4a, 0x7ffa1efc,
+ 0x02798d4f, 0x7ff9dfee, 0x0286967c, 0x7ff99ebb, 0x0293cb1b, 0x7ff95b55, 0x02a12b72, 0x7ff915ab,
+ 0x02aeb7cb, 0x7ff8cdaf, 0x02bc706d, 0x7ff88351, 0x02ca559f, 0x7ff83682, 0x02d867a9, 0x7ff7e731,
+ 0x02e6a6d2, 0x7ff7954e, 0x02f51361, 0x7ff740c8, 0x0303ad9c, 0x7ff6e98e, 0x031275ca, 0x7ff68f8f,
+ 0x03216c30, 0x7ff632ba, 0x03309116, 0x7ff5d2fb, 0x033fe4bf, 0x7ff57042, 0x034f6773, 0x7ff50a7a,
+ 0x035f1975, 0x7ff4a192, 0x036efb0a, 0x7ff43576, 0x037f0c78, 0x7ff3c612, 0x038f4e02, 0x7ff35353,
+ 0x039fbfeb, 0x7ff2dd24, 0x03b06279, 0x7ff26370, 0x03c135ed, 0x7ff1e623, 0x03d23a8b, 0x7ff16527,
+ 0x03e37095, 0x7ff0e067, 0x03f4d84e, 0x7ff057cc, 0x040671f7, 0x7fefcb40, 0x04183dd3, 0x7fef3aad,
+ 0x042a3c22, 0x7feea5fa, 0x043c6d25, 0x7fee0d11, 0x044ed11d, 0x7fed6fda, 0x04616849, 0x7fecce3d,
+ 0x047432eb, 0x7fec2821, 0x04873140, 0x7feb7d6c, 0x049a6388, 0x7feace07, 0x04adca01, 0x7fea19d6,
+ 0x04c164ea, 0x7fe960c0, 0x04d53481, 0x7fe8a2aa, 0x04e93902, 0x7fe7df79, 0x04fd72aa, 0x7fe71712,
+ 0x0511e1b6, 0x7fe6495a, 0x05268663, 0x7fe57634, 0x053b60eb, 0x7fe49d83, 0x05507189, 0x7fe3bf2b,
+ 0x0565b879, 0x7fe2db0f, 0x057b35f4, 0x7fe1f110, 0x0590ea35, 0x7fe10111, 0x05a6d574, 0x7fe00af3,
+ 0x05bcf7ea, 0x7fdf0e97, 0x05d351cf, 0x7fde0bdd, 0x05e9e35c, 0x7fdd02a6, 0x0600acc8, 0x7fdbf2d2,
+ 0x0617ae48, 0x7fdadc40, 0x062ee814, 0x7fd9becf, 0x06465a62, 0x7fd89a5e, 0x065e0565, 0x7fd76eca,
+ 0x0675e954, 0x7fd63bf1, 0x068e0662, 0x7fd501b0, 0x06a65cc3, 0x7fd3bfe4, 0x06beecaa, 0x7fd2766a,
+ 0x06d7b648, 0x7fd1251e, 0x06f0b9d1, 0x7fcfcbda, 0x0709f775, 0x7fce6a7a, 0x07236f65, 0x7fcd00d8,
+ 0x073d21d2, 0x7fcb8ecf, 0x07570eea, 0x7fca1439, 0x077136dd, 0x7fc890ed, 0x078b99da, 0x7fc704c7,
+ 0x07a6380d, 0x7fc56f9d, 0x07c111a4, 0x7fc3d147, 0x07dc26cc, 0x7fc2299e, 0x07f777b1, 0x7fc07878,
+ 0x0813047d, 0x7fbebdac, 0x082ecd5b, 0x7fbcf90f, 0x084ad276, 0x7fbb2a78, 0x086713f7, 0x7fb951bc,
+ 0x08839206, 0x7fb76eaf, 0x08a04ccb, 0x7fb58126, 0x08bd446e, 0x7fb388f4, 0x08da7915, 0x7fb185ee,
+ 0x08f7eae7, 0x7faf77e5, 0x09159a09, 0x7fad5ead, 0x0933869f, 0x7fab3a17, 0x0951b0cd, 0x7fa909f6,
+ 0x097018b7, 0x7fa6ce1a, 0x098ebe7f, 0x7fa48653, 0x09ada248, 0x7fa23273, 0x09ccc431, 0x7f9fd249,
+ 0x09ec245b, 0x7f9d65a4, 0x0a0bc2e7, 0x7f9aec53, 0x0a2b9ff3, 0x7f986625, 0x0a4bbb9e, 0x7f95d2e7,
+ 0x0a6c1604, 0x7f933267, 0x0a8caf43, 0x7f908472, 0x0aad8776, 0x7f8dc8d5, 0x0ace9eb9, 0x7f8aff5c,
+ 0x0aeff526, 0x7f8827d3, 0x0b118ad8, 0x7f854204, 0x0b335fe6, 0x7f824dbb, 0x0b557469, 0x7f7f4ac3,
+ 0x0b77c879, 0x7f7c38e4, 0x0b9a5c2b, 0x7f7917e9, 0x0bbd2f97, 0x7f75e79b, 0x0be042d0, 0x7f72a7c3,
+ 0x0c0395ec, 0x7f6f5828, 0x0c2728fd, 0x7f6bf892, 0x0c4afc16, 0x7f6888c9, 0x0c6f0f4a, 0x7f650894,
+ 0x0c9362a8, 0x7f6177b9, 0x0cb7f642, 0x7f5dd5ff, 0x0cdcca26, 0x7f5a232a, 0x0d01de63, 0x7f565f00,
+ 0x0d273307, 0x7f528947, 0x0d4cc81f, 0x7f4ea1c2, 0x0d729db7, 0x7f4aa835, 0x0d98b3da, 0x7f469c65,
+ 0x0dbf0a92, 0x7f427e13, 0x0de5a1e9, 0x7f3e4d04, 0x0e0c79e7, 0x7f3a08f9, 0x0e339295, 0x7f35b1b4,
+ 0x0e5aebfa, 0x7f3146f8, 0x0e82861a, 0x7f2cc884, 0x0eaa60fd, 0x7f28361b, 0x0ed27ca5, 0x7f238f7c,
+ 0x0efad917, 0x7f1ed467, 0x0f237656, 0x7f1a049d, 0x0f4c5462, 0x7f151fdc, 0x0f75733d, 0x7f1025e3,
+ 0x0f9ed2e6, 0x7f0b1672, 0x0fc8735e, 0x7f05f146, 0x0ff254a1, 0x7f00b61d, 0x101c76ae, 0x7efb64b4,
+ 0x1046d981, 0x7ef5fcca, 0x10717d15, 0x7ef07e19, 0x109c6165, 0x7eeae860, 0x10c7866a, 0x7ee53b5b,
+ 0x10f2ec1e, 0x7edf76c4, 0x111e9279, 0x7ed99a58, 0x114a7971, 0x7ed3a5d1, 0x1176a0fc, 0x7ecd98eb,
+ 0x11a30910, 0x7ec77360, 0x11cfb1a1, 0x7ec134eb, 0x11fc9aa2, 0x7ebadd44, 0x1229c406, 0x7eb46c27,
+ 0x12572dbf, 0x7eade14c, 0x1284d7bc, 0x7ea73c6c, 0x12b2c1ed, 0x7ea07d41, 0x12e0ec42, 0x7e99a382,
+ 0x130f56a8, 0x7e92aee7, 0x133e010b, 0x7e8b9f2a, 0x136ceb59, 0x7e847402, 0x139c157b, 0x7e7d2d25,
+ 0x13cb7f5d, 0x7e75ca4c, 0x13fb28e6, 0x7e6e4b2d, 0x142b1200, 0x7e66af7f, 0x145b3a92, 0x7e5ef6f8,
+ 0x148ba281, 0x7e572150, 0x14bc49b4, 0x7e4f2e3b, 0x14ed300f, 0x7e471d70, 0x151e5575, 0x7e3eeea5,
+ 0x154fb9c9, 0x7e36a18e, 0x15815ced, 0x7e2e35e2, 0x15b33ec1, 0x7e25ab56, 0x15e55f25, 0x7e1d019e,
+ 0x1617bdf9, 0x7e14386e, 0x164a5b19, 0x7e0b4f7d, 0x167d3662, 0x7e02467e, 0x16b04fb2, 0x7df91d25,
+ 0x16e3a6e2, 0x7defd327, 0x17173bce, 0x7de66837, 0x174b0e4d, 0x7ddcdc0a, 0x177f1e39, 0x7dd32e53,
+ 0x17b36b69, 0x7dc95ec6, 0x17e7f5b3, 0x7dbf6d17, 0x181cbcec, 0x7db558f9, 0x1851c0e9, 0x7dab221f,
+ 0x1887017d, 0x7da0c83c, 0x18bc7e7c, 0x7d964b05, 0x18f237b6, 0x7d8baa2b, 0x19282cfd, 0x7d80e563,
+ 0x195e5e20, 0x7d75fc5e, 0x1994caee, 0x7d6aeed0, 0x19cb7335, 0x7d5fbc6d, 0x1a0256c2, 0x7d5464e6,
+ 0x1a397561, 0x7d48e7ef, 0x1a70cede, 0x7d3d453b, 0x1aa86301, 0x7d317c7c, 0x1ae03195, 0x7d258d65,
+ 0x1b183a63, 0x7d1977aa, 0x1b507d30, 0x7d0d3afc, 0x1b88f9c5, 0x7d00d710, 0x1bc1afe6, 0x7cf44b97,
+ 0x1bfa9f58, 0x7ce79846, 0x1c33c7e0, 0x7cdabcce, 0x1c6d293f, 0x7ccdb8e4, 0x1ca6c337, 0x7cc08c39,
+ 0x1ce0958a, 0x7cb33682, 0x1d1a9ff8, 0x7ca5b772, 0x1d54e240, 0x7c980ebd, 0x1d8f5c21, 0x7c8a3c14,
+ 0x1dca0d56, 0x7c7c3f2e, 0x1e04f59f, 0x7c6e17bc, 0x1e4014b4, 0x7c5fc573, 0x1e7b6a53, 0x7c514807,
+ 0x1eb6f633, 0x7c429f2c, 0x1ef2b80f, 0x7c33ca96, 0x1f2eaf9e, 0x7c24c9fa, 0x1f6adc98, 0x7c159d0d,
+ 0x1fa73eb2, 0x7c064383, 0x1fe3d5a3, 0x7bf6bd11, 0x2020a11e, 0x7be7096c, 0x205da0d8, 0x7bd7284a,
+ 0x209ad483, 0x7bc71960, 0x20d83bd1, 0x7bb6dc65, 0x2115d674, 0x7ba6710d, 0x2153a41b, 0x7b95d710,
+ 0x2191a476, 0x7b850e24, 0x21cfd734, 0x7b7415ff, 0x220e3c02, 0x7b62ee59, 0x224cd28d, 0x7b5196e9,
+ 0x228b9a82, 0x7b400f67, 0x22ca938a, 0x7b2e578a, 0x2309bd52, 0x7b1c6f0b, 0x23491783, 0x7b0a55a1,
+ 0x2388a1c4, 0x7af80b07, 0x23c85bbf, 0x7ae58ef5, 0x2408451a, 0x7ad2e124, 0x24485d7c, 0x7ac0014e,
+ 0x2488a48a, 0x7aacef2e, 0x24c919e9, 0x7a99aa7e, 0x2509bd3d, 0x7a8632f8, 0x254a8e29, 0x7a728858,
+ 0x258b8c50, 0x7a5eaa5a, 0x25ccb753, 0x7a4a98b9, 0x260e0ed3, 0x7a365333, 0x264f9271, 0x7a21d983,
+ 0x269141cb, 0x7a0d2b68, 0x26d31c80, 0x79f8489e, 0x2715222f, 0x79e330e4, 0x27575273, 0x79cde3f8,
+ 0x2799acea, 0x79b8619a, 0x27dc3130, 0x79a2a989, 0x281ededf, 0x798cbb85, 0x2861b591, 0x7976974e,
+ 0x28a4b4e0, 0x79603ca5, 0x28e7dc65, 0x7949ab4c, 0x292b2bb8, 0x7932e304, 0x296ea270, 0x791be390,
+ 0x29b24024, 0x7904acb3, 0x29f6046b, 0x78ed3e30, 0x2a39eed8, 0x78d597cc, 0x2a7dff02, 0x78bdb94a,
+ 0x2ac2347c, 0x78a5a270, 0x2b068eda, 0x788d5304, 0x2b4b0dae, 0x7874cacb, 0x2b8fb08a, 0x785c098d,
+ 0x2bd47700, 0x78430f11, 0x2c1960a1, 0x7829db1f, 0x2c5e6cfd, 0x78106d7f, 0x2ca39ba3, 0x77f6c5fb,
+ 0x2ce8ec23, 0x77dce45c, 0x2d2e5e0b, 0x77c2c86e, 0x2d73f0e8, 0x77a871fa, 0x2db9a449, 0x778de0cd,
+ 0x2dff77b8, 0x777314b2, 0x2e456ac4, 0x77580d78, 0x2e8b7cf6, 0x773ccaeb, 0x2ed1addb, 0x77214cdb,
+ 0x2f17fcfb, 0x77059315, 0x2f5e69e2, 0x76e99d69, 0x2fa4f419, 0x76cd6ba9, 0x2feb9b27, 0x76b0fda4,
+ 0x30325e96, 0x7694532e, 0x30793dee, 0x76776c17, 0x30c038b5, 0x765a4834, 0x31074e72, 0x763ce759,
+ 0x314e7eab, 0x761f4959, 0x3195c8e6, 0x76016e0b, 0x31dd2ca9, 0x75e35545, 0x3224a979, 0x75c4fedc,
+ 0x326c3ed8, 0x75a66aab, 0x32b3ec4d, 0x75879887, 0x32fbb159, 0x7568884b, 0x33438d81, 0x754939d1,
+ 0x338b8045, 0x7529acf4, 0x33d3892a, 0x7509e18e, 0x341ba7b1, 0x74e9d77d, 0x3463db5a, 0x74c98e9e,
+ 0x34ac23a7, 0x74a906cd, 0x34f48019, 0x74883fec, 0x353cf02f, 0x746739d8, 0x3585736a, 0x7445f472,
+ 0x35ce0949, 0x74246f9c, 0x3616b14c, 0x7402ab37, 0x365f6af0, 0x73e0a727, 0x36a835b5, 0x73be6350,
+ 0x36f11118, 0x739bdf95, 0x3739fc98, 0x73791bdd, 0x3782f7b2, 0x7356180e, 0x37cc01e3, 0x7332d410,
+ 0x38151aa8, 0x730f4fc9, 0x385e417e, 0x72eb8b24, 0x38a775e1, 0x72c7860a, 0x38f0b74d, 0x72a34066,
+ 0x393a053e, 0x727eba24, 0x39835f30, 0x7259f331, 0x39ccc49e, 0x7234eb79, 0x3a163503, 0x720fa2eb,
+ 0x3a5fafda, 0x71ea1977, 0x3aa9349e, 0x71c44f0c, 0x3af2c2ca, 0x719e439d, 0x3b3c59d7, 0x7177f71a,
+ 0x3b85f940, 0x71516978, 0x3bcfa07e, 0x712a9aaa, 0x3c194f0d, 0x71038aa4, 0x3c630464, 0x70dc395e,
+ 0x3cacbfff, 0x70b4a6cd, 0x3cf68155, 0x708cd2e9, 0x3d4047e1, 0x7064bdab, 0x3d8a131c, 0x703c670d,
+ 0x3dd3e27e, 0x7013cf0a, 0x3e1db580, 0x6feaf59c, 0x3e678b9b, 0x6fc1dac1, 0x3eb16449, 0x6f987e76,
+ 0x3efb3f01, 0x6f6ee0b9, 0x3f451b3d, 0x6f45018b, 0x3f8ef874, 0x6f1ae0eb, 0x3fd8d620, 0x6ef07edb,
+ 0x4022b3b9, 0x6ec5db5d, 0x406c90b7, 0x6e9af675, 0x40b66c93, 0x6e6fd027, 0x410046c5, 0x6e446879,
+ 0x414a1ec6, 0x6e18bf71, 0x4193f40d, 0x6decd517, 0x41ddc615, 0x6dc0a972, 0x42279455, 0x6d943c8d,
+ 0x42715e45, 0x6d678e71, 0x42bb235f, 0x6d3a9f2a, 0x4304e31a, 0x6d0d6ec5, 0x434e9cf1, 0x6cdffd4f,
+ 0x4398505b, 0x6cb24ad6, 0x43e1fcd1, 0x6c84576b, 0x442ba1cd, 0x6c56231c, 0x44753ec7, 0x6c27adfd,
+ 0x44bed33a, 0x6bf8f81e, 0x45085e9d, 0x6bca0195, 0x4551e06b, 0x6b9aca75, 0x459b581e, 0x6b6b52d5,
+ 0x45e4c52f, 0x6b3b9ac9, 0x462e2717, 0x6b0ba26b, 0x46777d52, 0x6adb69d3, 0x46c0c75a, 0x6aaaf11b,
+ 0x470a04a9, 0x6a7a385c, 0x475334b9, 0x6a493fb3, 0x479c5707, 0x6a18073d, 0x47e56b0c, 0x69e68f17,
+ 0x482e7045, 0x69b4d761, 0x4877662c, 0x6982e039, 0x48c04c3f, 0x6950a9c0, 0x490921f8, 0x691e341a,
+ 0x4951e6d5, 0x68eb7f67, 0x499a9a51, 0x68b88bcd, 0x49e33beb, 0x68855970, 0x4a2bcb1f, 0x6851e875,
+ 0x4a74476b, 0x681e3905, 0x4abcb04c, 0x67ea4b47, 0x4b050541, 0x67b61f63, 0x4b4d45c9, 0x6781b585,
+ 0x4b957162, 0x674d0dd6, 0x4bdd878c, 0x67182883, 0x4c2587c6, 0x66e305b8, 0x4c6d7190, 0x66ada5a5,
+ 0x4cb5446a, 0x66780878, 0x4cfcffd5, 0x66422e60, 0x4d44a353, 0x660c1790, 0x4d8c2e64, 0x65d5c439,
+ 0x4dd3a08c, 0x659f348e, 0x4e1af94b, 0x656868c3, 0x4e623825, 0x6531610d, 0x4ea95c9d, 0x64fa1da3,
+ 0x4ef06637, 0x64c29ebb, 0x4f375477, 0x648ae48d, 0x4f7e26e1, 0x6452ef53, 0x4fc4dcfb, 0x641abf46,
+ 0x500b7649, 0x63e254a2, 0x5051f253, 0x63a9afa2, 0x5098509f, 0x6370d083, 0x50de90b3, 0x6337b784,
+ 0x5124b218, 0x62fe64e3, 0x516ab455, 0x62c4d8e0, 0x51b096f3, 0x628b13bc, 0x51f6597b, 0x625115b8,
+ 0x523bfb78, 0x6216df18, 0x52817c72, 0x61dc701f, 0x52c6dbf5, 0x61a1c912, 0x530c198d, 0x6166ea36,
+ 0x535134c5, 0x612bd3d2, 0x53962d2a, 0x60f0862d, 0x53db024a, 0x60b50190, 0x541fb3b1, 0x60794644,
+ 0x546440ef, 0x603d5494, 0x54a8a992, 0x60012cca, 0x54eced2b, 0x5fc4cf33, 0x55310b48, 0x5f883c1c,
+ 0x5575037c, 0x5f4b73d2, 0x55b8d558, 0x5f0e76a5, 0x55fc806f, 0x5ed144e5, 0x56400452, 0x5e93dee1,
+ 0x56836096, 0x5e5644ec, 0x56c694cf, 0x5e187757, 0x5709a092, 0x5dda7677, 0x574c8374, 0x5d9c429f,
+ 0x578f3d0d, 0x5d5ddc24, 0x57d1ccf2, 0x5d1f435d, 0x581432bd, 0x5ce078a0, 0x58566e04, 0x5ca17c45,
+ 0x58987e63, 0x5c624ea4, 0x58da6372, 0x5c22f016, 0x591c1ccc, 0x5be360f6, 0x595daa0d, 0x5ba3a19f,
+ 0x599f0ad1, 0x5b63b26c, 0x59e03eb6, 0x5b2393ba, 0x5a214558, 0x5ae345e7, 0x5a621e56, 0x5aa2c951,
+};
+
+
+
+/* bit reverse tables for FFT */
+
+const int bitrevtabOffset[NUM_IMDCT_SIZES] = {0, 17};
+
+const unsigned char bitrevtab[17 + 129] = {
+ /* nfft = 64 */
+ 0x01, 0x08, 0x02, 0x04, 0x03, 0x0c, 0x05, 0x0a, 0x07, 0x0e, 0x0b, 0x0d, 0x00, 0x06, 0x09, 0x0f,
+ 0x00,
+
+ /* nfft = 512 */
+ 0x01, 0x40, 0x02, 0x20, 0x03, 0x60, 0x04, 0x10, 0x05, 0x50, 0x06, 0x30, 0x07, 0x70, 0x09, 0x48,
+ 0x0a, 0x28, 0x0b, 0x68, 0x0c, 0x18, 0x0d, 0x58, 0x0e, 0x38, 0x0f, 0x78, 0x11, 0x44, 0x12, 0x24,
+ 0x13, 0x64, 0x15, 0x54, 0x16, 0x34, 0x17, 0x74, 0x19, 0x4c, 0x1a, 0x2c, 0x1b, 0x6c, 0x1d, 0x5c,
+ 0x1e, 0x3c, 0x1f, 0x7c, 0x21, 0x42, 0x23, 0x62, 0x25, 0x52, 0x26, 0x32, 0x27, 0x72, 0x29, 0x4a,
+ 0x2b, 0x6a, 0x2d, 0x5a, 0x2e, 0x3a, 0x2f, 0x7a, 0x31, 0x46, 0x33, 0x66, 0x35, 0x56, 0x37, 0x76,
+ 0x39, 0x4e, 0x3b, 0x6e, 0x3d, 0x5e, 0x3f, 0x7e, 0x43, 0x61, 0x45, 0x51, 0x47, 0x71, 0x4b, 0x69,
+ 0x4d, 0x59, 0x4f, 0x79, 0x53, 0x65, 0x57, 0x75, 0x5b, 0x6d, 0x5f, 0x7d, 0x67, 0x73, 0x6f, 0x7b,
+ 0x00, 0x08, 0x14, 0x1c, 0x22, 0x2a, 0x36, 0x3e, 0x41, 0x49, 0x55, 0x5d, 0x63, 0x6b, 0x77, 0x7f,
+ 0x00,
+
+};
+
+const unsigned char uniqueIDTab[8] = {0x5f, 0x4b, 0x43, 0x5f, 0x5f, 0x4a, 0x52, 0x5f};
+
+/* Twiddle tables for FFT
+ * format = Q30
+ *
+ * for (k = 4; k <= N/4; k <<= 1) {
+ * for (j = 0; j < k; j++) {
+ * double wr1, wi1, wr2, wi2, wr3, wi3;
+ *
+ * wr1 = cos(1.0 * M_PI * j / (2*k));
+ * wi1 = sin(1.0 * M_PI * j / (2*k));
+ * wr1 = (wr1 + wi1);
+ * wi1 = -wi1;
+ *
+ * wr2 = cos(2.0 * M_PI * j / (2*k));
+ * wi2 = sin(2.0 * M_PI * j / (2*k));
+ * wr2 = (wr2 + wi2);
+ * wi2 = -wi2;
+ *
+ * wr3 = cos(3.0 * M_PI * j / (2*k));
+ * wi3 = sin(3.0 * M_PI * j / (2*k));
+ * wr3 = (wr3 + wi3);
+ * wi3 = -wi3;
+ *
+ * if (k & 0xaaaaaaaa) {
+ * w_odd[iodd++] = (float)wr2;
+ * w_odd[iodd++] = (float)wi2;
+ * w_odd[iodd++] = (float)wr1;
+ * w_odd[iodd++] = (float)wi1;
+ * w_odd[iodd++] = (float)wr3;
+ * w_odd[iodd++] = (float)wi3;
+ * } else {
+ * w_even[ieven++] = (float)wr2;
+ * w_even[ieven++] = (float)wi2;
+ * w_even[ieven++] = (float)wr1;
+ * w_even[ieven++] = (float)wi1;
+ * w_even[ieven++] = (float)wr3;
+ * w_even[ieven++] = (float)wi3;
+ * }
+ * }
+ * }
+ */
+const int twidTabOdd[8 * 6 + 32 * 6 + 128 * 6] = {
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x539eba45, 0xe7821d59,
+ 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59,
+ 0x539eba45, 0xc4df2862, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x22a2f4f8, 0xc4df2862,
+ 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862,
+ 0xac6145bb, 0x187de2a7, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52,
+
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x45f704f7, 0xf9ba1651,
+ 0x43103085, 0xfcdc1342, 0x48b2b335, 0xf69bf7c9, 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651,
+ 0x4fd288dc, 0xed6bf9d1, 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9, 0x553805f2, 0xe4a2eff6,
+ 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x569cc31b, 0xe1d4a2c8,
+ 0x4da1fab5, 0xf0730342, 0x5a6690ae, 0xd5052d97, 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1,
+ 0x5a12e720, 0xce86ff2a, 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a, 0x57cc15bc, 0xc91af976,
+ 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a12e720, 0xce86ff2a,
+ 0x553805f2, 0xe4a2eff6, 0x4da1fab5, 0xc1eb0209, 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8,
+ 0x45f704f7, 0xc04ee4b8, 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce, 0x3cc85709, 0xc013bc39,
+ 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x4fd288dc, 0xc2c17d52,
+ 0x5987b08a, 0xd9e01006, 0x26b2a794, 0xc3bdbdf6, 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6,
+ 0x1a4608ab, 0xc78e9a1d, 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97, 0x0d47d096, 0xcc983f70,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x396b3199, 0xc04ee4b8,
+ 0x5a6690ae, 0xd09441bb, 0xf2b82f6a, 0xd9e01006, 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a,
+ 0xe5b9f755, 0xe1d4a2c8, 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70, 0xd94d586c, 0xea70658a,
+ 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x1a4608ab, 0xc78e9a1d,
+ 0x57cc15bc, 0xc91af976, 0xc337a8f7, 0xfcdc1342, 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d,
+ 0xba08fb09, 0x0645e9af, 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18, 0xb25e054b, 0x0f8cfcbe,
+ 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xf720e574, 0xd76619b6,
+ 0x51d1dc80, 0xc3bdbdf6, 0xa833ea44, 0x20e70f32, 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52,
+ 0xa5ed18e0, 0x2899e64a, 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209, 0xa5996f52, 0x2f6bbe45,
+ 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xd5558381, 0xed6bf9d1,
+ 0x48b2b335, 0xc0b15502, 0xaac7fa0e, 0x39daf5e8, 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8,
+ 0xb02d7724, 0x3d3e82ae, 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39, 0xb74d4ccb, 0x3f4eaafe,
+
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x418d2621, 0xfe6deaa1,
+ 0x40c7d2bd, 0xff36f170, 0x424ff28f, 0xfda4f351, 0x43103085, 0xfcdc1342, 0x418d2621, 0xfe6deaa1,
+ 0x4488e37f, 0xfb4ab7db, 0x4488e37f, 0xfb4ab7db, 0x424ff28f, 0xfda4f351, 0x46aa0d6d, 0xf8f21e8e,
+ 0x45f704f7, 0xf9ba1651, 0x43103085, 0xfcdc1342, 0x48b2b335, 0xf69bf7c9, 0x475a5c77, 0xf82a6c6a,
+ 0x43cdd89a, 0xfc135231, 0x4aa22036, 0xf4491311, 0x48b2b335, 0xf69bf7c9, 0x4488e37f, 0xfb4ab7db,
+ 0x4c77a88e, 0xf1fa3ecb, 0x49ffd417, 0xf50ef5de, 0x454149fc, 0xfa824bfd, 0x4e32a956, 0xefb047f2,
+ 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x4c77a88e, 0xf1fa3ecb,
+ 0x46aa0d6d, 0xf8f21e8e, 0x5156b6d9, 0xeb2e1dbe, 0x4da1fab5, 0xf0730342, 0x475a5c77, 0xf82a6c6a,
+ 0x52beac9f, 0xe8f77acf, 0x4ec05432, 0xeeee2d9d, 0x4807eb4b, 0xf7630799, 0x5409ed4b, 0xe6c8d59c,
+ 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9, 0x553805f2, 0xe4a2eff6, 0x50d86e6d, 0xebeca36c,
+ 0x495aada2, 0xf5d544a7, 0x56488dc5, 0xe28688a4, 0x51d1dc80, 0xea70658a, 0x49ffd417, 0xf50ef5de,
+ 0x573b2635, 0xe0745b24, 0x52beac9f, 0xe8f77acf, 0x4aa22036, 0xf4491311, 0x580f7b19, 0xde6d1f65,
+ 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5471e2e6, 0xe61086bc,
+ 0x4bde1089, 0xf2beafed, 0x595c3e2a, 0xda8249b4, 0x553805f2, 0xe4a2eff6, 0x4c77a88e, 0xf1fa3ecb,
+ 0x59d438e5, 0xd8a00bae, 0x55f104dc, 0xe3399167, 0x4d0e4de2, 0xf136580d, 0x5a2d0957, 0xd6cb76c9,
+ 0x569cc31b, 0xe1d4a2c8, 0x4da1fab5, 0xf0730342, 0x5a6690ae, 0xd5052d97, 0x573b2635, 0xe0745b24,
+ 0x4e32a956, 0xefb047f2, 0x5a80baf6, 0xd34dcdb4, 0x57cc15bc, 0xdf18f0ce, 0x4ec05432, 0xeeee2d9d,
+ 0x5a7b7f1a, 0xd1a5ef90, 0x584f7b58, 0xddc29958, 0x4f4af5d1, 0xee2cbbc1, 0x5a56deec, 0xd00e2639,
+ 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a, 0x592d59da, 0xdb25f566,
+ 0x50570819, 0xecabef3d, 0x59afaf4c, 0xcd110216, 0x5987b08a, 0xd9e01006, 0x50d86e6d, 0xebeca36c,
+ 0x592d59da, 0xcbacb0bf, 0x59d438e5, 0xd8a00bae, 0x5156b6d9, 0xeb2e1dbe, 0x588c1404, 0xca5a86c4,
+ 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a, 0x57cc15bc, 0xc91af976, 0x5a43b190, 0xd6326a88,
+ 0x5249daa2, 0xe9b38223, 0x56eda1a0, 0xc7ee77b3, 0x5a6690ae, 0xd5052d97, 0x52beac9f, 0xe8f77acf,
+ 0x55f104dc, 0xc6d569be, 0x5a7b7f1a, 0xd3de9156, 0x53304df6, 0xe83c56cf, 0x54d69714, 0xc5d03118,
+ 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a7b7f1a, 0xd1a5ef90,
+ 0x5409ed4b, 0xe6c8d59c, 0x5249daa2, 0xc402a33c, 0x5a6690ae, 0xd09441bb, 0x5471e2e6, 0xe61086bc,
+ 0x50d86e6d, 0xc33aee27, 0x5a43b190, 0xcf89e3e8, 0x54d69714, 0xe55937d5, 0x4f4af5d1, 0xc2884e6e,
+ 0x5a12e720, 0xce86ff2a, 0x553805f2, 0xe4a2eff6, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xcd8bbb6d,
+ 0x55962bc0, 0xe3edb628, 0x4bde1089, 0xc1633f8a, 0x5987b08a, 0xcc983f70, 0x55f104dc, 0xe3399167,
+ 0x49ffd417, 0xc0f1360b, 0x592d59da, 0xcbacb0bf, 0x56488dc5, 0xe28688a4, 0x4807eb4b, 0xc0950d1d,
+ 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x584f7b58, 0xc9edeb50,
+ 0x56eda1a0, 0xe123e6ad, 0x43cdd89a, 0xc01ed535, 0x57cc15bc, 0xc91af976, 0x573b2635, 0xe0745b24,
+ 0x418d2621, 0xc004ef3f, 0x573b2635, 0xc8507ea7, 0x57854ddd, 0xdfc606f1, 0x3f35b59d, 0xc0013bd3,
+ 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce, 0x3cc85709, 0xc013bc39, 0x55f104dc, 0xc6d569be,
+ 0x580f7b19, 0xde6d1f65, 0x3a45e1f7, 0xc03c6a07, 0x553805f2, 0xc6250a18, 0x584f7b58, 0xddc29958,
+ 0x37af354c, 0xc07b371e, 0x5471e2e6, 0xc57d965d, 0x588c1404, 0xdd196538, 0x350536f1, 0xc0d00db6,
+ 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x52beac9f, 0xc449d892,
+ 0x58fb0568, 0xdbcb0cce, 0x2f7afdfc, 0xc1bb5a11, 0x51d1dc80, 0xc3bdbdf6, 0x592d59da, 0xdb25f566,
+ 0x2c9caf6c, 0xc2517e31, 0x50d86e6d, 0xc33aee27, 0x595c3e2a, 0xda8249b4, 0x29aee694, 0xc2fd08a9,
+ 0x4fd288dc, 0xc2c17d52, 0x5987b08a, 0xd9e01006, 0x26b2a794, 0xc3bdbdf6, 0x4ec05432, 0xc2517e31,
+ 0x59afaf4c, 0xd93f4e9e, 0x23a8fb93, 0xc4935b3c, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xd8a00bae,
+ 0x2092f05f, 0xc57d965d, 0x4c77a88e, 0xc18e18a7, 0x59f54bee, 0xd8024d59, 0x1d719810, 0xc67c1e18,
+ 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d, 0x49ffd417, 0xc0f1360b,
+ 0x5a2d0957, 0xd6cb76c9, 0x17115bc0, 0xc8b4ab32, 0x48b2b335, 0xc0b15502, 0x5a43b190, 0xd6326a88,
+ 0x13d4ae08, 0xc9edeb50, 0x475a5c77, 0xc07b371e, 0x5a56deec, 0xd59afadb, 0x10911f04, 0xcb39edca,
+ 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97, 0x0d47d096, 0xcc983f70, 0x4488e37f, 0xc02c64a6,
+ 0x5a72c63b, 0xd4710883, 0x09f9e6a1, 0xce0866b8, 0x43103085, 0xc013bc39, 0x5a7b7f1a, 0xd3de9156,
+ 0x06a886a0, 0xcf89e3e8, 0x418d2621, 0xc004ef3f, 0x5a80baf6, 0xd34dcdb4, 0x0354d741, 0xd11c3142,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3e68fb62, 0xc004ef3f,
+ 0x5a80baf6, 0xd2317756, 0xfcab28bf, 0xd4710883, 0x3cc85709, 0xc013bc39, 0x5a7b7f1a, 0xd1a5ef90,
+ 0xf9577960, 0xd6326a88, 0x3b1e5335, 0xc02c64a6, 0x5a72c63b, 0xd11c3142, 0xf606195f, 0xd8024d59,
+ 0x396b3199, 0xc04ee4b8, 0x5a6690ae, 0xd09441bb, 0xf2b82f6a, 0xd9e01006, 0x37af354c, 0xc07b371e,
+ 0x5a56deec, 0xd00e2639, 0xef6ee0fc, 0xdbcb0cce, 0x35eaa2c7, 0xc0b15502, 0x5a43b190, 0xcf89e3e8,
+ 0xec2b51f8, 0xddc29958, 0x341dbfd3, 0xc0f1360b, 0x5a2d0957, 0xcf077fe1, 0xe8eea440, 0xdfc606f1,
+ 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x306c2624, 0xc18e18a7,
+ 0x59f54bee, 0xce0866b8, 0xe28e67f0, 0xe3edb628, 0x2e88013a, 0xc1eb0209, 0x59d438e5, 0xcd8bbb6d,
+ 0xdf6d0fa1, 0xe61086bc, 0x2c9caf6c, 0xc2517e31, 0x59afaf4c, 0xcd110216, 0xdc57046d, 0xe83c56cf,
+ 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70, 0xd94d586c, 0xea70658a, 0x28b1b544, 0xc33aee27,
+ 0x595c3e2a, 0xcc217822, 0xd651196c, 0xecabef3d, 0x26b2a794, 0xc3bdbdf6, 0x592d59da, 0xcbacb0bf,
+ 0xd3635094, 0xeeee2d9d, 0x24ada23d, 0xc449d892, 0x58fb0568, 0xcb39edca, 0xd0850204, 0xf136580d,
+ 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x2092f05f, 0xc57d965d,
+ 0x588c1404, 0xca5a86c4, 0xcafac90f, 0xf5d544a7, 0x1e7de5df, 0xc6250a18, 0x584f7b58, 0xc9edeb50,
+ 0xc850cab4, 0xf82a6c6a, 0x1c6427a9, 0xc6d569be, 0x580f7b19, 0xc9836582, 0xc5ba1e09, 0xfa824bfd,
+ 0x1a4608ab, 0xc78e9a1d, 0x57cc15bc, 0xc91af976, 0xc337a8f7, 0xfcdc1342, 0x1823dc7d, 0xc8507ea7,
+ 0x57854ddd, 0xc8b4ab32, 0xc0ca4a63, 0xff36f170, 0x15fdf758, 0xc91af976, 0x573b2635, 0xc8507ea7,
+ 0xbe72d9df, 0x0192155f, 0x13d4ae08, 0xc9edeb50, 0x56eda1a0, 0xc7ee77b3, 0xbc322766, 0x03ecadcf,
+ 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af, 0x0f7944a7, 0xcbacb0bf,
+ 0x56488dc5, 0xc730e997, 0xb7f814b5, 0x089cf867, 0x0d47d096, 0xcc983f70, 0x55f104dc, 0xc6d569be,
+ 0xb6002be9, 0x0af10a22, 0x0b145041, 0xcd8bbb6d, 0x55962bc0, 0xc67c1e18, 0xb421ef77, 0x0d415013,
+ 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18, 0xb25e054b, 0x0f8cfcbe, 0x06a886a0, 0xcf89e3e8,
+ 0x54d69714, 0xc5d03118, 0xb0b50a2f, 0x11d3443f, 0x0470ebdc, 0xd09441bb, 0x5471e2e6, 0xc57d965d,
+ 0xaf279193, 0x14135c94, 0x0238a1c6, 0xd1a5ef90, 0x5409ed4b, 0xc52d3d18, 0xadb6255e, 0x164c7ddd,
+ 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xfdc75e3a, 0xd3de9156,
+ 0x53304df6, 0xc4935b3c, 0xab2968ec, 0x1aa6c82b, 0xfb8f1424, 0xd5052d97, 0x52beac9f, 0xc449d892,
+ 0xaa0efb24, 0x1cc66e99, 0xf9577960, 0xd6326a88, 0x5249daa2, 0xc402a33c, 0xa9125e60, 0x1edc1953,
+ 0xf720e574, 0xd76619b6, 0x51d1dc80, 0xc3bdbdf6, 0xa833ea44, 0x20e70f32, 0xf4ebafbf, 0xd8a00bae,
+ 0x5156b6d9, 0xc37b2b6a, 0xa773ebfc, 0x22e69ac8, 0xf2b82f6a, 0xd9e01006, 0x50d86e6d, 0xc33aee27,
+ 0xa6d2a626, 0x24da0a9a, 0xf086bb59, 0xdb25f566, 0x50570819, 0xc2fd08a9, 0xa65050b4, 0x26c0b162,
+ 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xec2b51f8, 0xddc29958,
+ 0x4f4af5d1, 0xc2884e6e, 0xa5a92114, 0x2a650525, 0xea0208a8, 0xdf18f0ce, 0x4ec05432, 0xc2517e31,
+ 0xa58480e6, 0x2c216eaa, 0xe7dc2383, 0xe0745b24, 0x4e32a956, 0xc21d0eb8, 0xa57f450a, 0x2dce88aa,
+ 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209, 0xa5996f52, 0x2f6bbe45, 0xe39bd857, 0xe3399167,
+ 0x4d0e4de2, 0xc1bb5a11, 0xa5d2f6a9, 0x30f8801f, 0xe1821a21, 0xe4a2eff6, 0x4c77a88e, 0xc18e18a7,
+ 0xa62bc71b, 0x32744493, 0xdf6d0fa1, 0xe61086bc, 0x4bde1089, 0xc1633f8a, 0xa6a3c1d6, 0x33de87de,
+ 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xdb525dc3, 0xe8f77acf,
+ 0x4aa22036, 0xc114ccb9, 0xa7f084e7, 0x367c9a7e, 0xd94d586c, 0xea70658a, 0x49ffd417, 0xc0f1360b,
+ 0xa8c4d9cb, 0x37af8159, 0xd74e4abc, 0xebeca36c, 0x495aada2, 0xc0d00db6, 0xa9b7723b, 0x38cf1669,
+ 0xd5558381, 0xed6bf9d1, 0x48b2b335, 0xc0b15502, 0xaac7fa0e, 0x39daf5e8, 0xd3635094, 0xeeee2d9d,
+ 0x4807eb4b, 0xc0950d1d, 0xabf612b5, 0x3ad2c2e8, 0xd177fec6, 0xf0730342, 0x475a5c77, 0xc07b371e,
+ 0xad415361, 0x3bb6276e, 0xcf93d9dc, 0xf1fa3ecb, 0x46aa0d6d, 0xc063d405, 0xaea94927, 0x3c84d496,
+ 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae, 0xcbe2402d, 0xf50ef5de,
+ 0x454149fc, 0xc03c6a07, 0xb1cd56aa, 0x3de2f148, 0xca155d39, 0xf69bf7c9, 0x4488e37f, 0xc02c64a6,
+ 0xb3885772, 0x3e71e759, 0xc850cab4, 0xf82a6c6a, 0x43cdd89a, 0xc01ed535, 0xb55ddfca, 0x3eeb3347,
+ 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39, 0xb74d4ccb, 0x3f4eaafe, 0xc4e1accb, 0xfb4ab7db,
+ 0x424ff28f, 0xc00b1a20, 0xb955f293, 0x3f9c2bfb, 0xc337a8f7, 0xfcdc1342, 0x418d2621, 0xc004ef3f,
+ 0xbb771c81, 0x3fd39b5a, 0xc197049e, 0xfe6deaa1, 0x40c7d2bd, 0xc0013bd3, 0xbdb00d71, 0x3ff4e5e0,
+};
+
+const int twidTabEven[4 * 6 + 16 * 6 + 64 * 6] = {
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x5a82799a, 0xd2bec333,
+ 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333,
+ 0x00000000, 0xd2bec333, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7,
+
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x4b418bbe, 0xf383a3e2,
+ 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2,
+ 0x58c542c5, 0xdc71898d, 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a,
+ 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xcac933ae,
+ 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d,
+ 0x3248d382, 0xc13ad060, 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3248d382, 0xc13ad060,
+ 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae,
+ 0xcdb72c7e, 0xf383a3e2, 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af,
+ 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xee57aa21, 0xdc71898d,
+ 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060,
+ 0xa73abd3b, 0x3536cc52, 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae,
+
+ 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x43103085, 0xfcdc1342,
+ 0x418d2621, 0xfe6deaa1, 0x4488e37f, 0xfb4ab7db, 0x45f704f7, 0xf9ba1651, 0x43103085, 0xfcdc1342,
+ 0x48b2b335, 0xf69bf7c9, 0x48b2b335, 0xf69bf7c9, 0x4488e37f, 0xfb4ab7db, 0x4c77a88e, 0xf1fa3ecb,
+ 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x4da1fab5, 0xf0730342,
+ 0x475a5c77, 0xf82a6c6a, 0x52beac9f, 0xe8f77acf, 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9,
+ 0x553805f2, 0xe4a2eff6, 0x51d1dc80, 0xea70658a, 0x49ffd417, 0xf50ef5de, 0x573b2635, 0xe0745b24,
+ 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x553805f2, 0xe4a2eff6,
+ 0x4c77a88e, 0xf1fa3ecb, 0x59d438e5, 0xd8a00bae, 0x569cc31b, 0xe1d4a2c8, 0x4da1fab5, 0xf0730342,
+ 0x5a6690ae, 0xd5052d97, 0x57cc15bc, 0xdf18f0ce, 0x4ec05432, 0xeeee2d9d, 0x5a7b7f1a, 0xd1a5ef90,
+ 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a, 0x5987b08a, 0xd9e01006,
+ 0x50d86e6d, 0xebeca36c, 0x592d59da, 0xcbacb0bf, 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a,
+ 0x57cc15bc, 0xc91af976, 0x5a6690ae, 0xd5052d97, 0x52beac9f, 0xe8f77acf, 0x55f104dc, 0xc6d569be,
+ 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a6690ae, 0xd09441bb,
+ 0x5471e2e6, 0xe61086bc, 0x50d86e6d, 0xc33aee27, 0x5a12e720, 0xce86ff2a, 0x553805f2, 0xe4a2eff6,
+ 0x4da1fab5, 0xc1eb0209, 0x5987b08a, 0xcc983f70, 0x55f104dc, 0xe3399167, 0x49ffd417, 0xc0f1360b,
+ 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x57cc15bc, 0xc91af976,
+ 0x573b2635, 0xe0745b24, 0x418d2621, 0xc004ef3f, 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce,
+ 0x3cc85709, 0xc013bc39, 0x553805f2, 0xc6250a18, 0x584f7b58, 0xddc29958, 0x37af354c, 0xc07b371e,
+ 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x51d1dc80, 0xc3bdbdf6,
+ 0x592d59da, 0xdb25f566, 0x2c9caf6c, 0xc2517e31, 0x4fd288dc, 0xc2c17d52, 0x5987b08a, 0xd9e01006,
+ 0x26b2a794, 0xc3bdbdf6, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xd8a00bae, 0x2092f05f, 0xc57d965d,
+ 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d, 0x48b2b335, 0xc0b15502,
+ 0x5a43b190, 0xd6326a88, 0x13d4ae08, 0xc9edeb50, 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97,
+ 0x0d47d096, 0xcc983f70, 0x43103085, 0xc013bc39, 0x5a7b7f1a, 0xd3de9156, 0x06a886a0, 0xcf89e3e8,
+ 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3cc85709, 0xc013bc39,
+ 0x5a7b7f1a, 0xd1a5ef90, 0xf9577960, 0xd6326a88, 0x396b3199, 0xc04ee4b8, 0x5a6690ae, 0xd09441bb,
+ 0xf2b82f6a, 0xd9e01006, 0x35eaa2c7, 0xc0b15502, 0x5a43b190, 0xcf89e3e8, 0xec2b51f8, 0xddc29958,
+ 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x2e88013a, 0xc1eb0209,
+ 0x59d438e5, 0xcd8bbb6d, 0xdf6d0fa1, 0xe61086bc, 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70,
+ 0xd94d586c, 0xea70658a, 0x26b2a794, 0xc3bdbdf6, 0x592d59da, 0xcbacb0bf, 0xd3635094, 0xeeee2d9d,
+ 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x1e7de5df, 0xc6250a18,
+ 0x584f7b58, 0xc9edeb50, 0xc850cab4, 0xf82a6c6a, 0x1a4608ab, 0xc78e9a1d, 0x57cc15bc, 0xc91af976,
+ 0xc337a8f7, 0xfcdc1342, 0x15fdf758, 0xc91af976, 0x573b2635, 0xc8507ea7, 0xbe72d9df, 0x0192155f,
+ 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af, 0x0d47d096, 0xcc983f70,
+ 0x55f104dc, 0xc6d569be, 0xb6002be9, 0x0af10a22, 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18,
+ 0xb25e054b, 0x0f8cfcbe, 0x0470ebdc, 0xd09441bb, 0x5471e2e6, 0xc57d965d, 0xaf279193, 0x14135c94,
+ 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xfb8f1424, 0xd5052d97,
+ 0x52beac9f, 0xc449d892, 0xaa0efb24, 0x1cc66e99, 0xf720e574, 0xd76619b6, 0x51d1dc80, 0xc3bdbdf6,
+ 0xa833ea44, 0x20e70f32, 0xf2b82f6a, 0xd9e01006, 0x50d86e6d, 0xc33aee27, 0xa6d2a626, 0x24da0a9a,
+ 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xea0208a8, 0xdf18f0ce,
+ 0x4ec05432, 0xc2517e31, 0xa58480e6, 0x2c216eaa, 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209,
+ 0xa5996f52, 0x2f6bbe45, 0xe1821a21, 0xe4a2eff6, 0x4c77a88e, 0xc18e18a7, 0xa62bc71b, 0x32744493,
+ 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xd94d586c, 0xea70658a,
+ 0x49ffd417, 0xc0f1360b, 0xa8c4d9cb, 0x37af8159, 0xd5558381, 0xed6bf9d1, 0x48b2b335, 0xc0b15502,
+ 0xaac7fa0e, 0x39daf5e8, 0xd177fec6, 0xf0730342, 0x475a5c77, 0xc07b371e, 0xad415361, 0x3bb6276e,
+ 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae, 0xca155d39, 0xf69bf7c9,
+ 0x4488e37f, 0xc02c64a6, 0xb3885772, 0x3e71e759, 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39,
+ 0xb74d4ccb, 0x3f4eaafe, 0xc337a8f7, 0xfcdc1342, 0x418d2621, 0xc004ef3f, 0xbb771c81, 0x3fd39b5a,
+};
+
+/* for reference, here's the code to generate the bitreverse tables
+ short blocks: nbits = 4 (nfft = 64)
+ long blocks: nbits = 7 (nfft = 512)
+
+static int bitrev(int n, int nbits)
+{
+ int r, i;
+
+ r = 0;
+ for (i = 0; i < nbits; i++) {
+ r <<= 1;
+ r |= (n & 1);
+ n >>= 1;
+ }
+
+ return r;
+}
+
+static void InitBitrevTable(unsigned char *out, int nbits)
+{
+ int i, t;
+
+ for (i = 0; i < (1<<nbits); i++) {
+ / *** do not register the same transposition twice *** /
+ t = bitrev(i,nbits);
+ if (i < t) {
+ *out++ = (unsigned char)i;
+ *out++ = (unsigned char)t;
+ }
+ }
+
+ / *** no need to write a sentinel (or rather, the first entry in the
+ * table for symetric codes will be 0, which serves as the sentinel)
+ *** /
+ for (i = 0; i < (1<<nbits); i++) {
+ t = bitrev(i,nbits);
+ if (i == t) / *** symmetric codes get special treatment *** /
+ *out++ = (unsigned char)t;
+ }
+ *out++ = 0; / *** second sentinel is 0, again *** /
+}
+
+*/
+
+/* code to generate KBD window:
+static double CalcI0(double x)
+{
+ int k;
+ double i0, iTmp, iLast, x2, xPow, kFact;
+
+ x2 = x / 2.0;
+ i0 = 0.0;
+ k = 0;
+ kFact = 1;
+ xPow = 1;
+ do {
+ iLast = i0;
+ iTmp = xPow / kFact;
+ i0 += (iTmp*iTmp);
+ k++;
+ kFact *= k;
+ xPow *= x2;
+ } while (fabs(i0 - iLast) > KBD_THRESH);
+
+ return i0;
+}
+
+static double CalcW(double nRef, double n, double a)
+{
+ double i0Base, i0Curr, nTemp;
+
+ i0Base = CalcI0(M_PI * a);
+
+ nTemp = (n - nRef/4) / (nRef/4);
+ i0Curr = CalcI0( M_PI * a * sqrt(1.0 - nTemp*nTemp) );
+
+ return i0Curr / i0Base;
+}
+
+void InitKBDWindow(int nmdct)
+{
+ int n, nRef;
+ double a, wBase, wCurr;
+
+ nRef = nmdct * 2;
+
+ / *** kbd window *** /
+ if (nmdct == 128)
+ a = 6.0;
+ else
+ a = 4.0;
+
+ wBase = 0;
+ for (n = 0; n <= nRef/2; n++)
+ wBase += CalcW(nRef, n, a);
+
+ / *** left *** /
+ wCurr = 0;
+ for (n = 0; n < nRef/2; n++) {
+ wCurr += CalcW(nRef, n, a);
+ kbdWindowRef[n] = sqrt(wCurr / wBase);
+ }
+
+ / ***
+ * symmetry:
+ * kbd_right(n) = kbd_ldef(N_REF - 1 - n), n = [N_REF/2, N_REF - 1]
+ *
+ * wCurr = 0;
+ * for (n = N_REF-1; n >= N_REF/2; n--) {
+ * wCurr += CalcW(N_REF-n-1, a);
+ * kbdWindowRef[n] = sqrt(wCurr / wBase);
+ * }
+ *
+ *** /
+ return;
+}
+*/
diff --git a/audio_codec/wfd_aac_decoder/trigtabs_fltgen.c b/audio_codec/wfd_aac_decoder/trigtabs_fltgen.c
new file mode 100644
index 0000000..b5ffa8e
--- a/dev/null
+++ b/audio_codec/wfd_aac_decoder/trigtabs_fltgen.c
@@ -0,0 +1,357 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Source last modified: $Id: trigtabs_fltgen.c,v 1.2 2006/12/05 03:36:53 ehyche Exp $
+ *
+ * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
+ *
+ * The contents of this file, and the files included with this file,
+ * are subject to the current version of the RealNetworks Public
+ * Source License (the "RPSL") available at
+ * http://www.helixcommunity.org/content/rpsl unless you have licensed
+ * the file under the current version of the RealNetworks Community
+ * Source License (the "RCSL") available at
+ * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
+ * will apply. You may also obtain the license terms directly from
+ * RealNetworks. You may not use this file except in compliance with
+ * the RPSL or, if you have a valid RCSL with RealNetworks applicable
+ * to this file, the RCSL. Please see the applicable RPSL or RCSL for
+ * the rights, obligations and limitations governing use of the
+ * contents of the file.
+ *
+ * This file is part of the Helix DNA Technology. RealNetworks is the
+ * developer of the Original Code and owns the copyrights in the
+ * portions it created.
+ *
+ * This file, and the files included with this file, is distributed
+ * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
+ * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
+ * ENJOYMENT OR NON-INFRINGEMENT.
+ *
+ * Technology Compatibility Kit Test Suite(s) Location:
+ * http://www.helixcommunity.org/content/tck
+ *
+ * Contributor(s):
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**************************************************************************************
+ * Fixed-point HE-AAC decoder
+ * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
+ * June 2005
+ *
+ * trigtabs_fltgen.c - low-ROM alternative to trigtabs.c
+ * generates large trig tables at runtime using floating-point
+ * math library
+ * MUST VERIFY that runtime-generated tables are bit-exact matches
+ * with ROM tables in trigtabs.c
+ **************************************************************************************/
+#ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT
+
+#include <math.h>
+#include "coder.h"
+
+/* read-only tables */
+const int cos4sin4tabOffset[NUM_IMDCT_SIZES] = {0, 128};
+const int sinWindowOffset[NUM_IMDCT_SIZES] = {0, 128};
+const int kbdWindowOffset[NUM_IMDCT_SIZES] = {0, 128};
+const int bitrevtabOffset[NUM_IMDCT_SIZES] = {0, 17};
+const unsigned char bitrevtab[17 + 129] = {
+ /* nfft = 64 */
+ 0x01, 0x08, 0x02, 0x04, 0x03, 0x0c, 0x05, 0x0a, 0x07, 0x0e, 0x0b, 0x0d, 0x00, 0x06, 0x09, 0x0f,
+ 0x00,
+
+ /* nfft = 512 */
+ 0x01, 0x40, 0x02, 0x20, 0x03, 0x60, 0x04, 0x10, 0x05, 0x50, 0x06, 0x30, 0x07, 0x70, 0x09, 0x48,
+ 0x0a, 0x28, 0x0b, 0x68, 0x0c, 0x18, 0x0d, 0x58, 0x0e, 0x38, 0x0f, 0x78, 0x11, 0x44, 0x12, 0x24,
+ 0x13, 0x64, 0x15, 0x54, 0x16, 0x34, 0x17, 0x74, 0x19, 0x4c, 0x1a, 0x2c, 0x1b, 0x6c, 0x1d, 0x5c,
+ 0x1e, 0x3c, 0x1f, 0x7c, 0x21, 0x42, 0x23, 0x62, 0x25, 0x52, 0x26, 0x32, 0x27, 0x72, 0x29, 0x4a,
+ 0x2b, 0x6a, 0x2d, 0x5a, 0x2e, 0x3a, 0x2f, 0x7a, 0x31, 0x46, 0x33, 0x66, 0x35, 0x56, 0x37, 0x76,
+ 0x39, 0x4e, 0x3b, 0x6e, 0x3d, 0x5e, 0x3f, 0x7e, 0x43, 0x61, 0x45, 0x51, 0x47, 0x71, 0x4b, 0x69,
+ 0x4d, 0x59, 0x4f, 0x79, 0x53, 0x65, 0x57, 0x75, 0x5b, 0x6d, 0x5f, 0x7d, 0x67, 0x73, 0x6f, 0x7b,
+ 0x00, 0x08, 0x14, 0x1c, 0x22, 0x2a, 0x36, 0x3e, 0x41, 0x49, 0x55, 0x5d, 0x63, 0x6b, 0x77, 0x7f,
+ 0x00,
+
+};
+
+/* tables generated at runtime */
+int cos4sin4tab[128 + 1024];
+int cos1sin1tab[514];
+int sinWindow[128 + 1024];
+int kbdWindow[128 + 1024];
+int twidTabEven[4 * 6 + 16 * 6 + 64 * 6];
+int twidTabOdd[8 * 6 + 32 * 6 + 128 * 6];
+
+#define M_PI 3.14159265358979323846
+#define M2_30 1073741824.0
+#define M2_31 2147483648.0
+
+#define MAX_DBL 2147483647.0
+#define MIN_DBL -2147483648.0
+
+static int NormAndRound(double x, double q, double n)
+{
+ if (x >= 0.0) {
+ x = (x * q * n + 0.5);
+ } else {
+ x = (x * q * n - 0.5);
+ }
+
+ /* clip */
+ if (x > MAX_DBL) {
+ x = MAX_DBL;
+ }
+ if (x < MIN_DBL) {
+ x = MIN_DBL;
+ }
+
+ return (int)x;
+}
+
+static void Init_cos4sin4tab(int *tPtr, int nmdct)
+{
+ int i;
+ double angle1, angle2, invM, x1, x2, x3, x4;
+
+ invM = -1.0 / (double)nmdct;
+ for (i = 0; i < nmdct / 4; i++) {
+ angle1 = (i + 0.25) * M_PI / nmdct;
+ angle2 = (nmdct / 2 - 1 - i + 0.25) * M_PI / nmdct;
+
+ x1 = invM * (cos(angle1) + sin(angle1));
+ x2 = invM * sin(angle1);
+ x3 = invM * (cos(angle2) + sin(angle2));
+ x4 = invM * sin(angle2);
+
+ tPtr[0] = NormAndRound(x1, M2_30, nmdct);
+ tPtr[1] = NormAndRound(x2, M2_30, nmdct);
+ tPtr[2] = NormAndRound(x3, M2_30, nmdct);
+ tPtr[3] = NormAndRound(x4, M2_30, nmdct);
+ tPtr += 4;
+ }
+}
+
+static void Init_cos1sin1tab(int *tPtr)
+{
+ int i;
+ double angle, x1, x2;
+
+ for (i = 0; i <= (512 / 2); i++) {
+ angle = i * M_PI / 1024;
+ x1 = (cos(angle) + sin(angle));
+ x2 = sin(angle);
+
+ tPtr[0] = NormAndRound(x1, M2_30, 1);
+ tPtr[1] = NormAndRound(x2, M2_30, 1);
+ tPtr += 2;
+ }
+}
+
+static void Init_sinWindow(int *tPtr, int nmdct)
+{
+ int i;
+ double angle1, angle2, x1, x2;
+
+ for (i = 0; i < nmdct / 2; i++) {
+ angle1 = (i + 0.5) * M_PI / (2.0 * nmdct);
+ angle2 = (nmdct - 1 - i + 0.5) * M_PI / (2.0 * nmdct);
+ x1 = sin(angle1);
+ x2 = sin(angle2);
+
+ tPtr[0] = NormAndRound(x1, M2_31, 1);
+ tPtr[1] = NormAndRound(x2, M2_31, 1);
+ tPtr += 2;
+ }
+}
+
+
+#define KBD_THRESH 1e-12
+
+static double CalcI0(double x)
+{
+ int k;
+ double i0, iTmp, iLast, x2, xPow, kFact;
+
+ x2 = x / 2.0;
+ i0 = 0.0;
+ k = 0;
+ kFact = 1;
+ xPow = 1;
+ do {
+ iLast = i0;
+ iTmp = xPow / kFact;
+ i0 += (iTmp * iTmp);
+ k++;
+ kFact *= k;
+ xPow *= x2;
+ } while (fabs(i0 - iLast) > KBD_THRESH);
+
+ return i0;
+}
+
+static double CalcW(double nRef, double n, double a)
+{
+ double i0Base, i0Curr, nTemp;
+
+ i0Base = CalcI0(M_PI * a);
+
+ nTemp = (n - nRef / 4) / (nRef / 4);
+ i0Curr = CalcI0(M_PI * a * sqrt(1.0 - nTemp * nTemp));
+
+ return i0Curr / i0Base;
+}
+
+static void Init_kbdWindow(int *tPtr, int nmdct)
+{
+ int n, nRef;
+ double a, wBase, wCurr, x1;
+
+ nRef = nmdct * 2;
+
+ /* kbd window */
+ if (nmdct == 128) {
+ a = 6.0;
+ } else {
+ a = 4.0;
+ }
+
+ wBase = 0;
+ for (n = 0; n <= nRef / 2; n++) {
+ wBase += CalcW(nRef, n, a);
+ }
+
+ /* left */
+ wCurr = 0;
+ for (n = 0; n < nmdct / 2; n++) {
+ wCurr += CalcW(nRef, n, a);
+ x1 = sqrt(wCurr / wBase);
+ tPtr[0] = NormAndRound(x1, M2_31, 1);
+ tPtr += 2;
+ }
+ tPtr--;
+
+ /* right */
+ for (n = nmdct / 2; n < nmdct; n++) {
+ wCurr += CalcW(nRef, n, a);
+ x1 = sqrt(wCurr / wBase);
+ tPtr[0] = NormAndRound(x1, M2_31, 1);
+ tPtr -= 2;
+ }
+
+ /* symmetry:
+ * kbd_right(n) = kbd_ldef(N_REF - 1 - n), n = [N_REF/2, N_REF - 1]
+ *
+ * wCurr = 0;
+ * for (n = N_REF-1; n >= N_REF/2; n--) {
+ * wCurr += CalcW(N_REF-n-1, a);
+ * kbdWindowRef[n] = sqrt(wCurr / wBase);
+ * }
+ *
+ */
+ return;
+}
+
+static void Init_twidTabs(int *tPtrEven, int *tPtrOdd, int nfft)
+{
+ int j, k;
+ double wr1, wi1, wr2, wi2, wr3, wi3;
+
+ for (k = 4; k <= nfft / 4; k <<= 1) {
+ for (j = 0; j < k; j++) {
+ wr1 = cos(1.0 * M_PI * j / (2 * k));
+ wi1 = sin(1.0 * M_PI * j / (2 * k));
+ wr1 = (wr1 + wi1);
+ wi1 = -wi1;
+
+ wr2 = cos(2.0 * M_PI * j / (2 * k));
+ wi2 = sin(2.0 * M_PI * j / (2 * k));
+ wr2 = (wr2 + wi2);
+ wi2 = -wi2;
+
+ wr3 = cos(3.0 * M_PI * j / (2 * k));
+ wi3 = sin(3.0 * M_PI * j / (2 * k));
+ wr3 = (wr3 + wi3);
+ wi3 = -wi3;
+
+ if (k & 0xaaaaaaaa) {
+ tPtrOdd[0] = NormAndRound(wr2, M2_30, 1);
+ tPtrOdd[1] = NormAndRound(wi2, M2_30, 1);
+ tPtrOdd[2] = NormAndRound(wr1, M2_30, 1);
+ tPtrOdd[3] = NormAndRound(wi1, M2_30, 1);
+ tPtrOdd[4] = NormAndRound(wr3, M2_30, 1);
+ tPtrOdd[5] = NormAndRound(wi3, M2_30, 1);
+ tPtrOdd += 6;
+ } else {
+ tPtrEven[0] = NormAndRound(wr2, M2_30, 1);
+ tPtrEven[1] = NormAndRound(wi2, M2_30, 1);
+ tPtrEven[2] = NormAndRound(wr1, M2_30, 1);
+ tPtrEven[3] = NormAndRound(wi1, M2_30, 1);
+ tPtrEven[4] = NormAndRound(wr3, M2_30, 1);
+ tPtrEven[5] = NormAndRound(wi3, M2_30, 1);
+ tPtrEven += 6;
+ }
+ }
+ }
+}
+
+/**************************************************************************************
+ * Function: AACInitTrigtabsFloat
+ *
+ * Description: generate AAC decoder tables using floating-point math library
+ *
+ * Inputs: none
+ *
+ * Outputs: initialized tables
+ *
+ * Return: 0 on success
+ *
+ * Notes: this function should ONLY be called when double-precision
+ * floating-point math is supported
+ * the generated tables must be bit-exact matches with read-only
+ * tables stored in trigtabs.c
+ * this initializes global tables in RAM, and is NOT thread-safe,
+ * so the caller must ensure that this function is not called
+ * from multiple threads
+ * this should be called exactly once, before the entrypoint function
+ * for the application or DLL is called
+ **************************************************************************************/
+int AACInitTrigtabsFloat(void)
+{
+ /* cos4sin4tab */
+ Init_cos4sin4tab(cos4sin4tab + cos4sin4tabOffset[0], 128);
+ Init_cos4sin4tab(cos4sin4tab + cos4sin4tabOffset[1], 1024);
+
+ /* cos1sin1tab */
+ Init_cos1sin1tab(cos1sin1tab);
+
+ /* sinWindow */
+ Init_sinWindow(sinWindow + sinWindowOffset[0], 128);
+ Init_sinWindow(sinWindow + sinWindowOffset[1], 1024);
+
+ /* kbdWindow */
+ Init_kbdWindow(kbdWindow + kbdWindowOffset[0], 128);
+ Init_kbdWindow(kbdWindow + kbdWindowOffset[1], 1024);
+
+ /* twidTabEven, twidTabOdd */
+ Init_twidTabs(twidTabEven, twidTabOdd, 512);
+
+ return 0;
+}
+
+/**************************************************************************************
+ * Function: AACFreeTrigtabsFloat
+ *
+ * Description: free any memory allocated by AACInitTrigtabsFloat()
+ *
+ * Inputs: none
+ *
+ * Outputs: none
+ *
+ * Return: none
+ **************************************************************************************/
+void AACFreeTrigtabsFloat(void)
+{
+ return;
+}
+
+#endif /* HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT */