summaryrefslogtreecommitdiff
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/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;
+}